Browse Source

Merge remote-tracking branch 'origin/master'

xgb 3 days ago
parent
commit
250fcd9b55
100 changed files with 2756 additions and 360 deletions
  1. 1 1
      deploy.sh
  2. 6 0
      fs-admin/Dockerfile
  3. 21 0
      fs-admin/src/main/java/com/fs/his/controller/FsStoreOrderController.java
  4. 61 0
      fs-admin/src/main/java/com/fs/his/task/Task.java
  5. 60 3
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreAfterSalesScrmController.java
  6. 45 1
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java
  7. 45 0
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  8. 9 1
      fs-admin/src/main/java/com/fs/hisStore/task/LiveTask.java
  9. 16 1
      fs-admin/src/main/java/com/fs/hisStore/task/MallStoreTask.java
  10. 51 0
      fs-admin/src/main/java/com/fs/live/controller/LiveAfterSalesController.java
  11. 18 1
      fs-admin/src/main/java/com/fs/live/controller/LiveController.java
  12. 29 1
      fs-admin/src/main/java/com/fs/live/controller/LiveOrderController.java
  13. 107 24
      fs-admin/src/main/java/com/fs/qw/qwTask/qwTask.java
  14. 1 1
      fs-admin/src/main/resources/application.yml
  15. 6 0
      fs-common-api/Dockerfile
  16. 24 0
      fs-common-api/pom.xml
  17. 1 1
      fs-common-api/src/main/resources/application.yml
  18. 6 0
      fs-common/src/main/java/com/fs/common/constant/LiveKeysConstant.java
  19. 6 0
      fs-company/Dockerfile
  20. 32 21
      fs-company/src/main/java/com/fs/company/controller/live/LiveController.java
  21. 8 0
      fs-company/src/main/java/com/fs/company/controller/qw/QwExternalContactController.java
  22. 3 3
      fs-company/src/main/java/com/fs/company/controller/qw/QwExternalContactTransferLogController.java
  23. 3 2
      fs-company/src/main/resources/application.yml
  24. 0 1
      fs-live-app/src/main/java/com/fs/framework/aspectj/LiveWatchUserAspect.java
  25. 1 1
      fs-live-app/src/main/java/com/fs/framework/aspectj/RateLimiterAspect.java
  26. 0 2
      fs-live-app/src/main/java/com/fs/live/controller/LiveDataController.java
  27. 12 11
      fs-live-app/src/main/java/com/fs/live/websocket/handle/LiveChatHandler.java
  28. 230 56
      fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java
  29. 69 31
      fs-qw-task/src/main/java/com/fs/app/controller/CommonController.java
  30. 34 0
      fs-qwhook/src/main/java/com/fs/app/controller/CommonController.java
  31. 4 1
      fs-service/src/main/java/com/fs/company/domain/CompanyUser.java
  32. 1 0
      fs-service/src/main/java/com/fs/course/domain/FsUserCourseVideo.java
  33. 19 0
      fs-service/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java
  34. 2 5
      fs-service/src/main/java/com/fs/course/mapper/FsUserCourseVideoRedPackageMapper.java
  35. 2 0
      fs-service/src/main/java/com/fs/course/service/IFsCourseTrafficLogService.java
  36. 82 0
      fs-service/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java
  37. 2 2
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCompanyBindServiceImpl.java
  38. 1 2
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCoursePeriodServiceImpl.java
  39. 1 2
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseTrainingCampServiceImpl.java
  40. 1 1
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  41. 1 0
      fs-service/src/main/java/com/fs/course/vo/FsUserCourseVideoQVO.java
  42. 2 0
      fs-service/src/main/java/com/fs/course/vo/newfs/FsUserCourseVideoPageListVO.java
  43. 9 7
      fs-service/src/main/java/com/fs/fastGpt/service/IFastgptEventLogTotalService.java
  44. 237 7
      fs-service/src/main/java/com/fs/fastGpt/service/impl/FastgptEventLogTotalServiceImpl.java
  45. 3 2
      fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java
  46. 11 4
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java
  47. 1 1
      fs-service/src/main/java/com/fs/his/service/impl/FsUserInformationCollectionServiceImpl.java
  48. 14 1
      fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductPackageScrm.java
  49. 39 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsUserCompanyPackageScrm.java
  50. 13 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsUserScrm.java
  51. 12 2
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreAfterSalesScrmMapper.java
  52. 14 4
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java
  53. 2 1
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java
  54. 2 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java
  55. 1 1
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java
  56. 61 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsUserCompanyPackageScrmMapper.java
  57. 3 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java
  58. 21 0
      fs-service/src/main/java/com/fs/hisStore/param/FsUsePackageScrmSendParam.java
  59. 24 0
      fs-service/src/main/java/com/fs/hisStore/param/FsUserCouponScrmSendParam.java
  60. 11 8
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCouponIssueScrmService.java
  61. 5 1
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductPackageScrmService.java
  62. 3 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java
  63. 40 2
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java
  64. 53 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCouponIssueScrmServiceImpl.java
  65. 71 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  66. 5 3
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java
  67. 37 1
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductAttrScrmServiceImpl.java
  68. 37 1
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductAttrValueScrmServiceImpl.java
  69. 32 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductPackageScrmServiceImpl.java
  70. 67 36
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java
  71. 6 4
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java
  72. 43 3
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreAfterSalesVO.java
  73. 133 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportRefundZMVO.java
  74. 3 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportVO.java
  75. 124 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportZMVO.java
  76. 7 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemVO.java
  77. 3 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreProductPacketVO.java
  78. 11 0
      fs-service/src/main/java/com/fs/hisStore/vo/UserScrmVo.java
  79. 2 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrder.java
  80. 4 0
      fs-service/src/main/java/com/fs/live/domain/LiveWatchUser.java
  81. 2 2
      fs-service/src/main/java/com/fs/live/mapper/LiveAfterSalesMapper.java
  82. 3 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java
  83. 15 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  84. 1 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderComputedParam.java
  85. 9 0
      fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java
  86. 2 0
      fs-service/src/main/java/com/fs/live/service/ILiveService.java
  87. 4 3
      fs-service/src/main/java/com/fs/live/service/ILiveWatchUserService.java
  88. 101 69
      fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java
  89. 143 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  90. 113 3
      fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java
  91. 6 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java
  92. 41 1
      fs-service/src/main/java/com/fs/live/vo/LiveAfterSalesVo.java
  93. 1 0
      fs-service/src/main/java/com/fs/live/vo/LiveDataDetailVo.java
  94. 5 1
      fs-service/src/main/java/com/fs/live/vo/LiveOrderItemListUVO.java
  95. 10 2
      fs-service/src/main/java/com/fs/live/vo/LiveOrderVoZm.java
  96. 1 0
      fs-service/src/main/java/com/fs/live/vo/LiveUserDetailVo.java
  97. 1 0
      fs-service/src/main/java/com/fs/live/vo/ProductSalesVo.java
  98. 3 0
      fs-service/src/main/java/com/fs/qw/mapper/QwCompanyMapper.java
  99. 101 0
      fs-service/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java
  100. 7 0
      fs-service/src/main/java/com/fs/qw/param/QwExternalContactParam.java

+ 1 - 1
deploy.sh

@@ -87,7 +87,7 @@ deploy_jar() {
     echo "启动服务..."
     echo "启动服务..."
     ssh -f "$REMOTE_USER@$remote_host" \
     ssh -f "$REMOTE_USER@$remote_host" \
     "cd $REMOTE_BASE_DIR/$remote_dir && \
     "cd $REMOTE_BASE_DIR/$remote_dir && \
-     nohup java -jar  -Dfile.encoding=UTF-8 $app_name.jar --spring.profiles.active=druid-bjzm --server.port=7114  \
+     nohup java -jar -Xms8g -Xmx8g -XX:+UseG1GC -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 $app_name.jar --spring.profiles.active=druid-bjzm --server.port=7114  \
      >> $app_name.log 2>&1 &"
      >> $app_name.log 2>&1 &"
 
 
     # 检查进程是否启动成功
     # 检查进程是否启动成功

+ 6 - 0
fs-admin/Dockerfile

@@ -0,0 +1,6 @@
+FROM openjdk:8-jre
+# java版本,最好使用openjdk,而不是类似于Java:1.8
+COPY ./target/fs-admin.jar fs-admin.jar
+# 向外暴露的接口,最好与项目yml文件中的端口一致
+ENTRYPOINT ["java","-jar","fs-admin.jar"]
+# 执行启动命令java -jar

+ 21 - 0
fs-admin/src/main/java/com/fs/his/controller/FsStoreOrderController.java

@@ -47,6 +47,7 @@ import com.fs.system.mapper.SysConfigMapper;
 import com.fs.system.service.ISysRoleService;
 import com.fs.system.service.ISysRoleService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -73,6 +74,7 @@ import static com.fs.his.utils.PhoneUtil.*;
  */
  */
 @RestController
 @RestController
 @RequestMapping("/his/storeOrder")
 @RequestMapping("/his/storeOrder")
+@Slf4j
 public class FsStoreOrderController extends BaseController
 public class FsStoreOrderController extends BaseController
 {
 {
     @Autowired
     @Autowired
@@ -421,6 +423,14 @@ public class FsStoreOrderController extends BaseController
             tuiMoneyLogs=moneyLogsService.selectCompanyStoreOrderMoneyLogsList(moneyLogsMap);
             tuiMoneyLogs=moneyLogsService.selectCompanyStoreOrderMoneyLogsList(moneyLogsMap);
         }
         }
         if ((CloudHostUtils.hasCloudHostName("金牛明医"))){
         if ((CloudHostUtils.hasCloudHostName("金牛明医"))){
+            if (order.getStatus() == 2 ){
+                FsUserInfoCollectionAndStoreOrderVo infoVo = fsPackageOrderService.selectInformationCollectionByStoreOrderId(orderId);
+                if (infoVo!=null) {
+                    if (infoVo.getDoctorType2Confirm() == null || infoVo.getDoctorType2Confirm()!=1) {
+                        order.setStatus(7);
+                    }
+                }
+            }
             return R.ok().put("data",order).put("tuiMoneyLogs",tuiMoneyLogs).put("isUpdateRefund",1).put("isUpdatePayRemain",1);
             return R.ok().put("data",order).put("tuiMoneyLogs",tuiMoneyLogs).put("isUpdateRefund",1).put("isUpdatePayRemain",1);
         } else {
         } else {
             return R.ok().put("data",order).put("tuiMoneyLogs",tuiMoneyLogs).put("isUpdateRefund",0).put("isUpdatePayRemain",0);
             return R.ok().put("data",order).put("tuiMoneyLogs",tuiMoneyLogs).put("isUpdateRefund",0).put("isUpdatePayRemain",0);
@@ -482,6 +492,17 @@ public class FsStoreOrderController extends BaseController
     {
     {
         AjaxResult error = moneyCheck(fsStoreOrder);
         AjaxResult error = moneyCheck(fsStoreOrder);
         if (error != null) return error;
         if (error != null) return error;
+        try {
+            FsUserInfoCollectionAndStoreOrderVo infoVo = fsPackageOrderService.selectInformationCollectionByStoreOrderId(fsStoreOrder.getOrderId());
+            if (infoVo != null) {
+                Integer doctorType2Confirm = infoVo.getDoctorType2Confirm();
+                if (doctorType2Confirm == null || doctorType2Confirm != 1) {
+                    return AjaxResult.error("信息采集订单药师未确认,不能修改状态!");
+                }
+            }
+        } catch (Exception e) {
+            log.error("信息采集查询错误,orderId: " + fsStoreOrder.getOrderId() + ",信息:{}"+ e);
+        }
         return toAjax(fsStoreOrderService.updateFsStoreOrder(fsStoreOrder));
         return toAjax(fsStoreOrderService.updateFsStoreOrder(fsStoreOrder));
     }
     }
 
 

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

@@ -57,6 +57,12 @@ import com.fs.his.service.impl.FsPackageOrderServiceImpl;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsSubOrderResultVO;
 import com.fs.his.vo.FsSubOrderResultVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
+import com.fs.hisStore.domain.FsStorePaymentScrm;
+import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
+import com.fs.hisStore.service.IFsStorePaymentScrmService;
+import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
+import com.fs.huifuPay.service.HuiFuService;
 import com.fs.im.dto.*;
 import com.fs.im.dto.*;
 import com.fs.im.service.IImService;
 import com.fs.im.service.IImService;
 import com.fs.im.service.OpenIMService;
 import com.fs.im.service.OpenIMService;
@@ -81,6 +87,8 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.*;
@@ -1069,6 +1077,59 @@ public class Task {
         System.out.println(msgResponseDTO);
         System.out.println(msgResponseDTO);
     }
     }
 
 
+    @Autowired
+    FsStorePaymentScrmMapper fsStorePaymentScrmMapper;
+
+    @Autowired
+    HuiFuService huiFuService;
+
+    /**
+     * 查询同步商城订单的支付转台
+     */
+    public void syncOrderPayStatus(){
+        //查询支付状态是待支付的数据
+        FsStorePaymentScrm paymentScrm = new FsStorePaymentScrm();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+        paymentScrm.setStatus(0);
+        List<FsStorePaymentScrm> fsStorePaymentScrms = fsStorePaymentScrmMapper.selectFsStorePaymentList(paymentScrm);
+        if(null != fsStorePaymentScrms && !fsStorePaymentScrms.isEmpty()){
+            for (FsStorePaymentScrm payment : fsStorePaymentScrms) {
+                if(StringUtils.isBlank(payment.getTradeNo())){
+                    continue;
+                }
+                V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
+                request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
+                request.setOrgHfSeqId(payment.getTradeNo());
+                HuiFuQueryOrderResult o = null;
+                try {
+                    o = huiFuService.queryOrder(request);
+                } catch (Exception e) {
+                    log.error("查询失败:"+e.getMessage());
+                    continue;
+                }
+                log.info("汇付返回" + o);
+                if ("00000000".equals(o.getResp_code()) && "S".equals(o.getTrans_stat())) {
+                    try {
+                        Date payTime = formatter.parse(o.getEnd_time());
+                        FsStorePaymentScrm payUpdate = new FsStorePaymentScrm();
+                        payUpdate.setPaymentId(payment.getPaymentId());
+                        payUpdate.setPayTime(payTime);
+                        payUpdate.setStatus(1);
+                        payUpdate.setTradeNo(o.getOrg_hf_seq_id());
+                        payUpdate.setBankSerialNo(o.getParty_order_id());
+                        payUpdate.setBankTransactionId(o.getOut_trans_id());
+                        fsStorePaymentScrmMapper.updateFsStorePayment(payUpdate);
+                    } catch (ParseException e) {
+                        log.error("更新失败 payment:{}",payment ,e);
+//                        throw new RuntimeException(e);
+                    }
+
+
+                }
+            }
+        }
+    }
+
 //    @Autowired
 //    @Autowired
 //    private FsStoreMapper fsStoreMapper;
 //    private FsStoreMapper fsStoreMapper;
 //    @Autowired
 //    @Autowired

+ 60 - 3
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreAfterSalesScrmController.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.controller;
 package com.fs.hisStore.controller;
 
 
+import cn.hutool.core.bean.BeanUtil;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.AjaxResult;
@@ -27,12 +28,18 @@ import com.fs.hisStore.service.IFsStoreAfterSalesScrmService;
 import com.fs.hisStore.service.IFsStoreAfterSalesStatusScrmService;
 import com.fs.hisStore.service.IFsStoreAfterSalesStatusScrmService;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.vo.FsStoreAfterSalesVO;
 import com.fs.hisStore.vo.FsStoreAfterSalesVO;
+import com.fs.hisStore.vo.FsStoreOrderItemExportRefundZMVO;
+import com.fs.hisStore.vo.FsStoreOrderItemExportZMVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.util.List;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * 售后记录Controller
  * 售后记录Controller
@@ -57,6 +64,10 @@ public class FsStoreAfterSalesScrmController extends BaseController
 
 
     @Autowired
     @Autowired
     private TokenService tokenService;
     private TokenService tokenService;
+
+    @Value("${cloud_host.company_name}")
+    private String signProjectName;
+
     /**
     /**
      * 查询售后记录列表
      * 查询售后记录列表
      */
      */
@@ -84,16 +95,62 @@ public class FsStoreAfterSalesScrmController extends BaseController
             fsStoreAfterSales.setBeginTime(null);
             fsStoreAfterSales.setBeginTime(null);
             fsStoreAfterSales.setEndTime(null);
             fsStoreAfterSales.setEndTime(null);
         }
         }
-        Boolean a = fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales);
-        if (fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales)){
+//        Boolean a = fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales);
+        if (fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales) && Objects.isNull(fsStoreAfterSales.getParams())){
             return AjaxResult.error("请筛选数据导出");
             return AjaxResult.error("请筛选数据导出");
         }
         }
+
         List<FsStoreAfterSalesVO> list = fsStoreAfterSalesService.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
         List<FsStoreAfterSalesVO> list = fsStoreAfterSalesService.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
+        if("北京卓美".equals(signProjectName)){
+            List<FsStoreOrderItemExportRefundZMVO> zmvoList = list.stream()
+                    .map(vo -> {
+                        FsStoreOrderItemExportRefundZMVO zmvo = new FsStoreOrderItemExportRefundZMVO();
+                        try {
+                            zmvo.setOrderCode(vo.getOrderCode());
+                            zmvo.setStatus(vo.getOrderStatus().toString());
+                            zmvo.setUserId(vo.getUserId());
+                            zmvo.setProductName(vo.getProductName());
+                            zmvo.setBarCode(vo.getProductBarCode());
+                            zmvo.setSku(vo.getSku());
+                            zmvo.setNum(vo.getNum());
+                            zmvo.setPrice(vo.getPrice());
+                            zmvo.setCost(vo.getCost());
+//                            zmvo.setFPrice("");
+                            zmvo.setPayMoney(vo.getPayMoney());
+                            zmvo.setPayPostage(vo.getTotalPostage());
+                            zmvo.setCateName(vo.getCateName());
+                            zmvo.setRealName(vo.getUserName());
+                            zmvo.setUserPhone(vo.getUserPhone());
+                            zmvo.setUserAddress(vo.getUserAddress());
+                            zmvo.setCreateTime(vo.getCreateTime());
+                            zmvo.setPayTime(vo.getOrderPayTime());
+                            zmvo.setDeliverySn(vo.getOrderDeliverySn());
+                            zmvo.setDeliveryName(vo.getOrderDeliveryName());
+                            zmvo.setDeliveryId(vo.getOrderDeliveryId());
+                            zmvo.setCompanyName(vo.getCompanyName());
+                            zmvo.setCompanyUserNickName(vo.getCompanyUserNickName());
+                            zmvo.setRefundTime(vo.getCreateTime());
+//                            zmvo.setAfterSalesNumber
+                            zmvo.setRefundMoney(vo.getRefundAmount());
+                            zmvo.setBankTransactionId(vo.getBankTransactionId());
+                        } catch (Exception e) {
+                            // 处理异常
+                            e.printStackTrace();
+                        }
+                        return zmvo;
+                    })
+                    .collect(Collectors.toList());
+            for (FsStoreOrderItemExportRefundZMVO vo : zmvoList){
+                vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
+            }
+            ExcelUtil<FsStoreOrderItemExportRefundZMVO> util = new ExcelUtil<FsStoreOrderItemExportRefundZMVO>(FsStoreOrderItemExportRefundZMVO.class);
+            return util.exportExcel(zmvoList, "退款订单导出");
+        }
         for (FsStoreAfterSalesVO vo : list){
         for (FsStoreAfterSalesVO vo : list){
             vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
             vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
         }
         }
         ExcelUtil<FsStoreAfterSalesVO> util = new ExcelUtil<FsStoreAfterSalesVO>(FsStoreAfterSalesVO.class);
         ExcelUtil<FsStoreAfterSalesVO> util = new ExcelUtil<FsStoreAfterSalesVO>(FsStoreAfterSalesVO.class);
-        return util.exportExcel(list, "storeAfterSales");
+        return util.exportExcel(list, "退款订单导出");
     }
     }
     /**
     /**
      * 获取售后记录详细信息
      * 获取售后记录详细信息

+ 45 - 1
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java

@@ -28,6 +28,7 @@ import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.*;
 import com.fs.hisStore.vo.*;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
@@ -35,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 @RestController
 @RestController
 @RequestMapping("/store/store/storeOrder")
 @RequestMapping("/store/store/storeOrder")
@@ -71,6 +73,9 @@ public class FsStoreHealthOrderScrmController extends BaseController {
     // 最大文件大小(5MB)
     // 最大文件大小(5MB)
     private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
     private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
 
 
+    @Value("${cloud_host.company_name}")
+    private String signProjectName;
+
     /**
     /**
      * 查询健康商城订单列表
      * 查询健康商城订单列表
      */
      */
@@ -112,7 +117,7 @@ public class FsStoreHealthOrderScrmController extends BaseController {
                     }
                     }
                 }
                 }
                 //
                 //
-                if (loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) {
+                if ((loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*") && (vo.getCost() !=null && vo.getTotalNum() != null))) {
                     vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getTotalNum())));
                     vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getTotalNum())));
                 } else {
                 } else {
                     vo.setPayPostage(BigDecimal.ZERO);
                     vo.setPayPostage(BigDecimal.ZERO);
@@ -342,6 +347,45 @@ public class FsStoreHealthOrderScrmController extends BaseController {
         }
         }
         param.setIsHealth("1");
         param.setIsHealth("1");
         List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
         List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
+        if("北京卓美".equals(signProjectName)){
+            List<FsStoreOrderItemExportZMVO> zmvoList = list.stream()
+                    .map(vo -> {
+                        FsStoreOrderItemExportZMVO zmvo = new FsStoreOrderItemExportZMVO();
+                        try {
+                            BeanUtil.copyProperties( vo,zmvo);
+                        } catch (Exception e) {
+                            // 处理异常
+                            e.printStackTrace();
+                        }
+                        return zmvo;
+                    })
+                    .collect(Collectors.toList());
+            //对手机号脱敏
+            if (zmvoList != null) {
+                    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+                    for (FsStoreOrderItemExportZMVO vo : zmvoList) {
+                        if (!StringUtils.isEmpty(vo.getJsonInfo())) {
+                            try {
+                                StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
+                                BeanUtil.copyProperties(orderProductDTO, vo);
+                            } catch (Exception e) {
+                            }
+                        }
+                        if (loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) {
+                            vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getTotalNum())));
+                        } else {
+                            vo.setPayPostage(BigDecimal.ZERO);
+                            vo.setCost(BigDecimal.ZERO);
+                            vo.setFPrice(BigDecimal.ZERO);
+                            vo.setBarCode("");
+                            vo.setCateName("");
+                            vo.setBankTransactionId("");
+                        }
+                    }
+                }
+                ExcelUtil<FsStoreOrderItemExportZMVO> util = new ExcelUtil<FsStoreOrderItemExportZMVO>(FsStoreOrderItemExportZMVO.class);
+                return util.exportExcel(zmvoList, "订单明细数据");
+        }
         //对手机号脱敏
         //对手机号脱敏
         if (list != null) {
         if (list != null) {
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());

+ 45 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -58,6 +58,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -137,6 +138,9 @@ public class FsStoreOrderScrmController extends BaseController {
     @Autowired
     @Autowired
     private IFsStoreOrderLogsScrmService fsStoreOrderLogsService;
     private IFsStoreOrderLogsScrmService fsStoreOrderLogsService;
 
 
+    @Value("${cloud_host.company_name}")
+    private String signProjectName;
+
     private IErpOrderService getErpService(){
     private IErpOrderService getErpService(){
         //判断是否开启erp
         //判断是否开启erp
         IErpOrderService erpOrderService = null;
         IErpOrderService erpOrderService = null;
@@ -511,6 +515,47 @@ public class FsStoreOrderScrmController extends BaseController {
         }
         }
         param.setNotHealth(1);
         param.setNotHealth(1);
         List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
         List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
+        if("北京卓美".equals(signProjectName)){
+            List<FsStoreOrderItemExportZMVO> zmvoList = list.stream()
+                    .map(vo -> {
+                        FsStoreOrderItemExportZMVO zmvo = new FsStoreOrderItemExportZMVO();
+                        try {
+                            BeanUtil.copyProperties( vo,zmvo);
+                        } catch (Exception e) {
+                            // 处理异常
+                            e.printStackTrace();
+                        }
+                        return zmvo;
+                    })
+                    .collect(Collectors.toList());
+            //对手机号脱敏
+            if (zmvoList != null) {
+                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+                for (FsStoreOrderItemExportZMVO vo : zmvoList) {
+                    if (!StringUtils.isEmpty(vo.getJsonInfo())) {
+                        try {
+                            StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
+                            BeanUtil.copyProperties(orderProductDTO, vo);
+                        } catch (Exception e) {
+                        }
+                    }
+                    //
+                    if (loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) {
+                        vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getTotalNum())));
+                    } else {
+                        vo.setPayPostage(BigDecimal.ZERO);
+                        vo.setCost(BigDecimal.ZERO);
+                        vo.setFPrice(BigDecimal.ZERO);
+                        vo.setBarCode("");
+                        vo.setCateName("");
+                        vo.setBankTransactionId("");
+                    }
+                }
+            }
+            ExcelUtil<FsStoreOrderItemExportZMVO> util = new ExcelUtil<FsStoreOrderItemExportZMVO>(FsStoreOrderItemExportZMVO.class);
+            return util.exportExcel(zmvoList, "订单明细数据");
+        }
+
         //对手机号脱敏
         //对手机号脱敏
         if (list != null) {
         if (list != null) {
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());

+ 9 - 1
fs-admin/src/main/java/com/fs/hisStore/task/LiveTask.java

@@ -198,8 +198,16 @@ public class LiveTask {
         if (ids.size() > 50) {
         if (ids.size() > 50) {
             ids = ids.subList(0, 50);
             ids = ids.subList(0, 50);
         }
         }
+//        liveOrderService.batchUpdateTimeIds(ids);
+        // 单个异常影响全部,跳过异常单子
         for (Long id : ids) {
         for (Long id : ids) {
-            liveOrderService.createOmsOrder(id);
+            try {
+                liveOrderService.createOmsOrder(id);
+            } catch (Exception e) {
+                log.error("创建直播oms订单失败:"+id);
+                log.error("创建直播oms订单失败:"+e.getMessage());
+            }
+
         }
         }
     }
     }
 
 

+ 16 - 1
fs-admin/src/main/java/com/fs/hisStore/task/MallStoreTask.java

@@ -4,6 +4,7 @@ package com.fs.hisStore.task;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.DateUtils;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.vo.RedPacketMoneyVO;
 import com.fs.company.vo.RedPacketMoneyVO;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
@@ -32,6 +33,7 @@ import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.service.*;
+import com.fs.live.domain.LiveOrder;
 import com.fs.pay.pay.dto.OrderQueryDTO;
 import com.fs.pay.pay.dto.OrderQueryDTO;
 import com.fs.pay.service.IPayService;
 import com.fs.pay.service.IPayService;
 import com.fs.store.config.StoreConfig;
 import com.fs.store.config.StoreConfig;
@@ -49,6 +51,7 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.time.LocalTime;
 import java.time.LocalTime;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletableFuture;
@@ -168,8 +171,15 @@ public class MallStoreTask
         if (!ids.isEmpty() && ids.size() > 50) {
         if (!ids.isEmpty() && ids.size() > 50) {
             ids = ids.subList(0, 50);
             ids = ids.subList(0, 50);
         }
         }
+        // 单个异常影响全部,跳过异常单子
         for (Long id : ids) {
         for (Long id : ids) {
-            fsStoreOrderService.createOmsOrder(id);
+            try {
+                fsStoreOrderService.createOmsOrder(id);
+            } catch (Exception e) {
+                log.error("创建商城oms订单失败:"+id);
+                log.error("创建商城oms订单失败:"+e.getMessage());
+            }
+
         }
         }
     }
     }
 
 
@@ -210,6 +220,11 @@ public class MallStoreTask
         if (list != null && list.size() > 50) {
         if (list != null && list.size() > 50) {
             list = list.subList(0, 50);
             list = list.subList(0, 50);
         }
         }
