Browse Source

Merge remote-tracking branch 'origin/master'

yumeng 7 months ago
parent
commit
72f1d1d3f2

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

@@ -2243,12 +2243,6 @@ public class SupplyChainController extends BaseController {
             String events = PlatformEventSecurityUtil.decode(eventsEncoded, "xjX0jX828wWrnnwt26UYDA==");
             logger.info("-KWaiShop-订单-消息-订阅-");
             JSONObject eventJSon = JSONObject.parseObject(events);
-           /* List<String> list = new ArrayList<>();
-            list.add("kwaishop_order_deliverySuccess");//已收货消息
-            list.add("kwaishop_order_paySuccess");//已支付消息
-            list.add("kwaishop_order_delivering");//已发货消息
-            list.add("kwaishop_order_orderFail");//交易失败消息
-            list.add("kwaishop_order_orderSuccess");//交易成功消息*/
             orderNewsService.submit(new Runnable() {
                 @Override
                 public void run() {
@@ -2259,7 +2253,8 @@ public class SupplyChainController extends BaseController {
                             if ("kwaishop_order_addOrder".equals(event)) {
                                 orderCursorListService.insertKWaiShopOrder(eventJSon);
                             } else if (EVENT_LIST.contains(event)) {
-                                //状态变更 kwaixiaodian_order_cursor_list
+//                                logger.info("-KWaiShop----报文------------\n{}",eventJSon);
+                                //状态变更以及对应状态时间 kwaixiaodian_order_cursor_list
                                 orderCursorListService.updateKWaiShopOrderStatus(eventJSon);
                             }
                         }

+ 13 - 5
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KwaixiaodianOrderCursorList.java

@@ -1,6 +1,5 @@
 package com.ruixuan.isc.entity;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
@@ -514,7 +513,9 @@ public class KwaixiaodianOrderCursorList {
         JSONObject orderBaseInfo = object.getJSONObject("orderBaseInfo");
         if (Check.isNotNull(orderBaseInfo)) {
             this.setOid(orderBaseInfo.getLong("oid"));
-            this.setPayTime(orderBaseInfo.getLong("payTime"));
+            if (!Check.isNull(orderBaseInfo.getLong("payTime"))) {
+                this.setPayTime(Long.valueOf(DateUtils.timestamptoStr(orderBaseInfo.getLong("payTime"))));
+            }
             this.setBuyerImage(orderBaseInfo.getString("buyerImage"));
             this.setBuyerOpenId(orderBaseInfo.getString("buyerOpenId"));
             this.setBuyerNick(orderBaseInfo.getString("buyerNick"));
@@ -522,8 +523,13 @@ public class KwaixiaodianOrderCursorList {
             this.setDiscountFee(orderBaseInfo.getLong("discountFee"));
             this.setTotalFee(orderBaseInfo.getLong("totalFee"));
             this.setStatus(orderBaseInfo.getLong("status"));
-            this.setSendTime(orderBaseInfo.getLong("sendTime"));
-            this.setRefundTime(orderBaseInfo.getLong("refundTime"));
+            if (!Check.isNull(orderBaseInfo.getLong("sendTime"))) {
+                this.setSendTime(Long.valueOf(DateUtils.timestamptoStr(orderBaseInfo.getLong("sendTime"))));
+            }
+            if (!Check.isNull(orderBaseInfo.getLong("refundTime"))) {
+                this.setRefundTime(Long.valueOf(DateUtils.timestamptoStr(orderBaseInfo.getLong("refundTime"))));
+            }
+
             this.setCreateTime(orderBaseInfo.getString("createTime"));
             this.setStatDate(Long.valueOf(DateUtils.timestamptoStr(orderBaseInfo.getLong("createTime"))));
             this.setStatHour(DateUtils.timestamptoHour(orderBaseInfo.getLong("createTime")));
@@ -534,7 +540,9 @@ public class KwaixiaodianOrderCursorList {
             this.setCpsType(orderBaseInfo.getLong("cpsType"));
             this.setValidPromiseShipmentTimeStamp(orderBaseInfo.getLong("validPromiseShipmentTimeStamp"));
             this.setPreSale(orderBaseInfo.getLong("preSale"));
-            this.setRecvTime(orderBaseInfo.getLong("recvTime"));
+            if (!Check.isNull(orderBaseInfo.getLong("recvTime"))) {
+                this.setRecvTime(Long.valueOf(DateUtils.timestamptoStr(orderBaseInfo.getLong("recvTime"))));
+            }
             this.setCoType(orderBaseInfo.getLong("coType"));
             this.setCommentStatus(orderBaseInfo.getLong("commentStatus"));
             this.setPayType(orderBaseInfo.getLong("payType"));

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KwaixiaodianOrderCursorListMapper.java

@@ -20,7 +20,7 @@ public interface KwaixiaodianOrderCursorListMapper {
 
     void insertKWaixiaodianOrderCursorList(@Param("order") KwaixiaodianOrderCursorList order);
 
-    int updateKWaiShopOrderStatus(@Param("oid") Long oid, @Param("status") Integer status);
+    int updateKWaiShopOrderStatus(Map<String, Object> map);
 
     KwaixiaodianShopScore getScore(@Param("shopId") String shopId);
 

+ 47 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -14,6 +14,7 @@ import com.ruixuan.common.utils.RedisUtil;
 import com.ruixuan.common.utils.Result;
 import com.ruixuan.common.utils.file.FileUtil;
 import com.ruixuan.common.utils.http.HttpUtil;
+import com.ruixuan.common.weixin.CorpWexinUtils;
 import com.ruixuan.data.utils.ExportExcelUtils;
 import com.ruixuan.isc.entity.FirstDeliveryValidMaterials;
 import com.ruixuan.isc.entity.JYKuaishouPromoter;
@@ -87,6 +88,9 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     @Autowired
     private IKuaishouItemCollectSamplesService kuaishouItemCollectSamplesService;
 
+    @Autowired
+    private CorpWexinUtils corpWexinUtils;
+
     /**
      * 查询快手达人 信息列表
      *
@@ -391,6 +395,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateKuaishouPromoterByPromoterId(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -398,6 +404,31 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         }
     }
 
+    private void stToken(String key) {
+        String value = (String) redisUtil.get(key);
+        if (Check.isNotNull(value)) {
+            Integer times = Integer.valueOf(value);
+            redisUtil.set(key, times + 1, 60 * 60 * 24);
+            sendNotice(times);
+        } else {
+            redisUtil.set(key, "1", 60 * 60 * 24);
+        }
+    }
+
+    private void sendNotice(Integer times) {
+        if (times >= 1 && times < 5) {
+            //发送token失效通知
+            String date = DateUtils.getDate();
+            JSONObject weChat = new JSONObject();
+            weChat.put("wexin_id", "RenYuPeng");
+            weChat.put("corp_id", "ww24b8a47826f5875f");
+            StringBuilder text = new StringBuilder();
+            text.append("达人更新token失效通知:").append("<br/>").append("达人token已失效,请及时更新token");
+            corpWexinUtils.sendMessage(weChat, text.toString());
+        }
+
+    }
+
     /**
      * 同步更新数据
      */
@@ -445,6 +476,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateKuaishouPromoterByPromoterId3(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -499,6 +532,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateMiaogousiKuaishouPromoterByPromoterId(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -552,6 +587,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateRocketKuaishouPromoterByPromoterId(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -605,6 +642,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateYufuKuaishouPromoterByPromoterId(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -657,6 +696,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateYuxiuKuaishouPromoterByPromoterId(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -710,6 +751,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 kuaishouPromoterMapper.updateZhishuiKuaishouPromoterByPromoterId(kuaishouPromoter);
             } else {
                 log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+                String key = DateUtils.getDate() + "_token_invalid";
+                stToken(key);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -775,6 +818,9 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
 
     @Override
     public Result supplementInfo() {
+        String key = DateUtils.getDate() + "_token_invalid";
+        redisUtil.del(key);
+
         List<String> promoters = new ArrayList<>();
         List<KuaishouPromoter> list = kuaishouPromoterMapper.getFailInfo();
         if (!Check.isNull(list)) {
@@ -793,6 +839,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         promoters.add(yufuInfo());
         promoters.add(yuxiuInfo());
         promoters.add(zhishuiInfo());
+
         return Result.success("达人数据更新 -------------<睿选>共计:" + list.size() + "条", promoters);
     }
 

+ 21 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KwaixiaodianOrderCursorListServiceImpl.java

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -215,9 +216,28 @@ public class KwaixiaodianOrderCursorListServiceImpl implements IKwaixiaodianOrde
         try {
             JSONObject info = eventJSon.getJSONObject("info");
             if (!Check.isNull(info)) {
+                Map<String, Object> map = new HashMap<>();
+                Long createTime = eventJSon.getLong("createTime");
+                if (!Check.isNull(createTime)) {
+                    Long time = Long.valueOf(DateUtils.timestamptoStr(createTime));
+                    map.put("time", time);
+                }
                 Long oid = info.getLong("oid");
                 Integer status = info.getInteger("status");
-                int i = mapper.updateKWaiShopOrderStatus(oid, status);
+                map.put("oid", oid);
+                map.put("status", status);
+                String event = eventJSon.getString("event");
+                if ("kwaishop_order_paySuccess".equals(event)) {
+                    //已支付消息
+                    map.put("field", "pay_time");
+                } else if ("kwaishop_order_delivering".equals(event)) {
+                    //已发货消息
+                    map.put("field", "send_time");
+                } else if ("kwaishop_order_deliverySuccess".equals(event)) {
+                    //已收货消息
+                    map.put("field", "recv_time");
+                }
+                int i = mapper.updateKWaiShopOrderStatus(map);
                 if (i <= 0) {
                     log.error("KWai_订单ID:{},状态:{} 修改失败", oid, status);
                 }

+ 5 - 0
ruixuan-live/src/main/resources/mapper/isc/KwaixiaodianOrderCursorListMapper.xml

@@ -418,6 +418,11 @@
     <update id="updateKWaiShopOrderStatus">
         UPDATE `ruixuan`.kwaixiaodian_order_cursor_list
         SET status = #{status}
+        <choose>
+            <when test="field !=null and field !='' ">
+                ,${field} =#{time}
+            </when>
+        </choose>
         WHERE oid = #{oid}
     </update>