|
@@ -163,16 +163,46 @@ public class AndroidApi {
|
|
|
|
|
|
@ApiOperation("订单状态查询接口")
|
|
|
@GetMapping({"/getOrder"})
|
|
|
- public R<Map<Object, Object>> getOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
|
|
|
+ public R<Map<Object, Object>> getOrder(@RequestParam(name = "orderId", required = true) Long orderId) throws Exception {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
- HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
- Order order = orderService.getById(orderId);
|
|
|
- String orderStatus = order.getOrderStatus();
|
|
|
- if ("1" == orderStatus) {
|
|
|
+ String orderStatus = "";
|
|
|
+ String status = wxPayService.wxQueryOrder(orderId + "");
|
|
|
+ UpdateWrapper<Order> orderUpdateWrapper = new UpdateWrapper<>();
|
|
|
+// orderService.upd
|
|
|
+
|
|
|
+ if (status.equals("NOTPAY")) {
|
|
|
+//未支付
|
|
|
+ HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("order", "0");
|
|
|
+ return R.success(resultMap);
|
|
|
+ } else if (status.equals("SUCCESS")) {
|
|
|
+//支付成功
|
|
|
+ HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
+ Order order = orderService.getById(orderId);
|
|
|
ProductConfig productConfig = productConfigService.getProdCfg(order.getOrderSpecs());
|
|
|
resultMap.put("productConfig", productConfig);
|
|
|
+ resultMap.put("order", "1");
|
|
|
+ return R.success(resultMap);
|
|
|
+ } else if (status.equals("REFUND")) {
|
|
|
+//转入退款
|
|
|
+ HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("order", "5");
|
|
|
+ return R.success(resultMap);
|
|
|
+ } else if (status.equals("CLOSED")) {
|
|
|
+//已关闭
|
|
|
+ HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("order", "2");
|
|
|
+ return R.success(resultMap);
|
|
|
}
|
|
|
- resultMap.put("order", order);
|
|
|
+ HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
+// Order order = orderService.getById(orderId);
|
|
|
+// String orderStatus = order.getOrderStatus();
|
|
|
+// if ("1" == orderStatus) {
|
|
|
+// ProductConfig productConfig = productConfigService.getProdCfg(order.getOrderSpecs());
|
|
|
+// resultMap.put("productConfig", productConfig);
|
|
|
+// }
|
|
|
+
|
|
|
+ resultMap.put("order", "0");
|
|
|
|
|
|
return R.success(resultMap);
|
|
|
}
|
|
@@ -292,7 +322,14 @@ public class AndroidApi {
|
|
|
String trade_state = cipherDto.getTrade_state();
|
|
|
Order localOrder = orderService.getById(cipherDto.getOut_trade_no());
|
|
|
localOrder.setUpdateTime(LocalDateTime.now());
|
|
|
- localOrder.setOrderStatus(trade_state);
|
|
|
+ if(trade_state.equals("SUCCESS")){
|
|
|
+ localOrder.setOrderStatus("1");
|
|
|
+ }else if(trade_state.equals("CLOSED")){
|
|
|
+ localOrder.setOrderStatus("2");
|
|
|
+ }else if(trade_state.equals("REFUND")){
|
|
|
+ localOrder.setOrderStatus("5");
|
|
|
+ }
|
|
|
+// localOrder.setOrderStatus(trade_state);
|
|
|
// LocalDateTime parse = LocalDateTime.parse(success_time, dtf);
|
|
|
LocalDateTime localDateTime = DateUtil.parseLocalDateTime(success_time, "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
localOrder.setOrderPayTime(localDateTime);
|
|
@@ -345,20 +382,20 @@ public class AndroidApi {
|
|
|
// 生产异常,发起退款
|
|
|
if (orderStatus == "4") {
|
|
|
//调用微信支付api,发起退款
|
|
|
- int i = wxPayService.wxCloseOrder(orderId);
|
|
|
- if (i == 204) {
|
|
|
+// int i = wxPayService.wxCloseOrder(orderId);
|
|
|
+// if (i == 204) {
|
|
|
// 订单关闭成功,修改本地订单状态
|
|
|
- UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.eq("id", orderId).set("order_status", orderStatus);
|
|
|
- boolean update = orderService.update(updateWrapper);
|
|
|
- return R.success(update);
|
|
|
- } else {
|
|
|
- return R.fail("订单关闭失败,建议等待5秒,然后调用被扫订单结果查询API,查询当前订单的不同状态,决定下一步的操作");
|
|
|
- }
|
|
|
+// UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
|
|
|
+// updateWrapper.eq("id", orderId).set("order_status", orderStatus);
|
|
|
+// boolean update = orderService.update(updateWrapper);
|
|
|
+// return R.success(update);
|
|
|
+// } else {
|
|
|
+// return R.fail("订单关闭失败,建议等待5秒,然后调用被扫订单结果查询API,查询当前订单的不同状态,决定下一步的操作");
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (orderStatus == "5") {
|
|
|
+ if (orderStatus == "3") {
|
|
|
UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.eq("id", orderId).set("order_status", orderStatus);
|
|
|
boolean update = orderService.update(updateWrapper);
|