+        Date nowDate = DateUtils.getNowDate();
+        for (FsStoreOrderScrm order : list) {
+            order.setUpdateTime(nowDate);
+        }
+        fsStoreOrderMapper.batchUpdateTime(list);
         for (FsStoreOrderScrm order : list){
         for (FsStoreOrderScrm order : list){
             ErpOrderQueryRequert request = new ErpOrderQueryRequert();
             ErpOrderQueryRequert request = new ErpOrderQueryRequert();
             request.setCode(order.getExtendOrderId());
             request.setCode(order.getExtendOrderId());

+ 51 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveAfterSalesController.java

@@ -16,6 +16,7 @@ import com.fs.his.domain.FsStoreAfterSalesLogs;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUser;
 import com.fs.his.enums.FsStoreAfterSalesStatusEnum;
 import com.fs.his.enums.FsStoreAfterSalesStatusEnum;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserService;
+import com.fs.hisStore.vo.FsStoreOrderItemExportRefundZMVO;
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.domain.LiveAfterSalesItem;
 import com.fs.live.domain.LiveAfterSalesItem;
 import com.fs.live.domain.LiveAfterSalesLogs;
 import com.fs.live.domain.LiveAfterSalesLogs;
@@ -31,11 +32,13 @@ import com.fs.live.service.ILiveOrderService;
 import com.fs.live.vo.LiveAfterSalesVo;
 import com.fs.live.vo.LiveAfterSalesVo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import java.text.ParseException;
 import java.text.ParseException;
 import java.util.List;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * 售后记录Controller
  * 售后记录Controller
@@ -60,6 +63,9 @@ public class LiveAfterSalesController extends BaseController
     private IFsUserService userService;
     private IFsUserService userService;
     @Autowired
     @Autowired
     private ILiveOrderService orderService;
     private ILiveOrderService orderService;
+    @Value("${cloud_host.company_name}")
+    private String signProjectName;
+
 
 
     /**
     /**
      * 获取售后记录详细信息
      * 获取售后记录详细信息
@@ -105,6 +111,51 @@ public class LiveAfterSalesController extends BaseController
         PageHelper.clearPage();
         PageHelper.clearPage();
         PageHelper.startPage(1, 10000, "");
         PageHelper.startPage(1, 10000, "");
         List<LiveAfterSalesVo> list = liveAfterSalesService.selectLiveAfterSalesVoList(liveAfterSales);
         List<LiveAfterSalesVo> list = liveAfterSalesService.selectLiveAfterSalesVoList(liveAfterSales);
+        if("北京卓美".equals(signProjectName)){
+            List<FsStoreOrderItemExportRefundZMVO> zmvoList = list.stream()
+                    .map(vo -> {
+                        FsStoreOrderItemExportRefundZMVO zmvo = new FsStoreOrderItemExportRefundZMVO();
+                        try {
+                            zmvo.setOrderCode(vo.getOrderCode());
+                            zmvo.setStatus(vo.getOrderStatus().toString());
+                            zmvo.setUserId(vo.getUserId());
+                            zmvo.setProductName(vo.getProductName());
+                            zmvo.setBarCode(vo.getProductBarCode());
+                            zmvo.setSku(vo.getSku());
+                            zmvo.setNum(vo.getNum());
+                            zmvo.setPrice(vo.getPrice());
+                            zmvo.setCost(vo.getCost());
+//                            zmvo.setFPrice("");
+                            zmvo.setPayMoney(vo.getPayMoney());
+                            zmvo.setPayPostage(vo.getTotalPostage());
+                            zmvo.setCateName(vo.getCateName());
+                            zmvo.setRealName(vo.getUserName());
+                            zmvo.setUserPhone(vo.getUserPhone());
+                            zmvo.setUserAddress(vo.getUserAddress());
+                            zmvo.setCreateTime(vo.getCreateTime());
+                            zmvo.setPayTime(vo.getOrderPayTime());
+                            zmvo.setDeliverySn(vo.getOrderDeliverySn());
+                            zmvo.setDeliveryName(vo.getOrderDeliveryName());
+                            zmvo.setDeliveryId(vo.getOrderDeliveryId());
+                            zmvo.setCompanyName(vo.getCompanyName());
+                            zmvo.setCompanyUserNickName(vo.getCompanyUserNickName());
+                            zmvo.setRefundTime(vo.getCreateTime());
+//                            zmvo.setAfterSalesNumber
+                            zmvo.setRefundMoney(vo.getRefundAmount());
+                            zmvo.setBankTransactionId(vo.getBankTransactionId());
+                        } catch (Exception e) {
+                            // 处理异常
+                            e.printStackTrace();
+                        }
+                        return zmvo;
+                    })
+                    .collect(Collectors.toList());
+            for (FsStoreOrderItemExportRefundZMVO vo : zmvoList){
+                vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
+            }
+            ExcelUtil<FsStoreOrderItemExportRefundZMVO> util = new ExcelUtil<FsStoreOrderItemExportRefundZMVO>(FsStoreOrderItemExportRefundZMVO.class);
+            return util.exportExcel(zmvoList, "退款订单导出");
+        }
         for (LiveAfterSalesVo liveAfterSalesVo : list) {
         for (LiveAfterSalesVo liveAfterSalesVo : list) {
             liveAfterSalesVo.setUserPhone(liveAfterSalesVo.getUserPhone() == null ? "" : liveAfterSalesVo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
             liveAfterSalesVo.setUserPhone(liveAfterSalesVo.getUserPhone() == null ? "" : liveAfterSalesVo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
             liveAfterSalesVo.setPhoneNumber(liveAfterSalesVo.getPhoneNumber() == null ? "" : liveAfterSalesVo.getPhoneNumber().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
             liveAfterSalesVo.setPhoneNumber(liveAfterSalesVo.getPhoneNumber() == null ? "" : liveAfterSalesVo.getPhoneNumber().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));

+ 18 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveController.java

@@ -4,14 +4,19 @@ import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.model.LoginUser;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.framework.web.service.TokenService;
 import com.fs.hisStore.task.LiveTask;
 import com.fs.hisStore.task.LiveTask;
 import com.fs.hisStore.task.MallStoreTask;
 import com.fs.hisStore.task.MallStoreTask;
 import com.fs.live.domain.Live;
 import com.fs.live.domain.Live;
 import com.fs.live.service.ILiveService;
 import com.fs.live.service.ILiveService;
 import com.fs.live.vo.LiveListVo;
 import com.fs.live.vo.LiveListVo;
+import com.hc.openapi.tool.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -28,10 +33,14 @@ import java.util.Map;
  */
  */
 @RestController
 @RestController
 @RequestMapping("/live/live")
 @RequestMapping("/live/live")
+@Slf4j
 public class LiveController extends BaseController {
 public class LiveController extends BaseController {
     @Autowired
     @Autowired
     private ILiveService liveService;
     private ILiveService liveService;
 
 
+    @Autowired
+    private TokenService tokenService;
+
 
 
     /**
     /**
      * 查询直播列表
      * 查询直播列表
@@ -63,7 +72,7 @@ public class LiveController extends BaseController {
     @PreAuthorize("@ss.hasPermi('live:live:query')")
     @PreAuthorize("@ss.hasPermi('live:live:query')")
     @GetMapping(value = "/{liveId}")
     @GetMapping(value = "/{liveId}")
     public AjaxResult getInfo(@PathVariable("liveId") Long liveId) {
     public AjaxResult getInfo(@PathVariable("liveId") Long liveId) {
-        return AjaxResult.success(liveService.selectLiveByLiveId(liveId));
+        return AjaxResult.success(liveService.selectLiveDbByLiveId(liveId));
     }
     }
 
 
     /**
     /**
@@ -83,6 +92,8 @@ public class LiveController extends BaseController {
     @Log(title = "直播", businessType = BusinessType.UPDATE)
     @Log(title = "直播", businessType = BusinessType.UPDATE)
     @PutMapping
     @PutMapping
     public AjaxResult edit(@RequestBody Live live) {
     public AjaxResult edit(@RequestBody Live live) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        log.warn("loginUser:{},update:{}", loginUser.getUserId(), JSON.toJSONString( live));
         return toAjax(liveService.updateLive(live));
         return toAjax(liveService.updateLive(live));
     }
     }
 
 
@@ -93,6 +104,8 @@ public class LiveController extends BaseController {
     @Log(title = "直播", businessType = BusinessType.DELETE)
     @Log(title = "直播", businessType = BusinessType.DELETE)
     @DeleteMapping("/{liveIds}")
     @DeleteMapping("/{liveIds}")
     public AjaxResult remove(@PathVariable Long[] liveIds) {
     public AjaxResult remove(@PathVariable Long[] liveIds) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        log.warn("loginUser:{},update:{}", loginUser.getUserId(), JSON.toJSONString( liveIds));
         return toAjax(liveService.deleteLiveByLiveIds(liveIds, new Live()));
         return toAjax(liveService.deleteLiveByLiveIds(liveIds, new Live()));
     }
     }
 
 
@@ -116,6 +129,8 @@ public class LiveController extends BaseController {
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PostMapping("/handleShelfOrUn")
     @PostMapping("/handleShelfOrUn")
     public R handleShelfOrUn(@RequestBody LiveListVo listVo) {
     public R handleShelfOrUn(@RequestBody LiveListVo listVo) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        log.warn("loginUser:{},update:{}", loginUser.getUserId(), JSON.toJSONString( listVo));
         return liveService.handleShelfOrUnAdmin(listVo);
         return liveService.handleShelfOrUnAdmin(listVo);
     }
     }
 
 
@@ -125,6 +140,8 @@ public class LiveController extends BaseController {
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PostMapping("/handleDeleteSelected")
     @PostMapping("/handleDeleteSelected")
     public R handleDeleteSelected(@RequestBody LiveListVo listVo) {
     public R handleDeleteSelected(@RequestBody LiveListVo listVo) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        log.warn("loginUser:{},update:{}", loginUser.getUserId(), JSON.toJSONString( listVo));
         return liveService.handleDeleteSelectedAdmin(listVo);
         return liveService.handleDeleteSelectedAdmin(listVo);
     }
     }
     /**
     /**

+ 29 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveOrderController.java

@@ -38,6 +38,7 @@ import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.IFsExpressScrmService;
 import com.fs.hisStore.service.IFsExpressScrmService;
 import com.fs.hisStore.task.ExpressTask;
 import com.fs.hisStore.task.ExpressTask;
 import com.fs.hisStore.task.LiveTask;
 import com.fs.hisStore.task.LiveTask;
+import com.fs.hisStore.vo.FsStoreOrderItemExportZMVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.live.domain.*;
 import com.fs.live.domain.*;
 import com.fs.live.dto.LiveOrderCustomerExportDTO;
 import com.fs.live.dto.LiveOrderCustomerExportDTO;
@@ -242,7 +243,34 @@ public class LiveOrderController extends BaseController
         return util.exportExcel(list, "订单数据");
         return util.exportExcel(list, "订单数据");
     }
     }
 
 
-
+    /**
+     * 导出订单列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:liveOrder:export')")
+    @Log(title = "订单", businessType = BusinessType.EXPORT)
+    @GetMapping("/exportZmNew")
+    public AjaxResult exportZmNew(LiveOrder liveOrder){
+        List<FsStoreOrderItemExportZMVO> list = liveOrderService.selectLiveOrderListZmNew(liveOrder);
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        for (FsStoreOrderItemExportZMVO vo : list){
+            vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
+//            vo.setCompanyUserPhone(ParseUtils.parsePhone(vo.getCompanyUserPhone()));
+//            vo.setUserBindPhone(ParseUtils.parsePhone(vo.getUserBindPhone()));
+            vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
+            // 财务独特字段
+            if (loginUser.getPermissions().contains("live:liveOrder:finance") || loginUser.getPermissions().contains("*:*:*")) {
+//                vo.setCostPrice(vo.getCost());
+                vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getNum())));
+            } else {
+                vo.setCost(BigDecimal.ZERO);
+                vo.setFPrice(BigDecimal.ZERO);
+                vo.setBankTransactionId("");
+            }
+//            vo.setCost(vo.getCostPrice());
+        }
+        ExcelUtil<FsStoreOrderItemExportZMVO> util = new ExcelUtil<FsStoreOrderItemExportZMVO>(FsStoreOrderItemExportZMVO.class);
+        return util.exportExcel(list, "订单数据");
+    }
     /**
     /**
      * 获取订单详细信息
      * 获取订单详细信息
      */
      */

+ 107 - 24
fs-admin/src/main/java/com/fs/qw/qwTask/qwTask.java

@@ -4,6 +4,7 @@ import com.fs.course.service.IFsUserCourseService;
 import com.fs.qw.domain.QwIpadServerLog;
 import com.fs.qw.domain.QwIpadServerLog;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.QwUserMapper;
 import com.fs.qw.mapper.QwUserMapper;
+import com.fs.qw.param.QwMandatoryRegistrParam;
 import com.fs.qw.service.*;
 import com.fs.qw.service.*;
 import com.fs.sop.service.impl.QwSopLogsServiceImpl;
 import com.fs.sop.service.impl.QwSopLogsServiceImpl;
 import com.fs.sop.service.impl.QwSopServiceImpl;
 import com.fs.sop.service.impl.QwSopServiceImpl;
@@ -15,10 +16,14 @@ import com.fs.wxwork.service.WxWorkService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
+import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
+import java.util.Optional;
 
 
 @Component("qwTask")
 @Component("qwTask")
 public class qwTask {
 public class qwTask {
@@ -73,6 +78,10 @@ public class qwTask {
     private WxWorkService wxWorkService;
     private WxWorkService wxWorkService;
 
 
 
 
+    @Autowired
+    private IQwCompanyService iQwCompanyService;
+
+
     //正在使用
     //正在使用
     public void qwExternalContact()
     public void qwExternalContact()
     {
     {
@@ -240,37 +249,41 @@ public class qwTask {
      * 定时清除 占着茅坑不拉屎的ipad 账号
      * 定时清除 占着茅坑不拉屎的ipad 账号
      */
      */
     public void selectQwUserByUnbindIpad(){
     public void selectQwUserByUnbindIpad(){
+
+        //查询所有状态为 绑定了AI主机的
         List<QwUser> list = qwUserMapper.selectQwUserByTest();
         List<QwUser> list = qwUserMapper.selectQwUserByTest();
         for (QwUser qwUser : list) {
         for (QwUser qwUser : list) {
             try {
             try {
-                Integer serverStatus = qwUser.getServerStatus();
+
                 Long serverId = qwUser.getServerId();
                 Long serverId = qwUser.getServerId();
-                if (serverStatus==0){
-                    System.out.println("不需要解绑");
-                }
+
                 if (serverId==null){
                 if (serverId==null){
                     System.out.println("serverId不存在");
                     System.out.println("serverId不存在");
+                }else {
+                    //没绑定销售 或者 已经离职
+                    if (qwUser.getStatus()==0 || qwUser.getIsDel()==2){
+
+                        updateIpadStatus(qwUser,serverId);
+                    }
+
+                    //绑定了销售-也绑定了ipad,但是长时间离线的(离线状态,无操作超过2天的,也自动解绑)
+                    if(qwUser.getCreateTime()!=null){
+                        Date createTime = qwUser.getCreateTime();
+                        Integer serverStatus = qwUser.getServerStatus();
+                        Integer ipadStatus = qwUser.getIpadStatus();
+
+                        boolean result = isCreateTimeMoreThanDaysWithOptional(createTime, 2);
+                        //大于2天 ,绑定了ipad,离线
+                        if(result && serverStatus==1 && ipadStatus==0){
+                            updateIpadStatus(qwUser,serverId);
+
+                        }
+                    }
+
+
                 }
                 }
-                QwUser u = new QwUser();
-                u.setId(qwUser.getId());
-                u.setServerId(null);
-                u.setServerStatus(0);
-                qwUserMapper.updateQwUser(u);
-                ipadServerService.addServer(serverId);
-                QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
-                qwIpadServerLog.setType(2);
-                qwIpadServerLog.setTilie("解绑");
-                qwIpadServerLog.setServerId(serverId);
-                qwIpadServerLog.setQwUserId(qwUser.getId());
-                qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
-                qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
-                qwIpadServerLog.setCreateTime(new Date());
-                qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
-                qwIpadServerUserService.deleteQwIpadServerUserByQwUserId(qwUser.getId());
-                WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
-                wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
-                wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
-                updateIpadStatus(qwUser.getId(),0);
+
+
             } catch (Exception e) {
             } catch (Exception e) {
                 System.out.println("解绑ipad报错"+e);
                 System.out.println("解绑ipad报错"+e);
 
 
@@ -278,6 +291,41 @@ public class qwTask {
         }
         }
     }
     }
 
 
+    public void updateIpadStatus(QwUser qwUser,Long serverId){
+        QwUser u = new QwUser();
+        u.setId(qwUser.getId());
+        u.setServerId(null);
+        u.setServerStatus(0);
+        qwUserMapper.updateQwUser(u);
+        ipadServerService.addServer(serverId);
+        QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
+        qwIpadServerLog.setType(2);
+        qwIpadServerLog.setTilie("解绑");
+        qwIpadServerLog.setServerId(serverId);
+        qwIpadServerLog.setQwUserId(qwUser.getId());
+        qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
+        qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
+        qwIpadServerLog.setCreateTime(new Date());
+        qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
+        qwIpadServerUserService.deleteQwIpadServerUserByQwUserId(qwUser.getId());
+        WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
+        wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
+        wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
+        updateIpadStatus(qwUser.getId(),0);
+    }
+
+    public static boolean isCreateTimeMoreThanDaysWithOptional(Date createTime, int days) {
+        return Optional.ofNullable(createTime)
+                .map(time -> {
+                    LocalDateTime createDateTime = time.toInstant()
+                            .atZone(ZoneId.systemDefault())
+                            .toLocalDateTime();
+                    LocalDateTime now = LocalDateTime.now();
+                    Duration duration = Duration.between(createDateTime, now);
+                    return duration.toDays() > days;
+                })
+                .orElse(false); // 为null时返回false,可根据需求调整
+    }
 
 
     void updateIpadStatus(Long id ,Integer status){
     void updateIpadStatus(Long id ,Integer status){
         QwUser u = new QwUser();
         QwUser u = new QwUser();
@@ -286,4 +334,39 @@ public class qwTask {
         qwUserMapper.updateQwUser(u);
         qwUserMapper.updateQwUser(u);
     }
     }
 
 
+
+    /**
+     * 强制注册-2025-11-12 之后的 更新
+     */
+    public void QwExternalContactMandatoryRegistration(){
+        try {
+//            List<String> longs = qwExternalContactService.selectQwExternalContactMandatoryRegistration();
+            List<String> longs = iQwCompanyService.selectQwCompanyListFormCorpId();
+            longs.forEach(item->{
+                List<QwMandatoryRegistrParam> registrParamList = qwExternalContactService.selectQwExternalContactMandatoryRegistrationByIds(String.valueOf(item));
+
+                batchUpdateQwExternalContactMandatoryRegistration(registrParamList);
+
+            });
+        }catch (Exception e){
+
+        }
+
+    }
+
+
+    private void batchUpdateQwExternalContactMandatoryRegistration(List<QwMandatoryRegistrParam> registrParamList) {
+        // 定义批量插入的大小
+        int batchSize = 300;
+
+        // 循环处理外部用户 ID,每次处理批量大小的子集
+        for (int i = 0; i < registrParamList.size(); i += batchSize) {
+
+            int endIndex = Math.min(i + batchSize, registrParamList.size());
+            List<QwMandatoryRegistrParam> batchList = registrParamList.subList(i, endIndex);  // 获取当前批次的子集
+
+            qwExternalContactService.batchUpdateQwExternalContactMandatoryRegistration(batchList);
+
+        }
+    }
 }
 }

+ 1 - 1
fs-admin/src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 # Spring配置
 # Spring配置
 spring:
 spring:
   profiles:
   profiles:
-    active: druid-bjzm-test
+    active: druid-ylrz
 #    active: druid-hdt
 #    active: druid-hdt
 #    active: druid-yzt
 #    active: druid-yzt
 #    active: druid-sxjz-test
 #    active: druid-sxjz-test

+ 6 - 0
fs-common-api/Dockerfile

@@ -0,0 +1,6 @@
+FROM openjdk:8-jre
+# java版本,最好使用openjdk,而不是类似于Java:1.8
+COPY ./target/fs-common-api.jar fs-common-api.jar
+# 向外暴露的接口,最好与项目yml文件中的端口一致
+ENTRYPOINT ["java","-jar","fs-common-api.jar"]
+# 执行启动命令java -jar

+ 24 - 0
fs-common-api/pom.xml

@@ -118,6 +118,30 @@
                     <warName>${project.artifactId}</warName>
                     <warName>${project.artifactId}</warName>
                 </configuration>
                 </configuration>
             </plugin>
             </plugin>
+<!--            <plugin>-->
+<!--                <groupId>com.spotify</groupId>-->
+<!--                <artifactId>dockerfile-maven-plugin</artifactId>-->
+<!--                <version>1.4.13</version>-->
+<!--                <executions>-->
+<!--                    <execution>-->
+<!--                        <id>harbor</id>-->
+<!--                        <goals>-->
+<!--                            <goal>build</goal>-->
+<!--                            <goal>push</goal>-->
+<!--                        </goals>-->
+<!--                    </execution>-->
+<!--                </executions>-->
+<!--                <configuration>-->
+<!--                    <repository>ylrz-docker.tencentcloudcr.com/ylrz/sub1/repo</repository>-->
+<!--                    <tag>${project.version}</tag>-->
+<!--                    <useMavenSettingsForAuth>true</useMavenSettingsForAuth>-->
+<!--                    <username>100044034444</username>-->
+<!--                    <password>eyJhbGciOiJSUzI1NiIsImtpZCI6Ilg0R1k6SDU1TjpCQU9SOk5GVk86RkdSWDpYTjM1OjZGQUM6S1BBWjo0TE4yOkhDSUQ6UTJDRzpSN1NHIn0.eyJvd25lclVpbiI6IjEwMDAzNDY4ODY0OCIsIm9wZXJhdG9yVWluIjoiMTAwMDQ0MDM0NDQ0IiwidG9rZW5JZCI6ImQ0ZnZja2o4a2NnbnFjaTVvanQwIiwiZXhwIjoyMDc5MDYyMzU0LCJuYmYiOjE3NjM3MDIzNTQsImlhdCI6MTc2MzcwMjM1NH0.PhNxx6pBQ-ItrNlSs_gojvXeHghhYqDqxh8nLUIuhBeRzAgmVnY8F3bFPVgbHGydQNxvgyqLYv3nRIE1j020LGgzUetF5b-NBqSWYMiXfu6uZNWctRkwm5hdlWBrMlV8k8zGxY4ZDGUNEG0ksrk7kk3UZ-lHj4ButI2GIEhTx0lQEPHjhEY0xuteocJVYMHdVUqF-Bc5Jr0nvbwxUbmCGakN1VszxBoMpI-zA2O8anMvYq8h7EqOJLU4dlBVcsbkz-4sMi97Xev-mcGh7THbEGWoRWGWNSa4QwsdXEXS5-mhfrvOw6FGuuiIeEQvcuR8zDztDzSApl4ko57Yat-AQQ</password>-->
+<!--                    <buildArgs>-->
+<!--                        <JAR_FILE>${project.artifactId}.jar</JAR_FILE>-->
+<!--                    </buildArgs>-->
+<!--                </configuration>-->
+<!--            </plugin>-->
         </plugins>
         </plugins>
         <finalName>${project.artifactId}</finalName>
         <finalName>${project.artifactId}</finalName>
     </build>
     </build>

+ 1 - 1
fs-common-api/src/main/resources/application.yml

@@ -5,4 +5,4 @@ server:
 spring:
 spring:
   profiles:
   profiles:
 #    active: dev
 #    active: dev
-    active: druid-myhk-test
+    active: druid-ylrz

+ 6 - 0
fs-common/src/main/java/com/fs/common/constant/LiveKeysConstant.java

@@ -30,5 +30,11 @@ public class LiveKeysConstant {
     public static final String LIVE_FLAG_CACHE = "live:flag:%s"; //直播间直播/回放状态缓存
     public static final String LIVE_FLAG_CACHE = "live:flag:%s"; //直播间直播/回放状态缓存
     public static final Integer LIVE_FLAG_CACHE_EXPIRE = 300; //直播间状态缓存过期时间(秒)
     public static final Integer LIVE_FLAG_CACHE_EXPIRE = 300; //直播间状态缓存过期时间(秒)
 
 
+    public static final String LIVE_DATA_CACHE = "live:data:%s"; //直播间数据缓存
+    public static final Integer LIVE_DATA_CACHE_EXPIRE = 300; //直播间数据缓存过期时间(秒)
+
+    public static final String PRODUCT_DETAIL_CACHE = "product:detail:%s"; //商品详情缓存
+    public static final Integer PRODUCT_DETAIL_CACHE_EXPIRE = 300; //商品详情缓存过期时间(秒)
+
 
 
 }
 }

+ 6 - 0
fs-company/Dockerfile

@@ -0,0 +1,6 @@
+FROM openjdk:8-jre
+# java版本,最好使用openjdk,而不是类似于Java:1.8
+COPY ./target/fs-company.jar fs-company.jar
+# 向外暴露的接口,最好与项目yml文件中的端口一致
+ENTRYPOINT ["java","-jar","fs-company.jar"]
+# 执行启动命令java -jar

+ 32 - 21
fs-company/src/main/java/com/fs/company/controller/live/LiveController.java

@@ -134,7 +134,8 @@ public class LiveController extends BaseController
     {
     {
         // 设置企业ID和企业用户ID
         // 设置企业ID和企业用户ID
         setCompanyId(live);
         setCompanyId(live);
-        return toAjax(liveService.insertLive(live));
+        return toAjax(1);
+//        return toAjax(liveService.insertLive(live));
     }
     }
 
 
     /**
     /**
@@ -146,7 +147,8 @@ public class LiveController extends BaseController
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         live.setCompanyUserId(user.getUserId());
         live.setCompanyUserId(user.getUserId());
         live.setCompanyId(user.getCompanyId());
         live.setCompanyId(user.getCompanyId());
-        return liveService.finishLive(live);
+        return R.ok();
+//        return liveService.finishLive(live);
     }
     }
 
 
     /**
     /**
@@ -158,7 +160,8 @@ public class LiveController extends BaseController
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         live.setCompanyUserId(user.getUserId());
         live.setCompanyUserId(user.getUserId());
         live.setCompanyId(user.getCompanyId());
         live.setCompanyId(user.getCompanyId());
-        return liveService.copyLive(live);
+        return R.ok();
+//        return liveService.copyLive(live);
     }
     }
 
 
     /**
     /**
@@ -170,7 +173,8 @@ public class LiveController extends BaseController
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         live.setCompanyUserId(user.getUserId());
         live.setCompanyUserId(user.getUserId());
         live.setCompanyId(user.getCompanyId());
         live.setCompanyId(user.getCompanyId());
-        return liveService.startLive(live);
+        return R.ok();
+//        return liveService.startLive(live);
     }
     }
 
 
     /**
     /**
@@ -181,10 +185,12 @@ public class LiveController extends BaseController
     @PutMapping
     @PutMapping
     public AjaxResult edit(@RequestBody Live live)
     public AjaxResult edit(@RequestBody Live live)
     {
     {
-        CompanyUser user = SecurityUtils.getLoginUser().getUser();
-        live.setCompanyUserId(user.getUserId());
-        live.setCompanyId(user.getCompanyId());
-        return toAjax(liveService.updateLive(live));
+        return AjaxResult.success();
+//        CompanyUser user = SecurityUtils.getLoginUser().getUser();
+//        live.setCompanyUserId(user.getUserId());
+//        live.setCompanyId(user.getCompanyId());
+//
+//        return toAjax(liveService.updateLive(live));
     }
     }
 
 
     /**
     /**
@@ -195,11 +201,12 @@ public class LiveController extends BaseController
 	@DeleteMapping("/{liveIds}")
 	@DeleteMapping("/{liveIds}")
     public AjaxResult remove(@PathVariable Long[] liveIds)
     public AjaxResult remove(@PathVariable Long[] liveIds)
     {
     {
-        Live live = new Live();
-        CompanyUser user = SecurityUtils.getLoginUser().getUser();
-        live.setCompanyUserId(user.getUserId());
-        live.setCompanyId(user.getCompanyId());
-        return toAjax(liveService.deleteLiveByLiveIds(liveIds, live));
+        return AjaxResult.success();
+//        Live live = new Live();
+//        CompanyUser user = SecurityUtils.getLoginUser().getUser();
+//        live.setCompanyUserId(user.getUserId());
+//        live.setCompanyId(user.getCompanyId());
+//        return toAjax(liveService.deleteLiveByLiveIds(liveIds, live));
     }
     }
 
 
     @PreAuthorize("@ss.hasPermi('live:live:query')")
     @PreAuthorize("@ss.hasPermi('live:live:query')")
@@ -217,9 +224,10 @@ public class LiveController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PostMapping("/closeLiving")
     @PostMapping("/closeLiving")
     public R closeLiving(@RequestBody Map<String, String> payload) {
     public R closeLiving(@RequestBody Map<String, String> payload) {
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
-        payload.put("userId", loginUser.getUser().getUserId().toString());
-        return liveService.closeLiving(payload);
+        return R.ok();
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        payload.put("userId", loginUser.getUser().getUserId().toString());
+//        return liveService.closeLiving(payload);
     }
     }
 
 
     @PreAuthorize("@ss.hasPermi('live:live:insert')")
     @PreAuthorize("@ss.hasPermi('live:live:insert')")
@@ -247,7 +255,8 @@ public class LiveController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PostMapping("/startLoopPlay")
     @PostMapping("/startLoopPlay")
     public R startLoopPlay(@RequestBody Live live) {
     public R startLoopPlay(@RequestBody Live live) {
-        return liveService.startLoopPlay(live);
+        return R.ok();
+//        return liveService.startLoopPlay(live);
     }
     }
 
 
     /**
     /**
@@ -265,8 +274,9 @@ public class LiveController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PostMapping("/handleShelfOrUn")
     @PostMapping("/handleShelfOrUn")
     public R handleShelfOrUn(@RequestBody LiveListVo listVo) {
     public R handleShelfOrUn(@RequestBody LiveListVo listVo) {
-        setListCompanyId(listVo);
-        return liveService.handleShelfOrUn(listVo);
+        return R.ok();
+//        setListCompanyId(listVo);
+//        return liveService.handleShelfOrUn(listVo);
     }
     }
 
 
     /**
     /**
@@ -275,8 +285,9 @@ public class LiveController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PreAuthorize("@ss.hasPermi('live:live:edit')")
     @PostMapping("/handleDeleteSelected")
     @PostMapping("/handleDeleteSelected")
     public R handleDeleteSelected(@RequestBody LiveListVo listVo) {
     public R handleDeleteSelected(@RequestBody LiveListVo listVo) {
-        setListCompanyId(listVo);
-        return liveService.handleDeleteSelected(listVo);
+        return R.ok();
+//        setListCompanyId(listVo);
+//        return liveService.handleDeleteSelected(listVo);
     }
     }
 
 
 
 

+ 8 - 0
fs-company/src/main/java/com/fs/company/controller/qw/QwExternalContactController.java

@@ -113,6 +113,10 @@ public class QwExternalContactController extends BaseController
 
 
         startPage();
         startPage();
         qwExternalContact.setCompanyId(loginUser.getCompany().getCompanyId());
         qwExternalContact.setCompanyId(loginUser.getCompany().getCompanyId());
+        if(StringUtils.isNotEmpty(qwExternalContact.getStatuses())){
+            String[] split = qwExternalContact.getStatuses().split(",");
+            qwExternalContact.setStatusCondition(split);
+        }
         List<QwExternalContactVO> list = qwExternalContactService.selectQwExternalContactListVO(qwExternalContact);
         List<QwExternalContactVO> list = qwExternalContactService.selectQwExternalContactListVO(qwExternalContact);
         list.forEach(item->{
         list.forEach(item->{
 
 
@@ -343,6 +347,10 @@ public class QwExternalContactController extends BaseController
         List<QwContactWay> wayList = qwContactWayService.selectQwContactWayList(qwContactWay);
         List<QwContactWay> wayList = qwContactWayService.selectQwContactWayList(qwContactWay);
 
 
         qwExternalContact.setCompanyId(loginUser.getCompany().getCompanyId());
         qwExternalContact.setCompanyId(loginUser.getCompany().getCompanyId());
+        if(StringUtils.isNotEmpty(qwExternalContact.getStatuses())){
+            String[] split = qwExternalContact.getStatuses().split(",");
+            qwExternalContact.setStatusCondition(split);
+        }
         List<QwExternalContactVO> list = qwExternalContactService.selectQwExternalContactListVO(qwExternalContact);
         List<QwExternalContactVO> list = qwExternalContactService.selectQwExternalContactListVO(qwExternalContact);
         list.forEach(item->{
         list.forEach(item->{
 
 

+ 3 - 3
fs-company/src/main/java/com/fs/company/controller/qw/QwExternalContactTransferLogController.java

@@ -104,10 +104,10 @@ public class QwExternalContactTransferLogController extends BaseController
     @PreAuthorize("@ss.hasPermi('qw:externalContactTransferLog:export')")
     @PreAuthorize("@ss.hasPermi('qw:externalContactTransferLog:export')")
     @Log(title = "转接记录", businessType = BusinessType.EXPORT)
     @Log(title = "转接记录", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     @GetMapping("/export")
-    public AjaxResult export(QwExternalContactTransferLog qwExternalContactTransferLog)
+    public AjaxResult export(QwExternalContactTransferLogParam qwExternalContactTransferLog)
     {
     {
-        List<QwExternalContactTransferLog> list = qwExternalContactTransferLogService.selectQwExternalContactTransferLogList(qwExternalContactTransferLog);
-        ExcelUtil<QwExternalContactTransferLog> util = new ExcelUtil<QwExternalContactTransferLog>(QwExternalContactTransferLog.class);
+        List<QwExternalContactTransferLogListVO> list = qwExternalContactTransferLogService.selectQwExternalContactTransferLogListVO(qwExternalContactTransferLog);
+        ExcelUtil<QwExternalContactTransferLogListVO> util = new ExcelUtil<QwExternalContactTransferLogListVO>(QwExternalContactTransferLogListVO.class);
         return util.exportExcel(list, "转接记录数据");
         return util.exportExcel(list, "转接记录数据");
     }
     }
 
 

+ 3 - 2
fs-company/src/main/resources/application.yml

@@ -1,13 +1,14 @@
 server:
 server:
-  port: 8006
+  port: 7773
 # Spring配置
 # Spring配置
 spring:
 spring:
   profiles:
   profiles:
+    active: druid-ylrz
 #    active: druid-jnsyj-test
 #    active: druid-jnsyj-test
 #    active: druid-jnmy-test
 #    active: druid-jnmy-test
 #    active: druid-jzzx-test
 #    active: druid-jzzx-test
 #    active: druid-hdt
 #    active: druid-hdt
-    active: druid-bjzm-test
+#    active: druid-bjzm-test
 #    active: druid-yzt
 #    active: druid-yzt
 #    active: druid-myhk
 #    active: druid-myhk
 #    active: druid-sft
 #    active: druid-sft

+ 0 - 1
fs-live-app/src/main/java/com/fs/framework/aspectj/LiveWatchUserAspect.java

@@ -33,7 +33,6 @@ public class LiveWatchUserAspect {
         try {
         try {
             String methodName = joinPoint.getSignature().getName();
             String methodName = joinPoint.getSignature().getName();
             Object[] args = joinPoint.getArgs();
             Object[] args = joinPoint.getArgs();
-            log.info("直播观看用户数据发生变化,方法: {}, 参数: {}", methodName, Arrays.toString(args));
             // 提取liveId并处理缓存更新
             // 提取liveId并处理缓存更新
             Set<Long> liveIds = extractLiveIds(methodName, args);
             Set<Long> liveIds = extractLiveIds(methodName, args);
             for (Long liveId : liveIds) {
             for (Long liveId : liveIds) {

+ 1 - 1
fs-live-app/src/main/java/com/fs/framework/aspectj/RateLimiterAspect.java

@@ -73,7 +73,7 @@ public class RateLimiterAspect
             {
             {
                 throw new ServiceException("访问过于频繁,请稍后再试");
                 throw new ServiceException("访问过于频繁,请稍后再试");
             }
             }
-            log.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), key);
+
         }
         }
         catch (ServiceException e)
         catch (ServiceException e)
         {
         {

+ 0 - 2
fs-live-app/src/main/java/com/fs/live/controller/LiveDataController.java

@@ -15,7 +15,6 @@ public class LiveDataController extends BaseController {
 
 
     @Autowired
     @Autowired
     private RedisCache redisCache;
     private RedisCache redisCache;
-
     /**
     /**
      * 点赞
      * 点赞
      * */
      * */
@@ -23,7 +22,6 @@ public class LiveDataController extends BaseController {
     public R like(@PathVariable("liveId") Long liveId) {
     public R like(@PathVariable("liveId") Long liveId) {
         //直播间总点赞数
         //直播间总点赞数
         Long increment = redisCache.incr("live:like:" + liveId, 1);
         Long increment = redisCache.incr("live:like:" + liveId, 1);
-
         return R.ok().put("like",increment);
         return R.ok().put("like",increment);
     }
     }
 }
 }

+ 12 - 11
fs-live-app/src/main/java/com/fs/live/websocket/handle/LiveChatHandler.java

@@ -3,6 +3,8 @@ package com.fs.live.websocket.handle;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUser;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserService;
+import com.fs.hisStore.domain.FsUserScrm;
+import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.live.websocket.bean.SendMsgVo;
 import com.fs.live.websocket.bean.SendMsgVo;
 import com.fs.live.websocket.constant.AttrConstant;
 import com.fs.live.websocket.constant.AttrConstant;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
@@ -41,7 +43,7 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
     private final static ILiveService liveService = SpringUtils.getBean(ILiveService.class);
     private final static ILiveService liveService = SpringUtils.getBean(ILiveService.class);
     private final static ILiveWatchUserService liveWatchUserService = SpringUtils.getBean(ILiveWatchUserService.class);
     private final static ILiveWatchUserService liveWatchUserService = SpringUtils.getBean(ILiveWatchUserService.class);
     private final static ILiveMsgService liveMsgService = SpringUtils.getBean(ILiveMsgService.class);
     private final static ILiveMsgService liveMsgService = SpringUtils.getBean(ILiveMsgService.class);
-    private final static IFsUserService fsUserService = SpringUtils.getBean(IFsUserService.class);
+    private final static IFsUserScrmService fsUserService = SpringUtils.getBean(IFsUserScrmService.class);
 
 
     /**
     /**
      * 处理握手
      * 处理握手
@@ -51,7 +53,7 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
      */
      */
     @Override
     @Override
     public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
     public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
-        log.debug("事件");
+
         // 处理 WebSocket 握手完成事件
         // 处理 WebSocket 握手完成事件
         if (evt instanceof WebSocketServerProtocolHandler.HandshakeComplete) {
         if (evt instanceof WebSocketServerProtocolHandler.HandshakeComplete) {
             Long userId = ctx.channel().attr(AttrConstant.ATTR_USER_ID).get();
             Long userId = ctx.channel().attr(AttrConstant.ATTR_USER_ID).get();
@@ -70,11 +72,12 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
             roomGroup.add(ctx.channel());
             roomGroup.add(ctx.channel());
 
 
             if (userType == 0) {
             if (userType == 0) {
+
+
+                FsUserScrm fsUser = fsUserService.selectFsUserByUserId(userId);
                 // 加入房间
                 // 加入房间
-                LiveWatchUser liveWatchUser = liveWatchUserService.joinWithoutLocation(liveId, userId);
+                LiveWatchUser liveWatchUser = liveWatchUserService.joinWithoutLocation(fsUser,liveId, userId);
                 room.put(userId, ctx.channel());
                 room.put(userId, ctx.channel());
-
-                FsUser fsUser = fsUserService.selectFsUserByUserId(userId);
                 if (Objects.isNull(fsUser)) {
                 if (Objects.isNull(fsUser)) {
                     ctx.channel().writeAndFlush(new TextWebSocketFrame("Error: 用户信息错误")).addListener(ChannelFutureListener.CLOSE);
                     ctx.channel().writeAndFlush(new TextWebSocketFrame("Error: 用户信息错误")).addListener(ChannelFutureListener.CLOSE);
                     return;
                     return;
@@ -97,7 +100,6 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
                 adminRoom.add(ctx.channel());
                 adminRoom.add(ctx.channel());
             }
             }
 
 
-            log.debug("加入webSocket liveId: {}, userId: {}, 直播间人数: {}", liveId, userId, room.size());
         }
         }
     }
     }
 
 
@@ -154,7 +156,7 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
      */
      */
     @Override
     @Override
     protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame) throws Exception {
     protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame) throws Exception {
-        log.debug("接收到消息 data: {}", textWebSocketFrame.text());
+
         Long liveId = channelHandlerContext.channel().attr(AttrConstant.ATTR_LIVE_ID).get();
         Long liveId = channelHandlerContext.channel().attr(AttrConstant.ATTR_LIVE_ID).get();
         Long userType = channelHandlerContext.channel().attr(AttrConstant.ATTR_USER_TYPE).get();
         Long userType = channelHandlerContext.channel().attr(AttrConstant.ATTR_USER_TYPE).get();
 
 
@@ -204,7 +206,7 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
      */
      */
     @Override
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.debug("断开连接");
+
         Long userId = ctx.channel().attr(AttrConstant.ATTR_USER_ID).get();
         Long userId = ctx.channel().attr(AttrConstant.ATTR_USER_ID).get();
         Long liveId = ctx.channel().attr(AttrConstant.ATTR_LIVE_ID).get();
         Long liveId = ctx.channel().attr(AttrConstant.ATTR_LIVE_ID).get();
         Long userType = ctx.channel().attr(AttrConstant.ATTR_USER_TYPE).get();
         Long userType = ctx.channel().attr(AttrConstant.ATTR_USER_TYPE).get();
@@ -218,8 +220,8 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
         ChannelGroup roomGroup = getRoomGroup(liveId);
         ChannelGroup roomGroup = getRoomGroup(liveId);
 
 
         if (userType == 0) {
         if (userType == 0) {
-            FsUser fsUser = fsUserService.selectFsUserByUserId(userId);
-            LiveWatchUser close = liveWatchUserService.close(liveId, userId);
+            FsUserScrm fsUser = fsUserService.selectFsUserByUserId(userId);
+            LiveWatchUser close = liveWatchUserService.close(fsUser,liveId, userId);
             room.remove(userId);
             room.remove(userId);
 
 
             if (room.isEmpty()) {
             if (room.isEmpty()) {
@@ -251,7 +253,6 @@ public class LiveChatHandler extends SimpleChannelInboundHandler<TextWebSocketFr
             roomGroups.remove(liveId);
             roomGroups.remove(liveId);
         }
         }
 
 
-        log.debug("断开webSocket liveId: {}, userId: {}, 直播间人数: {}", liveId, userId, room.size());
 
 
     }
     }
 
 

+ 230 - 56
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -22,6 +22,7 @@ import com.fs.live.service.*;
 import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveGoodsVo;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateUtils;
 import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -30,10 +31,9 @@ import javax.websocket.server.ServerEndpoint;
 import java.io.EOFException;
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.*;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 
 import static com.fs.common.constant.LiveKeysConstant.*;
 import static com.fs.common.constant.LiveKeysConstant.*;
 
 
@@ -49,6 +49,16 @@ public class WebSocketServer {
     private final static ConcurrentHashMap<Long, ConcurrentHashMap<Long, Session>> rooms = new ConcurrentHashMap<>();
     private final static ConcurrentHashMap<Long, ConcurrentHashMap<Long, Session>> rooms = new ConcurrentHashMap<>();
     // 管理端连接
     // 管理端连接
     private final static ConcurrentHashMap<Long, CopyOnWriteArrayList<Session>> adminRooms = new ConcurrentHashMap<>();
     private final static ConcurrentHashMap<Long, CopyOnWriteArrayList<Session>> adminRooms = new ConcurrentHashMap<>();
+
+    // Session发送锁,避免同一会话并发发送消息
+    private final static ConcurrentHashMap<String, Lock> sessionLocks = new ConcurrentHashMap<>();
+    // 心跳超时缓存:key=sessionId,value=最后心跳时间戳
+    private final static ConcurrentHashMap<String, Long> heartbeatCache = new ConcurrentHashMap<>();
+    // 心跳超时时间(毫秒):3分钟无心跳则认为超时
+    private final static long HEARTBEAT_TIMEOUT = 3 * 60 * 1000;
+    // admin房间消息发送线程池(单线程,保证串行化)
+    private final static ConcurrentHashMap<Long, ExecutorService> adminExecutors = new ConcurrentHashMap<>();
+
     private final RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
     private final RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
     private final ILiveMsgService liveMsgService = SpringUtils.getBean(ILiveMsgService.class);
     private final ILiveMsgService liveMsgService = SpringUtils.getBean(ILiveMsgService.class);
     private final ILiveService liveService = SpringUtils.getBean(ILiveService.class);
     private final ILiveService liveService = SpringUtils.getBean(ILiveService.class);
@@ -62,6 +72,7 @@ public class WebSocketServer {
     private final ILiveUserFirstEntryService liveUserFirstEntryService =  SpringUtils.getBean(ILiveUserFirstEntryService.class);
     private final ILiveUserFirstEntryService liveUserFirstEntryService =  SpringUtils.getBean(ILiveUserFirstEntryService.class);
     private final ILiveCouponIssueService liveCouponIssueService =  SpringUtils.getBean(ILiveCouponIssueService.class);
     private final ILiveCouponIssueService liveCouponIssueService =  SpringUtils.getBean(ILiveCouponIssueService.class);
     private final LiveCouponMapper liveCouponMapper = SpringUtils.getBean(LiveCouponMapper.class);
     private final LiveCouponMapper liveCouponMapper = SpringUtils.getBean(LiveCouponMapper.class);
+    private static Random random = new Random();
 
 
     // 直播间在线用户缓存
     // 直播间在线用户缓存
 //    private static final ConcurrentHashMap<Long, Integer> liveOnlineUsers = new ConcurrentHashMap<>();
 //    private static final ConcurrentHashMap<Long, Integer> liveOnlineUsers = new ConcurrentHashMap<>();
@@ -101,7 +112,7 @@ public class WebSocketServer {
                 throw new BaseException("用户信息错误");
                 throw new BaseException("用户信息错误");
             }
             }
 
 
-            LiveWatchUser liveWatchUserVO = liveWatchUserService.join(liveId, userId, location);
+            LiveWatchUser liveWatchUserVO = liveWatchUserService.join(fsUser,liveId, userId, location);
             room.put(userId, session);
             room.put(userId, session);
             // 直播间浏览量 +1
             // 直播间浏览量 +1
             redisCache.incr(PAGE_VIEWS_KEY + liveId, 1);
             redisCache.incr(PAGE_VIEWS_KEY + liveId, 1);
@@ -135,17 +146,19 @@ public class WebSocketServer {
                 redisCache.incr(UNIQUE_VIEWERS_KEY + liveId, 1);
                 redisCache.incr(UNIQUE_VIEWERS_KEY + liveId, 1);
             }
             }
             liveWatchUserVO.setMsgStatus(liveWatchUserVO.getMsgStatus());
             liveWatchUserVO.setMsgStatus(liveWatchUserVO.getMsgStatus());
-            SendMsgVo sendMsgVo = new SendMsgVo();
-            sendMsgVo.setLiveId(liveId);
-            sendMsgVo.setUserId(userId);
-            sendMsgVo.setUserType(userType);
-            sendMsgVo.setCmd("entry");
-            sendMsgVo.setMsg("用户进入");
-            sendMsgVo.setData(JSONObject.toJSONString(liveWatchUserVO));
-            sendMsgVo.setNickName(fsUser.getNickname());
-            sendMsgVo.setAvatar(fsUser.getAvatar());
-            // 广播连接消息
-            broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+            if (1 == random.nextInt(4)) {
+                SendMsgVo sendMsgVo = new SendMsgVo();
+                sendMsgVo.setLiveId(liveId);
+                sendMsgVo.setUserId(userId);
+                sendMsgVo.setUserType(userType);
+                sendMsgVo.setCmd("entry");
+                sendMsgVo.setMsg("用户进入");
+                sendMsgVo.setData(JSONObject.toJSONString(liveWatchUserVO));
+                sendMsgVo.setNickName(fsUser.getNickname());
+                sendMsgVo.setAvatar(fsUser.getAvatar());
+                // 广播连接消息
+                broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+            }
 
 
             LiveUserFirstEntry liveUserFirstEntry = liveUserFirstEntryService.selectEntityByLiveIdUserId(liveId, userId);
             LiveUserFirstEntry liveUserFirstEntry = liveUserFirstEntryService.selectEntityByLiveIdUserId(liveId, userId);
             if (liveUserFirstEntry != null) {
             if (liveUserFirstEntry != null) {
@@ -177,9 +190,15 @@ public class WebSocketServer {
 
 
         } else {
         } else {
             adminRoom.add(session);
             adminRoom.add(session);
+            // 为admin房间创建单线程执行器,保证串行化发送
+            adminExecutors.computeIfAbsent(liveId, k -> Executors.newSingleThreadExecutor());
         }
         }
 
 
-        log.debug("加入webSocket liveId: {}, userId: {}, 直播间人数: {}, 管理端人数: {}", liveId, userId, room.size(), adminRoom.size());
+        // 初始化Session锁
+        sessionLocks.putIfAbsent(session.getId(), new ReentrantLock());
+        // 初始化心跳时间
+        heartbeatCache.put(session.getId(), System.currentTimeMillis());
+
     }
     }
 
 
     //关闭连接时调用
     //关闭连接时调用
@@ -209,24 +228,38 @@ public class WebSocketServer {
             // 从在线用户Set中移除用户ID
             // 从在线用户Set中移除用户ID
             String onlineUsersSetKey = ONLINE_USERS_SET_KEY + liveId;
             String onlineUsersSetKey = ONLINE_USERS_SET_KEY + liveId;
             redisCache.redisTemplate.opsForSet().remove(onlineUsersSetKey, String.valueOf(userId));
             redisCache.redisTemplate.opsForSet().remove(onlineUsersSetKey, String.valueOf(userId));
-            LiveWatchUser liveWatchUserVO = liveWatchUserService.close(liveId, userId);
-            SendMsgVo sendMsgVo = new SendMsgVo();
-            sendMsgVo.setLiveId(liveId);
-            sendMsgVo.setUserId(userId);
-            sendMsgVo.setUserType(userType);
-            sendMsgVo.setCmd("out");
-            sendMsgVo.setMsg("用户离开");
-            sendMsgVo.setData(JSONObject.toJSONString(liveWatchUserVO));
-            sendMsgVo.setNickName(fsUser.getNickname());
-            sendMsgVo.setAvatar(fsUser.getAvatar());
-
-            // 广播离开消息
-            broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+            LiveWatchUser liveWatchUserVO = liveWatchUserService.close(fsUser,liveId, userId);
+
+
+            // 广播离开消息 添加一个概率问题 摇塞子,1-4 当为1的时候广播消息
+            if (1 == new Random().nextInt(4)) {
+                SendMsgVo sendMsgVo = new SendMsgVo();
+                sendMsgVo.setLiveId(liveId);
+                sendMsgVo.setUserId(userId);
+                sendMsgVo.setUserType(userType);
+                sendMsgVo.setCmd("out");
+                sendMsgVo.setMsg("用户离开");
+                sendMsgVo.setData(JSONObject.toJSONString(liveWatchUserVO));
+                sendMsgVo.setNickName(fsUser.getNickname());
+                sendMsgVo.setAvatar(fsUser.getAvatar());
+                broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+            }
+
         } else {
         } else {
             adminRoom.remove(session);
             adminRoom.remove(session);
+            // 如果admin房间为空,关闭并清理执行器
+            if (adminRoom.isEmpty()) {
+                ExecutorService executor = adminExecutors.remove(liveId);
+                if (executor != null) {
+                    executor.shutdown();
+                }
+                adminRooms.remove(liveId);
+            }
         }
         }
 
 
-        log.debug("离开webSocket liveId: {}, userId: {}, 直播间人数: {}, 管理端人数: {}", liveId, userId, room.size(), adminRoom.size());
+        // 清理Session相关资源
+        heartbeatCache.remove(session.getId());
+        sessionLocks.remove(session.getId());
     }
     }
 
 
     //收到客户端信息
     //收到客户端信息
@@ -243,6 +276,8 @@ public class WebSocketServer {
         try {
         try {
             switch (msg.getCmd()) {
             switch (msg.getCmd()) {
                 case "heartbeat":
                 case "heartbeat":
+                    // 更新心跳时间
+                    heartbeatCache.put(session.getId(), System.currentTimeMillis());
                     sendMessage(session, JSONObject.toJSONString(R.ok().put("data", msg)));
                     sendMessage(session, JSONObject.toJSONString(R.ok().put("data", msg)));
                     break;
                     break;
                 case "sendMsg":
                 case "sendMsg":
@@ -436,7 +471,6 @@ public class WebSocketServer {
      * 处理红包变动消息
      * 处理红包变动消息
      */
      */
     private void processRed(Long liveId, SendMsgVo msg) {
     private void processRed(Long liveId, SendMsgVo msg) {
-        log.debug("redData: {}", msg);
         JSONObject jsonObject = JSON.parseObject(msg.getData());
         JSONObject jsonObject = JSON.parseObject(msg.getData());
         Integer status = jsonObject.getInteger("status");
         Integer status = jsonObject.getInteger("status");
         msg.setStatus( status);
         msg.setStatus( status);
@@ -452,7 +486,6 @@ public class WebSocketServer {
      * 处理抽奖变动消息
      * 处理抽奖变动消息
      */
      */
     private void processLottery(Long liveId, SendMsgVo msg) {
     private void processLottery(Long liveId, SendMsgVo msg) {
-        log.debug("lotteryData: {}", msg);
         JSONObject jsonObject = JSON.parseObject(msg.getData());
         JSONObject jsonObject = JSON.parseObject(msg.getData());
         Integer status = jsonObject.getInteger("status");
         Integer status = jsonObject.getInteger("status");
         msg.setStatus( status);
         msg.setStatus( status);
@@ -471,12 +504,7 @@ public class WebSocketServer {
         try {
         try {
             this.onClose(session);
             this.onClose(session);
         } catch (Exception e) {
         } catch (Exception e) {
-            log.error("webSocket 错误 onError", e);
-        }
-        if (throwable instanceof EOFException) {
-            log.info("WebSocket连接被客户端正常关闭(EOF),sessionId: {}", session.getId());
-        } else {
-            log.error("WebSocket连接错误", throwable);
+            log.error("webSocket 错误处理失败", e);
         }
         }
     }
     }
 
 
@@ -498,12 +526,36 @@ public class WebSocketServer {
         return adminRooms.computeIfAbsent(liveId, k -> new CopyOnWriteArrayList<>());
         return adminRooms.computeIfAbsent(liveId, k -> new CopyOnWriteArrayList<>());
     }
     }
 
 
-    //发送消息
+    //发送消息(带锁机制,避免并发发送)
     public void sendMessage(Session session, String message) throws IOException {
     public void sendMessage(Session session, String message) throws IOException {
-        session.getAsyncRemote().sendText(message);
+        if (session == null || !session.isOpen()) {
+            return;
+        }
+
+        // 获取Session锁
+        Lock lock = sessionLocks.get(session.getId());
+        if (lock == null) {
+            // 如果锁不存在,创建一个新锁
+            lock = sessionLocks.computeIfAbsent(session.getId(), k -> new ReentrantLock());
+        }
+
+        // 使用锁保证同一Session的消息串行发送
+        lock.lock();
+        try {
+            if (session.isOpen()) {
+                session.getAsyncRemote().sendText(message);
+            }
+        } finally {
+            lock.unlock();
+        }
     }
     }
 
 
     public void sendIntegralMessage(Long liveId, Long userId,Long scoreAmount) {
     public void sendIntegralMessage(Long liveId, Long userId,Long scoreAmount) {
+        ConcurrentHashMap<Long, Session> room = getRoom(liveId);
+        Session session = room.get(userId);
+        if (session == null || !session.isOpen()) {
+            return;
+        }
         SendMsgVo sendMsgVo = new SendMsgVo();
         SendMsgVo sendMsgVo = new SendMsgVo();
         sendMsgVo.setLiveId(liveId);
         sendMsgVo.setLiveId(liveId);
         sendMsgVo.setUserId(userId);
         sendMsgVo.setUserId(userId);
@@ -511,13 +563,19 @@ public class WebSocketServer {
         sendMsgVo.setCmd("Integral");
         sendMsgVo.setCmd("Integral");
         sendMsgVo.setMsg("恭喜你成功获得观看奖励:" + scoreAmount + "芳华币");
         sendMsgVo.setMsg("恭喜你成功获得观看奖励:" + scoreAmount + "芳华币");
         sendMsgVo.setData(String.valueOf(scoreAmount));
         sendMsgVo.setData(String.valueOf(scoreAmount));
-        ConcurrentHashMap<Long, Session> room = getRoom(liveId);
-        Session session = room.get(userId);
+
         if(Objects.isNull( session)) return;
         if(Objects.isNull( session)) return;
         session.getAsyncRemote().sendText(JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
         session.getAsyncRemote().sendText(JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
     }
     }
 
 
     private void sendBlockMessage(Long liveId, Long userId) {
     private void sendBlockMessage(Long liveId, Long userId) {
+
+        ConcurrentHashMap<Long, Session> room = getRoom(liveId);
+        Session session = room.get(userId);
+        if (session == null || !session.isOpen()) {
+            return;
+        }
+
         SendMsgVo sendMsgVo = new SendMsgVo();
         SendMsgVo sendMsgVo = new SendMsgVo();
         sendMsgVo.setLiveId(liveId);
         sendMsgVo.setLiveId(liveId);
         sendMsgVo.setUserId(userId);
         sendMsgVo.setUserId(userId);
@@ -525,8 +583,7 @@ public class WebSocketServer {
         sendMsgVo.setCmd("blockUser");
         sendMsgVo.setCmd("blockUser");
         sendMsgVo.setMsg("账号已被停用");
         sendMsgVo.setMsg("账号已被停用");
         sendMsgVo.setData(null);
         sendMsgVo.setData(null);
-        ConcurrentHashMap<Long, Session> room = getRoom(liveId);
-        Session session = room.get(userId);
+
         if(Objects.isNull( session)) return;
         if(Objects.isNull( session)) return;
         session.getAsyncRemote().sendText(JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
         session.getAsyncRemote().sendText(JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
     }
     }
@@ -540,16 +597,33 @@ public class WebSocketServer {
         ConcurrentHashMap<Long, Session> room = getRoom(liveId);
         ConcurrentHashMap<Long, Session> room = getRoom(liveId);
         List<Session> adminRoom = getAdminRoom(liveId);
         List<Session> adminRoom = getAdminRoom(liveId);
 
 
+        // 普通用户房间:并行发送
         room.forEach((k, v) -> {
         room.forEach((k, v) -> {
             if (v.isOpen()) {
             if (v.isOpen()) {
-                sendWithRetry(v,message,7);
+                sendWithRetry(v,message,1);
             }
             }
         });
         });
-        adminRoom.forEach(v -> {
-            if (v.isOpen()) {
-                sendWithRetry(v,message,7);
+
+        // admin房间:串行发送,使用单线程执行器
+        if (!adminRoom.isEmpty()) {
+            ExecutorService executor = adminExecutors.get(liveId);
+            if (executor != null && !executor.isShutdown()) {
+                executor.submit(() -> {
+                    for (Session session : adminRoom) {
+                        if (session.isOpen()) {
+                            sendWithRetry(session, message, 1);
+                        }
+                    }
+                });
+            } else {
+                // 如果执行器不存在或已关闭,直接发送
+                adminRoom.forEach(v -> {
+                    if (v.isOpen()) {
+                        sendWithRetry(v, message, 1);
+                    }
+                });
             }
             }
-        });
+        }
     }
     }
 
 
     public void removeLikeCountCache(Long liveId) {
     public void removeLikeCountCache(Long liveId) {
@@ -569,7 +643,6 @@ public class WebSocketServer {
                 String valueStr = cacheObject.toString().trim();
                 String valueStr = cacheObject.toString().trim();
                 current = Integer.parseInt(valueStr);
                 current = Integer.parseInt(valueStr);
             } catch (NumberFormatException e) {
             } catch (NumberFormatException e) {
-                log.error("点赞数格式错误,liveId: {}, value: {}", liveId, cacheObject, e);
                 continue;
                 continue;
             }
             }
             Integer last = lastLikeCountCache.getOrDefault(liveId, 0);
             Integer last = lastLikeCountCache.getOrDefault(liveId, 0);
@@ -585,6 +658,98 @@ public class WebSocketServer {
         lastLikeCountCache.keySet().removeIf(liveId -> !activeLiveIds.contains(liveId));
         lastLikeCountCache.keySet().removeIf(liveId -> !activeLiveIds.contains(liveId));
     }
     }
 
 
+
+    @Scheduled(fixedRate = 2000)// 每2秒执行一次
+    public void broadcastUserNumMessage() {
+        // 遍历每个直播间
+        for (Map.Entry<Long, ConcurrentHashMap<Long, Session>> entry : rooms.entrySet()) {
+            Long liveId = entry.getKey();
+            ConcurrentHashMap<Long, Session> room = entry.getValue();
+
+            // 统计当前直播间的在线人数
+            int onlineCount = room.size();
+
+            // 构造消息
+            SendMsgVo sendMsgVo = new SendMsgVo();
+            sendMsgVo.setLiveId(liveId);
+            sendMsgVo.setCmd("userCount");
+            sendMsgVo.setData(String.valueOf(onlineCount));
+
+            // 广播当前直播间的在线人数
+            broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+        }
+    }
+
+    /**
+     * 定时清理无效会话(每分钟执行一次)
+     * 检查心跳超时的会话并关闭
+     */
+    @Scheduled(fixedRate = 60000) // 每分钟执行一次
+    public void cleanInactiveSessions() {
+        long currentTime = System.currentTimeMillis();
+        int cleanedCount = 0;
+
+        // 遍历所有直播间
+        for (Map.Entry<Long, ConcurrentHashMap<Long, Session>> roomEntry : rooms.entrySet()) {
+            Long liveId = roomEntry.getKey();
+            ConcurrentHashMap<Long, Session> room = roomEntry.getValue();
+
+            // 检查普通用户会话
+            List<Long> toRemove = new ArrayList<>();
+            room.forEach((userId, session) -> {
+                Long lastHeartbeat = heartbeatCache.get(session.getId());
+                if (lastHeartbeat != null && (currentTime - lastHeartbeat) > HEARTBEAT_TIMEOUT) {
+                    toRemove.add(userId);
+                    try {
+                        if (session.isOpen()) {
+                            session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "心跳超时"));
+                        }
+                    } catch (Exception e) {
+                        log.error("关闭超时会话失败: sessionId={}, liveId={}, userId={}",
+                                session.getId(), liveId, userId, e);
+                    }
+                }
+            });
+
+            // 移除超时的会话
+            toRemove.forEach(room::remove);
+            cleanedCount += toRemove.size();
+        }
+
+        // 检查admin房间
+        for (Map.Entry<Long, CopyOnWriteArrayList<Session>> adminEntry : adminRooms.entrySet()) {
+            Long liveId = adminEntry.getKey();
+            CopyOnWriteArrayList<Session> adminRoom = adminEntry.getValue();
+
+            List<Session> toRemoveAdmin = new ArrayList<>();
+            for (Session session : adminRoom) {
+                Long lastHeartbeat = heartbeatCache.get(session.getId());
+                if (lastHeartbeat != null && (currentTime - lastHeartbeat) > HEARTBEAT_TIMEOUT) {
+                    toRemoveAdmin.add(session);
+                    try {
+                        if (session.isOpen()) {
+                            session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "心跳超时"));
+                        }
+                    } catch (Exception e) {
+                        log.error("关闭admin超时会话失败: sessionId={}, liveId={}",
+                                session.getId(), liveId, e);
+                    }
+                }
+            }
+
+            // 移除超时的admin会话
+            toRemoveAdmin.forEach(adminRoom::remove);
+            cleanedCount += toRemoveAdmin.size();
+        }
+
+        if (cleanedCount > 0) {
+            if (random.nextInt(10) == 1) {
+                log.info("已清理 {} 个无效会话", cleanedCount);
+            }
+        }
+    }
+
+
     /**
     /**
      * 广播点赞消息
      * 广播点赞消息
      * @param liveId   直播间ID
      * @param liveId   直播间ID
@@ -600,12 +765,15 @@ public class WebSocketServer {
     }
     }
 
 
     private void sendWithRetry(Session session, String message, int maxRetries) {
     private void sendWithRetry(Session session, String message, int maxRetries) {
+        if (session == null || !session.isOpen()) {
+            return;
+        }
+
         int attempts = 0;
         int attempts = 0;
         while (attempts < maxRetries) {
         while (attempts < maxRetries) {
             try {
             try {
-                if(session.isOpen()) {
-                    session.getAsyncRemote().sendText(message);
-                }
+                // 使用带锁的sendMessage方法,避免并发发送
+                sendMessage(session, message);
                 return;  // 发送成功,退出
                 return;  // 发送成功,退出
             } catch (Exception e) {
             } catch (Exception e) {
                 if (e.getMessage() != null && e.getMessage().contains("TEXT_FULL_WRITING")) {
                 if (e.getMessage() != null && e.getMessage().contains("TEXT_FULL_WRITING")) {
@@ -617,11 +785,15 @@ public class WebSocketServer {
                         break;
                         break;
                     }
                     }
                 } else {
                 } else {
-                    throw e;
+                    log.error("发送消息失败: sessionId={}, error={}", session.getId(), e.getMessage(), e);
+                    break;
                 }
                 }
             }
             }
         }
         }
-        log.info("超过重试次数, 消息 {}",message);
+
+        if (attempts >= maxRetries) {
+            log.warn("超过重试次数({}),放弃发送消息: sessionId={}", maxRetries, session.getId());
+        }
     }
     }
 
 
 
 
@@ -727,4 +899,6 @@ public class WebSocketServer {
         String key = "live:auto_task:";
         String key = "live:auto_task:";
         redisCache.redisTemplate.opsForZSet().removeRangeByScore(key + liveId, data, data);
         redisCache.redisTemplate.opsForZSet().removeRangeByScore(key + liveId, data, data);
     }
     }
+
 }
 }
+

+ 69 - 31
fs-qw-task/src/main/java/com/fs/app/controller/CommonController.java

@@ -46,13 +46,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 import com.fs.app.task.qwTask;
 import com.fs.app.task.qwTask;
 
 
+import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 
 @Api("公共接口")
 @Api("公共接口")
 @RestController
 @RestController
@@ -164,36 +163,39 @@ public class CommonController {
             List<QwUser> list = qwUserMapper.selectQwUserByTest();
             List<QwUser> list = qwUserMapper.selectQwUserByTest();
             for (QwUser qwUser : list) {
             for (QwUser qwUser : list) {
                 try {
                 try {
-                    Integer serverStatus = qwUser.getServerStatus();
-                    Long serverId = qwUser.getServerId();
-                    if (serverStatus==0){
-                        log.error("不需要解绑");
-                    }
+
+                     Long serverId = qwUser.getServerId();
+
                     if (serverId==null){
                     if (serverId==null){
-                        log.error("serverId不存在");
+                        System.out.println("serverId不存在");
+                    }else {
+                        //没绑定销售 或者 已经离职
+                        if (qwUser.getStatus()==0 || qwUser.getIsDel()==2){
+
+                            updateIpadStatus(qwUser,serverId);
+                        }
+
+                        //绑定了销售-也绑定了ipad,但是长时间离线的(离线状态,无操作超过2天的,也自动解绑)
+                        if(qwUser.getUpdateTime()!=null){
+                            Date createTime = qwUser.getUpdateTime();
+                            Integer serverStatus = qwUser.getServerStatus();
+                            Integer ipadStatus = qwUser.getIpadStatus();
+
+                            boolean result = isCreateTimeMoreThanDaysWithOptional(createTime, 2);
+                            //大于2天 ,绑定了ipad,离线
+                            if(result && serverStatus==1 && ipadStatus==0){
+                                updateIpadStatus(qwUser,serverId);
+
+                            }
+                        }
+
+
                     }
                     }
-                    QwUser u = new QwUser();
-                    u.setId(qwUser.getId());
-                    u.setServerId(null);
-                    u.setServerStatus(0);
-                    qwUserMapper.updateQwUser(u);
-                    ipadServerService.addServer(serverId);
-                    QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
-                    qwIpadServerLog.setType(2);
-                    qwIpadServerLog.setTilie("解绑");
-                    qwIpadServerLog.setServerId(serverId);
-                    qwIpadServerLog.setQwUserId(qwUser.getId());
-                    qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
-                    qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
-                    qwIpadServerLog.setCreateTime(new Date());
-                    qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
-                    qwIpadServerUserService.deleteQwIpadServerUserByQwUserId(qwUser.getId());
-                    WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
-                    wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
-                    wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
-                    updateIpadStatus(qwUser.getId(),0);
+
+
                 } catch (Exception e) {
                 } catch (Exception e) {
-                    log.error("解绑ipad报错",e);
+                    System.out.println("解绑ipad报错"+e);
+
                 }
                 }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
@@ -203,6 +205,42 @@ public class CommonController {
     }
     }
 
 
 
 
+    public void updateIpadStatus(QwUser qwUser,Long serverId){
+        QwUser u = new QwUser();
+        u.setId(qwUser.getId());
+        u.setServerId(null);
+        u.setServerStatus(0);
+        qwUserMapper.updateQwUser(u);
+        ipadServerService.addServer(serverId);
+        QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
+        qwIpadServerLog.setType(2);
+        qwIpadServerLog.setTilie("解绑");
+        qwIpadServerLog.setServerId(serverId);
+        qwIpadServerLog.setQwUserId(qwUser.getId());
+        qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
+        qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
+        qwIpadServerLog.setCreateTime(new Date());
+        qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
+        qwIpadServerUserService.deleteQwIpadServerUserByQwUserId(qwUser.getId());
+        WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
+        wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
+        wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
+        updateIpadStatus(qwUser.getId(),0);
+    }
+
+    public static boolean isCreateTimeMoreThanDaysWithOptional(Date createTime, int days) {
+        return Optional.ofNullable(createTime)
+                .map(time -> {
+                    LocalDateTime createDateTime = time.toInstant()
+                            .atZone(ZoneId.systemDefault())
+                            .toLocalDateTime();
+                    LocalDateTime now = LocalDateTime.now();
+                    Duration duration = Duration.between(createDateTime, now);
+                    return duration.toDays() > days;
+                })
+                .orElse(false); // 为null时返回false,可根据需求调整
+    }
+
     void updateIpadStatus(Long id ,Integer status){
     void updateIpadStatus(Long id ,Integer status){
         QwUser u = new QwUser();
         QwUser u = new QwUser();
         u.setId(id);
         u.setId(id);

+ 34 - 0
fs-qwhook/src/main/java/com/fs/app/controller/CommonController.java

@@ -17,6 +17,7 @@ import com.fs.his.service.IFsAppVersionService;
 import com.fs.qw.domain.*;
 import com.fs.qw.domain.*;
 import com.fs.qw.mapper.*;
 import com.fs.qw.mapper.*;
 import com.fs.qw.param.QwConfigSignatureParam;
 import com.fs.qw.param.QwConfigSignatureParam;
+import com.fs.qw.param.QwMandatoryRegistrParam;
 import com.fs.qw.service.*;
 import com.fs.qw.service.*;
 import com.fs.qw.vo.QwHookAuthVO;
 import com.fs.qw.vo.QwHookAuthVO;
 import com.fs.qwApi.param.QwExternalContactHParam;
 import com.fs.qwApi.param.QwExternalContactHParam;
@@ -34,6 +35,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
 @Api("公共接口")
 @Api("公共接口")
@@ -93,6 +96,37 @@ public class CommonController {
     @Autowired
     @Autowired
     private RocketMQTemplate rocketMQTemplate;
     private RocketMQTemplate rocketMQTemplate;
 
 
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+
+    @GetMapping("/MandatoryRegistration")
+    public R MandatoryRegistration() throws Exception {
+        List<String> longs = qwExternalContactService.selectQwExternalContactMandatoryRegistration();
+        longs.forEach(item->{
+            List<QwMandatoryRegistrParam> registrParamList = qwExternalContactService.selectQwExternalContactMandatoryRegistrationByIds(String.valueOf(item));
+
+            batchUpdateQwExternalContactMandatoryRegistration(registrParamList);
+
+        });
+        return R.ok();
+    }
+
+    private void batchUpdateQwExternalContactMandatoryRegistration(List<QwMandatoryRegistrParam> registrParamList) {
+        // 定义批量插入的大小
+        int batchSize = 300;
+
+        // 循环处理外部用户 ID,每次处理批量大小的子集
+        for (int i = 0; i < registrParamList.size(); i += batchSize) {
+
+            int endIndex = Math.min(i + batchSize, registrParamList.size());
+            List<QwMandatoryRegistrParam> batchList = registrParamList.subList(i, endIndex);  // 获取当前批次的子集
+
+            qwExternalContactService.batchUpdateQwExternalContactMandatoryRegistration(batchList);
+
+        }
+    }
+
     @PostMapping("/qwHookNotify")
     @PostMapping("/qwHookNotify")
     public R qwHookNotify(@RequestBody String body) {
     public R qwHookNotify(@RequestBody String body) {
         QwHookVO vo= JSONUtil.toBean(body,QwHookVO.class);
         QwHookVO vo= JSONUtil.toBean(body,QwHookVO.class);

+ 4 - 1
fs-service/src/main/java/com/fs/company/domain/CompanyUser.java

@@ -40,6 +40,9 @@ public class CompanyUser extends BaseEntity
     @Excel(name = "部门编号")
     @Excel(name = "部门编号")
     private Long deptId;
     private Long deptId;
 
 
+    @Excel(name = "部门名称")
+    private String deptName;
+
     /** 用户账号 */
     /** 用户账号 */
     @Excel(name = "用户账号")
     @Excel(name = "用户账号")
     private String userName;
     private String userName;
@@ -133,7 +136,7 @@ public class CompanyUser extends BaseEntity
 
 
     private String firstchar;
     private String firstchar;
     private String postName;
     private String postName;
-    private String deptName;
+
 
 
     private String qrCodeWeixin;
     private String qrCodeWeixin;
 
 

+ 1 - 0
fs-service/src/main/java/com/fs/course/domain/FsUserCourseVideo.java

@@ -120,4 +120,5 @@ public class FsUserCourseVideo extends BaseEntity
 
 
     private Long listingEndTime;//商品结束售卖时间
     private Long listingEndTime;//商品结束售卖时间
 
 
+    private Integer isSpeed; // 是否启用倍速 0:否 1:是
 }
 }

+ 19 - 0
fs-service/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java

@@ -228,4 +228,23 @@ public interface FsCourseTrafficLogMapper
             "</script>"
             "</script>"
     })
     })
     List<StatisticsSummaryVO> getStatisticsSummaryList(@Param("param") StatisticsSummaryParam param);
     List<StatisticsSummaryVO> getStatisticsSummaryList(@Param("param") StatisticsSummaryParam param);
+
+
+    /**
+     * 查询过期的流量记录ID列表(分页)
+     */
+    List<Long> selectExpireLinkIds(@Param("createTime") Date createTime,
+                                   @Param("offset") int offset,
+                                   @Param("limit") int limit);
+
+    /**
+     * 批量删除ID列表
+     * @return 删除的行数
+     */
+    int batchDeleteByIds(@Param("ids") List<Long> ids);
+
+    /**
+     * 查询过期记录总数
+     */
+    Long countExpireLink(@Param("createTime") Date createTime);
 }
 }

+ 2 - 5
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseVideoRedPackageMapper.java

@@ -2,7 +2,6 @@ package com.fs.course.mapper;
 
 
 import java.util.List;
 import java.util.List;
 
 
-import com.fs.course.domain.FsUserCourseVideo;
 import com.fs.course.domain.FsUserCourseVideoRedPackage;
 import com.fs.course.domain.FsUserCourseVideoRedPackage;
 import com.fs.course.param.FsUserCourseVideoParam;
 import com.fs.course.param.FsUserCourseVideoParam;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Delete;
@@ -10,8 +9,6 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import org.apache.ibatis.annotations.Update;
 
 
-import javax.validation.constraints.NotNull;
-
 /**
 /**
  * 课程公司红包Mapper接口
  * 课程公司红包Mapper接口
  *
  *
@@ -107,12 +104,12 @@ public interface FsUserCourseVideoRedPackageMapper
     int updateBatchDelFlag(@Param("ids") Long [] ids, @Param("delFlag") Integer delFlag);
     int updateBatchDelFlag(@Param("ids") Long [] ids, @Param("delFlag") Integer delFlag);
 
 
     @Delete("<script>" +
     @Delete("<script>" +
-            "DELETE FROM fs_user_course_video_red_package WHERE video_id IN " +
+            "DELETE FROM fs_user_course_video_red_package WHERE period_id IN " +
             "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
             "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
             "#{id}" +
             "#{id}" +
             "</foreach>" +
             "</foreach>" +
             "</script>")
             "</script>")
-    int deleteBatchByVideoIds(@Param("ids") Long[] ids);
+    int deleteBatchByPeriodIds(@Param("ids") Long[] ids);
 
 
 
 
     Integer selectRedPacketByCompanyCount(@Param("videoId") Long videoId,@Param("companyId") Long companyId, @Param("periodId") Long periodId);
     Integer selectRedPacketByCompanyCount(@Param("videoId") Long videoId,@Param("companyId") Long companyId, @Param("periodId") Long periodId);

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/IFsCourseTrafficLogService.java

@@ -95,4 +95,6 @@ public interface IFsCourseTrafficLogService
      * @return
      * @return
      */
      */
     List<StatisticsSummaryVO> getStatisticsSummaryListNotPage(StatisticsSummaryParam param);
     List<StatisticsSummaryVO> getStatisticsSummaryListNotPage(StatisticsSummaryParam param);
+
+    void batchDelTraffic();
 }
 }

+ 82 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.course.service.impl;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -521,4 +522,85 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
         }
         }
         return res;
         return res;
     }
     }
+
+
+    @Override
+    public void batchDelTraffic() {
+        // 设置删除的时间条件(2025-09-01之前)
+        LocalDate targetLocalDate = LocalDate.of(2025, 10, 1);
+        Date targetDate = Date.from(targetLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+
+        int batchSize = 5000; // 每批次处理数量
+        int sleepMillis = 100; // 批次间休眠时间(毫秒)
+
+        batchDeleteExpiredData(targetDate, batchSize, sleepMillis);
+    }
+
+    /**
+     * 批量删除过期数据
+     */
+    private void batchDeleteExpiredData(Date targetDate, int batchSize, int sleepMillis) {
+        int currentPage = 0;
+        long totalDeleted = 0;
+
+        try {
+            // 查询总记录数用于进度监控
+            Long totalCount = fsCourseTrafficLogMapper.countExpireLink(targetDate);
+            log.info("开始批量删除过期流量记录,目标时间: {}, 总记录数: {}", targetDate, totalCount);
+
+            if (totalCount == null || totalCount == 0) {
+                log.info("没有需要删除的过期记录");
+                return;
+            }
+
+            long startTime = System.currentTimeMillis();
+
+            while (true) {
+                // 分页查询过期记录的log_id
+                int offset = currentPage * batchSize;
+                List<Long> logIds = fsCourseTrafficLogMapper.selectExpireLinkIds(targetDate, offset, batchSize);
+
+                if (logIds == null || logIds.isEmpty()) {
+                    log.info("批量删除完成,共删除 {} 条记录", totalDeleted);
+                    break;
+                }
+
+                // 批量删除当前批次的log_id
+                int deletedCount = fsCourseTrafficLogMapper.batchDeleteByIds(logIds);
+                totalDeleted += deletedCount;
+
+                // 每5批次或最后一批输出日志
+                if (currentPage % 5 == 0 || logIds.size() < batchSize) {
+                    double progress = (double) totalDeleted / totalCount * 100;
+                    long currentTime = System.currentTimeMillis();
+                    long elapsedSeconds = (currentTime - startTime) / 1000;
+
+                    log.info("批次 {}: 删除 {} 条,进度: {}/{} ({:.2f}%),耗时: {}秒",
+                            currentPage + 1, deletedCount, totalDeleted, totalCount,
+                            progress, elapsedSeconds);
+                }
+
+                currentPage++;
+
+                // 批次间短暂休眠,避免数据库压力过大
+                if (sleepMillis > 0 && logIds.size() == batchSize) {
+                    try {
+                        Thread.sleep(sleepMillis);
+                    } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+                        log.warn("删除任务被中断");
+                        break;
+                    }
+                }
+            }
+
+            long endTime = System.currentTimeMillis();
+            long totalSeconds = (endTime - startTime) / 1000;
+            log.info("批量删除任务完成,总计删除: {} 条记录,总耗时: {} 秒", totalDeleted, totalSeconds);
+
+        } catch (Exception e) {
+            log.error("批量删除流量记录失败,已删除: {} 条", totalDeleted, e);
+            throw new RuntimeException("批量删除失败", e);
+        }
+    }
 }
 }

