Bladeren bron

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_his_scrm_java

caoliqin 2 weken geleden
bovenliggende
commit
8474b4c402
31 gewijzigde bestanden met toevoegingen van 1408 en 149 verwijderingen
  1. 1 1
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  2. 37 2
      fs-admin/src/main/java/com/fs/live/controller/OrderController.java
  3. 2 2
      fs-company/src/main/java/com/fs/company/controller/company/CompanyUserController.java
  4. 46 8
      fs-company/src/main/java/com/fs/company/controller/live/OrderController.java
  5. 1 1
      fs-service/src/main/java/com/fs/company/vo/CompanyMoneyLogsExport1VO.java
  6. 8 1
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java
  7. 7 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java
  8. 40 0
      fs-service/src/main/java/com/fs/hisStore/mapper/MergedOrderMapper.java
  9. 8 0
      fs-service/src/main/java/com/fs/hisStore/service/IMergedOrderService.java
  10. 36 1
      fs-service/src/main/java/com/fs/hisStore/service/impl/MergedOrderServiceImpl.java
  11. 3 1
      fs-service/src/main/java/com/fs/live/domain/LiveCouponUser.java
  12. 7 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  13. 7 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderPaymentMapper.java
  14. 8 0
      fs-service/src/main/java/com/fs/live/mapper/LiveWatchLogMapper.java
  15. 3 0
      fs-service/src/main/java/com/fs/live/param/MergedOrderQueryParam.java
  16. 123 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java
  17. 5 0
      fs-service/src/main/java/com/fs/live/vo/HandleUserTagVO.java
  18. 61 0
      fs-service/src/main/java/com/fs/live/vo/PaymentExportVO.java
  19. 41 0
      fs-service/src/main/java/com/fs/live/vo/PaymentImportVO.java
  20. 1 0
      fs-service/src/main/java/com/fs/qw/mapper/QwUserMapper.java
  21. 5 0
      fs-service/src/main/resources/application-config-fzbt.yml
  22. 8 0
      fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml
  23. 8 0
      fs-service/src/main/resources/mapper/hisStore/FsStorePaymentScrmMapper.xml
  24. 2 1
      fs-service/src/main/resources/mapper/hisStore/FsStoreProductPackageScrmMapper.xml
  25. 909 127
      fs-service/src/main/resources/mapper/hisStore/MergedOrderMapper.xml
  26. 2 2
      fs-service/src/main/resources/mapper/live/LiveAfterSalesMapper.xml
  27. 7 1
      fs-service/src/main/resources/mapper/live/LiveCouponUserMapper.xml
  28. 8 0
      fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml
  29. 8 0
      fs-service/src/main/resources/mapper/live/LiveOrderPaymentMapper.xml
  30. 4 0
      fs-service/src/main/resources/mapper/live/LiveWatchLogMapper.xml
  31. 2 1
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

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

