Ver código fonte

销售绑定用户 直播数据消息 区分直播还是回放 直播订单同步到微信

yuhongqi 1 semana atrás
pai
commit
cbcf18539b
24 arquivos alterados com 248 adições e 62 exclusões
  1. 5 0
      fs-admin/src/main/java/com/fs/hisStore/task/LiveTask.java
  2. 1 1
      fs-common/src/main/java/com/fs/common/constant/LiveKeysConstant.java
  3. 64 0
      fs-company/src/main/java/com/fs/company/controller/company/CompanyUserController.java
  4. 52 21
      fs-live-app/src/main/java/com/fs/live/task/Task.java
  5. 5 15
      fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java
  6. 3 0
      fs-service/src/main/java/com/fs/company/domain/CompanyUser.java
  7. 15 0
      fs-service/src/main/java/com/fs/company/mapper/CompanyUserMapper.java
  8. 15 0
      fs-service/src/main/java/com/fs/company/service/ICompanyUserService.java
  9. 10 0
      fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java
  10. 1 1
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java
  11. 7 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java
  12. 7 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java
  13. 1 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  14. 5 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java
  15. 2 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrder.java
  16. 1 1
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  17. 2 2
      fs-service/src/main/java/com/fs/live/mapper/LiveUserFirstEntryMapper.java
  18. 2 2
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  19. 6 4
      fs-service/src/main/java/com/fs/live/vo/LiveOrderVoZm.java
  20. 10 11
      fs-service/src/main/java/com/fs/wx/order/service/impl/LiveExpressToWxService.java
  21. 19 0
      fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml
  22. 6 0
      fs-service/src/main/resources/mapper/hisStore/FsUserScrmMapper.xml
  23. 4 0
      fs-service/src/main/resources/mapper/live/LiveMsgMapper.xml
  24. 5 4
      fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

+ 5 - 0
fs-admin/src/main/java/com/fs/hisStore/task/LiveTask.java