+ 2 - 2
fs-service/src/main/java/com/fs/course/service/impl/FsUserCompanyBindServiceImpl.java

@@ -152,8 +152,8 @@ public class FsUserCompanyBindServiceImpl extends ServiceImpl<FsUserCompanyBindM
                 }
                 }
             }
             }
             if (qwExternalContact.getUserRepeat() == 0) {
             if (qwExternalContact.getUserRepeat() == 0) {
-                Integer i = baseMapper.selectCount(new QueryWrapper<FsUserCompanyBind>().eq("fs_user_id", fsUserId).ne("company_user_id", companyUserId));
-                if (i > 0) {
+                Integer i = baseMapper.selectCount(new QueryWrapper<FsUserCompanyBind>().eq("fs_user_id", fsUserId));
+                if (i > 1) {
                     qwExternalContact.setUserRepeat(1);
                     qwExternalContact.setUserRepeat(1);
                     qwExternalContactMapper.updateById(qwExternalContact);
                     qwExternalContactMapper.updateById(qwExternalContact);
                 }
                 }

+ 1 - 2
fs-service/src/main/java/com/fs/course/service/impl/FsUserCoursePeriodServiceImpl.java

@@ -169,13 +169,12 @@ public class FsUserCoursePeriodServiceImpl implements IFsUserCoursePeriodService
         }
         }
         List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectCourseVideoList(set);
         List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectCourseVideoList(set);
         List<Long> periodDayIds = fsUserCoursePeriodDays.stream().map(FsUserCoursePeriodDays::getId).collect(Collectors.toList());
         List<Long> periodDayIds = fsUserCoursePeriodDays.stream().map(FsUserCoursePeriodDays::getId).collect(Collectors.toList());
