|
|
@@ -27,6 +27,7 @@ import java.io.IOException;
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
@RestController
|
|
|
+@RequestMapping("/back")
|
|
|
@Slf4j
|
|
|
public class CallBackController{
|
|
|
|
|
|
@@ -36,34 +37,68 @@ public class CallBackController{
|
|
|
@Autowired
|
|
|
UserService userService;
|
|
|
|
|
|
- @Resource
|
|
|
- private RedissonClient redissonClient;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 回调
|
|
|
*/
|
|
|
- @RequestMapping("/back/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");
|
|
|
+// @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";
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回调
|
|
|
+ */
|
|
|
+ @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){
|
|
|
|
|
|
UserEntity userEntity = userService.queryByPhone(tel);
|
|
|
if (ObjectUtils.isEmpty(userEntity)) {
|
|
|
@@ -72,31 +107,26 @@ public class CallBackController{
|
|
|
}
|
|
|
|
|
|
// 获取骑手订单
|
|
|
- TbIndent tbIndent = tbIndentService.findIndentByIndentNumber(orderNo);
|
|
|
+ TbIndent tbIndent = tbIndentService.findIndentByIndentNumber(order_no);
|
|
|
if (ObjectUtils.isEmpty(tbIndent)) {
|
|
|
- log.info("不存在该配送订单:"+orderNo);
|
|
|
+ log.info("不存在该配送订单:"+order_no);
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
// 状态
|
|
|
- String state = jsonObject.getString("state");
|
|
|
if ("4".equals(state)) {//接单
|
|
|
- log.info("骑手接单:"+orderNo);
|
|
|
- tbIndentService.indentReceiving(userEntity.getUserId(),orderNo);
|
|
|
+ log.info("骑手接单:"+order_no);
|
|
|
+ tbIndentService.indentReceiving(userEntity.getUserId(),order_no);
|
|
|
}else if ("5".equals(state)){//取餐
|
|
|
- log.info("骑手取餐:"+orderNo);
|
|
|
- tbIndentService.riderBuyGoods(tbIndent);
|
|
|
+ log.info("骑手取餐:"+order_no);
|
|
|
+ tbIndentService.riderBuyGoods(tbIndent);
|
|
|
}else if ("6".equals(state)){//完成订单
|
|
|
- log.info("骑手完成订单:"+orderNo);
|
|
|
+ log.info("骑手完成订单:"+order_no);
|
|
|
tbIndentService.finalizeOrder(userEntity.getUserId(),tbIndent);
|
|
|
}
|
|
|
- }
|
|
|
- return "success";
|
|
|
+ return "success";
|
|
|
}
|
|
|
|
|
|
- public String back2(@RequestBody CallBackDto callBackDto)throws IOException {
|
|
|
- log.info("callBackDto = " + callBackDto);
|
|
|
- return "success";
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|