@@ -181,6 +181,10 @@ public class LiveTask {
     //每5分钟执行一次
     public void deliveryOp() {
         List<LiveOrder> list = liveOrderService.selectUpdateExpress();
+        if(list == null || list.isEmpty()) return;
+        if (list.size() > 100) {
+            list = list.subList(0, 100);
+        }
         for (LiveOrder order : list) {
             ErpOrderQueryRequert request = new ErpOrderQueryRequert();
             request.setCode(order.getExtendOrderId());
@@ -202,6 +206,7 @@ public class LiveTask {
                 }
             }
         }
+
     }
 
     public void couponOp() {

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

@@ -28,7 +28,7 @@ public class LiveKeysConstant {
     public static final String TOP_MSG = "topMsg"; //抽奖记录
 
     public static final String LIVE_FLAG_CACHE = "live:flag:%s"; //直播间直播/回放状态缓存
-    public static final Integer LIVE_FLAG_CACHE_EXPIRE = 60; //直播间状态缓存过期时间(秒)
+    public static final Integer LIVE_FLAG_CACHE_EXPIRE = 300; //直播间状态缓存过期时间(秒)
 
 
 }

+ 64 - 0
fs-company/src/main/java/com/fs/company/controller/company/CompanyUserController.java

@@ -35,6 +35,7 @@ import com.fs.framework.security.SecurityUtils;
 import com.fs.framework.service.TokenService;
 import com.fs.his.utils.qrcode.QRCodeUtils;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.hisStore.vo.FsStoreProductExportVO;
 import com.fs.im.config.IMConfig;
 import com.fs.im.dto.OpenImResponseDTO;
@@ -112,6 +113,9 @@ public class CompanyUserController extends BaseController {
     @Autowired
     private CloudHostProper cloudHostProper;
 
+    @Autowired
+    private IFsUserScrmService fsUserScrmService;
+
     private static final String appLink = "https://jump.ylrztop.com/jumpapp/pages/index/index?link=";
 
     /**
@@ -805,4 +809,64 @@ public class CompanyUserController extends BaseController {
         OpenImResponseDTO openImResponseDTO = openIMService.importFriend(ownerUserID, friendUserIDs);
         return R.ok().put("data",openImResponseDTO);
     }
+
+    /**
+     * 根据手机号码精确查询fs_user(完全匹配)
+     * @param phone 手机号码
+     * @return 用户列表
+     */
+    @ApiOperation("根据手机号码精确查询fs_user")
+    @GetMapping("/fsUser/queryByPhone")
+    public R queryFsUserByPhone(@RequestParam("phone") String phone) {
+        if (StringUtils.isEmpty(phone)) {
+            return R.error("手机号码不能为空");
+        }
+        List<com.fs.hisStore.domain.FsUserScrm> userList = fsUserScrmService.selectFsUserListByPhoneExact(phone);
+        return R.ok().put("data", userList);
+    }
+
+    /**
+     * 批量绑定用户到员工
+     * @param data 包含 userIds(公司用户ID列表)和 bindCompanyUserId(绑定的销售ID)
+     * @return 操作结果
+     */
+    @ApiOperation("批量绑定用户到员工")
+    @PostMapping("/batchBindCompanyUserId")
+    public R batchBindCompanyUserId(@RequestBody Map<String, Object> data) {
+        List<Long> userIds = (List<Long>) data.get("fsUserIds");
+        Long bindCompanyUserId = null;
+        if (data.get("companyUserId") != null) {
+            if (data.get("companyUserId") instanceof Integer) {
+                bindCompanyUserId = ((Integer) data.get("companyUserId")).longValue();
+            } else if (data.get("companyUserId") instanceof Long) {
+                bindCompanyUserId = (Long) data.get("companyUserId");
+            }
+        }
+
+        if (userIds == null || userIds.isEmpty()) {
+            return R.error("用户ID列表不能为空");
+        }
+
+        int result = companyUserService.batchUpdateBindCompanyUserId(userIds, bindCompanyUserId);
+        if (result > 0) {
+            return R.ok("绑定成功");
+        } else {
+            return R.error("绑定失败");
+        }
+    }
+
+    /**
+     * 查询已绑定的用户
+     * @param companyUserId 销售ID
+     * @return 绑定的用户列表
+     */
+    @ApiOperation("查询已绑定的用户")
+    @GetMapping("/getBoundUsers/{companyUserId}")
+    public R getBoundUsers(@PathVariable("companyUserId") Long companyUserId) {
+        if (companyUserId == null) {
+            return R.error("销售ID不能为空");
+        }
+        List<com.fs.hisStore.domain.FsUserScrm> userList = companyUserService.selectBoundFsUsersByCompanyUserId(companyUserId);
+        return R.ok().put("data", userList);
+    }
 }

+ 52 - 21
fs-live-app/src/main/java/com/fs/live/task/Task.java

@@ -461,27 +461,58 @@ public class Task {
             return;
         liveDatas.forEach(liveData ->{
 
-            Long resultLikeCount = getAsLong(redisCache, "live:like:" + liveData.getLiveId());
-            resultLikeCount = resultLikeCount > 0L ? resultLikeCount : liveData.getLikes();
-            redisCache.setCacheObject("live:like:" + liveData.getLiveId(), resultLikeCount.intValue());
-            liveData.setLikes(
-                    resultLikeCount
-            );
-
-       /* for (Long liveId : liveIds) {
-            LiveData liveData = liveDataService.selectLiveDataByLiveId(liveId);
-            if (liveData == null) {
-                continue; // 防止空指针异常
-            }*/
-
-
-            // 从 redis 获取数据,并提供默认值,避免 NPE
-            liveData.setPageViews(
-                    Math.max( liveData.getPageViews(), Optional.ofNullable(redisCache.incr(PAGE_VIEWS_KEY + liveData.getLiveId(),0)).orElse(0L))
-            );
-            liveData.setTotalViews(
-                    Math.max( liveData.getTotalViews(), Optional.ofNullable(redisCache.incr(TOTAL_VIEWS_KEY + liveData.getLiveId(),0)).orElse(0L))
-            );
+            Map<String, Integer> flagMap = liveWatchUserService.getLiveFlagWithCache(liveData.getLiveId());
+            Integer liveFlag = flagMap.get("liveFlag");
+
+            // 判断是直播还是回放
+            if (liveFlag != null && liveFlag == 1) {
+                // 直播:更新 likes 和 totalViews
+                Long resultLikeCount = getAsLong(redisCache, "live:like:" + liveData.getLiveId());
+                resultLikeCount = resultLikeCount > 0L ? resultLikeCount : liveData.getLikes();
+                redisCache.setCacheObject("live:like:" + liveData.getLiveId(), resultLikeCount.intValue());
+                liveData.setLikes(resultLikeCount);
+
+                // 从 redis 获取数据,并提供默认值,避免 NPE
+                liveData.setPageViews(
+                        Math.max( liveData.getPageViews(), Optional.ofNullable(redisCache.incr(PAGE_VIEWS_KEY + liveData.getLiveId(),0)).orElse(0L))
+                );
+                liveData.setTotalViews(
+                        Math.max( liveData.getTotalViews(), Optional.ofNullable(redisCache.incr(TOTAL_VIEWS_KEY + liveData.getLiveId(),0)).orElse(0L))
+                );
+            } else {
+                // 回放:使用 Redis 中的数据减去直播的数据,得到回放的数据
+                String likeKey = "live:like:" + liveData.getLiveId();
+                String totalViewsKey = TOTAL_VIEWS_KEY + liveData.getLiveId();
+                
+                // 从 Redis 获取总数据(直播+回放)
+                Long totalLikeCount = getAsLong(redisCache, likeKey);
+                Long totalViewCount = getAsLong(redisCache, totalViewsKey);
+                
+                // 获取数据库中直播的数据
+                Long liveLikeCount = liveData.getLikes() != null ? liveData.getLikes() : 0L;
+                Long liveViewCount = liveData.getTotalViews() != null ? liveData.getTotalViews() : 0L;
+                
+                // 回放数据 = Redis总数据 - 直播数据
+                Long replayLikeNum = totalLikeCount - liveLikeCount;
+                Long replayViewNum = totalViewCount - liveViewCount;
+                
+                // 确保回放数据不为负数
+                if (replayLikeNum < 0L) {
+                    replayLikeNum = 0L;
+                }
+                if (replayViewNum < 0L) {
+                    replayViewNum = 0L;
+                }
+                
+                // 更新回放数据
+                liveData.setReplayLikeNum(replayLikeNum);
+                liveData.setReplayViewNum(replayViewNum);
+
+                // 从 redis 获取数据,并提供默认值,避免 NPE
+                liveData.setPageViews(
+                        Math.max( liveData.getPageViews(), Optional.ofNullable(redisCache.incr(PAGE_VIEWS_KEY + liveData.getLiveId(),0)).orElse(0L))
+                );
+            }
             liveData.setUniqueVisitors(
                     /*Optional.ofNullable(redisCache.getCacheSet(UNIQUE_VISITORS_KEY + liveId))
                             .map(Set::size)  // 获取集合大小

+ 5 - 15
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -263,21 +263,11 @@ public class WebSocketServer {
                             return;
                         }
 
-                        // 根据直播状态设置live_flag或replay_flag
-                        Live msgLive = liveService.selectLiveByLiveId(msg.getLiveId());
-                        if (msgLive != null && msgLive.getFinishTime() != null) {
-                            Date finishTime = java.sql.Timestamp.valueOf(msgLive.getFinishTime());
-                            if (new Date().after(finishTime)) {
-                                liveMsg.setReplayFlag(1);
-                                liveMsg.setLiveFlag(0);
-                            } else {
-                                liveMsg.setLiveFlag(1);
-                                liveMsg.setReplayFlag(0);
-                            }
-                        } else {
-                            liveMsg.setLiveFlag(1);
-                            liveMsg.setReplayFlag(0);
-                        }
+                        Map<String, Integer> flagMap = liveWatchUserService.getLiveFlagWithCache(liveId);
+                        Integer liveFlag = flagMap.get("liveFlag");
+                        Integer replayFlag = flagMap.get("replayFlag");
+                        liveMsg.setLiveFlag(liveFlag);
+                        liveMsg.setReplayFlag(replayFlag);
 
                         liveMsgService.insertLiveMsg(liveMsg);
                     }

+ 3 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyUser.java

@@ -178,6 +178,9 @@ public class CompanyUser extends BaseEntity
     /** 是否允许所有方式注册会员,1-是,0-否,默认1(用于个微注册会员) */
     private Integer isAllowedAllRegister;
 
+    /** 绑定的公司用户ID */
+    private Long bindCompanyUserId;
+
     @TableField(exist = false)
     private List<Long> deptList;
 

+ 15 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyUserMapper.java

@@ -336,4 +336,19 @@ public interface CompanyUserMapper
             "</script>")
     List<Long> selectCompanyQwUserByDept(@Param("companyUserIDs") List<Long> companyUserIDs, @Param("userType") String userType);
 
+    /**
+     * 批量更新公司用户的绑定销售ID
+     * @param userIds 公司用户ID列表
+     * @param bindCompanyUserId 绑定的销售ID
+     * @return 更新结果
+     */
+    int batchUpdateBindCompanyUserId(@Param("userIds") List<Long> userIds, @Param("bindCompanyUserId") Long bindCompanyUserId);
+
+    /**
+     * 根据销售ID查询绑定的fs_user用户列表
+     * @param companyUserId 销售ID
+     * @return 绑定的用户列表
+     */
+    List<com.fs.hisStore.domain.FsUserScrm> selectBoundFsUsersByCompanyUserId(@Param("companyUserId") Long companyUserId);
+
 }

+ 15 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyUserService.java

@@ -249,4 +249,19 @@ public interface ICompanyUserService {
     R updateBatchUserRoles(BatchUserRolesVO batchUserRolesVO);
 
     List<Long> selectCompanyQwUserByDept(List<Long> deptList,String userType);
+
+    /**
+     * 批量更新公司用户的绑定销售ID
+     * @param userIds 公司用户ID列表
+     * @param bindCompanyUserId 绑定的销售ID
+     * @return 更新结果
+     */
+    int batchUpdateBindCompanyUserId(List<Long> userIds, Long bindCompanyUserId);
+
+    /**
+     * 根据销售ID查询绑定的fs_user用户列表
+     * @param companyUserId 销售ID
+     * @return 绑定的用户列表
+     */
+    List<com.fs.hisStore.domain.FsUserScrm> selectBoundFsUsersByCompanyUserId(Long companyUserId);
 }

+ 10 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -1086,4 +1086,14 @@ public class CompanyUserServiceImpl implements ICompanyUserService
     public List<Long> selectCompanyQwUserByDept(List<Long> deptList,String userType) {
         return companyUserMapper.selectCompanyQwUserByDept(deptList,userType);
     }
+
+    @Override
+    public int batchUpdateBindCompanyUserId(List<Long> userIds, Long bindCompanyUserId) {
+        return companyUserMapper.batchUpdateBindCompanyUserId(userIds, bindCompanyUserId);
+    }
+
+    @Override
+    public List<com.fs.hisStore.domain.FsUserScrm> selectBoundFsUsersByCompanyUserId(Long companyUserId) {
+        return companyUserMapper.selectBoundFsUsersByCompanyUserId(companyUserId);
+    }
 }

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

@@ -388,7 +388,7 @@ public interface FsStoreProductScrmMapper
     List<FsStoreProductScrm> getStoreProductInProductIds(List<Long> productIds);
 
     @Select({"<script> " +
-            "SELECT fsp.* FROM fs_store_product_scrm fsp " +
+            "SELECT distinct fsp.* FROM fs_store_product_scrm fsp " +
             " left join fs_store_product_attr_value_scrm fspav on fsp.product_id = fspav.product_id  " +
             "WHERE fsp.is_show = 1 and (fspav.bar_code is not null)  and " +
             " fsp.product_id NOT IN (" +

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

@@ -125,6 +125,13 @@ public interface FsUserScrmMapper
     @Select("select * from fs_user where phone=#{phone}")
     FsUserScrm selectFsUserByPhone(String phone);
 
+    /**
+     * 根据手机号码精确查询用户列表(完全匹配)
+     * @param phone 手机号码
+     * @return 用户列表
+     */
+    List<FsUserScrm> selectFsUserListByPhoneExact(String phone);
+
 
     @Select("select  b.total_amount,b.last_buy_time,p.pay_money as number,p.payment_id,p.pay_time," +
             " u.* FROM fs_user u LEFT JOIN  (" +

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

@@ -107,6 +107,13 @@ public interface IFsUserScrmService
 
     FsUserScrm selectFsUserByPhone(String phone);
 
+    /**
+     * 根据手机号码精确查询用户列表(完全匹配)
+     * @param phone 手机号码
+     * @return 用户列表
+     */
+    List<FsUserScrm> selectFsUserListByPhoneExact(String phone);
+
     TableDataInfo selectCusListPage(SelectCusListPageParam param);
 
     List<FsCompanyUserListQueryVO> selectFsCompanyUserListQuery(FsUserScrm fsUser);

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

@@ -408,6 +408,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
                 FsUserScrm fsUser = userService.selectFsUserByUserId(fsWxExpressTask.getUserId());
 
+                // 目前支持商城订单和直播订单
                 ExpressToWxService service = ExpressToWxHolder.findBest(fsWxExpressTask.getType(),fsWxExpressTask.getOrderCode());
                 Asserts.notNull(service,"订单类型不被支持!");
 

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java

@@ -247,6 +247,11 @@ public class FsUserScrmServiceImpl implements IFsUserScrmService
         return fsUserMapper.selectFsUserByPhone(phone);
     }
 
+    @Override
+    public List<FsUserScrm> selectFsUserListByPhoneExact(String phone) {
+        return fsUserMapper.selectFsUserListByPhoneExact(phone);
+    }
+
     @Override
     public TableDataInfo selectCusListPage(SelectCusListPageParam param) {
         Asserts.check(ObjectUtils.isNotNull(param.getPageNum()), "页数不能为空");

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

@@ -340,7 +340,9 @@ public class LiveOrder extends BaseEntity {
     private String productName;
     private String productSpec;
     private String productNum;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTimeStart;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTimeEnd;
 
     private Integer price;

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

@@ -104,7 +104,7 @@ public interface LiveOrderMapper {
     @Select("select * from live_order where `status` = 3 AND TIMESTAMPDIFF(HOUR, start_time, NOW()) >= 48  ")
     List<LiveOrder> selectLiveOrderByFinish();
 
-    @Select("select * from live_order where `status` = 1 and extend_order_id is not null ")
+    @Select("select * from live_order where `status` = 1 and extend_order_id is not null and delivery_sn is null ")
     List<LiveOrder> selectUpdateExpress();
 
     @Select("select order_id from live_order where `status` = 2")

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

@@ -78,8 +78,8 @@ public interface LiveUserFirstEntryMapper {
     LiveUserFirstEntry selectEntityByLiveIdUserId(@Param("liveId") long liveId,@Param("userId") long userId);
 
     @Select("SELECT  " +
-            "  cu.user_name companyUserName,  " +
-            "  count( 1 ) AS invite_num   " +
+            "  cu.nick_name as userName,  " +
+            "  sum( case when company_user_id > 0 then 1 else 0 end ) AS invite_num   " +
             "FROM  " +
             "  live_user_first_entry lufe  " +
             "  LEFT JOIN company_user cu ON lufe.company_user_id = cu.user_id   " +

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

@@ -1688,7 +1688,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             FsExpressScrm express = expressService.selectFsExpressByOmsCode(deliverCode);
             if (express != null) {
                 order.setDeliveryName(deliverName);
-                order.setDeliverySn(express.getCode());
+                order.setDeliveryCode(express.getCode());
             }
             order.setStatus(OrderInfoEnum.STATUS_2.getValue());
             order.setDeliverySn(deliveryId);
@@ -3289,7 +3289,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         liveOrder.setPayType("1");
         liveOrder.setTotalPrice(payPrice);
         liveOrder.setPayMoney(BigDecimal.ZERO);
-        liveOrder.setPayPrice(liveOrder.getTotalPrice().subtract(liveOrder.getDiscountMoney()));
+        liveOrder.setPayPrice(payPrice);
         try {
             if (baseMapper.insertLiveOrder(liveOrder) > 0) {
                 LiveOrderItemDTO dto=new LiveOrderItemDTO();

+ 6 - 4
fs-service/src/main/java/com/fs/live/vo/LiveOrderVoZm.java

@@ -123,6 +123,10 @@ public class LiveOrderVoZm{
     @Excel(name = "结算价格")
     private BigDecimal fPrice;
 
+    /** 支付金额 */
+    @Excel(name = "支付金额")
+    private BigDecimal payMoney;
+
     /** 详细地址 */
     @Excel(name = "收货地址")
     private String userAddress;
@@ -165,9 +169,7 @@ public class LiveOrderVoZm{
 //    @Excel(name = "实际支付金额")
     private BigDecimal payPrice;
 
-    /** 支付金额 */
-//    @Excel(name = "支付金额")
-    private BigDecimal payMoney;
+
 
     /** 支付状态 待支付 1已支付 */
 //    @Excel(name = "支付状态 待支付 1已支付")
@@ -189,7 +191,7 @@ public class LiveOrderVoZm{
     private String payType;
 
     /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:已取消 1:待支付 2:待发货;3:待收货;4:待评价;5:已完成) */
-    @Excel(name = "订单状态",dictType="sys_order_status")
+    @Excel(name = "订单状态",dictType="sys_live_order_status")
     private Integer status;
 
     /** 对应供应商 */

+ 10 - 11
fs-service/src/main/java/com/fs/wx/order/service/impl/LiveExpressToWxService.java

@@ -1,10 +1,12 @@
 package com.fs.wx.order.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.domain.FsStorePayment;
+import com.fs.his.domain.FsStoreProduct;
 import com.fs.his.mapper.FsStoreOrderMapper;
 import com.fs.his.mapper.FsStorePaymentMapper;
 import com.fs.live.domain.LiveOrder;
@@ -40,8 +42,8 @@ public class LiveExpressToWxService extends ExpressToWxService {
         if(ObjectUtil.isNull(liveOrder)) {
             throw new IllegalArgumentException(String.format("该订单 %s 未找到!",getOrderCode()));
         }
-        LiveOrderPayment fsStorePayments = liveOrderPaymentMapper.selectLiveOrderLatestPayByOrderId(liveOrder.getOrderId());
-        if(fsStorePayments == null){
+        this.liveOrderPayment = liveOrderPaymentMapper.selectLiveOrderLatestPayByOrderId(liveOrder.getOrderId());
+        if(ObjectUtil.isNull(liveOrderPayment)){
             throw new IllegalArgumentException(String.format("该订单 %s 未找到对应支付记录!", getOrderCode()));
         }
     }
@@ -92,15 +94,12 @@ public class LiveExpressToWxService extends ExpressToWxService {
 //            JSONObject jsonObject = JSON.parseObject(packageJson);
 //            title = new StringBuilder(jsonObject.getString("title"));
 //        } else {
-            String itemJson = order.getItemJson();
-            com.alibaba.fastjson.JSONArray arrays = JSON.parseArray(itemJson);
-            for(int i=0;i<arrays.size();i++){
-                JSONObject jsonObject = arrays.getJSONObject(i);
-                String jsonInfo = jsonObject.getString("jsonInfo");
-                JSONObject jsonObject1 = JSON.parseObject(jsonInfo);
-                String productName = jsonObject1.getString("productName");
-                title.append(productName).append("\n");
-            }
+
+            FsStoreProduct product = JSONUtil.toBean(order.getItemJson(), FsStoreProduct.class);
+
+            String productName = product.getProductName();
+            title.append(productName).append("\n");
+
 //        }
         return title.toString();
     }

+ 19 - 0
fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml

@@ -43,6 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isNeedRegisterMember"    column="is_need_register_member"    />
         <result property="isAllowedAllRegister"    column="is_allowed_all_register"    />
         <result property="doctorId"    column="doctor_id"    />
+        <result property="bindCompanyUserId"    column="bind_company_user_id"    />
         <association property="dept"    column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
         <collection  property="roles"   javaType="java.util.List"        resultMap="RoleResult" />
     </resultMap>
@@ -712,4 +713,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </select>
 
+    <!-- 批量更新公司用户的绑定销售ID -->
+    <update id="batchUpdateBindCompanyUserId">
+        update fs_user
+        set bind_company_user_id = #{bindCompanyUserId}
+        where user_id in
+        <foreach collection="userIds" item="userId" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+    </update>
+
+    <!-- 根据销售ID查询绑定的fs_user用户列表 -->
+    <select id="selectBoundFsUsersByCompanyUserId" resultType="com.fs.hisStore.domain.FsUserScrm">
+        SELECT *
+        FROM fs_user
+        WHERE bind_company_user_id = #{companyUserId}
+        AND is_del = 0
+    </select>
+
 </mapper>

+ 6 - 0
fs-service/src/main/resources/mapper/hisStore/FsUserScrmMapper.xml

@@ -2024,4 +2024,10 @@
         </if>
     </select>
 
+    <!-- 根据手机号码精确查询用户列表(完全匹配) -->
+    <select id="selectFsUserListByPhoneExact" parameterType="String" resultMap="FsUserResult">
+        <include refid="selectFsUserVo"/>
+        where phone = #{phone}
+    </select>
+
 </mapper>

+ 4 - 0
fs-service/src/main/resources/mapper/live/LiveMsgMapper.xml

@@ -65,6 +65,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
+            <if test="liveFlag != null">live_flag,</if>
+            <if test="replayFlag != null">replay_flag,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -76,6 +78,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
+            <if test="liveFlag != null">#{liveFlag},</if>
+            <if test="replayFlag != null">#{replayFlag},</if>
          </trim>
     </insert>
 

+ 5 - 4
fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -949,6 +949,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             o.is_pay,
             o.pay_time,
             o.pay_type,
+            o.pay_money,
             o.create_time,
             o.update_time,
             o.status,
@@ -1055,16 +1056,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userAddress != null and userAddress != ''">
                 AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
             </if>
-            <if test="createTimeStart != null and createTimeStart != ''">
+            <if test="createTimeStart != null ">
                 AND o.create_time &gt;= #{createTimeStart}
             </if>
-            <if test="createTimeEnd != null and createTimeEnd != ''">
+            <if test="createTimeEnd != null ">
                 AND o.create_time &lt;= #{createTimeEnd}
             </if>
-            <if test="payStartTime != null and payStartTime != ''">
+            <if test="payStartTime != null ">
                 AND o.pay_time &gt;= #{payStartTime}
             </if>
-            <if test="payEndTime != null and payEndTime != ''">
+            <if test="payEndTime != null ">
                 AND o.pay_time &lt;= #{payEndTime}
             </if>
             <if test="userPhone != null and userPhone != ''">