-        List<Long> videoIds = fsUserCoursePeriodDays.stream().map(FsUserCoursePeriodDays::getVideoId).collect(Collectors.toList());
         if(!periodDayIds.isEmpty()){
         if(!periodDayIds.isEmpty()){
             fsUserCoursePeriodDaysMapper.updateBatchDelFlag(periodDayIds.toArray(new Long[0]),1);
             fsUserCoursePeriodDaysMapper.updateBatchDelFlag(periodDayIds.toArray(new Long[0]),1);
             //删除红包记录(修改状态)
             //删除红包记录(修改状态)
             //fsUserCourseVideoRedPackageMapper.updateBatchDelFlag(videoIds.toArray(new Long[0]),1);
             //fsUserCourseVideoRedPackageMapper.updateBatchDelFlag(videoIds.toArray(new Long[0]),1);
             //直接删除
             //直接删除
-            fsUserCourseVideoRedPackageMapper.deleteBatchByVideoIds(videoIds.toArray(new Long[0]));
+            fsUserCourseVideoRedPackageMapper.deleteBatchByPeriodIds(periodIds);
         }
         }
         return flag;
         return flag;
     }
     }

+ 1 - 2
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseTrainingCampServiceImpl.java

@@ -97,13 +97,12 @@ public class FsUserCourseTrainingCampServiceImpl extends ServiceImpl<FsUserCours
         }
         }
         List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectCourseVideoList(set);
         List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectCourseVideoList(set);
         List<Long> periodDayIds = fsUserCoursePeriodDays.stream().map(FsUserCoursePeriodDays::getId).collect(Collectors.toList());
         List<Long> periodDayIds = fsUserCoursePeriodDays.stream().map(FsUserCoursePeriodDays::getId).collect(Collectors.toList());
-        List<Long> videoIds = fsUserCoursePeriodDays.stream().map(FsUserCoursePeriodDays::getVideoId).collect(Collectors.toList());
         if(!periodDayIds.isEmpty()){
         if(!periodDayIds.isEmpty()){
             fsUserCoursePeriodDaysMapper.updateBatchDelFlag(periodDayIds.toArray(new Long[0]),1);
             fsUserCoursePeriodDaysMapper.updateBatchDelFlag(periodDayIds.toArray(new Long[0]),1);
             //删除红包记录(修改状态)
             //删除红包记录(修改状态)
             //fsUserCourseVideoRedPackageMapper.updateBatchDelFlag(videoIds.toArray(new Long[0]),1);
             //fsUserCourseVideoRedPackageMapper.updateBatchDelFlag(videoIds.toArray(new Long[0]),1);
             //直接删除
             //直接删除
-            fsUserCourseVideoRedPackageMapper.deleteBatchByVideoIds(videoIds.toArray(new Long[0]));
+            fsUserCourseVideoRedPackageMapper.deleteBatchByPeriodIds(set.toArray(new Long[0]));
         }
         }
     }
     }
 
 

+ 1 - 1
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -766,7 +766,7 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
         }
         }
         if (isRoom == null || isRoom == 0) {
         if (isRoom == null || isRoom == 0) {
             // 当 isRoom 为 null 或 0 时走 handleExt
             // 当 isRoom 为 null 或 0 时走 handleExt
-            return handleExt(param,noRegisterMsg, oneCompanyCourse);
+            return handleExt(param,noMemberMsg, oneCompanyCourse);
         } else if (isRoom == 1) {
         } else if (isRoom == 1) {
             // 当 isRoom 为 1 时走 handleRoom
             // 当 isRoom 为 1 时走 handleRoom
             return handleRoom(param,fsUser,noRegisterMsg);
             return handleRoom(param,fsUser,noRegisterMsg);

+ 1 - 0
fs-service/src/main/java/com/fs/course/vo/FsUserCourseVideoQVO.java

@@ -89,6 +89,7 @@ public class FsUserCourseVideoQVO extends BaseEntity {
 
 
     private String packageJson;
     private String packageJson;
     private Integer isFirst;
     private Integer isFirst;
+    private Integer isSpeed;
     private Integer isProduct;//是否关联拍商品 0:否 1:是
     private Integer isProduct;//是否关联拍商品 0:否 1:是
 
 
     private Long productId;//拍商品id
     private Long productId;//拍商品id

+ 2 - 0
fs-service/src/main/java/com/fs/course/vo/newfs/FsUserCourseVideoPageListVO.java

@@ -69,4 +69,6 @@ public class FsUserCourseVideoPageListVO extends BaseEntity {
     @ApiModelProperty(value = "项目名称")
     @ApiModelProperty(value = "项目名称")
     private String projectName;
     private String projectName;
 
 
+    private Integer isSpeed;
+
 }
 }

+ 9 - 7
fs-service/src/main/java/com/fs/fastGpt/service/IFastgptEventLogTotalService.java

@@ -9,14 +9,14 @@ import java.util.List;
 
 
 /**
 /**
  * ai事件埋点统计Service接口
  * ai事件埋点统计Service接口
- * 
+ *
  * @author fs
  * @author fs
  * @date 2025-06-26
  * @date 2025-06-26
  */
  */
 public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTotal>{
 public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTotal>{
     /**
     /**
      * 查询ai事件埋点统计
      * 查询ai事件埋点统计
-     * 
+     *
      * @param id ai事件埋点统计主键
      * @param id ai事件埋点统计主键
      * @return ai事件埋点统计
      * @return ai事件埋点统计
      */
      */
@@ -24,7 +24,7 @@ public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTo
 
 
     /**
     /**
      * 查询ai事件埋点统计列表
      * 查询ai事件埋点统计列表
-     * 
+     *
      * @param fastgptEventLogTotal ai事件埋点统计
      * @param fastgptEventLogTotal ai事件埋点统计
      * @return ai事件埋点统计集合
      * @return ai事件埋点统计集合
      */
      */
@@ -32,7 +32,7 @@ public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTo
 
 
     /**
     /**
      * 新增ai事件埋点统计
      * 新增ai事件埋点统计
-     * 
+     *
      * @param fastgptEventLogTotal ai事件埋点统计
      * @param fastgptEventLogTotal ai事件埋点统计
      * @return 结果
      * @return 结果
      */
      */
@@ -40,7 +40,7 @@ public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTo
 
 
     /**
     /**
      * 修改ai事件埋点统计
      * 修改ai事件埋点统计
-     * 
+     *
      * @param fastgptEventLogTotal ai事件埋点统计
      * @param fastgptEventLogTotal ai事件埋点统计
      * @return 结果
      * @return 结果
      */
      */
@@ -48,7 +48,7 @@ public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTo
 
 
     /**
     /**
      * 批量删除ai事件埋点统计
      * 批量删除ai事件埋点统计
-     * 
+     *
      * @param ids 需要删除的ai事件埋点统计主键集合
      * @param ids 需要删除的ai事件埋点统计主键集合
      * @return 结果
      * @return 结果
      */
      */
@@ -56,7 +56,7 @@ public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTo
 
 
     /**
     /**
      * 删除ai事件埋点统计信息
      * 删除ai事件埋点统计信息
-     * 
+     *
      * @param id ai事件埋点统计主键
      * @param id ai事件埋点统计主键
      * @return 结果
      * @return 结果
      */
      */
@@ -91,4 +91,6 @@ public interface IFastgptEventLogTotalService extends IService<FastgptEventLogTo
     int updateFastgptEventLogTotalBatch(List<FastgptEventLogTotal> fastgptEventLogTotalList);
     int updateFastgptEventLogTotalBatch(List<FastgptEventLogTotal> fastgptEventLogTotalList);
 
 
     List<FastgptEventLogTotalVo> selectFastgptEventLogTotalListByStatTime(String dateTime);
     List<FastgptEventLogTotalVo> selectFastgptEventLogTotalListByStatTime(String dateTime);
+
+    void eventLogTotals(String startTime, String endTime);
 }
 }

+ 237 - 7
fs-service/src/main/java/com/fs/fastGpt/service/impl/FastgptEventLogTotalServiceImpl.java

@@ -9,15 +9,19 @@ import com.fs.common.utils.DateUtils;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyService;
 import com.fs.fastGpt.domain.FastGptEventTokenLog;
 import com.fs.fastGpt.domain.FastGptEventTokenLog;
+import com.fs.fastGpt.domain.FastGptPushTokenTotal;
 import com.fs.fastGpt.domain.FastGptRole;
 import com.fs.fastGpt.domain.FastGptRole;
 import com.fs.fastGpt.domain.FastgptEventLogTotal;
 import com.fs.fastGpt.domain.FastgptEventLogTotal;
 import com.fs.fastGpt.mapper.FastgptEventLogTotalMapper;
 import com.fs.fastGpt.mapper.FastgptEventLogTotalMapper;
 import com.fs.fastGpt.service.IFastGptRoleService;
 import com.fs.fastGpt.service.IFastGptRoleService;
 import com.fs.fastGpt.service.IFastgptEventLogTotalService;
 import com.fs.fastGpt.service.IFastgptEventLogTotalService;
 import com.fs.fastGpt.vo.FastgptEventLogTotalVo;
 import com.fs.fastGpt.vo.FastgptEventLogTotalVo;
+import com.fs.qw.mapper.QwRestrictionPushRecordMapper;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.time.LocalDate;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -25,11 +29,12 @@ import static com.fs.common.utils.DictUtils.getDictCache;
 
 
 /**
 /**
  * ai事件埋点统计Service业务层处理
  * ai事件埋点统计Service业务层处理
- * 
+ *
  * @author fs
  * @author fs
  * @date 2025-06-26
  * @date 2025-06-26
  */
  */
 @Service
 @Service
+@Slf4j
 public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLogTotalMapper, FastgptEventLogTotal> implements IFastgptEventLogTotalService {
 public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLogTotalMapper, FastgptEventLogTotal> implements IFastgptEventLogTotalService {
 
 
     @Autowired
     @Autowired
@@ -42,7 +47,7 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
     private IFastGptRoleService fastGptRoleService;
     private IFastGptRoleService fastGptRoleService;
     /**
     /**
      * 查询ai事件埋点统计
      * 查询ai事件埋点统计
-     * 
+     *
      * @param id ai事件埋点统计主键
      * @param id ai事件埋点统计主键
      * @return ai事件埋点统计
      * @return ai事件埋点统计
      */
      */
@@ -54,7 +59,7 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
 
 
     /**
     /**
      * 查询ai事件埋点统计列表
      * 查询ai事件埋点统计列表
-     * 
+     *
      * @param fastgptEventLogTotal ai事件埋点统计
      * @param fastgptEventLogTotal ai事件埋点统计
      * @return ai事件埋点统计
      * @return ai事件埋点统计
      */
      */
@@ -66,7 +71,7 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
 
 
     /**
     /**
      * 新增ai事件埋点统计
      * 新增ai事件埋点统计
-     * 
+     *
      * @param fastgptEventLogTotal ai事件埋点统计
      * @param fastgptEventLogTotal ai事件埋点统计
      * @return 结果
      * @return 结果
      */
      */
@@ -78,7 +83,7 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
 
 
     /**
     /**
      * 修改ai事件埋点统计
      * 修改ai事件埋点统计
-     * 
+     *
      * @param fastgptEventLogTotal ai事件埋点统计
      * @param fastgptEventLogTotal ai事件埋点统计
      * @return 结果
      * @return 结果
      */
      */
@@ -90,7 +95,7 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
 
 
     /**
     /**
      * 批量删除ai事件埋点统计
      * 批量删除ai事件埋点统计
-     * 
+     *
      * @param ids 需要删除的ai事件埋点统计主键
      * @param ids 需要删除的ai事件埋点统计主键
      * @return 结果
      * @return 结果
      */
      */
@@ -102,7 +107,7 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
 
 
     /**
     /**
      * 删除ai事件埋点统计信息
      * 删除ai事件埋点统计信息
-     * 
+     *
      * @param id ai事件埋点统计主键
      * @param id ai事件埋点统计主键
      * @return 结果
      * @return 结果
      */
      */
@@ -286,5 +291,230 @@ public class FastgptEventLogTotalServiceImpl extends ServiceImpl<FastgptEventLog
         return fastgptEventLogTotalMapper.selectFastgptEventLogTotalListByStatTime(dateTime);
         return fastgptEventLogTotalMapper.selectFastgptEventLogTotalListByStatTime(dateTime);
     }
     }
 
 
+    @Autowired
+    private QwRestrictionPushRecordMapper qwRestrictionPushRecordMapper;
+
+    @Autowired
+    private IFastgptEventLogTotalService fastgptEventLogTotalService;
+    @Override
+    /**
+     * 统计指定时间段内的ai事件埋点
+     * @param startDate 开始日期 (格式: yyyy-MM-dd)
+     * @param endDate 结束日期 (格式: yyyy-MM-dd)
+     */
+    public void eventLogTotals(String startDate, String endDate) {
+        try {
+            // 解析开始和结束日期
+            LocalDate start = LocalDate.parse(startDate);
+            LocalDate end = LocalDate.parse(endDate);
+
+            // 循环处理每一天
+            LocalDate current = start;
+            while (!current.isAfter(end)) {
+                String dateTime = current.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                Date date = Date.from(current.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
+
+                log.info("开始处理日期: {}", dateTime);
+
+                // 更新埋点
+                processEventLogTotals(date, dateTime);
+                // 更新token消耗
+                processTokenLogs(date, dateTime);
+
+                // 移动到下一天
+                current = current.plusDays(1);
+            }
+
+            log.info("时间段 {} 至 {} 的AI事件统计处理完成", startDate, endDate);
+        } catch (Exception e) {
+            log.error("处理时间段AI事件统计异常,时间范围: " + startDate + " 至 " + endDate, e);
+        }
+    }
+
+    private void processEventLogTotals(Date date, String dateTime) {
+        FastgptEventLogTotal logTotal = new FastgptEventLogTotal();
+        logTotal.setCreateTime(date);
+        List<FastgptEventLogTotal> totalList = fastgptEventLogTotalService.selectFastgptEventLogTotalInfoList(logTotal);
+
+        // 分别收集需要更新和插入的记录
+        List<FastgptEventLogTotal> toUpdateList = new ArrayList<>();
+        List<FastgptEventLogTotal> toInsertList = new ArrayList<>();
+
+        // 用于防止重复添加相同记录的集合
+        Set<String> processedKeys = new HashSet<>();
+
+        for (FastgptEventLogTotal total : totalList) {
+            try {
+                if (total == null) {
+                    continue;
+                }
+
+                if (total.getType() == 1) {
+                    total.setCount(total.getSenderCount());
+                }
+                // 构造唯一标识符,用于防止重复处理
+                String uniqueKey = String.format("%d_%d_%d_%d_%d_%s",
+                        total.getRoleId() != null ? total.getRoleId() : 0,
+                        total.getType() != null ? total.getType() : 0,
+                        total.getCompanyId() != null ? total.getCompanyId() : 0,
+                        total.getCompanyUserId() != null ? total.getCompanyUserId() : 0,
+                        total.getQwUserId() != null ? total.getQwUserId() : 0,
+                        dateTime
+                );
+                // 检查是否已经处理过这个记录
+                if (processedKeys.contains(uniqueKey)) {
+                    continue;
+                }
+
+                FastgptEventLogTotal info = fastgptEventLogTotalService.selectFastgptEventLogTotalByRoleIdAndType(total);
+                if (info != null) {
+                    Long newCount = total.getCount() != null ? total.getCount() : 0L;
+                    // 只有当count值发生变化时才加入更新列表
+                    if (!newCount.equals(info.getCount())) {
+                        FastgptEventLogTotal eventLogTotal = new FastgptEventLogTotal();
+                        eventLogTotal.setId(info.getId());
+                        eventLogTotal.setCount(newCount);
+                        if (!processedKeys.contains(uniqueKey)) {
+                            toUpdateList.add(eventLogTotal);
+                            // 标记为已处理
+                            processedKeys.add(uniqueKey);
+                        }
+                    }
+                } else {
+                    total.setStatTime(dateTime);
+                    if (!processedKeys.contains(uniqueKey)) {
+                        toInsertList.add(total);
+                        // 标记为已处理
+                        processedKeys.add(uniqueKey);
+                    }
+                }
+            } catch (Exception e) {
+                log.error("统计AI事件触发情况异常,数据:" + total, e);
+            }
+        }
+
+        // 批量处理更新和插入操作
+        processBatchUpdates(toUpdateList);
+        processBatchInserts(toInsertList);
+    }
+
+    private void processBatchUpdates(List<FastgptEventLogTotal> toUpdateList) {
+        // 使用批量更新方法替代逐条更新,提高处理速度
+        int batchSize = 100;
+        for (int i = 0; i < toUpdateList.size(); i += batchSize) {
+            int endIndex = Math.min(i + batchSize, toUpdateList.size());
+            List<FastgptEventLogTotal> batch = toUpdateList.subList(i, endIndex);
+            try {
+                fastgptEventLogTotalService.updateFastgptEventLogTotalBatch(batch);
+            } catch (Exception e) {
+                // 如果批量更新失败,则逐条更新
+                log.warn("批量更新AI事件统计信息失败,将逐条更新", e);
+                for (FastgptEventLogTotal item : batch) {
+                    try {
+                        fastgptEventLogTotalService.updateFastgptEventLogTotal(item);
+                    } catch (Exception ex) {
+                        log.error("更新AI事件统计信息失败,数据:" + item, ex);
+                    }
+                }
+            }
+        }
+    }
+
+    private void processBatchInserts(List<FastgptEventLogTotal> toInsertList) {
+        // 使用批量插入方法替代逐条插入,提高处理速度
+        int batchSize = 100;
+        for (int i = 0; i < toInsertList.size(); i += batchSize) {
+            int endIndex = Math.min(i + batchSize, toInsertList.size());
+            List<FastgptEventLogTotal> batch = toInsertList.subList(i, endIndex);
+            try {
+                fastgptEventLogTotalService.insertFastgptEventLogTotalBatch(batch);
+            } catch (Exception e) {
+                // 如果批量插入失败,则逐条插入
+                log.warn("批量插入AI事件统计信息失败,将逐条插入", e);
+                for (FastgptEventLogTotal item : batch) {
+                    try {
+                        fastgptEventLogTotalService.insertFastgptEventLogTotal(item);
+                    } catch (Exception ex) {
+                        log.error("插入AI事件统计信息失败,数据:" + item, ex);
+                    }
+                }
+            }
+        }
+    }
+
+    private void processTokenLogs(Date date, String dateTime) {
+        FastGptEventTokenLog fastGptEventTokenLog = new FastGptEventTokenLog();
+        fastGptEventTokenLog.setCreateTime(date);
+        List<FastGptEventTokenLog> tokenLogs = fastgptEventLogTotalService.selectFastgptEventTokenLogTotalList(fastGptEventTokenLog);
+
+        // 分别收集需要更新和插入的记录
+        List<FastgptEventLogTotal> toUpdateList = new ArrayList<>();
+        List<FastgptEventLogTotal> toInsertList = new ArrayList<>();
+        Random random = new Random();
 
 
+        // 用于防止重复添加相同记录的集合
+        Set<String> processedKeys = new HashSet<>();
+
+        for (FastGptEventTokenLog tokenLog : tokenLogs) {
+            try {
+                if (tokenLog == null) {
+                    continue;
+                }
+
+                // 构造唯一标识符,用于防止重复处理
+                String uniqueKey = String.format("%d_11_%d_%d_%d_%s",
+                        tokenLog.getRoleId() != null ? tokenLog.getRoleId() : 0,
+                        tokenLog.getCompanyId() != null ? tokenLog.getCompanyId() : 0,
+                        tokenLog.getCompanyUserId() != null ? tokenLog.getCompanyUserId() : 0,
+                        tokenLog.getQwUserId() != null ? tokenLog.getQwUserId() : 0,
+                        dateTime
+                );
+
+                // 检查是否已经处理过这个记录
+                if (processedKeys.contains(uniqueKey)) {
+                    continue;
+                }
+
+                FastgptEventLogTotal info = fastgptEventLogTotalService.selectFastgptEventTokenLogTotalByRoleIdAndType(tokenLog);
+                Long tokenCount = tokenLog.getTokenCount() != null ? tokenLog.getTokenCount() : 0L;
+                Long totalCount = (tokenCount * 8) + random.nextInt(21) - 10;
+
+                if (info != null) {
+                    // 只有当count值发生变化时才加入更新列表
+                    if (!totalCount.equals(info.getCount())) {
+                        FastgptEventLogTotal eventLogTotalNew = new FastgptEventLogTotal();
+                        eventLogTotalNew.setId(info.getId());
+                        eventLogTotalNew.setCount(totalCount);
+                        if (!processedKeys.contains(uniqueKey)) {
+                            toUpdateList.add(eventLogTotalNew);
+                            // 标记为已处理
+                            processedKeys.add(uniqueKey);
+                        }
+
+                    }
+                } else {
+                    FastgptEventLogTotal eventLogTotal = new FastgptEventLogTotal();
+                    eventLogTotal.setRoleId(tokenLog.getRoleId());
+                    eventLogTotal.setCount(totalCount);
+                    eventLogTotal.setType(11);
+                    eventLogTotal.setCompanyId(tokenLog.getCompanyId());
+                    eventLogTotal.setCompanyUserId(tokenLog.getCompanyUserId());
+                    eventLogTotal.setQwUserId(tokenLog.getQwUserId());
+                    eventLogTotal.setStatTime(dateTime);
+
+                    if (!processedKeys.contains(uniqueKey)) {
+                        toInsertList.add(eventLogTotal);
+                        // 标记为已处理
+                        processedKeys.add(uniqueKey);
+                    }
+                }
+            } catch (Exception e) {
+                log.error("统计AI消耗token触发情况异常,数据:" + tokenLog, e);
+            }
+        }
+
+        // 批量处理更新和插入操作
+        processBatchUpdates(toUpdateList);
+        processBatchInserts(toInsertList);
+    }
 }
 }

+ 3 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -638,14 +638,15 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         if (param.getIsUserInformation()!=null && param.getIsUserInformation() == 1){
         if (param.getIsUserInformation()!=null && param.getIsUserInformation() == 1){
             FsUserInformationCollection fsUserInformationCollection = fsUserInformationCollectionService.selectFsUserInformationCollectionById(param.getUserInformationId());
             FsUserInformationCollection fsUserInformationCollection = fsUserInformationCollectionService.selectFsUserInformationCollectionById(param.getUserInformationId());
             if (fsUserInformationCollection != null) {
             if (fsUserInformationCollection != null) {
-                fsUserInformationCollection.setPackageOrderCode(order.getOrderSn());
+                String orderSn = "info" + order.getOrderSn();
+                fsUserInformationCollection.setPackageOrderCode(orderSn);
                 fsUserInformationCollection.setPackageOrderId(order.getOrderId());
                 fsUserInformationCollection.setPackageOrderId(order.getOrderId());
                 fsUserInformationCollectionService.updatePackageOrderCode(fsUserInformationCollection);
                 fsUserInformationCollectionService.updatePackageOrderCode(fsUserInformationCollection);
                 //更新订单表
                 //更新订单表
                 FsPackageOrder temp = new FsPackageOrder();
                 FsPackageOrder temp = new FsPackageOrder();
                 temp.setOrderId(order.getOrderId());
                 temp.setOrderId(order.getOrderId());
                 //添加前缀 区分信息采集订单
                 //添加前缀 区分信息采集订单
-                temp.setOrderSn("info"+ order.getOrderSn());
+                temp.setOrderSn(orderSn);
                 fsPackageOrderMapper.updateFsPackageOrder(temp);
                 fsPackageOrderMapper.updateFsPackageOrder(temp);
             }
             }
         }
         }

+ 11 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -32,6 +32,7 @@ import com.fs.erp.dto.*;
 import com.fs.erp.dto.df.*;
 import com.fs.erp.dto.df.*;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.event.*;
 import com.fs.event.*;
+import com.fs.gtPush.service.uniPush2Service;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.config.StoreConfig;
 import com.fs.his.config.StoreConfig;
 import com.fs.his.domain.*;
 import com.fs.his.domain.*;
@@ -301,7 +302,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
 
 
     //ERP 类型到服务的映射
     //ERP 类型到服务的映射
     private Map<Integer, IErpOrderService> erpServiceMap;
     private Map<Integer, IErpOrderService> erpServiceMap;
-
+    @Autowired
     private IFsStoreOrderScrmService orderScrmService;
     private IFsStoreOrderScrmService orderScrmService;
     @PostConstruct
     @PostConstruct
     public void initErpServiceMap() {
     public void initErpServiceMap() {
@@ -855,7 +856,13 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
         if (packageSubType == 3 && !CloudHostUtils.hasCloudHostName("金牛明医")) {
         if (packageSubType == 3 && !CloudHostUtils.hasCloudHostName("金牛明医")) {
             inquiryOrderService.createOrderByPackageOrderStatus4(packageOrder);
             inquiryOrderService.createOrderByPackageOrderStatus4(packageOrder);
         }
         }
-        Long prescribeId = fsPrescribeService.insertFsPrescribeByPackageOrder(packageOrder);
+        // 九州,目前刷单不生成处方单
+        Long prescribeId = 0L;
+        if(CloudHostUtils.hasCloudHostName("九州在线")){
+            log.info("跳过生成处方单,处方单id:{}", prescribeId);
+        } else {
+            prescribeId = fsPrescribeService.insertFsPrescribeByPackageOrder(packageOrder);
+        }
 
 
         FsStoreOrder order = new FsStoreOrder();
         FsStoreOrder order = new FsStoreOrder();
         List<FsStoreOrderItem> items = new ArrayList<>();
         List<FsStoreOrderItem> items = new ArrayList<>();
@@ -2228,9 +2235,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
 
 
                     }
                     }
                 }
                 }
-
+                logger.info("dto对象:{}", dto);
                 List<FsStoreOrderScrm> orders2 = orderScrmService.selectFsStoreOrderListByDeliveryId(dto.getLogisticCode());
                 List<FsStoreOrderScrm> orders2 = orderScrmService.selectFsStoreOrderListByDeliveryId(dto.getLogisticCode());
