Ver código fonte

商城对接代服

ct 1 dia atrás
pai
commit
201a411e7d
23 arquivos alterados com 2600 adições e 251 exclusões
  1. 103 0
      fs-admin/src/main/java/com/fs/his/controller/FsDfAccountController.java
  2. 92 13
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java
  3. 300 17
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  4. 23 7
      fs-company/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  5. 11 9
      fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  6. 8 18
      fs-service/src/main/java/com/fs/erp/dto/sdk/df/DfClient.java
  7. 254 70
      fs-service/src/main/java/com/fs/erp/service/impl/DfOrderServiceImpl.java
  8. 74 0
      fs-service/src/main/java/com/fs/his/domain/FsDfAccount.java
  9. 61 0
      fs-service/src/main/java/com/fs/his/mapper/FsDfAccountMapper.java
  10. 61 0
      fs-service/src/main/java/com/fs/his/service/IFsDfAccountService.java
  11. 94 0
      fs-service/src/main/java/com/fs/his/service/impl/FsDfAccountServiceImpl.java
  12. 3 0
      fs-service/src/main/java/com/fs/his/vo/FsStoreOrderExcelVO.java
  13. 38 3
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java
  14. 257 103
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java
  15. 22 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderParam.java
  16. 14 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderScrmSetErpPhoneParam.java
  17. 14 1
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java
  18. 115 3
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  19. 24 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderErpExportVO.java
  20. 10 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderVO.java
  21. 124 0
      fs-service/src/main/resources/mapper/his/FsDfAccountMapper.xml
  22. 7 7
      fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml
  23. 891 0
      fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

+ 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;
+    }
 }

+ 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 - 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);
+                }
             }
         }
     }

+ 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);
+    }
+}

+ 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;
+
 
 }

+ 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>

+ 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