@@ -693,7 +693,7 @@ public class FsStoreOrderScrmController extends BaseController {
         ExpressInfoDTO expressInfoDTO = null;
         if (StringUtils.isNotEmpty(order.getDeliveryId())) {
             String lastFourNumber = "";
-            if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue())) {
+            if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue()) || order.getDeliverySn().equals(ShipperCodeEnum.ZTO.getValue())) {
                 lastFourNumber = order.getUserPhone();
                 if (lastFourNumber.length() == 11) {
                     lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);

+ 37 - 2
fs-admin/src/main/java/com/fs/live/controller/OrderController.java

@@ -7,10 +7,13 @@ import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.model.LoginUser;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.core.page.PageDomain;
+import com.fs.common.core.page.TableSupport;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.common.constant.HttpStatus;
 import com.fs.framework.web.service.TokenService;
 import com.fs.his.utils.PhoneUtil;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
@@ -64,7 +67,33 @@ public class OrderController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(MergedOrderQueryParam param)
     {
-        startPage();
+        // 从请求参数中获取分页信息
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+        
+        // 设置分页参数到 param
+        if (pageNum == null || pageNum < 1) {
+            pageNum = 1;
+            param.setPageNum(1);
+        } else {
+            param.setPageNum(pageNum);
+        }
+        if (pageSize == null || pageSize < 1) {
+            pageSize = 10;
+            param.setPageSize(10);
+        } else {
+            param.setPageSize(pageSize);
+        }
+        
+        // 在外面计算 offset,然后放在请求参数中
+        Integer offset = (pageNum - 1) * pageSize;
+        param.setOffset(offset);
+        
+        // 先查询总数(不分页)
+        long total = mergedOrderService.countMergedOrderList(param);
+        
+        // 查询分页数据
         List<MergedOrderVO> list = mergedOrderService.selectMergedOrderList(param);
         for (MergedOrderVO vo : list) {
             vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
@@ -73,7 +102,13 @@ public class OrderController extends BaseController
             vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
             vo.setCost(BigDecimal.ZERO);
         }
-        return getDataTable(list);
+        
+        TableDataInfo dataTable = new TableDataInfo();
+        dataTable.setCode(HttpStatus.SUCCESS);
+        dataTable.setMsg("查询成功");
+        dataTable.setRows(list);
+        dataTable.setTotal(total);
+        return dataTable;
     }
 
     /**

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

@@ -135,6 +135,7 @@ public class CompanyUserController extends BaseController {
     /**
      * 获取用户列表
      */
+    @PreAuthorize("@ss.hasPermi('company:user:deptList')")
     @GetMapping("/deptList")
     public TableDataInfo deptList(CompanyUser user)
     {
@@ -160,7 +161,6 @@ public class CompanyUserController extends BaseController {
         return getDataTable(list);
     }
 
-
     @GetMapping("/getUserList")
     public R getUserList()
     {
@@ -451,7 +451,7 @@ public class CompanyUserController extends BaseController {
     /**
      * 重置密码
      */
-    @PreAuthorize("@ss.hasPermi('company:user:edit')")
+    @PreAuthorize("@ss.hasPermi('company:user:resetPwd')")
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
     @PutMapping("/resetPwd")
     public AjaxResult resetPwd(@RequestBody CompanyUser user)

+ 46 - 8
fs-company/src/main/java/com/fs/company/controller/live/OrderController.java

@@ -3,10 +3,13 @@ package com.fs.company.controller.live;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
+import com.fs.common.constant.HttpStatus;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.model.LoginUser;
+import com.fs.common.core.page.PageDomain;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.core.page.TableSupport;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.ServletUtils;
@@ -63,15 +66,44 @@ public class OrderController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(MergedOrderQueryParam param)
     {
-/*        if(param.getOrderTypeFilter() == null || param.getOrderTypeFilter().equals("2")){
-            return getDataTable(new ArrayList<>());
-        }*/
+        // 从请求参数中获取分页信息
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+
+        // 设置分页参数到 param
+        if (pageNum == null || pageNum < 1) {
+            pageNum = 1;
+            param.setPageNum(1);
+        } else {
+            param.setPageNum(pageNum);
+        }
+        if (pageSize == null || pageSize < 1) {
+            pageSize = 10;
+            param.setPageSize(10);
+        } else {
+            param.setPageSize(pageSize);
+        }
+        
+        // 在外面计算 offset,然后放在请求参数中
+        Integer offset = (pageNum - 1) * pageSize;
+        param.setOffset(offset);
+        
+        // 设置公司ID和用户ID
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         param.setCompanyId(user.getCompanyId());
-       if (user.getUserType().equals("01")){
-           param.setUserId(user.getUserId());
-       }
-        startPage();
+        if (user.getUserType().equals("01")){
+            param.setUserId(user.getUserId());
+        }
+        
+        // 如果 OrderTypeFilter 为空,只查询销售和直播订单,不查询商城订单
+        // 通过设置一个特殊值来实现,或者修改查询逻辑
+        // 这里我们通过修改查询逻辑来实现:如果 orderTypeFilter 为 null,在 SQL 中排除商城订单
+        
+        // 先查询总数(不分页)
+        long total = mergedOrderService.countMergedOrderList(param);
+        
+        // 查询分页数据
         List<MergedOrderVO> list = mergedOrderService.selectMergedOrderList(param);
         for (MergedOrderVO vo : list) {
             vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
@@ -80,7 +112,13 @@ public class OrderController extends BaseController
             vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
             vo.setCost(BigDecimal.ZERO);
         }
-        return getDataTable(list);
+
+        TableDataInfo dataTable = new TableDataInfo();
+        dataTable.setCode(HttpStatus.SUCCESS);
+        dataTable.setMsg("查询成功");
+        dataTable.setRows(list);
+        dataTable.setTotal(total);
+        return dataTable;
     }
 
     /**

+ 1 - 1
fs-service/src/main/java/com/fs/company/vo/CompanyMoneyLogsExport1VO.java

@@ -71,7 +71,7 @@ public class CompanyMoneyLogsExport1VO implements Serializable
     @Excel(name = "物流代收")
     private BigDecimal payDelivery;
 
-    @Excel(name = "订单状态",dictType = "sys_order_status")
+    @Excel(name = "订单状态", readConverterExp = "-1=申请退款,-2=退款成功,-3=已取消,0=待支付,1=待发货,2=待收货,3=已完成,4=待评价")
     private String status;
 
     @Excel(name = "快递单号")

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

@@ -39,6 +39,13 @@ public interface FsStoreOrderScrmMapper
      */
     public FsStoreOrderScrm selectFsStoreOrderById(Long id);
 
+    /**
+     * 根据订单ID列表批量查询订单
+     * @param orderIds 订单ID列表
+     * @return 订单列表
+     */
+    List<FsStoreOrderScrm> selectFsStoreOrderByIds(@Param("orderIds") List<Long> orderIds);
+
     /**
      * 查询订单列表
      *
@@ -992,7 +999,7 @@ public interface FsStoreOrderScrmMapper
     @Select("select id from fs_store_order_scrm where status = 2  and DATE(pay_time)>='2023-11-1' and DATE(create_time)<='2024-2-7' and company_id is null ")
     List<Long> selectSyncExpressIds();
 
-    @Select("select id from fs_store_order_scrm where status = 2  and DATE(pay_time)>='2023-11-1' and company_id is null ")
+    @Select("select id from fs_store_order_scrm where status = 2  and DATE(pay_time)>='2025-11-1' ")
     List<Long> selectSyncExpressIdsNoDate();
 
 

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

@@ -391,4 +391,11 @@ public interface FsStorePaymentScrmMapper
 
     @Select("select * from fs_store_payment_scrm where order_id=#{orderId} and status=0   ")
     List<FsStorePaymentScrm> selectNoPayByOrderId(Long orderId);
+
+    /**
+     * 根据交易单号列表批量查询支付记录
+     * @param bankTransactionIds 交易单号列表
+     * @return 支付记录列表
+     */
+    List<FsStorePaymentScrm> selectByBankTransactionIds(@Param("bankTransactionIds") List<String> bankTransactionIds);
 }

+ 40 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/MergedOrderMapper.java

@@ -27,6 +27,46 @@ public interface MergedOrderMapper
      */
     List<MergedOrderVO> selectMergedOrderList(@Param("maps") MergedOrderQueryParam param);
 
+    /**
+     * 查询销售订单列表(只查询销售订单,order_type = 1)
+     *
+     * @param param 查询参数
+     * @return 销售订单列表
+     */
+    List<MergedOrderVO> selectSalesOrderList(@Param("maps") MergedOrderQueryParam param);
+
+    /**
+     * 查询商城订单列表(只查询商城订单,order_type = 2)
+     *
+     * @param param 查询参数
+     * @return 商城订单列表
+     */
+    List<MergedOrderVO> selectStoreOrderList(@Param("maps") MergedOrderQueryParam param);
+
+    /**
+     * 查询直播订单列表(只查询直播订单,order_type = 3)
+     *
+     * @param param 查询参数
+     * @return 直播订单列表
+     */
+    List<MergedOrderVO> selectLiveOrderList(@Param("maps") MergedOrderQueryParam param);
+
+    /**
+     * 从视图查询合并订单列表(全部订单,使用视图优化)
+     *
+     * @param param 查询参数
+     * @return 合并后的订单列表
+     */
+    List<MergedOrderVO> selectMergedOrderListFromView(@Param("maps") MergedOrderQueryParam param);
+
+    /**
+     * 统计合并订单总数
+     *
+     * @param param 查询参数
+     * @return 订单总数
+     */
+    long countMergedOrderList(@Param("maps") MergedOrderQueryParam param);
+    
     /**
      * 查询合并的售后列表(商城售后+直播售后)
      *

+ 8 - 0
fs-service/src/main/java/com/fs/hisStore/service/IMergedOrderService.java

@@ -27,6 +27,14 @@ public interface IMergedOrderService
     List<FsMergedOrderListQueryVO> selectMergedOrderListVO(FsMyStoreOrderQueryParam param);
 
     List<MergedOrderVO> selectMergedOrderList(MergedOrderQueryParam param);
+    
+    /**
+     * 统计合并订单总数
+     *
+     * @param param 查询参数
+     * @return 订单总数
+     */
+    long countMergedOrderList(MergedOrderQueryParam param);
 
     /**
      * 查询合并的售后列表(商城售后+直播售后)

+ 36 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/MergedOrderServiceImpl.java

@@ -49,11 +49,37 @@ public class MergedOrderServiceImpl implements IMergedOrderService
 
     /*
      * 后端合并
+     * 根据订单类型筛选,选择不同的查询方式:
+     * - orderTypeFilter = 1: 只查询销售订单
+     * - orderTypeFilter = 2: 只查询商城订单
+     * - orderTypeFilter = 3: 只查询直播订单
+     * - orderTypeFilter = null: 使用视图查询全部订单
      * */
     @Override
     public List<MergedOrderVO> selectMergedOrderList(MergedOrderQueryParam param)
     {
-        List<MergedOrderVO> list = mergedOrderMapper.selectMergedOrderList(param);
+        List<MergedOrderVO> list;
+
+        // 根据订单类型筛选选择不同的查询方式
+        if (param.getOrderTypeFilter() != null) {
+            // 选择单个订单类型,只查询对应的表
+            if (param.getOrderTypeFilter() == 1) {
+                // 销售订单
+                list = mergedOrderMapper.selectSalesOrderList(param);
+            } else if (param.getOrderTypeFilter() == 2) {
+                // 商城订单
+                list = mergedOrderMapper.selectStoreOrderList(param);
+            } else if (param.getOrderTypeFilter() == 3) {
+                // 直播订单
+                list = mergedOrderMapper.selectLiveOrderList(param);
+            } else {
+                // 未知类型,使用视图查询
+                list = mergedOrderMapper.selectMergedOrderList(param);
+            }
+        } else {
+            // 全部订单,使用视图查询优化性能
+            list = mergedOrderMapper.selectMergedOrderList(param);
+        }
 
         // 处理商品JSON
         for (MergedOrderVO vo : list)
@@ -77,6 +103,15 @@ public class MergedOrderServiceImpl implements IMergedOrderService
 
         return list;
     }
+    
+    /**
+     * 统计合并订单总数
+     */
+    @Override
+    public long countMergedOrderList(MergedOrderQueryParam param)
+    {
+        return mergedOrderMapper.countMergedOrderList(param);
+    }
 
 
     @Autowired

+ 3 - 1
fs-service/src/main/java/com/fs/live/domain/LiveCouponUser.java

@@ -73,5 +73,7 @@ public class LiveCouponUser extends BaseEntity
     @Excel(name = "商品ID")
     private Long goodsId;
 
-
+    //非数据库实体 只是返回
+    private String nickname;
+    private String phone;
 }

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

@@ -159,6 +159,13 @@ public interface LiveOrderMapper {
     String selectLiveOrderProductStatistics(@Param("maps")LiveOrderParam param);
 
     List<LiveOrder> selectLiveOrderInId(@Param("ids") Long[] ids);
+
+    /**
+     * 根据订单ID列表批量查询订单
+     * @param orderIds 订单ID列表
+     * @return 订单列表
+     */
+    List<LiveOrder> selectLiveOrderByOrderIds(@Param("orderIds") List<Long> orderIds);
     @Select({"<script> " +
             "select o.*,cts.name as scheduleName,u.nickname,u.phone,cc.push_code,cc.create_time as customer_create_time," +
             "cc.source,cc.customer_code, c.company_name ,cu.nick_name as company_user_nick_name ," +

+ 7 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderPaymentMapper.java

@@ -82,4 +82,11 @@ public interface LiveOrderPaymentMapper {
 
     @Select("select * from live_order_payment where business_id= #{orderId} and status=1 order by create_time desc limit 1")
     LiveOrderPayment selectLiveOrderLatestPayByOrderId(@Param("orderId") Long orderId);
+
+    /**
+     * 根据交易单号列表批量查询支付记录
+     * @param bankTransactionIds 交易单号列表
+     * @return 支付记录列表
+     */
+    List<LiveOrderPayment> selectByBankTransactionIds(@Param("bankTransactionIds") List<String> bankTransactionIds);
 }

+ 8 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveWatchLogMapper.java

@@ -72,6 +72,14 @@ public interface LiveWatchLogMapper extends BaseMapper<LiveWatchLog> {
 
     List<LiveWatchLog> selectLiveWatchLogByLiveId(@Param("liveId")Long liveId);
 
+    /**
+     * 根据直播间ID和外部联系人ID查询看课记录
+     * @param liveId 直播间ID
+     * @param externalContactId 外部联系人ID
+     * @return 看课记录
+     */
+    LiveWatchLog selectLiveWatchLogByLiveIdAndExternalId(@Param("liveId")Long liveId, @Param("externalContactId")Long externalContactId);
+
     List<LiveWatchLogListVO> selectLiveWatchLogListInfo(LiveWatchLog liveWatchLog);
 
     /**

+ 3 - 0
fs-service/src/main/java/com/fs/live/param/MergedOrderQueryParam.java

@@ -120,5 +120,8 @@ public class MergedOrderQueryParam extends BaseQueryParam implements Serializabl
     private String erpPhoneNumber;
     /** 汇付商户订单号 */
     private String hfshh;
+    
+    /** 分页偏移量(在外部计算后传入,不在SQL中计算) */
+    private Integer offset;
 }
 

+ 123 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java

@@ -30,6 +30,8 @@ import com.fs.live.vo.*;
 import com.fs.qw.domain.QwExternalContact;
 import com.fs.qwApi.domain.QwResult;
 import com.fs.qwApi.param.QwEditUserTagParam;
+import com.fs.qwApi.param.QwExternalContactRemarkParam;
+import com.fs.qwApi.domain.QwExternalContactRemarkResult;
 import com.fs.qwApi.service.QwApiService;
 import com.fs.qw.domain.QwGroupChat;
 import com.fs.qw.domain.QwGroupChatUser;
@@ -46,9 +48,12 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -934,6 +939,8 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
                     if (null != liveTagItemVO) {
                         tags.add(liveTagItemVO.getQwTagRealId());
                     }
+                    // 设置完课标志
+                    addItem.setIsCompleted(true);
                     break;
                 //3待看课
                 case 3:
@@ -1053,6 +1060,10 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
                     updateContact.setTagIds(JSON.toJSONString(new ArrayList<>(uniqueTagIds)));
                     qwExternalContactMapper.updateQwExternalContact(updateContact);
 
+                    // 处理完课备注更新逻辑
+                    Boolean isCompleted = userTagVO.getIsCompleted() != null && userTagVO.getIsCompleted();
+                    updateRemarkForCompletedCourse(userTagVO.getLiveId(), userTagVO.getExternalId(), qwExternalContact, isCompleted);
+
                     successCount++;
                     log.info("成功为用户打标签: externalId={}, userId={}, externalUserId={}, tags={}",
                             userTagVO.getExternalId(),
@@ -1080,6 +1091,118 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
                 userTagVOS.size(), successCount, failCount);
     }
 
+    /**
+     * 更新完课备注
+     * 如果用户完课,在备注中添加或更新完课日期
+     * 格式:MMdd完课-原有备注
+     * 
+     * @param liveId 直播间ID
+     * @param externalId 外部联系人ID
+     * @param qwExternalContact 企微外部联系人信息
+     * @param isCompleted 完课标志(如果为true,不再查询数据库)
+     */
+    private void updateRemarkForCompletedCourse(Long liveId, Long externalId, QwExternalContact qwExternalContact, Boolean isCompleted) {
+        try {
+            // 如果liveId为空,跳过
+            if (liveId == null || externalId == null) {
+                return;
+            }
+
+            //
+            boolean completed = false;
+            if (isCompleted != null) {
+                // 使用传入的完课标志
+                completed = isCompleted;
+            }
+            
+            if (!completed) {
+                // 未完课,不改动备注
+                log.debug("用户未完课,不更新备注: liveId={}, externalId={}", 
+                        liveId, externalId);
+                return;
+            }
+
+            // 完课,需要更新备注
+            String currentRemark = qwExternalContact.getRemark();
+            String newRemark = buildCompletedCourseRemark(currentRemark);
+            
+            // 如果备注没有变化,跳过更新
+            if (newRemark.equals(currentRemark)) {
+                log.debug("备注无需更新: liveId={}, externalId={}, remark={}", 
+                        liveId, externalId, currentRemark);
+                return;
+            }
+
+            // 调用企微API更新备注
+            QwExternalContactRemarkParam remarkParam = new QwExternalContactRemarkParam();
+            remarkParam.setUserid(qwExternalContact.getUserId());
+            remarkParam.setExternal_userid(qwExternalContact.getExternalUserId());
+            remarkParam.setRemark(newRemark);
+
+            QwExternalContactRemarkResult remarkResult = qwApiService.externalcontactRemark(remarkParam, qwExternalContact.getCorpId());
+            
+            if (remarkResult != null && remarkResult.getErrcode() == 0) {
+                // 更新成功,同步更新数据库
+                QwExternalContact updateContact = new QwExternalContact();
+                updateContact.setId(qwExternalContact.getId());
+                updateContact.setRemark(newRemark);
+                qwExternalContactMapper.updateQwExternalContact(updateContact);
+                
+                log.info("成功更新完课备注: liveId={}, externalId={}, oldRemark={}, newRemark={}",
+                        liveId, externalId, currentRemark, newRemark);
+            } else {
+                String errorMsg = remarkResult != null ? remarkResult.getErrmsg() : "未知错误";
+                log.error("更新完课备注失败: liveId={}, externalId={}, error={}",
+                        liveId, externalId, errorMsg);
+            }
+        } catch (Exception e) {
+            log.error("更新完课备注异常: liveId={}, externalId={}, error={}",
+                    liveId, externalId, e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 构建完课备注
+     * 格式:MMdd完课-原有备注
+     * 如果已有完课标记,则更新日期部分
+     * 
+     * @param currentRemark 当前备注
+     * @return 新的备注
+     */
+    private String buildCompletedCourseRemark(String currentRemark) {
+        // 获取当前日期(MMdd格式)
+        SimpleDateFormat dateFormat = new SimpleDateFormat("MMdd");
+        String todayDate = dateFormat.format(new Date());
+        String completedPrefix = todayDate + "完课";
+
+        // 如果备注为空,直接返回完课标记
+        if (StringUtils.isEmpty(currentRemark)) {
+            return completedPrefix;
+        }
+
+        // 使用正则表达式匹配已有的完课标记格式:MMdd完课-xxx
+        // 匹配模式:4位数字(MMdd)+ "完课" + "-" + 后续内容
+        Pattern pattern = Pattern.compile("^(\\d{4})完课-(.+)$");
+        Matcher matcher = pattern.matcher(currentRemark);
+
+        if (matcher.matches()) {
+            // 已有完课标记,更新日期部分
+            String existingDate = matcher.group(1);
+            String remainingRemark = matcher.group(2);
+            
+            // 如果日期相同,不需要更新
+            if (todayDate.equals(existingDate)) {
+                return currentRemark;
+            }
+            
+            // 更新日期
+            return completedPrefix + "-" + remainingRemark;
+        } else {
+            // 没有完课标记,添加完课标记到前面
+            return completedPrefix + "-" + currentRemark;
+        }
+    }
+
     /**
      * 更新用户观看时长(心跳时调用)- 异步执行
      * @param liveId 直播间ID

+ 5 - 0
fs-service/src/main/java/com/fs/live/vo/HandleUserTagVO.java

@@ -26,4 +26,9 @@ public class HandleUserTagVO {
      * 打标签列表
      */
     private List<String> tags;
+
+    /**
+     * 是否完课标志(logType == 2 表示完课)
+     */
+    private Boolean isCompleted;
 }

+ 61 - 0
fs-service/src/main/java/com/fs/live/vo/PaymentExportVO.java

@@ -0,0 +1,61 @@
+package com.fs.live.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 支付导出VO
+ *
+ * @author fs
+ * @date 2026-01-08
+ */
+@Data
+public class PaymentExportVO {
+
+    /** 支付时间 */
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
+
+    /** 交易单号 */
+    @Excel(name = "交易单号")
+    private String bankTransactionId;
+
+    /** 商户单号 */
+    @Excel(name = "商户单号")
+    private String tradeNo;
+
+    /** 商户号 */
+    @Excel(name = "商户号")
+    private String merchantNo;
+
+    /** 支付金额 */
+    @Excel(name = "支付金额")
+    private BigDecimal payMoney;
+
+    /** 状态 */
+    @Excel(name = "状态")
+    private String status;
+
+    /** 订单状态 */
+    @Excel(name = "订单状态")
+    private String orderStatus;
+
+    /** 物流单号 */
+    @Excel(name = "物流单号")
+    private String deliverySn;
+
+    /** 物流公司 */
+    @Excel(name = "物流公司")
+    private String deliveryName;
+
+    /** 商品名称 */
+    @Excel(name = "商品名称")
+    private String productName;
+
+    /** 支付订单号(带前缀) */
+    @Excel(name = "支付订单号")
+    private String payCodeWithPrefix;
+}

+ 41 - 0
fs-service/src/main/java/com/fs/live/vo/PaymentImportVO.java

@@ -0,0 +1,41 @@
+package com.fs.live.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 支付导入VO
+ *
+ * @author fs
+ * @date 2026-01-08
+ */
+@Data
+public class PaymentImportVO {
+
+    /** 支付时间 */
+    @Excel(name = "支付时间")
+    private Date payTime;
+
+    /** 交易单号 */
+    @Excel(name = "交易单号", required = true)
+    private String bankTransactionId;
+
+    /** 商户单号 */
+    @Excel(name = "商户单号")
+    private String tradeNo;
+
+    /** 商户号 */
+    @Excel(name = "商户号")
+    private String merchantNo;
+
+    /** 支付金额 */
+    @Excel(name = "支付金额")
+    private BigDecimal payMoney;
+
+    /** 状态 */
+    @Excel(name = "状态")
+    private String status;
+}

+ 1 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwUserMapper.java

@@ -151,6 +151,7 @@ public interface QwUserMapper extends BaseMapper<QwUser>
             "RIGHT JOIN qw_dept qd on qu.department=qd.dept_id and qd.corp_id=qu.corp_id " +
             "left join fastgpt_role fr on fr.role_id=qu.fastGpt_role_id " +
             "where qu.company_user_id is not null "+
+            "            <if test=\"id != null  and id != ''\"> and qu.id = #{id}</if>\n" +
             "            <if test=\"qwUserId != null  and qwUserId != ''\"> and qu.qw_user_id = #{qwUserId}</if>\n" +
             "            <if test=\"loginStatus != null \"> and qu.ipad_status = #{loginStatus}</if>\n" +
             "            <if test=\"appKey != null  and appKey != ''\"> and qu.app_key = #{appKey}</if>\n" +

+ 5 - 0
fs-service/src/main/resources/application-config-fzbt.yml

@@ -10,6 +10,11 @@ logging:
 wx:
   miniapp:
     configs:
+      - appid: wx4115995705bb0ea0   #中康智慧
+        secret: 58910ae743005c396012b029c7def579
+        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+        msgDataFormat: JSON
   cp:
     corpId: wwb2a1055fb6c9a7c2
     appConfigs:

+ 8 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -160,6 +160,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <select id="selectFsStoreOrderByIds" resultMap="FsStoreOrderResult">
+        <include refid="selectFsStoreOrderVo"/>
+        where id IN
+        <foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
+            #{orderId}
+        </foreach>
+    </select>
+
     <insert id="insertFsStoreOrder" parameterType="FsStoreOrderScrm" useGeneratedKeys="true" keyProperty="id">
         insert into fs_store_order_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 8 - 0
fs-service/src/main/resources/mapper/hisStore/FsStorePaymentScrmMapper.xml

@@ -234,4 +234,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{bankTransactionId}
         </foreach>
     </update>
+
+    <select id="selectByBankTransactionIds" resultMap="FsStorePaymentResult">
+        <include refid="selectFsStorePaymentVo"/>
+        where bank_transaction_id in
+        <foreach item="bankTransactionId" collection="bankTransactionIds" open="(" separator="," close=")">
+            #{bankTransactionId}
+        </foreach>
+    </select>
 </mapper>

+ 2 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreProductPackageScrmMapper.xml

@@ -136,8 +136,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                                             </if>
                                              <if test="companyId !=null">
                                                  company_id = #{companyId},
-                                                 products = null
+                                                 products = null,
                                              </if>
+                                                 store_id = null
                                          where package_id in
         <foreach item="packageId" collection="packageIds" open="(" separator="," close=")">
             #{packageId}

+ 909 - 127
fs-service/src/main/resources/mapper/hisStore/MergedOrderMapper.xml

@@ -64,87 +64,92 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       sp_latest.bank_transaction_id,
         CONCAT('store-',sp_latest.pay_code) as hfshh
       FROM
-      fs_store_order_scrm o
-      left join ( SELECT fsois.*, ROW_NUMBER() OVER ( PARTITION BY fsois.order_id ORDER BY fsois.item_id ) AS rn FROM fs_store_order_item_scrm fsois ) item_latest ON item_latest.order_id = o.id and item_latest.rn = 1
-      LEFT JOIN fs_user u ON o.user_id = u.user_id
-
-      LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = item_latest.product_id
-      LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
-      left join fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
-
-
-      LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
-        LEFT JOIN company c ON c.company_id = cu.company_id
-      LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_order_id ORDER BY sp.create_time DESC ) AS rn FROM fs_store_payment_scrm sp ) sp_latest ON sp_latest.business_order_id = o.id
-      AND sp_latest.rn = 1
-      LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
-          WHERE  o.company_id IS NOT NULL
+      (
+        SELECT * FROM fs_store_order_scrm 
+        WHERE company_id IS NOT NULL AND is_del = 0 AND is_sys_del = 0
           <if test="maps.status != null and maps.status != ''">
-            AND o.status = #{maps.status}
+            AND status = #{maps.status}
           </if>
         <if test="maps.userId != null and maps.userId != ''">
-            AND o.company_user_id = #{maps.userId}
-        </if>
-
-        <if test="maps.productId != null and maps.productId != ''">
-            AND fspc.product_id = #{maps.productId}
+            AND company_user_id = #{maps.userId}
         </if>
           <if test="maps.orderCode != null and maps.orderCode != ''">
-            AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+            AND order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
           </if>
           <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
-            AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+            AND FIND_IN_SET(order_code, #{maps.orderCodeList})
           </if>
           <if test="maps.deliveryId != null and maps.deliveryId != ''">
-            AND o.delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
-          </if>
-        <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
-            AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+            AND delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
         </if>
           <if test="maps.userPhone != null and maps.userPhone != ''">
-            AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+            AND user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
           </if>
         <if test="maps.userAddress != null and maps.userAddress != ''">
-            AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+            AND user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
         </if>
           <if test="maps.realName != null and maps.realName != ''">
-            AND o.real_name LIKE CONCAT('%', #{maps.realName}, '%')
-          </if>
-          <if test="maps.productName != null and maps.productName != ''">
-            AND fspc.product_name LIKE CONCAT('%', #{maps.productName}, '%')
+            AND real_name LIKE CONCAT('%', #{maps.realName}, '%')
           </if>
           <if test="maps.deliveryStatus != null">
-            AND o.delivery_status = #{maps.deliveryStatus}
+            AND delivery_status = #{maps.deliveryStatus}
           </if>
           <if test="maps.deliveryPayStatus != null">
-            AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+            AND delivery_pay_status = #{maps.deliveryPayStatus}
           </if>
           <if test="maps.payType != null and maps.payType != ''">
-            AND o.pay_type = #{maps.payType}
+            AND pay_type = #{maps.payType}
           </if>
           <if test="maps.companyId != null">
-            AND o.company_id = #{maps.companyId}
+            AND company_id = #{maps.companyId}
           </if>
           <if test="maps.deptId != null">
-            AND o.dept_id = #{maps.deptId}
-          </if>
-          <if test="maps.salesName != null and maps.salesName != ''">
-            AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
-          </if>
-          <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
-            AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+            AND dept_id = #{maps.deptId}
           </if>
           <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
-            AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+            AND create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
           </if>
           <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
-            AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+            AND pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
           </if>
           <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
-            AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+            AND DATE(delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
           </if>
           <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
-            AND DATE(o.delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+            AND DATE(delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+          </if>
+        ORDER BY create_time DESC
+        limit 1000
+      ) o
+      left join ( SELECT fsois.*, ROW_NUMBER() OVER ( PARTITION BY fsois.order_id ORDER BY fsois.item_id ) AS rn FROM fs_store_order_item_scrm fsois ) item_latest ON item_latest.order_id = o.id and item_latest.rn = 1
+      LEFT JOIN fs_user u ON o.user_id = u.user_id
+
+      LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = item_latest.product_id
+      LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
+      left join fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
+
+
+      LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
+        LEFT JOIN company c ON c.company_id = cu.company_id
+      LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_order_id ORDER BY sp.create_time DESC ) AS rn FROM fs_store_payment_scrm sp ) sp_latest ON sp_latest.business_order_id = o.id
+      AND sp_latest.rn = 1
+      LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+          WHERE 1=1
+        <!-- 需要 JOIN 后才能过滤的条件 -->
+        <if test="maps.productId != null and maps.productId != ''">
+            AND fspc.product_id = #{maps.productId}
+        </if>
+        <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
+            AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+        </if>
+          <if test="maps.productName != null and maps.productName != ''">
+            AND fspc.product_name LIKE CONCAT('%', #{maps.productName}, '%')
+        </if>
+          <if test="maps.salesName != null and maps.salesName != ''">
+            AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
+          </if>
+          <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
+            AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
           </if>
           <if test="maps.appId != null and maps.appId != ''">
             AND csc.appid = #{maps.appId}
@@ -154,7 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
           group by o.id
           UNION ALL
-          -- 商城订单(没有company_user_id的商城订单)
+
       SELECT
       o.id,
       '商城订单' AS order_type_name,
@@ -213,86 +218,92 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       sp_latest.bank_transaction_id,
         CONCAT('store-',sp_latest.pay_code) as hfshh
         FROM
-      fs_store_order_scrm o
-        left join ( SELECT fsois.*, ROW_NUMBER() OVER ( PARTITION BY fsois.order_id ORDER BY fsois.item_id ) AS rn FROM fs_store_order_item_scrm fsois ) item_latest ON item_latest.order_id = o.id and item_latest.rn = 1
-      LEFT JOIN fs_user u ON o.user_id = u.user_id
-
-        LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = item_latest.product_id
-        LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
-        left join fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
-
-
-      LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
-        LEFT JOIN company c ON c.company_id = cu.company_id
-      LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_order_id ORDER BY sp.create_time DESC ) AS rn FROM fs_store_payment_scrm sp ) sp_latest ON sp_latest.business_order_id = o.id
-      AND sp_latest.rn = 1
-      LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
-          WHERE  o.company_id is null
+      (
+        SELECT * FROM fs_store_order_scrm 
+        WHERE company_id IS NULL AND is_del = 0 AND is_sys_del = 0
           <if test="maps.status != null and maps.status != ''">
-            AND o.status = #{maps.status}
+            AND status = #{maps.status}
           </if>
         <if test="maps.userId != null and maps.userId != ''">
-            AND o.company_user_id = #{maps.userId}
-        </if>
-        <if test="maps.productId != null and maps.productId != ''">
-            AND fspc.product_id = #{maps.productId}
+            AND company_user_id = #{maps.userId}
         </if>
           <if test="maps.orderCode != null and maps.orderCode != ''">
-            AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+            AND order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
           </if>
           <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
-            AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+            AND FIND_IN_SET(order_code, #{maps.orderCodeList})
           </if>
           <if test="maps.deliveryId != null and maps.deliveryId != ''">
-            AND o.delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
-          </if>
-          <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
-            AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+            AND delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
           </if>
           <if test="maps.userPhone != null and maps.userPhone != ''">
-            AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+            AND user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
           </if>
         <if test="maps.userAddress != null and maps.userAddress != ''">
-            AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+            AND user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
         </if>
           <if test="maps.realName != null and maps.realName != ''">
-            AND o.real_name LIKE CONCAT('%', #{maps.realName}, '%')
-          </if>
-          <if test="maps.productName != null and maps.productName != ''">
-            AND o.item_json LIKE CONCAT('%', #{maps.productName}, '%')
+            AND real_name LIKE CONCAT('%', #{maps.realName}, '%')
           </if>
           <if test="maps.deliveryStatus != null">
-            AND o.delivery_status = #{maps.deliveryStatus}
+            AND delivery_status = #{maps.deliveryStatus}
           </if>
           <if test="maps.deliveryPayStatus != null">
-            AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+            AND delivery_pay_status = #{maps.deliveryPayStatus}
           </if>
           <if test="maps.payType != null and maps.payType != ''">
-            AND o.pay_type = #{maps.payType}
+            AND pay_type = #{maps.payType}
           </if>
           <if test="maps.companyId != null">
-            AND o.company_id = #{maps.companyId}
+            AND company_id = #{maps.companyId}
           </if>
           <if test="maps.deptId != null">
-            AND o.dept_id = #{maps.deptId}
-          </if>
-          <if test="maps.salesName != null and maps.salesName != ''">
-            AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
-          </if>
-          <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
-            AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+            AND dept_id = #{maps.deptId}
           </if>
           <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
-              AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+            AND create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
           </if>
         <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
-            AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+            AND pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
           </if>
           <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
-            AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+            AND DATE(delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
           </if>
           <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
-            AND DATE(o.delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+            AND DATE(delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+          </if>
+        ORDER BY create_time DESC
+      limit 1000
+      ) o
+        left join ( SELECT fsois.*, ROW_NUMBER() OVER ( PARTITION BY fsois.order_id ORDER BY fsois.item_id ) AS rn FROM fs_store_order_item_scrm fsois ) item_latest ON item_latest.order_id = o.id and item_latest.rn = 1
+      LEFT JOIN fs_user u ON o.user_id = u.user_id
+
+        LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = item_latest.product_id
+        LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
+        left join fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
+
+
+      LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
+        LEFT JOIN company c ON c.company_id = cu.company_id
+      LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_order_id ORDER BY sp.create_time DESC ) AS rn FROM fs_store_payment_scrm sp ) sp_latest ON sp_latest.business_order_id = o.id
+      AND sp_latest.rn = 1
+      LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+          WHERE 1=1
+        <!-- 需要 JOIN 后才能过滤的条件 -->
+        <if test="maps.productId != null and maps.productId != ''">
+            AND fspc.product_id = #{maps.productId}
+        </if>
+          <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
+            AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+          </if>
+          <if test="maps.productName != null and maps.productName != ''">
+            AND o.item_json LIKE CONCAT('%', #{maps.productName}, '%')
+        </if>
+          <if test="maps.salesName != null and maps.salesName != ''">
+            AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
+          </if>
+          <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
+            AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
           </if>
           <if test="maps.appId != null and maps.appId != ''">
             AND csc.appid = #{maps.appId}
@@ -361,7 +372,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       sp_latest.bank_transaction_id,
         CONCAT('live-',sp_latest.pay_code) as hfshh
       FROM
-      live_order o
+      (
+        SELECT * FROM live_order 
+        WHERE is_del = 0
+          <if test="maps.status != null and maps.status != ''">
+            AND status = #{maps.status}
+          </if>
+          <if test="maps.userId != null and maps.userId != ''">
+            AND company_user_id = #{maps.userId}
+          </if>
+          <if test="maps.orderCode != null and maps.orderCode != ''">
+            AND order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+          </if>
+          <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+            AND FIND_IN_SET(order_code, #{maps.orderCodeList})
+          </if>
+          <if test="maps.deliveryId != null and maps.deliveryId != ''">
+            AND delivery_sn LIKE CONCAT('%', #{maps.deliveryId}, '%')
+          </if>
+          <if test="maps.userPhone != null and maps.userPhone != ''">
+            AND user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+          </if>
+          <if test="maps.userAddress != null and maps.userAddress != ''">
+            AND user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+          </if>
+          <if test="maps.realName != null and maps.realName != ''">
+            AND user_name LIKE CONCAT('%', #{maps.realName}, '%')
+          </if>
+          <if test="maps.deliveryStatus != null">
+            AND delivery_status = #{maps.deliveryStatus}
+          </if>
+          <if test="maps.deliveryPayStatus != null">
+            AND delivery_pay_status = #{maps.deliveryPayStatus}
+          </if>
+          <if test="maps.payType != null and maps.payType != ''">
+            AND pay_type = #{maps.payType}
+          </if>
+          <if test="maps.companyId != null">
+            AND company_id = #{maps.companyId}
+          </if>
+          <if test="maps.deptId != null">
+            AND dept_id = #{maps.deptId}
+          </if>
+          <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+            AND create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+          </if>
+          <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+            AND pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+          </if>
+          <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+            AND DATE(delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+          </if>
+        ORDER BY create_time DESC
+      limit 1000
+      ) o
       left join live_order_item loi on loi.order_id = o.order_id
       LEFT JOIN fs_user u ON o.user_id = u.user_id
 
@@ -378,80 +442,509 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_id ORDER BY sp.create_time DESC ) AS rn FROM live_order_payment sp ) sp_latest ON sp_latest.business_id = o.order_id
       AND sp_latest.rn = 1
       LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
-          WHERE o.is_del = 0
+          WHERE 1=1
+        <!-- 需要 JOIN 后才能过滤的条件 -->
+        <if test="maps.productId != null and maps.productId != ''">
+            AND fspc.product_id = #{maps.productId}
+        </if>
+        <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
+            AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+        </if>
+          <if test="maps.productName != null and maps.productName != ''">
+            AND o.item_json LIKE CONCAT('%', #{maps.productName}, '%')
+          </if>
+          <if test="maps.salesName != null and maps.salesName != ''">
+            AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
+          </if>
+          <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
+            AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+          </if>
+          <if test="maps.appId != null and maps.appId != ''">
+            AND csc.appid = #{maps.appId}
+          </if>
+        <if test="maps.hfshh != null and maps.hfshh != ''">
+            AND CONCAT('live-',sp_latest.pay_code) = #{maps.hfshh}
+        </if>
+        group by o.order_id
+        ) AS merged_orders
+        WHERE 1=1
+        <if test="maps.orderTypeFilter != null">
+          AND order_type = #{maps.orderTypeFilter}
+        </if>
+        <if test="maps.orderTypeFilter == null">
+          <!-- 如果 OrderTypeFilter 为空,只查询销售和直播订单,不查询商城订单 -->
+          AND order_type != 2
+        </if>
+        ORDER BY create_time DESC
+        <if test="maps.pageSize != null and maps.pageSize > 0">
+          LIMIT #{maps.pageSize}
+          <if test="maps.offset != null and maps.offset >= 0">
+            OFFSET #{maps.offset}
+          </if>
+        </if>
+    </select>
+
+  <!-- 查询销售订单列表(只查询销售订单,order_type = 1) -->
+  <select id="selectSalesOrderList" parameterType="com.fs.live.param.MergedOrderQueryParam" resultType="com.fs.live.vo.MergedOrderVO">
+    SELECT
+    o.id,
+    '销售订单' AS order_type_name,
+    NULL AS order_id,
+    NULL AS live_id,
+    NULL AS after_sales_id,
+    o.order_code,
+    o.pay_price,
+    o.pay_money,
+    o.STATUS,
+    o.is_package,
+    o.package_json,
+    item_latest.json_info as item_json,
+    o.delivery_id,
+    o.delivery_sn as deliveryCode,
+    o.delivery_name as deliveryName,
+    o.finish_time,
+    o.create_time,
+    o.pay_time,
+    o.delivery_send_time,
+    o.total_num AS total_num,
+    o.deduction_price AS discount_money,
+    1 AS order_type,
+    cu.phonenumber as salesPhone,
+    cu.create_time as salesCreateTime,
+    o.user_id as userId,
+    u.order_count as userOrderCount,
+    u.total_amount as userTotalAmount,
+    u.level as userLevel,
+    fspc.product_id as productId,
+    fspc.product_name as productName,
+    fspc.prescribe_spec as productSpec,
+    COALESCE(fspc.cost, 0) as cost,
+    o.pay_postage as payDelivery,
+    o.coupon_price as discountMoney,
+    fss.store_id as storeId,
+    fss.store_name as storeName,
+    fspcs.cate_name as cateName,
+    GROUP_CONCAT(JSON_UNQUOTE(JSON_EXTRACT(item_latest.json_info, '$.barCode')) SEPARATOR ',') AS barCode,
+    c.company_name,
+    cu.user_name AS sales_name,
+    cu.nick_name AS company_user_nick_name,
+    ifnull(u.nickname,u.nick_name) as nickname,
+    u.phone,
+    o.real_name,
+    o.user_phone,
+    o.user_address,
+    o.pay_type,
+    o.delivery_status,
+    o.delivery_pay_status,
+    o.total_price,
+    csc.NAME AS mini_program_name,
+    sp_latest.bank_transaction_id,
+    CONCAT('store-',sp_latest.pay_code) as hfshh
+    FROM
+    (
+      SELECT * FROM fs_store_order_scrm 
+      WHERE company_id IS NOT NULL AND is_del = 0 AND is_sys_del = 0
           <if test="maps.status != null and maps.status != ''">
-            AND o.status = #{maps.status}
+        AND status = #{maps.status}
           </if>
         <if test="maps.userId != null and maps.userId != ''">
-            AND o.company_user_id = #{maps.userId}
-        </if>
-        <if test="maps.productId != null and maps.productId != ''">
-            AND fspc.product_id = #{maps.productId}
+        AND company_user_id = #{maps.userId}
         </if>
           <if test="maps.orderCode != null and maps.orderCode != ''">
-            AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+        AND order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
           </if>
           <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
-            AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+        AND FIND_IN_SET(order_code, #{maps.orderCodeList})
           </if>
           <if test="maps.deliveryId != null and maps.deliveryId != ''">
-            AND o.delivery_sn LIKE CONCAT('%', #{maps.deliveryId}, '%')
+        AND delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
+      </if>
+      <if test="maps.userPhone != null and maps.userPhone != ''">
+        AND user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+      </if>
+      <if test="maps.userAddress != null and maps.userAddress != ''">
+        AND user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+      </if>
+      <if test="maps.realName != null and maps.realName != ''">
+        AND real_name LIKE CONCAT('%', #{maps.realName}, '%')
+      </if>
+      <if test="maps.deliveryStatus != null">
+        AND delivery_status = #{maps.deliveryStatus}
+      </if>
+      <if test="maps.deliveryPayStatus != null">
+        AND delivery_pay_status = #{maps.deliveryPayStatus}
+      </if>
+      <if test="maps.payType != null and maps.payType != ''">
+        AND pay_type = #{maps.payType}
+      </if>
+      <if test="maps.companyId != null">
+        AND company_id = #{maps.companyId}
+      </if>
+      <if test="maps.deptId != null">
+        AND dept_id = #{maps.deptId}
+      </if>
+      <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+        AND create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+      </if>
+      <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+        AND pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+      </if>
+      <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+        AND DATE(delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+      </if>
+      <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
+        AND DATE(delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+      </if>
+      ORDER BY create_time DESC
+      <if test="maps.pageSize != null and maps.pageSize > 0">
+        LIMIT #{maps.pageSize}
+        <if test="maps.pageNum != null and maps.pageNum > 1">
+          OFFSET #{maps.offset}
+        </if>
+      </if>
+    ) o
+    LEFT JOIN ( SELECT fsois.*, ROW_NUMBER() OVER ( PARTITION BY fsois.order_id ORDER BY fsois.item_id ) AS rn FROM fs_store_order_item_scrm fsois ) item_latest ON item_latest.order_id = o.id and item_latest.rn = 1
+    LEFT JOIN fs_user u ON o.user_id = u.user_id
+    LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = item_latest.product_id
+    LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
+    LEFT JOIN fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
+    LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
+    LEFT JOIN company c ON c.company_id = cu.company_id
+    LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_order_id ORDER BY sp.create_time DESC ) AS rn FROM fs_store_payment_scrm sp ) sp_latest ON sp_latest.business_order_id = o.id AND sp_latest.rn = 1
+    LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+    WHERE 1=1
+    <!-- 需要 JOIN 后才能过滤的条件 -->
+    <if test="maps.productId != null and maps.productId != ''">
+      AND fspc.product_id = #{maps.productId}
           </if>
         <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
             AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+    </if>
+    <if test="maps.productName != null and maps.productName != ''">
+      AND fspc.product_name LIKE CONCAT('%', #{maps.productName}, '%')
+    </if>
+    <if test="maps.salesName != null and maps.salesName != ''">
+      AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
+    </if>
+    <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
+      AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+    </if>
+    <if test="maps.appId != null and maps.appId != ''">
+      AND csc.appid = #{maps.appId}
+    </if>
+    <if test="maps.hfshh != null and maps.hfshh != ''">
+      AND CONCAT('store-',sp_latest.pay_code) = #{maps.hfshh}
+    </if>
+    GROUP BY o.id
+    ORDER BY o.create_time DESC
+  </select>
+
+  <!-- 查询商城订单列表(只查询商城订单,order_type = 2) -->
+  <select id="selectStoreOrderList" parameterType="com.fs.live.param.MergedOrderQueryParam" resultType="com.fs.live.vo.MergedOrderVO">
+    SELECT
+    o.id,
+    '商城订单' AS order_type_name,
+    NULL AS order_id,
+    NULL AS live_id,
+    NULL AS after_sales_id,
+    o.order_code,
+    o.pay_price,
+    o.pay_money,
+    o.STATUS,
+    o.is_package,
+    o.package_json,
+    item_latest.json_info as item_json,
+    o.delivery_id,
+    o.delivery_sn as deliveryCode,
+    o.delivery_name as deliveryName,
+    o.finish_time,
+    o.create_time,
+    o.pay_time,
+    o.delivery_send_time,
+    o.total_num AS total_num,
+    o.deduction_price AS discount_money,
+    2 AS order_type,
+    cu.phonenumber as salesPhone,
+    cu.create_time as salesCreateTime,
+    o.user_id as userId,
+    u.order_count as userOrderCount,
+    u.total_amount as userTotalAmount,
+    u.level as userLevel,
+    fspc.product_id as productId,
+    fspc.product_name as productName,
+    fspc.prescribe_spec as productSpec,
+    COALESCE(fspc.cost, 0) as cost,
+    o.pay_postage as payDelivery,
+    o.coupon_price as discountMoney,
+    fss.store_id as storeId,
+    fss.store_name as storeName,
+    fspcs.cate_name as cateName,
+    GROUP_CONCAT(JSON_UNQUOTE(JSON_EXTRACT(item_latest.json_info, '$.barCode')) SEPARATOR ',') AS barCode,
+    c.company_name,
+    cu.user_name AS sales_name,
+    cu.nick_name AS company_user_nick_name,
+    ifnull(u.nickname,u.nick_name) as nickname,
+    u.phone,
+    o.real_name,
+    o.user_phone,
+    o.user_address,
+    o.pay_type,
+    o.delivery_status,
+    o.delivery_pay_status,
+    o.total_price,
+    csc.NAME AS mini_program_name,
+    sp_latest.bank_transaction_id,
+    CONCAT('store-',sp_latest.pay_code) as hfshh
+    FROM
+    (
+      SELECT * FROM fs_store_order_scrm 
+      WHERE company_id IS NULL AND is_del = 0 AND is_sys_del = 0
+      <if test="maps.status != null and maps.status != ''">
+        AND status = #{maps.status}
+      </if>
+      <if test="maps.userId != null and maps.userId != ''">
+        AND company_user_id = #{maps.userId}
+      </if>
+      <if test="maps.orderCode != null and maps.orderCode != ''">
+        AND order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+      </if>
+      <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+        AND FIND_IN_SET(order_code, #{maps.orderCodeList})
+      </if>
+      <if test="maps.deliveryId != null and maps.deliveryId != ''">
+        AND delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
         </if>
           <if test="maps.userPhone != null and maps.userPhone != ''">
-            AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+        AND user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
           </if>
         <if test="maps.userAddress != null and maps.userAddress != ''">
-            AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+        AND user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
           </if>
           <if test="maps.realName != null and maps.realName != ''">
-            AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
-          </if>
-          <if test="maps.productName != null and maps.productName != ''">
-            AND o.item_json LIKE CONCAT('%', #{maps.productName}, '%')
+        AND real_name LIKE CONCAT('%', #{maps.realName}, '%')
           </if>
           <if test="maps.deliveryStatus != null">
-            AND o.delivery_status = #{maps.deliveryStatus}
+        AND delivery_status = #{maps.deliveryStatus}
           </if>
           <if test="maps.deliveryPayStatus != null">
-            AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+        AND delivery_pay_status = #{maps.deliveryPayStatus}
           </if>
           <if test="maps.payType != null and maps.payType != ''">
-            AND o.pay_type = #{maps.payType}
+        AND pay_type = #{maps.payType}
           </if>
           <if test="maps.companyId != null">
-            AND o.company_id = #{maps.companyId}
+        AND company_id = #{maps.companyId}
           </if>
           <if test="maps.deptId != null">
-            AND o.dept_id = #{maps.deptId}
+        AND dept_id = #{maps.deptId}
+      </if>
+      <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+        AND create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+      </if>
+      <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+        AND pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+      </if>
+      <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+        AND DATE(delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+      </if>
+      <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
+        AND DATE(delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+      </if>
+      ORDER BY create_time DESC
+      <if test="maps.pageSize != null and maps.pageSize > 0">
+        LIMIT #{maps.pageSize}
+        <if test="maps.pageNum != null and maps.pageNum > 1">
+          OFFSET #{maps.offset}
+        </if>
+      </if>
+    ) o
+    LEFT JOIN ( SELECT fsois.*, ROW_NUMBER() OVER ( PARTITION BY fsois.order_id ORDER BY fsois.item_id ) AS rn FROM fs_store_order_item_scrm fsois ) item_latest ON item_latest.order_id = o.id and item_latest.rn = 1
+    LEFT JOIN fs_user u ON o.user_id = u.user_id
+    LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = item_latest.product_id
+    LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
+    LEFT JOIN fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
+    LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
+    LEFT JOIN company c ON c.company_id = cu.company_id
+    LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_order_id ORDER BY sp.create_time DESC ) AS rn FROM fs_store_payment_scrm sp ) sp_latest ON sp_latest.business_order_id = o.id AND sp_latest.rn = 1
+    LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+    WHERE 1=1
+    <!-- 需要 JOIN 后才能过滤的条件 -->
+    <if test="maps.productId != null and maps.productId != ''">
+      AND fspc.product_id = #{maps.productId}
+    </if>
+    <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
+      AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+    </if>
+    <if test="maps.productName != null and maps.productName != ''">
+      AND o.item_json LIKE CONCAT('%', #{maps.productName}, '%')
           </if>
           <if test="maps.salesName != null and maps.salesName != ''">
             AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
           </if>
           <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
             AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+    </if>
+    <if test="maps.appId != null and maps.appId != ''">
+      AND csc.appid = #{maps.appId}
+    </if>
+    <if test="maps.hfshh != null and maps.hfshh != ''">
+      AND CONCAT('store-',sp_latest.pay_code) = #{maps.hfshh}
+    </if>
+    GROUP BY o.id
+    ORDER BY o.create_time DESC
+  </select>
+
+  <!-- 查询直播订单列表(只查询直播订单,order_type = 3) -->
+  <select id="selectLiveOrderList" parameterType="com.fs.live.param.MergedOrderQueryParam" resultType="com.fs.live.vo.MergedOrderVO">
+    SELECT
+    NULL AS id,
+    '直播订单' AS order_type_name,
+    o.order_id,
+    o.live_id,
+    a.id AS after_sales_id,
+    o.order_code,
+    o.pay_price,
+    o.pay_money,
+    o.STATUS,
+    NULL AS is_package,
+    NULL AS package_json,
+    loi.json_info as item_json,
+    o.delivery_sn AS delivery_id,
+    o.delivery_code as deliveryCode,
+    o.delivery_name as deliveryName,
+    o.finish_time,
+    o.create_time,
+    o.pay_time,
+    o.delivery_send_time,
+    o.total_num,
+    o.discount_money,
+    3 AS order_type,
+    cu.phonenumber as salesPhone,
+    cu.create_time as salesCreateTime,
+    o.user_id as userId,
+    u.order_count as userOrderCount,
+    u.total_amount as userTotalAmount,
+    u.level as userLevel,
+    fspc.product_id as productId,
+    fspc.product_name as productName,
+    fspc.prescribe_spec as productSpec,
+    COALESCE(fspc.cost, 0) as cost,
+    o.pay_postage as payDelivery,
+    o.discount_money as discountMoney,
+    fss.store_id as storeId,
+    fss.store_name as storeName,
+    fspcs.cate_name as cateName,
+    GROUP_CONCAT(JSON_UNQUOTE(JSON_EXTRACT(loi.json_info, '$.barCode')) SEPARATOR ',') AS barCode,
+    c.company_name,
+    cu.user_name AS sales_name,
+    cu.nick_name AS company_user_nick_name,
+    ifnull(u.nickname,u.nick_name) as nickname,
+    u.phone,
+    o.user_name AS real_name,
+    o.user_phone,
+    o.user_address,
+    o.pay_type,
+    o.delivery_status,
+    o.delivery_pay_status,
+    o.total_price,
+    csc.NAME AS mini_program_name,
+    sp_latest.bank_transaction_id,
+    CONCAT('live-',sp_latest.pay_code) as hfshh
+    FROM
+    (
+      SELECT * FROM live_order 
+      WHERE is_del = 0
+      <if test="maps.status != null and maps.status != ''">
+        AND status = #{maps.status}
+      </if>
+      <if test="maps.userId != null and maps.userId != ''">
+        AND company_user_id = #{maps.userId}
+      </if>
+      <if test="maps.orderCode != null and maps.orderCode != ''">
+        AND order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+      </if>
+      <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+        AND FIND_IN_SET(order_code, #{maps.orderCodeList})
+      </if>
+      <if test="maps.deliveryId != null and maps.deliveryId != ''">
+        AND delivery_sn LIKE CONCAT('%', #{maps.deliveryId}, '%')
+      </if>
+      <if test="maps.userPhone != null and maps.userPhone != ''">
+        AND user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+      </if>
+      <if test="maps.userAddress != null and maps.userAddress != ''">
+        AND user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+      </if>
+      <if test="maps.realName != null and maps.realName != ''">
+        AND user_name LIKE CONCAT('%', #{maps.realName}, '%')
+      </if>
+      <if test="maps.deliveryStatus != null">
+        AND delivery_status = #{maps.deliveryStatus}
+      </if>
+      <if test="maps.deliveryPayStatus != null">
+        AND delivery_pay_status = #{maps.deliveryPayStatus}
+      </if>
+      <if test="maps.payType != null and maps.payType != ''">
+        AND pay_type = #{maps.payType}
+      </if>
+      <if test="maps.companyId != null">
+        AND company_id = #{maps.companyId}
+      </if>
+      <if test="maps.deptId != null">
+        AND dept_id = #{maps.deptId}
           </if>
           <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
-              AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+        AND create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
           </if>
         <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
-            AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+        AND pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
           </if>
           <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
-            AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+        AND DATE(delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
           </if>
-        <if test="maps.hfshh != null and maps.hfshh != ''">
-            AND CONCAT('store-',sp_latest.pay_code) = #{maps.hfshh}
+      ORDER BY create_time DESC
+      <if test="maps.pageSize != null and maps.pageSize > 0">
+        LIMIT #{maps.pageSize}
+        <if test="maps.pageNum != null and maps.pageNum > 1">
+          OFFSET #{maps.offset}
         </if>
-        group by o.order_id
-        ) AS merged_orders
+      </if>
+    ) o
+    LEFT JOIN live_order_item loi on loi.order_id = o.order_id
+    LEFT JOIN fs_user u ON o.user_id = u.user_id
+    LEFT JOIN fs_store_product_scrm  fspc ON fspc.product_id = o.product_id
+    LEFT JOIN fs_store_scrm  fss ON fspc.store_id = fss.store_id
+    LEFT JOIN fs_store_product_category_scrm fspcs on fspc.cate_id = fspcs.cate_id
+    LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
+    LEFT JOIN company c ON c.company_id = cu.company_id
+    LEFT JOIN ( SELECT t.*, ROW_NUMBER() OVER ( PARTITION BY t.order_id ORDER BY t.create_time DESC ) AS rn FROM live_after_sales t ) a ON o.order_id = a.order_id AND a.rn = 1
+    LEFT JOIN ( SELECT sp.*, ROW_NUMBER() OVER ( PARTITION BY sp.business_id ORDER BY sp.create_time DESC ) AS rn FROM live_order_payment sp ) sp_latest ON sp_latest.business_id = CAST(o.order_id AS CHAR) AND sp_latest.rn = 1
+    LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
         WHERE 1=1
-        <if test="maps.orderTypeFilter != null">
-          AND order_type = #{maps.orderTypeFilter}
+    <!-- 需要 JOIN 后才能过滤的条件 -->
+    <if test="maps.productId != null and maps.productId != ''">
+      AND fspc.product_id = #{maps.productId}
         </if>
-        ORDER BY create_time DESC
+    <if test="maps.bankTransactionId != null and maps.bankTransactionId != ''">
+      AND sp_latest.bank_transaction_id LIKE CONCAT('%', #{maps.bankTransactionId}, '%')
+    </if>
+    <if test="maps.productName != null and maps.productName != ''">
+      AND o.item_json LIKE CONCAT('%', #{maps.productName}, '%')
+    </if>
+    <if test="maps.salesName != null and maps.salesName != ''">
+      AND cu.user_name LIKE CONCAT('%', #{maps.salesName}, '%')
+    </if>
+    <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
+      AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+    </if>
+    <if test="maps.appId != null and maps.appId != ''">
+      AND csc.appid = #{maps.appId}
+    </if>
+    <if test="maps.hfshh != null and maps.hfshh != ''">
+      AND CONCAT('live-',sp_latest.pay_code) = #{maps.hfshh}
+    </if>
+    GROUP BY o.order_id
+    ORDER BY o.create_time DESC
     </select>
 
     <!-- 查询合并的售后列表(商城售后+直播售后) -->
@@ -535,5 +1028,294 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY createTime DESC
     </select>
 
+  <!-- 统计合并订单总数 -->
+  <select id="countMergedOrderList" parameterType="com.fs.live.param.MergedOrderQueryParam" resultType="long">
+    SELECT 
+      <choose>
+        <when test="maps.orderTypeFilter != null and maps.orderTypeFilter == 1">
+          <!-- 只统计销售订单 -->
+          (SELECT COUNT(DISTINCT o.id)
+           FROM fs_store_order_scrm o
+           WHERE o.company_id IS NOT NULL AND o.is_del = 0 AND o.is_sys_del = 0
+             <if test="maps.status != null and maps.status != ''">
+               AND o.status = #{maps.status}
+             </if>
+             <if test="maps.userId != null and maps.userId != ''">
+               AND o.company_user_id = #{maps.userId}
+             </if>
+             <if test="maps.orderCode != null and maps.orderCode != ''">
+               AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+             </if>
+             <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+               AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+             </if>
+             <if test="maps.deliveryId != null and maps.deliveryId != ''">
+               AND o.delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
+             </if>
+             <if test="maps.userPhone != null and maps.userPhone != ''">
+               AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+             </if>
+             <if test="maps.userAddress != null and maps.userAddress != ''">
+               AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+             </if>
+             <if test="maps.realName != null and maps.realName != ''">
+               AND o.real_name LIKE CONCAT('%', #{maps.realName}, '%')
+             </if>
+             <if test="maps.deliveryStatus != null">
+               AND o.delivery_status = #{maps.deliveryStatus}
+             </if>
+             <if test="maps.deliveryPayStatus != null">
+               AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+             </if>
+             <if test="maps.payType != null and maps.payType != ''">
+               AND o.pay_type = #{maps.payType}
+             </if>
+             <if test="maps.companyId != null">
+               AND o.company_id = #{maps.companyId}
+             </if>
+             <if test="maps.deptId != null">
+               AND o.dept_id = #{maps.deptId}
+             </if>
+             <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+               AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+             </if>
+             <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+               AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+               AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
+               AND DATE(o.delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+             </if>
+          )
+        </when>
+        <when test="maps.orderTypeFilter != null and maps.orderTypeFilter == 2">
+          <!-- 只统计商城订单 -->
+          (SELECT COUNT(DISTINCT o.id)
+           FROM fs_store_order_scrm o
+           WHERE o.company_id IS NULL AND o.is_del = 0 AND o.is_sys_del = 0
+             <if test="maps.status != null and maps.status != ''">
+               AND o.status = #{maps.status}
+             </if>
+             <if test="maps.userId != null and maps.userId != ''">
+               AND o.company_user_id = #{maps.userId}
+             </if>
+             <if test="maps.orderCode != null and maps.orderCode != ''">
+               AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+             </if>
+             <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+               AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+             </if>
+             <if test="maps.deliveryId != null and maps.deliveryId != ''">
+               AND o.delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
+             </if>
+             <if test="maps.userPhone != null and maps.userPhone != ''">
+               AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+             </if>
+             <if test="maps.userAddress != null and maps.userAddress != ''">
+               AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+             </if>
+             <if test="maps.realName != null and maps.realName != ''">
+               AND o.real_name LIKE CONCAT('%', #{maps.realName}, '%')
+             </if>
+             <if test="maps.deliveryStatus != null">
+               AND o.delivery_status = #{maps.deliveryStatus}
+             </if>
+             <if test="maps.deliveryPayStatus != null">
+               AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+             </if>
+             <if test="maps.payType != null and maps.payType != ''">
+               AND o.pay_type = #{maps.payType}
+             </if>
+             <if test="maps.companyId != null">
+               AND o.company_id = #{maps.companyId}
+             </if>
+             <if test="maps.deptId != null">
+               AND o.dept_id = #{maps.deptId}
+             </if>
+             <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+               AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+             </if>
+             <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+               AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+               AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
+               AND DATE(o.delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+             </if>
+          )
+        </when>
+        <when test="maps.orderTypeFilter != null and maps.orderTypeFilter == 3">
+          <!-- 只统计直播订单 -->
+          (SELECT COUNT(DISTINCT o.order_id)
+           FROM live_order o
+           WHERE o.is_del = 0
+             <if test="maps.status != null and maps.status != ''">
+               AND o.status = #{maps.status}
+             </if>
+             <if test="maps.userId != null and maps.userId != ''">
+               AND o.company_user_id = #{maps.userId}
+             </if>
+             <if test="maps.orderCode != null and maps.orderCode != ''">
+               AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+             </if>
+             <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+               AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+             </if>
+             <if test="maps.deliveryId != null and maps.deliveryId != ''">
+               AND o.delivery_sn LIKE CONCAT('%', #{maps.deliveryId}, '%')
+             </if>
+             <if test="maps.userPhone != null and maps.userPhone != ''">
+               AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+             </if>
+             <if test="maps.userAddress != null and maps.userAddress != ''">
+               AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+             </if>
+             <if test="maps.realName != null and maps.realName != ''">
+               AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
+             </if>
+             <if test="maps.deliveryStatus != null">
+               AND o.delivery_status = #{maps.deliveryStatus}
+             </if>
+             <if test="maps.deliveryPayStatus != null">
+               AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+             </if>
+             <if test="maps.payType != null and maps.payType != ''">
+               AND o.pay_type = #{maps.payType}
+             </if>
+             <if test="maps.companyId != null">
+               AND o.company_id = #{maps.companyId}
+             </if>
+             <if test="maps.deptId != null">
+               AND o.dept_id = #{maps.deptId}
+             </if>
+             <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+               AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+             </if>
+             <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+               AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+               AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+             </if>
+          )
+        </when>
+        <otherwise>
+          <!-- 如果 OrderTypeFilter 为空,只统计销售和直播订单,不统计商城订单 -->
+          (SELECT COUNT(DISTINCT o.id)
+           FROM fs_store_order_scrm o
+           WHERE o.company_id IS NOT NULL AND o.is_del = 0 AND o.is_sys_del = 0
+             <if test="maps.status != null and maps.status != ''">
+               AND o.status = #{maps.status}
+             </if>
+             <if test="maps.userId != null and maps.userId != ''">
+               AND o.company_user_id = #{maps.userId}
+             </if>
+             <if test="maps.orderCode != null and maps.orderCode != ''">
+               AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+             </if>
+             <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+               AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+             </if>
+             <if test="maps.deliveryId != null and maps.deliveryId != ''">
+               AND o.delivery_id LIKE CONCAT('%', #{maps.deliveryId}, '%')
+             </if>
+             <if test="maps.userPhone != null and maps.userPhone != ''">
+               AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+             </if>
+             <if test="maps.userAddress != null and maps.userAddress != ''">
+               AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+             </if>
+             <if test="maps.realName != null and maps.realName != ''">
+               AND o.real_name LIKE CONCAT('%', #{maps.realName}, '%')
+             </if>
+             <if test="maps.deliveryStatus != null">
+               AND o.delivery_status = #{maps.deliveryStatus}
+             </if>
+             <if test="maps.deliveryPayStatus != null">
+               AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+             </if>
+             <if test="maps.payType != null and maps.payType != ''">
+               AND o.pay_type = #{maps.payType}
+             </if>
+             <if test="maps.companyId != null">
+               AND o.company_id = #{maps.companyId}
+             </if>
+             <if test="maps.deptId != null">
+               AND o.dept_id = #{maps.deptId}
+             </if>
+             <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+               AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+             </if>
+             <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+               AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+               AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliveryImportTimeRange != null and maps.deliveryImportTimeRange != ''">
+               AND DATE(o.delivery_import_time) BETWEEN SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliveryImportTimeRange}, '--', -1)
+             </if>
+          ) +
+          (SELECT COUNT(DISTINCT o.order_id)
+           FROM live_order o
+           WHERE o.is_del = 0
+             <if test="maps.status != null and maps.status != ''">
+               AND o.status = #{maps.status}
+             </if>
+             <if test="maps.userId != null and maps.userId != ''">
+               AND o.company_user_id = #{maps.userId}
+             </if>
+             <if test="maps.orderCode != null and maps.orderCode != ''">
+               AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+             </if>
+             <if test="maps.orderCodeList != null and maps.orderCodeList != ''">
+               AND FIND_IN_SET(o.order_code, #{maps.orderCodeList})
+             </if>
+             <if test="maps.deliveryId != null and maps.deliveryId != ''">
+               AND o.delivery_sn LIKE CONCAT('%', #{maps.deliveryId}, '%')
+             </if>
+             <if test="maps.userPhone != null and maps.userPhone != ''">
+               AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+             </if>
+             <if test="maps.userAddress != null and maps.userAddress != ''">
+               AND o.user_address LIKE CONCAT('%', #{maps.userAddress}, '%')
+             </if>
+             <if test="maps.realName != null and maps.realName != ''">
+               AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
+             </if>
+             <if test="maps.deliveryStatus != null">
+               AND o.delivery_status = #{maps.deliveryStatus}
+             </if>
+             <if test="maps.deliveryPayStatus != null">
+               AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+             </if>
+             <if test="maps.payType != null and maps.payType != ''">
+               AND o.pay_type = #{maps.payType}
+             </if>
+             <if test="maps.companyId != null">
+               AND o.company_id = #{maps.companyId}
+             </if>
+             <if test="maps.deptId != null">
+               AND o.dept_id = #{maps.deptId}
+             </if>
+             <if test="maps.createTimeRange != null and maps.createTimeRange != ''">
+               AND o.create_time BETWEEN SUBSTRING_INDEX(#{maps.createTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.createTimeRange}, '--', -1)
+             </if>
+             <if test="maps.payTimeRange != null and maps.payTimeRange != ''">
+               AND o.pay_time BETWEEN SUBSTRING_INDEX(#{maps.payTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.payTimeRange}, '--', -1)
+             </if>
+             <if test="maps.deliverySendTimeRange != null and maps.deliverySendTimeRange != ''">
+               AND DATE(o.delivery_send_time) BETWEEN SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', 1) AND SUBSTRING_INDEX(#{maps.deliverySendTimeRange}, '--', -1)
+             </if>
+          )
+        </otherwise>
+      </choose>
+      AS total_count
+  </select>
+
 </mapper>
 

+ 2 - 2
fs-service/src/main/resources/mapper/live/LiveAfterSalesMapper.xml

@@ -90,7 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="refundType != null "> and las.refund_type = #{refundType}</if>
             <if test="status != null "> and las.status = #{status}</if>
             <if test="salesStatus != null "> and las.sales_status = #{salesStatus}</if>
-            <if test="orderStatus != null "> and las.order_status = #{orderStatus}</if>
+            <if test="orderStatus != null "> and lo.status = #{orderStatus}</if>
             <if test="reasons != null  and reasons != ''"> and las.reasons = #{reasons}</if>
             <if test="explains != null  and explains != ''"> and las.explains = #{explains}</if>
             <if test="explainImg != null  and explainImg != ''"> and las.explain_img = #{explainImg}</if>
@@ -99,7 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deliveryName != null  and deliveryName != ''"> and las.delivery_name like concat('%', #{deliveryName}, '%')</if>
             <if test="status != null "> and las.status = #{status}</if>
             <if test="salesStatus != null "> and las.sales_status = #{salesStatus}</if>
-            <if test="orderStatus != null "> and las.order_status = #{orderStatus}</if>
+            <!--<if test="orderStatus != null "> and las.order_status = #{orderStatus}</if>-->
             <if test="deliveryStatus != null and deliveryStatus!= ''"> and las.order_status = #{deliveryStatus}</if>
             <if test="isDel != null  and isDel != ''"> and las.is_del = #{isDel}</if>
             <if test="userId != null "> and las.user_id = #{userId}</if>

+ 7 - 1
fs-service/src/main/resources/mapper/live/LiveCouponUserMapper.xml

@@ -27,7 +27,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectLiveCouponUserList" parameterType="LiveCouponUser" resultMap="LiveCouponUserResult">
-        <include refid="selectLiveCouponUserVo"/>
+
+        select cou.id, cou.coupon_id, cou.user_id, cou.coupon_title, cou.coupon_price, cou.use_min_price, cou.create_time, cou.update_time, cou.limit_time, cou.use_time, cou.type, cou.status, cou.is_fail, cou.is_del,cou.goods_id,
+        u.nick_name,u.phone
+
+        from live_coupon_user as  cou
+         left join fs_user u on cou.user_id=u.user_id
+
         <where>
             <if test="couponId != null "> and coupon_id = #{couponId}</if>
             <if test="userId != null "> and user_id = #{userId}</if>

+ 8 - 0
fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -483,6 +483,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </foreach>
     </select>
 
+    <select id="selectLiveOrderByOrderIds" resultMap="LiveOrderResult">
+        <include refid="selectLiveOrderVo"/>
+        where order_id IN
+        <foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
+            #{orderId}
+        </foreach>
+    </select>
+
     <select id="selectLiveOrderListVO" resultType="com.fs.live.vo.LiveOrderVO">
 
     select o.*,u.phone,u.register_code,u.register_date,u.source, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber

+ 8 - 0
fs-service/src/main/resources/mapper/live/LiveOrderPaymentMapper.xml

@@ -223,4 +223,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{paymentId}
         </foreach>
     </delete>
+
+    <select id="selectByBankTransactionIds" resultMap="LiveOrderPaymentResult">
+        <include refid="selectLiveOrderPaymentVo"/>
+        where bank_transaction_id in
+        <foreach item="bankTransactionId" collection="bankTransactionIds" open="(" separator="," close=")">
+            #{bankTransactionId}
+        </foreach>
+    </select>
 </mapper>

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

@@ -211,6 +211,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from live_watch_log where live_id = #{liveId}
     </select>
 
+    <select id="selectLiveWatchLogByLiveIdAndExternalId" resultType="com.fs.live.domain.LiveWatchLog">
+        select * from live_watch_log where live_id = #{liveId} and external_contact_id = #{externalContactId} limit 1
+    </select>
+
     <select id="selectLiveWatchLogListInfo"   parameterType="LiveWatchLog" resultType="com.fs.live.vo.LiveWatchLogListVO">
         select
         t2.nick_name as userName,

+ 2 - 1
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -351,7 +351,7 @@ public class LiveOrderController extends AppBaseController
         LiveOrder liveOrder = orderService.selectLiveOrderByOrderId(orderId);
         //订单总价 临时处理 为 商品支付金额(商品支付金额=订单总价-快递费)
         if(ObjectUtil.isNotEmpty(liveOrder)) {
-            liveOrder.setTotalPrice(liveOrder.getTotalPrice().subtract(liveOrder.getPayDelivery()));
+            liveOrder.setTotalPrice(liveOrder.getTotalPrice().subtract(liveOrder.getPayPostage()));
         }
         return AjaxResult.success(liveOrder);
     }
@@ -909,6 +909,7 @@ public class LiveOrderController extends AppBaseController
         if (order.getStatus() !=0) {
             throw new CustomException("非法操作");
         }
+        order.setCouponUserId(Long.parseLong(getUserId()));
         orderService.cancelOrder(order);
 
         return R.ok("操作成功");