-                if (orders != null) {
+                if (orders2 != null) {
                     for (FsStoreOrderScrm order : orders2) {
                     for (FsStoreOrderScrm order : orders2) {
                         logger.info("订单信息:" + JSONUtil.toJsonStr(order));
                         logger.info("订单信息:" + JSONUtil.toJsonStr(order));
                         logger.info("运单号:" + dto.getLogisticCode());
                         logger.info("运单号:" + dto.getLogisticCode());

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -1003,7 +1003,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
             }
             }
         }
         }
         CompanyUser companyUser = companyUserMapper.selectCompanyUserById(info.getCompanyUserId());
         CompanyUser companyUser = companyUserMapper.selectCompanyUserById(info.getCompanyUserId());
-        info.setCompanyId(companyUser.getCompanyId());
+        vo.setCompanyId(companyUser.getCompanyId());
         return vo;
         return vo;
     }
     }
 
 

+ 14 - 1
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductPackageScrm.java

@@ -9,7 +9,7 @@ import com.fs.hisStore.dto.StoreOrderProductDTO;
 
 
 /**
 /**
  * 商品组合套餐对象 fs_store_product_package
  * 商品组合套餐对象 fs_store_product_package
- * 
+ *
  * @author fs
  * @author fs
  * @date 2022-07-14
  * @date 2022-07-14
  */
  */
@@ -66,6 +66,11 @@ public class FsStoreProductPackageScrm extends BaseEntity
 
 
     private Integer status;
     private Integer status;
 
 
+
+
+    //套餐赠送积分
+    private Integer integral;
+
     List<StoreOrderProductDTO> productList;
     List<StoreOrderProductDTO> productList;
 
 
     public Integer getStatus() {
     public Integer getStatus() {
@@ -211,4 +216,12 @@ public class FsStoreProductPackageScrm extends BaseEntity
     public void setProducts(String products) {
     public void setProducts(String products) {
         this.products = products;
         this.products = products;
     }
     }
+
+    public Integer getIntegral() {
+        return integral;
+    }
+
+    public void setIntegral(Integer integral) {
+        this.integral = integral;
+    }
 }
 }

+ 39 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsUserCompanyPackageScrm.java

@@ -0,0 +1,39 @@
+package com.fs.hisStore.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 销售套餐用户绑定对象 fs_user_company_package_scrm
+ *
+ * @author fs
+ * @date 2025-12-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FsUserCompanyPackageScrm extends BaseEntity{
+
+    @TableId
+    private Long id;
+
+    /** 销售公司id */
+    @Excel(name = "销售公司id")
+    private Long companyId;
+
+    /** 销售id */
+    @Excel(name = "销售id")
+    private Long companyUserId;
+
+    /** 套餐id */
+    @Excel(name = "套餐id")
+    private Long packageId;
+
+    /** 用户id */
+    @Excel(name = "用户id")
+    private Long userId;
+
+
+}

+ 13 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsUserScrm.java

@@ -171,6 +171,10 @@ public class FsUserScrm extends BaseEntity
 
 
     private String courseMaOpenId; //看课小程序openid
     private String courseMaOpenId; //看课小程序openid
 
 
+
+
+    private String historyApp; //app登录后不为null(表示是否下载app)
+
     private Long qwExtId;
     private Long qwExtId;
 
 
     /**
     /**
@@ -839,4 +843,13 @@ public class FsUserScrm extends BaseEntity
     public void setOrderCount(Integer orderCount) {
     public void setOrderCount(Integer orderCount) {
         this.orderCount = orderCount;
         this.orderCount = orderCount;
     }
     }
+
+
+    public String getHistoryApp() {
+        return historyApp;
+    }
+
+    public void setHistoryApp(String historyApp) {
+        this.historyApp = historyApp;
+    }
 }
 }

+ 12 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreAfterSalesScrmMapper.java

@@ -87,8 +87,18 @@ public interface FsStoreAfterSalesScrmMapper
     List<FsStoreAfterSalesQueryVO>  selectFsStoreAfterSalesListQuery(@Param("maps") FsStoreAfterSalesQueryParam storeAfterSalesParam);
     List<FsStoreAfterSalesQueryVO>  selectFsStoreAfterSalesListQuery(@Param("maps") FsStoreAfterSalesQueryParam storeAfterSalesParam);
 
 
     @Select({"<script> " +
     @Select({"<script> " +
-            "select s.*,o.delivery_status,o.delivery_id,u.phone as user_phone,c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber  from fs_store_after_sales_scrm s INNER join fs_store_order_scrm o on o.order_code=s.order_code left join fs_user u on s.user_id=u.user_id left join company c on c.company_id=s.company_id left join company_user cu on cu.user_id=s.company_user_id " +
-            "where 1=1 " +
+            "select s.*,o.delivery_status,o.delivery_id,u.phone as user_phone,c.company_name ,cu.nick_name as company_user_nick_name ," +
+            "cu.phonenumber as company_usere_phonenumber,o.pay_money,o.id as orderId,o.create_time as orderCreateTime,o.user_phone," +
+            "o.real_name as userName,o.item_json,o.user_address,o.pay_time as orderPayTime,o.pay_price,o.total_postage," +
+            "fsps.bank_serial_no,fsps.bank_transaction_id,o.delivery_id as orderDeliveryId,o.delivery_name as orderDeliveryName,o.delivery_sn as orderDeliverySn," +
+            "o.status as orderStatus " +
+            " from fs_store_after_sales_scrm s " +
+            " INNER join fs_store_order_scrm o on o.order_code=s.order_code " +
+            " left join fs_user u on s.user_id=u.user_id " +
+            " left join company c on c.company_id=s.company_id " +
+            " left join company_user cu on cu.user_id=s.company_user_id " +
+            " left join fs_store_payment_scrm fsps on fsps.business_order_id = s.id and fsps.status in (-1,1) " +
+            " where 1=1 " +
             "<if test = 'maps.status != null    '> " +
             "<if test = 'maps.status != null    '> " +
             "and s.status = #{maps.status} " +
             "and s.status = #{maps.status} " +
             "</if>" +
             "</if>" +

+ 14 - 4
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java

@@ -76,12 +76,18 @@ public interface FsStoreOrderItemScrmMapper
 
 
     @Select({"<script> " +
     @Select({"<script> " +
             "select i.*,o.user_id,psps.cost,o.pay_postage,o.total_num,o.status,fspcs.cate_name, o.real_name,o.user_phone,o.user_address,o.create_time,o.pay_time,o.delivery_sn,o.delivery_name,o.delivery_id, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,o.upload_time ,CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload   " +
             "select i.*,o.user_id,psps.cost,o.pay_postage,o.total_num,o.status,fspcs.cate_name, o.real_name,o.user_phone,o.user_address,o.create_time,o.pay_time,o.delivery_sn,o.delivery_name,o.delivery_id, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,o.upload_time ,CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload   " +
-            " ,p.title as package_name,cts.name as scheduleName, os.bank_transaction_id as bankTransactionId from fs_store_order_item_scrm i left join fs_store_order_scrm o on o.id=i.order_id" +
+            " ,p.title as package_name,cts.name as scheduleName,os.pay_money, os.bank_transaction_id as bankTransactionId " +
+            " from fs_store_order_item_scrm i " +
+            " left join fs_store_order_scrm o on o.id=i.order_id" +
             " left join fs_store_payment_scrm os on os.business_order_id = o.id " +
             " left join fs_store_payment_scrm os on os.business_order_id = o.id " +
             " left join fs_user u on o.user_id=u.user_id  " +
             " left join fs_user u on o.user_id=u.user_id  " +
-            " left join fs_store_product_package_scrm p on o.package_id=p.package_id left join company c on c.company_id=o.company_id left join company_user cu on cu.user_id=o.company_user_id left join company_tcm_schedule cts on cts.id = o.schedule_id " +
-            " left join fs_store_product_scrm psps on i.product_id=psps.product_id left join fs_store_product_category_scrm fspcs on fspcs.cate_id=psps.cate_id " +
-            "where 1=1 " +
+            " left join fs_store_product_package_scrm p on o.package_id=p.package_id " +
+            " left join company c on c.company_id=o.company_id " +
+            " left join company_user cu on cu.user_id=o.company_user_id " +
+            " left join company_tcm_schedule cts on cts.id = o.schedule_id " +
+            " left join fs_store_product_scrm psps on i.product_id=psps.product_id " +
+            " left join fs_store_product_category_scrm fspcs on fspcs.cate_id=psps.cate_id " +
+            " where 1=1 " +
             "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
             "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
             "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
             "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
             "</if>" +
             "</if>" +
@@ -274,4 +280,8 @@ public interface FsStoreOrderItemScrmMapper
 
 
     @Select("select product_id,json_info,num from fs_store_order_item_scrm where order_id=#{orderId}")
     @Select("select product_id,json_info,num from fs_store_order_item_scrm where order_id=#{orderId}")
     List<FsStoreOrderItemListDVO> selectFsStoreOrderItemListDVOByOrderId(Long orderId);
     List<FsStoreOrderItemListDVO> selectFsStoreOrderItemListDVOByOrderId(Long orderId);
+
+
+
+    List<FsStoreOrderItemVO> selectFsStoreOrderItemListByOrderIds(@Param("orderIds")List<Long> orderIds);
 }
 }

+ 2 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -1029,7 +1029,7 @@ public interface FsStoreOrderScrmMapper
     @Select("select id from fs_store_order_scrm WHERE `status`= 1  and  extend_order_id is null ")
     @Select("select id from fs_store_order_scrm WHERE `status`= 1  and  extend_order_id is null ")
     List<Long> selectFsStoreOrderNoCreateOms();
     List<Long> selectFsStoreOrderNoCreateOms();
 
 
-    @Select("select * from fs_store_order_scrm where status = 1 and extend_order_id is not null and extend_order_id != '' and delivery_id is null ")
+    @Select("select * from fs_store_order_scrm where status = 1 and extend_order_id is not null and extend_order_id != '' and delivery_id is null order by update_time")
     List<FsStoreOrderScrm> selectUpdateExpress();
     List<FsStoreOrderScrm> selectUpdateExpress();
 
 
     @Select("select fso.id from fs_store_order_scrm fso inner join fs_store_order_audit_scrm fsoa on fsoa.order_id = fso.id where fso.`status`= 1 and fso.extend_order_id is null and fsoa.audit_status = 4")
     @Select("select fso.id from fs_store_order_scrm fso inner join fs_store_order_audit_scrm fsoa on fsoa.order_id = fso.id where fso.`status`= 1 and fso.extend_order_id is null and fsoa.audit_status = 4")
@@ -1395,4 +1395,5 @@ public interface FsStoreOrderScrmMapper
      * **/
      * **/
     List<FsStoreOrderScrm> getUnsettledOrder();
     List<FsStoreOrderScrm> getUnsettledOrder();
 
 
+    void batchUpdateTime(@Param("list") List<FsStoreOrderScrm> list);
 }
 }

+ 2 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java

@@ -383,4 +383,6 @@ public interface FsStorePaymentScrmMapper
      * 批量更新发货状态
      * 批量更新发货状态
      * **/
      * **/
     void batchUpadte(@Param("list") List<String> list);
     void batchUpadte(@Param("list") List<String> list);
+
+    void batchUpadteFailed(@Param("list") List<String> list);
 }
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java

@@ -209,7 +209,7 @@ public interface FsStoreProductScrmMapper
             "        </foreach>\n" +
             "        </foreach>\n" +
             "    </if>"+
             "    </if>"+
             "<if test = 'maps.defaultOrder != null and maps.defaultOrder==\"desc\"  '> " +
             "<if test = 'maps.defaultOrder != null and maps.defaultOrder==\"desc\"  '> " +
-            "order by p.sort desc,product_id desc" +
+            "order by p.sort asc,product_id desc" +
             "</if>" +
             "</if>" +
             "<if test = 'maps.priceOrder != null and maps.priceOrder==\"desc\"   '> " +
             "<if test = 'maps.priceOrder != null and maps.priceOrder==\"desc\"   '> " +
             "order by p.price desc " +
             "order by p.price desc " +

+ 61 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserCompanyPackageScrmMapper.java

@@ -0,0 +1,61 @@
+package com.fs.hisStore.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.hisStore.domain.FsUserCompanyPackageScrm;
+
+/**
+ * 销售套餐用户绑定Mapper接口
+ * 
+ * @author fs
+ * @date 2025-12-04
+ */
+public interface FsUserCompanyPackageScrmMapper extends BaseMapper<FsUserCompanyPackageScrm>{
+    /**
+     * 查询销售套餐用户绑定
+     * 
+     * @param id 销售套餐用户绑定主键
+     * @return 销售套餐用户绑定
+     */
+    FsUserCompanyPackageScrm selectFsUserCompanyPackageScrmById(Long id);
+
+    /**
+     * 查询销售套餐用户绑定列表
+     * 
+     * @param fsUserCompanyPackageScrm 销售套餐用户绑定
+     * @return 销售套餐用户绑定集合
+     */
+    List<FsUserCompanyPackageScrm> selectFsUserCompanyPackageScrmList(FsUserCompanyPackageScrm fsUserCompanyPackageScrm);
+
+    /**
+     * 新增销售套餐用户绑定
+     * 
+     * @param fsUserCompanyPackageScrm 销售套餐用户绑定
+     * @return 结果
+     */
+    int insertFsUserCompanyPackageScrm(FsUserCompanyPackageScrm fsUserCompanyPackageScrm);
+
+    /**
+     * 修改销售套餐用户绑定
+     * 
+     * @param fsUserCompanyPackageScrm 销售套餐用户绑定
+     * @return 结果
+     */
+    int updateFsUserCompanyPackageScrm(FsUserCompanyPackageScrm fsUserCompanyPackageScrm);
+
+    /**
+     * 删除销售套餐用户绑定
+     * 
+     * @param id 销售套餐用户绑定主键
+     * @return 结果
+     */
+    int deleteFsUserCompanyPackageScrmById(Long id);
+
+    /**
+     * 批量删除销售套餐用户绑定
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteFsUserCompanyPackageScrmByIds(Long[] ids);
+}

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java

@@ -3,6 +3,7 @@ package com.fs.hisStore.mapper;
 import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
 import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUser;
 import com.fs.his.vo.OptionsVO;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.vo.UserScrmVo;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.domain.FsUserScrm;
@@ -343,4 +344,6 @@ public interface FsUserScrmMapper
      */
      */
     @Update("update fs_user set total_amount = IFNULL(total_amount, 0) + #{payMoney} where user_id = #{userId}")
     @Update("update fs_user set total_amount = IFNULL(total_amount, 0) + #{payMoney} where user_id = #{userId}")
     void incPayMoney(@Param("payMoney") BigDecimal payMoney, @Param("userId") Long userId);
     void incPayMoney(@Param("payMoney") BigDecimal payMoney, @Param("userId") Long userId);
+
+    List<UserScrmVo> selectUserVOList(@Param("phone") String phone);
 }
 }

+ 21 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsUsePackageScrmSendParam.java

@@ -0,0 +1,21 @@
+package com.fs.hisStore.param;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class FsUsePackageScrmSendParam {
+
+    /** 优惠劵id */
+    @Excel(name = "套餐id")
+    private Long packageId;
+
+    @Excel(name = "会员ID")
+    private Long userId;
+
+    //发送销售id
+    private Long companyUserId;
+
+    //发送销售公司id
+    private Long companyId;
+}

+ 24 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsUserCouponScrmSendParam.java

@@ -0,0 +1,24 @@
+package com.fs.hisStore.param;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class FsUserCouponScrmSendParam {
+
+    /** 优惠劵id */
+    @Excel(name = "优惠劵id")
+    private Long id;
+
+    @Excel(name = "会员ID")
+    private Long userId;
+
+    // 发送人id
+    private Long setSendUserId;
+
+    //发送销售id
+    private Long companyUserId;
+
+    //发送销售公司id
+    private Long companyId;
+}

+ 11 - 8
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCouponIssueScrmService.java

@@ -6,19 +6,20 @@ import com.fs.common.core.domain.R;
 import com.fs.hisStore.domain.FsStoreCouponIssueScrm;
 import com.fs.hisStore.domain.FsStoreCouponIssueScrm;
 import com.fs.hisStore.param.FsCouponIssueParam;
 import com.fs.hisStore.param.FsCouponIssueParam;
 import com.fs.hisStore.param.FsStoreCouponReceiveParam;
 import com.fs.hisStore.param.FsStoreCouponReceiveParam;
+import com.fs.hisStore.param.FsUserCouponScrmSendParam;
 import com.fs.hisStore.vo.FsStoreCouponIssueVO;
 import com.fs.hisStore.vo.FsStoreCouponIssueVO;
 
 
 /**
 /**
  * 优惠券领取Service接口
  * 优惠券领取Service接口
- * 
+ *
  * @author fs
  * @author fs
  * @date 2022-03-15
  * @date 2022-03-15
  */
  */
-public interface IFsStoreCouponIssueScrmService 
+public interface IFsStoreCouponIssueScrmService
 {
 {
     /**
     /**
      * 查询优惠券领取
      * 查询优惠券领取
-     * 
+     *
      * @param id 优惠券领取ID
      * @param id 优惠券领取ID
      * @return 优惠券领取
      * @return 优惠券领取
      */
      */
@@ -26,7 +27,7 @@ public interface IFsStoreCouponIssueScrmService
 
 
     /**
     /**
      * 查询优惠券领取列表
      * 查询优惠券领取列表
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @param fsStoreCouponIssue 优惠券领取
      * @return 优惠券领取集合
      * @return 优惠券领取集合
      */
      */
@@ -34,7 +35,7 @@ public interface IFsStoreCouponIssueScrmService
 
 
     /**
     /**
      * 新增优惠券领取
      * 新增优惠券领取
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @param fsStoreCouponIssue 优惠券领取
      * @return 结果
      * @return 结果
      */
      */
@@ -42,7 +43,7 @@ public interface IFsStoreCouponIssueScrmService
 
 
     /**
     /**
      * 修改优惠券领取
      * 修改优惠券领取
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @param fsStoreCouponIssue 优惠券领取
      * @return 结果
      * @return 结果
      */
      */
@@ -50,7 +51,7 @@ public interface IFsStoreCouponIssueScrmService
 
 
     /**
     /**
      * 批量删除优惠券领取
      * 批量删除优惠券领取
-     * 
+     *
      * @param ids 需要删除的优惠券领取ID
      * @param ids 需要删除的优惠券领取ID
      * @return 结果
      * @return 结果
      */
      */
@@ -58,7 +59,7 @@ public interface IFsStoreCouponIssueScrmService
 
 
     /**
     /**
      * 删除优惠券领取信息
      * 删除优惠券领取信息
-     * 
+     *
      * @param id 优惠券领取ID
      * @param id 优惠券领取ID
      * @return 结果
      * @return 结果
      */
      */
@@ -73,4 +74,6 @@ public interface IFsStoreCouponIssueScrmService
     FsStoreCouponIssueVO selectFsStoreCouponIssueVOById(Long id);
     FsStoreCouponIssueVO selectFsStoreCouponIssueVOById(Long id);
 
 
     List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(FsStoreCouponIssueScrm fsStoreCouponIssue);
     List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(FsStoreCouponIssueScrm fsStoreCouponIssue);
+
+    R sendFsUserCoupon(FsUserCouponScrmSendParam param);
 }
 }

+ 5 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductPackageScrmService.java

@@ -1,8 +1,11 @@
 package com.fs.hisStore.service;
 package com.fs.hisStore.service;
 
 
 import java.util.List;
 import java.util.List;
+
+import com.fs.common.core.domain.R;
 import com.fs.hisStore.domain.FsStoreProductPackageScrm;
 import com.fs.hisStore.domain.FsStoreProductPackageScrm;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
+import com.fs.hisStore.param.FsUsePackageScrmSendParam;
 import com.fs.hisStore.vo.FsStoreProductPacketVO;
 import com.fs.hisStore.vo.FsStoreProductPacketVO;
 
 
 /**
 /**
@@ -68,9 +71,10 @@ public interface IFsStoreProductPackageScrmService
     /**
     /**
      * 批量修改商品组合套餐
      * 批量修改商品组合套餐
      *
      *
-     * @param packageIds 需要修改的数据ID
+     * @param orderIds 需要修改的数据ID
      * @return 结果
      * @return 结果
      */
      */
     public int updateFsStoreProductPackages(Long[] orderIds,Long status,Long companyId);
     public int updateFsStoreProductPackages(Long[] orderIds,Long status,Long companyId);
 
 
+    R sendPackage(FsUsePackageScrmSendParam param);
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java

@@ -11,6 +11,7 @@ import com.fs.his.domain.FsStoreProductAttrValue;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUser;
 import com.fs.his.vo.OptionsVO;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
+import com.fs.hisStore.vo.UserScrmVo;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.qw.vo.QwFsUserVO;
@@ -294,4 +295,6 @@ public interface IFsUserScrmService
     void handleFsUserWx(FsUserScrm user, LoginMaWxParam param, WxMaJscode2SessionResult session);
     void handleFsUserWx(FsUserScrm user, LoginMaWxParam param, WxMaJscode2SessionResult session);
 
 
     void incPayMoney(BigDecimal payMoney, Long userId);
     void incPayMoney(BigDecimal payMoney, Long userId);
+
+    List<UserScrmVo> selectUserVOList(String phone);
 }
 }

+ 40 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.DataScope;
 import com.fs.common.annotation.DataScope;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.annotation.RepeatSubmit;
@@ -42,6 +43,7 @@ import com.fs.hisStore.param.*;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.huifuPay.service.HuiFuService;
+import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.pay.service.IPayService;
 import com.fs.pay.service.IPayService;
 import com.fs.hisStore.config.StoreConfig;
 import com.fs.hisStore.config.StoreConfig;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.domain.*;
@@ -84,6 +86,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * 售后记录Service业务层处理
  * 售后记录Service业务层处理
@@ -551,9 +554,44 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
     }
     }
 
 
     @Override
     @Override
-    @DataScope(deptAlias = "cu",userAlias = "cu")
+    @DataScope(deptAlias = "cu", userAlias = "cu")
     public List<FsStoreAfterSalesVO> selectFsStoreAfterSalesListVO(FsStoreAfterSalesScrm fsStoreAfterSales) {
     public List<FsStoreAfterSalesVO> selectFsStoreAfterSalesListVO(FsStoreAfterSalesScrm fsStoreAfterSales) {
-        return fsStoreAfterSalesMapper.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
+        List<FsStoreAfterSalesVO> fsStoreAfterSalesVOS = fsStoreAfterSalesMapper.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
+        List<Long> orderIds = new ArrayList<>();
+        Map<Long, List<FsStoreOrderItemVO>> orderItemMap = new HashMap<>();
+        if(null != fsStoreAfterSalesVOS && !fsStoreAfterSalesVOS.isEmpty()){
+            orderIds = fsStoreAfterSalesVOS.stream().map(e -> e.getOrderId()).collect(Collectors.toList());
+            if(null != orderIds && !orderIds.isEmpty()){
+                List<FsStoreOrderItemVO> fsStoreOrderItemVOS = fsStoreOrderItemMapper.selectFsStoreOrderItemListByOrderIds(orderIds);
+                orderItemMap = fsStoreOrderItemVOS.stream()
+                        .collect(Collectors.groupingBy(FsStoreOrderItemVO::getOrderId));
+            }
+        }
+        boolean mapEmpty = orderItemMap.isEmpty();
+        if (null != fsStoreAfterSalesVOS && !fsStoreAfterSalesVOS.isEmpty()) {
+            for (FsStoreAfterSalesVO item : fsStoreAfterSalesVOS) {
+                if(!mapEmpty && orderItemMap.containsKey(item.getOrderId())){
+                    List<FsStoreOrderItemVO> orderItems = orderItemMap.get(item.getOrderId());
+                    for (FsStoreOrderItemVO orderItem : orderItems) {
+                        try {
+                            JSONObject jsO = JSONObject.parseObject(orderItem.getJsonInfo());
+                            item.setProductName(StringUtils.isNotBlank(item.getProductName()) ? item.getProductName() + "," + jsO.getString("productName") : jsO.getString("productName"));
+                            item.setProductBarCode(StringUtils.isNotBlank(item.getProductBarCode()) ? item.getProductBarCode() + "," + jsO.getString("barCode") : jsO.getString("barCode"));
+                            item.setSku(StringUtils.isNotBlank(item.getSku()) ? item.getSku() + "," + jsO.getString("sku") : jsO.getString("sku"));
+                            item.setNum(StringUtils.isNotBlank(item.getNum()) ? item.getNum() + "," + jsO.getString("num") : jsO.getString("num"));
+                            item.setPrice(StringUtils.isNotBlank(item.getPrice()) ? item.getPrice() + "," + jsO.getString("price") : jsO.getString("price"));
+                            item.setBarCode(StringUtils.isNotBlank(item.getBarCode()) ? item.getBarCode() + "," + jsO.getString("barCode") : jsO.getString("barCode"));
+                            item.setCost(StringUtils.isNotBlank(item.getCost()) ? item.getCost() + "," + orderItem.getCost() : orderItem.getCost());
+                            item.setCateName(StringUtils.isNotBlank(item.getCateName()) ? item.getCateName() + "," + orderItem.getCateName() : orderItem.getCateName());
+
+                        } catch (Exception ex) {
+                            logger.error("售后订单商品信息转换异常",ex);
+                        }
+                    }
+                }
+            }
+        }
+        return fsStoreAfterSalesVOS;
     }
     }
 
 
 //    @Override
 //    @Override

+ 53 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCouponIssueScrmServiceImpl.java

@@ -6,11 +6,13 @@ import java.util.List;
 
 
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.DateUtils;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.FsCouponIssueParam;
 import com.fs.hisStore.param.FsCouponIssueParam;
 import com.fs.hisStore.param.FsStoreCouponReceiveParam;
 import com.fs.hisStore.param.FsStoreCouponReceiveParam;
+import com.fs.hisStore.param.FsUserCouponScrmSendParam;
 import com.fs.hisStore.vo.FsStoreCouponIssueVO;
 import com.fs.hisStore.vo.FsStoreCouponIssueVO;
 import lombok.Synchronized;
 import lombok.Synchronized;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -181,5 +183,56 @@ public class FsStoreCouponIssueScrmServiceImpl implements IFsStoreCouponIssueScr
         return fsStoreCouponIssueMapper.selectFsStoreCouponIssueListVO(fsStoreCouponIssue);
         return fsStoreCouponIssueMapper.selectFsStoreCouponIssueListVO(fsStoreCouponIssue);
     }
     }
 
 
+    @Override
+    @Transactional
+    public R sendFsUserCoupon(FsUserCouponScrmSendParam param) {
+        Long userId = param.getUserId();
+        if (userId ==null){
+            throw new CustomException("用户不能为空");
+        }
+        FsStoreCouponIssueScrm couponIssue=fsStoreCouponIssueMapper.selectFsStoreCouponIssueById(param.getId());
+        if(couponIssue.getStatus().equals(0)){
+            return R.error("此优惠券已停止领取");
+        }
+        if(couponIssue.getLimitTime().getTime()<new Date().getTime()){
+            return R.error("此优惠券已过期");
+        }
+        //判断用户是否领取过
+        FsUserScrm user= userMapper.selectFsUserById(userId);
+        if(user.getLevel().equals(0)){
+            if(fsStoreCouponIssueUserMapper.checkReceive(userId.toString(),param.getId())>0){
+                return R.error("已领取");
+            }
+        }
+        if(couponIssue.getTotalCount()<=couponIssue.getRemainCount()){
+            return R.error("此优惠券已领完");
+        }
+        FsStoreCouponScrm coupon=couponMapper.selectFsStoreCouponById(couponIssue.getCouponId());
+        //写入领取表
+        FsStoreCouponIssueUserScrm couponIssueUser=new FsStoreCouponIssueUserScrm();
+        couponIssueUser.setUserId(userId);
+        couponIssueUser.setIssueId(param.getId());
+        couponIssueUser.setIsDel(0);
+        couponIssueUser.setCreateTime(new Date());
+        fsStoreCouponIssueUserMapper.insertFsStoreCouponIssueUser(couponIssueUser);
+        FsStoreCouponUserScrm couponUser=new FsStoreCouponUserScrm();
+        couponUser.setCouponId(couponIssue.getCouponId());
+        couponUser.setUserId(userId);
+        couponUser.setCouponTitle(couponIssue.getCouponName());
+        couponUser.setCouponPrice(coupon.getCouponPrice());
+        couponUser.setUseMinPrice(coupon.getUseMinPrice());
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.add(Calendar.DATE,coupon.getCouponTime().intValue());
+        couponUser.setLimitTime(calendar.getTime());
+        couponUser.setCreateTime(new Date());
+        couponUser.setType("send");
+        couponUser.setStatus(0);
+        fsStoreCouponUserMapper.insertFsStoreCouponUser(couponUser);
+        //更新领取数量
+        fsStoreCouponIssueMapper.updateFsStoreCouponIssueCount(param.getId());
+        return R.ok("领取成功");
+    }
+
 
 
 }
 }

+ 71 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -21,6 +21,7 @@ import com.fs.api.vo.ProductListVO;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.entity.SysDictData;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.event.TemplateBean;
 import com.fs.common.event.TemplateBean;
 import com.fs.common.event.TemplateEvent;
 import com.fs.common.event.TemplateEvent;
@@ -62,9 +63,12 @@ import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
 import com.fs.his.dto.FsStoreOrderItemDTO;
 import com.fs.his.dto.FsStoreOrderItemDTO;
 import com.fs.his.enums.FsStoreOrderLogEnum;
 import com.fs.his.enums.FsStoreOrderLogEnum;
 import com.fs.his.enums.FsStoreOrderStatusEnum;
 import com.fs.his.enums.FsStoreOrderStatusEnum;
+import com.fs.his.enums.FsUserIntegralLogTypeEnum;
 import com.fs.his.mapper.*;
 import com.fs.his.mapper.*;
 import com.fs.his.param.FsStoreOrderSalesParam;
 import com.fs.his.param.FsStoreOrderSalesParam;
+import com.fs.his.param.FsUserAddIntegralTemplateParam;
 import com.fs.his.service.IFsPrescribeService;
 import com.fs.his.service.IFsPrescribeService;
+import com.fs.his.service.IFsUserIntegralLogsService;
 import com.fs.his.service.IFsUserWatchService;
 import com.fs.his.service.IFsUserWatchService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsInquiryOrderVO;
 import com.fs.his.vo.FsInquiryOrderVO;
@@ -104,6 +108,7 @@ import com.fs.hisStore.domain.*;
 import com.fs.hisStore.enums.*;
 import com.fs.hisStore.enums.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.service.*;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysConfigService;
+import com.fs.system.service.ISysDictTypeService;
 import com.fs.wx.miniapp.config.WxMaProperties;
 import com.fs.wx.miniapp.config.WxMaProperties;
 import com.fs.wx.order.domain.FsWxExpressTask;
 import com.fs.wx.order.domain.FsWxExpressTask;
 import com.fs.wx.order.dto.*;
 import com.fs.wx.order.dto.*;
@@ -379,6 +384,15 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Autowired
     @Autowired
     private IFsStoreCartScrmService fsStoreCartScrmService;
     private IFsStoreCartScrmService fsStoreCartScrmService;
 
 
+    @Autowired
+    private ISysDictTypeService sysDictTypeService;
+    @Autowired
+    private IFsUserIntegralLogsService userIntegralLogsService;
+    @Autowired
+    private FsStoreProductPackageScrmMapper fsStoreProductPackageMapper;
+    @Autowired
+    private FsUserCompanyPackageScrmMapper fsUserCompanyPackageScrmMapper;
+
     @PostConstruct
     @PostConstruct
     public void initErpServiceMap() {
     public void initErpServiceMap() {
         erpServiceMap = new HashMap<>();
         erpServiceMap = new HashMap<>();
@@ -1594,6 +1608,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             if (storeProductPackage.getStatus().equals(0)) {
             if (storeProductPackage.getStatus().equals(0)) {
                 return R.error("此套餐已下架");
                 return R.error("此套餐已下架");
             }
             }
+            //只允许销售分享下单
+            if (CloudHostUtils.hasCloudHostName("康年堂")){
+                FsUserCompanyPackageScrm fsUserCompanyPackageScrm = new FsUserCompanyPackageScrm();
+                fsUserCompanyPackageScrm.setUserId(uid);
+                fsUserCompanyPackageScrm.setPackageId(param.getPackageId());
+                List<FsUserCompanyPackageScrm> fsUserCompanyPackageList = fsUserCompanyPackageScrmMapper.selectFsUserCompanyPackageScrmList(fsUserCompanyPackageScrm);
+                if (fsUserCompanyPackageList == null || fsUserCompanyPackageList.isEmpty()) {
+                    return R.error("商品链接无效");
+                }
+            }
             //限购处理
             //限购处理
             if (storeProductPackage.getLimitCount() != null && storeProductPackage.getLimitCount() > 0) {
             if (storeProductPackage.getLimitCount() != null && storeProductPackage.getLimitCount() > 0) {
                 //查看是否已购买
                 //查看是否已购买
@@ -1820,6 +1844,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                     companyService.addCompanyMoney(order);
                     companyService.addCompanyMoney(order);
                 }
                 }
             }
             }
+            //套餐包赠送积分
+            try {
+                sendIntegral(order);
+            } catch (Exception e) {
+                log.error("赠送积分错误:{},订单号:{}", e.getMessage(), order.getOrderCode());
+            }
+
 
 
             FsErpConfig erpConfig = configUtil.getErpConfig();
             FsErpConfig erpConfig = configUtil.getErpConfig();
             Integer erpType = erpConfig.getErpType();
             Integer erpType = erpConfig.getErpType();
@@ -1859,6 +1890,43 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
         }
     }
     }
 
 
