瀏覽代碼

订单增加接口

周箭河 5 年之前
父節點
當前提交
c4b1343a91

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -292,7 +292,7 @@
     <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
         SELECT * FROM student_payment_order
         WHERE status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND payment_channel_ =
-        #{paymentChannel}
+        #{paymentChannel} LIMIT 100
     </select>
 
     <!-- 查询支付中超时订单 -->

+ 60 - 9
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -51,6 +51,8 @@ public class StudentOrderController extends BaseController {
     private MusicGroupService musicGroupService;
     @Autowired
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
+    @Autowired
+    YqPayFeignService yqPayFeignService;
 
     @PostMapping("/notify")
     public Msg notify(@ModelAttribute Msg msg) throws Exception {
@@ -94,16 +96,16 @@ public class StudentOrderController extends BaseController {
             return failed("未找到指定订单");
         }
         HashMap<String, Object> orderDetail = new HashMap<>();
-        orderDetail.put("order",orderByOrderNo);
-        orderDetail.put("groupType",orderByOrderNo.getGroupType());
-        if(orderByOrderNo.getGroupType().equals(GroupType.MUSIC)){
+        orderDetail.put("order", orderByOrderNo);
+        orderDetail.put("groupType", orderByOrderNo.getGroupType());
+        if (orderByOrderNo.getGroupType().equals(GroupType.MUSIC)) {
             MusicGroup musicGroup = musicGroupService.get(orderByOrderNo.getMusicGroupId());
             List<Goods> goodsList = studentPaymentOrderDetailService.findApplyOrderGoods(orderByOrderNo.getId());
-            orderDetail.put("goods",goodsList);
-            orderDetail.put("course",musicGroup.getCourseForm());
-        }else if(orderByOrderNo.getGroupType().equals(GroupType.VIP)){
+            orderDetail.put("goods", goodsList);
+            orderDetail.put("course", musicGroup.getCourseForm());
+        } else if (orderByOrderNo.getGroupType().equals(GroupType.VIP)) {
             VipBuyResultDto vipBuyResultInfo = vipGroupService.findVipBuyResultInfo(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
-            orderDetail.put("detail",vipBuyResultInfo);
+            orderDetail.put("detail", vipBuyResultInfo);
         }
 
         return succeed(orderDetail);
@@ -202,7 +204,7 @@ public class StudentOrderController extends BaseController {
 
     }
 
-//    @Scheduled(cron = "0/30 * * * * ?")
+    //    @Scheduled(cron = "0/30 * * * * ?")
     @GetMapping("/setSuccessStatus")
     public void setSuccessStatus() throws Exception {
         List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "YQPAY");
@@ -221,7 +223,7 @@ public class StudentOrderController extends BaseController {
             if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
                 try {
                     studentPaymentOrderService.updateOrder(rpMap); //更新订单
-                }catch (Exception e){
+                } catch (Exception e) {
                     e.printStackTrace();
                     continue;
                 }
@@ -230,4 +232,53 @@ public class StudentOrderController extends BaseController {
 
     }
 
+    @GetMapping("/fixOrder")
+    private void fixOrder() throws Exception {
+        List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.SUCCESS, "YQPAY");
+
+        if (payingOrders.size() == 0) {
+            return;
+        }
+        String merOrderNos = payingOrders.stream().map(StudentPaymentOrder::getOrderNo).collect(Collectors.joining(","));
+
+        String notifyUrl = ""; //回调地址
+        Map<String, Object> resultMap = new LinkedHashMap<>();
+        resultMap.put("merOrderNoList", merOrderNos);
+        Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
+
+        RsqMsg rsqMsg = new RsqMsg(requestMap);
+
+        Msg queryRs = yqPayFeignService.orderQuery(rsqMsg);
+
+        if (queryRs.getCode().equals("88")) {
+            String responseParameters = queryRs.getResponseParameters();
+            List<Map<String, Object>> responseList = JSON.parseObject(responseParameters, List.class);
+            for (Map<String, Object> response : responseList) {
+                String type = "per";
+                String orderNo = (String) response.get("merOrderNo");
+                String tempRoutingResultList = response.get("tempRoutingResultList").toString();
+                System.out.println(tempRoutingResultList);
+
+                if (tempRoutingResultList.contains("武汉大雅乐盟教育咨询有限公司")) {
+                    type = "com";
+                }
+                fixUpdateOrder(orderNo,type);
+            }
+        }
+    }
+
+    void fixUpdateOrder(String orderNo,String type) {
+        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(orderNo);
+        if(type.equals("com")){
+            order.setComAmount(order.getActualAmount());
+            order.setPerAmount(BigDecimal.ZERO);
+            order.setMerNos("0023115");
+        }else {
+            order.setComAmount(BigDecimal.ZERO);
+            order.setPerAmount(order.getActualAmount());
+            order.setMerNos("0031215");
+        }
+        studentPaymentOrderService.update(order);
+    }
+
 }