yumeng 1 year ago
parent
commit
d79b8d1d63

+ 14 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -33,6 +33,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @RestController
 @RequestMapping("/isv/supply_chain")
@@ -1883,13 +1885,23 @@ public class SupplyChainController extends BaseController {
         supplyChainService.addList(beginDate, endDate, null);
     }
 
-
+    static ExecutorService fxNowService = Executors.newFixedThreadPool(3);
     @PostMapping(value = "/accept")
     public Map<String, Object> acceptEvent(@RequestBody String eventsEncoded) {
        // System.err.println(eventsEncoded);
         try {
             String events = PlatformEventSecurityUtil.decode(eventsEncoded, "JRowMMndTkSlvVORNvtJbw==");
-            System.err.println(events);
+            JSONObject eventJSon = JSONObject.parseObject(events);
+            fxNowService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        supplyChainService.updateOrder(eventJSon);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
         } catch (KsMerchantApiException e) {
             e.printStackTrace();
         }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -145,4 +145,6 @@ public interface SupplyChainMapper {
     List<JSONObject> exportBindOrder(Map<String, Object> requestMap);
 
     void replaceAll(@Param("list") List<KuaishouSupplyChain> list);
+
+    void updateOrder(@Param("oid") Long oid, @Param("cpsOrderStatus") Long cpsOrderStatus);
 }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/ISupplyChainService.java

@@ -166,4 +166,6 @@ public interface ISupplyChainService {
     List<JSONObject> exportBindOrder(Map<String, Object> requestMap);
 
     void addList(String beginDate, String endDate,String pcursor);
+
+    void updateOrder(JSONObject eventJSon);
 }

+ 14 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -408,6 +408,20 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
         }
     }
 
+    @Override
+    public void updateOrder(JSONObject eventJSon) {
+
+        JSONObject info = eventJSon.getJSONObject("info");
+        if (!Check.isNull(info)) {
+            Long oid = info.getLong("oid");
+            Long cpsOrderStatus = info.getLong("cpsOrderStatus");
+            supplyChainMapper.updateOrder(oid, cpsOrderStatus);
+            log.info("订单ID:{},状态:{} 修改成功", oid, cpsOrderStatus);
+        }
+
+
+    }
+
     private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Map<Long, Long> itemMap) {
         List<KuaishouSupplyChain> list = new ArrayList<>();
         String appKey = accessToken.getAppKey();

+ 23 - 8
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -8,6 +8,13 @@
             value
             (#{itemId},#{userId},#{nikeName})
     </insert>
+    <update id="updateOrder">
+
+    update kuaishou_supply_chain set order_status = #{cpsOrderStatus}
+    where oid = #{oid}
+
+
+    </update>
     <delete id="unbindUser" parameterType="java.lang.Long">
         delete
         from kuaishou_item_bind_user
@@ -156,7 +163,8 @@
         sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
         round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
         sum(case when t1.send_status = 1 then 1 else 0 end) as 'deliveryNum',
-        round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when t1.order_status != 80
+        round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
+        t1.order_status != 80
         then 1 else 0 end),4) as 'shippingGreen',
         sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
         sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
@@ -888,7 +896,8 @@
         sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
         round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
         sum(case when t2.send_status = 1 then 1 else 0 end) as 'deliveryNum',
-        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when t2.order_status != 80
+        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
+        t2.order_status != 80
         then 1 else 0 end),4) as 'shippingGreen',
         sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
         sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
@@ -963,7 +972,8 @@
         END
         ) AS 'deliveryNum',
 
-        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when t2.order_status != 80
+        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
+        t2.order_status != 80
         then 1 else 0 end),4) as 'shippingGreen',
 
         sum(
@@ -1136,7 +1146,8 @@
         END
         ) AS 'deliveryNum',
 
-        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when t2.order_status != 80
+        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
+        t2.order_status != 80
         then 1 else 0 end),4) as 'shippingGreen',
 
         sum(
@@ -1580,7 +1591,8 @@
         (
         SELECT
         IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
-        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS 'regimentalPromotionAmount'
+        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
+        'regimentalPromotionAmount'
         FROM bytedance_order_list t1
         WHERE flow_point != 'REFUND'
         <if test='promoterIds != null and promoterIds.size() > 0'>
@@ -1595,7 +1607,8 @@
         (
         SELECT
         IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
-        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS 'regimentalPromotionAmount'
+        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
+        'regimentalPromotionAmount'
         FROM bytedance_order_list t1
         WHERE flow_point != 'REFUND'
         <if test='promoterIds != null and promoterIds.size() > 0'>
@@ -1668,7 +1681,8 @@
         (
         SELECT
         IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
-        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS 'regimentalPromotionAmount',
+        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
+        'regimentalPromotionAmount',
         COUNT(order_id) as 'orderCount'
         FROM bytedance_order_list t1
         WHERE flow_point != 'REFUND'
@@ -1686,7 +1700,8 @@
         (
         SELECT
         IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
-        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS 'regimentalPromotionAmount',
+        IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
+        'regimentalPromotionAmount',
         COUNT(order_id) as 'orderCount'
         FROM bytedance_order_list t1
         WHERE flow_point != 'REFUND'