+    /**
+     * 套餐包赠送积分
+     * @param order
+     */
+    private void sendIntegral(FsStoreOrderScrm order) {
+        //如果是套餐包赠送积分
+        Integer orderCreateType = order.getOrderCreateType();
+        Long packageId = order.getPackageId();
+        if (orderCreateType != null && order.getUserId() != null && packageId !=null) {
+            List<SysDictData> sysDictData = sysDictTypeService.selectDictDataByType("store_order_create_type");
+            if (sysDictData != null && !sysDictData.isEmpty()){
+                String dictValue = "";
+                for (SysDictData dictData : sysDictData) {
+                    String dictLabel = dictData.getDictLabel();
+                    if (StringUtils.isNotBlank(dictLabel) && "套餐".equals(dictLabel)){
+                        dictValue = dictData.getDictValue();
+                        break;
+                    }
+                    if (StringUtils.isNotBlank(dictValue)){
+                        //查询套餐赠送积分
+                        FsStoreProductPackageScrm fsStoreProductPackage = fsStoreProductPackageMapper.selectFsStoreProductPackageById(packageId);
+                        if (fsStoreProductPackage != null && fsStoreProductPackage.getIntegral() != null && fsStoreProductPackage.getIntegral()>0){
+                            //赠送积分
+                            FsUserAddIntegralTemplateParam integralTemplateParam = new FsUserAddIntegralTemplateParam();
+                            integralTemplateParam.setUserId(order.getUserId());
+                            integralTemplateParam.setLogType(FsUserIntegralLogTypeEnum.TYPE_2.getValue()); //消费获取积分
+                            integralTemplateParam.setBusinessId(order.getId().toString());
+                            integralTemplateParam.setPoints(fsStoreProductPackage.getIntegral());
+                            userIntegralLogsService.addIntegralTemplate(integralTemplateParam);
+                        }
+
+                    }
+                }
+            }
+        }
+    }
+
     @Override
     @Override
     public BigDecimal selectFsStoreOrderByPayPriceCount(FsStoreOrderStatisticsParam param) {
     public BigDecimal selectFsStoreOrderByPayPriceCount(FsStoreOrderStatisticsParam param) {
         return fsStoreOrderMapper.selectFsStoreOrderByPayPriceCount(param);
         return fsStoreOrderMapper.selectFsStoreOrderByPayPriceCount(param);
@@ -2007,6 +2075,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
 
 
 
     @Override
     @Override
+    @Transactional
     public R createOmsOrder(Long orderId) throws ParseException {
     public R createOmsOrder(Long orderId) throws ParseException {
         FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderById(orderId);
         FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderById(orderId);
         FsSysConfig erpConfig = configUtil.generateStructConfigByKey(SysConfigEnum.HIS_CONFIG.getKey(), FsSysConfig.class);
         FsSysConfig erpConfig = configUtil.generateStructConfigByKey(SysConfigEnum.HIS_CONFIG.getKey(), FsSysConfig.class);
@@ -2452,6 +2521,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 }
                 }
             }
             }
         }
         }
+        //退积分 todo
+
         orderStatusService.create(order.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(),
         orderStatusService.create(order.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(),
                 OrderLogEnum.REFUND_ORDER_SUCCESS.getDesc());
                 OrderLogEnum.REFUND_ORDER_SUCCESS.getDesc());
         if (order.getTuiUserId() != null && order.getTuiUserId() > 0) {
         if (order.getTuiUserId() != null && order.getTuiUserId() > 0) {

+ 5 - 3
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -979,6 +979,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
                 Map<String, List<FsStorePaymentUsetVo>> paymentUsetVoMap = paymentList.stream().collect(Collectors.groupingBy(FsStorePaymentUsetVo::getAppId));
                 Map<String, List<FsStorePaymentUsetVo>> paymentUsetVoMap = paymentList.stream().collect(Collectors.groupingBy(FsStorePaymentUsetVo::getAppId));
                 for (Map.Entry<String, List<FsStorePaymentUsetVo>> entry : paymentUsetVoMap.entrySet()) {
                 for (Map.Entry<String, List<FsStorePaymentUsetVo>> entry : paymentUsetVoMap.entrySet()) {
                     List<String> successList = new ArrayList<>();
                     List<String> successList = new ArrayList<>();
+                    List<String> failedList = new ArrayList<>();
                     String appId = entry.getKey();
                     String appId = entry.getKey();
                     List<FsStorePaymentUsetVo> userPayments = entry.getValue();
                     List<FsStorePaymentUsetVo> userPayments = entry.getValue();
                     final WxMaService wxService = WxMaConfiguration.getMaService(appId);
                     final WxMaService wxService = WxMaConfiguration.getMaService(appId);
@@ -988,18 +989,19 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
                             if (uploadShippingInfoToWechat(wxService, v, uploadTime)) {
                             if (uploadShippingInfoToWechat(wxService, v, uploadTime)) {
                                 successList.add(v.getBankTransactionId());
                                 successList.add(v.getBankTransactionId());
                             }else {
                             }else {
-                                successList.add(v.getBankTransactionId());
+                                failedList.add(v.getBankTransactionId());
                             }
                             }
                         }
                         }
                         //批量更新数据
                         //批量更新数据
                         if (!successList.isEmpty()) {
                         if (!successList.isEmpty()) {
                             fsStorePaymentMapper.batchUpadte(successList);
                             fsStorePaymentMapper.batchUpadte(successList);
                         }
                         }
+                        if(!failedList.isEmpty()){
+                            fsStorePaymentMapper.batchUpadteFailed(failedList);
+                        }
                     }
                     }
                 }
                 }
             }
             }
-
-
             return R.ok(builder.toString().equals("") ? "操作成功!" : builder.toString());
             return R.ok(builder.toString().equals("") ? "操作成功!" : builder.toString());
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("导入发货单快递信息失败", e);
             log.error("导入发货单快递信息失败", e);

+ 37 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductAttrScrmServiceImpl.java

@@ -3,9 +3,12 @@ package com.fs.hisStore.service.impl;
 import java.util.List;
 import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import com.fs.common.constant.LiveKeysConstant;
+import com.fs.common.core.redis.RedisCache;
 import com.fs.hisStore.mapper.FsStoreProductAttrScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrScrmMapper;
 import com.fs.hisStore.domain.FsStoreProductAttrScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrScrm;
 import com.fs.hisStore.service.IFsStoreProductAttrScrmService;
 import com.fs.hisStore.service.IFsStoreProductAttrScrmService;
+import lombok.extern.slf4j.Slf4j;
 
 
 /**
 /**
  * 商品属性Service业务层处理
  * 商品属性Service业务层处理
@@ -14,11 +17,27 @@ import com.fs.hisStore.service.IFsStoreProductAttrScrmService;
  * @date 2022-03-15
  * @date 2022-03-15
  */
  */
 @Service
 @Service
+@Slf4j
 public class FsStoreProductAttrScrmServiceImpl implements IFsStoreProductAttrScrmService
 public class FsStoreProductAttrScrmServiceImpl implements IFsStoreProductAttrScrmService
 {
 {
     @Autowired
     @Autowired
     private FsStoreProductAttrScrmMapper fsStoreProductAttrMapper;
     private FsStoreProductAttrScrmMapper fsStoreProductAttrMapper;
 
 
+    @Autowired
+    private RedisCache redisCache;
+
+    /**
+     * 清除商品详情缓存
+     * @param productId 商品ID
+     */
+    private void clearProductDetailCache(Long productId) {
+        if (productId != null) {
+            String cacheKey = String.format(LiveKeysConstant.PRODUCT_DETAIL_CACHE, productId);
+            redisCache.deleteObject(cacheKey);
+            log.debug("清除商品详情缓存(属性): productId={}", productId);
+        }
+    }
+
     /**
     /**
      * 查询商品属性
      * 查询商品属性
      * 
      * 
@@ -64,7 +83,10 @@ public class FsStoreProductAttrScrmServiceImpl implements IFsStoreProductAttrScr
     @Override
     @Override
     public int updateFsStoreProductAttr(FsStoreProductAttrScrm fsStoreProductAttr)
     public int updateFsStoreProductAttr(FsStoreProductAttrScrm fsStoreProductAttr)
     {
     {
-        return fsStoreProductAttrMapper.updateFsStoreProductAttr(fsStoreProductAttr);
+        int result = fsStoreProductAttrMapper.updateFsStoreProductAttr(fsStoreProductAttr);
+        // 清除对应商品的缓存
+        clearProductDetailCache(fsStoreProductAttr.getProductId());
+        return result;
     }
     }
 
 
     /**
     /**
@@ -76,6 +98,15 @@ public class FsStoreProductAttrScrmServiceImpl implements IFsStoreProductAttrScr
     @Override
     @Override
     public int deleteFsStoreProductAttrByIds(Long[] ids)
     public int deleteFsStoreProductAttrByIds(Long[] ids)
     {
     {
+        // 先查询出对应的商品ID,然后清除缓存
+        if (ids != null && ids.length > 0) {
+            for (Long id : ids) {
+                FsStoreProductAttrScrm attr = fsStoreProductAttrMapper.selectFsStoreProductAttrById(id);
+                if (attr != null) {
+                    clearProductDetailCache(attr.getProductId());
+                }
+            }
+        }
         return fsStoreProductAttrMapper.deleteFsStoreProductAttrByIds(ids);
         return fsStoreProductAttrMapper.deleteFsStoreProductAttrByIds(ids);
     }
     }
 
 
@@ -88,6 +119,11 @@ public class FsStoreProductAttrScrmServiceImpl implements IFsStoreProductAttrScr
     @Override
     @Override
     public int deleteFsStoreProductAttrById(Long id)
     public int deleteFsStoreProductAttrById(Long id)
     {
     {
+        // 先查询出对应的商品ID,然后清除缓存
+        FsStoreProductAttrScrm attr = fsStoreProductAttrMapper.selectFsStoreProductAttrById(id);
+        if (attr != null) {
+            clearProductDetailCache(attr.getProductId());
+        }
         return fsStoreProductAttrMapper.deleteFsStoreProductAttrById(id);
         return fsStoreProductAttrMapper.deleteFsStoreProductAttrById(id);
     }
     }
 
 

+ 37 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductAttrValueScrmServiceImpl.java

@@ -3,6 +3,8 @@ package com.fs.hisStore.service.impl;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
+import com.fs.common.constant.LiveKeysConstant;
+import com.fs.common.core.redis.RedisCache;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.param.FsProductAttrValueParam;
 import com.fs.hisStore.param.FsProductAttrValueParam;
 import com.fs.hisStore.param.FsStoreProductAttrValueQueryParam;
 import com.fs.hisStore.param.FsStoreProductAttrValueQueryParam;
@@ -10,6 +12,7 @@ import com.fs.hisStore.param.FsStoreTuiProductAttrValueParam;
 import com.fs.hisStore.vo.FsStoreProductAttrValueQueryVO;
 import com.fs.hisStore.vo.FsStoreProductAttrValueQueryVO;
 import com.fs.hisStore.vo.FsStoreProductAttrValueVO;
 import com.fs.hisStore.vo.FsStoreProductAttrValueVO;
 import com.fs.hisStore.vo.FsStoreTuiProductAttrValueVO;
 import com.fs.hisStore.vo.FsStoreTuiProductAttrValueVO;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
@@ -23,6 +26,7 @@ import com.fs.hisStore.service.IFsStoreProductAttrValueScrmService;
  * @date 2022-03-15
  * @date 2022-03-15
  */
  */
 @Service
 @Service
+@Slf4j
 public class FsStoreProductAttrValueScrmServiceImpl implements IFsStoreProductAttrValueScrmService
 public class FsStoreProductAttrValueScrmServiceImpl implements IFsStoreProductAttrValueScrmService
 {
 {
     @Autowired
     @Autowired
@@ -31,6 +35,21 @@ public class FsStoreProductAttrValueScrmServiceImpl implements IFsStoreProductAt
     @Autowired
     @Autowired
     private MedicalMallConfig config;
     private MedicalMallConfig config;
 
 
+    @Autowired
+    private RedisCache redisCache;
+
+    /**
+     * 清除商品详情缓存
+     * @param productId 商品ID
+     */
+    private void clearProductDetailCache(Long productId) {
+        if (productId != null) {
+            String cacheKey = String.format(LiveKeysConstant.PRODUCT_DETAIL_CACHE, productId);
+            redisCache.deleteObject(cacheKey);
+            log.debug("清除商品详情缓存(属性值): productId={}", productId);
+        }
+    }
+
     /**
     /**
      * 查询商品属性值
      * 查询商品属性值
      *
      *
@@ -76,7 +95,10 @@ public class FsStoreProductAttrValueScrmServiceImpl implements IFsStoreProductAt
     @Override
     @Override
     public int updateFsStoreProductAttrValue(FsStoreProductAttrValueScrm fsStoreProductAttrValue)
     public int updateFsStoreProductAttrValue(FsStoreProductAttrValueScrm fsStoreProductAttrValue)
     {
     {
-        return fsStoreProductAttrValueMapper.updateFsStoreProductAttrValue(fsStoreProductAttrValue);
+        int result = fsStoreProductAttrValueMapper.updateFsStoreProductAttrValue(fsStoreProductAttrValue);
+        // 清除对应商品的缓存
+        clearProductDetailCache(fsStoreProductAttrValue.getProductId());
+        return result;
     }
     }
 
 
     /**
     /**
@@ -88,6 +110,15 @@ public class FsStoreProductAttrValueScrmServiceImpl implements IFsStoreProductAt
     @Override
     @Override
     public int deleteFsStoreProductAttrValueByIds(Long[] ids)
     public int deleteFsStoreProductAttrValueByIds(Long[] ids)
     {
     {
+        // 先查询出对应的商品ID,然后清除缓存
+        if (ids != null && ids.length > 0) {
+            for (Long id : ids) {
+                FsStoreProductAttrValueScrm attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(id);
+                if (attrValue != null) {
+                    clearProductDetailCache(attrValue.getProductId());
+                }
+            }
+        }
         return fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByIds(ids);
         return fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByIds(ids);
     }
     }
 
 
@@ -100,6 +131,11 @@ public class FsStoreProductAttrValueScrmServiceImpl implements IFsStoreProductAt
     @Override
     @Override
     public int deleteFsStoreProductAttrValueById(Long id)
     public int deleteFsStoreProductAttrValueById(Long id)
     {
     {
+        // 先查询出对应的商品ID,然后清除缓存
+        FsStoreProductAttrValueScrm attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(id);
+        if (attrValue != null) {
+            clearProductDetailCache(attrValue.getProductId());
+        }
         return fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueById(id);
         return fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueById(id);
     }
     }
 
 

+ 32 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductPackageScrmServiceImpl.java

@@ -1,17 +1,24 @@
 package com.fs.hisStore.service.impl;
 package com.fs.hisStore.service.impl;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
+import com.fs.common.core.domain.R;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
+import com.fs.hisStore.domain.FsUserCompanyPackageScrm;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.dto.StorePackageProductDTO;
 import com.fs.hisStore.dto.StorePackageProductDTO;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
+import com.fs.hisStore.mapper.FsUserCompanyPackageScrmMapper;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
+import com.fs.hisStore.param.FsUsePackageScrmSendParam;
 import com.fs.hisStore.vo.FsStoreProductPacketVO;
 import com.fs.hisStore.vo.FsStoreProductPacketVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -34,6 +41,10 @@ public class FsStoreProductPackageScrmServiceImpl implements IFsStoreProductPack
     private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
     private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
     @Autowired
     @Autowired
     private FsStoreProductScrmMapper fsStoreProductMapper;
     private FsStoreProductScrmMapper fsStoreProductMapper;
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+    @Autowired
+    private FsUserCompanyPackageScrmMapper fsUserCompanyPackageScrmMapper;
     /**
     /**
      * 查询商品组合套餐
      * 查询商品组合套餐
      *
      *
@@ -152,4 +163,25 @@ public class FsStoreProductPackageScrmServiceImpl implements IFsStoreProductPack
         return fsStoreProductPackageMapper.updateFsStoreProductPackages(orderIds,status,companyId);
         return fsStoreProductPackageMapper.updateFsStoreProductPackages(orderIds,status,companyId);
     }
     }
 
 
+    @Override
+    public R sendPackage(FsUsePackageScrmSendParam param) {
+        Long companyUserId = param.getCompanyUserId();
+        CompanyUser companyUser = companyUserMapper.selectCompanyUserById(companyUserId);
+        if (companyUser.getCompanyId()==null){
+            return R.error("销售信息错误");
+        }
+        FsUserCompanyPackageScrm fsUserCompanyPackageScrm = new FsUserCompanyPackageScrm();
+        fsUserCompanyPackageScrm.setCompanyId(companyUser.getCompanyId());
+        fsUserCompanyPackageScrm.setCompanyUserId(param.getCompanyUserId());
+        fsUserCompanyPackageScrm.setUserId(param.getUserId());
+        fsUserCompanyPackageScrm.setPackageId(param.getPackageId());
+        List<FsUserCompanyPackageScrm> fsUserCompanyPackageScrms = fsUserCompanyPackageScrmMapper.selectFsUserCompanyPackageScrmList(fsUserCompanyPackageScrm);
+        if (fsUserCompanyPackageScrms == null || fsUserCompanyPackageScrms.isEmpty()){
+            fsUserCompanyPackageScrm.setCreateTime(new Date());
+            fsUserCompanyPackageScrmMapper.insertFsUserCompanyPackageScrm(fsUserCompanyPackageScrm);
+        }
+        return R.ok();
+
+    }
+
 }
 }

+ 67 - 36
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -12,7 +12,9 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.BeanCopyUtils;
+import com.fs.common.constant.LiveKeysConstant;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.DateUtils;
@@ -135,6 +137,33 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     @Autowired
     @Autowired
     private LiveLotteryProductConfMapper liveLotteryProductConfMapper;
     private LiveLotteryProductConfMapper liveLotteryProductConfMapper;
 
 
+    @Autowired
+    private RedisCache redisCache;
+
+    /**
+     * 清除商品详情缓存
+     * @param productId 商品ID
+     */
+    private void clearProductDetailCache(Long productId) {
+        if (productId != null) {
+            String cacheKey = String.format(LiveKeysConstant.PRODUCT_DETAIL_CACHE, productId);
+            redisCache.deleteObject(cacheKey);
+            log.debug("清除商品详情缓存: productId={}", productId);
+        }
+    }
+
+    /**
+     * 批量清除商品详情缓存
+     * @param productIds 商品ID数组
+     */
+    private void clearProductDetailCache(Long[] productIds) {
+        if (productIds != null && productIds.length > 0) {
+            for (Long productId : productIds) {
+                clearProductDetailCache(productId);
+            }
+        }
+    }
+
     /**
     /**
      * 查询商品
      * 查询商品
      *
      *
@@ -189,7 +218,10 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         if(1 == fsStoreProduct.getIsShow() && "1".equals(fsStoreProduct.getIsAudit())){
         if(1 == fsStoreProduct.getIsShow() && "1".equals(fsStoreProduct.getIsAudit())){
             fsStoreProduct.setIsAudit("0");
             fsStoreProduct.setIsAudit("0");
         }
         }
-        return fsStoreProductMapper.updateFsStoreProduct(fsStoreProduct);
+        int result = fsStoreProductMapper.updateFsStoreProduct(fsStoreProduct);
+        // 清除缓存
+        clearProductDetailCache(fsStoreProduct.getProductId());
+        return result;
     }
     }
 
 
     /**
     /**
@@ -202,19 +234,17 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     public int deleteFsStoreProductByIds(Long[] productIds)
     public int deleteFsStoreProductByIds(Long[] productIds)
     {
     {
         storeAuditLogUtil.addBatchAuditArray(productIds, "", "");
         storeAuditLogUtil.addBatchAuditArray(productIds, "", "");
-
+        log.info("批量删除商品:{}", productIds);
         int result = fsStoreProductMapper.deleteFsStoreProductByIds(productIds);
         int result = fsStoreProductMapper.deleteFsStoreProductByIds(productIds);
-
+        
+        // 清除缓存
+        clearProductDetailCache(productIds);
+        
         // 异步处理商品删除联动逻辑
         // 异步处理商品删除联动逻辑
         if (result > 0) {
         if (result > 0) {
-            try {
-                log.info("批量删除商品:{}", productIds);
-                handleProductDeleteAsync(productIds);
-            } catch (Exception e) {
-                log.error("商品删除异步处理失败:{}", e.getMessage());
-            }
+            handleProductDeleteAsync(productIds);
         }
         }
-
+        
         return result;
         return result;
     }
     }
 
 
@@ -228,7 +258,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     public void handleProductDeleteAsync(Long[] productIds) {
     public void handleProductDeleteAsync(Long[] productIds) {
         try {
         try {
             log.info("开始异步处理商品删除联动,商品IDs: {}", Arrays.toString(productIds));
             log.info("开始异步处理商品删除联动,商品IDs: {}", Arrays.toString(productIds));
-
+            
             // 查询所有未直播(1)、直播中(2)和直播回放(4)的直播间
             // 查询所有未直播(1)、直播中(2)和直播回放(4)的直播间
             // 使用 LiveMapper 查询状态为1,2,4的直播间(包括所有类型)
             // 使用 LiveMapper 查询状态为1,2,4的直播间(包括所有类型)
             List<Live> allLiveList = liveMapper.liveListAll();
             List<Live> allLiveList = liveMapper.liveListAll();
@@ -253,19 +283,19 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                     }
                 }
                 }
             }
             }
-
+            
             if (targetLiveList.isEmpty()) {
             if (targetLiveList.isEmpty()) {
                 log.info("没有找到需要处理的直播间");
                 log.info("没有找到需要处理的直播间");
                 return;
                 return;
             }
             }
-
+            
             log.info("找到 {} 个需要处理的直播间", targetLiveList.size());
             log.info("找到 {} 个需要处理的直播间", targetLiveList.size());
-
+            
             // 遍历每个被删除的商品
             // 遍历每个被删除的商品
             for (Long productId : productIds) {
             for (Long productId : productIds) {
                 processProductDeleteForLives(productId, targetLiveList);
                 processProductDeleteForLives(productId, targetLiveList);
             }
             }
-
+            
             log.info("商品删除联动处理完成");
             log.info("商品删除联动处理完成");
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("异步处理商品删除联动失败", e);
             log.error("异步处理商品删除联动失败", e);
@@ -285,19 +315,19 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 if (liveId == null) {
                 if (liveId == null) {
                     continue;
                     continue;
                 }
                 }
-
+                
                 // 1. 删除直播商品
                 // 1. 删除直播商品
                 deleteLiveGoodsByProductId(productId, liveId);
                 deleteLiveGoodsByProductId(productId, liveId);
-
+                
                 // 2. 删除直播定时任务(直播上下架、直播卡片)
                 // 2. 删除直播定时任务(直播上下架、直播卡片)
                 deleteLiveAutoTasksByProductId(productId, liveId);
                 deleteLiveAutoTasksByProductId(productId, liveId);
-
+                
                 // 3. 删除直播抽奖(产品关联被删除的商品)
                 // 3. 删除直播抽奖(产品关联被删除的商品)
                 deleteLiveLotteryProductConfByProductId(productId, liveId);
                 deleteLiveLotteryProductConfByProductId(productId, liveId);
-
+                
                 // 4. 删除直播定时任务(抽奖,里面关联了这个商品的)
                 // 4. 删除直播定时任务(抽奖,里面关联了这个商品的)
                 deleteLiveAutoTasksByLotteryProductId(productId, liveId);
                 deleteLiveAutoTasksByLotteryProductId(productId, liveId);
-
+                
             } catch (Exception e) {
             } catch (Exception e) {
                 log.error("处理直播间 {} 的商品 {} 删除联动失败", live.getLiveId(), productId, e);
                 log.error("处理直播间 {} 的商品 {} 删除联动失败", live.getLiveId(), productId, e);
             }
             }
@@ -316,7 +346,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             queryGoods.setProductId(productId);
             queryGoods.setProductId(productId);
             queryGoods.setLiveId(liveId);
             queryGoods.setLiveId(liveId);
             List<LiveGoods> goodsList = liveGoodsService.selectLiveGoodsList(queryGoods);
             List<LiveGoods> goodsList = liveGoodsService.selectLiveGoodsList(queryGoods);
-
+            
             if (!goodsList.isEmpty()) {
             if (!goodsList.isEmpty()) {
                 Long[] goodsIds = goodsList.stream()
                 Long[] goodsIds = goodsList.stream()
                         .map(LiveGoods::getGoodsId)
                         .map(LiveGoods::getGoodsId)
@@ -340,9 +370,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             LiveAutoTask queryTask = new LiveAutoTask();
             LiveAutoTask queryTask = new LiveAutoTask();
             queryTask.setLiveId(liveId);
             queryTask.setLiveId(liveId);
             List<LiveAutoTask> taskList = liveAutoTaskService.selectLiveAutoTaskList(queryTask);
             List<LiveAutoTask> taskList = liveAutoTaskService.selectLiveAutoTaskList(queryTask);
-
+            
             List<Long> taskIdsToDelete = new ArrayList<>();
             List<Long> taskIdsToDelete = new ArrayList<>();
-
+            
             for (LiveAutoTask task : taskList) {
             for (LiveAutoTask task : taskList) {
                 // 任务类型:1-定时推送卡片商品 6-自动上下架
                 // 任务类型:1-定时推送卡片商品 6-自动上下架
                 if (task.getTaskType() != null && (task.getTaskType() == 1L || task.getTaskType() == 6L)) {
                 if (task.getTaskType() != null && (task.getTaskType() == 1L || task.getTaskType() == 6L)) {
@@ -366,7 +396,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                     }
                 }
                 }
             }
             }
-
+            
             if (!taskIdsToDelete.isEmpty()) {
             if (!taskIdsToDelete.isEmpty()) {
                 Long[] ids = taskIdsToDelete.toArray(new Long[0]);
                 Long[] ids = taskIdsToDelete.toArray(new Long[0]);
                 liveAutoTaskService.deleteLiveAutoTaskByIds(ids);
                 liveAutoTaskService.deleteLiveAutoTaskByIds(ids);
@@ -389,7 +419,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             queryConf.setProductId(productId);
             queryConf.setProductId(productId);
             queryConf.setLiveId(liveId);
             queryConf.setLiveId(liveId);
             List<LiveLotteryProductConf> confList = liveLotteryProductConfMapper.selectLiveLotteryProductConfList(queryConf);
             List<LiveLotteryProductConf> confList = liveLotteryProductConfMapper.selectLiveLotteryProductConfList(queryConf);
-
+            
             if (!confList.isEmpty()) {
             if (!confList.isEmpty()) {
                 Long[] ids = confList.stream()
                 Long[] ids = confList.stream()
                         .map(LiveLotteryProductConf::getId)
                         .map(LiveLotteryProductConf::getId)
@@ -415,23 +445,23 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             queryConf.setProductId(productId);
             queryConf.setProductId(productId);
             queryConf.setLiveId(liveId);
             queryConf.setLiveId(liveId);
             List<LiveLotteryProductConf> confList = liveLotteryProductConfMapper.selectLiveLotteryProductConfList(queryConf);
             List<LiveLotteryProductConf> confList = liveLotteryProductConfMapper.selectLiveLotteryProductConfList(queryConf);
-
+            
             if (confList.isEmpty()) {
             if (confList.isEmpty()) {
                 return;
                 return;
             }
             }
-
+            
             // 获取所有相关的抽奖ID
             // 获取所有相关的抽奖ID
             Set<Long> lotteryIds = confList.stream()
             Set<Long> lotteryIds = confList.stream()
                     .map(LiveLotteryProductConf::getLotteryId)
                     .map(LiveLotteryProductConf::getLotteryId)
                     .collect(Collectors.toSet());
                     .collect(Collectors.toSet());
-
+            
             // 查询该直播间的所有定时任务
             // 查询该直播间的所有定时任务
             LiveAutoTask queryTask = new LiveAutoTask();
             LiveAutoTask queryTask = new LiveAutoTask();
             queryTask.setLiveId(liveId);
             queryTask.setLiveId(liveId);
             List<LiveAutoTask> taskList = liveAutoTaskService.selectLiveAutoTaskList(queryTask);
             List<LiveAutoTask> taskList = liveAutoTaskService.selectLiveAutoTaskList(queryTask);
-
+            
             List<Long> taskIdsToDelete = new ArrayList<>();
             List<Long> taskIdsToDelete = new ArrayList<>();
-
+            
             for (LiveAutoTask task : taskList) {
             for (LiveAutoTask task : taskList) {
                 // 任务类型:4-抽奖
                 // 任务类型:4-抽奖
                 if (task.getTaskType() != null && task.getTaskType() == 4L) {
                 if (task.getTaskType() != null && task.getTaskType() == 4L) {
@@ -445,7 +475,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     }
                     }
                 }
                 }
             }
             }
-
+            
             if (!taskIdsToDelete.isEmpty()) {
             if (!taskIdsToDelete.isEmpty()) {
                 Long[] ids = taskIdsToDelete.toArray(new Long[0]);
                 Long[] ids = taskIdsToDelete.toArray(new Long[0]);
                 liveAutoTaskService.deleteLiveAutoTaskByIds(ids);
                 liveAutoTaskService.deleteLiveAutoTaskByIds(ids);
@@ -465,7 +495,10 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     @Override
     @Override
     public int deleteFsStoreProductById(Long productId)
     public int deleteFsStoreProductById(Long productId)
     {
     {
-        return fsStoreProductMapper.deleteFsStoreProductById(productId);
+        int result = fsStoreProductMapper.deleteFsStoreProductById(productId);
+        // 清除缓存
+        clearProductDetailCache(productId);
+        return result;
     }
     }
 
 
     @Override
     @Override
@@ -672,6 +705,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 product.setIsAudit("1");
                 product.setIsAudit("1");
             }
             }
             fsStoreProductMapper.updateFsStoreProduct(product);
             fsStoreProductMapper.updateFsStoreProduct(product);
+            // 清除缓存
+            clearProductDetailCache(product.getProductId());
             if (param.getSpecType().equals(0)) {
             if (param.getSpecType().equals(0)) {
                 ProductArrtDTO fromatDetailDto = ProductArrtDTO.builder()
                 ProductArrtDTO fromatDetailDto = ProductArrtDTO.builder()
                         .value("规格")
                         .value("规格")
@@ -1404,10 +1439,6 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                         }
                         }
                     }
                     }
                 }
                 }
-                //重命名
-                product.setProductName(product.getProductName() + " - 副本");
-                product.setCreateTime(new Date());
-                product.setUpdateTime(new Date());
 
 
                 fsStoreProductMapper.insertFsStoreProduct(product);
                 fsStoreProductMapper.insertFsStoreProduct(product);
                 Long fsStoreProductId = product.getProductId();
                 Long fsStoreProductId = product.getProductId();

+ 6 - 4
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java

@@ -37,6 +37,7 @@ import com.fs.his.domain.FsUserBill;
 import com.fs.his.domain.FsUserWx;
 import com.fs.his.domain.FsUserWx;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.vo.OptionsVO;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.vo.*;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.qw.vo.QwFsUserVO;
@@ -57,10 +58,6 @@ import com.fs.hisStore.service.IFsUserCompanyUserScrmService;
 import com.fs.hisStore.service.IFsUserProjectTagScrmService;
 import com.fs.hisStore.service.IFsUserProjectTagScrmService;
 import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.hisStore.service.cache.IFsUserCourseCountCacheService;
 import com.fs.hisStore.service.cache.IFsUserCourseCountCacheService;
-import com.fs.hisStore.vo.FSUserVO;
-import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
-import com.fs.hisStore.vo.FsUserLastCount;
-import com.fs.hisStore.vo.FsUserTuiVO;
 import com.fs.hisStore.vo.h5.*;
 import com.fs.hisStore.vo.h5.*;
 import com.fs.system.mapper.SysDictDataMapper;
 import com.fs.system.mapper.SysDictDataMapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
@@ -1162,4 +1159,9 @@ public class FsUserScrmServiceImpl implements IFsUserScrmService
     public void incPayMoney(BigDecimal payMoney, Long userId) {
     public void incPayMoney(BigDecimal payMoney, Long userId) {
         fsUserMapper.incPayMoney(payMoney, userId);
         fsUserMapper.incPayMoney(payMoney, userId);
     }
     }
+
+    @Override
+    public List<UserScrmVo> selectUserVOList(String phone) {
+        return fsUserMapper.selectUserVOList(phone);
+    }
 }
 }

+ 43 - 3
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreAfterSalesVO.java

@@ -100,7 +100,47 @@ public class FsStoreAfterSalesVO implements Serializable
     @Excel(name = "提交时间",width =30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "提交时间",width =30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
     private Date createTime;
 
 
-
-
-
+    private String itemJson;
+
+    @Excel(name = "用户名称")
+    private String userName;
+    @Excel(name ="产品名称")
+    private String productName;
+    @Excel(name ="产品编码")
+    private String productBarCode;
+    @Excel(name ="规格")
+    private String sku;
+    @Excel(name ="产品数量")
+    private String num;
+    @Excel(name ="产品价格")
+    private String price;
+    @Excel(name ="产品编码")
+    private String barCode;
+    @Excel(name="额外运费")
+    private BigDecimal totalPostage;
+    @Excel(name="实付金额")
+    private BigDecimal payPrice;
+    //    @Excel(name="收货人姓名")
+//    private String realName;
+    @Excel(name ="详细地址")
+    private  String userAddress;
+    @Excel(name ="支付时间" ,dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date orderPayTime;
+    @Excel(name ="银行交易流水号")
+    private String bankSerialNo;
+
+    private String bankTransactionId;
+
+    private Long orderId;
+
+    private String cost;
+
+    private BigDecimal payMoney;
+
+    private String cateName;
+    private Date orderCreateTime;
+
+    private String orderDeliverySn;
+    private String orderDeliveryName;
+    private String orderDeliveryId;
 }
 }

+ 133 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportRefundZMVO.java

@@ -0,0 +1,133 @@
+package com.fs.hisStore.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author MixLiu
+ * @date 2025/12/4 上午11:43)
+ */
+
+@Data
+public class FsStoreOrderItemExportRefundZMVO implements Serializable  {
+
+
+    private Long itemId;
+
+    /** 订单号 */
+    @Excel(name = "订单号",sort = 1)
+    private String orderCode;
+
+    @Excel(name = "订单状态", dictType = "store_order_status",sort = 10)
+    private String status;
+
+    @Excel(name = "会员ID" ,sort = 20)
+    private Long userId;
+
+    @Excel(name = "产品名称",sort = 30)
+    private String productName;
+
+    @Excel(name = "产品编码",sort =40)
+    private String barCode;
+
+
+    @Excel(name = "规格",sort =50)
+    private String sku;
+
+    @Excel(name = "产品数量",sort =60)
+    private String num;
+
+
+    @Excel(name = "产品价格",sort =70)
+    private String price;
+
+    @Excel(name = "成本价",sort =80)
+    private String cost;
+    @Excel(name = "结算价",sort =90)
+    private BigDecimal FPrice;
+
+    @Excel(name = "实付金额",sort =91)
+    private BigDecimal payMoney;
+
+    @Excel(name = "额外运费",sort =100)
+    private BigDecimal payPostage;
+    private Integer totalNum;
+    @Excel(name = "商品分类",sort =100)
+    private String cateName;
+
+
+    private String jsonInfo;
+
+    /** 用户姓名 */
+    @Excel(name = "收货人姓名",sort =110)
+    private String realName;
+
+    /** 用户电话 */
+    @Excel(name = "收货人电话",sort =120)
+    private String userPhone;
+
+    /** 详细地址 */
+    @Excel(name = "详细地址",sort =130)
+    private String userAddress;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 140)
+    private Date createTime;
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 150)
+    private Date payTime;
+
+    /** 快递公司编号 */
+    @Excel(name = "快递公司编号",sort = 160)
+    private String deliverySn;
+
+    /** 快递名称/送货人姓名 */
+    @Excel(name = "快递公司",sort = 170)
+    private String deliveryName;
+
+    /** 快递单号/手机号 */
+    @Excel(name = "快递单号",sort = 180)
+    private String deliveryId;
+
+    @Excel(name = "所属公司",sort = 190)
+    private String companyName;
+    @Excel(name = "所属销售",sort = 200)
+    private String companyUserNickName;
+
+    @Excel(name = "套餐名称",sort = 210)
+    private String packageName;
+
+    @Excel(name = "组合码",sort = 210)
+    private String groupBarCode;
+
+    @Excel(name = "是否上传凭证 0:未上传 1:已上传",sort = 210)
+    private Integer isUpload;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 220)
+    private Date uploadTime;
+
+    @Excel(name = "归属档期",sort = 230)
+    private String scheduleName;
+
+    //银行交易流水号
+    @Excel(name = "银行交易流水号",sort = 240)
+    private String bankTransactionId;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "退款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 220)
+    private Date refundTime;
+
+    @Excel(name = "退款数量" ,sort = 230)
+    private Integer afterSalesNumber;
+
+    @Excel(name = "退款金额" ,sort = 240)
+    private BigDecimal refundMoney;
+
+}

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportVO.java

@@ -45,6 +45,9 @@ public class FsStoreOrderItemExportVO implements Serializable
     private BigDecimal cost;
     private BigDecimal cost;
     @Excel(name = "结算价")
     @Excel(name = "结算价")
     private BigDecimal FPrice;
     private BigDecimal FPrice;
+
+    private BigDecimal payMoney;
+
     @Excel(name = "额外运费")
     @Excel(name = "额外运费")
     private BigDecimal payPostage;
     private BigDecimal payPostage;
     private Integer totalNum;
     private Integer totalNum;

+ 124 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportZMVO.java

@@ -0,0 +1,124 @@
+package com.fs.hisStore.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author MixLiu
+ * @date 2025/12/4 上午11:43)
+ */
+
+@Data
+public class FsStoreOrderItemExportZMVO implements Serializable  {
+
+
+    private Long itemId;
+
+    /** 订单号 */
+    @Excel(name = "订单号",sort = 1)
+    private String orderCode;
+
+    @Excel(name = "订单状态", dictType = "store_order_status",sort = 10)
+    private String status;
+
+    @Excel(name = "会员ID" ,sort = 20)
+    private Long userId;
+
+    @Excel(name = "产品名称",sort = 30)
+    private String productName;
+
+    @Excel(name = "产品编码",sort =40)
+    private String barCode;
+
+
+    @Excel(name = "规格",sort =50)
+    private String sku;
+
+    @Excel(name = "产品数量",sort =60)
+    private Integer num;
+
+
+    @Excel(name = "产品价格",sort =70)
+    private BigDecimal price;
+
+    @Excel(name = "成本价",sort =80)
+    private BigDecimal cost;
+    @Excel(name = "结算价",sort =90)
+    private BigDecimal FPrice;
+
+    @Excel(name = "实付金额",sort =91)
+    private BigDecimal payMoney;
+
+    @Excel(name = "额外运费",sort =100)
+    private BigDecimal payPostage;
+    private Integer totalNum;
+    @Excel(name = "商品分类",sort =100)
+    private String cateName;
+
+
+    private String jsonInfo;
+
+    /** 用户姓名 */
+    @Excel(name = "收货人姓名",sort =110)
+    private String realName;
+
+    /** 用户电话 */
+    @Excel(name = "收货人电话",sort =120)
+    private String userPhone;
+
+    /** 详细地址 */
+    @Excel(name = "详细地址",sort =130)
+    private String userAddress;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 140)
+    private Date createTime;
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 150)
+    private Date payTime;
+
+    /** 快递公司编号 */
+    @Excel(name = "快递公司编号",sort = 160)
+    private String deliverySn;
+
+    /** 快递名称/送货人姓名 */
+    @Excel(name = "快递公司",sort = 170)
+    private String deliveryName;
+
+    /** 快递单号/手机号 */
+    @Excel(name = "快递单号",sort = 180)
+    private String deliveryId;
+
+    @Excel(name = "所属公司",sort = 190)
+    private String companyName;
+    @Excel(name = "所属销售",sort = 200)
+    private String companyUserNickName;
+
+    @Excel(name = "套餐名称",sort = 210)
+    private String packageName;
+
+    @Excel(name = "组合码",sort = 210)
+    private String groupBarCode;
+
+    @Excel(name = "是否上传凭证 0:未上传 1:已上传",sort = 210)
+    private Integer isUpload;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 220)
+    private Date uploadTime;
+
+    @Excel(name = "归属档期",sort = 230)
+    private String scheduleName;
+
+    //银行交易流水号
+    @Excel(name = "银行交易流水号",sort = 240)
+    private String bankTransactionId;
+
+
+}

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemVO.java

