Explorar el Código

1.恒春来提交看课统计代码和定时物流同步代码

jzp hace 4 semanas
padre
commit
9e0361eb27

+ 71 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -2,6 +2,8 @@ package com.fs.his.task;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -56,8 +58,10 @@ import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsSubOrderResultVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
+import com.fs.hisStore.enums.ShipperCodeEnum;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
+import com.fs.hisStore.service.IFsExpressScrmService;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.service.IFsStorePaymentScrmService;
 import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
@@ -266,6 +270,73 @@ public class Task {
     @Autowired
     private ConversationSyncService syncService;
 
+    @Autowired
+    private IFsExpressScrmService expressService;
+
+    @Autowired
+    private IFsStoreOrderScrmService  fsStoreOrderScrmService;
+
+
+    /**
+     * 快递信息同步
+     */
+    public void expressInfoSync(){
+        FsStoreOrderScrm storeOrderScrm = new FsStoreOrderScrm();
+        storeOrderScrm.setIsAudit(1);
+        storeOrderScrm.setStatus(2);
+        storeOrderScrm.setDeliveryExceptionStatus(null);
+        List<FsStoreOrderScrm> orderList = fsStoreOrderScrmService.selectFsStoreOrderList(storeOrderScrm);
+        com.fs.hisStore.dto.ExpressInfoDTO expressInfoDTO = null;
+        String lastFourNumber = "";
+        for (FsStoreOrderScrm order : orderList) {
+            try {
+                if (com.fs.common.utils.StringUtils.isNotEmpty(order.getDeliveryId()) &&ObjectUtil.isNotEmpty(lastFourNumber = order.getVirtualPhone())) {
+                    if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue()) || order.getDeliverySn().equals(ShipperCodeEnum.ZTO.getValue())) {
+                        if(order.getDeliveryExceptionStatus() !=null){
+                            continue;
+                        }
+                        if (lastFourNumber.contains("-")) {
+                            String beforeDash = lastFourNumber.split("-")[0];
+                            lastFourNumber = beforeDash.length() >= 4 ? beforeDash.substring(beforeDash.length() - 4) : beforeDash;
+                        }else{
+                            lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+                        }
+                        expressInfoDTO=expressService.getExpressInfo(order.getOrderCode(),order.getDeliverySn(),order.getDeliveryId(),lastFourNumber);
+                        if (lastFourNumber.contains("-")) {
+                            if (expressInfoDTO != null && !expressInfoDTO.isSuccess()) {
+                                lastFourNumber = StrUtil.sub(order.getVirtualPhone(), order.getVirtualPhone().length(), -4);
+                                expressInfoDTO = expressService.getExpressInfo(order.getOrderCode(), order.getDeliverySn(), order.getDeliveryId(), lastFourNumber);
+                            }
+                        }
+                        if(expressInfoDTO!=null){
+                            FsStoreOrderScrm map = new FsStoreOrderScrm();
+                            map.setId(order.getId());
+                            if(expressInfoDTO.isSuccess()){
+                                map.setDeliveryType(expressInfoDTO.getStateEx());
+                                map.setDeliveryStatus(Integer.parseInt(expressInfoDTO.getState()));
+                            }else{
+                                map.setDeliveryExceptionRemark(expressInfoDTO.getReason());
+                                map.setDeliveryExceptionStatus(1);
+                            }
+                            fsStoreOrderScrmMapper.updateFsStoreOrder(map);
+                            //如果是正常签收,更新订单状态
+                            if (expressInfoDTO.getState().equals("3") && (expressInfoDTO.getStateEx().equals("301") || expressInfoDTO.getStateEx().equals("302") || expressInfoDTO.getStateEx().equals("304") || expressInfoDTO.getStateEx().equals("311"))) {
+                                fsStoreOrderScrmService.finishOrder(order.getId());
+                            }
+                            continue;
+                        }
+                    }else if ((lastFourNumber = order.getUserPhone()).length() == 11) {
+                        lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+                    }
+                    expressInfoDTO = expressService.getExpressInfo(order.getOrderCode(), order.getDeliverySn(), order.getDeliveryId(), lastFourNumber);
+                }
+            } catch (Exception e) {
+                System.out.println(e);
+                continue;
+            }
+        }
+    }
+
     /**
      * 定时任务,处理ai禁止回复之后的消息
      */

+ 4 - 2
fs-company/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -674,8 +674,10 @@ public class FsStoreOrderScrmController extends BaseController
      */
     private void applyCompanyDataScope(FsStoreOrderParam param, LoginUser loginUser) {
         param.setCompanyId(loginUser.getCompany().getCompanyId());
-        if (!"00".equals(loginUser.getUser().getUserType()) && !hasRoleKey(loginUser, "finance_order_goods")) {
-            param.setCompanyUserId(loginUser.getUser().getUserId());
+        if(!"恒春来".equals(cloudHostProper.getCompanyName())) {
+            if (!"00".equals(loginUser.getUser().getUserType()) && !hasRoleKey(loginUser, "finance_order_goods")) {
+                param.setCompanyUserId(loginUser.getUser().getUserId());
+            }
         }
     }
 

+ 1 - 1
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -255,7 +255,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             " ,sum(if((o.user_id is null or o.user_id=0) and o.log_type=3,1,0)) no_user_wait_number" +
 //            " ,sum(ifnull(fcr.amount,0)) red_amount" +
             ",COALESCE((SELECT SUM(amount) FROM fs_course_red_packet_log \n" +
-            "     WHERE user_id = o.user_id AND video_id = o.video_id), 0) as red_amount " +
+            "     WHERE user_id = o.user_id AND video_id = o.video_id AND company_user_id = o.company_user_id), 0) as red_amount " +
             "</if> " +
             "FROM fs_course_watch_log o " +
             "<if test= 'sendType != 1 '> " +