Browse Source

更新回调和配置文件

liu 10 months ago
parent
commit
477b7878ee

+ 35 - 79
src/main/java/com/sqx/modules/callBack/controller/CallBackController.java

@@ -1,6 +1,7 @@
 package com.sqx.modules.callBack.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.sqx.common.constant.RedisKey;
 import com.sqx.common.exception.SqxException;
@@ -9,6 +10,8 @@ import com.sqx.modules.app.service.UserService;
 import com.sqx.modules.callBack.dto.CallBackDto;
 import com.sqx.modules.errand.entity.TbIndent;
 import com.sqx.modules.errand.service.TbIndentService;
+import com.sqx.modules.order.entity.TbOrder;
+import com.sqx.modules.order.service.AppOrderService;
 import lombok.extern.slf4j.Slf4j;
 import org.checkerframework.checker.units.qual.A;
 import org.redisson.api.RLock;
@@ -29,7 +32,7 @@ import java.io.InputStreamReader;
 @RestController
 @RequestMapping("/back")
 @Slf4j
-public class CallBackController{
+public class CallBackController {
 
     @Autowired
     TbIndentService tbIndentService;
@@ -37,96 +40,49 @@ public class CallBackController{
     @Autowired
     UserService userService;
 
-
-
-    /**
-     * 回调
-     */
-//    @PostMapping("/open")
-//    public String back(HttpServletResponse response, HttpServletRequest httpServletRequest)throws IOException {
-//        BufferedReader streamReader = new BufferedReader(new InputStreamReader(httpServletRequest.getInputStream(), "UTF-8"));
-//        StringBuilder responseStrBuilder = new StringBuilder();
-//        String inputStr;
-//        while ((inputStr = streamReader.readLine()) != null) {
-//            responseStrBuilder.append(inputStr);
-//        }
-//
-//        JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
-//        log.info("回调收到的参数 = " + jsonObject);
-//        if (ObjectUtils.isNotEmpty(jsonObject)) {
-//
-////            订单号
-//            String orderNo = jsonObject.getString("order_no");
-////            配送员名称
-//            String courier = jsonObject.getString("courier");
-////            手机号
-//            String tel = jsonObject.getString("tel");
-////            更改时间
-//            String updateTime = jsonObject.getString("update_time");
-//
-//            UserEntity userEntity = userService.queryByPhone(tel);
-//            if (ObjectUtils.isEmpty(userEntity)) {
-//                log.info("不存在该手机号的骑手:"+tel);
-//                return "success";
-//            }
-//
-////            获取骑手订单
-//            TbIndent tbIndent = tbIndentService.findIndentByIndentNumber(orderNo);
-//            if (ObjectUtils.isEmpty(tbIndent)) {
-//                log.info("不存在该配送订单:"+orderNo);
-//                return "success";
-//            }
-//
-//            //            状态
-//            String state = jsonObject.getString("state");
-//            if ("4".equals(state)) {//接单
-//                log.info("骑手接单:"+orderNo);
-//                tbIndentService.indentReceiving(userEntity.getUserId(),orderNo);
-//            }else if ("5".equals(state)){//取餐
-//                log.info("骑手取餐:"+orderNo);
-//               tbIndentService.riderBuyGoods(tbIndent);
-//            }else if ("6".equals(state)){//完成订单
-//                log.info("骑手完成订单:"+orderNo);
-//                tbIndentService.finalizeOrder(userEntity.getUserId(),tbIndent);
-//            }
-//        }
-//        return "success";
-//    }
+    @Autowired
+    AppOrderService appOrderService;
 
 
     /**
      * 回调
      */
     @PostMapping("/open")
-    public String back(String expire_time,String sign,String trade_no,String order_no,String state,String note,String courier,String longitude,String latitude,String tel,String update_time){
+    public String back(String expire_time, String sign, String trade_no, String order_no, String state, String note, String courier, String longitude, String latitude, String tel, String update_time) {
 
-            UserEntity userEntity = userService.queryByPhone(tel);
-            if (ObjectUtils.isEmpty(userEntity)) {
-                log.info("不存在该手机号的骑手:"+tel);
-                return "success";
-            }
+        UserEntity userEntity = userService.queryByPhone(tel);
+        if (ObjectUtils.isEmpty(userEntity)) {
+            log.info("不存在该手机号的骑手:" + tel);
+            return "success";
+        }
 
 //            获取骑手订单
-            TbIndent tbIndent = tbIndentService.findIndentByIndentNumber(order_no);
-            if (ObjectUtils.isEmpty(tbIndent)) {
-                log.info("不存在该配送订单:"+order_no);
-                return "success";
-            }
+        TbIndent tbIndent = tbIndentService.findIndentByIndentNumber(order_no);
+        if (ObjectUtils.isEmpty(tbIndent)) {
+            log.info("不存在该配送订单:" + order_no);
+            return "success";
+        }
 
-            //            状态
-            if ("4".equals(state)) {//接单
-                log.info("骑手接单:"+order_no);
-                tbIndentService.indentReceiving(userEntity.getUserId(),order_no);
-            }else if ("5".equals(state)){//取餐
-                log.info("骑手取餐:"+order_no);
-                tbIndentService.riderBuyGoods(tbIndent);
-            }else if ("6".equals(state)){//完成订单
-                log.info("骑手完成订单:"+order_no);
-                tbIndentService.finalizeOrder(userEntity.getUserId(),tbIndent);
-            }
+//            获取订单id
+        TbOrder tbOrder = appOrderService.getOne(new QueryWrapper<TbOrder>().eq("order_number", order_no));
+        if (ObjectUtils.isEmpty(tbOrder)) {
+            log.info("不存在该订单:" + order_no);
             return "success";
+        }
+
+        //            状态
+        if ("4".equals(state)) {//接单
+            log.info("骑手接单:" + order_no);
+            tbIndentService.orderIndentReceiving(userEntity.getUserId(), tbOrder.getOrderId()+"");
+        } else if ("5".equals(state)) {//取餐
+            log.info("骑手取餐:" + order_no);
+            tbIndentService.riderBuyGoods(tbIndent);
+        } else if ("6".equals(state)) {//完成订单
+            log.info("骑手完成订单:" + order_no);
+            tbIndentService.finalizeOrder(userEntity.getUserId(), tbIndent);
+        }
+        return "success";
     }
 
 
-
 }

+ 1 - 1
src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java

@@ -712,7 +712,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
                 if (!"2".equals(tbIndent.getIndentState())) {
                     return Result.error("订单已被抢走!");
                 }
-                if ("4".equals(tbIndent.getIndentType())) {
+                if ("5".equals(tbIndent.getIndentType())) {
                     tbIndentDao.indentReceiv(userId, indentNumber, format, "4");
                     TransferRecordEntity tr = new TransferRecordEntity();
                     tr.setUserId(userEntity1.getUserId());

+ 4 - 4
src/main/resources/application-dev.yml

@@ -124,11 +124,11 @@ sftp:
 
 dynamic:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://172.16.20.104:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
-#    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+#    url: jdbc:mysql://172.16.20.104:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
     username: root
-    password: ch@2025.wm
-#    password: chuanghai@2024
+#    password: ch@2025.wm
+    password: chuanghai@2024
     initial-size: 15
     max-active: 100
     min-idle: 10