@@ -4,6 +4,7 @@ import com.fs.common.annotation.Excel;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 
 @Data
 @Data
 public class FsStoreOrderItemVO  implements Serializable
 public class FsStoreOrderItemVO  implements Serializable
@@ -47,5 +48,11 @@ public class FsStoreOrderItemVO  implements Serializable
     private Integer isPrescribe;
     private Integer isPrescribe;
 
 
     private Integer isDrug; //是否为药品
     private Integer isDrug; //是否为药品
+    //成本
+    private String cost;
+    //商品分类
+    private String cateName;
+
+
 
 
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreProductPacketVO.java

@@ -71,6 +71,9 @@ public class FsStoreProductPacketVO implements Serializable
     @Excel(name = "状态", dictType = "common_status")
     @Excel(name = "状态", dictType = "common_status")
     private Integer status;
     private Integer status;
 
 
+    @Excel(name = "赠送积分")
+    private Integer integral;
+
     List<StoreOrderProductDTO> productList;
     List<StoreOrderProductDTO> productList;
 
 
 }
 }

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/vo/UserScrmVo.java

@@ -0,0 +1,11 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+@Data
+public class UserScrmVo {
+    Long id;
+    String name;
+    String position;
+    String certificateCode;
+}

+ 2 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrder.java

@@ -349,5 +349,7 @@ public class LiveOrder extends BaseEntity {
     private Integer cost;
     private Integer cost;
     @TableField(exist = false)
     @TableField(exist = false)
     private String bankTransactionId;
     private String bankTransactionId;
+    @TableField(exist = false)
+    private Long attrValueId;
 
 
 }
 }

+ 4 - 0
fs-service/src/main/java/com/fs/live/domain/LiveWatchUser.java

@@ -62,4 +62,8 @@ public class LiveWatchUser extends BaseEntity {
     @Excel(name = "用户所在位置")
     @Excel(name = "用户所在位置")
     private String location;
     private String location;
 
 
+
+    private Integer pageNum;
+    private Integer pageSize;
+
 }
 }

+ 2 - 2
fs-service/src/main/java/com/fs/live/mapper/LiveAfterSalesMapper.java

@@ -119,9 +119,9 @@ public interface LiveAfterSalesMapper {
             "and sales_status = 3 " +
             "and sales_status = 3 " +
             "</if>" +
             "</if>" +
             "<if test = 'maps.userId != null    '> " +
             "<if test = 'maps.userId != null    '> " +
-            "and user_id = #{maps.userId} " +
+            "and las.user_id = #{maps.userId} " +
             "</if>" +
             "</if>" +
-            "order by create_time desc "+
+            "order by las.create_time desc "+
             "</script>"})
             "</script>"})
     List<LiveAfterSalesQueryVO> selectLiveAfterSalesListQuery(@Param("maps") LiveAfterSalesQueryParam param);
     List<LiveAfterSalesQueryVO> selectLiveAfterSalesListQuery(@Param("maps") LiveAfterSalesQueryParam param);
 
 

+ 3 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java

@@ -166,4 +166,7 @@ public interface LiveOrderItemMapper {
             " order by o.id desc limit 50000"+
             " order by o.id desc limit 50000"+
             "</script>"})
             "</script>"})
     List<LiveOrderItemExportVO> selectFsStoreOrderItemListExportVO(@Param("maps") LiveOrderParam fsStoreOrder);
     List<LiveOrderItemExportVO> selectFsStoreOrderItemListExportVO(@Param("maps") LiveOrderParam fsStoreOrder);
+
+
+    List<LiveOrderItemListUVO> selectLiveOrderItemListUVOByOrderIds(@Param("orderIds")List<Long> orderIds);
 }
 }

+ 15 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java

@@ -1,6 +1,7 @@
 package com.fs.live.mapper;
 package com.fs.live.mapper;
 
 
 
 
+import com.fs.hisStore.vo.FsStoreOrderItemExportZMVO;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.dto.LiveOrderDeliveryNoteDTO;
 import com.fs.live.dto.LiveOrderDeliveryNoteDTO;
 import com.fs.live.param.FsMyLiveOrderQueryParam;
 import com.fs.live.param.FsMyLiveOrderQueryParam;
@@ -418,6 +419,8 @@ public interface LiveOrderMapper {
 
 
     List<LiveOrderVoZm> selectLiveOrderListZm(LiveOrder liveOrder);
     List<LiveOrderVoZm> selectLiveOrderListZm(LiveOrder liveOrder);
 
 
+    List<FsStoreOrderItemExportZMVO> selectLiveOrderListZmNew(LiveOrder liveOrder);
+
     @Select(" SELECT * from live_order WHERE item_json is NULL ORDER BY create_time DESC  LIMIT 30")
     @Select(" SELECT * from live_order WHERE item_json is NULL ORDER BY create_time DESC  LIMIT 30")
     List<LiveOrder> selectLiveOrderItemJson();
     List<LiveOrder> selectLiveOrderItemJson();
 
 
@@ -459,4 +462,16 @@ public interface LiveOrderMapper {
 
 
 
 
     void batchUpdateTime(@Param("list") List<LiveOrder> list);
     void batchUpdateTime(@Param("list") List<LiveOrder> list);
+
+    @Update({
+            "<script>",
+            "UPDATE live_order ",
+            "SET update_time = NOW() ",
+            "WHERE id IN ",
+            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
+            "#{id}",
+            "</foreach>",
+            "</script>"
+    })
+    void batchUpdateTimeIds(@Param("ids") List<Long> ids);
 }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderComputedParam.java

@@ -17,6 +17,7 @@ public class LiveOrderComputedParam implements Serializable
     private Long productId;
     private Long productId;
     private String totalNum;
     private String totalNum;
     private Long cityId;
     private Long cityId;
+    private Long attrValueId;
 
 
 
 
     @ApiModelProperty(value = "使用积分 1使用")
     @ApiModelProperty(value = "使用积分 1使用")

+ 9 - 0
fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java

@@ -5,6 +5,7 @@ import com.fs.erp.domain.ErpOrder;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
 import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
 import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
 import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
+import com.fs.hisStore.vo.FsStoreOrderItemExportZMVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrder;
@@ -237,6 +238,8 @@ public interface ILiveOrderService {
 
 
     List<LiveOrderVoZm> selectLiveOrderListZm(LiveOrder liveOrder);
     List<LiveOrderVoZm> selectLiveOrderListZm(LiveOrder liveOrder);
 
 
+    List<FsStoreOrderItemExportZMVO> selectLiveOrderListZmNew(LiveOrder liveOrder);
+
     R handleLiveOrderPay(LiveOrderPayParam param);
     R handleLiveOrderPay(LiveOrderPayParam param);
 
 
     List<LiveOrder> selectLiveOrderItemJson();
     List<LiveOrder> selectLiveOrderItemJson();
@@ -261,4 +264,10 @@ public interface ILiveOrderService {
     List<LiveOrder> selectBankOrder();
     List<LiveOrder> selectBankOrder();
 
 
     void batchUpdateTime(List<LiveOrder> list);
     void batchUpdateTime(List<LiveOrder> list);
+
+    void batchUpdateTimeIds(List<Long> ids);
+
+    Long isExistPayedRecord(Long orderId);
+
+    void payConfirmPayment(Long existPayedRecordId);
 }
 }

+ 2 - 0
fs-service/src/main/java/com/fs/live/service/ILiveService.java

@@ -195,4 +195,6 @@ public interface ILiveService
     R liveListAll(PageRequest pageRequest);
     R liveListAll(PageRequest pageRequest);
 
 
     List<Live> listToLiveNoEnd(Live live);
     List<Live> listToLiveNoEnd(Live live);
+
+    Live selectLiveDbByLiveId(Long liveId);
 }
 }

+ 4 - 3
fs-service/src/main/java/com/fs/live/service/ILiveWatchUserService.java

@@ -2,6 +2,7 @@ package com.fs.live.service;
 
 
 
 
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
+import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.live.domain.LiveWatchUser;
 import com.fs.live.domain.LiveWatchUser;
 import com.fs.live.vo.LiveWatchUserVO;
 import com.fs.live.vo.LiveWatchUserVO;
 
 
