Browse Source

rider交通工具

licailing 5 years ago
parent
commit
dd98175dd4

+ 3 - 0
src/main/java/com/izouma/dingdong/config/KsherPaySdk.java

@@ -160,6 +160,9 @@ public class KsherPaySdk {
         params.put("nonce_str", RandomStringUtils.randomAlphanumeric(4));
         params.put("nonce_str", RandomStringUtils.randomAlphanumeric(4));
         params.put("time_stamp", timeStampFormat.format(new Date()));
         params.put("time_stamp", timeStampFormat.format(new Date()));
 
 
+        //回调
+        params.put("notify_url","");
+
         List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
         List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
         for (Iterator iter = params.keySet().iterator(); iter.hasNext(); ) {
         for (Iterator iter = params.keySet().iterator(); iter.hasNext(); ) {
             String name = (String) iter.next();
             String name = (String) iter.next();

+ 6 - 3
src/main/java/com/izouma/dingdong/domain/rider/Rider.java

@@ -39,11 +39,14 @@ public class Rider extends BaseEntity {
 //    @ApiModelProperty(value = "签到", name = "signIn")
 //    @ApiModelProperty(value = "签到", name = "signIn")
 //    private Boolean signIn;
 //    private Boolean signIn;
 
 
+    @ApiModelProperty(value = "交通工具",name = "transportation")
+    private String transportation;
+
     @ApiModelProperty(value = "摩托车图片", name = "motorcycle")
     @ApiModelProperty(value = "摩托车图片", name = "motorcycle")
-    private String motorcycleImg;
+    private String transportationImg;
 
 
-    @ApiModelProperty(value = "车牌照片", name = "licensePlateImg")
-    private String licensePlateImg;
+/*    @ApiModelProperty(value = "车牌照片", name = "licensePlateImg")
+    private String licensePlateImg;*/
 
 
     @ApiModelProperty(value = "驾照照片",name = "driverLicenseImg")
     @ApiModelProperty(value = "驾照照片",name = "driverLicenseImg")
     private String driverLicenseImg;
     private String driverLicenseImg;

+ 19 - 0
src/main/java/com/izouma/dingdong/enums/Transportation.java

@@ -0,0 +1,19 @@
+package com.izouma.dingdong.enums;
+
+public enum Transportation {
+    /*
+    摩托车
+     */
+
+    /*
+    电动车
+     */
+
+    /*
+    其他
+     */
+
+    /*
+    没有
+     */
+}

+ 13 - 10
src/main/java/com/izouma/dingdong/service/ConsumptionService.java

@@ -59,8 +59,8 @@ public class ConsumptionService {
         }
         }
         try {
         try {
             //调app支付
             //调app支付
-            String request = ksherPaySdk.AppPay(mchOrderNo, feeType, channel, subOpenid, properties.getAppId(), total);
-            success(mchOrderNo, channel, total, request);
+            ksherPaySdk.AppPay(mchOrderNo, feeType, channel, subOpenid, properties.getAppId(), total);
+//            success(mchOrderNo, channel, total, request);
         } catch (Exception e) {
         } catch (Exception e) {
             log.info("支付异常", e);
             log.info("支付异常", e);
             throw new BusinessException(e.getMessage());
             throw new BusinessException(e.getMessage());
@@ -86,8 +86,8 @@ public class ConsumptionService {
         //内容
         //内容
         String productName = "购买商品";
         String productName = "购买商品";
         try {
         try {
-            String request = ksherPaySdk.GatewayPay(mchOrderNo, feeType, channelList, mchCode, null, null, productName, null, device, total);
-            success(mchOrderNo, channelList, total, request);
+            ksherPaySdk.GatewayPay(mchOrderNo, feeType, channelList, mchCode, null, null, productName, null, device, total);
+//            success(mchOrderNo, channelList, total, request);
         } catch (Exception e) {
         } catch (Exception e) {
             log.info("支付异常", e);
             log.info("支付异常", e);
             throw new BusinessException(e.getMessage());
             throw new BusinessException(e.getMessage());
@@ -119,8 +119,8 @@ public class ConsumptionService {
         }
         }
         try {
         try {
             //调小程序支付
             //调小程序支付
-            String request = ksherPaySdk.MiniproPay(mchOrderNo, feeType, channel, subOpenid, properties.getAppId(), total);
-            success(mchOrderNo, channel, total, request);
+            ksherPaySdk.MiniproPay(mchOrderNo, feeType, channel, subOpenid, properties.getAppId(), total);
+//            success(mchOrderNo, channel, total, request);
         } catch (Exception e) {
         } catch (Exception e) {
             log.info("支付异常", e);
             log.info("支付异常", e);
             throw new BusinessException(e.getMessage());
             throw new BusinessException(e.getMessage());
@@ -136,16 +136,16 @@ public class ConsumptionService {
         String mchRefundNo = String.valueOf(new SnowflakeIdWorker(1, 1).nextId());
         String mchRefundNo = String.valueOf(new SnowflakeIdWorker(1, 1).nextId());
         try {
         try {
             //全部退款
             //全部退款
-            String request = ksherPaySdk.OrderRefund(mchRefundNo, feeType, feeRecord.getMchNo(), feeRecord.getTotalFee(), feeRecord
+            ksherPaySdk.OrderRefund(mchRefundNo, feeType, feeRecord.getMchNo(), feeRecord.getTotalFee(), feeRecord
                     .getTotalFee());
                     .getTotalFee());
-            success(mchRefundNo, feeRecord.getChannel(), feeRecord.getTotalFee(), request);
+//            success(mchRefundNo, feeRecord.getChannel(), feeRecord.getTotalFee(), request);
         } catch (Exception e) {
         } catch (Exception e) {
             log.info("退款异常", e);
             log.info("退款异常", e);
             throw new BusinessException(e.getMessage());
             throw new BusinessException(e.getMessage());
         }
         }
     }
     }
 
 
-    private void success(String mchOrderNo, String channel, Integer total, String request) {
+/*    private void success(String mchOrderNo, String channel, Integer total, String request) {
         JSONObject json = JSONObject.parseObject(request);
         JSONObject json = JSONObject.parseObject(request);
         String result = json.getJSONObject("data").getString("result");
         String result = json.getJSONObject("data").getString("result");
         if ("SUCCESS".equals(result)) {
         if ("SUCCESS".equals(result)) {
@@ -158,8 +158,11 @@ public class ConsumptionService {
                     .mchNo(mchOrderNo)
                     .mchNo(mchOrderNo)
                     .enabled(true)
                     .enabled(true)
                     .build();
                     .build();
+
+        } else {
+            throw new BusinessException("支付失败");
         }
         }
-    }
+    }*/
 
 
 
 
 }
 }

+ 79 - 0
src/main/java/com/izouma/dingdong/web/PayConsumptionController.java

@@ -0,0 +1,79 @@
+package com.izouma.dingdong.web;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.izouma.dingdong.domain.FeeRecord;
+import com.izouma.dingdong.service.ConsumptionService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.MapUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static com.alibaba.fastjson.serializer.SerializerFeature.PrettyFormat;
+
+@RestController
+@RequestMapping("/pay")
+@AllArgsConstructor
+@Slf4j
+public class PayConsumptionController {
+    private ConsumptionService consumptionService;
+
+    /**
+     * 支付回调
+     * @param request
+     * @param response
+     * @return
+     */
+    @PostMapping(value = "/notify",produces = "application/json; charset=utf-8")
+    public Map<?,?> notify(HttpServletRequest request, HttpServletResponse response) {
+        Map<String, String> params = new HashMap<>();
+        Set<Map.Entry<String, String[]>> entrySet = request.getParameterMap().entrySet();
+
+        for (Map.Entry<String, String[]> entry : entrySet) {
+            String name = entry.getKey();
+            String[] values = entry.getValue();
+            int valLen = values.length;
+
+            if (valLen == 1) {
+                params.put(name, values[0]);
+            } else if (valLen > 1) {
+                StringBuilder sb = new StringBuilder();
+                for (String val : values) {
+                    sb.append(",").append(val);
+                }
+                params.put(name, sb.toString().substring(1));
+            } else {
+                params.put(name, "");
+            }
+        }
+        log.info("ksher支付回调 {}", JSON.toJSONString(params, PrettyFormat));
+        if (MapUtils.getString(params, "result").equals("SUCCESS")) {
+            JSONObject body = JSON.parseObject(params.get("data"));
+/*            FeeRecord.builder()
+                    .channel(channel)
+                    .feeType(feeType)
+                    .isRefund(false)
+                    .totalFee(total)
+                    .isPay(true)
+                    .mchNo(mchOrderNo)
+                    .enabled(true)
+                    .build();*/
+        }
+
+
+        // 注意:必须按这个结构返回
+        Map<String, String> result = new HashMap<>();
+        result.put("result", "SUCCESS");
+        result.put("msg", "OK");
+        return result;
+    }
+}

+ 1 - 0
src/main/resources/application.yaml

@@ -74,6 +74,7 @@ aliyun:
     oss-domain: https://idingdong.oss-cn-hangzhou.aliyuncs.com
     oss-domain: https://idingdong.oss-cn-hangzhou.aliyuncs.com
 general:
 general:
     host: http://dingdong.izouma.com
     host: http://dingdong.izouma.com
+    notify-url: http://dingdong.izouma.com/alipay/notify
 ksher:
 ksher:
     appid:
     appid:
     private_key:
     private_key: