Przeglądaj źródła

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

15376779826 1 dzień temu
rodzic
commit
e596819568
54 zmienionych plików z 4254 dodań i 451 usunięć
  1. 26 4
      fs-admin/src/main/java/com/fs/his/controller/FsCompanyController.java
  2. 103 0
      fs-admin/src/main/java/com/fs/his/controller/FsCompanyDivItemController.java
  3. 103 0
      fs-admin/src/main/java/com/fs/his/controller/FsDfAccountController.java
  4. 92 13
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java
  5. 300 17
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  6. 2 1
      fs-company/src/main/java/com/fs/company/controller/course/FsCourseWatchLogController.java
  7. 15 0
      fs-company/src/main/java/com/fs/company/controller/qw/QwUserController.java
  8. 23 7
      fs-company/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  9. 11 0
      fs-qw-task/src/main/java/com/fs/app/controller/CommonController.java
  10. 54 53
      fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java
  11. 48 0
      fs-service/src/main/java/com/fs/company/domain/CompanyDivConfig.java
  12. 55 0
      fs-service/src/main/java/com/fs/company/domain/CompanyDivItem.java
  13. 61 0
      fs-service/src/main/java/com/fs/company/mapper/CompanyDivConfigMapper.java
  14. 65 0
      fs-service/src/main/java/com/fs/company/mapper/CompanyDivItemMapper.java
  15. 19 0
      fs-service/src/main/java/com/fs/company/param/CompanyAcctInfo.java
  16. 40 0
      fs-service/src/main/java/com/fs/company/param/CompanyDivConfigUpdateParam.java
  17. 66 0
      fs-service/src/main/java/com/fs/company/service/ICompanyDivConfigService.java
  18. 65 0
      fs-service/src/main/java/com/fs/company/service/ICompanyDivItemService.java
  19. 179 0
      fs-service/src/main/java/com/fs/company/service/impl/CompanyDivConfigServiceImpl.java
  20. 104 0
      fs-service/src/main/java/com/fs/company/service/impl/CompanyDivItemServiceImpl.java
  21. 11 9
      fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  22. 41 0
      fs-service/src/main/java/com/fs/company/vo/CompanyDivConfigVo.java
  23. 6 0
      fs-service/src/main/java/com/fs/course/param/FsCourseWatchLogListParam.java
  24. 4 1
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  25. 8 18
      fs-service/src/main/java/com/fs/erp/dto/sdk/df/DfClient.java
  26. 254 70
      fs-service/src/main/java/com/fs/erp/service/impl/DfOrderServiceImpl.java
  27. 74 0
      fs-service/src/main/java/com/fs/his/domain/FsDfAccount.java
  28. 61 0
      fs-service/src/main/java/com/fs/his/mapper/FsDfAccountMapper.java
  29. 61 0
      fs-service/src/main/java/com/fs/his/service/IFsDfAccountService.java
  30. 94 0
      fs-service/src/main/java/com/fs/his/service/impl/FsDfAccountServiceImpl.java
  31. 9 0
      fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java
  32. 125 18
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java
  33. 3 0
      fs-service/src/main/java/com/fs/his/vo/FsStoreOrderExcelVO.java
  34. 38 3
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java
  35. 257 103
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java
  36. 22 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderParam.java
  37. 14 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderScrmSetErpPhoneParam.java
  38. 14 1
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java
  39. 115 3
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  40. 24 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderErpExportVO.java
  41. 10 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderVO.java
  42. 2 0
      fs-service/src/main/java/com/fs/huifuPay/domain/HuiFuCreateOrder.java
  43. 19 1
      fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/request/V2TradePaymentScanpayRefundRequest.java
  44. 158 0
      fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/utils/HuiFuUtils.java
  45. 3 2
      fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java
  46. 127 119
      fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsInfoServiceImpl.java
  47. 91 0
      fs-service/src/main/resources/mapper/company/CompanyDivConfigMapper.xml
  48. 103 0
      fs-service/src/main/resources/mapper/company/CompanyDivItemMapper.xml
  49. 3 0
      fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml
  50. 124 0
      fs-service/src/main/resources/mapper/his/FsDfAccountMapper.xml
  51. 1 1
      fs-service/src/main/resources/mapper/his/FsPackageMapper.xml
  52. 7 7
      fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml
  53. 891 0
      fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml
  54. 49 0
      fs-user-app/src/main/java/com/fs/app/controller/HuifuPayController.java

+ 26 - 4
fs-admin/src/main/java/com/fs/his/controller/FsCompanyController.java

@@ -15,11 +15,9 @@ import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyDeduct;
 import com.fs.company.domain.CompanyRecharge;
 import com.fs.company.param.CompanyDeductParam;
+import com.fs.company.param.CompanyDivConfigUpdateParam;
 import com.fs.company.param.CompanyRechargeParam;
-import com.fs.company.service.ICompanyDeductService;
-import com.fs.company.service.ICompanyRechargeService;
-import com.fs.company.service.ICompanyService;
-import com.fs.company.service.ICompanyUserService;
+import com.fs.company.service.*;
 import com.fs.company.vo.CompanyVO;
 import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.config.CourseConfig;
@@ -70,6 +68,8 @@ public class FsCompanyController extends BaseController
     private ICompanyDeductService deductService;
     @Autowired
     private ISysConfigService configService;
+    @Autowired
+    private ICompanyDivConfigService companyDivConfigService;
     /**
      * 查询诊所管理列表
      */
@@ -241,4 +241,26 @@ public class FsCompanyController extends BaseController
         deductService.insertCompanyDeduct(deduct);
         return R.ok("提交成功,等待审核");
     }
+
+    /**
+     * 获取公司分账配置详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('his:companyDivConfig:query')")
+    @GetMapping(value = "/getDivConfig/{companyId}")
+    public AjaxResult getDivConfig(@PathVariable("companyId") Long companyId)
+    {
+        return AjaxResult.success(companyDivConfigService.selectCompanyDivConfigByCompanyId(companyId));
+    }
+
+    /**
+     * 公司分账配置
+     */
+    @PreAuthorize("@ss.hasPermi('his:companyDivConfig:set')")
+    @Log(title = "公司分账配置", businessType = BusinessType.UPDATE)
+    @PostMapping("/setDiv")
+    public R setDiv(@RequestBody CompanyDivConfigUpdateParam param)
+    {
+        return companyDivConfigService.setDiv(param);
+    }
+
 }

+ 103 - 0
fs-admin/src/main/java/com/fs/his/controller/FsCompanyDivItemController.java

@@ -0,0 +1,103 @@
+package com.fs.his.controller;
+
+import java.util.List;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.company.domain.CompanyDivItem;
+import com.fs.company.service.ICompanyDivItemService;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 分账明细Controller
+ *
+ * @author fs
+ * @date 2025-10-21
+ */
+@RestController
+@RequestMapping("/his/divItem")
+public class FsCompanyDivItemController extends BaseController
+{
+    @Autowired
+    private ICompanyDivItemService companyDivItemService;
+
+    /**
+     * 查询分账明细列表
+     */
+    @PreAuthorize("@ss.hasPermi('his:divItem:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(CompanyDivItem companyDivItem)
+    {
+        startPage();
+        List<CompanyDivItem> list = companyDivItemService.selectCompanyDivItemList(companyDivItem);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出分账明细列表
+     */
+    @PreAuthorize("@ss.hasPermi('his:divItem:export')")
+    @Log(title = "分账明细", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(CompanyDivItem companyDivItem)
+    {
+        List<CompanyDivItem> list = companyDivItemService.selectCompanyDivItemList(companyDivItem);
+        ExcelUtil<CompanyDivItem> util = new ExcelUtil<CompanyDivItem>(CompanyDivItem.class);
+        return util.exportExcel(list, "分账明细数据");
+    }
+
+    /**
+     * 获取分账明细详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('his:divItem:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(companyDivItemService.selectCompanyDivItemById(id));
+    }
+
+//    /**
+//     * 新增分账明细
+//     */
+//    @PreAuthorize("@ss.hasPermi('his:divItem:add')")
+//    @Log(title = "分账明细", businessType = BusinessType.INSERT)
+//    @PostMapping
+//    public AjaxResult add(@RequestBody CompanyDivItem companyDivItem)
+//    {
+//        return toAjax(companyDivItemService.insertCompanyDivItem(companyDivItem));
+//    }
+//
+//    /**
+//     * 修改分账明细
+//     */
+//    @PreAuthorize("@ss.hasPermi('his:divItem:edit')")
+//    @Log(title = "分账明细", businessType = BusinessType.UPDATE)
+//    @PutMapping
+//    public AjaxResult edit(@RequestBody CompanyDivItem companyDivItem)
+//    {
+//        return toAjax(companyDivItemService.updateCompanyDivItem(companyDivItem));
+//    }
+//
+//    /**
+//     * 删除分账明细
+//     */
+//    @PreAuthorize("@ss.hasPermi('his:divItem:remove')")
+//    @Log(title = "分账明细", businessType = BusinessType.DELETE)
+//	@DeleteMapping("/{ids}")
+//    public AjaxResult remove(@PathVariable Long[] ids)
+//    {
+//        return toAjax(companyDivItemService.deleteCompanyDivItemByIds(ids));
+//    }
+}

+ 103 - 0
fs-admin/src/main/java/com/fs/his/controller/FsDfAccountController.java

@@ -0,0 +1,103 @@
+package com.fs.his.controller;
+
+import java.util.List;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.his.domain.FsDfAccount;
+import com.fs.his.service.IFsDfAccountService;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 代服账户Controller
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+@RestController
+@RequestMapping("/his/dfAccount")
+public class FsDfAccountController extends BaseController
+{
+    @Autowired
+    private IFsDfAccountService fsDfAccountService;
+
+    /**
+     * 查询代服账户列表
+     */
+
+    @GetMapping("/list")
+    public TableDataInfo list(FsDfAccount fsDfAccount)
+    {
+        startPage();
+        List<FsDfAccount> list = fsDfAccountService.selectFsDfAccountList(fsDfAccount);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出代服账户列表
+     */
+    @PreAuthorize("@ss.hasPermi('his:dfAccount:export')")
+    @Log(title = "代服账户", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsDfAccount fsDfAccount)
+    {
+        List<FsDfAccount> list = fsDfAccountService.selectFsDfAccountList(fsDfAccount);
+        ExcelUtil<FsDfAccount> util = new ExcelUtil<FsDfAccount>(FsDfAccount.class);
+        return util.exportExcel(list, "代服账户数据");
+    }
+
+    /**
+     * 获取代服账户详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('his:dfAccount:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(fsDfAccountService.selectFsDfAccountById(id));
+    }
+
+    /**
+     * 新增代服账户
+     */
+    @PreAuthorize("@ss.hasPermi('his:dfAccount:add')")
+    @Log(title = "代服账户", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsDfAccount fsDfAccount)
+    {
+        return toAjax(fsDfAccountService.insertFsDfAccount(fsDfAccount));
+    }
+
+    /**
+     * 修改代服账户
+     */
+    @PreAuthorize("@ss.hasPermi('his:dfAccount:edit')")
+    @Log(title = "代服账户", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsDfAccount fsDfAccount)
+    {
+        return toAjax(fsDfAccountService.updateFsDfAccount(fsDfAccount));
+    }
+
+    /**
+     * 删除代服账户
+     */
+    @PreAuthorize("@ss.hasPermi('his:dfAccount:remove')")
+    @Log(title = "代服账户", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(fsDfAccountService.deleteFsDfAccountByIds(ids));
+    }
+}

+ 92 - 13
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java

@@ -9,24 +9,34 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.service.ICompanyMoneyLogsService;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.domain.FsStoreOrderDf;
+import com.fs.his.service.IFsStoreOrderDfService;
 import com.fs.his.service.IFsUserService;
+import com.fs.his.vo.FsStoreOrderListAndStatisticsVo;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.param.FsStoreOrderParam;
 import com.fs.hisStore.service.*;
+import com.fs.hisStore.vo.FsStoreOrderErpExportVO;
 import com.fs.hisStore.vo.FsStoreOrderExportVO;
 import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/store/store/storeOrder")
@@ -52,6 +62,9 @@ public class FsStoreHealthOrderScrmController extends BaseController {
     @Autowired
     private ICompanyMoneyLogsService moneyLogsService;
 
+    @Autowired
+    private IFsStoreOrderDfService fsStoreOrderDfService;
+
     // 允许的文件扩展名
     private static final String[] ALLOWED_EXCEL_EXTENSIONS = {".xlsx", ".xls"};
 
@@ -62,8 +75,8 @@ public class FsStoreHealthOrderScrmController extends BaseController {
      * 查询健康商城订单列表
      */
     @PreAuthorize("@ss.hasPermi('store:healthStoreOrder:list')")
-    @GetMapping("/healthList")
-    public TableDataInfo healthStoreList(FsStoreOrderParam param) {
+    @PostMapping("/healthList")
+    public TableDataInfo healthStoreList(@RequestBody FsStoreOrderParam param) {
         startPage();
         if(!StringUtils.isEmpty(param.getCreateTimeRange())){
             param.setCreateTimeList(param.getCreateTimeRange().split("--"));
@@ -79,16 +92,50 @@ public class FsStoreHealthOrderScrmController extends BaseController {
         }
         param.setIsHealth("1");
         List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
+        //金牛需求 区别其他项目 status = 6 (金牛代服管家) ,其他项目请避免使用订单状态status = 6
+        TableDataInfo dataTable = getDataTable(list);
+        if (CloudHostUtils.hasCloudHostName("康年堂")){
+            dataTable.setMsg("knt");
+        }
         if (list != null) {
             for (FsStoreOrderVO vo : list) {
                 if(vo.getPhone()!=null){
                     vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
                     vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
                 }
+                if (CloudHostUtils.hasCloudHostName("康年堂")){
+                    //查询顺丰代服账号
+                    FsStoreOrderDf df = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(vo.getId());
+                    if (df != null){
+                        vo.setErpAccount(df.getLoginAccount());
+                    }
+                }
 
             }
         }
-        return getDataTable(list);
+        FsStoreOrderListAndStatisticsVo vo = new FsStoreOrderListAndStatisticsVo();
+        BeanUtils.copyProperties(dataTable, vo);
+        if (dataTable.getTotal()>0){
+            Map<String, BigDecimal> statistics= fsStoreOrderService.selectFsStoreOrderStatistics(param);
+            if (statistics != null && statistics.size() >= 3){
+                vo.setPayPriceTotal(statistics.get("pay_price").toString());
+                vo.setPayMoneyTotal(statistics.get("pay_money").toString());
+                vo.setPayRemainTotal(statistics.get("pay_remain").toString());
+            }else {
+                vo.setPayPriceTotal("0");
+                vo.setPayMoneyTotal("0");
+                vo.setPayRemainTotal("0");
+            }
+            //商品数量合计
+            String productStatistics= fsStoreOrderService.selectFsStoreOrderProductStatistics(param);
+            if (StringUtils.isNotBlank(productStatistics)){
+                vo.setProductInfo(productStatistics);
+            } else {
+                vo.setProductInfo("");
+            }
+
+        }
+        return vo;
     }
 
     /**
@@ -96,8 +143,8 @@ public class FsStoreHealthOrderScrmController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('store:healthStoreOrder:export')")
     @Log(title = "健康商城订单", businessType = BusinessType.EXPORT)
-    @GetMapping("/healthExport")
-    public AjaxResult export1(FsStoreOrderParam param) {
+    @PostMapping("/healthExport")
+    public AjaxResult export1(@RequestBody FsStoreOrderParam param) {
         if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
             param.setBeginTime(null);
             param.setEndTime(null);
@@ -118,7 +165,7 @@ public class FsStoreHealthOrderScrmController extends BaseController {
             param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
         }
         param.setIsHealth("1");
-        List<FsStoreOrderExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
+        List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
         //对手机号脱敏
         if (list != null) {
             for (FsStoreOrderExportVO vo : list) {
@@ -131,8 +178,24 @@ public class FsStoreHealthOrderScrmController extends BaseController {
 
             }
         }
-        ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
-        return util.exportExcel(list, "订单数据");
+        String filter = param.getFilter();
+        // 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
+        ArrayList<String> filterList = new ArrayList<>();
+        if (StringUtils.isNotBlank(filter)) {
+            // 按逗号拆分,同时去除可能的空格(如filter传"orderId, orderCode"时兼容)
+            String[] filterArr = filter.split("\\s*,\\s*");
+            filterList.addAll(Arrays.asList(filterArr));
+        }
+        // 动态导出:根据选中的字段生成Excel
+        ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
     }
 
     /**
@@ -140,8 +203,8 @@ public class FsStoreHealthOrderScrmController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('store:healthStoreOrder:export:details')")
     @Log(title = "健康商城订单", businessType = BusinessType.EXPORT)
-    @GetMapping("/healthExportDetails")
-    public AjaxResult healthExportDetails(FsStoreOrderParam param) {
+    @PostMapping("/healthExportDetails")
+    public AjaxResult healthExportDetails(@RequestBody FsStoreOrderParam param) {
         if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
             param.setBeginTime(null);
             param.setEndTime(null);
@@ -162,9 +225,25 @@ public class FsStoreHealthOrderScrmController extends BaseController {
             param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
         }
         param.setIsHealth("1");
-        List<FsStoreOrderExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
-        ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
-        return util.exportExcel(list, "订单数据");
+        List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
+        String filter = param.getFilter();
+        // 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
+        ArrayList<String> filterList = new ArrayList<>();
+        if (StringUtils.isNotBlank(filter)) {
+            // 按逗号拆分,同时去除可能的空格(如filter传"orderId, orderCode"时兼容)
+            String[] filterArr = filter.split("\\s*,\\s*");
+            filterList.addAll(Arrays.asList(filterArr));
+        }
+        // 动态导出:根据选中的字段生成Excel
+        ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
     }
 
 

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

@@ -2,6 +2,7 @@ package com.fs.hisStore.controller;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
@@ -10,6 +11,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.model.LoginUser;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
@@ -21,12 +23,22 @@ import com.fs.erp.domain.ErpDeliverys;
 import com.fs.erp.domain.ErpOrderQuery;
 import com.fs.erp.dto.ErpOrderQueryRequert;
 import com.fs.erp.dto.ErpOrderQueryResponse;
+import com.fs.erp.dto.df.DFConfigVo;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.framework.web.service.TokenService;
+import com.fs.his.domain.FsDfAccount;
+import com.fs.his.domain.FsStoreOrderDf;
 import com.fs.his.domain.FsUser;
+import com.fs.his.enums.FsStoreOrderLogEnum;
+import com.fs.his.param.FsStoreOrderSetErpPhoneParam;
+import com.fs.his.service.IFsDfAccountService;
 import com.fs.his.service.IFsExpressService;
+import com.fs.his.service.IFsStoreOrderDfService;
 import com.fs.his.service.IFsUserService;
+import com.fs.his.service.impl.FsDfAccountServiceImpl;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.vo.FsStoreOrderListAndStatisticsVo;
+import com.fs.his.vo.FsStoreOrderListVO;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
@@ -39,6 +51,8 @@ import com.fs.hisStore.enums.ShipperCodeEnum;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.*;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.mapper.SysConfigMapper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,9 +63,12 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.fs.his.utils.PhoneUtil.encryptPhone;
 
 /**
  * 订单Controller
@@ -107,6 +124,18 @@ public class FsStoreOrderScrmController extends BaseController {
     @Autowired
     private TokenService tokenService;
 
+    @Autowired
+    SysConfigMapper sysConfigMapper;
+
+    @Autowired
+    private IFsDfAccountService fsDfAccountService;
+
+    @Autowired
+    private IFsStoreOrderDfService fsStoreOrderDfService;
+
+    @Autowired
+    private IFsStoreOrderLogsScrmService fsStoreOrderLogsService;
+
     private IErpOrderService getErpService(){
         //判断是否开启erp
         IErpOrderService erpOrderService = null;
@@ -142,8 +171,8 @@ public class FsStoreOrderScrmController extends BaseController {
      * 查询订单列表
      */
     @PreAuthorize("@ss.hasPermi('store:storeOrder:list')")
-    @GetMapping("/list")
-    public TableDataInfo list(FsStoreOrderParam param) {
+    @PostMapping("/list")
+    public TableDataInfo list(@RequestBody FsStoreOrderParam param) {
         startPage();
         if(!StringUtils.isEmpty(param.getCreateTimeRange())){
             param.setCreateTimeList(param.getCreateTimeRange().split("--"));
@@ -159,15 +188,49 @@ public class FsStoreOrderScrmController extends BaseController {
         }
         param.setNotHealth(1);
         List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
+        //金牛需求 区别其他项目 status = 6 (金牛代服管家) ,其他项目请避免使用订单状态status = 6
+        TableDataInfo dataTable = getDataTable(list);
+        if (CloudHostUtils.hasCloudHostName("康年堂")){
+            dataTable.setMsg("knt");
+        }
         if (list != null) {
             for (FsStoreOrderVO vo : list) {
                 if(vo.getPhone()!=null){
                     vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
                     vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
                 }
+                if (CloudHostUtils.hasCloudHostName("康年堂")){
+                    //查询顺丰代服账号
+                    FsStoreOrderDf df = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(vo.getId());
+                    if (df != null){
+                        vo.setErpAccount(df.getLoginAccount());
+                    }
+                }
             }
         }
-        return getDataTable(list);
+        FsStoreOrderListAndStatisticsVo vo = new FsStoreOrderListAndStatisticsVo();
+        BeanUtils.copyProperties(dataTable, vo);
+        if (dataTable.getTotal()>0){
+            Map<String, BigDecimal> statistics= fsStoreOrderService.selectFsStoreOrderStatistics(param);
+            if (statistics != null && statistics.size() >= 3){
+                vo.setPayPriceTotal(statistics.get("pay_price").toString());
+                vo.setPayMoneyTotal(statistics.get("pay_money").toString());
+                vo.setPayRemainTotal(statistics.get("pay_remain").toString());
+            }else {
+                vo.setPayPriceTotal("0");
+                vo.setPayMoneyTotal("0");
+                vo.setPayRemainTotal("0");
+            }
+            //商品数量合计
+            String productStatistics= fsStoreOrderService.selectFsStoreOrderProductStatistics(param);
+            if (StringUtils.isNotBlank(productStatistics)){
+                vo.setProductInfo(productStatistics);
+            } else {
+                vo.setProductInfo("");
+            }
+
+        }
+        return vo;
     }
 
     @PreAuthorize("@ss.hasPermi('store:storeOrder:payRemainList')")
@@ -236,8 +299,8 @@ public class FsStoreOrderScrmController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('store:storeOrder:export')")
     @Log(title = "订单", businessType = BusinessType.EXPORT)
-    @GetMapping("/export")
-    public AjaxResult export(FsStoreOrderParam param) {
+    @PostMapping("/export")
+    public AjaxResult export(@RequestBody FsStoreOrderParam param) {
         if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
             param.setBeginTime(null);
             param.setEndTime(null);
@@ -258,13 +321,13 @@ public class FsStoreOrderScrmController extends BaseController {
             param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
         }
         param.setNotHealth(1);
-        List<FsStoreOrderExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
+        List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
         //对手机号脱敏
         if (list != null) {
             //获取当前账号角色权限
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
 
-            for (FsStoreOrderExportVO vo : list) {
+            for (FsStoreOrderErpExportVO vo : list) {
                 if (vo.getPhone() != null) {
                     vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
                 }
@@ -276,8 +339,24 @@ public class FsStoreOrderScrmController extends BaseController {
                 }
             }
         }
-        ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
-        return util.exportExcel(list, "订单数据");
+        String filter = param.getFilter();
+        // 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
+        ArrayList<String> filterList = new ArrayList<>();
+        if (StringUtils.isNotBlank(filter)) {
+            // 按逗号拆分,同时去除可能的空格(如filter传"orderId, orderCode"时兼容)
+            String[] filterArr = filter.split("\\s*,\\s*");
+            filterList.addAll(Arrays.asList(filterArr));
+        }
+        // 动态导出:根据选中的字段生成Excel
+        ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
     }
 
 
@@ -286,8 +365,8 @@ public class FsStoreOrderScrmController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('store:storeOrder:export:details')")
     @Log(title = "订单", businessType = BusinessType.EXPORT)
-    @GetMapping("/exportDetails")
-    public AjaxResult exportDetails(FsStoreOrderParam param) {
+    @PostMapping("/exportDetails")
+    public AjaxResult exportDetails(@RequestBody FsStoreOrderParam param) {
         if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
             param.setBeginTime(null);
             param.setEndTime(null);
@@ -308,9 +387,25 @@ public class FsStoreOrderScrmController extends BaseController {
             param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
         }
         param.setNotHealth(1);
-        List<FsStoreOrderExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
-        ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
-        return util.exportExcel(list, "订单数据");
+        List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
+        String filter = param.getFilter();
+        // 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
+        ArrayList<String> filterList = new ArrayList<>();
+        if (StringUtils.isNotBlank(filter)) {
+            // 按逗号拆分,同时去除可能的空格(如filter传"orderId, orderCode"时兼容)
+            String[] filterArr = filter.split("\\s*,\\s*");
+            filterList.addAll(Arrays.asList(filterArr));
+        }
+        // 动态导出:根据选中的字段生成Excel
+        ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
     }
 
     @PreAuthorize("@ss.hasPermi('store:storeOrder:exportItems')")
@@ -739,4 +834,192 @@ public class FsStoreOrderScrmController extends BaseController {
         }
         return resultList;
     }
+
+    /**
+     * 查询erp默认手机号
+     * @return
+     */
+    @GetMapping(value = "/queryErpPhone")
+    public AjaxResult queryErpPhone()
+    {
+        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("erp.phone");
+        List<String> list = new ArrayList<>();
+        if(sysConfig!=null){
+            String configValue = sysConfig.getConfigValue();
+            if(StringUtils.isNotEmpty(configValue)){
+                list = JSON.parseArray(configValue, String.class);
+            }
+        }
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 设置erp默认手机号
+     * @param phoneList
+     * @return
+     */
+    @PostMapping(value = "/saveErpPhone")
+    public AjaxResult saveErpPhone(@RequestBody List<String> phoneList)
+    {
+        //去重
+        phoneList = phoneList.stream().distinct().collect(Collectors.toList());
+        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("erp.phone");
+        sysConfig.setConfigValue(JSON.toJSONString(phoneList));
+        return AjaxResult.success(sysConfigMapper.updateConfig(sysConfig));
+    }
+
+    /**
+     * 批量设置erp手机号
+     */
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
+    @Log(title = "订单", businessType = BusinessType.UPDATE)
+    @PostMapping("/editErpPhone")
+    public AjaxResult editErpPhone(@RequestBody FsStoreOrderScrmSetErpPhoneParam param)
+    {
+        param.setOpeName(getLoginUser().getUser().getNickName());
+        List<String> erpPhone = param.getErpPhone();
+        if (erpPhone == null || erpPhone.isEmpty()) {
+            return AjaxResult.error("请选择手机号");
+        }
+        return toAjax(fsStoreOrderService.batchUpdateErpByOrderIds(param));
+    }
+
+    /**
+     * 获取erp账户
+     */
+    @GetMapping("/getErpAccount")
+    public R getErpAccount()
+    {
+        List<FsDfAccount> erpAccounts = fsDfAccountService.selectFsDfAccountList(null);
+        List<String> list = erpAccounts.stream().map(FsDfAccount::getLoginAccount).collect(Collectors.toList());
+        return R.ok().put("data", list);
+    }
+
+    @Log(title = "手动推管易", businessType = BusinessType.INSERT)
+    @ApiOperation("批量创建ERP订单")
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
+    @PostMapping(value = "/batchCreateErpOrder")
+    public R batchCreateErpOrder(@RequestBody FsStoreOrderScrmSetErpPhoneParam param)
+    {
+        String nickName = getLoginUser().getUser().getNickName();
+        String loginAccount = param.getLoginAccount();
+        if (StringUtils.isBlank(loginAccount)){
+            return R.error("未选择推送erp账户");
+        }
+        FsStoreOrderDf df = getDFInfo(loginAccount);
+        if (df.getLoginAccount() == null){
+            return R.error("未查询到所选erp账户");
+        }
+        List<Long> orderIds = param.getOrderIds();
+        if (orderIds  == null || orderIds.isEmpty()) {
+            if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+                param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getPayTimeRange())){
+                param.setPayTimeList(param.getPayTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+                param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+                param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+            }
+            param.setNotHealth(1);
+            List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
+            orderIds = list.stream().map(FsStoreOrderVO::getId).collect(Collectors.toList());
+        }
+        if (orderIds.isEmpty()){
+            return R.ok();
+        }
+        orderIds.forEach(orderId->{
+            try {
+                df.setOrderId(orderId);
+                FsStoreOrderDf temp = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(df.getOrderId());
+                if (temp == null){
+                    df.setParcelQuantity(param.getParcelQuantity()); //设置包裹数量
+                    fsStoreOrderDfService.insertFsStoreOrderDf(df);
+                    fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getValue(),
+                            nickName + " " +FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getDesc() + ":" + df.getLoginAccount());
+                }
+                fsStoreOrderService.createOmsOrder(orderId);
+                fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.PUSH_ORDER_ERP.getValue(),
+                        nickName + " " +FsStoreOrderLogEnum.PUSH_ORDER_ERP.getDesc() + ":" + df.getLoginAccount());
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+
+        });
+        return R.ok();
+    }
+
+
+    @ApiOperation("批量设置订单账户")
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
+    @PostMapping(value = "/batchSetErpOrder")
+    public R batchSetErpOrder(@RequestBody FsStoreOrderScrmSetErpPhoneParam param)
+    {
+        String nickName = getLoginUser().getUser().getNickName();
+        String loginAccount = param.getLoginAccount();
+        if (StringUtils.isBlank(loginAccount)){
+            return R.error("未选择erp账户");
+        }
+        FsStoreOrderDf df = getDFInfo(loginAccount);
+        if (df.getLoginAccount() == null){
+            return R.error("未查询到所选erp账户");
+        }
+        List<Long> orderIds = param.getOrderIds();
+        if (orderIds  == null || orderIds.isEmpty()) {
+            if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+                param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getPayTimeRange())){
+                param.setPayTimeList(param.getPayTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+                param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+                param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+            }
+            param.setNotHealth(1);
+            List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
+            orderIds = list.stream().map(FsStoreOrderVO::getId).collect(Collectors.toList());
+        }
+        if (orderIds.isEmpty()){
+            return R.ok();
+        }
+        orderIds.forEach(orderId->{
+            df.setOrderId(orderId);
+            FsStoreOrderDf temp = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(df.getOrderId());
+            df.setParcelQuantity(param.getParcelQuantity());
+            if (temp != null){
+                df.setUpdateTime(new Date());
+                fsStoreOrderDfService.updateFsStoreOrderDf(df);
+            } else {
+                fsStoreOrderDfService.insertFsStoreOrderDf(df);
+            }
+            fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getValue(),
+                    nickName + " " +FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getDesc() + ":" + df.getLoginAccount());
+        });
+        return R.ok();
+    }
+
+    private FsStoreOrderDf getDFInfo(String loginAccount) {
+        //查询订单账户 判断是否存在该订单账户
+        List<FsDfAccount> erpAccounts = fsDfAccountService.selectFsDfAccountList(null);
+        FsStoreOrderDf df = new FsStoreOrderDf();
+        for (FsDfAccount erpAccount : erpAccounts) {
+            if (loginAccount.equals(erpAccount.getLoginAccount())){
+                //添加df记录
+                df.setAppKey(erpAccount.getDfAppKey());
+                df.setAppSecret(erpAccount.getDfAppsecret());
+                df.setLoginAccount(loginAccount);
+                df.setMonthlyCard(erpAccount.getMonthlyCard());
+                df.setExpressProductCode(erpAccount.getExpressProductCode());
+                df.setStatus(0);
+                break;
+            }
+        }
+        return df;
+    }
 }

+ 2 - 1
fs-company/src/main/java/com/fs/company/controller/course/FsCourseWatchLogController.java

@@ -1,5 +1,6 @@
 package com.fs.company.controller.course;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
@@ -119,7 +120,7 @@ public class FsCourseWatchLogController extends BaseController
         param.setCompanyId(loginUser.getCompany().getCompanyId());
 
 
-        if (param.getSendType()==1&& param.getPeriodETime()!=null && param.getPeriodSTime()!=null) {
+        if (ObjectUtil.isNotEmpty(param.getSendType()) &&param.getSendType()==1&& param.getPeriodETime()!=null && param.getPeriodSTime()!=null) {
             List<Long> periodIds = userCoursePeriodDaysService.selectFsUserCoursePeriodDaysByTime(param.getPeriodSTime(), param.getPeriodETime());
 
             if (!periodIds.isEmpty()){

+ 15 - 0
fs-company/src/main/java/com/fs/company/controller/qw/QwUserController.java

@@ -449,6 +449,21 @@ public class QwUserController extends BaseController
         ExcelUtil<QwUser> util = new ExcelUtil<QwUser>(QwUser.class);
         return util.exportExcel(list, "企微用户数据");
     }
+
+    /**
+     * 查询企微用户列表-下拉框
+     */
+    @GetMapping("/qwList")
+    public TableDataInfo getQwList(QwUser qwUser)
+    {
+        startPage();
+
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        qwUser.setCompanyId(loginUser.getCompany().getCompanyId());
+
+        List<QwUser> list = qwUserService.selectQwUserList(qwUser);
+        return getDataTable(list);
+    }
     /**
     * 查询企微员工列表-用于员工管理绑定
     */

+ 23 - 7
fs-company/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -35,10 +35,7 @@ import com.fs.hisStore.param.FsStoreOrderCreateUserParam;
 import com.fs.hisStore.param.FsStoreOrderFinishParam;
 import com.fs.hisStore.param.FsStoreOrderParam;
 import com.fs.hisStore.service.*;
-import com.fs.hisStore.vo.FsStoreOrderAuditLogVO;
-import com.fs.hisStore.vo.FsStoreOrderExportVO;
-import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
-import com.fs.hisStore.vo.FsStoreOrderVO;
+import com.fs.hisStore.vo.*;
 import com.fs.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -47,6 +44,8 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -171,7 +170,7 @@ public class FsStoreOrderScrmController extends BaseController
         if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
             param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
         }
-        List<FsStoreOrderExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
+        List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
         //对手机号脱敏
         if(list!=null){
             for(FsStoreOrderExportVO vo:list){
@@ -187,8 +186,25 @@ public class FsStoreOrderScrmController extends BaseController
 
             }
         }
-        ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
-        return util.exportExcel(list,"订单数据");
+
+        String filter = param.getFilter();
+        // 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
+        ArrayList<String> filterList = new ArrayList<>();
+        if (StringUtils.isNotBlank(filter)) {
+            // 按逗号拆分,同时去除可能的空格(如filter传"orderId, orderCode"时兼容)
+            String[] filterArr = filter.split("\\s*,\\s*");
+            filterList.addAll(Arrays.asList(filterArr));
+        }
+        // 动态导出:根据选中的字段生成Excel
+        ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
     }
 
 

+ 11 - 0
fs-qw-task/src/main/java/com/fs/app/controller/CommonController.java

@@ -31,6 +31,7 @@ import com.fs.sop.service.*;
 import com.fs.sop.vo.QwSopLogsDoSendListTVO;
 import com.fs.store.service.IFsUserCourseCountService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -123,6 +124,16 @@ public class CommonController {
     private SyncQwExternalContactService syncQwExternalContactService;
 
 
+
+    /**
+     * 获取跳转微信小程序的链接地址
+     */
+    @GetMapping("/getGotoWxAppLink")
+    @ApiOperation("获取跳转微信小程序的链接地址")
+    public ResponseResult<String> getGotoWxAppLink(String linkStr,String appid) {
+        return ResponseResult.ok(courseLinkService.getGotoWxAppLink(linkStr,appid));
+    }
+
     /**
     * 发官方通连
     */

+ 54 - 53
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java

@@ -931,66 +931,66 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
                 //文字和短链一起
                 case "1":
                 case "3":
-                    if ("1".equals(setting.getIsBindUrl())) {
-                        String link;
-                        if (isGroupChat) {
-                            FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
-                            createParam.setCourseId(courseId);
-                            createParam.setVideoId(videoId);
-                            createParam.setCorpId(logVo.getCorpId());
-                            createParam.setCompanyUserId(Long.parseLong(companyUserId));
-                            createParam.setCompanyId(Long.parseLong(companyId));
-                            createParam.setChatId(logVo.getChatId());
-                            createParam.setQwUserId(Long.valueOf(qwUserId));
-                            createParam.setDays(setting.getExpiresDays());
-                            R createLink = courseLinkService.createRoomLinkUrl(createParam);
-                            if (createLink.get("code").equals(500)) {
-                                throw new BaseException("链接生成失败!");
-                            }
-                            try {
-                                groupChat.getChatUserList().stream().filter(e -> e.getUserList() != null && !e.getUserList().isEmpty()).forEach(e -> {
-                                    Map<String, GroupUserExternalVo> userMap = PubFun.listToMapByGroupObject(e.getUserList(), GroupUserExternalVo::getUserId);
-                                    GroupUserExternalVo vo = userMap.get(groupChat.getOwner());
-                                    if (vo != null && vo.getId() != null) {
-                                        sopLogs.setFsUserId(vo.getFsUserId());
-                                        addWatchLogIfNeeded(sopLogs, videoId, courseId, sendTime, qwUserId, companyUserId, companyId, vo.getId().toString(), logVo);
-                                    }
-                                });
-                            } catch (Exception e) {
-                                log.error("群聊创建看课记录失败!", e);
-                            }
-                            link = (String) createLink.get("url");
-                        } else {
-                            addWatchLogIfNeeded(sopLogs, videoId, courseId, sendTime, qwUserId, companyUserId, companyId, externalId, logVo);
-                            link = generateShortLink(setting, logVo, sendTime, courseId, videoId,
-                                    qwUserId, companyUserId, companyId, externalId,isOfficial,sopLogs.getFsUserId());
-                        }
+//                    if ("1".equals(setting.getIsBindUrl())) {
+//                        String link;
+//                        if (isGroupChat) {
+//                            FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
+//                            createParam.setCourseId(courseId);
+//                            createParam.setVideoId(videoId);
+//                            createParam.setCorpId(logVo.getCorpId());
+//                            createParam.setCompanyUserId(Long.parseLong(companyUserId));
+//                            createParam.setCompanyId(Long.parseLong(companyId));
+//                            createParam.setChatId(logVo.getChatId());
+//                            createParam.setQwUserId(Long.valueOf(qwUserId));
+//                            createParam.setDays(setting.getExpiresDays());
+//                            R createLink = courseLinkService.createRoomLinkUrl(createParam);
+//                            if (createLink.get("code").equals(500)) {
+//                                throw new BaseException("链接生成失败!");
+//                            }
+//                            try {
+//                                groupChat.getChatUserList().stream().filter(e -> e.getUserList() != null && !e.getUserList().isEmpty()).forEach(e -> {
+//                                    Map<String, GroupUserExternalVo> userMap = PubFun.listToMapByGroupObject(e.getUserList(), GroupUserExternalVo::getUserId);
+//                                    GroupUserExternalVo vo = userMap.get(groupChat.getOwner());
+//                                    if (vo != null && vo.getId() != null) {
+//                                        sopLogs.setFsUserId(vo.getFsUserId());
+//                                        addWatchLogIfNeeded(sopLogs, videoId, courseId, sendTime, qwUserId, companyUserId, companyId, vo.getId().toString(), logVo);
+//                                    }
+//                                });
+//                            } catch (Exception e) {
+//                                log.error("群聊创建看课记录失败!", e);
+//                            }
+//                            link = (String) createLink.get("url");
+//                        } else {
+//                            addWatchLogIfNeeded(sopLogs, videoId, courseId, sendTime, qwUserId, companyUserId, companyId, externalId, logVo);
+//                            link = generateShortLink(setting, logVo, sendTime, courseId, videoId,
+//                                    qwUserId, companyUserId, companyId, externalId,isOfficial,sopLogs.getFsUserId());
+//                        }
 
-                        if (StringUtils.isNotEmpty(link)) {
-                            if ("3".equals(setting.getContentType())) {
-                                setting.setLinkUrl(link);
-                            } else {
-                                String currentValue = setting.getValue();
-                                if (currentValue == null) {
-                                    setting.setValue(link);
-                                } else {
-                                    setting.setValue(currentValue
-                                            .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(welcomeText) ? "" : welcomeText)
-                                            .replaceAll("#客户称呼#", contact == null || StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus())
-                                            + "\n" + link);
-                                }
-                            }
-                        } else {
-                            log.error("生成短链失败,跳过设置 URL。");
-                        }
+//                        if (StringUtils.isNotEmpty(link)) {
+//                            if ("3".equals(setting.getContentType())) {
+//                                setting.setLinkUrl(link);
+//                            } else {
+//                                String currentValue = setting.getValue();
+//                                if (currentValue == null) {
+//                                    setting.setValue(link);
+//                                } else {
+//                                    setting.setValue(currentValue
+//                                            .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(welcomeText) ? "" : welcomeText)
+//                                            .replaceAll("#客户称呼#", contact == null || StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus())
+//                                            + "\n" + link);
+//                                }
+//                            }
+//                        } else {
+//                            log.error("生成短链失败,跳过设置 URL。");
+//                        }
 
-                    } else {
+//                    } else {
                         if ("1".equals(setting.getContentType())) {
                             setting.setValue(setting.getValue()
                                     .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(welcomeText) ? "" : welcomeText)
                                     .replaceAll("#客户称呼#", contact == null || StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus()));
                         }
-                    }
+//                    }
                     break;
                 //小程序单独
                 case "4":
@@ -1968,6 +1968,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
         sopLogs.setExternalUserId(externalContact.getExternalUserId());
         sopLogs.setExternalUserName(externalContact.getName());
         sopLogs.setFsUserId(finishLog.getUserId() != null ? finishLog.getUserId() : null );
+        sopLogs.setExternalId(finishLog.getQwExternalContactId());
         sopLogs.setUserLogsId("-");
 
         sopLogs.setQwUserKey(finishLog.getQwUserId() != null ? finishLog.getQwUserId() : null);

+ 48 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyDivConfig.java

@@ -0,0 +1,48 @@
+package com.fs.company.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 公司分账配置对象 company_div_config
+ *
+ * @author fs
+ * @date 2025-10-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CompanyDivConfig extends BaseEntity{
+
+    /** 公司id */
+    @TableId
+    private Long companyId;
+
+    /** 公司名称 */
+    @Excel(name = "公司名称")
+    private String companyName;
+
+    /** 是否开启分账 0:否 1:是 */
+    @Excel(name = "是否开启分账 0:否 1:是")
+    private Integer divFlag;
+
+    /** 分账模式 Y:延迟分账 N:实时分账 */
+    @Excel(name = "分账模式 Y:延迟分账 N:实时分账")
+    private String delayAcctFlag;
+
+    /** 是否使用百分比分账 */
+    @Excel(name = "是否使用百分比分账")
+    private String percentageFlag;
+
+    /** 是否净值分账 */
+    @Excel(name = "是否净值分账")
+    private String isCleanSplit;
+
+    /** 分账对象 */
+    @Excel(name = "分账对象")
+    private String acctInfos;
+
+
+}

+ 55 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyDivItem.java

@@ -0,0 +1,55 @@
+package com.fs.company.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 分账明细对象 company_div_item
+ *
+ * @author fs
+ * @date 2025-10-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CompanyDivItem extends BaseEntity{
+
+    @TableId
+    private Long id;
+
+//    /** 订单id */
+//    @Excel(name = "订单id")
+//    private Long orderId;
+
+    /** 订单编号 */
+    @Excel(name = "订单编号")
+    private String orderCode;
+
+    /** 支付订单号 */
+    @Excel(name = "支付订单号")
+    private String payCode;
+
+    /** 分账明细 */
+    @Excel(name = "分账明细")
+    private String detail;
+
+    /** 分账明细 */
+    @Excel(name = "退款明细")
+    private String refundDetail;
+
+    /** 分账明细 */
+    @Excel(name = "是否支付成功 0否 1是")
+    private Integer isPay;
+
+    /** 是否延迟分账 0否 1是 */
+    @Excel(name = "是否延迟分账 0否 1是")
+    private Integer isDelay;
+
+    /** 是否退款 0否 1是 */
+    @Excel(name = "是否退款 0否 1是")
+    private Integer isRefund;
+
+
+}

+ 61 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyDivConfigMapper.java

@@ -0,0 +1,61 @@
+package com.fs.company.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.company.domain.CompanyDivConfig;
+
+/**
+ * 公司分账配置Mapper接口
+ *
+ * @author fs
+ * @date 2025-10-20
+ */
+public interface CompanyDivConfigMapper extends BaseMapper<CompanyDivConfig>{
+    /**
+     * 查询公司分账配置
+     *
+     * @param companyId 公司分账配置主键
+     * @return 公司分账配置
+     */
+    CompanyDivConfig selectCompanyDivConfigByCompanyId(Long companyId);
+
+    /**
+     * 查询公司分账配置列表
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 公司分账配置集合
+     */
+    List<CompanyDivConfig> selectCompanyDivConfigList(CompanyDivConfig companyDivConfig);
+
+    /**
+     * 新增公司分账配置
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 结果
+     */
+    int insertCompanyDivConfig(CompanyDivConfig companyDivConfig);
+
+    /**
+     * 修改公司分账配置
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 结果
+     */
+    int updateCompanyDivConfig(CompanyDivConfig companyDivConfig);
+
+    /**
+     * 删除公司分账配置
+     *
+     * @param companyId 公司分账配置主键
+     * @return 结果
+     */
+    int deleteCompanyDivConfigByCompanyId(Long companyId);
+
+    /**
+     * 批量删除公司分账配置
+     *
+     * @param companyIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteCompanyDivConfigByCompanyIds(Long[] companyIds);
+}

+ 65 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyDivItemMapper.java

@@ -0,0 +1,65 @@
+package com.fs.company.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.company.domain.CompanyDivItem;
+
+/**
+ * 分账明细Mapper接口
+ *
+ * @author fs
+ * @date 2025-10-21
+ */
+public interface CompanyDivItemMapper extends BaseMapper<CompanyDivItem>{
+    /**
+     * 查询分账明细
+     *
+     * @param id 分账明细主键
+     * @return 分账明细
+     */
+    CompanyDivItem selectCompanyDivItemById(Long id);
+
+    /**
+     * 查询分账明细列表
+     *
+     * @param companyDivItem 分账明细
+     * @return 分账明细集合
+     */
+    List<CompanyDivItem> selectCompanyDivItemList(CompanyDivItem companyDivItem);
+
+    /**
+     * 新增分账明细
+     *
+     * @param companyDivItem 分账明细
+     * @return 结果
+     */
+    int insertCompanyDivItem(CompanyDivItem companyDivItem);
+
+    /**
+     * 修改分账明细
+     *
+     * @param companyDivItem 分账明细
+     * @return 结果
+     */
+    int updateCompanyDivItem(CompanyDivItem companyDivItem);
+
+    /**
+     * 删除分账明细
+     *
+     * @param id 分账明细主键
+     * @return 结果
+     */
+    int deleteCompanyDivItemById(Long id);
+
+    /**
+     * 批量删除分账明细
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteCompanyDivItemByIds(Long[] ids);
+
+    CompanyDivItem selectCompanyDivItemByOrderCode(String orderCode);
+
+    CompanyDivItem selectCompanyDivItemByPayCode(String payCode);
+}

+ 19 - 0
fs-service/src/main/java/com/fs/company/param/CompanyAcctInfo.java

@@ -0,0 +1,19 @@
+package com.fs.company.param;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+@Data
+public class CompanyAcctInfo {
+    //分账金额
+    private BigDecimal divAmt;
+    //分账接收方ID
+    @NotNull(message = "分账接收方ID不能为空")
+    private String huifuId;
+    //	账户号
+    private String acctId;
+    //分账百分比%
+    private Float percentageDiv;
+}

+ 40 - 0
fs-service/src/main/java/com/fs/company/param/CompanyDivConfigUpdateParam.java

@@ -0,0 +1,40 @@
+package com.fs.company.param;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CompanyDivConfigUpdateParam {
+    /** 公司id */
+    @TableId
+    private Long companyId;
+
+    /** 公司名称 */
+    @Excel(name = "公司名称")
+    private String companyName;
+
+    /** 是否开启分账 0:否 1:是 */
+    @Excel(name = "是否开启分账 0:否 1:是")
+    private Integer divFlag;
+
+    /** 分账模式 Y:延迟分账 N:实时分账 */
+    @Excel(name = "分账模式 Y:延迟分账 N:实时分账")
+    private String delayAcctFlag;
+
+    /** 是否使用百分比分账 */
+    @Excel(name = "是否使用百分比分账")
+    private String percentageFlag;
+
+    /** 是否净值分账 */
+    @Excel(name = "是否净值分账")
+    private String isCleanSplit;
+
+    /** 分账对象 */
+    @Excel(name = "分账对象")
+    private List<CompanyAcctInfo> acctInfos;
+
+    private Integer isAdd; //是否新增 1:是
+}

+ 66 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyDivConfigService.java

@@ -0,0 +1,66 @@
+package com.fs.company.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.common.core.domain.R;
+import com.fs.company.domain.CompanyDivConfig;
+import com.fs.company.param.CompanyDivConfigUpdateParam;
+import com.fs.company.vo.CompanyDivConfigVo;
+
+/**
+ * 公司分账配置Service接口
+ *
+ * @author fs
+ * @date 2025-10-20
+ */
+public interface ICompanyDivConfigService extends IService<CompanyDivConfig>{
+    /**
+     * 查询公司分账配置
+     *
+     * @param companyId 公司分账配置主键
+     * @return 公司分账配置
+     */
+    CompanyDivConfigVo selectCompanyDivConfigByCompanyId(Long companyId);
+
+    /**
+     * 查询公司分账配置列表
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 公司分账配置集合
+     */
+    List<CompanyDivConfig> selectCompanyDivConfigList(CompanyDivConfig companyDivConfig);
+
+    /**
+     * 新增公司分账配置
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 结果
+     */
+    int insertCompanyDivConfig(CompanyDivConfig companyDivConfig);
+
+    /**
+     * 修改公司分账配置
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 结果
+     */
+    int updateCompanyDivConfig(CompanyDivConfig companyDivConfig);
+
+    /**
+     * 批量删除公司分账配置
+     *
+     * @param companyIds 需要删除的公司分账配置主键集合
+     * @return 结果
+     */
+    int deleteCompanyDivConfigByCompanyIds(Long[] companyIds);
+
+    /**
+     * 删除公司分账配置信息
+     *
+     * @param companyId 公司分账配置主键
+     * @return 结果
+     */
+    int deleteCompanyDivConfigByCompanyId(Long companyId);
+
+    R setDiv(CompanyDivConfigUpdateParam param);
+}

+ 65 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyDivItemService.java

@@ -0,0 +1,65 @@
+package com.fs.company.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.company.domain.CompanyDivItem;
+
+/**
+ * 分账明细Service接口
+ *
+ * @author fs
+ * @date 2025-10-21
+ */
+public interface ICompanyDivItemService extends IService<CompanyDivItem>{
+    /**
+     * 查询分账明细
+     *
+     * @param id 分账明细主键
+     * @return 分账明细
+     */
+    CompanyDivItem selectCompanyDivItemById(Long id);
+
+    /**
+     * 查询分账明细列表
+     *
+     * @param companyDivItem 分账明细
+     * @return 分账明细集合
+     */
+    List<CompanyDivItem> selectCompanyDivItemList(CompanyDivItem companyDivItem);
+
+    /**
+     * 新增分账明细
+     *
+     * @param companyDivItem 分账明细
+     * @return 结果
+     */
+    int insertCompanyDivItem(CompanyDivItem companyDivItem);
+
+    /**
+     * 修改分账明细
+     *
+     * @param companyDivItem 分账明细
+     * @return 结果
+     */
+    int updateCompanyDivItem(CompanyDivItem companyDivItem);
+
+    /**
+     * 批量删除分账明细
+     *
+     * @param ids 需要删除的分账明细主键集合
+     * @return 结果
+     */
+    int deleteCompanyDivItemByIds(Long[] ids);
+
+    /**
+     * 删除分账明细信息
+     *
+     * @param id 分账明细主键
+     * @return 结果
+     */
+    int deleteCompanyDivItemById(Long id);
+
+    CompanyDivItem selectCompanyDivItemByOrderCode(String orderCode);
+
+    CompanyDivItem selectCompanyDivItemByPayCode(String payCode);
+}

+ 179 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyDivConfigServiceImpl.java

@@ -0,0 +1,179 @@
+package com.fs.company.service.impl;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import com.alibaba.fastjson.JSON;
+import com.fs.common.core.domain.R;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.common.utils.StringUtils;
+import com.fs.company.domain.CompanyDivConfig;
+import com.fs.company.mapper.CompanyDivConfigMapper;
+import com.fs.company.param.CompanyAcctInfo;
+import com.fs.company.param.CompanyDivConfigUpdateParam;
+import com.fs.company.service.ICompanyDivConfigService;
+import com.fs.company.vo.CompanyDivConfigVo;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 公司分账配置Service业务层处理
+ *
+ * @author fs
+ * @date 2025-10-20
+ */
+@Service
+public class CompanyDivConfigServiceImpl extends ServiceImpl<CompanyDivConfigMapper, CompanyDivConfig> implements ICompanyDivConfigService {
+    @Autowired
+    private CompanyDivConfigMapper companyDivConfigMapper;
+
+    /**
+     * 查询公司分账配置
+     *
+     * @param companyId 公司分账配置主键
+     * @return 公司分账配置
+     */
+    @Override
+    public CompanyDivConfigVo selectCompanyDivConfigByCompanyId(Long companyId)
+    {
+        CompanyDivConfig companyDivConfig = baseMapper.selectCompanyDivConfigByCompanyId(companyId);
+        if (companyDivConfig == null){
+            return null;
+        }
+        CompanyDivConfigVo vo = new CompanyDivConfigVo();
+        BeanUtils.copyProperties(companyDivConfig, vo);
+        String acctInfosStr = companyDivConfig.getAcctInfos();
+        if (StringUtils.isNotBlank(acctInfosStr)){
+            List<CompanyAcctInfo> acctInfos = JSON.parseArray(acctInfosStr, CompanyAcctInfo.class);
+            vo.setAcctInfos(acctInfos);
+        }
+        return vo;
+    }
+
+    /**
+     * 查询公司分账配置列表
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 公司分账配置
+     */
+    @Override
+    public List<CompanyDivConfig> selectCompanyDivConfigList(CompanyDivConfig companyDivConfig)
+    {
+        return baseMapper.selectCompanyDivConfigList(companyDivConfig);
+    }
+
+    /**
+     * 新增公司分账配置
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 结果
+     */
+    @Override
+    public int insertCompanyDivConfig(CompanyDivConfig companyDivConfig)
+    {
+        companyDivConfig.setCreateTime(DateUtils.getNowDate());
+        return baseMapper.insertCompanyDivConfig(companyDivConfig);
+    }
+
+    /**
+     * 修改公司分账配置
+     *
+     * @param companyDivConfig 公司分账配置
+     * @return 结果
+     */
+    @Override
+    public int updateCompanyDivConfig(CompanyDivConfig companyDivConfig)
+    {
+        companyDivConfig.setUpdateTime(DateUtils.getNowDate());
+        return baseMapper.updateCompanyDivConfig(companyDivConfig);
+    }
+
+    /**
+     * 批量删除公司分账配置
+     *
+     * @param companyIds 需要删除的公司分账配置主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCompanyDivConfigByCompanyIds(Long[] companyIds)
+    {
+        return baseMapper.deleteCompanyDivConfigByCompanyIds(companyIds);
+    }
+
+    /**
+     * 删除公司分账配置信息
+     *
+     * @param companyId 公司分账配置主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCompanyDivConfigByCompanyId(Long companyId)
+    {
+        return baseMapper.deleteCompanyDivConfigByCompanyId(companyId);
+    }
+
+    @Override
+    public R setDiv(CompanyDivConfigUpdateParam param) {
+        if (param.getCompanyId() == null || StringUtils.isBlank(param.getCompanyName())){
+            return R.error("公司信息不能为空!");
+        }
+        Integer divFlag = param.getDivFlag();
+        String acctInfosStr = null;
+        //分账账户
+        List<CompanyAcctInfo> acctInfos = param.getAcctInfos();
+        if (divFlag == null){
+            divFlag = 0;
+        } else if (divFlag == 1){
+            String delayAcctFlag = param.getDelayAcctFlag();
+            if (StringUtils.isBlank(delayAcctFlag)){
+                return R.error("分账模式不能为空!");
+            }
+
+            if (acctInfos == null || acctInfos.isEmpty()){
+                return R.error("分账接收方不能为空!");
+            }
+            acctInfosStr = JSON.toJSONString(acctInfos);
+        }
+        CompanyDivConfig companyDivConfig = new CompanyDivConfig();
+        BeanUtils.copyProperties(param, companyDivConfig);
+        companyDivConfig.setAcctInfos(acctInfosStr);
+        String percentageFlag = companyDivConfig.getPercentageFlag();
+        if (acctInfos != null && !acctInfos.isEmpty()){
+            if (StringUtils.isNotBlank(percentageFlag) && percentageFlag.equals("Y")){
+                if (StringUtils.isBlank(companyDivConfig.getIsCleanSplit())){
+                    companyDivConfig.setIsCleanSplit("N");
+                }
+            }
+            Float total = 0f;
+            for (CompanyAcctInfo acctInfo : acctInfos) {
+                if ("N".equals(percentageFlag)){
+                    if (BigDecimal.valueOf(0.01).compareTo(acctInfo.getDivAmt())>0) {
+                        return R.error("分账接收方:"+acctInfo.getHuifuId()+"分账金额必须大于0.01!");
+                    }
+                } else if ("Y".equals(percentageFlag)){
+                    if (acctInfo.getPercentageDiv()>100) {
+                        return R.error("分账接收方:"+acctInfo.getHuifuId()+"分账百分比不能大于100!");
+                    }
+                    total = total + acctInfo.getPercentageDiv();
+                    if (total>100){
+                        return R.error("分账接收方百分比之和不能大于100!");
+                    }
+                }
+            }
+        }
+        int flag = 0;
+        if (param.getIsAdd()!= null && param.getIsAdd() == 1){
+            //新增
+            companyDivConfig.setCreateTime(DateUtils.getNowDate());
+            flag = companyDivConfigMapper.insertCompanyDivConfig(companyDivConfig);
+        } else {
+            //更新
+            companyDivConfig.setUpdateTime(DateUtils.getNowDate());
+            flag = companyDivConfigMapper.updateCompanyDivConfig(companyDivConfig);
+        }
+
+        return flag>0?R.ok():R.error();
+    }
+}

+ 104 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyDivItemServiceImpl.java

@@ -0,0 +1,104 @@
+package com.fs.company.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.fs.company.mapper.CompanyDivItemMapper;
+import com.fs.company.domain.CompanyDivItem;
+import com.fs.company.service.ICompanyDivItemService;
+
+/**
+ * 分账明细Service业务层处理
+ *
+ * @author fs
+ * @date 2025-10-21
+ */
+@Service
+public class CompanyDivItemServiceImpl extends ServiceImpl<CompanyDivItemMapper, CompanyDivItem> implements ICompanyDivItemService {
+
+    /**
+     * 查询分账明细
+     *
+     * @param id 分账明细主键
+     * @return 分账明细
+     */
+    @Override
+    public CompanyDivItem selectCompanyDivItemById(Long id)
+    {
+        return baseMapper.selectCompanyDivItemById(id);
+    }
+
+    /**
+     * 查询分账明细列表
+     *
+     * @param companyDivItem 分账明细
+     * @return 分账明细
+     */
+    @Override
+    public List<CompanyDivItem> selectCompanyDivItemList(CompanyDivItem companyDivItem)
+    {
+        return baseMapper.selectCompanyDivItemList(companyDivItem);
+    }
+
+    /**
+     * 新增分账明细
+     *
+     * @param companyDivItem 分账明细
+     * @return 结果
+     */
+    @Override
+    public int insertCompanyDivItem(CompanyDivItem companyDivItem)
+    {
+        companyDivItem.setCreateTime(DateUtils.getNowDate());
+        return baseMapper.insertCompanyDivItem(companyDivItem);
+    }
+
+    /**
+     * 修改分账明细
+     *
+     * @param companyDivItem 分账明细
+     * @return 结果
+     */
+    @Override
+    public int updateCompanyDivItem(CompanyDivItem companyDivItem)
+    {
+        companyDivItem.setUpdateTime(DateUtils.getNowDate());
+        return baseMapper.updateCompanyDivItem(companyDivItem);
+    }
+
+    /**
+     * 批量删除分账明细
+     *
+     * @param ids 需要删除的分账明细主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCompanyDivItemByIds(Long[] ids)
+    {
+        return baseMapper.deleteCompanyDivItemByIds(ids);
+    }
+
+    /**
+     * 删除分账明细信息
+     *
+     * @param id 分账明细主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCompanyDivItemById(Long id)
+    {
+        return baseMapper.deleteCompanyDivItemById(id);
+    }
+
+    @Override
+    public CompanyDivItem selectCompanyDivItemByOrderCode(String orderCode) {
+        return baseMapper.selectCompanyDivItemByOrderCode(orderCode);
+    }
+
+    @Override
+    public CompanyDivItem selectCompanyDivItemByPayCode(String payCode) {
+        return baseMapper.selectCompanyDivItemByPayCode(payCode);
+    }
+}

+ 11 - 9
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -370,15 +370,17 @@ public class CompanyServiceImpl implements ICompanyService
                 String json =configService.selectConfigByKey("his.store");
                 StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
                 //支付金额-(订单金额*rate%)
-                Double rate=config.getTuiMoneyRate()/100d;
-                BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
-                logger.info("写入公司推广佣金:"+tuiMoney);
-                company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
-                companyMapper.updateCompany(company);
-                FsStoreOrderScrm storeOrderMap=new FsStoreOrderScrm();
-                storeOrderMap.setId(order.getId());
-                storeOrderMap.setTuiMoney(tuiMoney);
-                storeOrderScrmMapper.updateFsStoreOrder(storeOrderMap);
+                if (config.getTuiMoneyRate()!=null){
+                    Double rate=config.getTuiMoneyRate()/100d;
+                    BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
+                    logger.info("写入公司推广佣金:"+tuiMoney);
+                    company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
+                    companyMapper.updateCompany(company);
+                    FsStoreOrderScrm storeOrderMap=new FsStoreOrderScrm();
+                    storeOrderMap.setId(order.getId());
+                    storeOrderMap.setTuiMoney(tuiMoney);
+                    storeOrderScrmMapper.updateFsStoreOrder(storeOrderMap);
+                }
             }
         }
     }

+ 41 - 0
fs-service/src/main/java/com/fs/company/vo/CompanyDivConfigVo.java

@@ -0,0 +1,41 @@
+package com.fs.company.vo;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import com.fs.company.param.CompanyAcctInfo;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CompanyDivConfigVo {
+    /** 公司id */
+    @TableId
+    private Long companyId;
+
+    /** 公司名称 */
+    @Excel(name = "公司名称")
+    private String companyName;
+
+    /** 是否开启分账 0:否 1:是 */
+    @Excel(name = "是否开启分账 0:否 1:是")
+    private Integer divFlag;
+
+    /** 分账模式 Y:延迟分账 N:实时分账 */
+    @Excel(name = "分账模式 Y:延迟分账 N:实时分账")
+    private String delayAcctFlag;
+
+    /** 是否使用百分比分账 */
+    @Excel(name = "是否使用百分比分账")
+    private String percentageFlag;
+
+    /** 是否净值分账 */
+    @Excel(name = "是否净值分账")
+    private String isCleanSplit;
+
+    /** 分账对象 */
+    @Excel(name = "分账对象")
+    private List<CompanyAcctInfo> acctInfos;
+
+    private Integer isAdd; //是否新增 1:是
+}

+ 6 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseWatchLogListParam.java

@@ -93,4 +93,10 @@ public class FsCourseWatchLogListParam implements Serializable {
      * sop主键id
      */
     private String sopId;
+
+    /**
+     * 企微名称
+     */
+    private String qwUserName;
+
 }

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

@@ -1484,7 +1484,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             Company company = companyMapper.selectCompanyById(param.getCompanyId());
             BigDecimal money = company.getMoney();
             if (money.compareTo(BigDecimal.ZERO)<=0) {
-                return R.error("服务商余额不足,请联系群主服务充值!");
+                return R.error("服务商余额不足,请联系群主服务充值!");
             }
 
             // 发送红包
@@ -1719,6 +1719,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         FsUserCourseVideoDetailsVO fsUserCourseVideoDetailsVO = new FsUserCourseVideoDetailsVO();
         BeanUtils.copyProperties(fsUserCourseVideo, fsUserCourseVideoDetailsVO);
 
+        //这里 改成取线路一值,返回给前端。VideoUrl 是原视频(用来算流量的),不要去改,lineOne是转码后的视频
+        fsUserCourseVideoDetailsVO.setVideoUrl(fsUserCourseVideo.getLineOne());
+
         // 获取课程相关的题库
         String questionBankId = fsUserCourseVideo.getQuestionBankId();
         List<FsUserVideoQuestionVO> questionList = Collections.emptyList();

+ 8 - 18
fs-service/src/main/java/com/fs/erp/dto/sdk/df/DfClient.java

@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSON;
 import com.fs.erp.dto.df.DFConfigVo;
 import com.fs.erp.dto.sdk.df.enums.RequestUrlEnum;
 import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.FsDfAccount;
+import com.fs.his.mapper.FsDfAccountMapper;
 import com.fs.his.utils.ConfigUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Hex;
@@ -43,26 +45,13 @@ import java.util.Objects;
 public class DfClient {
 	@Autowired
 	ConfigUtil configUtil;
+	@Autowired
+	private FsDfAccountMapper fsDfAccountMapper;
 	private final String baseUrl = "https://ds-api.sf-express.com/externalapi/";
 	public static final String CHARSET = "UTF-8";
 	public static final String CONTENT_TYPE = "application/json";
 
 
-	private String getAppKey(int i) {
-		FsSysConfig sysConfig = configUtil.getSysConfig();
-		String dfConfigVo = sysConfig.getDfAccounts();
-		List<DFConfigVo> dfConfigVos = JSON.parseArray(dfConfigVo, DFConfigVo.class);
-		return dfConfigVos.get(i).getDfAppKey();
-	}
-
-	private String getAppsecret(int i) {
-		FsSysConfig sysConfig = configUtil.getSysConfig();
-		String dfConfigVo = sysConfig.getDfAccounts();
-		List<DFConfigVo> dfConfigVos = JSON.parseArray(dfConfigVo, DFConfigVo.class);
-		return dfConfigVos.get(i).getDfAppsecret();
-	}
-
-
 
 
 	private DfClient(){}
@@ -94,9 +83,10 @@ public class DfClient {
 		return Hex.encodeHexString(bytes);
 	}
 
-	public String execute(RequestUrlEnum request, Map<String, Object> params,int i) throws IOException {
-		String appkey = getAppKey(i);
-		String appsecret = getAppsecret(i);
+	public String execute(RequestUrlEnum request, Map<String, Object> params,Long dfAccountId) throws IOException {
+		FsDfAccount dfAccount = fsDfAccountMapper.selectFsDfAccountById(dfAccountId);
+		String appkey = dfAccount.getDfAppKey();
+		String appsecret = dfAccount.getDfAppsecret();
 		String timestamp = String.valueOf(System.currentTimeMillis());
 		String relativeUrl = request.getUrl();
 		String type = request.getType();

+ 254 - 70
fs-service/src/main/java/com/fs/erp/service/impl/DfOrderServiceImpl.java

@@ -27,6 +27,13 @@ import com.fs.his.service.IFsExpressService;
 import com.fs.his.service.IFsStoreOrderLogsService;
 import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.hisStore.domain.FsStoreOrderItemScrm;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
+import com.fs.hisStore.domain.FsStoreProductScrm;
+import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
+import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
+import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
 import com.hc.openapi.tool.util.StringUtils;
@@ -46,18 +53,30 @@ import java.util.concurrent.atomic.AtomicBoolean;
 @Slf4j
 public class DfOrderServiceImpl implements IErpOrderService
 {
+//    @Autowired
+//    ConfigUtil configUtil;
+
     @Autowired
-    ConfigUtil configUtil;
+    FsDfAccountMapper fsDfAccountMapper;
 
     @Autowired
     private FsStoreOrderMapper fsStoreOrderMapper;
 
+    @Autowired
+    private FsStoreOrderScrmMapper fsStoreOrderScrmMapper;
+
     @Autowired
     private FsStoreOrderItemMapper fsStoreOrderItemMapper;
 
+    @Autowired
+    private FsStoreOrderItemScrmMapper fsStoreOrderItemScrmMapper;
+
     @Autowired
     private FsStoreProductMapper fsStoreProductMapper;
 
+    @Autowired
+    private FsStoreProductScrmMapper fsStoreProductScrmMapper;
+
     @Autowired
     private FsStoreOrderDfMapper fsStoreOrderDfMapper;
 
@@ -92,7 +111,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 
     @Override
     public ErpOrderResponse addOrderScrm(ErpOrder order) {
-        return null;
+        return getScrmErpOrderResponse(order);
     }
 
     /**
@@ -110,19 +129,19 @@ public class DfOrderServiceImpl implements IErpOrderService
         if (df == null){
             return null;
         }
-        Integer sfAccountIndex = getSFAccountIndex(fsStoreOrder.getOrderId());
+        Long dfAccountId = getSFAccountIndex(fsStoreOrder.getOrderId());
         HashMap<String, Object> map = new HashMap<>();
         map.put("loginAccount", df.getLoginAccount());
-        DFConfigVo config = getconfig(sfAccountIndex);
-        if (config != null && StringUtils.isNotBlank(config.getCallBackUrl())) {
-            map.put("callBackUrl", config.getCallBackUrl());
+        FsDfAccount dfAccount = fsDfAccountMapper.selectFsDfAccountById(dfAccountId);
+        if (dfAccount != null && StringUtils.isNotBlank(dfAccount.getCallBackUrl())) {
+            map.put("callBackUrl", dfAccount.getCallBackUrl());
         }
         map.put("orderNumber", orderCode);
         map.put("mailNumber", fsStoreOrder.getDeliverySn());
         try {
             //2.请求
             log.info("开始取消订单,参数: {}", JSON.toJSONString(map));
-            String response = client.execute(RequestUrlEnum.ORDER_CANCEL, map, sfAccountIndex);
+            String response = client.execute(RequestUrlEnum.ORDER_CANCEL, map, dfAccountId);
             DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
             //3.处理请求结果
             if (dfApiResponse != null && "ok".equals(dfApiResponse.getCode())) {
@@ -158,13 +177,13 @@ public class DfOrderServiceImpl implements IErpOrderService
             FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderCode);
             if (order != null) {
                 String mailNumber = order.getDeliverySn();
-                Integer sfAccountIndex = getSFAccountIndex(order.getOrderId());
-                if (StringUtils.isNotBlank(mailNumber) && sfAccountIndex > -1) {
+                Long dfAccountId = getSFAccountIndex(order.getOrderId());
+                if (StringUtils.isNotBlank(mailNumber) && dfAccountId != null) {
                     try {
                         Map<String, Object> map = new HashMap<>();
                         map.put("mailNumber", mailNumber);
                         log.info("开始查询路由结果,参数为: {}", JSON.toJSONString(map));
-                        String response = client.execute(RequestUrlEnum.ORDER_DELIVERY, map, sfAccountIndex);
+                        String response = client.execute(RequestUrlEnum.ORDER_DELIVERY, map, dfAccountId);
                         DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
                         if (dfApiResponse != null && "ok".equals(dfApiResponse.getCode())) {
                             dfApiResponse.setCode(mailNumber);
@@ -224,12 +243,12 @@ public class DfOrderServiceImpl implements IErpOrderService
                 if(df == null){
                     return null;
                 }
-                Integer sfAccountIndex = getSFAccountIndex(order.getOrderId());
-                if (sfAccountIndex > -1) {
+                Long dfAccountId = getSFAccountIndex(order.getOrderId());
+                if (dfAccountId != null) {
                     Map<String, Object> orderResultQueryParam = new HashMap<>();
                     orderResultQueryParam.put("orderNumber", orderNumber);
                     orderResultQueryParam.put("exInterfaceType", df.getStatus());
-                    getOrderResult(orderResultQueryParam, sfAccountIndex);
+                    getOrderResult(orderResultQueryParam, dfAccountId);
                     return response;
                 }
             }
@@ -260,11 +279,11 @@ public class DfOrderServiceImpl implements IErpOrderService
     @Override
     public void getOrderDeliveryStatus(FsStoreOrder order) {
         Map<String, Object> map = new HashMap<>();
-        Integer sfAccountIndex = getSFAccountIndex(order.getOrderId());
+        Long dfAccountId = getSFAccountIndex(order.getOrderId());
         map.put("orderNumber", order.getOrderCode());
         map.put("mailNumber", order.getDeliverySn());
         try {
-            String response = client.execute(RequestUrlEnum.ORDER_DELIVERY_STATUS, map, sfAccountIndex);
+            String response = client.execute(RequestUrlEnum.ORDER_DELIVERY_STATUS, map, dfAccountId);
             DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
             if ("运单不存在".equals(dfApiResponse.getMsg())){
 
@@ -380,6 +399,56 @@ public class DfOrderServiceImpl implements IErpOrderService
         df.setUpdateTime(new Date());
         fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
     }
+    /**
+     * 获取erp推送参数
+     *
+     * @param order 订单参数
+     * @return
+     */
+    private ErpOrderResponse getScrmErpOrderResponse(ErpOrder order) {
+
+        FsStoreOrderScrm fsStoreOrder = fsStoreOrderScrmMapper.selectFsStoreOrderByOrderCode(order.getPlatform_code());
+        if (fsStoreOrder == null) {
+            return null;
+        }
+        Long dfAccountId = getSFAccountIndex(fsStoreOrder.getId());
+        //1.获取请求参数
+        ExternalOrderRequestVo vo = getCreateScrmOrderRequestParam(order, fsStoreOrder, dfAccountId);
+        if (vo == null) {
+            return null;
+        }
+        try {
+            Map<String, Object> map = JSON.parseObject(JSON.toJSONString(vo), Map.class);
+            //2.请求
+            log.info("开始推送订单,参数: {}", JSON.toJSONString(map));
+            String response = client.execute(RequestUrlEnum.CREAT_ORDER, map, dfAccountId);
+            DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
+            //3.处理请求结果
+            if (dfApiResponse != null && "ok".equals(dfApiResponse.getCode())) {
+                //存储订单推送用的哪个账户
+                FsStoreOrderDf df = addDfOrderScrm(fsStoreOrder, dfAccountId);
+                log.info("订单推送成功: {}", response);
+                //可以回调 也可以查询订单
+                Map<String, Object> orderResultQueryParam = new HashMap<>();
+                orderResultQueryParam.put("orderNumber", order.getPlatform_code());
+                orderResultQueryParam.put("exInterfaceType", df.getStatus());
+                try {
+                    getOrderResult(orderResultQueryParam,dfAccountId);
+                } catch (Exception e) {
+                    log.info("推送订单完成,查询订单问题{}", e.getMessage());
+                }
+                ErpOrderResponse erpOrderResponse = new ErpOrderResponse();
+                erpOrderResponse.setCode(order.getPlatform_code());
+                erpOrderResponse.setSuccess(true);
+                return erpOrderResponse;
+            } else {
+                throw new RuntimeException(String.format("订单推送失败,原因: %s", dfApiResponse.getMsg()));
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return new ErpOrderResponse();
+    }
 
     /**
      * 获取erp推送参数
@@ -393,9 +462,9 @@ public class DfOrderServiceImpl implements IErpOrderService
         if (fsStoreOrder == null) {
             return null;
         }
-        int sfAccountIndex = getSFAccountIndex(fsStoreOrder.getOrderId());
+        Long dfAccountId = getSFAccountIndex(fsStoreOrder.getOrderId());
         //1.获取请求参数
-        ExternalOrderRequestVo vo = getCreateOrderRequestParam(order, fsStoreOrder, sfAccountIndex);
+        ExternalOrderRequestVo vo = getCreateOrderRequestParam(order, fsStoreOrder, dfAccountId);
         if (vo == null) {
             return null;
         }
@@ -403,19 +472,19 @@ public class DfOrderServiceImpl implements IErpOrderService
             Map<String, Object> map = JSON.parseObject(JSON.toJSONString(vo), Map.class);
             //2.请求
             log.info("开始推送订单,参数: {}", JSON.toJSONString(map));
-            String response = client.execute(RequestUrlEnum.CREAT_ORDER, map, sfAccountIndex);
+            String response = client.execute(RequestUrlEnum.CREAT_ORDER, map, dfAccountId);
             DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
             //3.处理请求结果
             if (dfApiResponse != null && "ok".equals(dfApiResponse.getCode())) {
                 //存储订单推送用的哪个账户
-                FsStoreOrderDf df = addDfOrder(fsStoreOrder, sfAccountIndex);
+                FsStoreOrderDf df = addDfOrder(fsStoreOrder, dfAccountId);
                 log.info("订单推送成功: {}", response);
                 //可以回调 也可以查询订单
                 Map<String, Object> orderResultQueryParam = new HashMap<>();
                 orderResultQueryParam.put("orderNumber", order.getPlatform_code());
                 orderResultQueryParam.put("exInterfaceType", df.getStatus());
                 try {
-                    getOrderResult(orderResultQueryParam,sfAccountIndex);
+                    getOrderResult(orderResultQueryParam,dfAccountId);
                 } catch (Exception e) {
                     log.info("推送订单完成,查询订单问题{}", e.getMessage());
                 }
@@ -432,16 +501,42 @@ public class DfOrderServiceImpl implements IErpOrderService
         return new ErpOrderResponse();
     }
 
-    private @NotNull FsStoreOrderDf addDfOrder(FsStoreOrder fsStoreOrder, int sfAccountIndex) {
+    private @NotNull FsStoreOrderDf addDfOrderScrm(FsStoreOrderScrm fsStoreOrder, Long dfAccountId) {
+        FsStoreOrderDf df = new FsStoreOrderDf();
+        df.setOrderId(fsStoreOrder.getId());
+        df.setOrderCode(fsStoreOrder.getOrderCode());
+        FsDfAccount dfAccount = fsDfAccountMapper.selectFsDfAccountById(dfAccountId);
+        df.setAppKey(dfAccount.getDfAppKey());
+        df.setAppSecret(dfAccount.getDfAppsecret());
+        df.setLoginAccount(dfAccount.getLoginAccount());
+        df.setMonthlyCard(dfAccount.getMonthlyCard());
+        df.setExpressProductCode(dfAccount.getExpressProductCode());
+        df.setTotalPrice(fsStoreOrder.getPayMoney());
+        df.setPlatformPrice(fsStoreOrder.getPayPrice());
+        df.setStatus(1);
+        //查询是否存在
+        FsStoreOrderDf temp = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(df.getOrderId());
+        if (temp != null) {
+            //修改
+            df.setUpdateTime(DateUtils.getNowDate());
+            fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
+        } else {
+            df.setCreateTime(DateUtils.getNowDate());
+            fsStoreOrderDfMapper.insertFsStoreOrderDf(df);
+        }
+        return df;
+    }
+
+    private @NotNull FsStoreOrderDf addDfOrder(FsStoreOrder fsStoreOrder, Long dfAccountId) {
         FsStoreOrderDf df = new FsStoreOrderDf();
         df.setOrderId(fsStoreOrder.getOrderId());
         df.setOrderCode(fsStoreOrder.getOrderCode());
-        DFConfigVo config = getconfig(sfAccountIndex);
-        df.setAppKey(config.getDfAppKey());
-        df.setAppSecret(config.getDfAppsecret());
-        df.setLoginAccount(config.getLoginAccount());
-        df.setMonthlyCard(config.getMonthlyCard());
-        df.setExpressProductCode(config.getExpressProductCode());
+        FsDfAccount dfAccount = fsDfAccountMapper.selectFsDfAccountById(dfAccountId);
+        df.setAppKey(dfAccount.getDfAppKey());
+        df.setAppSecret(dfAccount.getDfAppsecret());
+        df.setLoginAccount(dfAccount.getLoginAccount());
+        df.setMonthlyCard(dfAccount.getMonthlyCard());
+        df.setExpressProductCode(dfAccount.getExpressProductCode());
         df.setTotalPrice(fsStoreOrder.getPayMoney());
         df.setPlatformPrice(fsStoreOrder.getPayPrice());
         df.setStatus(1);
@@ -458,25 +553,129 @@ public class DfOrderServiceImpl implements IErpOrderService
         return df;
     }
 
+    /**
+     * 通用erpOrderScrm获取创建订单参数
+     *
+     * @param order
+     * @return
+     */
+    private ExternalOrderRequestVo getCreateScrmOrderRequestParam(ErpOrder order, FsStoreOrderScrm fsStoreOrder, Long dfAccountId) {
+        ExternalOrderRequestVo vo = new ExternalOrderRequestVo();
+        FsDfAccount dfAccount = fsDfAccountMapper.selectFsDfAccountById(dfAccountId);
+        if (dfAccount == null) {
+            return null;
+        }
+        String loginAccount = dfAccount.getLoginAccount();
+        vo.setMonthlyCard(dfAccount.getMonthlyCard()); //月结卡号
+        vo.setExpressProductCode(dfAccount.getExpressProductCode()); //物流产品编码
+
+
+        vo.setLoginAccount(loginAccount); //代服系统登录账号
+        String callBackUrl = dfAccount.getCallBackUrl();
+        if (StringUtils.isNotBlank(callBackUrl)) {
+            vo.setCallBackUrl(callBackUrl); //订单下单后异步通知地址
+        }
+        FsStoreOrderDf temp = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(fsStoreOrder.getId());
+        if (temp != null) {
+            vo.setParcelQuantity(temp.getParcelQuantity());//包裹数量
+        }
+
+        vo.setOrderNumber(order.getPlatform_code()); //订单号(不能重复)
+
+        int orderPayMethod = 0;
+        BigDecimal couponPrice = fsStoreOrder.getCouponPrice();
+        if (couponPrice == null) {
+            couponPrice = BigDecimal.ZERO;
+        }
+
+        if (ObjectUtil.equal(1, fsStoreOrder.getPayType())) {
+            //在线支付
+            orderPayMethod = 1;
+        } else { // 如果是线上付款
+            orderPayMethod = 2;
+            // 货到付款金额 = 订单剩余支付金额
+            vo.setCollectingMoney(fsStoreOrder.getDeliveryPayMoney().doubleValue());
+            vo.setCollectionCardNumber(dfAccount.getMonthlyCard()); // 就是月结账号
+        }
+        //订单付款方式 1:在线支付 2:货到付款
+        //如果填了2,代收金额必须大于0,代收卡号必填
+        vo.setOrderPayMethod(orderPayMethod);
+
+        vo.setConsignmentNumber(Integer.valueOf(Math.toIntExact(fsStoreOrder.getTotalNum()))); //托寄物数量 必填
+
+        vo.setBuyerMessage(fsStoreOrder.getRemark()); //买家留言
+
+        vo.setSenderName(dfAccount.getSenderName()); //寄件人
+        vo.setSenderPhone(dfAccount.getSenderPhone()); //寄件人手机
+        vo.setSenderProvince(dfAccount.getSenderProvince());//寄件人省
+        vo.setSenderCity(dfAccount.getSenderCity());//寄件人市
+        vo.setSenderDistrict(dfAccount.getSenderDistrict());//寄件人区
+        vo.setSenderAddress(dfAccount.getSenderAddress());//寄件人地址
+        vo.setReceiverName(order.getReceiver_name());//收件人
+        vo.setReceiverPhone(order.getReceiver_mobile()); //收件人手机
+        vo.setReceiverTelephone(order.getReceiver_phone());//收件人电话 否
+        vo.setReceiverProvince(order.getReceiver_province()); //收件人省
+        vo.setReceiverCity(order.getReceiver_city()); //收件人市
+        vo.setReceiverDistrict(order.getReceiver_district()); //收件人区
+        vo.setReceiverAddress(order.getReceiver_address()); // 收件人地址
+        vo.setExpressPayMethod(1); //物流付款方式 1:寄付月结 2:寄付现结 3:收方付 4:第三方付
+        //订单sku集合
+        StringBuilder consignmentStr = new StringBuilder();
+        List<FsStoreOrderItemVO> items = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemListByOrderId(fsStoreOrder.getId());
+        if (items != null && !items.isEmpty()) {
+            ArrayList<ExteriorOrderSkuVo> orderSkus = new ArrayList<>();
+            items.forEach(item -> {
+                ExteriorOrderSkuVo skuVo = new ExteriorOrderSkuVo();
+                FsStoreProductScrm product = fsStoreProductScrmMapper.selectFsStoreProductById(item.getProductId());
+                Asserts.check(ObjectUtils.isNotNull(product), "该产品不存在! 产品id: {} ", item.getProductId());
+                skuVo.setProductName(product.getProductName()); //商品名称
+                com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(item.getJsonInfo());
+                skuVo.setSkuCode(jsonObject.getString("sku")); //sku编码
+                skuVo.setProductCode(jsonObject.getString("barCode")); //商品编号
+                skuVo.setAttributeNames(jsonObject.getString("sku")); //商品规格,格式:颜色:红色,尺寸:L码....以此类推
+                skuVo.setProductNumber(Math.toIntExact(item.getNum())); //商品预定数量
+                skuVo.setPrice(product.getPrice().doubleValue()); //商品单价
+
+//                skuVo.setAdjustAmount(0d); //调整金额
+                // 优惠
+                skuVo.setSubAmount(product.getPrice().doubleValue() * item.getNum());
+
+                //组装寄托物
+                consignmentStr.append(product.getProductName()).append("*").append(item.getNum()).append(",");
+                orderSkus.add(skuVo);
+            });
+            if (consignmentStr.length() > 0) {
+                consignmentStr.deleteCharAt(consignmentStr.length() - 1);
+            }
+            if (consignmentStr.length() > 100) {
+                consignmentStr.delete(consignmentStr.length() - 4, consignmentStr.length());
+                consignmentStr.append("...");
+            }
+            vo.setOrderSkus(orderSkus);
+            vo.setConsignment(consignmentStr.toString()); //寄托物 必填
+        }
+        return vo;
+    }
+
     /**
      * 通用erpOrder获取创建订单参数
      *
      * @param order
      * @return
      */
-    private ExternalOrderRequestVo getCreateOrderRequestParam(ErpOrder order, FsStoreOrder fsStoreOrder, int index) {
+    private ExternalOrderRequestVo getCreateOrderRequestParam(ErpOrder order, FsStoreOrder fsStoreOrder, Long dfAccountId) {
         ExternalOrderRequestVo vo = new ExternalOrderRequestVo();
-        DFConfigVo config = getconfig(index);
-        if (config == null) {
+        FsDfAccount dfAccount = fsDfAccountMapper.selectFsDfAccountById(dfAccountId);
+        if (dfAccount == null) {
             return null;
         }
-        String loginAccount = config.getLoginAccount();
-        vo.setMonthlyCard(config.getMonthlyCard()); //月结卡号
-        vo.setExpressProductCode(config.getExpressProductCode()); //物流产品编码
+        String loginAccount = dfAccount.getLoginAccount();
+        vo.setMonthlyCard(dfAccount.getMonthlyCard()); //月结卡号
+        vo.setExpressProductCode(dfAccount.getExpressProductCode()); //物流产品编码
 
 
         vo.setLoginAccount(loginAccount); //代服系统登录账号
-        String callBackUrl = config.getCallBackUrl();
+        String callBackUrl = dfAccount.getCallBackUrl();
         if (StringUtils.isNotBlank(callBackUrl)) {
             vo.setCallBackUrl(callBackUrl); //订单下单后异步通知地址
         }
@@ -500,7 +699,7 @@ public class DfOrderServiceImpl implements IErpOrderService
             orderPayMethod = 2;
             // 货到付款金额 = 订单剩余支付金额
             vo.setCollectingMoney(fsStoreOrder.getPayRemain().doubleValue());
-            vo.setCollectionCardNumber(config.getMonthlyCard()); // 就是月结账号
+            vo.setCollectionCardNumber(dfAccount.getMonthlyCard()); // 就是月结账号
         }
         //订单付款方式 1:在线支付 2:货到付款
         //如果填了2,代收金额必须大于0,代收卡号必填
@@ -510,12 +709,12 @@ public class DfOrderServiceImpl implements IErpOrderService
 
         vo.setBuyerMessage(fsStoreOrder.getRemark()); //买家留言
 
-        vo.setSenderName(config.getSenderName()); //寄件人
-        vo.setSenderPhone(config.getSenderPhone()); //寄件人手机
-        vo.setSenderProvince(config.getSenderProvince());//寄件人省
-        vo.setSenderCity(config.getSenderCity());//寄件人市
-        vo.setSenderDistrict(config.getSenderDistrict());//寄件人区
-        vo.setSenderAddress(config.getSenderAddress());//寄件人地址
+        vo.setSenderName(dfAccount.getSenderName()); //寄件人
+        vo.setSenderPhone(dfAccount.getSenderPhone()); //寄件人手机
+        vo.setSenderProvince(dfAccount.getSenderProvince());//寄件人省
+        vo.setSenderCity(dfAccount.getSenderCity());//寄件人市
+        vo.setSenderDistrict(dfAccount.getSenderDistrict());//寄件人区
+        vo.setSenderAddress(dfAccount.getSenderAddress());//寄件人地址
         vo.setReceiverName(order.getReceiver_name());//收件人
         vo.setReceiverPhone(order.getReceiver_mobile()); //收件人手机
         vo.setReceiverTelephone(order.getReceiver_phone());//收件人电话 否
@@ -562,21 +761,6 @@ public class DfOrderServiceImpl implements IErpOrderService
         return vo;
     }
 
-    private @Nullable DFConfigVo getconfig(int index) {
-        List<DFConfigVo> dfConfigVos = getDfConfigVos();
-        DFConfigVo config = null;
-        if (dfConfigVos != null && !dfConfigVos.isEmpty()) {
-            config = dfConfigVos.get(index);
-        }
-        return config;
-    }
-
-    private @Nullable List<DFConfigVo> getDfConfigVos() {
-        FsSysConfig sysConfig = configUtil.getSysConfig();
-        String dfConfigVo = sysConfig.getDfAccounts();
-        List<DFConfigVo> dfConfigVos = JSON.parseArray(dfConfigVo, DFConfigVo.class);
-        return dfConfigVos;
-    }
 
 
     /**
@@ -584,34 +768,34 @@ public class DfOrderServiceImpl implements IErpOrderService
      *
      * @return
      */
-    private int getSFAccountIndex(Long orderId) {
+    private Long getSFAccountIndex(Long orderId) {
+        List<FsDfAccount> fsDfAccounts = fsDfAccountMapper.selectFsDfAccountList(null);
         if (orderId != null) {
             //查询是否选择erp账户
             FsStoreOrderDf temp = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(orderId);
             if (temp != null) {
-                FsSysConfig sysConfig = configUtil.getSysConfig();
-                String dfConfigVo = sysConfig.getDfAccounts();
-                List<DFConfigVo> dfConfigVos = JSON.parseArray(dfConfigVo, DFConfigVo.class);
-                if (dfConfigVos != null && !dfConfigVos.isEmpty()) {
-                    for (int i = 0; i < dfConfigVos.size(); i++) {
-                        if (temp.getLoginAccount().equals(dfConfigVos.get(i).getLoginAccount())) {
-                            return i;
+                if (fsDfAccounts != null && !fsDfAccounts.isEmpty()) {
+                    for (FsDfAccount fsDfAccount : fsDfAccounts) {
+                        if (temp.getLoginAccount().equals(fsDfAccount.getLoginAccount())) {
+                            return fsDfAccount.getId();
                         }
                     }
                 }
-                return dfConfigVos.indexOf(temp);
+                return null;
             }
         }
-        //默认用第一个
-        return 0;
-
+        if (fsDfAccounts != null && !fsDfAccounts.isEmpty()) {
+            return fsDfAccounts.get(0).getId();
+        } else {
+            return null;
+        }
     }
 
-    private void getOrderResult(Map<String, Object> map, Integer sfAccountIndex) {
+    private void getOrderResult(Map<String, Object> map, Long dfAccountId) {
         try {
             String status = map.get("exInterfaceType").toString();
             log.info("开始查询订单结果,参数为: {}", JSON.toJSONString(map));
-            String response = client.execute(RequestUrlEnum.ORDER_RESULT, map, sfAccountIndex);
+            String response = client.execute(RequestUrlEnum.ORDER_RESULT, map, dfAccountId);
             DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
             if (dfApiResponse != null && "ok".equals(dfApiResponse.getCode())) {
                 log.info("查询订单结果,结果: {}", JSON.toJSONString(dfApiResponse));

+ 74 - 0
fs-service/src/main/java/com/fs/his/domain/FsDfAccount.java

@@ -0,0 +1,74 @@
+package com.fs.his.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 代服账户对象 fs_df_account
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FsDfAccount extends BaseEntity{
+
+    @TableId
+    private Long id;
+
+    @Excel(name = "dfAppKey")
+    private String dfAppKey;
+
+    /** dfAppsecret */
+    @Excel(name = "dfAppsecret")
+    private String dfAppsecret;
+
+    /** 登录账号 */
+    @Excel(name = "登录账号")
+    private String loginAccount;
+
+    /** 回调地址 */
+    @Excel(name = "回调地址")
+    private String callBackUrl;
+
+    /** 月结账号 */
+    @Excel(name = "月结账号")
+    private String monthlyCard;
+
+    /** 物流产品编码 */
+    @Excel(name = "物流产品编码")
+    private String expressProductCode;
+
+    /** 寄件人姓名 */
+    @Excel(name = "寄件人姓名")
+    private String senderName;
+
+    /** 寄件人手机 */
+    @Excel(name = "寄件人手机")
+    private String senderPhone;
+
+    private String cityIds;
+
+    /** 寄件人省 */
+    @Excel(name = "寄件人省")
+    private String senderProvince;
+
+    /** 寄件人市 */
+    @Excel(name = "寄件人市")
+    private String senderCity;
+
+    /** 寄件人区 */
+    @Excel(name = "寄件人区")
+    private String senderDistrict;
+
+    /** 寄件人地址 */
+    @Excel(name = "寄件人地址")
+    private String senderAddress;
+
+
+}

+ 61 - 0
fs-service/src/main/java/com/fs/his/mapper/FsDfAccountMapper.java

@@ -0,0 +1,61 @@
+package com.fs.his.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.his.domain.FsDfAccount;
+
+/**
+ * 代服账户Mapper接口
+ * 
+ * @author fs
+ * @date 2025-10-13
+ */
+public interface FsDfAccountMapper extends BaseMapper<FsDfAccount>{
+    /**
+     * 查询代服账户
+     * 
+     * @param id 代服账户主键
+     * @return 代服账户
+     */
+    FsDfAccount selectFsDfAccountById(Long id);
+
+    /**
+     * 查询代服账户列表
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 代服账户集合
+     */
+    List<FsDfAccount> selectFsDfAccountList(FsDfAccount fsDfAccount);
+
+    /**
+     * 新增代服账户
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 结果
+     */
+    int insertFsDfAccount(FsDfAccount fsDfAccount);
+
+    /**
+     * 修改代服账户
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 结果
+     */
+    int updateFsDfAccount(FsDfAccount fsDfAccount);
+
+    /**
+     * 删除代服账户
+     * 
+     * @param id 代服账户主键
+     * @return 结果
+     */
+    int deleteFsDfAccountById(Long id);
+
+    /**
+     * 批量删除代服账户
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteFsDfAccountByIds(Long[] ids);
+}

+ 61 - 0
fs-service/src/main/java/com/fs/his/service/IFsDfAccountService.java

@@ -0,0 +1,61 @@
+package com.fs.his.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.his.domain.FsDfAccount;
+
+/**
+ * 代服账户Service接口
+ * 
+ * @author fs
+ * @date 2025-10-13
+ */
+public interface IFsDfAccountService extends IService<FsDfAccount>{
+    /**
+     * 查询代服账户
+     * 
+     * @param id 代服账户主键
+     * @return 代服账户
+     */
+    FsDfAccount selectFsDfAccountById(Long id);
+
+    /**
+     * 查询代服账户列表
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 代服账户集合
+     */
+    List<FsDfAccount> selectFsDfAccountList(FsDfAccount fsDfAccount);
+
+    /**
+     * 新增代服账户
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 结果
+     */
+    int insertFsDfAccount(FsDfAccount fsDfAccount);
+
+    /**
+     * 修改代服账户
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 结果
+     */
+    int updateFsDfAccount(FsDfAccount fsDfAccount);
+
+    /**
+     * 批量删除代服账户
+     * 
+     * @param ids 需要删除的代服账户主键集合
+     * @return 结果
+     */
+    int deleteFsDfAccountByIds(Long[] ids);
+
+    /**
+     * 删除代服账户信息
+     * 
+     * @param id 代服账户主键
+     * @return 结果
+     */
+    int deleteFsDfAccountById(Long id);
+}

+ 94 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsDfAccountServiceImpl.java

@@ -0,0 +1,94 @@
+package com.fs.his.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.fs.his.mapper.FsDfAccountMapper;
+import com.fs.his.domain.FsDfAccount;
+import com.fs.his.service.IFsDfAccountService;
+
+/**
+ * 代服账户Service业务层处理
+ * 
+ * @author fs
+ * @date 2025-10-13
+ */
+@Service
+public class FsDfAccountServiceImpl extends ServiceImpl<FsDfAccountMapper, FsDfAccount> implements IFsDfAccountService {
+
+    /**
+     * 查询代服账户
+     * 
+     * @param id 代服账户主键
+     * @return 代服账户
+     */
+    @Override
+    public FsDfAccount selectFsDfAccountById(Long id)
+    {
+        return baseMapper.selectFsDfAccountById(id);
+    }
+
+    /**
+     * 查询代服账户列表
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 代服账户
+     */
+    @Override
+    public List<FsDfAccount> selectFsDfAccountList(FsDfAccount fsDfAccount)
+    {
+        return baseMapper.selectFsDfAccountList(fsDfAccount);
+    }
+
+    /**
+     * 新增代服账户
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 结果
+     */
+    @Override
+    public int insertFsDfAccount(FsDfAccount fsDfAccount)
+    {
+        fsDfAccount.setCreateTime(DateUtils.getNowDate());
+        return baseMapper.insertFsDfAccount(fsDfAccount);
+    }
+
+    /**
+     * 修改代服账户
+     * 
+     * @param fsDfAccount 代服账户
+     * @return 结果
+     */
+    @Override
+    public int updateFsDfAccount(FsDfAccount fsDfAccount)
+    {
+        fsDfAccount.setUpdateTime(DateUtils.getNowDate());
+        return baseMapper.updateFsDfAccount(fsDfAccount);
+    }
+
+    /**
+     * 批量删除代服账户
+     * 
+     * @param ids 需要删除的代服账户主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFsDfAccountByIds(Long[] ids)
+    {
+        return baseMapper.deleteFsDfAccountByIds(ids);
+    }
+
+    /**
+     * 删除代服账户信息
+     * 
+     * @param id 代服账户主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFsDfAccountById(Long id)
+    {
+        return baseMapper.deleteFsDfAccountById(id);
+    }
+}

+ 9 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -50,6 +50,7 @@ import com.fs.his.vo.FsPackageOrderListVO;
 import com.fs.his.vo.FsPackageOrderVO;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.oss.CloudStorageService;
@@ -1019,6 +1020,14 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         o.setTransAmt(storePayment.getPayMoney().toString());
                         o.setGoodsDesc("套餐包订单支付");
                         o.setAppId(appId);
+                        //公司分账
+                        try {
+                            HuiFuUtils.doDiv(o,fsPackageOrder.getCompanyId());
+                            //存储分账明细
+                            HuiFuUtils.saveDivItem(o, fsPackageOrder, storePayment);
+                        } catch (Exception e) {
+                            logger.error("-------------分账出错:{}", e.getMessage());
+                        }
                         HuifuCreateOrderResult result = huiFuService.createOrder(o);
                         logger.info("创建汇付支付:"+result);
                         FsStorePayment mt=new FsStorePayment();

+ 125 - 18
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -12,6 +12,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
@@ -20,7 +21,11 @@ import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.utils.spring.SpringUtils;
+import com.fs.company.domain.CompanyDivItem;
 import com.fs.company.param.FsStoreStatisticsParam;
+import com.fs.company.service.ICompanyDivConfigService;
+import com.fs.company.service.ICompanyDivItemService;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.impl.CompanyServiceImpl;
 import com.fs.company.vo.FsStoreOrderStatisticsVO;
@@ -160,6 +165,9 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     @Autowired
     private IFsStoreOrderLogsService fsStoreOrderLogsService;
 
+    @Autowired
+    private ICompanyDivItemService companyDivItemService;
+
     /**
      * 查询售后记录
      *
@@ -289,7 +297,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
         //添加订单日志
         fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getValue(),
-                logs.getOperator()+" "+FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getDesc());
+                logs.getOperator() + " " + FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getDesc());
         return 1;
     }
 
@@ -318,7 +326,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
         //添加订单日志
         fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getValue(),
-                logs.getOperator() + " " +FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getDesc());
+                logs.getOperator() + " " + FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getDesc());
 //        FsStoreOrderLogs Logs = new FsStoreOrderLogs();
 //        Logs.setChangeMessage("已取消退款");
 //        Logs.setOrderId(order.getOrderId());
@@ -330,7 +338,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         or.setStatus(order.getOrderStatus());
         fsStoreOrderMapper.updateFsStoreOrder(or);
         //金牛订单取消售后审核不需要操作
-        if(!CloudHostUtils.hasCloudHostName("金牛名医","康年堂")){
+        if (!CloudHostUtils.hasCloudHostName("金牛名医", "康年堂")) {
             if (order.getOrderStatus() == 2) {
                 FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(order.getOrderId());
                 String newOrderSn = OrderCodeUtils.getOrderSn();
@@ -376,7 +384,6 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         }
 
 
-
         return 1;
     }
 
@@ -402,7 +409,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
         //添加订单日志
         fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getValue(),
-                logs.getOperator() + " " +FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getDesc());
+                logs.getOperator() + " " + FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getDesc());
         //更改订单状态
         FsStoreOrder or = new FsStoreOrder();
         or.setOrderId(order.getOrderId());
@@ -464,7 +471,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         }
         if (payments != null && payments.size() > 0) {
             FsStorePayment payment = payments.get(0);
-            if (reMoney.compareTo(payment.getPayMoney())>0) {
+            if (reMoney.compareTo(payment.getPayMoney()) > 0) {
                 return 0; //退款金额不能大于实际支付金额
             }
             String json = configService.selectConfigByKey("his.pay");
@@ -550,6 +557,16 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
                 request.setReqSeqId("refund-" + payment.getPayCode());
                 Map<String, Object> extendInfoMap = new HashMap<>();
                 extendInfoMap.put("org_req_seq_id", orderType + "-" + payment.getPayCode());
+
+                //处理分账退款
+                //1.判断是否是全额退款
+                CompanyDivItem companyDivItem = null;
+                try {
+                    companyDivItem = doRefundDiv(fsStoreOrder, reMoney, payment, extendInfoMap);
+                } catch (Exception e) {
+                    logger.error("-----------------分账退款处理失败{}", e.getMessage());
+                }
+
                 request.setExtendInfo(extendInfoMap);
                 HuiFuRefundResult refund = huiFuService.refund(request);
                 logger.info("订单退款返回结果:退款订单id:" + order.getOrderId() + refund);
@@ -560,6 +577,15 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
                     paymentMap.setRefundTime(DateUtils.getNowDate());
                     paymentMap.setRefundMoney(payment.getPayMoney());
                     fsStorePaymentMapper.updateFsStorePayment(paymentMap);
+                    try {
+                        //处理分账退款明细表
+                        if (companyDivItem !=null && companyDivItem.getId() != null) {
+                            companyDivItem.setIsRefund(1);
+                            companyDivItemService.updateCompanyDivItem(companyDivItem);
+                        }
+                    } catch (Exception e) {
+                        logger.error("-----------------分账退款明细处理失败{}", e.getMessage());
+                    }
                 } else {
                     throw new CustomException("退款请求失败" + refund.getResp_desc());
                 }
@@ -576,17 +602,17 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
                     Integer erpType = sysConfig.getErpType();
                     if (erpType == 1) {
                         erpOrderService.refundUpdate(request);
-                    }else if (erpType == 2) {
+                    } else if (erpType == 2) {
                         //旺店通
                         wdtErpOrderService.refundUpdate(request);
                     } else if (erpType == 3) {
                         //瀚智
                         hzOMSerpOrderService.refundUpdate(request);
-                    }  else if (erpType == 4) {
+                    } else if (erpType == 4) {
                         dfOrderService.refundUpdate(request);
-                    }else if(erpType == 5){
+                    } else if (erpType == 5) {
                         jSTOrderService.refundUpdate(request);
-                    }else if(erpType == 6){
+                    } else if (erpType == 6) {
                         k9OrderService.refundUpdate(request);
                     }
                 }
@@ -603,6 +629,87 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         return i;
     }
 
+    /**
+     * 处理分账退款
+     *
+     * @param fsStoreOrder
+     * @param reMoney
+     * @param payment
+     * @param extendInfoMap
+     */
+    private CompanyDivItem doRefundDiv(FsStoreOrder fsStoreOrder, BigDecimal reMoney, FsStorePayment payment, Map<String, Object> extendInfoMap) {
+        CompanyDivItem companyDivItem = null;
+        Long companyId = fsStoreOrder.getCompanyId();
+        if (companyId != null) {
+            companyDivItem = companyDivItemService.selectCompanyDivItemByPayCode(payment.getPayCode());
+            if (fsStoreOrder.getPayPrice().compareTo(reMoney) > 0) {
+                //部分退款
+                if (companyDivItem != null) {
+                    SysConfigMapper sysConfigMapper = SpringUtils.getBean(SysConfigMapper.class);
+                    SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
+                    FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+                    String defaultHuiFuId = fsPayConfig.getHuifuId(); //默认汇付id
+
+                    String detail = companyDivItem.getDetail();
+                    if (StringUtils.isNotBlank(detail)) {
+                        JSONObject acctSplitBunch = JSONObject.parseObject(detail);
+                        if (acctSplitBunch.get("percentage_flag") != null) {
+                            List<Map<String, Object>> param = new ArrayList(); //传入汇付参数
+
+                            String percentageFlag = acctSplitBunch.get("percentage_flag").toString();
+                            Object acctInfosObj = acctSplitBunch.get("acct_infos");
+                            if (acctInfosObj != null) {
+                                if ("Y".equals(percentageFlag)) {
+                                    // 百分比分账
+                                    List<Map> acctInfos = JSON.parseArray(acctInfosObj.toString(), Map.class);
+                                    if (acctInfos != null && !acctInfos.isEmpty()) {
+                                        BigDecimal remainMoney = reMoney;
+
+                                        for (Map acctInfo : acctInfos) {
+                                            String percentageDiv = acctInfo.get("percentage_div").toString();
+                                            BigDecimal divAmt = reMoney.multiply(BigDecimal.valueOf(Float.valueOf(percentageDiv)).multiply(BigDecimal.valueOf(0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
+                                            if (divAmt.compareTo(BigDecimal.ZERO) <= 0) {
+                                                continue;
+                                            }
+                                            remainMoney = remainMoney.subtract(divAmt);
+                                            String huiFuId = acctInfo.get("huifu_id").toString();
+                                            Map<String, Object> map = new HashMap<>();
+                                            map.put("div_amt", divAmt);
+                                            map.put("huifu_id", huiFuId);
+//                                                part_loan_amt	垫资金额
+                                            param.add(map);
+                                            if (remainMoney.compareTo(BigDecimal.ZERO) >= 0) {
+                                                break;
+                                            }
+                                        }
+                                        if (remainMoney.compareTo(BigDecimal.ZERO) >= 0) {
+                                            BigDecimal divAmt = reMoney.subtract(remainMoney).setScale(2, BigDecimal.ROUND_HALF_UP);
+                                            Map<String, Object> map = new HashMap<>();
+                                            map.put("div_amt", divAmt);
+                                            map.put("huifu_id", defaultHuiFuId);
+                                            param.add(map);
+                                        }
+                                    }
+
+                                } else if ("N".equals(percentageFlag)) {
+                                    // 金额分账 目前按照排序从第一个开始扣 扣到满足退款金额
+                                }
+                                if (!param.isEmpty()) {
+                                    extendInfoMap.put("acct_split_bunch", JSON.toJSONString(param));
+                                }
+                            }
+
+                        }
+
+
+                    }
+                }
+            }
+        }
+        return companyDivItem;
+
+    }
+
     @Override
     public List<FsStoreAfterSalesExcelVO> selectFsStoreAfterSalesExcelListVO(FsStoreAfterSalesParam fsStoreAfterSales) {
         return fsStoreAfterSalesMapper.selectFsStoreAfterSalesExcelListVO(fsStoreAfterSales);
@@ -743,17 +850,17 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
             Integer erpType = sysConfig.getErpType();
             BaseResponse response = null;
             if (erpType == 1) {
-                response =  erpOrderService.refundUpdate(request);
-            }else if (erpType == 2) {
+                response = erpOrderService.refundUpdate(request);
+            } else if (erpType == 2) {
                 //旺店通
                 response = wdtErpOrderService.refundUpdate(request);
-            }  else if (erpType == 3) {
+            } else if (erpType == 3) {
                 //瀚智
-                response =  hzOMSerpOrderService.refundUpdate(request);
+                response = hzOMSerpOrderService.refundUpdate(request);
             } else if (erpType == 4) {
-                response =  dfOrderService.refundUpdate(request);
-            }else if(erpType == 5){
-                response=jSTOrderService.refundUpdate(request);
+                response = dfOrderService.refundUpdate(request);
+            } else if (erpType == 5) {
+                response = jSTOrderService.refundUpdate(request);
             }
             if (response.getSuccess()) {
                 return R.ok();
@@ -898,7 +1005,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
         //添加订单日志
         fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getValue(),
-                logs.getOperator() + " " +FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getDesc());
+                logs.getOperator() + " " + FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getDesc());
         return 1;
     }
 

+ 3 - 0
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderExcelVO.java

@@ -13,6 +13,9 @@ public class FsStoreOrderExcelVO {
     /** 订单号 */
     @Excel(name = "订单号")
     private String orderCode;
+    //小程序名称
+    @Excel(name = "小程序名称")
+    private String miniProgramName;
     @Excel(name = "处方单号")
     private String prescribeCode;
     @Excel(name = "公司名称")

+ 38 - 3
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java

@@ -147,7 +147,27 @@ public interface FsStoreOrderItemScrmMapper
     @Select({"<script> " +
             "select count(0) from fs_store_order_item_scrm i left join fs_store_order_scrm o on o.id=i.order_id left join fs_user u on o.user_id=u.user_id  " +
             " left join fs_store_product_package_scrm p on o.package_id=p.package_id left join company c on c.company_id=o.company_id left join company_user cu on cu.user_id=o.company_user_id left join company_tcm_schedule cts on cts.id = o.schedule_id " +
+            "LEFT JOIN fs_store_order_df df on df.order_id=o.id\n" +
+            "        <if test=\"maps.coursePlaySourceConfigId != null\">\n" +
+            "            LEFT JOIN (\n" +
+            "            SELECT\n" +
+            "            sp.*,\n" +
+            "            ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn\n" +
+            "            FROM fs_store_payment_scrm sp\n" +
+            "            WHERE sp.business_code IS NOT NULL\n" +
+            "            ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1\n" +
+            "            LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id\n" +
+            "        </if>" +
             "where 1=1 " +
+            "<if test=\"maps.coursePlaySourceConfigId != null\">\n" +
+            "                and csc.id = #{maps.coursePlaySourceConfigId}\n" +
+            "            </if>\n" +
+            "            <if test=\"maps.orderCodes != null  and maps.orderCodes.size > 0\">\n" +
+            "                and o.order_code in\n" +
+            "                <foreach collection=\"maps.orderCodes\" item=\"orderCode\" open=\"(\" close=\")\" separator=\",\">\n" +
+            "                    #{orderCode}\n" +
+            "                </foreach>\n" +
+            "            </if>" +
             "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
             "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
             "</if>" +
@@ -166,9 +186,15 @@ public interface FsStoreOrderItemScrmMapper
             "<if test = 'maps.userPhone != null and  maps.userPhone !=\"\"     '> " +
             "and o.user_phone like CONCAT('%',#{maps.userPhone},'%') " +
             "</if>" +
-            "<if test = 'maps.status != null    '> " +
-            "and o.status =#{maps.status} " +
-            "</if>" +
+            "<if test=\"maps.status != null and maps.status != 6\">\n" +
+            "                and o.status = #{maps.status}\n" +
+            "            </if>\n" +
+            "            <if test=\"maps.status == 6\">\n" +
+            "                and o.`status`= 1\n" +
+            "\n" +
+            "                and  (o.extend_order_id is null or  o.extend_order_id like '')\n" +
+            "            </if>" +
+
             "<if test = 'maps.companyId != null    '> " +
             "and o.company_id =#{maps.companyId} " +
             "</if>" +
@@ -212,6 +238,15 @@ public interface FsStoreOrderItemScrmMapper
             "<if test = 'maps.scheduleId != null    '> " +
             "and o.schedule_id =#{maps.scheduleId} " +
             "</if>" +
+            "<if test=\"maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''\">\n" +
+            "                and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')\n" +
+            "            </if>\n" +
+            "            <if test=\"maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''\">\n" +
+            "                and df.login_account like #{maps.erpAccount}\n" +
+            "            </if>\n" +
+            "            <if test=\"maps.erpAccount == '未分拣'\">\n" +
+            "                and ( df.login_account is null or df.login_account like '')\n" +
+            "            </if>" +
             " order by o.id desc "+
             "</script>"})
     Long itemsCount(@Param("maps")FsStoreOrderParam fsStoreOrder);

+ 257 - 103
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -1,6 +1,7 @@
 package com.fs.hisStore.mapper;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -78,108 +79,108 @@ public interface FsStoreOrderScrmMapper
      */
     public int deleteFsStoreOrderByIds(Long[] ids);
 
-    @Select({"<script> " +
-            "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   from fs_store_order_scrm o left join fs_user u on o.user_id=u.user_id  left join company c on c.company_id=o.company_id left join company_user cu on cu.user_id=o.company_user_id  " +
-            "<if test = 'maps.productName != null and  maps.productName !=  \"\" '> " +
-            "left join fs_store_order_item_scrm oi on o.id = oi.order_id "+
-            "left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id"+
-            "</if>" +
-            "where 1=1 " +
-            "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
-            "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
-            "</if>" +
-            "<if test = 'maps.isPayRemain != null      '> " +
-            "and o.is_pay_remain =#{maps.isPayRemain} " +
-            "</if>" +
-            "<if test = 'maps.userId != null      '> " +
-            "and o.user_id =#{maps.userId} " +
-            "</if>" +
-            "<if test = 'maps.deliveryId != null  and  maps.deliveryId !=\"\"    '> " +
-            "and o.delivery_id =#{maps.deliveryId} " +
-            "</if>" +
-            "<if test = 'maps.nickname != null and  maps.nickname !=\"\"     '> " +
-            "and u.nickname like CONCAT('%',#{maps.nickname},'%') " +
-            "</if>" +
-            "<if test = 'maps.realName != null and  maps.realName !=\"\"     '> " +
-            "and o.real_name like CONCAT('%',#{maps.realName},'%') " +
-            "</if>" +
-            "<if test = 'maps.phone != null and  maps.phone !=\"\"     '> " +
-            "and u.phone like CONCAT('%',#{maps.phone},'%') " +
-            "</if>" +
-            "<if test = 'maps.userPhone != null and  maps.userPhone !=\"\"     '> " +
-            "and o.user_phone like CONCAT('%',#{maps.userPhone},'%') " +
-            "</if>" +
-            "<if test = 'maps.status != null    '> " +
-            "and o.status =#{maps.status} " +
-            "</if>" +
-            "<if test = 'maps.isUpload != null and maps.isUpload == 0    '> " +
-            "and o.certificates is null  " +
-            "</if>" +
-            "<if test = 'maps.isUpload != null and maps.isUpload == 1    '> " +
-            "and o.certificates is not null " +
-            "</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.companyId != null    '> " +
-            "and o.company_id =#{maps.companyId} " +
-            "</if>" +
-            "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
-            "and o.company_id is null " +
-            "</if>" +
-            "<if test = 'maps.notHealth != null '> " +
-            "and o.company_id is not null " +
-            "</if>" +
-            "<if test = 'maps.companyUserId != null    '> " +
-            "and o.company_user_id =#{maps.companyUserId} " +
-            "</if>" +
-            "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=  \"\" '> " +
-            "and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%') " +
-            "</if>" +
-            "<if test = 'maps.productName != null and  maps.productName !=  \"\" '> " +
-            "and fsp.product_name like concat('%', #{maps.productName}, '%') " +
-            "</if>" +
-            "<if test = 'maps.orderType != null    '> " +
-            "and o.order_type =#{maps.orderType} " +
-            "</if>" +
-            "<if test = 'maps.payType != null    '> " +
-            "and o.pay_type =#{maps.payType} " +
-            "</if>" +
-            "<if test = 'maps.scheduleId != null    '> " +
-            "and o.schedule_id =#{maps.scheduleId} " +
-            "</if>" +
-            "<if test = 'maps.createTimeList != null    '> " +
-            " AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d') " +
-            " AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d') " +
-            "</if>" +
-
-            "<if test = 'maps.deliverySendTimeList != null    '> " +
-            " AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d') " +
-            " AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d') " +
-            "</if>" +
-            "<if test = 'maps.paidStatus != null    '> " +
-            "and o.paid =#{maps.paidStatus} " +
-            "</if>" +
-            "<if test = 'maps.payTimeList != null    '> " +
-            " AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d') " +
-            " AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d') " +
-            "</if>" +
-            "<if test = 'maps.deliveryImportTimeList != null    '> " +
-            " AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d') " +
-            " AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d') " +
-            "</if>" +
-            "<if test = 'maps.deptId != null    '> " +
-            "  AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
-            "</if>" +
-            " ${maps.params.dataScope} "+
-            "<if test = 'maps.productName != null and  maps.productName !=  \"\" '> " +
-            " group by o.id "+
-            "</if>" +
-            " order by o.id desc "+
-            "</script>"})
+//    @Select({"<script> " +
+//            "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   from fs_store_order_scrm o left join fs_user u on o.user_id=u.user_id  left join company c on c.company_id=o.company_id left join company_user cu on cu.user_id=o.company_user_id  " +
+//            "<if test = 'maps.productName != null and  maps.productName !=  \"\" '> " +
+//            "left join fs_store_order_item_scrm oi on o.id = oi.order_id "+
+//            "left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id"+
+//            "</if>" +
+//            "where 1=1 " +
+//            "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
+//            "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
+//            "</if>" +
+//            "<if test = 'maps.isPayRemain != null      '> " +
+//            "and o.is_pay_remain =#{maps.isPayRemain} " +
+//            "</if>" +
+//            "<if test = 'maps.userId != null      '> " +
+//            "and o.user_id =#{maps.userId} " +
+//            "</if>" +
+//            "<if test = 'maps.deliveryId != null  and  maps.deliveryId !=\"\"    '> " +
+//            "and o.delivery_id =#{maps.deliveryId} " +
+//            "</if>" +
+//            "<if test = 'maps.nickname != null and  maps.nickname !=\"\"     '> " +
+//            "and u.nickname like CONCAT('%',#{maps.nickname},'%') " +
+//            "</if>" +
+//            "<if test = 'maps.realName != null and  maps.realName !=\"\"     '> " +
+//            "and o.real_name like CONCAT('%',#{maps.realName},'%') " +
+//            "</if>" +
+//            "<if test = 'maps.phone != null and  maps.phone !=\"\"     '> " +
+//            "and u.phone like CONCAT('%',#{maps.phone},'%') " +
+//            "</if>" +
+//            "<if test = 'maps.userPhone != null and  maps.userPhone !=\"\"     '> " +
+//            "and o.user_phone like CONCAT('%',#{maps.userPhone},'%') " +
+//            "</if>" +
+//            "<if test = 'maps.status != null    '> " +
+//            "and o.status =#{maps.status} " +
+//            "</if>" +
+//            "<if test = 'maps.isUpload != null and maps.isUpload == 0    '> " +
+//            "and o.certificates is null  " +
+//            "</if>" +
+//            "<if test = 'maps.isUpload != null and maps.isUpload == 1    '> " +
+//            "and o.certificates is not null " +
+//            "</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.companyId != null    '> " +
+//            "and o.company_id =#{maps.companyId} " +
+//            "</if>" +
+//            "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
+//            "and o.company_id is null " +
+//            "</if>" +
+//            "<if test = 'maps.notHealth != null '> " +
+//            "and o.company_id is not null " +
+//            "</if>" +
+//            "<if test = 'maps.companyUserId != null    '> " +
+//            "and o.company_user_id =#{maps.companyUserId} " +
+//            "</if>" +
+//            "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=  \"\" '> " +
+//            "and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%') " +
+//            "</if>" +
+//            "<if test = 'maps.productName != null and  maps.productName !=  \"\" '> " +
+//            "and fsp.product_name like concat('%', #{maps.productName}, '%') " +
+//            "</if>" +
+//            "<if test = 'maps.orderType != null    '> " +
+//            "and o.order_type =#{maps.orderType} " +
+//            "</if>" +
+//            "<if test = 'maps.payType != null    '> " +
+//            "and o.pay_type =#{maps.payType} " +
+//            "</if>" +
+//            "<if test = 'maps.scheduleId != null    '> " +
+//            "and o.schedule_id =#{maps.scheduleId} " +
+//            "</if>" +
+//            "<if test = 'maps.createTimeList != null    '> " +
+//            " AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d') " +
+//            " AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d') " +
+//            "</if>" +
+//
+//            "<if test = 'maps.deliverySendTimeList != null    '> " +
+//            " AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d') " +
+//            " AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d') " +
+//            "</if>" +
+//            "<if test = 'maps.paidStatus != null    '> " +
+//            "and o.paid =#{maps.paidStatus} " +
+//            "</if>" +
+//            "<if test = 'maps.payTimeList != null    '> " +
+//            " AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d') " +
+//            " AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d') " +
+//            "</if>" +
+//            "<if test = 'maps.deliveryImportTimeList != null    '> " +
+//            " AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d') " +
+//            " AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d') " +
+//            "</if>" +
+//            "<if test = 'maps.deptId != null    '> " +
+//            "  AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
+//            "</if>" +
+//            " ${maps.params.dataScope} "+
+//            "<if test = 'maps.productName != null and  maps.productName !=  \"\" '> " +
+//            " group by o.id "+
+//            "</if>" +
+//            " order by o.id desc "+
+//            "</script>"})
     List<FsStoreOrderVO> selectFsStoreOrderListVO(@Param("maps")FsStoreOrderParam param);
 
 
@@ -732,7 +733,7 @@ public interface FsStoreOrderScrmMapper
             " ${maps.params.dataScope} "+
             " order by o.id desc limit 50000"+
             "</script>"})
-    List<FsStoreOrderExportVO> selectFsStoreOrderListVOByExport(@Param("maps") FsStoreOrderParam param);
+    List<FsStoreOrderErpExportVO> selectFsStoreOrderListVOByExport(@Param("maps") FsStoreOrderParam param);
 
     @Select({"<script> " +
             "select o.*, " +
@@ -1221,4 +1222,157 @@ public interface FsStoreOrderScrmMapper
     int updateFsStoreOrderByOrderCode(FsStoreOrderScrm fsStoreOrder);
 
     FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
+
+    List<FsStoreOrderVO> selectFsStoreOrderListVOByErpAccount(@Param("maps")FsStoreOrderParam param);
+
+    int batchUpdateErpByOrderIds(@Param("maps")ArrayList<Map<String, String>> maps);
+
+    Map<String, BigDecimal> selectFsStoreOrderStatistics(@Param("maps")FsStoreOrderParam param);
+
+    String selectFsStoreOrderProductStatistics(@Param("maps")FsStoreOrderParam param);
+
+    Long selectFsStoreOrderListVOByErpAccountByExportCount(@Param("maps")FsStoreOrderParam param);
+
+    @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 ," +
+            "cu.phonenumber as company_usere_phonenumber ,p.title as package_title ," +
+            "CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload " +
+            ",df.login_account as erp_account," +
+            "        csc.name miniProgramName " +
+            " from fs_store_order_scrm o  left JOIN fs_store_product_package_scrm p on o.package_id=p.package_id left join fs_user u on o.user_id=u.user_id  " +
+            " left join company c on c.company_id=o.company_id left join company_user cu on cu.user_id=o.company_user_id left join crm_customer cc on cc.customer_id=o.customer_id left join company_tcm_schedule cts on cts.id = o.schedule_id " +
+            " LEFT JOIN fs_store_order_df df on df.order_id=o.id " +
+            " LEFT JOIN ( " +
+            " SELECT " +
+            " sp.*, " +
+            "ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn " +
+            "FROM fs_store_payment_scrm sp " +
+            " ) sp_latest ON sp_latest.business_code = o.order_code 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.orderCode != null and  maps.orderCode !=\"\"    '> " +
+            "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
+            "</if>" +
+            "<if test=\"maps.orderCodes != null  and maps.orderCodes.size > 0\">" +
+            "            and o.order_code in" +
+            "            <foreach collection=\"maps.orderCodes\" item=\"orderCode\" open=\"(\" close=\")\" separator=\",\">" +
+            "                #{orderCode}" +
+            "            </foreach>" +
+            "        </if>" +
+            "<if test = 'maps.userId != null      '> " +
+            "and o.user_id =#{maps.userId} " +
+            "</if>" +
+            "<if test = 'maps.deliveryId != null  and  maps.deliveryId !=\"\"    '> " +
+            "and o.delivery_id =#{maps.deliveryId} " +
+            "</if>" +
+            "<if test = 'maps.nickname != null and  maps.nickname !=\"\"     '> " +
+            "and u.nickname like CONCAT('%',#{maps.nickname},'%') " +
+            "</if>" +
+            "<if test = 'maps.realName != null and  maps.realName !=\"\"     '> " +
+            "and o.real_name like CONCAT('%',#{maps.realName},'%') " +
+            "</if>" +
+            "<if test = 'maps.phone != null and  maps.phone !=\"\"     '> " +
+            "and u.phone like CONCAT('%',#{maps.phone},'%') " +
+            "</if>" +
+            "<if test = 'maps.userPhone != null and  maps.userPhone !=\"\"     '> " +
+            "and o.user_phone like CONCAT('%',#{maps.userPhone},'%') " +
+            "</if>" +
+            "<if test=\"maps.status != null and maps.status != 6\">" +
+            "            AND o.status = #{maps.status}" +
+            "        </if>" +
+            "<if test=\"maps.status == 6\">" +
+            "            AND o.`status` = 1" +
+            "            AND (" +
+            "            o.store_id IN (SELECT store_id FROM fs_store WHERE delivery_type=2 OR delivery_type=1)" +
+            "            )" +
+            "            AND (o.extend_order_id IS NULL OR o.extend_order_id = '')" +
+            "        </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.companyId != null    '> " +
+            "and o.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
+            "and o.company_id is null " +
+            "</if>" +
+            "<if test = 'maps.notHealth != null and maps.notHealth !=  \"\"  '> " +
+            "and o.company_id is not null " +
+            "</if>" +
+            "<if test = 'maps.companyUserId != null    '> " +
+            "and o.company_user_id =#{maps.companyUserId} " +
+            "</if>" +
+            "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=  \"\" '> " +
+            "and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%') " +
+            "</if>" +
+            "<if test = 'maps.orderType != null    '> " +
+            "and o.order_type =#{maps.orderType} " +
+            "</if>" +
+            "<if test = 'maps.payType != null    '> " +
+            "and o.pay_type =#{maps.payType} " +
+            "</if>" +
+            "<if test = 'maps.createTimeList != null    '> " +
+            " AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d') " +
+            " AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.payTimeList != null    '> " +
+            " AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d') " +
+            " AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deliverySendTimeList != null    '> " +
+            " AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d') " +
+            " AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deliveryImportTimeList != null    '> " +
+            " AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d') " +
+            " AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deptId != null    '> " +
+            "  AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
+            "</if>" +
+            "<if test = 'maps.isUpload != null and maps.isUpload == 0    '> " +
+            "and o.certificates is null  " +
+            "</if>" +
+            "<if test = 'maps.scheduleId != null    '> " +
+            "and o.schedule_id =#{maps.scheduleId} " +
+            "</if>" +
+            "<if test = 'maps.isUpload != null and maps.isUpload == 1    '> " +
+            "and o.certificates is not null " +
+            "</if>" +
+            " <if test=\"maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''\">" +
+            " and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')" +
+            "</if>" +
+            "        <if test=\"maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''\">" +
+            "            and df.login_account like #{maps.erpAccount}" +
+            "        </if>" +
+            "        <if test=\"maps.erpAccount == '未分拣'\">" +
+            "            and ( df.login_account is null or df.login_account like '')" +
+            "        </if>" +
+            " ${maps.params.dataScope} "+
+            " ORDER BY " +
+            "<if test=\"maps.sortField == 'companyUserName'\"> " +
+            "    cu.nick_name" +
+            "</if>" +
+            "<if test=\"maps.sortField == 'packageName'\">" +
+            "    o.package_name" +
+            "</if>" +
+            "<if test=\"maps.sortField == 'payPrice'\">" +
+            "    o.pay_price" +
+            "</if>" +
+            "<if test=\"maps.sortField == 'payMoney'\">" +
+            "    o.pay_money" +
+            "</if>" +
+            "<if test=\"maps.sortOrder != null and maps.sortOrder != ''\">" +
+            "    ${maps.sortOrder}" +
+            "</if>" +
+            "<if test=\"maps.sortField == null or maps.sortField == ''\">" +
+            "    o.id desc " +
+            "</if> " +
+            " limit 50000 "+
+            "</script>"})
+    List<FsStoreOrderErpExportVO> selectFsStoreOrderErpListVOByExport(@Param("maps") FsStoreOrderParam param);
 }

+ 22 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderParam.java

@@ -5,18 +5,24 @@ import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 @Data
 public class FsStoreOrderParam extends BaseEntity implements Serializable
 {
+
     private String orderCode;
 
+    //多个订单号搜索
+    private List<String> orderCodes;
+
     private String nickname;
 
     private String phone;
 
     private String userPhone;
 
+    /** 订单状态(-1 : 申请退款 -2 : 退货成功 1:待支付 2:待发货;3:待收货;4:待评价;5:已完成) 6(金牛代服待推送,请避开6)*/
     private Integer status;
 
     private Long companyId;
@@ -89,4 +95,20 @@ public class FsStoreOrderParam extends BaseEntity implements Serializable
 
     private Long storeId;
 
+    //排序字段
+    private String sortField;
+    //排序规则
+    private String sortOrder;
+
+    //erp电话
+    private String erpPhoneNumber;
+
+    //小程序id
+    private Long coursePlaySourceConfigId;
+    //erp账户
+    private String erpAccount;
+
+    //导出字段
+    private String filter;
+
 }

+ 14 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderScrmSetErpPhoneParam.java

@@ -0,0 +1,14 @@
+package com.fs.hisStore.param;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class FsStoreOrderScrmSetErpPhoneParam extends FsStoreOrderParam {
+    private List<String> erpPhone;
+    private List<Long> orderIds;
+    private String loginAccount;
+    private Integer parcelQuantity; //包裹数量
+    private String opeName; //操作人
+}

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

@@ -191,7 +191,7 @@ public interface IFsStoreOrderScrmService
 
     List<FsStoreOrderStatisticsVO> selectFsStoreOrderStatisticsList(FsStoreStatisticsParam param);
 
-    List<FsStoreOrderExportVO> selectFsStoreOrderListVOByExport(FsStoreOrderParam param);
+    List<FsStoreOrderErpExportVO> selectFsStoreOrderListVOByExport(FsStoreOrderParam param);
 
     List<FsStoreOrderPromotionExportVO> selectFsPromotionOrderListVOByExport(FsStoreOrderParam param);
 
@@ -289,4 +289,17 @@ public interface IFsStoreOrderScrmService
      * 查询app商城订单金额统计信息
      * */
     FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
+
+    /**
+     * 跟进代服账户查询订单
+     * @param param
+     * @return
+     */
+    List<FsStoreOrderVO> selectFsStoreOrderListVOByErpAccount(FsStoreOrderParam param);
+
+    int batchUpdateErpByOrderIds(FsStoreOrderScrmSetErpPhoneParam param);
+
+    Map<String, BigDecimal> selectFsStoreOrderStatistics(FsStoreOrderParam param);
+
+    String selectFsStoreOrderProductStatistics(FsStoreOrderParam param);
 }

+ 115 - 3
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -15,6 +15,7 @@ import com.fs.api.param.OrderListParam;
 import com.fs.api.vo.OrderListVO;
 import com.fs.api.vo.ProductListVO;
 import com.fs.common.config.FSSysConfig;
+import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.event.TemplateBean;
@@ -25,6 +26,7 @@ import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyDept;
 import com.fs.company.domain.CompanyMoneyLogs;
@@ -59,12 +61,19 @@ import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsInquiryOrderVO;
 import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
 import com.fs.his.vo.FsStoreOrderExcelVO;
+import com.fs.his.vo.*;
+import com.fs.his.vo.FsPrescribeVO;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.dto.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.vo.*;
-import com.fs.his.vo.FsPrescribeVO;
+import com.fs.hisStore.vo.FsStoreOrderErpExportVO;
+import com.fs.hisStore.vo.FsStoreOrderExportVO;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.hisStore.vo.FsStoreOrderVO;
+import com.fs.hisStore.vo.FsStoreProductAttrValueVO;
+import com.fs.hisStore.vo.FsStoreProductDeliverExcelVO;
 import com.fs.hisapi.domain.ApiResponse;
 import com.fs.hisapi.param.CreateOrderParam;
 import com.fs.hisapi.param.RecipeDetailParam;
@@ -124,6 +133,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static com.fs.his.utils.PhoneUtil.decryptPhone;
+import static com.fs.his.utils.PhoneUtil.encryptPhone;
 import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
 
 /**
@@ -2457,8 +2467,14 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     }
 
     @Override
-    public List<FsStoreOrderExportVO> selectFsStoreOrderListVOByExport(FsStoreOrderParam param) {
-        return fsStoreOrderMapper.selectFsStoreOrderListVOByExport(param);
+    public List<FsStoreOrderErpExportVO> selectFsStoreOrderListVOByExport(FsStoreOrderParam param) {
+        if (CloudHostUtils.hasCloudHostName("金牛明医","康年堂")){
+            return fsStoreOrderMapper.selectFsStoreOrderErpListVOByExport(param);
+
+        } else {
+            return fsStoreOrderMapper.selectFsStoreOrderListVOByExport(param);
+
+        }
     }
 
     @Override
@@ -3744,6 +3760,102 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
     }
 
+    @Override
+    public List<FsStoreOrderVO> selectFsStoreOrderListVOByErpAccount(FsStoreOrderParam param) {
+        List<FsStoreOrderVO> list = fsStoreOrderMapper.selectFsStoreOrderListVOByErpAccount(param);
+        for (FsStoreOrderVO vo : list) {
+            String nickName = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2");
+            vo.setNickname(nickName);
+            if (StringUtils.isNotEmpty(vo.getItemJson())) {
+                JSONArray jsonArray = JSONUtil.parseArray(vo.getItemJson());
+                List<FsStoreOrderItemVO> items = JSONUtil.toList(jsonArray, FsStoreOrderItemVO.class);
+                if (!items.isEmpty()) {
+                    vo.setItems(items);
+                }
+            }
+            //List<FsStoreOrderItemVO> items=storeOrderItemService.selectFsStoreOrderItemListByOrderId(vo.getId());
+            //vo.setItems(items);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional
+    public int batchUpdateErpByOrderIds(FsStoreOrderScrmSetErpPhoneParam param) {
+        //判断是根据orderId还是查询设置
+        List<Long> orderIds = param.getOrderIds();
+        if (orderIds == null || orderIds.isEmpty()) {
+            if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+                param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getPayTimeRange())){
+                param.setPayTimeList(param.getPayTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+                param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+            }
+            if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+                param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+            }
+            param.setNotHealth(1);
+            List<FsStoreOrderVO> list = fsStoreOrderMapper.selectFsStoreOrderListVO(param);
+            orderIds = list.stream().map(FsStoreOrderVO::getId).collect(Collectors.toList());
+            param.setOrderIds(orderIds);
+        }
+        if (orderIds.isEmpty()) {
+            return 0;
+        }
+        //分配手机号
+        //1.手机号大于/等于orderIds长度
+        List<String> erpPhones = param.getErpPhone();
+        int phoneSize = erpPhones.size();
+        int orderSize = orderIds.size();
+        ArrayList<Map<String, String>> maps = new ArrayList<>();
+        if (phoneSize >= orderSize) {
+            for (int i = 0; i < orderSize; i++) {
+                HashMap<String, String> map = new HashMap<>();
+                map.put("orderId", orderIds.get(i).toString());
+                map.put("erpPhone", erpPhones.get(i));
+                maps.add(map);
+                fsStoreOrderLogsService.create(orderIds.get(i), FsStoreOrderLogEnum.SET_PUSH_MOBILE.getValue(),
+                        param.getOpeName() + " " +FsStoreOrderLogEnum.SET_PUSH_MOBILE.getDesc() + ":" + erpPhones.get(i));
+            }
+        } else {
+            //2.手机号小于orderIds长度
+            int size = orderSize / phoneSize;
+            int num = orderSize % phoneSize;
+            if (num > 0) {
+                size = size + 1;
+            }
+            int orderIndex = 0;
+            for (String erpPhone : erpPhones) {
+                for (int i = 0; i < size; i++) {
+                    if (orderIndex > (orderSize - 1)) {
+                        break;
+                    }
+                    HashMap<String, String> map = new HashMap<>();
+                    map.put("orderId", orderIds.get(orderIndex).toString());
+                    map.put("erpPhone", erpPhone);
+                    maps.add(map);
+                    orderIndex++;
+                    fsStoreOrderLogsService.create(orderIds.get(i), FsStoreOrderLogEnum.SET_PUSH_MOBILE.getValue(),
+                            param.getOpeName() + " " +FsStoreOrderLogEnum.SET_PUSH_MOBILE.getDesc() + ":" + erpPhone);
+                }
+            }
+        }
+        return fsStoreOrderMapper.batchUpdateErpByOrderIds(maps);
+    }
+
+    @Override
+    public Map<String, BigDecimal> selectFsStoreOrderStatistics(FsStoreOrderParam param) {
+        return fsStoreOrderMapper.selectFsStoreOrderStatistics(param);
+    }
+
+    @Override
+    public String selectFsStoreOrderProductStatistics(FsStoreOrderParam param) {
+        return fsStoreOrderMapper.selectFsStoreOrderProductStatistics(param);
+    }
+
     private static final DateTimeFormatter CST_FORMATTER = DateTimeFormatter
             .ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US)
             .withZone(ZoneId.of("Asia/Shanghai"));

+ 24 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderErpExportVO.java

@@ -0,0 +1,24 @@
+package com.fs.hisStore.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 订单对象 fs_store_order
+ *
+ * @author fs
+ * @date 2022-03-15
+ */
+@Data
+public class FsStoreOrderErpExportVO extends FsStoreOrderExportVO
+{
+    @Excel(name = "ERP电话",sort = 1)
+    private String erpPhone;
+    @Excel(name = "ERP账户",sort = 2)
+    private String erpAccount;
+}

+ 10 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderVO.java

@@ -244,5 +244,15 @@ public class FsStoreOrderVO implements Serializable
 
     private String orderMedium;
 
+    //小程序名称
+    private String miniProgramName;
+
+
+    //erp推送号码
+    private String erpPhone;
+
+    //erp推送账号
+    private String erpAccount;
+
 
 }

+ 2 - 0
fs-service/src/main/java/com/fs/huifuPay/domain/HuiFuCreateOrder.java

@@ -20,4 +20,6 @@ public class HuiFuCreateOrder {
     String goodsDesc;
     String openid;
     String appId; //多小程序支付
+    String acctSplitBunch; //公司分账参数
+    String delayAcctFlag; //延时交易 延迟分账需要
 }

+ 19 - 1
fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/request/V2TradePaymentScanpayRefundRequest.java

@@ -43,6 +43,15 @@ public class V2TradePaymentScanpayRefundRequest extends BaseRequest {
     @JSONField(name = "org_hf_seq_id")
     private String orgHfSeqId;
 
+
+
+    /**
+     *分账对象
+     * **/
+    @JSONField(name = "acct_split_bunch")
+    private String acctSplitBunch;
+
+
     @Override
     public FunctionCodeEnum getFunctionCode() {
         return FunctionCodeEnum.V2_TRADE_PAYMENT_SCANPAY_REFUND;
@@ -51,12 +60,13 @@ public class V2TradePaymentScanpayRefundRequest extends BaseRequest {
     public V2TradePaymentScanpayRefundRequest() {
     }
 
-    public V2TradePaymentScanpayRefundRequest(String reqDate, String reqSeqId, String huifuId, String ordAmt, String orgReqDate) {
+    public V2TradePaymentScanpayRefundRequest(String reqDate, String reqSeqId, String huifuId, String ordAmt, String orgReqDate,String acctSplitBunch) {
         this.reqDate = reqDate;
         this.reqSeqId = reqSeqId;
         this.huifuId = huifuId;
         this.ordAmt = ordAmt;
         this.orgReqDate = orgReqDate;
+        this.acctSplitBunch = acctSplitBunch;
     }
 
     public String getReqDate() {
@@ -106,4 +116,12 @@ public class V2TradePaymentScanpayRefundRequest extends BaseRequest {
     public void setOrgHfSeqId(String orgHfSeqId) {
         this.orgHfSeqId = orgHfSeqId;
     }
+
+    public String getAcctSplitBunch() {
+        return acctSplitBunch;
+    }
+
+    public void setAcctSplitBunch(String acctSplitBunch) {
+        this.acctSplitBunch = acctSplitBunch;
+    }
 }

+ 158 - 0
fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/utils/HuiFuUtils.java

@@ -0,0 +1,158 @@
+package com.fs.huifuPay.sdk.opps.core.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.spring.SpringUtils;
+import com.fs.company.domain.CompanyDivItem;
+import com.fs.company.mapper.CompanyDivConfigMapper;
+import com.fs.company.param.CompanyAcctInfo;
+import com.fs.company.service.ICompanyDivConfigService;
+import com.fs.company.service.ICompanyDivItemService;
+import com.fs.company.service.impl.CompanyDivConfigServiceImpl;
+import com.fs.company.vo.CompanyDivConfigVo;
+import com.fs.his.domain.FsPackageOrder;
+import com.fs.his.domain.FsPayConfig;
+import com.fs.his.domain.FsStorePayment;
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.mapper.SysConfigMapper;
+import com.google.gson.Gson;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class HuiFuUtils {
+    private static ICompanyDivConfigService companyDivConfigService = SpringUtils.getBean(ICompanyDivConfigService.class);
+    private static ICompanyDivItemService companyDivItemService = SpringUtils.getBean(ICompanyDivItemService.class);
+
+    /**
+     *  处理分账
+     * @param huiFuCreateOrder
+     * @param companyId
+     */
+    public static void doDiv(HuiFuCreateOrder huiFuCreateOrder, Long companyId) throws Exception {
+        //默认汇付账户
+        SysConfigMapper sysConfigMapper= SpringUtils.getBean(SysConfigMapper.class);
+        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
+        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+        String defaultHuifuId = fsPayConfig.getHuifuId();
+        //查询是否开启分账
+        if (companyId !=null){
+
+            CompanyDivConfigVo configVo = companyDivConfigService.selectCompanyDivConfigByCompanyId(companyId);
+            if (configVo != null){
+                Integer divFlag = configVo.getDivFlag();
+                if (divFlag != null && divFlag == 1){
+                    //开启分账
+                    //汇付传参
+                    Map<String, Object> acctSplitBunchMap = new HashMap<>();
+                    List<Map<String,Object>> acctInfos = new ArrayList();
+                    List<CompanyAcctInfo> acctInfoVos = configVo.getAcctInfos();
+                    if (acctInfoVos != null && !acctInfoVos.isEmpty()){
+                        String delayAcctFlag = configVo.getDelayAcctFlag();
+                        String percentageFlag = configVo.getPercentageFlag();
+                        if (StringUtils.isNotBlank(delayAcctFlag) && delayAcctFlag.equals("N")){
+                            //实时分账
+                            if (StringUtils.isNotBlank(percentageFlag) && percentageFlag.equals("Y")){
+                                acctSplitBunchMap.put("percentage_flag","Y");
+                                Float total = 0f;
+                                //百分比分账
+                                for (CompanyAcctInfo acctInfo : acctInfoVos) {
+                                    Map<String, Object> map = new HashMap<>();
+                                    Float percentageDiv = acctInfo.getPercentageDiv();
+                                    if (percentageDiv == null || percentageDiv <= 0){
+                                        continue;
+                                    }
+                                    map.put("percentage_div", String.format("%.2f", percentageDiv));
+                                    if (percentageDiv > 100){
+                                        acctInfos = null;
+                                        break;
+                                    }
+                                    total = total + percentageDiv;
+                                    if (total>100){
+                                        acctInfos = null;
+                                        break;
+                                    }
+                                    if (StringUtils.isBlank(acctInfo.getAcctId())){
+                                        acctInfo.setAcctId(null);
+                                    }
+                                    map.put("huifu_id", acctInfo.getHuifuId());
+                                    acctInfos.add(map);
+                                }
+                                if (acctInfos != null && !acctInfos.isEmpty()){
+                                    Map<String, Object> defaultAccount = new HashMap<>();
+                                    defaultAccount.put("percentage_div", String.format("%.2f", 100f - total));
+                                    defaultAccount.put("huifu_id", defaultHuifuId);
+                                    acctInfos.add(defaultAccount);
+                                }
+
+
+                            } else {
+                                acctSplitBunchMap.put("percentage_flag","N");
+                                // 固定金额
+                                BigDecimal amtTotal = BigDecimal.ZERO;
+                                //支付金额
+                                BigDecimal initTotal = new BigDecimal(huiFuCreateOrder.getTransAmt()).setScale(2, RoundingMode.FLOOR);
+                                for (CompanyAcctInfo acctInfo : acctInfoVos) {
+                                    Map<String, Object> map = new HashMap<>();
+                                    BigDecimal divAmt = acctInfo.getDivAmt().setScale(2, RoundingMode.FLOOR);
+                                    if (divAmt.compareTo(BigDecimal.ZERO) <= 0){
+                                        continue;
+                                    }
+                                    map.put("div_amt",divAmt.toString());
+                                    amtTotal = amtTotal.add(divAmt);
+                                    if (amtTotal.compareTo(initTotal) > 0){
+                                        acctInfos = null;
+                                        break;
+                                    }
+                                    if (StringUtils.isBlank(acctInfo.getAcctId())){
+                                        acctInfo.setAcctId(null);
+                                    }
+                                    map.put("huifu_id", acctInfo.getHuifuId());
+                                    acctInfos.add(map);
+                                }
+                                if (acctInfos != null && !acctInfos.isEmpty()){
+                                    if (initTotal.compareTo(amtTotal)<0){
+                                        acctInfos = null;
+                                    } else {
+                                        Map<String, Object> defaultAccount = new HashMap<>();
+                                        defaultAccount.put("div_amt", String.valueOf(initTotal.subtract(amtTotal).setScale(2, RoundingMode.FLOOR)));
+                                        defaultAccount.put("huifu_id", defaultHuifuId);
+                                        acctInfos.add(defaultAccount);
+                                    }
+                                }
+
+                            }
+
+                            if (acctInfos != null){
+                                acctSplitBunchMap.put("is_clean_split", configVo.getIsCleanSplit());
+                                acctSplitBunchMap.put("acct_infos", acctInfos);
+                                huiFuCreateOrder.setAcctSplitBunch( JSON.toJSONString(acctSplitBunchMap));
+                            }
+                        } else if (StringUtils.isNotBlank(delayAcctFlag) && delayAcctFlag.equals("Y")){
+                            //延时分账 确认交易时传参
+                            huiFuCreateOrder.setDelayAcctFlag("Y");
+                        }
+
+                    }
+                }
+            }
+        }
+    }
+
+    public static void saveDivItem(HuiFuCreateOrder o, FsPackageOrder fsPackageOrder, FsStorePayment storePayment) {
+        CompanyDivItem companyDivItem = new CompanyDivItem();
+        if (StringUtils.isNotBlank(o.getAcctSplitBunch())){
+            companyDivItem.setOrderCode(fsPackageOrder.getOrderSn());
+            companyDivItem.setPayCode(storePayment.getPayCode());
+            companyDivItem.setDetail(o.getAcctSplitBunch());
+            companyDivItem.setIsRefund(0); //支付
+            companyDivItem.setIsDelay(0); //延迟分账
+            companyDivItemService.insertCompanyDivItem(companyDivItem);
+        }
+    }
+}

+ 3 - 2
fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java

@@ -9,14 +9,12 @@ import com.fs.his.domain.FsPayConfig;
 import com.fs.huifuPay.domain.*;
 import com.fs.huifuPay.sdk.opps.core.config.MerConfig;
 import com.fs.huifuPay.sdk.opps.core.request.*;
-import com.fs.huifuPay.sdk.opps.core.utils.RsaUtils;
 import com.fs.huifuPay.sdk.opps.core.utils.SequenceTools;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.huifuPay.sdk.opps.core.utils.DateTools;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
 import com.google.gson.Gson;
-import io.lettuce.core.ScriptOutputType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -57,6 +55,9 @@ public class HuiFuServiceImpl implements HuiFuService {
             // 是否延迟交易
             extendInfoMap.put("delay_acct_flag", "N");
             extendInfoMap.put("pay_scene", "02");
+            if (StringUtils.isNotBlank(order.getAcctSplitBunch())){
+                extendInfoMap.put("acct_split_bunch", order.getAcctSplitBunch());
+            }
             // 传入分帐遇到优惠的处理规则
             extendInfoMap.put("term_div_coupon_type", "0");
             String appId = order.getAppId();

+ 127 - 119
fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsInfoServiceImpl.java

@@ -570,40 +570,45 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                             //文字和短链一起
                             case "1":
                             case "3":
-                                if ("1".equals(st.getIsBindUrl())) {
-                                    String qwUserId = qwUser.getQwUserId();
-                                    String companyId = qwUser.getCompanyId().toString();
-                                    Long externalUserId = vo.getId();
-//                                    addWatchLogIfNeeded(param.getSopId(), param.getVideoId(), param.getCourseId(), null, qwUserId, companyUserId, companyId, externalUserId, param.getStartTime(), createTime);
-                                    FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
-                                    createParam.setCourseId(param.getCourseId().longValue());
-                                    createParam.setVideoId(param.getVideoId().longValue());
-                                    createParam.setCorpId(qwSop.getCorpId());
-                                    createParam.setCompanyUserId(Long.parseLong(companyUserId));
-                                    createParam.setCompanyId(Long.parseLong(companyId));
-                                    createParam.setChatId(groupUser.getChatId());
-                                    createParam.setQwUserId(qwUser.getId());
-                                    createParam.setDays(st.getExpiresDays());
-                                    R createLink = courseLinkService.createRoomLinkUrl(createParam);
-                                    if (createLink.get("code").equals(500)) {
-                                        throw new BaseException("链接生成失败!");
-                                    }
-                                    String sortLink = (String) createLink.get("url");
-
-                                    if (StringUtils.isNotEmpty(sortLink)) {
-                                        if ("3".equals(st.getContentType())) {
-                                            st.setLinkUrl(sortLink);
-                                        } else {
-                                            String currentValue = st.getValue();
-                                            if (currentValue == null) {
-                                                st.setValue(sortLink);
-                                            } else {
-                                                st.setValue(currentValue.replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText()) + "\n" + sortLink);
-                                            }
-                                        }
-                                    } else {
-                                        log.warn("生成短链失败,跳过设置 URL。");
-                                    }
+//                                if ("1".equals(st.getIsBindUrl())) {
+//                                    String qwUserId = qwUser.getQwUserId();
+//                                    String companyId = qwUser.getCompanyId().toString();
+//                                    Long externalUserId = vo.getId();
+////                                    addWatchLogIfNeeded(param.getSopId(), param.getVideoId(), param.getCourseId(), null, qwUserId, companyUserId, companyId, externalUserId, param.getStartTime(), createTime);
+//                                    FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
+//                                    createParam.setCourseId(param.getCourseId().longValue());
+//                                    createParam.setVideoId(param.getVideoId().longValue());
+//                                    createParam.setCorpId(qwSop.getCorpId());
+//                                    createParam.setCompanyUserId(Long.parseLong(companyUserId));
+//                                    createParam.setCompanyId(Long.parseLong(companyId));
+//                                    createParam.setChatId(groupUser.getChatId());
+//                                    createParam.setQwUserId(qwUser.getId());
+//                                    createParam.setDays(st.getExpiresDays());
+//                                    R createLink = courseLinkService.createRoomLinkUrl(createParam);
+//                                    if (createLink.get("code").equals(500)) {
+//                                        throw new BaseException("链接生成失败!");
+//                                    }
+//                                    String sortLink = (String) createLink.get("url");
+//
+//                                    if (StringUtils.isNotEmpty(sortLink)) {
+//                                        if ("3".equals(st.getContentType())) {
+//                                            st.setLinkUrl(sortLink);
+//                                        } else {
+//                                            String currentValue = st.getValue();
+//                                            if (currentValue == null) {
+//                                                st.setValue(sortLink);
+//                                            } else {
+//                                                st.setValue(currentValue.replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText()) + "\n" + sortLink);
+//                                            }
+//                                        }
+//                                    } else {
+//                                        log.warn("生成短链失败,跳过设置 URL。");
+//                                    }
+//                                }
+
+                                if ("1".equals(st.getContentType())) {
+                                    st.setValue(st.getValue()
+                                            .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText()));
                                 }
                                 break;
                             //小程序单独
@@ -677,39 +682,42 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                             //文字和短链一起
                             case "1":
                             case "3":
-                                if ("1".equals(st.getIsBindUrl())) {
-                                    FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
-                                    createParam.setCourseId(param.getCourseId().longValue());
-                                    createParam.setVideoId(param.getVideoId().longValue());
-                                    createParam.setCorpId(groupChat.getCorpId());
-                                    createParam.setCompanyUserId(qwUser.getCompanyUserId());
-                                    createParam.setCompanyId(qwUser.getCompanyId());
-                                    createParam.setChatId(groupChat.getChatId());
-                                    createParam.setQwUserId(qwUser.getId());
-                                    createParam.setDays(st.getExpiresDays());
-                                    R createLink = courseLinkService.createRoomLinkUrl(createParam);
-                                    if (createLink.get("code").equals(500)) {
-                                        throw new BaseException("链接生成失败!");
-                                    }
-                                    String link = (String) createLink.get("url");
-                                    if (StringUtils.isNotEmpty(link)) {
-                                        if ("3".equals(st.getContentType())) {
-                                            st.setLinkUrl(link);
-                                        } else {
-                                            String currentValue = st.getValue();
-                                            if (currentValue == null) {
-                                                st.setValue(link);
-                                            } else {
-                                                st.setValue(currentValue
-                                                        .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText())
-                                                        + "\n" + link);
-                                            }
-                                        }
-                                    } else {
-                                        log.error("生成短链失败,跳过设置 URL。");
-                                    }
+//                                if ("1".equals(st.getIsBindUrl())) {
+//                                    FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
+//                                    createParam.setCourseId(param.getCourseId().longValue());
+//                                    createParam.setVideoId(param.getVideoId().longValue());
+//                                    createParam.setCorpId(groupChat.getCorpId());
+//                                    createParam.setCompanyUserId(qwUser.getCompanyUserId());
+//                                    createParam.setCompanyId(qwUser.getCompanyId());
+//                                    createParam.setChatId(groupChat.getChatId());
+//                                    createParam.setQwUserId(qwUser.getId());
+//                                    createParam.setDays(st.getExpiresDays());
+//                                    R createLink = courseLinkService.createRoomLinkUrl(createParam);
+//                                    if (createLink.get("code").equals(500)) {
+//                                        throw new BaseException("链接生成失败!");
+//                                    }
+//                                    String link = (String) createLink.get("url");
+//                                    if (StringUtils.isNotEmpty(link)) {
+//                                        if ("3".equals(st.getContentType())) {
+//                                            st.setLinkUrl(link);
+//                                        } else {
+//                                            String currentValue = st.getValue();
+//                                            if (currentValue == null) {
+//                                                st.setValue(link);
+//                                            } else {
+//                                                st.setValue(currentValue
+//                                                        .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText())
+//                                                        + "\n" + link);
+//                                            }
+//                                        }
+//                                    } else {
+//                                        log.error("生成短链失败,跳过设置 URL。");
+//                                    }
+//                                }
+                                if ("1".equals(st.getContentType())) {
+                                    st.setValue(st.getValue()
+                                            .replaceAll("#销售称呼#", StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText()));
                                 }
-
                                 break;
                             //小程序单独
                             case "4":
@@ -833,37 +841,37 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                         //文字和短链一起
                         case "1":
                         case "3":
-                            if ("1".equals(st.getIsBindUrl())) {
-
-                                addWatchLogIfNeeded(param.getSopId(), param.getVideoId(), param.getCourseId(),item.getFsUserId(), qwUserId, companyUserId, companyId, item.getExternalId(),param.getStartTime(),createTime );
-
-                                String sortLink = generateShortLink(st, param.getCorpId(), createTime, param.getCourseId(), param.getVideoId(),
-                                        Long.valueOf(qwUserId), companyUserId, companyId, finalDomainName,item.getExternalId(),config);
-
-                                if (StringUtils.isNotEmpty(sortLink)) {
-                                    if ("3".equals(st.getContentType())) {
-                                        st.setLinkUrl(sortLink);
-                                    } else {
-                                        String currentValue = st.getValue();
-                                        if (currentValue == null) {
-                                            st.setValue(sortLink);
-                                        } else {
-                                            st.setValue(currentValue
-                                                    .replaceAll("#销售称呼#",StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText())?"":qwUser.getWelcomeText())
-                                                    .replaceAll("#客户称呼#",StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus())
-                                                    + "\n" + sortLink);
-                                        }
-                                    }
-                                } else {
-                                    log.warn("生成短链失败,跳过设置 URL。");
-                                }
-                            }else {
+//                            if ("1".equals(st.getIsBindUrl())) {
+//
+//                                addWatchLogIfNeeded(param.getSopId(), param.getVideoId(), param.getCourseId(),item.getFsUserId(), qwUserId, companyUserId, companyId, item.getExternalId(),param.getStartTime(),createTime );
+//
+//                                String sortLink = generateShortLink(st, param.getCorpId(), createTime, param.getCourseId(), param.getVideoId(),
+//                                        Long.valueOf(qwUserId), companyUserId, companyId, finalDomainName,item.getExternalId(),config);
+//
+//                                if (StringUtils.isNotEmpty(sortLink)) {
+//                                    if ("3".equals(st.getContentType())) {
+//                                        st.setLinkUrl(sortLink);
+//                                    } else {
+//                                        String currentValue = st.getValue();
+//                                        if (currentValue == null) {
+//                                            st.setValue(sortLink);
+//                                        } else {
+//                                            st.setValue(currentValue
+//                                                    .replaceAll("#销售称呼#",StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText())?"":qwUser.getWelcomeText())
+//                                                    .replaceAll("#客户称呼#",StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus())
+//                                                    + "\n" + sortLink);
+//                                        }
+//                                    }
+//                                } else {
+//                                    log.warn("生成短链失败,跳过设置 URL。");
+//                                }
+//                            }else {
                                 if ("1".equals(st.getContentType())) {
                                     st.setValue(st.getValue()
                                             .replaceAll("#销售称呼#",StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText())?"":qwUser.getWelcomeText())
                                             .replaceAll("#客户称呼#",StringUtil.strIsNullOrEmpty(contact.getStageStatus()) || "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus()));
                                 }
-                            }
+//                            }
 
                             break;
                         //小程序单独
@@ -1265,38 +1273,38 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                 //文字和短链一起
                 case "1":
                 case "3":
-                    if ("1".equals(st.getIsBindUrl())) {
-
-                        addWatchLogIfNeeded(item.getSopId(), param.getVideoId(), param.getCourseId(),item.getFsUserId(), String.valueOf(qwUser.getId()), companyUserId,
-                                companyId, item.getExternalId(),param.getStartTime(),dataTime );
-
-                        String sortLink = generateShortLink(st, param.getCorpId(), dataTime, param.getCourseId(), param.getVideoId(),
-                                qwUser.getId(), companyUserId, companyId, domainName,item.getExternalId(),config);
-
-                        if (StringUtils.isNotEmpty(sortLink)) {
-                            if ("3".equals(st.getContentType())) {
-                                st.setLinkUrl(sortLink);
-                            } else {
-                                String currentValue = st.getValue();
-                                if (currentValue == null) {
-                                    st.setValue(sortLink);
-                                } else {
-                                    st.setValue(currentValue
-                                            .replaceAll("#销售称呼#",StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText())?"":qwUser.getWelcomeText())
-                                            .replaceAll("#客户称呼#",StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus())
-                                            + "\n" + sortLink);
-                                }
-                            }
-                        } else {
-                            log.warn("生成短链失败,跳过设置 URL。");
-                        }
-                    }else {
+//                    if ("1".equals(st.getIsBindUrl())) {
+//
+//                        addWatchLogIfNeeded(item.getSopId(), param.getVideoId(), param.getCourseId(),item.getFsUserId(), String.valueOf(qwUser.getId()), companyUserId,
+//                                companyId, item.getExternalId(),param.getStartTime(),dataTime );
+//
+//                        String sortLink = generateShortLink(st, param.getCorpId(), dataTime, param.getCourseId(), param.getVideoId(),
+//                                qwUser.getId(), companyUserId, companyId, domainName,item.getExternalId(),config);
+//
+//                        if (StringUtils.isNotEmpty(sortLink)) {
+//                            if ("3".equals(st.getContentType())) {
+//                                st.setLinkUrl(sortLink);
+//                            } else {
+//                                String currentValue = st.getValue();
+//                                if (currentValue == null) {
+//                                    st.setValue(sortLink);
+//                                } else {
+//                                    st.setValue(currentValue
+//                                            .replaceAll("#销售称呼#",StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText())?"":qwUser.getWelcomeText())
+//                                            .replaceAll("#客户称呼#",StringUtil.strIsNullOrEmpty(contact.getStageStatus())|| "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus())
+//                                            + "\n" + sortLink);
+//                                }
+//                            }
+//                        } else {
+//                            log.warn("生成短链失败,跳过设置 URL。");
+//                        }
+//                    }else {
                         if ("1".equals(st.getContentType())) {
                             st.setValue(st.getValue()
                                     .replaceAll("#销售称呼#",StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText())?"":qwUser.getWelcomeText())
                                     .replaceAll("#客户称呼#",StringUtil.strIsNullOrEmpty(contact.getStageStatus()) || "0".equals(contact.getStageStatus())?"同学":contact.getStageStatus()));
                         }
-                    }
+//                    }
 
                     break;
                 //小程序单独

+ 91 - 0
fs-service/src/main/resources/mapper/company/CompanyDivConfigMapper.xml

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.company.mapper.CompanyDivConfigMapper">
+
+    <resultMap type="CompanyDivConfig" id="CompanyDivConfigResult">
+        <result property="companyId"    column="company_id"    />
+        <result property="companyName"    column="company_name"    />
+        <result property="divFlag"    column="div_flag"    />
+        <result property="delayAcctFlag"    column="delay_acct_flag"    />
+        <result property="percentageFlag"    column="percentage_flag"    />
+        <result property="isCleanSplit"    column="is_clean_split"    />
+        <result property="acctInfos"    column="acct_infos"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectCompanyDivConfigVo">
+        select company_id, company_name, div_flag, delay_acct_flag, percentage_flag, is_clean_split, acct_infos, create_time, update_time from company_div_config
+    </sql>
+
+    <select id="selectCompanyDivConfigList" parameterType="CompanyDivConfig" resultMap="CompanyDivConfigResult">
+        <include refid="selectCompanyDivConfigVo"/>
+        <where>
+            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
+            <if test="divFlag != null "> and div_flag = #{divFlag}</if>
+            <if test="delayAcctFlag != null  and delayAcctFlag != ''"> and delay_acct_flag = #{delayAcctFlag}</if>
+            <if test="percentageFlag != null  and percentageFlag != ''"> and percentage_flag = #{percentageFlag}</if>
+            <if test="isCleanSplit != null  and isCleanSplit != ''"> and is_clean_split = #{isCleanSplit}</if>
+            <if test="acctInfos != null  and acctInfos != ''"> and acct_infos = #{acctInfos}</if>
+        </where>
+    </select>
+
+    <select id="selectCompanyDivConfigByCompanyId" parameterType="Long" resultMap="CompanyDivConfigResult">
+        <include refid="selectCompanyDivConfigVo"/>
+        where company_id = #{companyId}
+    </select>
+
+    <insert id="insertCompanyDivConfig" parameterType="CompanyDivConfig">
+        insert into company_div_config
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="companyId != null">company_id,</if>
+            <if test="companyName != null and companyName != ''">company_name,</if>
+            <if test="divFlag != null">div_flag,</if>
+            <if test="delayAcctFlag != null">delay_acct_flag,</if>
+            <if test="percentageFlag != null">percentage_flag,</if>
+            <if test="isCleanSplit != null">is_clean_split,</if>
+            <if test="acctInfos != null">acct_infos,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="companyId != null">#{companyId},</if>
+            <if test="companyName != null and companyName != ''">#{companyName},</if>
+            <if test="divFlag != null">#{divFlag},</if>
+            <if test="delayAcctFlag != null">#{delayAcctFlag},</if>
+            <if test="percentageFlag != null">#{percentageFlag},</if>
+            <if test="isCleanSplit != null">#{isCleanSplit},</if>
+            <if test="acctInfos != null">#{acctInfos},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateCompanyDivConfig" parameterType="CompanyDivConfig">
+        update company_div_config
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="companyName != null and companyName != ''">company_name = #{companyName},</if>
+            <if test="divFlag != null">div_flag = #{divFlag},</if>
+            <if test="delayAcctFlag != null">delay_acct_flag = #{delayAcctFlag},</if>
+            <if test="percentageFlag != null">percentage_flag = #{percentageFlag},</if>
+            <if test="isCleanSplit != null">is_clean_split = #{isCleanSplit},</if>
+            <if test="acctInfos != null">acct_infos = #{acctInfos},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where company_id = #{companyId}
+    </update>
+
+    <delete id="deleteCompanyDivConfigByCompanyId" parameterType="Long">
+        delete from company_div_config where company_id = #{companyId}
+    </delete>
+
+    <delete id="deleteCompanyDivConfigByCompanyIds" parameterType="String">
+        delete from company_div_config where company_id in
+        <foreach item="companyId" collection="array" open="(" separator="," close=")">
+            #{companyId}
+        </foreach>
+    </delete>
+</mapper>

+ 103 - 0
fs-service/src/main/resources/mapper/company/CompanyDivItemMapper.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.company.mapper.CompanyDivItemMapper">
+
+    <resultMap type="CompanyDivItem" id="CompanyDivItemResult">
+        <result property="id"    column="id"    />
+<!--        <result property="orderId"    column="order_id"    />-->
+        <result property="orderCode"    column="order_code"    />
+        <result property="payCode"    column="pay_code"    />
+        <result property="detail"    column="detail"    />
+        <result property="refundDetail"    column="refund_detail"    />
+        <result property="isPay"    column="is_pay"    />
+        <result property="isDelay"    column="is_delay"    />
+        <result property="isRefund"    column="is_refund"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectCompanyDivItemVo">
+        select id, order_code, pay_code, detail,refund_detail,is_pay, is_delay, is_refund, create_time, update_time from company_div_item
+    </sql>
+
+    <select id="selectCompanyDivItemList" parameterType="CompanyDivItem" resultMap="CompanyDivItemResult">
+        <include refid="selectCompanyDivItemVo"/>
+        <where>
+            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
+            <if test="payCode != null  and payCode != ''"> and pay_code = #{payCode}</if>
+            <if test="detail != null  and detail != ''"> and detail = #{detail}</if>
+            <if test="refundDetail != null  and refundDetail != ''"> and refund_detail = #{refundDetail}</if>
+            <if test="isPay != null "> and is_pay = #{isPay}</if>
+            <if test="isDelay != null "> and is_delay = #{isDelay}</if>
+            <if test="isRefund != null "> and is_refund = #{isRefund}</if>
+        </where>
+    </select>
+
+    <select id="selectCompanyDivItemById" parameterType="Long" resultMap="CompanyDivItemResult">
+        <include refid="selectCompanyDivItemVo"/>
+        where id = #{id}
+    </select>
+    <select id="selectCompanyDivItemByOrderCode" resultType="com.fs.company.domain.CompanyDivItem">
+        <include refid="selectCompanyDivItemVo"/>
+        where order_code = #{orderCode}
+    </select>
+    <select id="selectCompanyDivItemByPayCode" resultType="com.fs.company.domain.CompanyDivItem">
+        <include refid="selectCompanyDivItemVo"/>
+        where pay_code = #{payCode}
+    </select>
+
+    <insert id="insertCompanyDivItem" parameterType="CompanyDivItem" useGeneratedKeys="true" keyProperty="id">
+        insert into company_div_item
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderCode != null and orderCode != ''">order_code,</if>
+            <if test="payCode != null and payCode != ''">pay_code,</if>
+            <if test="detail != null">detail,</if>
+            <if test="refundDetail != null">refund_detail,</if>
+            <if test="isPay != null">is_pay,</if>
+            <if test="isDelay != null">is_delay,</if>
+            <if test="isRefund != null">is_refund,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
+            <if test="payCode != null and payCode != ''">#{payCode},</if>
+            <if test="detail != null">#{detail},</if>
+            <if test="refundDetail != null">#{refundDetail},</if>
+            <if test="isPay != null">#{isPay},</if>
+            <if test="isDelay != null">#{isDelay},</if>
+            <if test="isRefund != null">#{isRefund},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateCompanyDivItem" parameterType="CompanyDivItem">
+        update company_div_item
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
+            <if test="payCode != null and payCode != ''">pay_code = #{payCode},</if>
+            <if test="detail != null">detail = #{detail},</if>
+            <if test="refundDetail != null">refund_detail = #{refundDetail},</if>
+            <if test="isPay != null">is_pay = #{isPay},</if>
+            <if test="isDelay != null">is_delay = #{isDelay},</if>
+            <if test="isRefund != null">is_refund = #{isRefund},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteCompanyDivItemById" parameterType="Long">
+        delete from company_div_item where id = #{id}
+    </delete>
+
+    <delete id="deleteCompanyDivItemByIds" parameterType="String">
+        delete from company_div_item where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 3 - 0
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -155,6 +155,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     #{periodId}
                 </foreach>
             </if>
+            <if test="maps.qwUserName != null  and maps.qwUserName != '' ">
+                and qu.qw_user_name = #{maps.qwUserName}
+            </if>
 
         </where>
          order by l.finish_time desc,l.update_time desc,l.create_time desc

+ 124 - 0
fs-service/src/main/resources/mapper/his/FsDfAccountMapper.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.his.mapper.FsDfAccountMapper">
+
+    <resultMap type="FsDfAccount" id="FsDfAccountResult">
+        <result property="id"    column="id"    />
+        <result property="dfAppKey"    column="df_app_key"    />
+        <result property="dfAppsecret"    column="df_appsecret"    />
+        <result property="loginAccount"    column="login_account"    />
+        <result property="callBackUrl"    column="call_back_url"    />
+        <result property="monthlyCard"    column="monthly_card"    />
+        <result property="expressProductCode"    column="express_product_code"    />
+        <result property="senderName"    column="sender_name"    />
+        <result property="senderPhone"    column="sender_phone"    />
+        <result property="cityIds"    column="city_ids"    />
+        <result property="senderProvince"    column="sender_province"    />
+        <result property="senderCity"    column="sender_city"    />
+        <result property="senderDistrict"    column="sender_district"    />
+        <result property="senderAddress"    column="sender_address"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectFsDfAccountVo">
+        select id, df_app_key, df_appsecret, login_account, call_back_url, monthly_card, express_product_code, sender_name, sender_phone, city_ids,sender_province, sender_city, sender_district, sender_address, create_time, update_time from fs_df_account
+    </sql>
+
+    <select id="selectFsDfAccountList" parameterType="FsDfAccount" resultMap="FsDfAccountResult">
+        <include refid="selectFsDfAccountVo"/>
+        <where>
+            <if test="dfAppKey != null  and dfAppKey != ''"> and df_app_key = #{dfAppKey}</if>
+            <if test="dfAppsecret != null  and dfAppsecret != ''"> and df_appsecret = #{dfAppsecret}</if>
+            <if test="loginAccount != null  and loginAccount != ''"> and login_account = #{loginAccount}</if>
+            <if test="callBackUrl != null  and callBackUrl != ''"> and call_back_url = #{callBackUrl}</if>
+            <if test="monthlyCard != null  and monthlyCard != ''"> and monthly_card = #{monthlyCard}</if>
+            <if test="expressProductCode != null  and expressProductCode != ''"> and express_product_code = #{expressProductCode}</if>
+            <if test="senderName != null  and senderName != ''"> and sender_name like concat('%', #{senderName}, '%')</if>
+            <if test="senderPhone != null  and senderPhone != ''"> and sender_phone = #{senderPhone}</if>
+            <if test="cityIds != null  and cityIds != ''"> and city_ids = #{cityIds}</if>
+            <if test="senderProvince != null  and senderProvince != ''"> and sender_province = #{senderProvince}</if>
+            <if test="senderCity != null  and senderCity != ''"> and sender_city = #{senderCity}</if>
+            <if test="senderDistrict != null  and senderDistrict != ''"> and sender_district = #{senderDistrict}</if>
+            <if test="senderAddress != null  and senderAddress != ''"> and sender_address = #{senderAddress}</if>
+        </where>
+    </select>
+
+    <select id="selectFsDfAccountById" parameterType="Long" resultMap="FsDfAccountResult">
+        <include refid="selectFsDfAccountVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertFsDfAccount" parameterType="FsDfAccount" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_df_account
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="dfAppKey != null and dfAppKey != ''">df_app_key,</if>
+            <if test="dfAppsecret != null and dfAppsecret != ''">df_appsecret,</if>
+            <if test="loginAccount != null and loginAccount != ''">login_account,</if>
+            <if test="callBackUrl != null and callBackUrl != ''">call_back_url,</if>
+            <if test="monthlyCard != null and monthlyCard != ''">monthly_card,</if>
+            <if test="expressProductCode != null and expressProductCode != ''">express_product_code,</if>
+            <if test="senderName != null and senderName != ''">sender_name,</if>
+            <if test="senderPhone != null and senderPhone != ''">sender_phone,</if>
+            <if test="cityIds != null and cityIds != ''">city_ids,</if>
+            <if test="senderProvince != null and senderProvince != ''">sender_province,</if>
+            <if test="senderCity != null and senderCity != ''">sender_city,</if>
+            <if test="senderDistrict != null and senderDistrict != ''">sender_district,</if>
+            <if test="senderAddress != null and senderAddress != ''">sender_address,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="dfAppKey != null and dfAppKey != ''">#{dfAppKey},</if>
+            <if test="dfAppsecret != null and dfAppsecret != ''">#{dfAppsecret},</if>
+            <if test="loginAccount != null and loginAccount != ''">#{loginAccount},</if>
+            <if test="callBackUrl != null and callBackUrl != ''">#{callBackUrl},</if>
+            <if test="monthlyCard != null and monthlyCard != ''">#{monthlyCard},</if>
+            <if test="expressProductCode != null and expressProductCode != ''">#{expressProductCode},</if>
+            <if test="senderName != null and senderName != ''">#{senderName},</if>
+            <if test="senderPhone != null and senderPhone != ''">#{senderPhone},</if>
+            <if test="cityIds != null and cityIds != ''">#{cityIds},</if>
+            <if test="senderProvince != null and senderProvince != ''">#{senderProvince},</if>
+            <if test="senderCity != null and senderCity != ''">#{senderCity},</if>
+            <if test="senderDistrict != null and senderDistrict != ''">#{senderDistrict},</if>
+            <if test="senderAddress != null and senderAddress != ''">#{senderAddress},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateFsDfAccount" parameterType="FsDfAccount">
+        update fs_df_account
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="dfAppKey != null and dfAppKey != ''">df_app_key = #{dfAppKey},</if>
+            <if test="dfAppsecret != null and dfAppsecret != ''">df_appsecret = #{dfAppsecret},</if>
+            <if test="loginAccount != null and loginAccount != ''">login_account = #{loginAccount},</if>
+            <if test="callBackUrl != null and callBackUrl != ''">call_back_url = #{callBackUrl},</if>
+            <if test="monthlyCard != null and monthlyCard != ''">monthly_card = #{monthlyCard},</if>
+            <if test="expressProductCode != null and expressProductCode != ''">express_product_code = #{expressProductCode},</if>
+            <if test="senderName != null and senderName != ''">sender_name = #{senderName},</if>
+            <if test="senderPhone != null and senderPhone != ''">sender_phone = #{senderPhone},</if>
+            <if test="cityIds != null">city_ids = #{cityIds},</if>
+            <if test="senderProvince != null and senderProvince != ''">sender_province = #{senderProvince},</if>
+            <if test="senderCity != null and senderCity != ''">sender_city = #{senderCity},</if>
+            <if test="senderDistrict != null and senderDistrict != ''">sender_district = #{senderDistrict},</if>
+            <if test="senderAddress != null and senderAddress != ''">sender_address = #{senderAddress},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteFsDfAccountById" parameterType="Long">
+        delete from fs_df_account where id = #{id}
+    </delete>
+
+    <delete id="deleteFsDfAccountByIds" parameterType="String">
+        delete from fs_df_account where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 1 - 1
fs-service/src/main/resources/mapper/his/FsPackageMapper.xml

@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT i.icd_name
         FROM fs_package p
                  LEFT JOIN fs_icd i ON FIND_IN_SET(i.icd_code, p.icd_code) > 0
-        WHERE package_id = #{packageId};
+        WHERE package_id = #{packageId}
     </select>
 
     <select id="selectFsPackageListByIds" resultType="com.fs.his.domain.FsPackage">

+ 7 - 7
fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml

@@ -571,7 +571,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and so.status = #{maps.status}
         </if>
         <if test="maps.status == 6">
-            and so.`status`= 2
+            and so.`status`= 1
             and (
             so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
             )
@@ -779,7 +779,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and so.status = #{maps.status}
             </if>
             <if test="maps.status == 6">
-                and so.`status`= 2
+                and so.`status`= 1
                 and (
                 so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
                 )
@@ -997,7 +997,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and so.status = #{maps.status}
             </if>
             <if test="maps.status == 6">
-                and so.`status`= 2
+                and so.`status`= 1
                 and (
                 so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
                 )
@@ -1221,7 +1221,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and so.status = #{maps.status}
         </if>
         <if test="maps.status == 6">
-            and so.`status`= 2
+            and so.`status`= 1
             and ( so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1))
             and  (so.extend_order_id is null or  so.extend_order_id like '')
         </if>
@@ -1453,7 +1453,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND so.status = #{maps.status}
         </if>
         <if test="maps.status == 6">
-            AND so.`status` = 2
+            AND so.`status` = 1
             AND (
             so.store_id IN (SELECT store_id FROM fs_store WHERE delivery_type=2 OR delivery_type=1)
             )
@@ -1703,7 +1703,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and so.status = #{maps.status}
             </if>
             <if test="maps.status == 6">
-                and so.`status`= 2
+                and so.`status`= 1
                 and (
                 so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
                 )
@@ -1914,7 +1914,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and so.status = #{maps.status}
             </if>
             <if test="maps.status == 6">
-                and so.`status`= 2
+                and so.`status`= 1
                 and (
                 so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
                 )

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

@@ -964,12 +964,903 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{item.orderNumber}
         </foreach>
     </update>
+    <update id="batchUpdateErpByOrderIds">
+        UPDATE fs_store_order_scrm
+        SET erp_phone =
+        <trim prefix="CASE id" suffix="END">
+            <foreach collection="maps" item="map">
+                WHEN #{map.orderId} THEN #{map.erpPhone}
+            </foreach>
+        </trim>
+        WHERE id IN
+        <foreach collection="maps" item="map" open="(" separator="," close=")">
+            #{map.orderId}
+        </foreach>
+    </update>
 
     <select id="selectStoreOrderScrmInId" resultType="com.fs.hisStore.domain.FsStoreOrderScrm">
         <include refid="selectFsStoreOrderVo"/>
         where id IN <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
             #{item}
     </foreach>
+    </select>
+    <select id="selectFsStoreOrderListVOByErpAccount" resultType="com.fs.hisStore.vo.FsStoreOrderVO">
+        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,,df.login_account as erp_account,
+        from fs_store_order_scrm o
+            left join fs_user u on o.user_id=u.user_id
+            left join company c on c.company_id=o.company_id
+            left join company_user cu on cu.user_id=o.company_user_id
+            LEFT JOIN fs_store_order_df df on df.order_id=o.id
+        <if test = "maps.productName != null and  maps.productName !=  '' ">
+            left join fs_store_order_item_scrm oi on o.id = oi.order_id
+            left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
+        </if>
+        LEFT JOIN (
+        SELECT
+        sp.*,
+        ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
+        FROM fs_store_payment_scrm sp
+        ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
+        LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+        <where>
+            <if test="maps.coursePlaySourceConfigId != null">
+                and csc.id = #{maps.coursePlaySourceConfigId}
+            </if>
+            <if test="maps.orderCodes != null  and maps.orderCodes.size > 0">
+                and o.order_code in
+                <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
+                    #{orderCode}
+                </foreach>
+            </if>
+            <if test="maps.orderCode != null and  maps.orderCode !=''">
+                and o.order_code like CONCAT('%',#{maps.orderCode},'%')
+            </if>
+            <if test="maps.isPayRemain != null">
+                and o.is_pay_remain =#{maps.isPayRemain}
+            </if>
+            <if test="maps.userId != null">
+                and o.user_id =#{maps.userId}
+            </if>
+            <if test="maps.deliveryId != null and  maps.deliveryId !=''">
+                and o.delivery_id =#{maps.deliveryId}
+            </if>
+            <if test="maps.nickname != null and  maps.nickname !=''">
+                and u.nickname like CONCAT('%',#{maps.nickname},'%')
+            </if>
+            <if test="maps.realName != null and  maps.realName !=''">
+                and o.real_name like CONCAT('%',#{maps.realName},'%')
+            </if>
+            <if test="maps.phone != null and  maps.phone !=''">
+                and u.phone like CONCAT('%',#{maps.phone},'%')
+            </if>
+            <if test="maps.userPhone != null and  maps.userPhone !=''">
+                and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
+            </if>
+
+            <if test="maps.status != null and maps.status != 6">
+                and o.status = #{maps.status}
+            </if>
+            <if test="maps.status == 6">
+                and o.`status`= 2
+
+                and  (o.extend_order_id is null or  o.extend_order_id like '')
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 0    ">
+                and o.certificates is null
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 1    ">
+                and o.certificates is not null
+            </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.companyId != null   ">
+                and o.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.isHealth != null and maps.isHealth !=  ''   ">
+                and o.company_id is null
+            </if>
+            <if test="maps.notHealth != null  ">
+                and o.company_id is not null
+            </if>
+            <if test="maps.companyUserId != null  ">
+                and o.company_user_id =#{maps.companyUserId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+                and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.productName != null and  maps.productName !=  '' ">
+                and fsp.product_name like concat('%', #{maps.productName}, '%')
+            </if>
+            <if test="maps.orderType != null    ">
+                and o.order_type =#{maps.orderType}
+            </if>
+            <if test="maps.payType != null    ">
+                and o.pay_type =#{maps.payType}
+            </if>
+            <if test="maps.scheduleId != null    ">
+                and o.schedule_id =#{maps.scheduleId}
+            </if>
+            <if test="maps.createTimeList != null    ">
+                AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
+                AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliverySendTimeList != null    ">
+                AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.paidStatus != null    ">
+                and o.paid =#{maps.paidStatus}
+            </if>
+            <if test="maps.payTimeList != null     ">
+                AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
+                AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliveryImportTimeList != null     ">
+                AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deptId != null     ">
+                AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
+                and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
+            </if>
+            <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
+                and df.login_account like #{maps.erpAccount}
+            </if>
+            <if test="maps.erpAccount == '未分拣'">
+                and ( df.login_account is null or df.login_account like '')
+            </if>
+        </where>
+       ${maps.params.dataScope}
+        <if test="maps.productName != null and  maps.productName !=  ''   ">
+            group by o.id
+        </if>
+        ORDER BY
+
+        <if test="maps.sortField == 'companyUserName'">
+            cu.nick_name
+        </if>
+        <if test="maps.sortField == 'packageName'">
+            o.package_name
+        </if>
+        <if test="maps.sortField == 'payPrice'">
+            o.pay_price
+        </if>
+        <if test="maps.sortField == 'payMoney'">
+            o.pay_money
+        </if>
+        <if test="maps.sortOrder != null and maps.sortOrder != ''">
+            ${maps.sortOrder}
+        </if>
+        <if test="maps.sortField == null or maps.sortField == ''">
+            o.id desc
+        </if>
+
+    </select>
+    <select id="selectFsStoreOrderListVOByErpAccountByExportCount" resultType="java.lang.Long">
+        select count(1)
+        from fs_store_order_scrm o
+        <if test="(maps.phone != null and  maps.phone !='') or (maps.nickname != null and  maps.nickname !='')">
+            left join fs_user u on o.user_id=u.user_id
+        </if>
+       <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+           left join company_user cu on cu.user_id=o.company_user_id
+       </if>
+
+        <if test = "maps.productName != null and  maps.productName !=  '' ">
+            left join fs_store_order_item_scrm oi on o.id = oi.order_id
+            left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
+        </if>
+        <if test="maps.erpAccount != null and  maps.erpAccount != ''">
+            LEFT JOIN fs_store_order_df df on df.order_id==o.id
+        </if>
+        <if test="maps.coursePlaySourceConfigId != null">
+            LEFT JOIN (
+            SELECT
+            sp.*,
+            ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
+            FROM fs_store_payment_scrm sp
+            ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
+            LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+        </if>
+        <where>
+            <if test="maps.coursePlaySourceConfigId != null">
+                and csc.id = #{maps.coursePlaySourceConfigId}
+            </if>
+            <if test="maps.orderCodes != null  and maps.orderCodes.size > 0">
+                and o.order_code in
+                <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
+                    #{orderCode}
+                </foreach>
+            </if>
+            <if test="maps.orderCode != null and  maps.orderCode !=''">
+                and o.order_code like CONCAT('%',#{maps.orderCode},'%')
+            </if>
+            <if test="maps.isPayRemain != null">
+                and o.is_pay_remain =#{maps.isPayRemain}
+            </if>
+            <if test="maps.userId != null">
+                and o.user_id =#{maps.userId}
+            </if>
+            <if test="maps.deliveryId != null and  maps.deliveryId !=''">
+                and o.delivery_id =#{maps.deliveryId}
+            </if>
+            <if test="maps.nickname != null and  maps.nickname !=''">
+                and u.nickname like CONCAT('%',#{maps.nickname},'%')
+            </if>
+            <if test="maps.realName != null and  maps.realName !=''">
+                and o.real_name like CONCAT('%',#{maps.realName},'%')
+            </if>
+            <if test="maps.phone != null and  maps.phone !=''">
+                and u.phone like CONCAT('%',#{maps.phone},'%')
+            </if>
+            <if test="maps.userPhone != null and  maps.userPhone !=''">
+                and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
+            </if>
+
+            <if test="maps.status != null and maps.status != 6">
+                and o.status = #{maps.status}
+            </if>
+            <if test="maps.status == 6">
+                and o.`status`= 2
+
+                and  (o.extend_order_id is null or  o.extend_order_id like '')
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 0    ">
+                and o.certificates is null
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 1    ">
+                and o.certificates is not null
+            </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.companyId != null   ">
+                and o.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.isHealth != null and maps.isHealth !=  ''   ">
+                and o.company_id is null
+            </if>
+            <if test="maps.notHealth != null  ">
+                and o.company_id is not null
+            </if>
+            <if test="maps.companyUserId != null  ">
+                and o.company_user_id =#{maps.companyUserId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+                and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.productName != null and  maps.productName !=  '' ">
+                and fsp.product_name like concat('%', #{maps.productName}, '%')
+            </if>
+            <if test="maps.orderType != null    ">
+                and o.order_type =#{maps.orderType}
+            </if>
+            <if test="maps.payType != null    ">
+                and o.pay_type =#{maps.payType}
+            </if>
+            <if test="maps.scheduleId != null    ">
+                and o.schedule_id =#{maps.scheduleId}
+            </if>
+            <if test="maps.createTimeList != null    ">
+                AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
+                AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliverySendTimeList != null    ">
+                AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.paidStatus != null    ">
+                and o.paid =#{maps.paidStatus}
+            </if>
+            <if test="maps.payTimeList != null     ">
+                AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
+                AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliveryImportTimeList != null     ">
+                AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deptId != null     ">
+                AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
+                and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
+            </if>
+            <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
+                and df.login_account like #{maps.erpAccount}
+            </if>
+            <if test="maps.erpAccount == '未分拣'">
+                and ( df.login_account is null or df.login_account like '')
+            </if>
+        </where>
+        <if test="maps.productName != null and  maps.productName !=  ''   ">
+            group by o.id
+        </if>
+
+
+    </select>
+    <select id="selectFsStoreOrderStatistics" resultType="java.util.Map">
+        select sum(o.pay_price) pay_price,sum(o.pay_money) pay_money,sum(o.pay_delivery) pay_remain
+        FROM fs_store_order_scrm o
+        left join fs_user u on o.user_id=u.user_id
+        left join company c on c.company_id=o.company_id
+        left join company_user cu on cu.user_id=o.company_user_id
+        <if test="maps.erpAccount != null or maps.erpAccount != ''">
+            LEFT JOIN fs_store_order_df df on df.order_id=o.id
+        </if>
+        <if test = "maps.productName != null and  maps.productName !=  '' ">
+            left join fs_store_order_item_scrm oi on o.id = oi.order_id
+            left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
+        </if>
+        <if test="maps.coursePlaySourceConfigId != null">
+            LEFT JOIN (
+            SELECT
+            sp.*,
+            ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
+            FROM fs_store_payment_scrm sp
+            WHERE sp.business_code IS NOT NULL
+            ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
+            LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+        </if>
+        <where>
+            <if test="maps.coursePlaySourceConfigId != null">
+                and csc.id = #{maps.coursePlaySourceConfigId}
+            </if>
+            <if test="maps.orderCodes != null  and maps.orderCodes.size > 0">
+                and o.order_code in
+                <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
+                    #{orderCode}
+                </foreach>
+            </if>
+            <if test="maps.orderCode != null and  maps.orderCode !=''">
+                and o.order_code like CONCAT('%',#{maps.orderCode},'%')
+            </if>
+            <if test="maps.isPayRemain != null">
+                and o.is_pay_remain =#{maps.isPayRemain}
+            </if>
+            <if test="maps.userId != null">
+                and o.user_id =#{maps.userId}
+            </if>
+            <if test="maps.deliveryId != null and  maps.deliveryId !=''">
+                and o.delivery_id =#{maps.deliveryId}
+            </if>
+            <if test="maps.nickname != null and  maps.nickname !=''">
+                and u.nickname like CONCAT('%',#{maps.nickname},'%')
+            </if>
+            <if test="maps.realName != null and  maps.realName !=''">
+                and o.real_name like CONCAT('%',#{maps.realName},'%')
+            </if>
+            <if test="maps.phone != null and  maps.phone !=''">
+                and u.phone like CONCAT('%',#{maps.phone},'%')
+            </if>
+            <if test="maps.userPhone != null and  maps.userPhone !=''">
+                and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
+            </if>
+
+            <if test="maps.status != null and maps.status != 6">
+                and o.status = #{maps.status}
+            </if>
+            <if test="maps.status == 6">
+                and o.`status`= 1
+
+                and  (o.extend_order_id is null or  o.extend_order_id like '')
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 0    ">
+                and o.certificates is null
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 1    ">
+                and o.certificates is not null
+            </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.companyId != null   ">
+                and o.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.isHealth != null and maps.isHealth !=  ''   ">
+                and o.company_id is null
+            </if>
+            <if test="maps.notHealth != null  ">
+                and o.company_id is not null
+            </if>
+            <if test="maps.companyUserId != null  ">
+                and o.company_user_id =#{maps.companyUserId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+                and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.productName != null and  maps.productName !=  '' ">
+                and fsp.product_name like concat('%', #{maps.productName}, '%')
+            </if>
+            <if test="maps.orderType != null    ">
+                and o.order_type =#{maps.orderType}
+            </if>
+            <if test="maps.payType != null    ">
+                and o.pay_type =#{maps.payType}
+            </if>
+            <if test="maps.scheduleId != null    ">
+                and o.schedule_id =#{maps.scheduleId}
+            </if>
+            <if test="maps.createTimeList != null    ">
+                AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
+                AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliverySendTimeList != null    ">
+                AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.paidStatus != null    ">
+                and o.paid =#{maps.paidStatus}
+            </if>
+            <if test="maps.payTimeList != null     ">
+                AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
+                AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliveryImportTimeList != null     ">
+                AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deptId != null     ">
+                AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
+                and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
+            </if>
+            <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
+                and df.login_account like #{maps.erpAccount}
+            </if>
+            <if test="maps.erpAccount == '未分拣'">
+                and ( df.login_account is null or df.login_account like '')
+            </if>
+
+        </where>
+        ${maps.params.dataScope}
+    </select>
+    <select id="selectFsStoreOrderProductStatistics" resultType="java.lang.String">
+        SELECT GROUP_CONCAT(
+        CONCAT(product_name, ':', product_num)
+        ORDER BY product_name
+        SEPARATOR '   '
+        ) AS product_num_list
+        FROM (
+        SELECT sp.product_name,SUM(IF(soi.num IS NULL,0,soi.num)) product_num
+        FROM fs_store_product_scrm sp
+        INNER JOIN fs_store_order_item_scrm soi ON soi.product_id = sp.product_id
+        INNER JOIN fs_store_order_scrm o ON soi.order_id = o.id
+        LEFT JOIN fs_user us ON us.user_id=o.user_id
+        LEFT JOIN company_user cu on cu.user_id=o.company_user_id
+        LEFT JOIN fs_store_order_df df on df.order_id=o.id
+        <if test="maps.coursePlaySourceConfigId != null">
+            LEFT JOIN (
+            SELECT
+            sp.*,
+            ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
+            FROM fs_store_payment_scrm sp
+            WHERE sp.business_code IS NOT NULL
+            ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
+            LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+        </if>
+        <where>
+            <if test="maps.coursePlaySourceConfigId != null">
+                and csc.id = #{maps.coursePlaySourceConfigId}
+            </if>
+            <if test="maps.orderCodes != null  and maps.orderCodes.size > 0">
+                and o.order_code in
+                <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
+                    #{orderCode}
+                </foreach>
+            </if>
+            <if test="maps.orderCode != null and  maps.orderCode !=''">
+                and o.order_code like CONCAT('%',#{maps.orderCode},'%')
+            </if>
+            <if test="maps.isPayRemain != null">
+                and o.is_pay_remain =#{maps.isPayRemain}
+            </if>
+            <if test="maps.userId != null">
+                and o.user_id =#{maps.userId}
+            </if>
+            <if test="maps.deliveryId != null and  maps.deliveryId !=''">
+                and o.delivery_id =#{maps.deliveryId}
+            </if>
+            <if test="maps.nickname != null and  maps.nickname !=''">
+                and u.nickname like CONCAT('%',#{maps.nickname},'%')
+            </if>
+            <if test="maps.realName != null and  maps.realName !=''">
+                and o.real_name like CONCAT('%',#{maps.realName},'%')
+            </if>
+            <if test="maps.phone != null and  maps.phone !=''">
+                and u.phone like CONCAT('%',#{maps.phone},'%')
+            </if>
+            <if test="maps.userPhone != null and  maps.userPhone !=''">
+                and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
+            </if>
+
+            <if test="maps.status != null and maps.status != 6">
+                and o.status = #{maps.status}
+            </if>
+            <if test="maps.status == 6">
+                and o.`status`= 1
+
+                and  (o.extend_order_id is null or  o.extend_order_id like '')
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 0    ">
+                and o.certificates is null
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 1    ">
+                and o.certificates is not null
+            </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.companyId != null   ">
+                and o.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.isHealth != null and maps.isHealth !=  ''   ">
+                and o.company_id is null
+            </if>
+            <if test="maps.notHealth != null  ">
+                and o.company_id is not null
+            </if>
+            <if test="maps.companyUserId != null  ">
+                and o.company_user_id =#{maps.companyUserId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+                and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.productName != null and  maps.productName !=  '' ">
+                and fsp.product_name like concat('%', #{maps.productName}, '%')
+            </if>
+            <if test="maps.orderType != null    ">
+                and o.order_type =#{maps.orderType}
+            </if>
+            <if test="maps.payType != null    ">
+                and o.pay_type =#{maps.payType}
+            </if>
+            <if test="maps.scheduleId != null    ">
+                and o.schedule_id =#{maps.scheduleId}
+            </if>
+            <if test="maps.createTimeList != null    ">
+                AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
+                AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliverySendTimeList != null    ">
+                AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.paidStatus != null    ">
+                and o.paid =#{maps.paidStatus}
+            </if>
+            <if test="maps.payTimeList != null     ">
+                AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
+                AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliveryImportTimeList != null     ">
+                AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deptId != null     ">
+                AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
+                and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
+            </if>
+            <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
+                and df.login_account like #{maps.erpAccount}
+            </if>
+            <if test="maps.erpAccount == '未分拣'">
+                and ( df.login_account is null or df.login_account like '')
+            </if>
+        </where>
+        ${maps.params.dataScope} GROUP BY sp.product_id
+        ) AS t
+    </select>
+    <select id="selectFsStoreOrderListVO" resultType="com.fs.hisStore.vo.FsStoreOrderVO">
+        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
+        , csc.name miniProgramName
+        from fs_store_order_scrm o
+        left join fs_user u on o.user_id=u.user_id
+        left join company c on c.company_id=o.company_id
+        left join company_user cu on cu.user_id=o.company_user_id
+        <if test="maps.erpAccount != null and maps.erpAccount != ''">
+            LEFT JOIN fs_store_order_df df on df.order_id=o.id
+
+        </if>
+        <if test = "maps.productName != null and  maps.productName !=  '' ">
+            left join fs_store_order_item_scrm oi on o.id = oi.order_id
+            left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
+        </if>
+        LEFT JOIN (
+        SELECT
+        sp.*,
+        ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
+        FROM fs_store_payment_scrm sp
+        WHERE sp.business_code IS NOT NULL
+        ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
+        LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+        <where>
+            <if test="maps.coursePlaySourceConfigId != null">
+                and csc.id = #{maps.coursePlaySourceConfigId}
+            </if>
+            <if test="maps.orderCodes != null  and maps.orderCodes.size > 0">
+                and o.order_code in
+                <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
+                    #{orderCode}
+                </foreach>
+            </if>
+            <if test="maps.orderCode != null and  maps.orderCode !=''">
+                and o.order_code like CONCAT('%',#{maps.orderCode},'%')
+            </if>
+            <if test="maps.isPayRemain != null">
+                and o.is_pay_remain =#{maps.isPayRemain}
+            </if>
+            <if test="maps.userId != null">
+                and o.user_id =#{maps.userId}
+            </if>
+            <if test="maps.deliveryId != null and  maps.deliveryId !=''">
+                and o.delivery_id =#{maps.deliveryId}
+            </if>
+            <if test="maps.nickname != null and  maps.nickname !=''">
+                and u.nickname like CONCAT('%',#{maps.nickname},'%')
+            </if>
+            <if test="maps.realName != null and  maps.realName !=''">
+                and o.real_name like CONCAT('%',#{maps.realName},'%')
+            </if>
+            <if test="maps.phone != null and  maps.phone !=''">
+                and u.phone like CONCAT('%',#{maps.phone},'%')
+            </if>
+            <if test="maps.userPhone != null and  maps.userPhone !=''">
+                and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
+            </if>
+            <if test="maps.status != null and maps.status != 6">
+                and o.status = #{maps.status}
+            </if>
+            <if test="maps.status == 6">
+                and o.`status`= 1
+                and  (o.extend_order_id is null or  o.extend_order_id like '')
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 0    ">
+                and o.certificates is null
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 1    ">
+                and o.certificates is not null
+            </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.companyId != null   ">
+                and o.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.isHealth != null and maps.isHealth !=  ''   ">
+                and o.company_id is null
+            </if>
+            <if test="maps.notHealth != null  ">
+                and o.company_id is not null
+            </if>
+            <if test="maps.companyUserId != null  ">
+                and o.company_user_id =#{maps.companyUserId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+                and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.productName != null and  maps.productName !=  '' ">
+                and fsp.product_name like concat('%', #{maps.productName}, '%')
+            </if>
+            <if test="maps.orderType != null    ">
+                and o.order_type =#{maps.orderType}
+            </if>
+            <if test="maps.payType != null    ">
+                and o.pay_type =#{maps.payType}
+            </if>
+            <if test="maps.scheduleId != null    ">
+                and o.schedule_id =#{maps.scheduleId}
+            </if>
+            <if test="maps.createTimeList != null    ">
+                AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
+                AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliverySendTimeList != null    ">
+                AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.paidStatus != null    ">
+                and o.paid =#{maps.paidStatus}
+            </if>
+            <if test="maps.payTimeList != null     ">
+                AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
+                AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliveryImportTimeList != null     ">
+                AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deptId != null     ">
+                AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
+                and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
+            </if>
+            <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
+                and df.login_account like #{maps.erpAccount}
+            </if>
+            <if test="maps.erpAccount == '未分拣'">
+                and ( df.login_account is null or df.login_account like '')
+            </if>
+        </where>
+        ${maps.params.dataScope}
+        <if test="maps.productName != null and  maps.productName !=  ''   ">
+            group by o.id
+        </if>
+            order by
+        <if test="maps.sortField == 'companyUserName'">
+            cu.nick_name
+        </if>
+        <if test="maps.sortField == 'packageName'">
+            o.package_name
+        </if>
+        <if test="maps.sortField == 'payPrice'">
+            o.pay_price
+        </if>
+        <if test="maps.sortField == 'payMoney'">
+            o.pay_money
+        </if>
+        <if test="maps.sortOrder != null and maps.sortOrder != ''">
+            ${maps.sortOrder}
+        </if>
+        <if test="maps.sortField == null or maps.sortField == ''">
+            o.id desc
+        </if>
+    </select>
+
+    <select id="selectFsStoreOrderListVO_COUNT" resultType="java.lang.Long">
+        select count(*)
+        from fs_store_order_scrm o
+        <if test="(maps.nickname != null and  maps.nickname !='') or (maps.phone != null and  maps.phone !='')">
+            left join fs_user u on o.user_id=u.user_id
+        </if>
+        <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  ''">
+            left join company_user cu on cu.user_id=o.company_user_id
+        </if>
+        <if test = "maps.productName != null and  maps.productName !=  '' ">
+            left join fs_store_order_item_scrm oi on o.id = oi.order_id
+            left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
+        </if>
+        <if test="maps.coursePlaySourceConfigId != null">
+            LEFT JOIN (
+            SELECT
+            sp.*,
+            ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
+            FROM fs_store_payment_scrm sp
+            WHERE sp.business_code IS NOT NULL
+            ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
+            LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
+        </if>
+
+        <where>
+            <if test="maps.coursePlaySourceConfigId != null">
+                and csc.id = #{maps.coursePlaySourceConfigId}
+            </if>
+            <if test="maps.orderCode != null and  maps.orderCode !=''">
+                and o.order_code like CONCAT('%',#{maps.orderCode},'%')
+            </if>
+            <if test="maps.isPayRemain != null">
+                and o.is_pay_remain =#{maps.isPayRemain}
+            </if>
+            <if test="maps.userId != null">
+                and o.user_id =#{maps.userId}
+            </if>
+            <if test="maps.deliveryId != null and  maps.deliveryId !=''">
+                and o.delivery_id =#{maps.deliveryId}
+            </if>
+            <if test="maps.nickname != null and  maps.nickname !=''">
+                and u.nickname like CONCAT('%',#{maps.nickname},'%')
+            </if>
+            <if test="maps.realName != null and  maps.realName !=''">
+                and o.real_name like CONCAT('%',#{maps.realName},'%')
+            </if>
+            <if test="maps.phone != null and  maps.phone !=''">
+                and u.phone like CONCAT('%',#{maps.phone},'%')
+            </if>
+            <if test="maps.userPhone != null and  maps.userPhone !=''">
+                and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
+            </if>
+            <if test="maps.status != null and maps.status != 6">
+                and o.status = #{maps.status}
+            </if>
+            <if test="maps.status == 6">
+                and o.`status`= 2
+                and  ( o.extend_order_id is null or  o.extend_order_id like '')
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 0    ">
+                and o.certificates is null
+            </if>
+            <if test="maps.isUpload != null and maps.isUpload == 1    ">
+                and o.certificates is not null
+            </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.companyId != null   ">
+                and o.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.isHealth != null and maps.isHealth !=  ''   ">
+                and o.company_id is null
+            </if>
+            <if test="maps.notHealth != null  ">
+                and o.company_id is not null
+            </if>
+            <if test="maps.companyUserId != null  ">
+                and o.company_user_id =#{maps.companyUserId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
+                and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.productName != null and  maps.productName !=  '' ">
+                and fsp.product_name like concat('%', #{maps.productName}, '%')
+            </if>
+            <if test="maps.orderType != null    ">
+                and o.order_type =#{maps.orderType}
+            </if>
+            <if test="maps.payType != null    ">
+                and o.pay_type =#{maps.payType}
+            </if>
+            <if test="maps.scheduleId != null    ">
+                and o.schedule_id =#{maps.scheduleId}
+            </if>
+            <if test="maps.createTimeList != null    ">
+                AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
+                AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliverySendTimeList != null    ">
+                AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.paidStatus != null    ">
+                and o.paid =#{maps.paidStatus}
+            </if>
+            <if test="maps.payTimeList != null     ">
+                AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
+                AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deliveryImportTimeList != null     ">
+                AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
+                AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
+            </if>
+            <if test="maps.deptId != null     ">
+                AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
+                and so.erp_phone like concat(#{maps.erpPhoneNumber},'%')
+            </if>
+        </where>
+        ${maps.params.dataScope}
+        <if test="maps.productName != null and  maps.productName !=  ''   ">
+            group by o.id
+        </if>
+        order by o.id desc
+    </select>
+    <select id="selectAddTuiMoney" resultType="java.lang.Long">
+
     </select>
     <select id="selectFsStoreOrderAmountScrmStats" resultType="com.fs.his.vo.FsStoreOrderAmountScrmStatsVo">
         SELECT

+ 49 - 0
fs-user-app/src/main/java/com/fs/app/controller/HuifuPayController.java

@@ -1,6 +1,8 @@
 package com.fs.app.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.fs.company.domain.CompanyDivItem;
+import com.fs.company.service.ICompanyDivItemService;
 import com.fs.course.service.IFsCourseProductOrderService;
 import com.fs.course.service.IFsUserCourseOrderService;
 import com.fs.course.service.IFsUserVipOrderService;
@@ -36,6 +38,9 @@ public class HuifuPayController {
     private IFsCourseProductOrderService courseProductOrderService;
 
     org.slf4j.Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private ICompanyDivItemService companyDivItemService;
+
     @RequestMapping("/payNotifyUrl")
     public String asyncMessage(@RequestParam String resp_desc,@RequestParam String resp_code,@RequestParam String sign,@RequestParam String resp_data) {
         HuiFuResult huiFuResult = JSON.parseObject(resp_data, HuiFuResult.class);
@@ -45,24 +50,59 @@ public class HuifuPayController {
             switch (orderId[0]){
                 case "inquiry":
                     inquiryOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
                 case "store":
                     storeOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
                 case "package":
                     packageOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
                 case "course":
                     courseOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
                 case "appvip":
                     vipOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
                 case "integral":
                     integralOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
                 case "product":
                     courseProductOrderService.payConfirm("",orderId[1],huiFuResult.getHf_seq_id(),"",1,huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+                    try {
+                        updateDivItem(orderId[1]);
+                    } catch (Exception e) {
+                        logger.error("-------分账明细回调错误{}", e.getMessage());
+                    }
                     break;
             }
         }
@@ -70,6 +110,15 @@ public class HuifuPayController {
         return "ok";
     }
 
+    private void updateDivItem(String orderId) {
+        //修改分账状态
+        CompanyDivItem companyDivItem = companyDivItemService.selectCompanyDivItemByPayCode(orderId);
+        if (companyDivItem != null) {
+            companyDivItem.setIsPay(1);
+            companyDivItemService.updateCompanyDivItem(companyDivItem);
+        }
+    }
+
 
     @RequestMapping("/payOnlineNotifyUrl")
     public String asyncHuFuOnlinePay(@RequestParam String resp_desc,@RequestParam String resp_code,@RequestParam String sign,@RequestParam String resp_data) {