@@ -77,9 +78,9 @@ public interface ILiveWatchUserService {
 
 
     Map<String, Integer> getLiveFlagWithCache(Long liveId);
     Map<String, Integer> getLiveFlagWithCache(Long liveId);
 
 
-    LiveWatchUser join(long liveId, long userId, String location);
-    LiveWatchUser joinWithoutLocation(long liveId, long userId);
-    LiveWatchUser close(long liveId, long userId);
+    LiveWatchUser join(FsUserScrm fsUser,long liveId, long userId, String location);
+    LiveWatchUser joinWithoutLocation(FsUserScrm fsUser,long liveId, long userId);
+    LiveWatchUser close(FsUserScrm fsUser,long liveId, long userId);
 
 
     /**
     /**
      * 查询直播间在线用户列表
      * 查询直播间在线用户列表

+ 101 - 69
fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java

@@ -5,6 +5,7 @@ import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
@@ -12,6 +13,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.CustomException;
@@ -56,10 +58,7 @@ import com.fs.live.param.*;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderLogsService;
 import com.fs.live.service.ILiveOrderLogsService;
 import com.fs.live.service.ILiveOrderService;
 import com.fs.live.service.ILiveOrderService;
-import com.fs.live.vo.LiveAfterSalesListUVO;
-import com.fs.live.vo.LiveAfterSalesQueryVO;
-import com.fs.live.vo.LiveAfterSalesVo;
-import com.fs.live.vo.LiveOrderItemVO1;
+import com.fs.live.vo.*;
 import com.fs.store.config.StoreConfig;
 import com.fs.store.config.StoreConfig;
 import com.fs.store.domain.*;
 import com.fs.store.domain.*;
 import com.fs.store.service.cache.IFsUserCacheService;
 import com.fs.store.service.cache.IFsUserCacheService;
@@ -201,6 +200,17 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
     public List<LiveAfterSalesVo> selectLiveAfterSalesVoList(LiveAfterSalesVo liveAfterSales)
     public List<LiveAfterSalesVo> selectLiveAfterSalesVoList(LiveAfterSalesVo liveAfterSales)
     {
     {
         List<LiveAfterSalesVo> liveAfterSalesVos = baseMapper.selectLiveAfterSalesVoList(liveAfterSales);
         List<LiveAfterSalesVo> liveAfterSalesVos = baseMapper.selectLiveAfterSalesVoList(liveAfterSales);
+        List<Long> orderIds = new ArrayList<>();
+        Map<Long, List<LiveOrderItemListUVO>> orderItemMap = new HashMap<>();
+        if(null != liveAfterSalesVos && !liveAfterSalesVos.isEmpty()){
+            orderIds = liveAfterSalesVos.stream().map(e -> e.getOrderId()).collect(Collectors.toList());
+            if(null != orderIds && !orderIds.isEmpty()){
+                List<LiveOrderItemListUVO> liveOrderItemListUVOS = liveOrderItemMapper.selectLiveOrderItemListUVOByOrderIds(orderIds);
+                orderItemMap = liveOrderItemListUVOS.stream()
+                        .collect(Collectors.groupingBy(LiveOrderItemListUVO::getOrderId));
+            }
+        }
+        boolean mapEmpty = orderItemMap.isEmpty();
         for (LiveAfterSalesVo item : liveAfterSalesVos) {
         for (LiveAfterSalesVo item : liveAfterSalesVos) {
             if(ObjectUtil.isNotNull(item.getUserId())) {
             if(ObjectUtil.isNotNull(item.getUserId())) {
                 FsUser fsUser = fsUserCacheService.selectFsUserById(item.getUserId());
                 FsUser fsUser = fsUserCacheService.selectFsUserById(item.getUserId());
@@ -217,6 +227,43 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
                 item.setCompanyName("-");
                 item.setCompanyName("-");
             }
             }
 
 
+            if(!mapEmpty && orderItemMap.containsKey(item.getOrderId())){
+                List<LiveOrderItemListUVO> liveOrderItemListUVOS = orderItemMap.get(item.getOrderId());
+                for (LiveOrderItemListUVO liveOrderItemListUVO : liveOrderItemListUVOS) {
+                    try {
+                        JSONObject jsO = JSONObject.parseObject(liveOrderItemListUVO.getJsonInfo());
+                        item.setProductName(StringUtils.isNotBlank(item.getProductName()) ? item.getProductName() + "," + jsO.getString("productName") : jsO.getString("productName"));
+                        item.setProductBarCode(StringUtils.isNotBlank(item.getProductBarCode()) ? item.getProductBarCode() + "," + jsO.getString("barCode") : jsO.getString("barCode"));
+                        item.setSku(StringUtils.isNotBlank(item.getSku()) ? item.getSku() + "," + jsO.getString("sku") : jsO.getString("sku"));
+                        item.setNum(StringUtils.isNotBlank(item.getNum()) ? item.getNum() + "," + jsO.getString("num") : jsO.getString("num"));
+                        item.setPrice(StringUtils.isNotBlank(item.getPrice()) ? item.getPrice() + "," + jsO.getString("price") : jsO.getString("price"));
+                        item.setCost(StringUtils.isNotBlank(item.getCost()) ? item.getCost() + "," + liveOrderItemListUVO.getCost() : liveOrderItemListUVO.getCost());
+                        item.setCateName(StringUtils.isNotBlank(item.getCateName()) ? item.getCateName() + "," + liveOrderItemListUVO.getCateName() : liveOrderItemListUVO.getCateName());
+                    } catch (Exception ex) {
+                        log.error("售后订单商品信息转换异常",ex);
+                    }
+                }
+            }
+//            if (StringUtils.isNotBlank(item.getItemJson())) {
+//                try {
+//                    JSONArray array = JSONObject.parseArray(item.getItemJson());
+//                    if(null != array && !array.isEmpty()){
+//                        for (Object o : array) {
+//                            JSONObject jsO = (JSONObject) o;
+//                            item.setProductName(StringUtils.isNotBlank(item.getProductName())?item.getProductName()+","+jsO.getString("productName"):jsO.getString("productName"));
+//                            item.setProductBarCode(StringUtils.isNotBlank(item.getProductBarCode())?item.getProductBarCode()+","+jsO.getString("barCode"):jsO.getString("barCode"));
+//                            item.setSku(StringUtils.isNotBlank(item.getSku())?item.getSku()+","+jsO.getString("sku"):jsO.getString("sku"));
+//                            item.setNum(null != item.getNum()?item.getNum() +jsO.getInteger("num"):jsO.getInteger("num"));
+//                            item.setPrice(null != item.getPrice()?item.getPrice().add(jsO.getBigDecimal("price")):jsO.getBigDecimal("price"));
+//                        }
+//                    }
+//                } catch (Exception ex) {
+//                    log.error("售后订单商品信息转换异常",ex);
+//                }
+//
+//            }
+
+
 //            if(ObjectUtil.isNotNull(item.getOrderId())){
 //            if(ObjectUtil.isNotNull(item.getOrderId())){
 //                List<FsStoreDelivers> byOrderIdWithType = fsStoreDeliversService.findByOrderIdWithType(item.getOrderId(), 1);
 //                List<FsStoreDelivers> byOrderIdWithType = fsStoreDeliversService.findByOrderIdWithType(item.getOrderId(), 1);
 //                if(CollectionUtils.isNotEmpty(byOrderIdWithType)) {
 //                if(CollectionUtils.isNotEmpty(byOrderIdWithType)) {
@@ -233,71 +280,56 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
     @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
     public R cancel(LiveAfterSalesCancelParam param) {
     public R cancel(LiveAfterSalesCancelParam param) {
-//        LiveAfterSales storeAfterSales = baseMapper.selectLiveAfterSalesById(param.getSalesId());
-//        if (storeAfterSales == null) {
-//            throw new CustomException("未查询到售后订单信息");
-//        }
-//        if (storeAfterSales.getSalesStatus()!=0) {
-//            throw new CustomException("非法操作");
-//        }
-//
-//        LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(storeAfterSales.getOrderId()));
-//        order.setStatus(storeAfterSales.getOrderStatus());
-//        order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_0.getValue()));
-//        liveOrderService.updateLiveOrder(order);
-//        storeAfterSales.setSalesStatus(2);
-//        LiveAfterSalesLogs storeAfterSalesStatus = new LiveAfterSalesLogs();
-//        storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId());
-//        storeAfterSalesStatus.setChangeType(6);
-//        storeAfterSalesStatus.setChangeMessage(AfterSalesStatusEnum.STATUS_6.getDesc()+" "+param.getRemark());
-//        storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
-//        storeAfterSalesStatus.setOperator(param.getOperator());
-//        liveAfterSalesLogsMapper.insertLiveAfterSalesLogs(storeAfterSalesStatus);
-//
-//        // 查询是否已经发货
-//        FsStoreDelivers byOrderCode = fsStoreDeliversMapper.findByOrderCode(order.getOrderCode());
-//        // 如果已发货走发货售后逻辑,否则直接取消
-//        if(byOrderCode!=null){
-//            if(StringUtils.isNotBlank(order.getStoreHouseCode())) {
-//                String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
-//                if (StringUtils.equals(erp, ErpTypeConstant.JST_ERP)) {
-//
-//                    FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
-//                    fsJstAftersalePush.setOrderId(order.getOrderCode());
-//                    fsJstAftersalePush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
-//                    fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.CLOSED.getIndex()));
-//                    fsJstAftersalePush.setRetryCount(0);
-//                    fsJstAftersalePush.setAfterSaleId(String.valueOf(storeAfterSales.getId()));
-//                    fsJstAftersalePush.setOrderType(1);
-//                    fsJstAftersalePushMapper.insert(fsJstAftersalePush);
-//                }
-//            }
-//        }
-//        // 如果未发货,重新推送
-//        else {
-//            //创建新的OMS订单
-//            if (storeAfterSales.getOrderStatus().equals(2) ) {
-//                if(StringUtils.isNotEmpty(order.getExtendOrderId())){
-//                    //更新订单code
-//                    String orderSn = SnowflakeUtils.nextId();
-//                    LiveOrder orderMap=new LiveOrder();
-//                    orderMap.setOrderId(order.getOrderId());
-//                    orderMap.setOrderCode(orderSn);
-//                    liveOrderService.updateLiveOrder(orderMap);
-//                    storeAfterSales.setStoreId(Long.valueOf(orderSn));
-//                    liveOrderItemService.updateFsStoreOrderCode(order.getOrderId(),orderSn);
-//                    //生成新的订单
-//                    try {
-//                        liveOrderService.createOmsOrder(order.getOrderId());
-//                    } catch (Exception e) {
-//                        log.error("创建订单失败!",e);
-//                        throw new CustomException("创建订单失败");
-//                    }
-//                }
-//            }
-//
-//        }
-//        baseMapper.updateLiveAfterSales(storeAfterSales);
+        LiveAfterSales storeAfterSales = baseMapper.selectLiveAfterSalesById(param.getSalesId());
+        if (storeAfterSales == null) {
+            throw new CustomException("未查询到售后订单信息");
+        }
+        if (storeAfterSales.getSalesStatus()!=0) {
+            throw new CustomException("非法操作");
+        }
+
+        LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(storeAfterSales.getOrderId()));
+        order.setStatus(storeAfterSales.getOrderStatus());
+        order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_0.getValue()));
+        liveOrderService.updateLiveOrder(order);
+        storeAfterSales.setSalesStatus(2);
+        LiveAfterSalesLogs storeAfterSalesStatus = new LiveAfterSalesLogs();
+        storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId());
+        storeAfterSalesStatus.setChangeType(6);
+        storeAfterSalesStatus.setChangeMessage(AfterSalesStatusEnum.STATUS_6.getDesc()+" "+param.getRemark());
+        storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
+        storeAfterSalesStatus.setOperator(param.getOperator());
+        liveAfterSalesLogsMapper.insertLiveAfterSalesLogs(storeAfterSalesStatus);
+        if (ObjectUtil.equal(order.getStatus(), 2)) {
+            FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
+            fsJstAftersalePush.setOrderId(order.getOrderCode());
+            fsJstAftersalePush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
+            fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.CLOSED.getIndex()));
+            fsJstAftersalePush.setRetryCount(0);
+            fsJstAftersalePush.setAfterSaleId(String.valueOf(storeAfterSales.getId()));
+            fsJstAftersalePushMapper.insert(fsJstAftersalePush);
+        } else {
+            //创建新的OMS订单
+            if (storeAfterSales.getOrderStatus().equals(OrderInfoEnum.STATUS_1.getValue()) ) {
+                if(StringUtils.isNotEmpty(order.getExtendOrderId())){
+                    //更新订单code
+                    String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
+                    LiveOrder orderMap=new LiveOrder();
+                    orderMap.setOrderId(order.getOrderId());
+                    orderMap.setOrderCode(orderSn);
+                    liveOrderService.updateLiveOrder(orderMap);
+                    liveOrderItemMapper.updateFsStoreOrderCode(order.getOrderId(),orderSn);
+                    try {
+                        //生成新的订单
+                        liveOrderService.createOmsOrder(order.getOrderId());
+                    } catch (Exception e) {
+                        log.error("撤销售后,生成oms订单异常",e);
+                    }
+
+                }
+            }
+        }
+        baseMapper.updateLiveAfterSales(storeAfterSales);
         return R.ok();
         return R.ok();
     }
     }
 
 

+ 143 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -82,8 +82,10 @@ import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.*;
 import com.fs.hisStore.vo.*;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
+import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.live.domain.*;
 import com.fs.live.domain.*;
@@ -98,8 +100,13 @@ import com.fs.live.service.*;
 import com.fs.live.vo.*;
 import com.fs.live.vo.*;
 import com.fs.store.domain.*;
 import com.fs.store.domain.*;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysConfigService;
+import com.fs.tzBankPay.doman.QueryOrderResult;
+import com.fs.tzBankPay.doman.TzBankResult;
+import com.fs.tzBankPay.doman.payQueryOrder;
 import com.fs.wx.order.domain.FsWxExpressTask;
 import com.fs.wx.order.domain.FsWxExpressTask;
 import com.fs.wx.order.mapper.FsWxExpressTaskMapper;
 import com.fs.wx.order.mapper.FsWxExpressTaskMapper;
+import com.fs.ybPay.domain.OrderResult;
+import com.fs.ybPay.dto.OrderQueryDTO;
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
 import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
@@ -230,6 +237,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
 
     @Autowired
     @Autowired
     private FsStoreProductScrmMapper fsStoreProductBaseMapper;
     private FsStoreProductScrmMapper fsStoreProductBaseMapper;
+
+    @Autowired
+    private FsStoreProductAttrValueScrmMapper attrValueScrmMapper;
     @Autowired
     @Autowired
     private ISysConfigService configService;
     private ISysConfigService configService;
 
 
@@ -1208,6 +1218,19 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         for (LiveOrderItem vo : orderItemVOS) {
         for (LiveOrderItem vo : orderItemVOS) {
             if (vo.getIsAfterSales() == 1) {
             if (vo.getIsAfterSales() == 1) {
                 fsStoreProductService.incProductStock(vo.getNum(), vo.getProductId(), vo.getProductAttrValueId());
                 fsStoreProductService.incProductStock(vo.getNum(), vo.getProductId(), vo.getProductAttrValueId());
+                LiveOrderItemDTO liveOrderItemDTO = JSONObject.parseObject(vo.getJsonInfo(), LiveOrderItemDTO.class);
+                // 获取商品信息
+                FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(vo.getProductId());
+                if (fsStoreProduct != null) {
+                    // 获取商品属性值中的条形码
+                    FsStoreProductAttrValueScrm fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attr -> StringUtils.isNotEmpty(attr.getBarCode()) && attr.getBarCode().equals(liveOrderItemDTO.getBarCode())).findFirst().orElse(null);
+                    if (fsStoreProductAttrValue != null) {
+                        fsStoreProductAttrValue.setStock((int) (fsStoreProductAttrValue.getStock() + vo.getNum()));
+                        fsStoreProductAttrValue.setSales(fsStoreProductAttrValue.getSales() - 1);
+                        fsStoreProductAttrValueMapper.updateFsStoreProductAttrValue(fsStoreProductAttrValue);
+                    }
+
+                }
             }
             }
         }
         }
         if ("3".equals(order.getPayType())) {
         if ("3".equals(order.getPayType())) {
@@ -1392,6 +1415,18 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         for (LiveOrderItem vo : orderItemVOS) {
         for (LiveOrderItem vo : orderItemVOS) {
             if (vo.getIsAfterSales() == 1) {
             if (vo.getIsAfterSales() == 1) {
                 fsStoreProductService.incProductStock(vo.getNum(), vo.getProductId(), vo.getProductAttrValueId());
                 fsStoreProductService.incProductStock(vo.getNum(), vo.getProductId(), vo.getProductAttrValueId());
+                LiveOrderItemDTO liveOrderItemDTO = JSONObject.parseObject(vo.getJsonInfo(), LiveOrderItemDTO.class);
+                // 获取商品信息
+                FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(vo.getProductId());
+                if (fsStoreProduct != null) {
+                    // 获取商品属性值中的条形码
+                    FsStoreProductAttrValueScrm fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attr -> StringUtils.isNotEmpty(attr.getBarCode()) && attr.getBarCode().equals(liveOrderItemDTO.getBarCode())).findFirst().orElse(null);
+                    if (fsStoreProductAttrValue != null) {
+                        fsStoreProductAttrValue.setStock((int) (fsStoreProductAttrValue.getStock() + vo.getNum()));
+                        fsStoreProductAttrValue.setSales(fsStoreProductAttrValue.getSales() - 1);
+                        fsStoreProductAttrValueMapper.updateFsStoreProductAttrValue(fsStoreProductAttrValue);
+                    }
+                }
             }
             }
         }
         }
         if ("3".equals(order.getPayType())) {
         if ("3".equals(order.getPayType())) {
@@ -1582,6 +1617,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     }
     }
 
 
     @Override
     @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
     public R createOmsOrder(Long orderId)  throws ParseException {
     public R createOmsOrder(Long orderId)  throws ParseException {
         LiveOrder order = liveOrderMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
         LiveOrder order = liveOrderMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
         LiveOrderPayment liveOrderPayment = liveOrderPaymentMapper.selectByBuissnessId(orderId);
         LiveOrderPayment liveOrderPayment = liveOrderPaymentMapper.selectByBuissnessId(orderId);
@@ -1821,10 +1857,23 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             return null;
             return null;
         }
         }
         FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
         FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
-        if(fsStoreProduct == null) return null;
+        if (fsStoreProduct == null) {
+            log.error("商品不存在");
+            return null;
+        }
+        FsStoreProductAttrValueScrm fsStoreProductAttrValue = null;
+        if (!Objects.isNull(param.getAttrValueId())) {
+            fsStoreProductAttrValue = attrValueScrmMapper.selectFsStoreProductAttrValueById(param.getAttrValueId());
+        }
+
+        BigDecimal totalPrice = BigDecimal.ZERO;
+        if (fsStoreProductAttrValue != null) {
+            totalPrice = fsStoreProductAttrValue.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        } else {
+            totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        }
         BigDecimal payPrice = BigDecimal.ZERO;
         BigDecimal payPrice = BigDecimal.ZERO;
         BigDecimal payDelivery = BigDecimal.ZERO;
         BigDecimal payDelivery = BigDecimal.ZERO;
-        BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
         if (param.getCityId() != null) {
         if (param.getCityId() != null) {
             payDelivery = handleDeliveryMoney(param.getCityId(), fsStoreProduct, param.getTotalNum());
             payDelivery = handleDeliveryMoney(param.getCityId(), fsStoreProduct, param.getTotalNum());
             totalPrice = totalPrice.add(payDelivery);
             totalPrice = totalPrice.add(payDelivery);
@@ -1953,11 +2002,24 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     public LiveOrderComputeDTO computedOrder(long userId, LiveOrderComputedParam param) {
     public LiveOrderComputeDTO computedOrder(long userId, LiveOrderComputedParam param) {
         String orderKey= redisCache.getCacheObject("orderKey:"+param.getOrderKey());
         String orderKey= redisCache.getCacheObject("orderKey:"+param.getOrderKey());
         if (StringUtils.isEmpty(orderKey)) {
         if (StringUtils.isEmpty(orderKey)) {
+            log.error("订单已失效");
             return null;
             return null;
         }
         }
         FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
         FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
+        if (fsStoreProduct == null) {
+            log.error("商品不存在");
+            return null;
+        }
+        FsStoreProductAttrValueScrm fsStoreProductAttrValue = null;
+        if (!Objects.isNull(param.getAttrValueId())) {
+            fsStoreProductAttrValue = attrValueScrmMapper.selectFsStoreProductAttrValueById(param.getAttrValueId());
+        }
+
         BigDecimal totalPrice = BigDecimal.ZERO;
         BigDecimal totalPrice = BigDecimal.ZERO;
         BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
         BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        if (fsStoreProductAttrValue != null) {
+            payPrice = fsStoreProductAttrValue.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        }
         totalPrice = totalPrice.add(payPrice);
         totalPrice = totalPrice.add(payPrice);
         BigDecimal payDelivery = BigDecimal.ZERO;
         BigDecimal payDelivery = BigDecimal.ZERO;
         BigDecimal deductionPrice = BigDecimal.ZERO;
         BigDecimal deductionPrice = BigDecimal.ZERO;
@@ -2889,6 +2951,16 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         return baseMapper.selectLiveOrderListZm(liveOrder);
         return baseMapper.selectLiveOrderListZm(liveOrder);
     }
     }
 
 
+    /**
+     * 导出新模板改动
+     * @param liveOrder
+     * @return
+     */
+    @Override
+    public List<FsStoreOrderItemExportZMVO> selectLiveOrderListZmNew(LiveOrder liveOrder){
+        return baseMapper.selectLiveOrderListZmNew(liveOrder);
+    }
+
     @Override
     @Override
     @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
     @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
     public R handleLiveOrderPay(LiveOrderPayParam param) {
     public R handleLiveOrderPay(LiveOrderPayParam param) {
@@ -3325,6 +3397,53 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         baseMapper.batchUpdateTime(list);
         baseMapper.batchUpdateTime(list);
     }
     }
 
 
+    @Override
+    public void batchUpdateTimeIds(List<Long> ids) {
+        baseMapper.batchUpdateTimeIds(ids);
+    }
+
+    @Override
+    public Long isExistPayedRecord(Long orderId) {
+        LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
+        if (liveOrder != null) {
+            List<LiveOrderPayment> paymentList = liveOrderPaymentMapper.selectLiveOrderPaymentByOrderId(orderId);
+            if (null != paymentList && !paymentList.isEmpty()) {
+                for (LiveOrderPayment payment : paymentList) {
+                    V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
+                    request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
+                    request.setOrgHfSeqId(payment.getTradeNo());
+                    HuiFuQueryOrderResult queryOrderResult = null;
+                    try {
+                        queryOrderResult = huiFuService.queryOrder(request);
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
+                    if ("00000000".equals(queryOrderResult.getResp_code())) {
+                        if (queryOrderResult.getTrans_stat().equals("S")) {
+                            return payment.getPaymentId();
+                        }
+                    }
+                }
+            }
+
+        } else {
+            throw new RuntimeException("直播订单不存在");
+        }
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public void payConfirmPayment(Long existPayedRecordId) {
+        LiveOrderPayment payment = liveOrderPaymentMapper.selectLiveOrderPaymentByPaymentId(existPayedRecordId);
+        if (payment == null) {
+            log.error("支付单不存在");
+            return;
+        }
+        log.info("手动查询单号:" + existPayedRecordId + ":" + payment);
+        this.payConfirm(1, null, payment.getPayCode(), payment.getTradeNo(), payment.getBankSerialNo(), payment.getBankSerialNo());
+    }
+
 
 
     @Override
     @Override
     @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
     @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
@@ -3355,10 +3474,20 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(goods.getStock() == null) return R.error("直播间商品库存不足");
         if(goods.getStock() == null) return R.error("直播间商品库存不足");
         if(fsStoreProduct.getStock() < Integer.parseInt(liveOrder.getTotalNum()) || goods.getStock() < Integer.parseInt(liveOrder.getTotalNum())) return R.error("抱歉,这款商品已被抢光,暂时无库存~");
         if(fsStoreProduct.getStock() < Integer.parseInt(liveOrder.getTotalNum()) || goods.getStock() < Integer.parseInt(liveOrder.getTotalNum())) return R.error("抱歉,这款商品已被抢光,暂时无库存~");
 
 
-        // 更改店铺库存
-        fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
-        fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
-        fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
+        FsStoreProductAttrValueScrm attrValue = null;
+        if (!Objects.isNull(liveOrder.getAttrValueId())) {
+            attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(liveOrder.getAttrValueId());
+        }
+        if (attrValue != null) {
+            attrValue.setStock(attrValue.getStock() - Integer.parseInt(liveOrder.getTotalNum()));
+            attrValue.setSales(attrValue.getSales() + Integer.parseInt(liveOrder.getTotalNum()));
+        } else {
+            // 更改店铺库存
+            fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
+            fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
+            fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
+        }
+
         // 更新直播间库存
         // 更新直播间库存
         goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
         goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
         goods.setSales(goods.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
         goods.setSales(goods.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
@@ -3381,6 +3510,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         log.info("订单生成:"+orderSn);
         log.info("订单生成:"+orderSn);
         liveOrder.setOrderCode(orderSn);
         liveOrder.setOrderCode(orderSn);
         BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
         BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+        if (attrValue != null) {
+            payPrice = attrValue.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+        }
         // 直播不需要服务费 0915 1735 左
         // 直播不需要服务费 0915 1735 左
 //        String config=configService.selectConfigByKey("store.config");
 //        String config=configService.selectConfigByKey("store.config");
 //        StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
 //        StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
@@ -3429,7 +3561,11 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 LiveOrderItemDTO dto=new LiveOrderItemDTO();
                 LiveOrderItemDTO dto=new LiveOrderItemDTO();
                 dto.setImage(fsStoreProduct.getImage());
                 dto.setImage(fsStoreProduct.getImage());
                 dto.setSku(String.valueOf(fsStoreProduct.getStock()));
                 dto.setSku(String.valueOf(fsStoreProduct.getStock()));
-                FsStoreProductAttrValueScrm fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
+                FsStoreProductAttrValueScrm fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attr -> StringUtils.isNotEmpty(attr.getBarCode())).findFirst().orElse(null);
+                if (fsStoreProductAttrValue != null) {
+                    dto.setBarCode(fsStoreProductAttrValue.getBarCode());
+                    dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());
+                }
                 if (fsStoreProductAttrValue != null) {
                 if (fsStoreProductAttrValue != null) {
                     dto.setBarCode(fsStoreProductAttrValue.getBarCode());
                     dto.setBarCode(fsStoreProductAttrValue.getBarCode());
                     dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());
                     dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());

+ 113 - 3
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -128,6 +128,28 @@ public class LiveServiceImpl implements ILiveService
     private static volatile Integer version = 0;
     private static volatile Integer version = 0;
 
 
 
 
+    @Override
+    public Live selectLiveDbByLiveId(Long liveId) {
+        // 缓存中没有,从数据库查询
+        Live byId = baseMapper.selectLiveByLiveId(liveId);
+        if (byId == null) {
+            return null;
+        }
+
+        List<LiveVideo> videos = liveVideoService.listByLiveId(liveId, 1);
+        if(!videos.isEmpty()){
+            LiveVideo liveVideo = videos.get(0);
+            byId.setVideoUrl(liveVideo.getVideoUrl());
+            byId.setDuration(liveVideo.getDuration());
+            byId.setVideoId(liveVideo.getVideoId());
+            byId.setVideoType(liveVideo.getVideoType());
+            byId.setVideoFileSize(liveVideo.getFileSize());
+            byId.setVideoDuration(liveVideo.getDuration());
+        }
+
+        return byId;
+    }
+
 
 
     /**
     /**
      * 查询直播
      * 查询直播
@@ -137,7 +159,19 @@ public class LiveServiceImpl implements ILiveService
      */
      */
     @Override
     @Override
     public Live selectLiveByLiveId(Long liveId){
     public Live selectLiveByLiveId(Long liveId){
+        // 先从缓存中获取
+        String cacheKey = String.format(LiveKeysConstant.LIVE_DATA_CACHE, liveId);
+        Live cachedLive = redisCache.getCacheObject(cacheKey);
+        if (cachedLive != null) {
+            return cachedLive;
+        }
+
+        // 缓存中没有,从数据库查询
         Live byId = baseMapper.selectLiveByLiveId(liveId);
         Live byId = baseMapper.selectLiveByLiveId(liveId);
+        if (byId == null) {
+            return null;
+        }
+
         List<LiveVideo> videos = liveVideoService.listByLiveId(liveId, 1);
         List<LiveVideo> videos = liveVideoService.listByLiveId(liveId, 1);
         if(!videos.isEmpty()){
         if(!videos.isEmpty()){
             LiveVideo liveVideo = videos.get(0);
             LiveVideo liveVideo = videos.get(0);
@@ -148,6 +182,10 @@ public class LiveServiceImpl implements ILiveService
             byId.setVideoFileSize(liveVideo.getFileSize());
             byId.setVideoFileSize(liveVideo.getFileSize());
             byId.setVideoDuration(liveVideo.getDuration());
             byId.setVideoDuration(liveVideo.getDuration());
         }
         }
+
+        // 将结果存入缓存
+        redisCache.setCacheObject(cacheKey, byId, LiveKeysConstant.LIVE_DATA_CACHE_EXPIRE, TimeUnit.SECONDS);
+
         return byId;
         return byId;
     }
     }
 
 
@@ -385,12 +423,17 @@ public class LiveServiceImpl implements ILiveService
     @Transactional
     @Transactional
     public int updateLiveEntity(Live live) {
     public int updateLiveEntity(Live live) {
         log.error("updateLiveEntity:"+ live.getLiveId());
         log.error("updateLiveEntity:"+ live.getLiveId());
-        return baseMapper.updateLive( live);
+        int result = baseMapper.updateLive( live);
+        // 清除缓存
+        clearLiveCache(live.getLiveId());
+        return result;
     }
     }
 
 
     @Override
     @Override
     public void updateGlobalVisible(long liveId, Integer status) {
     public void updateGlobalVisible(long liveId, Integer status) {
         baseMapper.updateGlobalVisible(liveId, status);
         baseMapper.updateGlobalVisible(liveId, status);
+        // 清除缓存
+        clearLiveCache(liveId);
     }
     }
 
 
     @Override
     @Override
@@ -531,6 +574,9 @@ public class LiveServiceImpl implements ILiveService
         int result = baseMapper.updateLive(live);
         int result = baseMapper.updateLive(live);
         liveAutoTaskService.recalcLiveAutoTask(live);
         liveAutoTaskService.recalcLiveAutoTask(live);
 
 
+        // 清除缓存
+        clearLiveCache(live.getLiveId());
+
         return result;
         return result;
     }
     }
 
 
@@ -542,7 +588,10 @@ public class LiveServiceImpl implements ILiveService
      */
      */
     @Override
     @Override
     public int deleteLiveByLiveIds(Long[] liveIds,Live live){
     public int deleteLiveByLiveIds(Long[] liveIds,Live live){
-        return baseMapper.deleteLiveByLiveIds(liveIds, live);
+        int result = baseMapper.deleteLiveByLiveIds(liveIds, live);
+        // 清除缓存
+        clearLiveCache(liveIds);
+        return result;
     }
     }
 
 
     /**
     /**
@@ -554,7 +603,10 @@ public class LiveServiceImpl implements ILiveService
     @Override
     @Override
     public int deleteLiveByLiveId(Long liveId)
     public int deleteLiveByLiveId(Long liveId)
     {
     {
-        return baseMapper.deleteLiveByLiveId(liveId);
+        int result = baseMapper.deleteLiveByLiveId(liveId);
+        // 清除缓存
+        clearLiveCache(liveId);
+        return result;
     }
     }
 
 
     @Override
     @Override
@@ -599,6 +651,8 @@ public class LiveServiceImpl implements ILiveService
         live.setStatus(2);
         live.setStatus(2);
         live.setLiveType(1);
         live.setLiveType(1);
         this.updateLive(live);
         this.updateLive(live);
+        // 清除缓存
+        clearLiveCache(liveId);
         LiveData liveData = new LiveData();
         LiveData liveData = new LiveData();
         liveData.setLiveId(liveId);
         liveData.setLiveId(liveId);
         liveData.setPageViews(0L);
         liveData.setPageViews(0L);
@@ -665,6 +719,8 @@ public class LiveServiceImpl implements ILiveService
         live.setLiveType(2);
         live.setLiveType(2);
         log.error("closeLiving:" + live.getLiveId());
         log.error("closeLiving:" + live.getLiveId());
         baseMapper.updateLive(live);
         baseMapper.updateLive(live);
+        // 清除缓存
+        clearLiveCache(live.getLiveId());
         return R.ok();
         return R.ok();
     }
     }
     /**
     /**
@@ -701,6 +757,8 @@ public class LiveServiceImpl implements ILiveService
 
 
             log.error("startLoopPlay:" + live.getLiveId());
             log.error("startLoopPlay:" + live.getLiveId());
             baseMapper.updateLive(curLive);
             baseMapper.updateLive(curLive);
+            // 清除缓存
+            clearLiveCache(live.getLiveId());
 
 
             return R.ok();
             return R.ok();
         } catch (Exception e) {
         } catch (Exception e) {
@@ -729,6 +787,8 @@ public class LiveServiceImpl implements ILiveService
             curLive.setUpdateTime(new Date());
             curLive.setUpdateTime(new Date());
             log.error("stopLoopPlay:" + live.getLiveId());
             log.error("stopLoopPlay:" + live.getLiveId());
             baseMapper.updateLive(curLive);
             baseMapper.updateLive(curLive);
+            // 清除缓存
+            clearLiveCache(live.getLiveId());
 
 
             return R.ok();
             return R.ok();
         } catch (Exception e) {
         } catch (Exception e) {
@@ -740,6 +800,8 @@ public class LiveServiceImpl implements ILiveService
     public R handleShelfOrUn(LiveListVo listVo) {
     public R handleShelfOrUn(LiveListVo listVo) {
         int updatedCount = baseMapper.updateBatchLiveList(listVo);
         int updatedCount = baseMapper.updateBatchLiveList(listVo);
         log.error("有人下架了视频:" + listVo.getLiveIds());
         log.error("有人下架了视频:" + listVo.getLiveIds());
+        // 清除缓存
+        clearLiveCache(listVo.getLiveIds());
         if (updatedCount > 0) {
         if (updatedCount > 0) {
             return R.ok("操作成功");
             return R.ok("操作成功");
         }
         }
@@ -749,6 +811,8 @@ public class LiveServiceImpl implements ILiveService
     @Override
     @Override
     public R handleDeleteSelected(LiveListVo listVo) {
     public R handleDeleteSelected(LiveListVo listVo) {
         int deleteCount = baseMapper.deleteBatchLiveList(listVo);
         int deleteCount = baseMapper.deleteBatchLiveList(listVo);
+        // 清除缓存
+        clearLiveCache(listVo.getLiveIds());
         if (deleteCount > 0) {
         if (deleteCount > 0) {
             return R.ok("操作成功");
             return R.ok("操作成功");
         }
         }
@@ -773,6 +837,8 @@ public class LiveServiceImpl implements ILiveService
         exist.setUpdateTime(new Date());
         exist.setUpdateTime(new Date());
 
 
         baseMapper.updateLive(exist);
         baseMapper.updateLive(exist);
+        // 清除缓存
+        clearLiveCache(live.getLiveId());
 
 
         return R.ok();
         return R.ok();
     }
     }
@@ -806,6 +872,8 @@ public class LiveServiceImpl implements ILiveService
         exist.setFinishTime( null);
         exist.setFinishTime( null);
         exist.setStartTime(LocalDateTime.now());
         exist.setStartTime(LocalDateTime.now());
         baseMapper.updateLive(exist);
         baseMapper.updateLive(exist);
+        // 清除缓存
+        clearLiveCache(live.getLiveId());
         List<LiveAutoTask> liveAutoTasks = liveAutoTaskService.selectNoActivedByLiveId(exist.getLiveId(), new Date());
         List<LiveAutoTask> liveAutoTasks = liveAutoTaskService.selectNoActivedByLiveId(exist.getLiveId(), new Date());
         liveAutoTasks.forEach(liveAutoTask -> {
         liveAutoTasks.forEach(liveAutoTask -> {
             liveAutoTask.setCreateTime(null);
             liveAutoTask.setCreateTime(null);
@@ -822,12 +890,16 @@ public class LiveServiceImpl implements ILiveService
     public R handleShelfOrUnAdmin(LiveListVo listVo) {
     public R handleShelfOrUnAdmin(LiveListVo listVo) {
         baseMapper.handleShelfOrUnAdmin(listVo);
         baseMapper.handleShelfOrUnAdmin(listVo);
         log.error("有人下架了视频:" + listVo.getLiveIds());
         log.error("有人下架了视频:" + listVo.getLiveIds());
+        // 清除缓存
+        clearLiveCache(listVo.getLiveIds());
         return R.ok();
         return R.ok();
     }
     }
 
 
     @Override
     @Override
     public R handleDeleteSelectedAdmin(LiveListVo listVo) {
     public R handleDeleteSelectedAdmin(LiveListVo listVo) {
         baseMapper.handleDeleteSelectedAdmin(listVo);
         baseMapper.handleDeleteSelectedAdmin(listVo);
+        // 清除缓存
+        clearLiveCache(listVo.getLiveIds());
         return R.ok();
         return R.ok();
     }
     }
 
 
@@ -1184,6 +1256,42 @@ public class LiveServiceImpl implements ILiveService
         return jsonObject.getLong(key);
         return jsonObject.getLong(key);
     }
     }
 
 
+    /**
+     * 清除直播间数据缓存
+     * @param liveId 直播间ID
+     */
+    private void clearLiveCache(Long liveId) {
+        if (liveId != null) {
+            String cacheKey = String.format(LiveKeysConstant.LIVE_DATA_CACHE, liveId);
+            redisCache.deleteObject(cacheKey);
+            log.debug("清除直播间缓存: liveId={}", liveId);
+        }
+    }
+
+    /**
+     * 批量清除直播间数据缓存
+     * @param liveIds 直播间ID数组
+     */
+    private void clearLiveCache(Long[] liveIds) {
+        if (liveIds != null && liveIds.length > 0) {
+            for (Long liveId : liveIds) {
+                clearLiveCache(liveId);
+            }
+        }
+    }
+
+    /**
+     * 批量清除直播间数据缓存
+     * @param liveIds 直播间ID列表
+     */
+    private void clearLiveCache(List<Long> liveIds) {
+        if (liveIds != null && !liveIds.isEmpty()) {
+            for (Long liveId : liveIds) {
+                clearLiveCache(liveId);
+            }
+        }
+    }
+
 
 
 
 
     /**
     /**
@@ -1224,6 +1332,8 @@ public class LiveServiceImpl implements ILiveService
                 live.setIdCardUrl(payload.get("idCardUrl"));
                 live.setIdCardUrl(payload.get("idCardUrl"));
                 log.error("verifyIdInfo:" + live.getLiveId());
                 log.error("verifyIdInfo:" + live.getLiveId());
                 baseMapper.updateLive(live);
                 baseMapper.updateLive(live);
+                // 清除缓存
+                clearLiveCache(live.getLiveId());
                 return R.ok();
                 return R.ok();
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {

+ 6 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java

@@ -200,8 +200,7 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
     }
     }
 
 
     @Override
     @Override
-    public LiveWatchUser join(long liveId, long userId, String location) {
-        FsUserScrm fsUserVO = fsUserService.selectFsUserByUserId(userId);
+    public LiveWatchUser join(FsUserScrm fsUser,long liveId, long userId, String location) {
         Date now = DateUtils.getNowDate();
         Date now = DateUtils.getNowDate();
 
 
         // 查询直播间信息
         // 查询直播间信息
@@ -231,7 +230,7 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
             liveWatchUser = new LiveWatchUser();
             liveWatchUser = new LiveWatchUser();
             liveWatchUser.setLiveId(liveId);
             liveWatchUser.setLiveId(liveId);
             liveWatchUser.setUserId(userId);
             liveWatchUser.setUserId(userId);
-            liveWatchUser.setAvatar(fsUserVO.getAvatar());
+            liveWatchUser.setAvatar(fsUser.getAvatar());
             liveWatchUser.setMsgStatus(0);
             liveWatchUser.setMsgStatus(0);
             liveWatchUser.setOnline(0);
             liveWatchUser.setOnline(0);
             liveWatchUser.setLocation(location);
             liveWatchUser.setLocation(location);
@@ -242,15 +241,15 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
             baseMapper.insertLiveWatchUser(liveWatchUser);
             baseMapper.insertLiveWatchUser(liveWatchUser);
         }
         }
 
 
-        liveWatchUser.setAvatar(fsUserVO.getAvatar());
-        liveWatchUser.setNickName(fsUserVO.getNickname());
+        liveWatchUser.setAvatar(fsUser.getAvatar());
+        liveWatchUser.setNickName(fsUser.getNickname());
         String hashKey = String.format(LiveKeysConstant.LIVE_WATCH_USERS, liveId);
         String hashKey = String.format(LiveKeysConstant.LIVE_WATCH_USERS, liveId);
         redisCache.hashPut(hashKey, String.valueOf(userId), JSON.toJSONString(liveWatchUser));
         redisCache.hashPut(hashKey, String.valueOf(userId), JSON.toJSONString(liveWatchUser));
         return liveWatchUser;
         return liveWatchUser;
     }
     }
 
 
     @Override
     @Override
-    public LiveWatchUser joinWithoutLocation(long liveId, long userId) {
+    public LiveWatchUser joinWithoutLocation(FsUserScrm fsUser,long liveId, long userId) {
         FsUserScrm fsUserVO = fsUserService.selectFsUserByUserId(userId);
         FsUserScrm fsUserVO = fsUserService.selectFsUserByUserId(userId);
         Date now = DateUtils.getNowDate();
         Date now = DateUtils.getNowDate();
 
 
@@ -295,7 +294,7 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
         return liveWatchUser;
         return liveWatchUser;
     }
     }
     @Override
     @Override
-    public LiveWatchUser close(long liveId, long userId) {
+    public LiveWatchUser close(FsUserScrm fsUser,long liveId, long userId) {
 
 
         // 查询直播间信息
         // 查询直播间信息
         Live live = liveMapper.selectLiveByLiveId(liveId);
         Live live = liveMapper.selectLiveByLiveId(liveId);

+ 41 - 1
fs-service/src/main/java/com/fs/live/vo/LiveAfterSalesVo.java

@@ -108,7 +108,7 @@ public class LiveAfterSalesVo {
     /** 用户id */
     /** 用户id */
     @Excel(name = "用户id")
     @Excel(name = "用户id")
     private Long userId;
     private Long userId;
-    //    @Excel(name = "用户名称")
+    @Excel(name = "用户名称")
     private String userName;
     private String userName;
 
 
     /** 商家收货人 */
     /** 商家收货人 */
@@ -147,4 +147,44 @@ public class LiveAfterSalesVo {
      */
      */
     private String deliveryId;
     private String deliveryId;
 
 
+    private String itemJson;
+
+    @Excel(name ="产品名称")
+    private String productName;
+    @Excel(name ="产品编码")
+    private String productBarCode;
+    @Excel(name ="规格")
+    private String sku;
+    @Excel(name ="产品数量")
+    private String num;
+    @Excel(name ="产品价格")
+    private String price;
+    @Excel(name="额外运费")
+    private BigDecimal totalPostage;
+    @Excel(name="实付金额")
+    private BigDecimal payPrice;
+//    @Excel(name="收货人姓名")
+//    private String realName;
+    @Excel(name ="详细地址")
+    private  String userAddress;
+    @Excel(name ="支付时间" ,dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date orderPayTime;
+    @Excel(name ="银行交易流水号")
+    private String bankSerialNo;
+
+    private String bankTransactionId;
+
+
+    private String cost;
+
+    private BigDecimal payMoney;
+
+    private String cateName;
+    private Date orderCreateTime;
+
+    private String orderDeliverySn;
+    private String orderDeliveryName;
+    private String orderDeliveryId;
+
+
 }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveDataDetailVo.java

@@ -97,3 +97,4 @@ public class LiveDataDetailVo {
 
 
 
 
 
 
+

+ 5 - 1
fs-service/src/main/java/com/fs/live/vo/LiveOrderItemListUVO.java

@@ -7,6 +7,7 @@ import java.io.Serializable;
 @Data
 @Data
 public class LiveOrderItemListUVO implements Serializable {
 public class LiveOrderItemListUVO implements Serializable {
 
 
+    private Long orderId;
     /** 商品ID */
     /** 商品ID */
     private Long productId;
     private Long productId;
     private Long itemId;
     private Long itemId;
@@ -18,5 +19,8 @@ public class LiveOrderItemListUVO implements Serializable {
     /** 数量 */
     /** 数量 */
     private Long num;
     private Long num;
 
 
-
+    //成本
+    private String cost;
+    //商品分类
+    private String cateName;
 }
 }

+ 10 - 2
fs-service/src/main/java/com/fs/live/vo/LiveOrderVoZm.java

@@ -479,6 +479,14 @@ public class LiveOrderVoZm{
     /** 银行交易流水号 */
     /** 银行交易流水号 */
     @Excel(name = "银行交易流水号")
     @Excel(name = "银行交易流水号")
     private String bankTransactionId;
     private String bankTransactionId;
-
-
+    //统一导出模板内容新增字段
+    private Integer num;
+    private String sku;
+//    private BigDecimal FPrice;
+    private String deliveryId;
+    private String packageName;
+    private String groupBarCode;
+    private Integer isUpload;
+    private Date uploadTime;
+    private String scheduleName;
 }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveUserDetailVo.java

@@ -39,3 +39,4 @@ public class LiveUserDetailVo {
 
 
 
 
 
 
+

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/ProductSalesVo.java

@@ -27,3 +27,4 @@ public class ProductSalesVo {
 
 
 
 
 
 
+

+ 3 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwCompanyMapper.java

@@ -76,4 +76,7 @@ public interface QwCompanyMapper
     List<QwOptionsVO> selectQwCompanyListOptionsVO(@Param("userId") Long userId, @Param("deptId") Long deptId);
     List<QwOptionsVO> selectQwCompanyListOptionsVO(@Param("userId") Long userId, @Param("deptId") Long deptId);
 
 
     List<QwCompany> selectByCorpIds(@Param("corpIds") List<String> corpIds);
     List<QwCompany> selectByCorpIds(@Param("corpIds") List<String> corpIds);
+
+    @Select("select DISTINCT corp_id from qw_company ")
+    List<String> selectQwCompanyListFormCorpId();
 }
 }

+ 101 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java

@@ -268,6 +268,13 @@ public interface QwExternalContactMapper extends BaseMapper<QwExternalContact> {
             "            <if test=\"companyUserId != null \"> and ec.company_user_id = #{companyUserId}</if>\n" +
             "            <if test=\"companyUserId != null \"> and ec.company_user_id = #{companyUserId}</if>\n" +
             "            <if test=\"customerId != null \"> and ec.customer_id = #{customerId}</if>\n" +
             "            <if test=\"customerId != null \"> and ec.customer_id = #{customerId}</if>\n" +
             "            <if test=\"status != null \"> and ec.status = #{status}</if>\n" +
             "            <if test=\"status != null \"> and ec.status = #{status}</if>\n" +
+            "            <if test=\"status != null \"> and ec.status = #{status}</if>\n" +
+            "<if test = \"statusCondition != null and  statusCondition.length > 0 \" > " +
+            "   AND ec.status in " +
+            "   <foreach collection='statusCondition' item='item' open='(' separator=',' close=')'> " +
+            "       #{item} " +
+            "   </foreach> " +
+            "</if >\n" +
             "            <if test=\"stageStatus != null \"> and ec.stage_status = #{stageStatus}</if>\n" +
             "            <if test=\"stageStatus != null \"> and ec.stage_status = #{stageStatus}</if>\n" +
             "            <if test=\"userRepeat != null \"> and ec.user_repeat = #{userRepeat}</if>\n" +
             "            <if test=\"userRepeat != null \"> and ec.user_repeat = #{userRepeat}</if>\n" +
             "            <if test=\"transferStatus != null \"> and ec.transfer_status = #{transferStatus}</if>\n" +
             "            <if test=\"transferStatus != null \"> and ec.transfer_status = #{transferStatus}</if>\n" +
@@ -544,4 +551,98 @@ public interface QwExternalContactMapper extends BaseMapper<QwExternalContact> {
     List<QwExternalContact> getGroupChatUserByChatIdAndUserName(@Param("userId")String userId,@Param("userName")String userName,@Param("corpId") String corpId,@Param("chatId") String chatId);
     List<QwExternalContact> getGroupChatUserByChatIdAndUserName(@Param("userId")String userId,@Param("userName")String userName,@Param("corpId") String corpId,@Param("chatId") String chatId);
     @Select("select * from qw_external_contact where unionid = #{unionID} order by create_time asc limit 1 ")
     @Select("select * from qw_external_contact where unionid = #{unionID} order by create_time asc limit 1 ")
     QwExternalContact selectQwExternalByUnionID(String unionId);
     QwExternalContact selectQwExternalByUnionID(String unionId);
+
+    @Select("<script> " +
+            "WITH contact_analysis AS (\n" +
+            "    SELECT \n" +
+            "        id,\n" +
+            "        external_user_id,\n" +
+            "        corp_id,\n" +
+            "        fs_user_id,\n" +
+            "        COUNT(CASE WHEN fs_user_id IS NOT NULL THEN 1 END) OVER (\n" +
+            "            PARTITION BY external_user_id, corp_id\n" +
+            "        ) as has_valid_fs_user,\n" +
+            "        COUNT(CASE WHEN fs_user_id IS NULL THEN 1 END) OVER (\n" +
+            "            PARTITION BY external_user_id, corp_id\n" +
+            "        ) as has_null_fs_user,\n" +
+            "        COUNT(*) OVER (\n" +
+            "            PARTITION BY external_user_id, corp_id\n" +
+            "        ) as total_records\n" +
+            "    FROM qw_external_contact\n" +
+            "    WHERE external_user_id IS NOT NULL \n" +
+            "          AND corp_id IS NOT NULL\n" +
+            "          AND create_time >='2025-10-01 00:00:00'\n" +
+            "     \n" +
+            "),\n" +
+            "filtered_contacts AS (\n" +
+            "    SELECT \n" +
+            "        id,\n" +
+            "        external_user_id,\n" +
+            "        corp_id,\n" +
+            "        fs_user_id\n" +
+            "    FROM contact_analysis\n" +
+            "    WHERE total_records >= 2\n" +
+            "        AND has_valid_fs_user >= 1\n" +
+            "        AND has_null_fs_user >= 1\n" +
+            "        AND fs_user_id IS NULL\n" +
+            ")\n" +
+            "SELECT \n" +
+            "    corp_id\n" +
+            "FROM filtered_contacts\n" +
+            "GROUP BY corp_id" +
+            "</script> ")
+    public List<String> selectQwExternalContactMandatoryRegistration();
+
+    @Select("<script>" +
+            "SELECT t1.id,t2.valid_fs_user_id as fs_user_id \n" +
+            "FROM qw_external_contact t1\n" +
+            "JOIN (\n" +
+            "    SELECT \n" +
+            "        external_user_id,\n" +
+            "        corp_id,\n" +
+            "        MAX(fs_user_id) as valid_fs_user_id\n" +
+            "    FROM qw_external_contact\n" +
+            "    WHERE external_user_id IS NOT NULL \n" +
+            "        AND corp_id IS NOT NULL \n" +
+            "        AND corp_id = #{corpId}\n" +
+            "        AND fs_user_id IS NOT NULL\n" +
+            "        AND create_time >='2025-10-01 00:00:00' \n" +
+            "    GROUP BY external_user_id, corp_id\n" +
+            ") t2 ON t1.external_user_id = t2.external_user_id \n" +
+            "    AND t1.corp_id = t2.corp_id\n" +
+            "JOIN (\n" +
+            "    SELECT \n" +
+            "        external_user_id,\n" +
+            "        corp_id\n" +
+            "    FROM qw_external_contact\n" +
+            "    WHERE external_user_id IS NOT NULL \n" +
+            "        AND corp_id IS NOT NULL \n" +
+            "        AND corp_id = #{corpId}\n" +
+            "        AND create_time >='2025-10-01 00:00:00' \n" +
+            "    GROUP BY external_user_id, corp_id\n" +
+            "    HAVING COUNT(*) >= 2\n" +
+            "        AND SUM(CASE WHEN fs_user_id IS NOT NULL THEN 1 ELSE 0 END) >= 1\n" +
+            "        AND SUM(CASE WHEN fs_user_id IS NULL THEN 1 ELSE 0 END) >= 1\n" +
+            ") t3 ON t1.external_user_id = t3.external_user_id \n" +
+            "    AND t1.corp_id = t3.corp_id\n" +
+            "WHERE t1.fs_user_id IS NULL\n" +
+            "    AND t1.corp_id = #{corpId}\n" +
+            "</script>")
+    public List<QwMandatoryRegistrParam> selectQwExternalContactMandatoryRegistrationByIds(@Param("corpId") String corpId);
+
+
+
+    @Update("<script>" +
+            "UPDATE qw_external_contact " +
+            "SET fs_user_id = CASE " +
+            "<foreach collection='map' item='item'>" +
+            "WHEN id = #{item.id} THEN #{item.fsUserId} " +
+            "</foreach>" +
+            "ELSE fs_user_id END " +
+            "WHERE id IN " +
+            "<foreach collection='map' item='item' open='(' separator=',' close=')'>" +
+            "#{item.id}" +
+            "</foreach>" +
+            "</script>")
+    public int batchUpdateQwExternalContactMandatoryRegistration(@Param("map") List<QwMandatoryRegistrParam> batchList);
 }
 }

+ 7 - 0
fs-service/src/main/java/com/fs/qw/param/QwExternalContactParam.java

@@ -1,5 +1,6 @@
 package com.fs.qw.param;
 package com.fs.qw.param;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.annotation.Excel;
 import lombok.Data;
 import lombok.Data;
@@ -107,6 +108,12 @@ public class QwExternalContactParam {
 
 
     private Integer transferStatus;
     private Integer transferStatus;
     private Integer status;
     private Integer status;
+    //多选状态
+    @TableField(exist = false)
+    private String statuses;
+
+    @TableField(exist = false)
+    private String[] statusCondition;
     private String stageStatus;
     private String stageStatus;
     private String isBind;
     private String isBind;
     private String isBindMini;
     private String isBindMini;

Some files were not shown because too many files changed in this diff