|
@@ -1,6 +1,7 @@
|
|
|
package com.sqx.modules.callBack.controller;
|
|
package com.sqx.modules.callBack.controller;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.sqx.common.constant.RedisKey;
|
|
import com.sqx.common.constant.RedisKey;
|
|
|
import com.sqx.common.exception.SqxException;
|
|
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.callBack.dto.CallBackDto;
|
|
|
import com.sqx.modules.errand.entity.TbIndent;
|
|
import com.sqx.modules.errand.entity.TbIndent;
|
|
|
import com.sqx.modules.errand.service.TbIndentService;
|
|
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 lombok.extern.slf4j.Slf4j;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.redisson.api.RLock;
|
|
import org.redisson.api.RLock;
|
|
@@ -29,7 +32,7 @@ import java.io.InputStreamReader;
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/back")
|
|
@RequestMapping("/back")
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
-public class CallBackController{
|
|
|
|
|
|
|
+public class CallBackController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
TbIndentService tbIndentService;
|
|
TbIndentService tbIndentService;
|
|
@@ -37,96 +40,49 @@ public class CallBackController{
|
|
|
@Autowired
|
|
@Autowired
|
|
|
UserService userService;
|
|
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")
|
|
@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";
|
|
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";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|