Quellcode durchsuchen

直播代码提交

yuhongqi vor 3 Tagen
Ursprung
Commit
86f3b5b040
43 geänderte Dateien mit 4707 neuen und 671 gelöschten Zeilen
  1. 326 0
      fs-admin/src/main/java/com/fs/live/controller/LiveHealthOrderController.java
  2. 233 10
      fs-admin/src/main/java/com/fs/live/controller/LiveOrderController.java
  3. 4 3
      fs-company/src/main/java/com/fs/company/controller/live/LiveOrderController.java
  4. 4 0
      fs-service/src/main/java/com/fs/company/service/ICompanyService.java
  5. 24 0
      fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  6. 7 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrder.java
  7. 66 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrderDf.java
  8. 52 0
      fs-service/src/main/java/com/fs/live/dto/LiveOrderDeliveryNoteDTO.java
  9. 31 0
      fs-service/src/main/java/com/fs/live/dto/LiveOrderExpressExportDTO.java
  10. 24 0
      fs-service/src/main/java/com/fs/live/mapper/LiveAfterSalesMapper.java
  11. 62 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderDfMapper.java
  12. 73 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java
  13. 307 3
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  14. 16 0
      fs-service/src/main/java/com/fs/live/param/FsMyLiveOrderQueryParam.java
  15. 50 0
      fs-service/src/main/java/com/fs/live/param/LiveAfterSalesParam.java
  16. 17 0
      fs-service/src/main/java/com/fs/live/param/LiveAfterSalesProductParam.java
  17. 15 0
      fs-service/src/main/java/com/fs/live/param/LiveAfterSalesQueryParam.java
  18. 59 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderCreateParam.java
  19. 15 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderExpressParam.java
  20. 114 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderParam.java
  21. 24 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderPayParam.java
  22. 15 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderScrmSetErpPhoneParam.java
  23. 8 8
      fs-service/src/main/java/com/fs/live/service/ILiveAfterSalesService.java
  24. 62 0
      fs-service/src/main/java/com/fs/live/service/ILiveOrderDfService.java
  25. 4 0
      fs-service/src/main/java/com/fs/live/service/ILiveOrderItemService.java
  26. 31 9
      fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java
  27. 231 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java
  28. 93 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderDfServiceImpl.java
  29. 7 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderItemServiceImpl.java
  30. 530 385
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  31. 53 0
      fs-service/src/main/java/com/fs/live/vo/FsMyLiveOrderListQueryVO.java
  32. 95 0
      fs-service/src/main/java/com/fs/live/vo/LiveAfterSalesQueryVO.java
  33. 19 0
      fs-service/src/main/java/com/fs/live/vo/LiveOrderErpExportVO.java
  34. 255 0
      fs-service/src/main/java/com/fs/live/vo/LiveOrderExportVO.java
  35. 101 0
      fs-service/src/main/java/com/fs/live/vo/LiveOrderItemExportVO.java
  36. 51 0
      fs-service/src/main/java/com/fs/live/vo/LiveOrderItemVO1.java
  37. 12 0
      fs-service/src/main/java/com/fs/live/vo/LiveOrderListAndStatisticsVo.java
  38. 1 1
      fs-service/src/main/java/com/fs/live/vo/LiveOrderTimeVo.java
  39. 259 0
      fs-service/src/main/java/com/fs/live/vo/LiveOrderVO.java
  40. 117 0
      fs-service/src/main/resources/mapper/live/LiveOrderDfMapper.xml
  41. 479 12
      fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml
  42. 26 28
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveAfterSalesController.java
  43. 735 205
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

+ 326 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveHealthOrderController.java

@@ -0,0 +1,326 @@
+package com.fs.live.controller;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+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.his.domain.FsStoreOrderDf;
+import com.fs.his.vo.FsStoreOrderListAndStatisticsVo;
+import com.fs.hisStore.dto.StoreOrderProductDTO;
+import com.fs.hisStore.param.FsStoreOrderParam;
+import com.fs.hisStore.vo.FsStoreOrderErpExportVO;
+import com.fs.hisStore.vo.FsStoreOrderExportVO;
+import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
+import com.fs.live.domain.LiveOrderDf;
+import com.fs.live.dto.LiveOrderDeliveryNoteDTO;
+import com.fs.live.param.LiveOrderParam;
+import com.fs.live.service.ILiveOrderDfService;
+import com.fs.live.service.ILiveOrderItemService;
+import com.fs.live.service.ILiveOrderService;
+import com.fs.live.vo.LiveOrderErpExportVO;
+import com.fs.live.vo.LiveOrderItemExportVO;
+import com.fs.live.vo.LiveOrderListAndStatisticsVo;
+import com.fs.live.vo.LiveOrderVO;
+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 java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**`
+ * 订单Controller
+ *
+ * @author fs
+ * @date 2025-07-08
+ */
+@RestController
+@RequestMapping("/live/liveOrder")
+public class LiveHealthOrderController extends BaseController {
+
+    @Autowired
+    private ILiveOrderService liveOrderService;
+    @Autowired
+    private ILiveOrderItemService orderItemService;
+
+    @Autowired
+    private ILiveOrderDfService liveOrderDfService;
+
+    @PreAuthorize("@ss.hasPermi('store:healthStoreOrder:exportItems:details')")
+    @Log(title = "商城订单明细导出", businessType = BusinessType.EXPORT)
+    @GetMapping("/healthExportItemsDetails")
+    public AjaxResult healthExportItemsDetails(LiveOrderParam param) {
+        if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
+            param.setBeginTime(null);
+            param.setEndTime(null);
+        }
+        if (liveOrderService.isEntityNull(param)){
+            return AjaxResult.error("请筛选数据导出");
+        }
+        if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+            param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getPayTimeRange())){
+            param.setPayTimeList(param.getPayTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+            param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+            param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+        }
+        param.setIsHealth("1");
+        List<LiveOrderItemExportVO> list = orderItemService.selectLiveOrderItemListExportVO(param);
+        //对手机号脱敏
+        if (list != null) {
+            for (LiveOrderItemExportVO vo : list) {
+                if (!StringUtils.isEmpty(vo.getJsonInfo())) {
+                    try {
+                        StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
+                        BeanUtil.copyProperties(orderProductDTO, vo);
+                    } catch (Exception e) {
+                    }
+                }
+            }
+        }
+        ExcelUtil<LiveOrderItemExportVO> util = new ExcelUtil<LiveOrderItemExportVO>(LiveOrderItemExportVO.class);
+        return util.exportExcel(list, "订单明细数据");
+    }
+
+
+    /**
+     * 导出健康商城列表(明文)
+     */
+    @PreAuthorize("@ss.hasPermi('store:healthStoreOrder:export:details')")
+    @Log(title = "健康商城订单", businessType = BusinessType.EXPORT)
+    @PostMapping("/healthExportDetails")
+    public AjaxResult healthExportDetails(@RequestBody LiveOrderParam param) {
+        if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
+            param.setBeginTime(null);
+            param.setEndTime(null);
+        }
+        if (liveOrderService.isEntityNull(param)){
+            return AjaxResult.error("请筛选数据导出");
+        }
+        if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+            param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getPayTimeRange())){
+            param.setPayTimeList(param.getPayTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+            param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+            param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+        }
+        param.setIsHealth("1");
+        List<LiveOrderErpExportVO> list = liveOrderService.selectLiveOrderListVOByExport(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<LiveOrderErpExportVO> util = new ExcelUtil<LiveOrderErpExportVO>(LiveOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
+    }
+
+    /**
+     * 导出健康商城列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:healthLiveOrder:export')")
+    @Log(title = "健康商城订单", businessType = BusinessType.EXPORT)
+    @PostMapping("/healthExport")
+    public AjaxResult export1(@RequestBody LiveOrderParam param) {
+        if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
+            param.setBeginTime(null);
+            param.setEndTime(null);
+        }
+        if (liveOrderService.isEntityNull(param)){
+            return AjaxResult.error("请筛选数据导出");
+        }
+        if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+            param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getPayTimeRange())){
+            param.setPayTimeList(param.getPayTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+            param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+            param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+        }
+        param.setIsHealth("1");
+        List<LiveOrderErpExportVO> list = liveOrderService.selectLiveOrderListVOByExport(param);
+        //对手机号脱敏
+        if (list != null) {
+            for (LiveOrderErpExportVO vo : list) {
+                if (vo.getPhone() != null) {
+                    vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+                }
+                if (vo.getUserPhone() != null) {
+                    vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+                }
+
+            }
+        }
+        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<LiveOrderErpExportVO> util = new ExcelUtil<LiveOrderErpExportVO>(LiveOrderErpExportVO.class);
+        AjaxResult result;
+        // 如果有选中的字段,只导出这些字段
+        if (filter != null && !filter.isEmpty()) {
+            return util.exportExcelSelectedColumns(list, "订单数据", filterList);
+        } else {
+            // 导出所有字段
+            return util.exportExcel(list, "订单数据");
+        }
+    }
+
+    /**
+     * 查询健康商城订单列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:healthLiveOrder:list')")
+    @PostMapping("/healthList")
+    public TableDataInfo healthStoreList(@RequestBody LiveOrderParam param) {
+        startPage();
+        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.setIsHealth("1");
+        List<LiveOrderVO> list = liveOrderService.selectLiveOrderListVO(param);
+        //金牛需求 区别其他项目 status = 6 (金牛代服管家) ,其他项目请避免使用订单状态status = 6
+        TableDataInfo dataTable = getDataTable(list);
+        if (CloudHostUtils.hasCloudHostName("康年堂")){
+            dataTable.setMsg("knt");
+        }
+        if (list != null) {
+            for (LiveOrderVO 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("康年堂")){
+                    //查询顺丰代服账号
+                    LiveOrderDf df = liveOrderDfService.selectLiveOrderDfByOrderId(vo.getId());
+                    if (df != null){
+                        vo.setErpAccount(df.getLoginAccount());
+                    }
+                }
+
+            }
+        }
+        LiveOrderListAndStatisticsVo vo = new LiveOrderListAndStatisticsVo();
+        BeanUtils.copyProperties(dataTable, vo);
+        if (dataTable.getTotal()>0){
+            Map<String, BigDecimal> statistics= liveOrderService.selectLiveOrderStatistics(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= liveOrderService.selectLiveOrderProductStatistics(param);
+            if (StringUtils.isNotBlank(productStatistics)){
+                vo.setProductInfo(productStatistics);
+            } else {
+                vo.setProductInfo("");
+            }
+
+        }
+        return vo;
+    }
+
+    @PreAuthorize("@ss.hasPermi('live:healthLiveOrder:exportItems')")
+    @Log(title = "直播订单明细导出", businessType = BusinessType.EXPORT)
+    @GetMapping("/healthExportItems")
+    public AjaxResult exportItems1(LiveOrderParam param) {
+        if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
+            param.setBeginTime(null);
+            param.setEndTime(null);
+        }
+        if (liveOrderService.isEntityNull(param)){
+            return AjaxResult.error("请筛选数据导出");
+        }
+        if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+            param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getPayTimeRange())){
+            param.setPayTimeList(param.getPayTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+            param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+            param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+        }
+        param.setIsHealth("1");
+        List<LiveOrderItemExportVO> list = orderItemService.selectLiveOrderItemListExportVO(param);
+        //对手机号脱敏
+        if (list != null) {
+            for (LiveOrderItemExportVO vo : list) {
+                if (vo.getUserPhone() != null) {
+                    String phone = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{1})", "$1****$2");
+                    vo.setUserPhone(phone);
+                }
+                if (!StringUtils.isEmpty(vo.getJsonInfo())) {
+                    try {
+                        StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
+                        BeanUtil.copyProperties(orderProductDTO, vo);
+                    } catch (Exception e) {
+                    }
+                }
+            }
+        }
+        ExcelUtil<LiveOrderItemExportVO> util = new ExcelUtil<LiveOrderItemExportVO>(LiveOrderItemExportVO.class);
+        return util.exportExcel(list, "订单明细数据");
+    }
+
+    @GetMapping("/importDeliveryNoteExpressTemplate")
+    public AjaxResult importTemplate() {
+        ExcelUtil<LiveOrderDeliveryNoteDTO> util = new ExcelUtil<>(LiveOrderDeliveryNoteDTO.class);
+        return util.importTemplateExcel("订单发货导入模板");
+    }
+}

+ 233 - 10
fs-admin/src/main/java/com/fs/live/controller/LiveOrderController.java

@@ -1,6 +1,7 @@
 package com.fs.live.controller;
 
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
@@ -22,23 +23,28 @@ import com.fs.erp.dto.ErpOrderQueryRequert;
 import com.fs.erp.dto.ErpOrderQueryResponse;
 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.service.IFsDfAccountService;
 import com.fs.his.service.IFsExpressService;
 import com.fs.his.service.IFsUserService;
+import com.fs.hisStore.dto.StoreOrderExpressExportDTO;
 import com.fs.hisStore.param.*;
-import com.fs.live.domain.LiveOrder;
-import com.fs.live.domain.LiveOrderItem;
-import com.fs.live.domain.LiveOrderLogs;
-import com.fs.live.domain.LiveOrderPayment;
+import com.fs.hisStore.vo.FsStoreOrderVO;
+import com.fs.live.domain.*;
+import com.fs.live.dto.LiveOrderExpressExportDTO;
 import com.fs.live.enums.LiveOrderCancleReason;
-import com.fs.live.service.ILiveOrderItemService;
-import com.fs.live.service.ILiveOrderLogsService;
-import com.fs.live.service.ILiveOrderPaymentService;
-import com.fs.live.service.ILiveOrderService;
+import com.fs.live.param.LiveOrderScrmSetErpPhoneParam;
+import com.fs.live.service.*;
 import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderPaymentVo;
-import com.fs.live.vo.LiveOrderVo;
+import com.fs.live.vo.LiveOrderTimeVo;
+import com.fs.live.vo.LiveOrderVO;
 import com.fs.store.domain.FsStoreDelivers;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.mapper.SysConfigMapper;
 import com.fs.task.LiveTask;
 import io.swagger.annotations.ApiOperation;
 import org.apache.http.util.Asserts;
@@ -51,9 +57,12 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**`
@@ -89,6 +98,23 @@ public class LiveOrderController extends BaseController
     @Autowired
     private LiveTask liveTask;
 
+
+    @Autowired
+    private IFsDfAccountService fsDfAccountService;
+
+    @Autowired
+    SysConfigMapper sysConfigMapper;
+
+    @Autowired
+    private ILiveOrderDfService liveOrderDfService;
+
+
+    @GetMapping("/importTemplate")
+    public AjaxResult importTemplate() {
+        ExcelUtil<LiveOrderExpressExportDTO> util = new ExcelUtil<LiveOrderExpressExportDTO>(LiveOrderExpressExportDTO.class);
+        return util.importTemplateExcel("物流回单数据");
+    }
+
     /**
      * 查询订单列表
      */
@@ -177,7 +203,7 @@ public class LiveOrderController extends BaseController
      * 按照时间粒度返回订单
      * */
     @GetMapping(value = "/getLiveOrderTimeGranularity")
-    public R getLiveOrderTimeGranularity(LiveOrderVo liveOrder){
+    public R getLiveOrderTimeGranularity(LiveOrderTimeVo liveOrder){
         return liveOrderService.getLiveOrderTimeGranularity(liveOrder);
     }
 
@@ -429,6 +455,203 @@ public class LiveOrderController extends BaseController
         return R.error("未查询到快递信息");
     }
 
+    /**
+     * 删除订单
+     */
+    @PreAuthorize("@ss.hasPermi('live:liveOrder:remove')")
+    @Log(title = "订单", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(liveOrderService.deleteLiveOrderByIds(ids));
+    }
+
+    /**
+     * 获取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);
+    }
+
+    /**
+     * 查询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('live:liveOrder:createErpOrder')")
+    @Log(title = "订单", businessType = BusinessType.UPDATE)
+    @PostMapping("/editErpPhone")
+    public AjaxResult editErpPhone(@RequestBody LiveOrderScrmSetErpPhoneParam param)
+    {
+        param.setOpeName(getLoginUser().getUser().getNickName());
+        List<String> erpPhone = param.getErpPhone();
+        if (erpPhone == null || erpPhone.isEmpty()) {
+            return AjaxResult.error("请选择手机号");
+        }
+        return toAjax(liveOrderService.batchUpdateErpByOrderIds(param));
+    }
+
+    @Log(title = "手动推管易", businessType = BusinessType.INSERT)
+    @ApiOperation("批量创建ERP订单")
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
+    @PostMapping(value = "/batchCreateErpOrder")
+    public R batchCreateErpOrder(@RequestBody LiveOrderScrmSetErpPhoneParam param)
+    {
+        String nickName = getLoginUser().getUser().getNickName();
+        String loginAccount = param.getLoginAccount();
+        if (StringUtils.isBlank(loginAccount)){
+            return R.error("未选择推送erp账户");
+        }
+        LiveOrderDf 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<LiveOrderVO> list = liveOrderService.selectLiveOrderListVO(param);
+            orderIds = list.stream().map(LiveOrderVO::getId).collect(Collectors.toList());
+        }
+        if (orderIds.isEmpty()){
+            return R.ok();
+        }
+        orderIds.forEach(orderId->{
+            try {
+                df.setOrderId(orderId);
+                LiveOrderDf temp = liveOrderDfService.selectLiveOrderDfByOrderId(df.getOrderId());
+                if (temp == null){
+                    df.setParcelQuantity(param.getParcelQuantity()); //设置包裹数量
+                    liveOrderDfService.insertLiveOrderDf(df);
+                    orderLogsService.create(orderId, FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getValue(),
+                            nickName + " " +FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getDesc() + ":" + df.getLoginAccount());
+                }
+                liveOrderService.createOmsOrder(orderId);
+                orderLogsService.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 LiveOrderScrmSetErpPhoneParam param)
+    {
+        String nickName = getLoginUser().getUser().getNickName();
+        String loginAccount = param.getLoginAccount();
+        if (StringUtils.isBlank(loginAccount)){
+            return R.error("未选择erp账户");
+        }
+        LiveOrderDf 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<LiveOrderVO> list = liveOrderService.selectLiveOrderListVO(param);
+            orderIds = list.stream().map(LiveOrderVO::getId).collect(Collectors.toList());
+        }
+        if (orderIds.isEmpty()){
+            return R.ok();
+        }
+        orderIds.forEach(orderId->{
+            df.setOrderId(orderId);
+            LiveOrderDf temp = liveOrderDfService.selectLiveOrderDfByOrderId(df.getOrderId());
+            df.setParcelQuantity(param.getParcelQuantity());
+            if (temp != null){
+                df.setUpdateTime(new Date());
+                liveOrderDfService.updateLiveOrderDf(df);
+            } else {
+                liveOrderDfService.insertLiveOrderDf(df);
+            }
+            orderLogsService.create(orderId, FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getValue(),
+                    nickName + " " +FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getDesc() + ":" + df.getLoginAccount());
+        });
+        return R.ok();
+    }
+
+    private LiveOrderDf getDFInfo(String loginAccount) {
+        //查询订单账户 判断是否存在该订单账户
+        List<FsDfAccount> erpAccounts = fsDfAccountService.selectFsDfAccountList(null);
+        LiveOrderDf df = new LiveOrderDf();
+        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;
+    }
+
 
 
 }

+ 4 - 3
fs-company/src/main/java/com/fs/company/controller/live/LiveOrderController.java

@@ -21,12 +21,13 @@ import com.fs.his.service.IFsUserService;
 import com.fs.hisStore.param.FsStoreOrderExpressParam;
 import com.fs.live.domain.*;
 import com.fs.live.enums.LiveOrderCancleReason;
+import com.fs.live.param.LiveOrderExpressParam;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderLogsService;
 import com.fs.live.service.ILiveOrderPaymentService;
 import com.fs.live.service.ILiveOrderService;
 import com.fs.live.vo.LiveGoodsVo;
-import com.fs.live.vo.LiveOrderVo;
+import com.fs.live.vo.LiveOrderTimeVo;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -157,7 +158,7 @@ public class LiveOrderController extends BaseController
     @ApiOperation("物流查询")
     @PostMapping("/getExpressByDeliverId")
     public R getExpressByDeliverId(@Validated @RequestBody FsStoreOrderExpressParam param, HttpServletRequest request){
-        // todo yhq
+
 //        return expressService.getLiveExpressByDeliverId(param);
         return R.ok();
     }
@@ -302,7 +303,7 @@ public class LiveOrderController extends BaseController
      * 按照时间粒度返回订单
      * */
     @GetMapping(value = "/getLiveOrderTimeGranularity")
-    public R getLiveOrderTimeGranularity(LiveOrderVo liveOrder){
+    public R getLiveOrderTimeGranularity(LiveOrderTimeVo liveOrder){
         return liveOrderService.getLiveOrderTimeGranularity(liveOrder);
     }
 

+ 4 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyService.java

@@ -18,6 +18,7 @@ import com.fs.his.domain.FsStorePayment;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
+import com.fs.live.domain.LiveOrder;
 import org.springframework.transaction.annotation.Transactional;
 
 
@@ -97,6 +98,9 @@ public interface ICompanyService
     @Transactional
     void addCompanyMoney(FsStoreOrderScrm order);
 
+    @Transactional
+    void addCompanyMoney(LiveOrder order);
+
     void subCompanyMoney(FsStoreOrder order);
 
     @Transactional

+ 24 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -32,6 +32,7 @@ import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
+import com.fs.live.domain.LiveOrder;
 import com.fs.store.config.CompanyMenuConfig;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
@@ -445,6 +446,29 @@ public class CompanyServiceImpl implements ICompanyService
         }
     }
 
+    @Override
+    public void addCompanyMoney(LiveOrder order) {
+        if(order.getCompanyId()>0){
+            Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
+            if(company!=null){
+                company.setMoney(company.getMoney().subtract(order.getTuiMoney()));
+                company.setTuiMoney(company.getTuiMoney().subtract(order.getTuiMoney()));
+                companyMapper.updateCompany(company);
+                //写入日志
+                CompanyMoneyLogs log=new CompanyMoneyLogs();
+                log.setCompanyId(order.getCompanyId());
+                log.setRemark("订单佣金退款");
+                log.setMoney(order.getTuiMoney().multiply(new BigDecimal(-1)));
+                log.setLogsType(4);
+                log.setBalance(company.getMoney());
+                log.setCreateTime(new Date());
+                log.setBusinessId(order.getOrderId().toString());
+                moneyLogsMapper.insertCompanyMoneyLogs(log);
+
+            }
+        }
+    }
+
     @Override
     @Transactional
     public void subCompanyMoney(FsStoreOrder order) {

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

@@ -101,6 +101,10 @@ public class LiveOrder extends BaseEntity {
     /** 0 未退款 1 申请中 2 已退款 */
     @Excel(name = "0 未退款 1 申请中 2 已退款")
     private String refundStatus;
+    /** 收货人 */
+    @Excel(name = "收货人")
+    private String realName;
+
 
     /** 退款图片 */
     @Excel(name = "退款图片")
@@ -328,5 +332,8 @@ public class LiveOrder extends BaseEntity {
     private Long customerId;
     private Long couponUserId;
 
+    /** 优惠券金额 */
+    private BigDecimal couponPrice;
+
 
 }

+ 66 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrderDf.java

@@ -0,0 +1,66 @@
+package com.fs.live.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+/**
+ * 订单代服管家对象 fs_store_order_df
+ *
+ * @author fs
+ * @date 2025-07-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class LiveOrderDf extends BaseEntity{
+
+    /** 订单id */
+    @TableId
+    private Long orderId;
+
+    /** 订单编号 */
+    @Excel(name = "订单编号")
+    private String orderCode;
+
+    @Excel(name = "key")
+    private String appKey;
+
+    @Excel(name = "secret")
+    private String appSecret;
+
+    @Excel(name = "登录账户")
+    private String loginAccount;
+
+    /** 顺丰月结账户 */
+    @Excel(name = "顺丰月结账户")
+    private String monthlyCard;
+
+    /** 顺丰月结账户 */
+    @Excel(name = "顺丰月结账户")
+    private String expressProductCode;
+
+    /** 订单总价 */
+    @Excel(name = "订单总价")
+    private BigDecimal totalPrice;
+
+    /** 平台收款 */
+    @Excel(name = "平台收款")
+    private BigDecimal platformPrice;
+
+    /** 平台收款 */
+    @Excel(name = "0:默认 1下单 2取消订单")
+    private Integer status;
+
+    /** 失败原因 */
+    private String failMsg;
+
+    /** 包裹数量 */
+    @Excel(name = "包裹数量 默认1")
+    private Integer parcelQuantity;
+
+
+}

+ 52 - 0
fs-service/src/main/java/com/fs/live/dto/LiveOrderDeliveryNoteDTO.java

@@ -0,0 +1,52 @@
+package com.fs.live.dto;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 订单发货下载模板
+ * **/
+@Data
+public class LiveOrderDeliveryNoteDTO {
+    /**
+     * 系统订单号
+     * **/
+    @Excel(name = "系统订单号(必填)",width = 20,sort = 1)
+    private String orderNumber;
+
+    @Excel(name = "物流公司编号(必填)(SF:顺丰、EMS:邮政、ZTO:中通、JD:京东、DBL:德邦)",width = 30,sort = 2)
+    private String deliverySn;
+
+    private String deliveryName;
+
+    @Excel(name = "快递单号(必填)",width = 20,sort = 3)
+    private String deliveryId;
+
+    @Excel(name = "物流状态(0:暂无信息、1:已揽收、2:在途中、3:签收、4:问题件)",width = 40,sort = 4)
+    private Integer deliveryStatus;
+
+    @Excel(name = "物流结算费用",width = 20,sort = 5)
+    private BigDecimal deliveryPayMoney;
+
+    @Excel(name = "物流跟踪状态(311:快递柜或驿站签收、304:派件异常后最终签收、301:正常签收、211:已放入快递柜或驿站、202:派件中、201:到达派件城市、401:发货无信息、412:快递柜或驿站超时未取、407:退货未签收)",width = 40,sort = 6)
+    private Integer deliveryType;
+
+    @Excel(name = "物流结算状态(1:已结算、2:冻结、3:解冻、4:退回运费、5.调账)",width = 20,sort = 7)
+    private Integer deliveryPayStatus;
+
+    @Excel(name = "快递账单日期",width = 20,sort = 8)
+    private String deliveryTime;
+
+    @Excel(name = "快递结算日期",width = 20,sort = 9)
+    private String deliveryPayTime;
+
+//    /**
+//     * 发货状态
+//     * **/
+//    @Excel(name = "系统订单号(1:待发货、2:待收货、3:交易完成,-3:已取消)填写对应数字",width = 40,sort = 7)
+//    private Integer deliveryNoteStatus;
+
+    private Integer deliveryNoteStatus;
+}

+ 31 - 0
fs-service/src/main/java/com/fs/live/dto/LiveOrderExpressExportDTO.java

@@ -0,0 +1,31 @@
+package com.fs.live.dto;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class LiveOrderExpressExportDTO {
+
+
+    @Excel(name = "快递单号")
+    private String deliveryId;
+
+    @Excel(name = "快递名称")
+    private String deliveryName;
+
+    @Excel(name = "代收金额")
+    private BigDecimal deliveryPayMoney;
+
+
+    @Excel(name = "结算状态",dictType="store_delivery_pay_status")
+    private String deliveryPayStatus;
+
+
+    @Excel(name = "快递帐单日期")
+    private String deliveryTime;
+
+    @Excel(name = "快递结算日期")
+    private String deliveryPayTime;
+}

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

@@ -3,7 +3,9 @@ package com.fs.live.mapper;
 
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.param.LiveAfterSalesListUParam;
+import com.fs.live.param.LiveAfterSalesQueryParam;
 import com.fs.live.vo.LiveAfterSalesListUVO;
+import com.fs.live.vo.LiveAfterSalesQueryVO;
 import com.fs.live.vo.LiveAfterSalesVo;
 import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
@@ -106,4 +108,26 @@ public interface LiveAfterSalesMapper {
     })
     @MapKey("orderId")
     Map<Long, LiveAfterSales> findByOrderIds(@Param("orderIdList") List<Long> orderIdList);
+
+    @Select({"<script> " +
+            "select *  from live_after_sales  " +
+            "where 1=1 " +
+            "<if test = 'maps.status != null and maps.status ==1   '> " +
+            "and sales_status = 0 " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status ==2   '> " +
+            "and sales_status = 3 " +
+            "</if>" +
+            "<if test = 'maps.userId != null    '> " +
+            "and user_id = #{maps.userId} " +
+            "</if>" +
+            "order by create_time desc "+
+            "</script>"})
+    List<LiveAfterSalesQueryVO> selectLiveAfterSalesListQuery(LiveAfterSalesQueryParam param);
+
+    @Select({"<script> " +
+            "select ifnull(count(1),0) from live_after_sales   " +
+            "where user_id=#{userId}  and sales_status =#{salesStatus} " +
+            "</script>"})
+    Integer selectLiveAfterSalesCount(@Param("userId")long userId,@Param("salesStatus") int salesStatus);
 }

+ 62 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderDfMapper.java

@@ -0,0 +1,62 @@
+package com.fs.live.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.live.domain.LiveOrderDf;
+
+import java.util.List;
+
+/**
+ * 订单代服管家Mapper接口
+ *
+ * @author fs
+ * @date 2025-07-08
+ */
+public interface LiveOrderDfMapper extends BaseMapper<LiveOrderDf>{
+    /**
+     * 查询订单代服管家
+     *
+     * @param orderId 订单代服管家主键
+     * @return 订单代服管家
+     */
+    LiveOrderDf selectLiveOrderDfByOrderId(Long orderId);
+
+    /**
+     * 查询订单代服管家列表
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 订单代服管家集合
+     */
+    List<LiveOrderDf> selectLiveOrderDfList(LiveOrderDf fsStoreOrderDf);
+
+    /**
+     * 新增订单代服管家
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 结果
+     */
+    int insertLiveOrderDf(LiveOrderDf fsStoreOrderDf);
+
+    /**
+     * 修改订单代服管家
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 结果
+     */
+    int updateLiveOrderDf(LiveOrderDf fsStoreOrderDf);
+
+    /**
+     * 删除订单代服管家
+     *
+     * @param orderId 订单代服管家主键
+     * @return 结果
+     */
+    int deleteLiveOrderDfByOrderId(Long orderId);
+
+    /**
+     * 批量删除订单代服管家
+     *
+     * @param orderIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteLiveOrderDfByOrderIds(Long[] orderIds);
+}

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

@@ -3,7 +3,10 @@ package com.fs.live.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.fs.hisStore.param.FsStoreOrderParam;
 import com.fs.live.domain.LiveOrderItem;
+import com.fs.live.param.LiveOrderParam;
+import com.fs.live.vo.LiveOrderItemExportVO;
 import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.live.vo.LiveOrderItemVo;
 import org.apache.ibatis.annotations.*;
@@ -93,4 +96,74 @@ public interface LiveOrderItemMapper {
 
     @Select("select * from live_order_item where order_id= #{orderId}")
     List<LiveOrderItem> selectCheckedByOrderId(@Param("orderId") Long orderId);
+
+    @Select({"<script> " +
+            "select i.*,o.user_id,o.status, o.real_name,o.user_phone,o.user_address,o.create_time,o.pay_time,o.delivery_sn,o.delivery_name,o.delivery_id, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,o.upload_time ,CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload   " +
+            " ,p.title as package_name,cts.name as scheduleName from live_order_item i left join live_order 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 " +
+            "where 1=1 " +
+            "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
+            "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.deliveryId != null    '> " +
+            "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.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.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.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.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.scheduleId != null    '> " +
+            "and o.schedule_id =#{maps.scheduleId} " +
+            "</if>" +
+            " order by o.id desc limit 50000"+
+            "</script>"})
+    List<LiveOrderItemExportVO> selectFsStoreOrderItemListExportVO(@Param("maps") LiveOrderParam fsStoreOrder);
 }

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

@@ -2,13 +2,17 @@ package com.fs.live.mapper;
 
 
 import com.fs.live.domain.LiveOrder;
-import com.fs.live.vo.LiveOrderListVo;
-import com.fs.live.vo.LiveOrderVo;
+import com.fs.live.param.FsMyLiveOrderQueryParam;
+import com.fs.live.param.LiveOrderParam;
+import com.fs.live.vo.*;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 订单Mapper接口
@@ -25,6 +29,15 @@ public interface LiveOrderMapper {
      */
     LiveOrder selectLiveOrderByOrderId(String orderId);
 
+    /**
+     * 查询订单
+     *
+     * @param orderId 订单主键
+     * @return 订单
+     */
+    @Select("select * from live_order where order_id=#{orderId}")
+    LiveOrder selectLiveOrderByOrderId(Long orderId);
+
     @Select("select order_code from live_order where order_id=#{orderId}")
     String selectLiveOrderCodeByOrderId(@Param("orderId") String orderId);
 
@@ -74,7 +87,7 @@ public interface LiveOrderMapper {
      * @param liveOrder 订单
      * @return 订单集合
      */
-    List<LiveOrder> getLiveOrderTimeGranularity(LiveOrderVo liveOrder);
+    List<LiveOrder> getLiveOrderTimeGranularity(LiveOrderTimeVo liveOrder);
 
     @Select("select * from live_order where extend_order_id is null or extend_order_id = '' and status = 2")
     List<LiveOrder> selectNotPushedLiveOrder();
@@ -117,4 +130,295 @@ public interface LiveOrderMapper {
     LiveOrder selectLiveOrderByOrderCode(@Param("orderCode") String orderCode);
 
     List<LiveOrder> selectFsOutDateOrder();
+
+
+    List<LiveOrderVO> selectLiveOrderListVO(@Param("maps") LiveOrderParam param);
+
+
+    Map<String, BigDecimal> selectLiveOrderStatistics(@Param("maps")LiveOrderParam param);
+
+
+    String selectLiveOrderProductStatistics(@Param("maps")LiveOrderParam param);
+
+    List<LiveOrder> selectLiveOrderInId(@Param("ids") Long[] ids);
+    @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 ," +
+            "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 live_order 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 crm_customer cc on cc.customer_id=o.customer_id left join company_tcm_schedule cts on cts.id = o.schedule_id " +
+            " LEFT JOIN live_order_df df on df.order_id=o.order_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.order_id desc " +
+            "</if> " +
+            " limit 50000 "+
+            "</script>"})
+    List<LiveOrderErpExportVO> selectLiveOrderErpListVOByExport(@Param("maps")LiveOrderParam 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 ,CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload  " +
+            " from live_order 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 crm_customer cc on cc.customer_id=o.customer_id left join company_tcm_schedule cts on cts.id = o.schedule_id " +
+            "where 1=1 " +
+            "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
+            "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
+            "</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.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>" +
+            " ${maps.params.dataScope} "+
+            " order by o.order_id desc limit 50000"+
+            "</script>"})
+    List<LiveOrderErpExportVO> selectLiveOrderListVOByExport(@Param("maps")LiveOrderParam param);
+
+    int batchUpdateErpByOrderIds(@Param("maps")ArrayList<Map<String, String>> maps);
+
+    @Select({"<script> " +
+            "select o.order_id,o.order_code,o.item_json,o.pay_price,o.status,o.delivery_id,o.finish_time  from live_order o  " +
+            "where o.is_del=0 and o.is_sys_del=0 " +
+            "<if test = 'maps.status != null and maps.status != \"\"     '> " +
+            "and o.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.keyword != null and  maps.keyword !=\"\"    '> " +
+            "and o.order_code like CONCAT('%',#{maps.keyword},'%') " +
+            "</if>" +
+            "<if test = 'maps.deliveryStatus != null     '> " +
+            "and o.delivery_status =#{maps.deliveryStatus} " +
+            "</if>" +
+            "<if test = 'maps.userId != null     '> " +
+            "and o.user_id=#{maps.userId} " +
+            "</if>" +
+            " order by o.order_id desc "+
+            "</script>"})
+    List<FsMyLiveOrderListQueryVO> selectFsMyLiveOrderListVO(@Param("maps")FsMyLiveOrderQueryParam param);
+
+    @Select({"<script> " +
+            "select o.*  from live_order o  " +
+            "where o.is_del=0 and o.is_sys_del=0 " +
+            "<if test = 'maps.status != null and maps.status != \"\"     '> " +
+            "and o.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.keyword != null and  maps.keyword !=\"\"    '> " +
+            "and o.order_code like CONCAT('%',#{maps.keyword},'%') " +
+            "</if>" +
+            "<if test = 'maps.userId != null     '> " +
+            "and o.user_id=#{maps.userId} " +
+            "</if>" +
+            "<if test = 'maps.companyUserId != null     '> " +
+            "and o.company_user_id=#{maps.companyUserId} " +
+            "</if>" +
+            "<if test = 'maps.companyId != null     '> " +
+            "and o.company_id=#{maps.companyId} " +
+            "</if>" +
+            " order by o.order_id desc "+
+            "</script>"})
+    List<FsMyLiveOrderListQueryVO> selectFsCompanyLiveOrderListVO(@Param("maps") FsMyLiveOrderQueryParam param);
+
+    @Select({"<script> " +
+            "select ifnull(count(1),0) from live_order o  " +
+            "where o.user_id=#{userId}  and o.status =#{status} " +
+            "</script>"})
+    Integer selectLiveOrderCount(long userId, int status);
 }

+ 16 - 0
fs-service/src/main/java/com/fs/live/param/FsMyLiveOrderQueryParam.java

@@ -0,0 +1,16 @@
+package com.fs.live.param;
+
+import com.fs.common.param.BaseQueryParam;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class FsMyLiveOrderQueryParam extends BaseQueryParam implements Serializable
+{
+    private String status;
+    private Long userId;
+    private Long companyId;
+    private Long companyUserId;
+    private Integer deliveryStatus;
+}

+ 50 - 0
fs-service/src/main/java/com/fs/live/param/LiveAfterSalesParam.java

@@ -0,0 +1,50 @@
+package com.fs.live.param;
+
+import com.fs.hisStore.param.FsStoreAfterSalesProductParam;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class LiveAfterSalesParam implements Serializable
+{
+
+    /**
+     * 订单号
+     */
+    @NotBlank
+    private String orderCode;
+
+    /**
+     * 服务类型 0仅退款1退货退款
+     */
+    @NotBlank
+    private Integer serviceType;
+
+    /**
+     * 申请原因
+     */
+    @NotBlank
+    private String reasons;
+
+    /**
+     * 申请说明
+     */
+    private String explains;
+
+    /**
+     * 申请说明图片
+     */
+    private String explainImg;
+
+    private BigDecimal refundAmount;
+
+    /**
+     * 商品数据
+     */
+    @NotBlank
+    private List<LiveAfterSalesProductParam> productList;
+}

+ 17 - 0
fs-service/src/main/java/com/fs/live/param/LiveAfterSalesProductParam.java

@@ -0,0 +1,17 @@
+package com.fs.live.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class LiveAfterSalesProductParam implements Serializable
+{
+
+
+    private Long productId;
+
+    private Integer num;
+
+
+}

+ 15 - 0
fs-service/src/main/java/com/fs/live/param/LiveAfterSalesQueryParam.java

@@ -0,0 +1,15 @@
+package com.fs.live.param;
+
+import com.fs.common.param.BaseQueryParam;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class LiveAfterSalesQueryParam extends BaseQueryParam implements Serializable
+{
+
+    private Integer status;
+    private Long userId;
+
+}

+ 59 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderCreateParam.java

@@ -0,0 +1,59 @@
+package com.fs.live.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class LiveOrderCreateParam implements Serializable
+{
+    private Long companyId;
+    private Long companyUserId;
+    private Long userId;
+    @ApiModelProperty(value = "orderKey")
+    @NotNull(message = "orderKey不能为空")
+    private String orderKey;
+    @ApiModelProperty(value = "地址ID")
+    @NotNull(message = "地址不能为空")
+    private Long addressId;
+
+    @ApiModelProperty(value = "来源")
+    private String from;
+
+    @Size(max = 200,message = "长度超过了限制")
+    @ApiModelProperty(value = "备注")
+    private String mark;
+
+    @NotBlank(message="请选择支付方式")
+    @ApiModelProperty(value = "支付方式")
+    private String payType;
+
+    @ApiModelProperty(value = "使用积分 1使用")
+    private Integer useIntegral;
+    private BigDecimal payPrice; //制单 改价 订单总价
+    private Long paymentId;
+
+    @ApiModelProperty(value = "优惠券")
+    private Long couponUserId;
+
+    private Long tuiUserId;
+
+    private String createOrderKey;
+
+    //订单创建类型 1普通订单 2套餐订单 3制单
+    private Integer orderCreateType;
+
+    private Long customerId;
+
+    private BigDecimal amount; //货到付款代收金额
+
+    private Integer orderType; //订单类型
+    private Integer orderMedium; //媒体来源
+
+    private Boolean isUserApp = true;
+}

+ 15 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderExpressParam.java

@@ -0,0 +1,15 @@
+package com.fs.live.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class LiveOrderExpressParam implements Serializable
+{
+    @ApiModelProperty(value = "orderId")
+    private Long orderId;
+
+
+}

+ 114 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderParam.java

@@ -0,0 +1,114 @@
+package com.fs.live.param;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class LiveOrderParam 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;
+
+    private String isHealth;
+
+    private Integer notHealth;
+
+    private Long companyUserId;
+
+    private String createTimeRange;
+
+    private String[] createTimeList;
+
+    private String payTimeRange;
+
+    private String[] payTimeList;
+
+    private String deliverySendTimeRange;
+
+    private String[] deliverySendTimeList;
+
+    private String deliveryImportTimeRange;
+
+    private String[] deliveryImportTimeList;
+
+    private Integer orderType;
+
+
+    private String companyUserNickName;
+
+    private String deliveryId;
+
+    private Integer deliveryStatus;
+
+    private Integer deliveryPayStatus;
+
+    private Long deptId;
+
+    private Long userId;
+
+    private Long customerId;
+
+    private String realName;
+
+    private Integer isPayRemain;
+
+    private Integer payType;
+
+    private String productName;
+
+    private Integer isUpload;
+
+    /** 开始时间 */
+    @JsonIgnore
+    private String beginTime;
+
+    /** 结束时间 */
+    @JsonIgnore
+    private String endTime;
+
+    private Long scheduleId;
+
+    private String orderVisit;
+
+    /**
+     * 支付状态 待支付 1已支付
+     */
+    private Integer paidStatus;
+
+    private Long storeId;
+
+    //排序字段
+    private String sortField;
+    //排序规则
+    private String sortOrder;
+
+    //erp电话
+    private String erpPhoneNumber;
+
+    //小程序id
+    private Long coursePlaySourceConfigId;
+    //erp账户
+    private String erpAccount;
+
+    //导出字段
+    private String filter;
+
+}

+ 24 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderPayParam.java

@@ -0,0 +1,24 @@
+package com.fs.live.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+public class LiveOrderPayParam implements Serializable
+{
+    @ApiModelProperty(value = "orderId")
+    @NotNull(message = "订单号不能为空")
+    private Long orderId;
+
+    @ApiModelProperty(value = "payType")
+    @NotNull(message = "支付类型不能为空")
+    private Integer payType;
+
+    /**
+     * 小程序多商城
+     * **/
+    private String appId;
+}

+ 15 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderScrmSetErpPhoneParam.java

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

+ 8 - 8
fs-service/src/main/java/com/fs/live/service/ILiveAfterSalesService.java

@@ -3,16 +3,10 @@ package com.fs.live.service;
 
 import com.fs.common.core.domain.R;
 import com.fs.live.domain.LiveAfterSales;
-import com.fs.live.param.LiveAfterSalesApplyParam;
-import com.fs.live.param.LiveAfterSalesDeliveryParam;
-import com.fs.live.param.LiveAfterSalesListUParam;
-import com.fs.live.param.LiveAfterSalesRevokeParam;
+import com.fs.live.param.*;
 import com.fs.live.vo.LiveAfterSalesListUVO;
+import com.fs.live.vo.LiveAfterSalesQueryVO;
 import com.fs.live.vo.LiveAfterSalesVo;
-import com.fs.live.param.LiveAfterSalesAudit1Param;
-import com.fs.live.param.LiveAfterSalesAudit2Param;
-import com.fs.live.param.LiveAfterSalesCancelParam;
-import com.fs.live.param.LiveAfterSalesRefundParam;
 
 import java.util.List;
 
@@ -90,4 +84,10 @@ public interface ILiveAfterSalesService {
     R refundMoney(LiveAfterSalesRefundParam param);
 
     R cancel(LiveAfterSalesCancelParam param);
+
+    R applyForAfterSales(String userId, LiveAfterSalesParam param);
+
+    List<LiveAfterSalesQueryVO> selectLiveAfterSalesListQuery(LiveAfterSalesQueryParam param);
+
+    Integer selectLiveAfterSalesCount(long l, int i);
 }

+ 62 - 0
fs-service/src/main/java/com/fs/live/service/ILiveOrderDfService.java

@@ -0,0 +1,62 @@
+package com.fs.live.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.live.domain.LiveOrderDf;
+
+import java.util.List;
+
+/**
+ * 订单代服管家Service接口
+ *
+ * @author fs
+ * @date 2025-07-08
+ */
+public interface ILiveOrderDfService extends IService<LiveOrderDf>{
+    /**
+     * 查询订单代服管家
+     *
+     * @param orderId 订单代服管家主键
+     * @return 订单代服管家
+     */
+    LiveOrderDf selectLiveOrderDfByOrderId(Long orderId);
+
+    /**
+     * 查询订单代服管家列表
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 订单代服管家集合
+     */
+    List<LiveOrderDf> selectLiveOrderDfList(LiveOrderDf fsStoreOrderDf);
+
+    /**
+     * 新增订单代服管家
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 结果
+     */
+    int insertLiveOrderDf(LiveOrderDf fsStoreOrderDf);
+
+    /**
+     * 修改订单代服管家
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 结果
+     */
+    int updateLiveOrderDf(LiveOrderDf fsStoreOrderDf);
+
+    /**
+     * 批量删除订单代服管家
+     *
+     * @param orderIds 需要删除的订单代服管家主键集合
+     * @return 结果
+     */
+    int deleteLiveOrderDfByOrderIds(Long[] orderIds);
+
+    /**
+     * 删除订单代服管家信息
+     *
+     * @param orderId 订单代服管家主键
+     * @return 结果
+     */
+    int deleteLiveOrderDfByOrderId(Long orderId);
+}

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

@@ -4,6 +4,8 @@ import java.util.List;
 
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrderItem;
+import com.fs.live.param.LiveOrderParam;
+import com.fs.live.vo.LiveOrderItemExportVO;
 import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.live.vo.LiveOrderItemVo;
 
@@ -69,4 +71,6 @@ public interface ILiveOrderItemService {
     int updateFsStoreOrderCode(Long orderId, String orderSn);
 
     List<LiveOrderItem> selectCheckedByOrderId(Long id);
+
+    List<LiveOrderItemExportVO> selectLiveOrderItemListExportVO(LiveOrderParam param);
 }

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

@@ -1,22 +1,23 @@
 package com.fs.live.service;
 
 import com.fs.common.core.domain.R;
+import com.fs.erp.domain.ErpOrder;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
+import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
+import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.dto.LiveOrderComputeDTO;
-import com.fs.live.param.FsUserLiveOrderPayUParam;
-import com.fs.live.param.LiveOrderComputedParam;
-import com.fs.live.param.LiveOrderConfirmParam;
-import com.fs.live.param.LiveOrderFinishParam;
-import com.fs.live.vo.LiveGoodsVo;
-import com.fs.live.vo.LiveOrderListVo;
-import com.fs.live.vo.LiveOrderVo;
+import com.fs.live.param.*;
+import com.fs.live.vo.*;
 import com.fs.store.domain.FsStoreDelivers;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 订单Service接口
@@ -83,7 +84,7 @@ public interface ILiveOrderService {
      * 获取订单时间粒度
      * @param liveOrder
      */
-    R getLiveOrderTimeGranularity(LiveOrderVo liveOrder);
+    R getLiveOrderTimeGranularity(LiveOrderTimeVo liveOrder);
 
     /**
      * 同步物流信息
@@ -175,7 +176,9 @@ public interface ILiveOrderService {
 
     List<Long> selectOrderIdByNoErp();
 
-    void createOmsOrder(Long id)  throws ParseException;
+    R createOmsOrder(Long id)  throws ParseException;
+    ErpOrder getErpOrder(LiveOrder order) throws ParseException;
+
 
     List<LiveOrder> selectDeliverPenddingData();
 
@@ -203,4 +206,23 @@ public interface ILiveOrderService {
 
     void orderCancel();
 
+    boolean isEntityNull(LiveOrderParam param);
+
+    List<LiveOrderVO> selectLiveOrderListVO(LiveOrderParam param);
+
+    Map<String, BigDecimal> selectLiveOrderStatistics(LiveOrderParam param);
+
+    String selectLiveOrderProductStatistics(LiveOrderParam param);
+
+    int deleteLiveOrderByIds(Long[] ids);
+
+    List<LiveOrderErpExportVO> selectLiveOrderListVOByExport(LiveOrderParam param);
+
+    int batchUpdateErpByOrderIds(LiveOrderScrmSetErpPhoneParam param);
+
+    List<FsMyLiveOrderListQueryVO> selectFsMyLiveOrderListVO(FsMyLiveOrderQueryParam param);
+
+    List<FsMyLiveOrderListQueryVO> selectFsCompanyLiveOrderListVO(FsMyLiveOrderQueryParam param);
+
+    Integer selectFsStoreOrderCount(long l, int i);
 }

+ 231 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java

@@ -1,15 +1,19 @@
 package com.fs.live.service.impl;
 
+import java.lang.reflect.InvocationTargetException;
 import java.sql.Timestamp;
 import java.time.LocalDateTime;
 import java.util.*;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
+import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
 
 import com.fs.common.utils.StringUtils;
@@ -19,11 +23,20 @@ import com.fs.erp.dto.BaseResponse;
 import com.fs.erp.dto.ErpRefundUpdateRequest;
 import com.fs.erp.mapper.FsJstAftersalePushMapper;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.FsUser;
 import com.fs.his.service.IFsUserService;
+import com.fs.his.utils.ConfigUtil;
+import com.fs.hisStore.domain.*;
+import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.enums.AfterSalesStatusEnum;
 import com.fs.hisStore.enums.AfterStatusEnum;
 import com.fs.hisStore.enums.OrderInfoEnum;
+import com.fs.hisStore.enums.SysConfigEnum;
+import com.fs.hisStore.param.FsStoreAfterSalesProductParam;
+import com.fs.hisStore.service.IFsUserScrmService;
+import com.fs.hisStore.vo.FsStoreAfterSalesQueryVO;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.live.domain.*;
 import com.fs.live.dto.LiveAfterSalesProductDTO;
 import com.fs.live.enums.LiveAfterSalesStatusEnum;
@@ -32,12 +45,15 @@ import com.fs.live.param.*;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderService;
 import com.fs.live.vo.LiveAfterSalesListUVO;
+import com.fs.live.vo.LiveAfterSalesQueryVO;
 import com.fs.live.vo.LiveAfterSalesVo;
+import com.fs.live.vo.LiveOrderItemVO1;
 import com.fs.store.config.StoreConfig;
 import com.fs.store.domain.*;
 import com.fs.store.service.cache.IFsUserCacheService;
 import com.fs.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.http.util.Asserts;
 import org.springframework.aop.framework.AopContext;
@@ -77,17 +93,39 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
 //    @Autowired
 //    private FsWarehousesMapper fsWarehousesMapper;
 
-
+    @Autowired
+    private ConfigUtil configUtil;
 
 
     @Autowired
     private ISysConfigService configService;
 
     @Autowired
-    private IFsUserService userService;
+    private IFsUserScrmService userService;
 
     @Autowired
     private IErpOrderService erpOrderService;
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+    @Autowired
+    @Qualifier("hzOMSErpOrderServiceImpl")
+    private IErpOrderService hzOMSerpOrderService;
+
+    @Autowired
+    @Qualifier("dfOrderServiceImpl")
+    private IErpOrderService dfOrderService;
+
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtErpOrderService;
+
+    @Autowired
+    @Qualifier("JSTErpOrderServiceImpl")
+    private IErpOrderService jSTOrderService;
+    @Autowired
+    @Qualifier("k9OrderScrmServiceImpl")
+    private IErpOrderService k9OrderService;
 
 
     @Autowired
@@ -243,6 +281,193 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         return R.ok();
     }
 
+    @Override
+    @Transactional
+    public R applyForAfterSales(String userId, LiveAfterSalesParam param) {
+        log.info("申请退款请求信息:"+JSONUtil.toJsonStr(param));
+        LiveOrder order=liveOrderService.selectOrderIdByOrderCode(param.getOrderCode());
+        if(!order.getUserId().equals(userId)){
+            throw new CustomException("非法操作");
+        }
+        if(order.getStatus()==0){
+            return R.error("未支付订单不能申请售后");
+        }
+        if("1".equals(configUtil.generateConfigByKey(SysConfigEnum.HIS_CONFIG.getKey()).getString("erpOpen"))
+                && StringUtils.isEmpty(order.getExtendOrderId())
+                && !CloudHostUtils.hasCloudHostName("康年堂")){
+            log.info("erpOpen:{}",configUtil.generateConfigByKey(SysConfigEnum.HIS_CONFIG.getKey()).getString("erpOpen"));
+            return R.error("仓库未生成订单,暂时不能申请退款,请联系客服");
+        }
+        if(order.getStatus()== OrderInfoEnum.STATUS_NE3.getValue()){
+            return R.error("已取消订单不能申请售后");
+        }
+        if(order.getStatus()== OrderInfoEnum.STATUS_NE1.getValue()){
+            return R.error("已提交申请,等待处理");
+        }
+//        if(storeAfterSalesParam.getRefundAmount().compareTo(order.getPayPrice())==1){
+//            return R.error("退款金额不能大于支付金额");
+//        }
+        //已完成订单七天后不能申请退款
+        if(order.getStatus().equals(OrderInfoEnum.STATUS_3.getValue())) {
+            String json=configService.selectConfigByKey("store.config");
+            com.fs.hisStore.config.StoreConfig config=JSONUtil.toBean(json, com.fs.hisStore.config.StoreConfig.class);
+            //已完成订单
+            if (order.getFinishTime() != null) {
+                if (config.getStoreAfterSalesDay() != null && config.getStoreAfterSalesDay() > 0) {
+                    //判断完成时间是否超过指定时间
+                    Calendar calendarAfterSales = new GregorianCalendar();
+                    calendarAfterSales.setTime(order.getFinishTime());
+                    calendarAfterSales.add(calendarAfterSales.DATE, config.getStoreAfterSalesDay()); //把日期往后增加一天,整数  往后推,负数往前移动
+                    if (calendarAfterSales.getTime().getTime() < new Date().getTime()) {
+                        return R.error("此订单已超过售后时间,不能提交售后");
+                    }
+
+                }
+            }
+        }
+        //商品除去优惠后的总价格
+        //BigDecimal totalPrice = BigDecimal.ZERO;
+        //拿到所有的商品
+        List<LiveOrderItem> orderItems = liveOrderItemService.selectCheckedByOrderId(order.getOrderId());
+        for (LiveOrderItem item : orderItems) {
+            StoreOrderProductDTO cartInfo = JSONObject.parseObject(item.getJsonInfo(), StoreOrderProductDTO.class);
+            LiveAfterSalesProductParam prosuctParam = param.getProductList().stream().filter(p -> p.getProductId().equals(item.getProductId())).findFirst().orElse(new LiveAfterSalesProductParam());
+            if (prosuctParam.getProductId() != null) {
+//                //商品优惠前总金额
+//                BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getPrice(), item.getNum());
+//                //商品优惠总金额
+//                BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(order.getTotalPrice(), order.getPayPostage())), order.getCouponPrice());
+//                //商品优惠后总金额
+//                totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
+                item.setIsAfterSales(1);
+                LiveOrderItem orderItem=new LiveOrderItem();
+//                BeanUtil.copyProperties(item, orderItem);
+                try {
+                    BeanUtils.copyProperties(orderItem,item);
+                } catch (IllegalAccessException e) {
+                    throw new RuntimeException(e);
+                } catch (InvocationTargetException e) {
+                    throw new RuntimeException(e);
+                }
+                liveOrderItemService.updateLiveOrderItem(orderItem);
+
+            }
+        }
+        //更新订单状态
+        Integer orderStatus=order.getStatus();
+        order.setStatus(OrderInfoEnum.STATUS_NE1.getValue());
+        order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_1.getValue()));
+        order.setRefundExplain(param.getReasons());
+        order.setCancelReason(param.getExplains());
+        order.setRefundTime(new Date());
+        liveOrderService.updateLiveOrder(order);
+        //生成售后订单
+        LiveAfterSales storeAfterSales = new LiveAfterSales();
+        storeAfterSales.setOrderId(order.getOrderId());
+        storeAfterSales.setRefundAmount(param.getRefundAmount());
+        storeAfterSales.setRefundType(param.getServiceType());
+        storeAfterSales.setReasons(param.getReasons());
+        storeAfterSales.setExplains(param.getExplains());
+        storeAfterSales.setExplainImg(param.getExplainImg());
+        storeAfterSales.setStatus(AfterSalesStatusEnum.STATUS_0.getValue());
+        storeAfterSales.setSalesStatus(0);
+        storeAfterSales.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
+        storeAfterSales.setIsDel(0);
+        storeAfterSales.setUserId(Long.valueOf(userId));
+        storeAfterSales.setOrderStatus(orderStatus);
+        storeAfterSales.setCompanyId(order.getCompanyId());
+        storeAfterSales.setCompanyUserId(order.getCompanyUserId());
+        liveAfterSalesService.insertLiveAfterSales(storeAfterSales);
+        //售后商品详情
+        for (LiveAfterSalesProductParam productParam : param.getProductList()) {
+            LiveOrderItem item = orderItems.stream().filter(p -> p.getProductId().equals(productParam.getProductId())).findFirst().orElse(new LiveOrderItem());
+            LiveAfterSalesItem storeAfterSalesItem = new LiveAfterSalesItem();
+            storeAfterSalesItem.setAfterSalesId(storeAfterSales.getId());
+            storeAfterSalesItem.setProductId(item.getProductId());
+            storeAfterSalesItem.setJsonInfo(item.getJsonInfo());
+            storeAfterSalesItem.setIsDel(0);
+            liveAfterSalesItemMapper.insertLiveAfterSalesItem(storeAfterSalesItem);
+        }
+        //操作记录
+        LiveAfterSalesLogs storeAfterSalesStatus = new LiveAfterSalesLogs();
+        storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId());
+        storeAfterSalesStatus.setChangeType(0);
+        storeAfterSalesStatus.setChangeMessage(AfterSalesStatusEnum.STATUS_0.getDesc());
+        storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
+        FsUserScrm user=userService.selectFsUserById(Long.valueOf(userId));
+        storeAfterSalesStatus.setOperator(user.getNickname());
+        liveAfterSalesLogsMapper.insertLiveAfterSalesLogs(storeAfterSalesStatus);
+
+//        //更新OMS
+        IErpOrderService erpOrderService = getErpService();
+        ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
+        request.setTid(order.getOrderCode());
+        request.setOid(order.getOrderCode());
+        request.setRefund_state(1);
+        request.setStoreAfterSalesId(storeAfterSales.getId());
+        if (StringUtils.isNotBlank(order.getExtendOrderId())){
+            BaseResponse response=erpOrderService.refundUpdateScrm(request);
+            if(response.getSuccess()){
+                return R.ok();
+            }
+            else{
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return R.error(response.getErrorDesc());
+            }
+        }
+        return R.ok();
+    }
+
+    @Override
+    public List<LiveAfterSalesQueryVO> selectLiveAfterSalesListQuery(LiveAfterSalesQueryParam param) {
+        List<LiveAfterSalesQueryVO>  list=baseMapper.selectLiveAfterSalesListQuery(param);
+        for(LiveAfterSalesQueryVO vo:list){
+            LiveAfterSalesItem map=new LiveAfterSalesItem();
+            map.setAfterSalesId(vo.getId());
+            List<LiveAfterSalesItem>  items=liveAfterSalesItemMapper.selectLiveAfterSalesItemByAfterId(vo.getId());
+            vo.setItems(items);
+        }
+        return list;
+    }
+
+    @Override
+    public Integer selectLiveAfterSalesCount(long userId, int salesStatus) {
+        return baseMapper.selectLiveAfterSalesCount(userId, salesStatus);
+    }
+
+    private IErpOrderService getErpService() {
+        FsSysConfig sysConfig = configUtil.getSysConfig();
+        Integer erpOpen = sysConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1){
+            //判断erp类型
+            Integer erpType = sysConfig.getErpType();
+            if (erpType != null){
+                IErpOrderService erpOrderService = null;
+                if (erpType == 1){
+                    //管易
+                    erpOrderService =  gyOrderService;
+                } else if (erpType == 2){
+                    //旺店通
+                    erpOrderService =  wdtErpOrderService;
+                } else if (erpType == 3){
+                    //
+                    erpOrderService =  hzOMSerpOrderService;
+                } else if (erpType == 4){
+                    //代服
+                    erpOrderService =  dfOrderService;
+                }else if(erpType == 5){
+                    erpOrderService=jSTOrderService;
+                }else if(erpType == 6){
+                    erpOrderService=k9OrderService;
+                }
+                return erpOrderService;
+
+
+            }
+        }
+        return null;
+    }
+
     @Override
     public R audit2(LiveAfterSalesAudit2Param param) {
         LiveAfterSales storeAfterSales = baseMapper.selectLiveAfterSalesById(param.getSalesId());
@@ -438,7 +663,7 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         LiveAfterSalesLogs logs = new LiveAfterSalesLogs();
         logs.setChangeTime(new DateTime());
         logs.setChangeType(2);
-        FsUser user = userService.selectFsUserByUserId(storeAfterSales.getUserId());
+        FsUserScrm user = userService.selectFsUserByUserId(storeAfterSales.getUserId());
         logs.setOperator(user.getNickname());
         logs.setStoreAfterSalesId(storeAfterSales.getId());
         logs.setChangeMessage(OrderInfoEnum.STATUS_2.getDesc());
@@ -610,7 +835,7 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
             throw new CustomException("已发货退款单不能撤销");
         }
         //只有未发货的可以撤销,
-        if (!storeAfterSales.getOrderStatus().equals(2)) {
+        if (!storeAfterSales.getOrderStatus().equals(OrderInfoEnum.STATUS_1.getValue())) {
             throw new CustomException("只有未发货的订单可以撤销售后");
         }
         storeAfterSales.setSalesStatus(1);
@@ -622,7 +847,7 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         LiveAfterSalesLogs logs = new LiveAfterSalesLogs();
         logs.setChangeTime(new DateTime());
         logs.setChangeType(5);
-        FsUser user = userService.selectFsUserByUserId(Long.valueOf(order.getUserId()));
+        FsUserScrm user = userService.selectFsUserByUserId(Long.valueOf(order.getUserId()));
         logs.setOperator(user.getNickname());
         logs.setStoreAfterSalesId(storeAfterSales.getId());
         logs.setChangeMessage(OrderInfoEnum.REFUND_STATUS_1.getDesc());
@@ -630,8 +855,7 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         if (storeAfterSales.getOrderStatus().equals(2)) {
             if (StringUtils.isNotEmpty(order.getExtendOrderId())) {
                 //更新订单code
-                // todo yhq
-                String orderSn = "123";
+                String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
                 if (StringUtils.isEmpty(orderSn)) {
                     return R.error("订单生成失败,请重试");
                 }

+ 93 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderDfServiceImpl.java

@@ -0,0 +1,93 @@
+package com.fs.live.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.live.domain.LiveOrderDf;
+import com.fs.live.mapper.LiveOrderDfMapper;
+import com.fs.live.service.ILiveOrderDfService;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 订单代服管家Service业务层处理
+ *
+ * @author fs
+ * @date 2025-07-08
+ */
+@Service
+public class LiveOrderDfServiceImpl extends ServiceImpl<LiveOrderDfMapper, LiveOrderDf> implements ILiveOrderDfService {
+
+    /**
+     * 查询订单代服管家
+     *
+     * @param orderId 订单代服管家主键
+     * @return 订单代服管家
+     */
+    @Override
+    public LiveOrderDf selectLiveOrderDfByOrderId(Long orderId)
+    {
+        return baseMapper.selectLiveOrderDfByOrderId(orderId);
+    }
+
+    /**
+     * 查询订单代服管家列表
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 订单代服管家
+     */
+    @Override
+    public List<LiveOrderDf> selectLiveOrderDfList(LiveOrderDf fsStoreOrderDf)
+    {
+        return baseMapper.selectLiveOrderDfList(fsStoreOrderDf);
+    }
+
+    /**
+     * 新增订单代服管家
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 结果
+     */
+    @Override
+    public int insertLiveOrderDf(LiveOrderDf fsStoreOrderDf)
+    {
+        fsStoreOrderDf.setCreateTime(new Date());
+        return baseMapper.insertLiveOrderDf(fsStoreOrderDf);
+    }
+
+    /**
+     * 修改订单代服管家
+     *
+     * @param fsStoreOrderDf 订单代服管家
+     * @return 结果
+     */
+    @Override
+    public int updateLiveOrderDf(LiveOrderDf fsStoreOrderDf)
+    {
+        return baseMapper.updateLiveOrderDf(fsStoreOrderDf);
+    }
+
+    /**
+     * 批量删除订单代服管家
+     *
+     * @param orderIds 需要删除的订单代服管家主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveOrderDfByOrderIds(Long[] orderIds)
+    {
+        return baseMapper.deleteLiveOrderDfByOrderIds(orderIds);
+    }
+
+    /**
+     * 删除订单代服管家信息
+     *
+     * @param orderId 订单代服管家主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveOrderDfByOrderId(Long orderId)
+    {
+        return baseMapper.deleteLiveOrderDfByOrderId(orderId);
+    }
+}

+ 7 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderItemServiceImpl.java

@@ -4,6 +4,8 @@ import java.util.Collections;
 import java.util.List;
 
 import com.fs.live.domain.LiveOrder;
+import com.fs.live.param.LiveOrderParam;
+import com.fs.live.vo.LiveOrderItemExportVO;
 import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.live.vo.LiveOrderItemVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -115,4 +117,9 @@ public class LiveOrderItemServiceImpl implements ILiveOrderItemService {
     public List<LiveOrderItem> selectCheckedByOrderId(Long id) {
         return baseMapper.selectCheckedByOrderId(id);
     }
+
+    @Override
+    public List<LiveOrderItemExportVO> selectLiveOrderItemListExportVO(LiveOrderParam param) {
+        return baseMapper.selectFsStoreOrderItemListExportVO(param);
+    }
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 530 - 385
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java


+ 53 - 0
fs-service/src/main/java/com/fs/live/vo/FsMyLiveOrderListQueryVO.java

@@ -0,0 +1,53 @@
+package com.fs.live.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.live.domain.LiveOrderItem;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 订单对象 fs_store_order
+ *
+ * @author fs
+ * @date 2022-03-15
+ */
+@Data
+public class FsMyLiveOrderListQueryVO implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 订单ID */
+    private Long id;
+
+    /** 订单号 */
+    private String orderCode;
+
+    /** 实际支付金额 */
+    @Excel(name = "实际支付金额")
+    private BigDecimal payPrice;
+
+    private Integer status;
+
+    private Integer isPackage;
+
+    private String  packageJson;
+
+    private String  itemJson;
+
+    private String deliveryId;
+
+    private Integer isAfterSales;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date finishTime;
+
+    private List<LiveOrderItem> items;
+
+
+}

+ 95 - 0
fs-service/src/main/java/com/fs/live/vo/LiveAfterSalesQueryVO.java

@@ -0,0 +1,95 @@
+package com.fs.live.vo;
+
+import com.fs.common.annotation.Excel;
+import com.fs.hisStore.domain.FsStoreAfterSalesItemScrm;
+import com.fs.live.domain.LiveAfterSalesItem;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class LiveAfterSalesQueryVO implements Serializable
+{
+
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 订单号 */
+    @Excel(name = "订单号")
+    private String orderCode;
+
+    /** 退款金额 */
+    @Excel(name = "退款金额")
+    private BigDecimal refundAmount;
+
+    /** 服务类型0仅退款1退货退款 */
+    @Excel(name = "服务类型0仅退款1退货退款")
+    private Integer serviceType;
+
+    /** 申请原因 */
+    @Excel(name = "申请原因")
+    private String reasons;
+
+    /** 说明 */
+    @Excel(name = "说明")
+    private String explains;
+
+    /** 说明图片->多个用逗号分割 */
+    @Excel(name = "说明图片->多个用逗号分割")
+    private String explainImg;
+
+    /** 物流公司编码 */
+    @Excel(name = "物流公司编码")
+    private String shipperCode;
+
+    /** 物流单号 */
+    @Excel(name = "物流单号")
+    private String deliverySn;
+
+    /** 物流名称 */
+    @Excel(name = "物流名称")
+    private String deliveryName;
+
+    /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功 */
+    @Excel(name = "状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功")
+    private Integer status;
+
+    /** 售后状态-0正常1用户取消2商家拒绝 */
+    @Excel(name = "售后状态-0正常1用户取消2商家拒绝")
+    private Integer salesStatus;
+
+    @Excel(name = "订单当前状态")
+    private Integer orderStatus;
+
+    /** 逻辑删除 */
+    @Excel(name = "逻辑删除")
+    private Integer isDel;
+
+    /** 用户id */
+    @Excel(name = "用户id")
+    private Long userId;
+
+    /** 商家收货人 */
+    @Excel(name = "商家收货人")
+    private String consignee;
+
+    /** 商家手机号 */
+    @Excel(name = "商家手机号")
+    private String phoneNumber;
+
+    /** 商家地址 */
+    @Excel(name = "商家地址")
+    private String address;
+
+    private Integer isPackage;
+
+    private String packageJson;
+
+
+    List<LiveAfterSalesItem> items;
+
+
+}

+ 19 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderErpExportVO.java

@@ -0,0 +1,19 @@
+package com.fs.live.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 订单对象 fs_store_order
+ *
+ * @author fs
+ * @date 2022-03-15
+ */
+@Data
+public class LiveOrderErpExportVO extends LiveOrderExportVO
+{
+    @Excel(name = "ERP电话",sort = 1)
+    private String erpPhone;
+    @Excel(name = "ERP账户",sort = 2)
+    private String erpAccount;
+}

+ 255 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderExportVO.java

@@ -0,0 +1,255 @@
+package com.fs.live.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 LiveOrderExportVO implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 订单ID */
+    private Long id;
+
+    /** 订单号 */
+    @Excel(name = "订单号")
+    private String orderCode;
+    @Excel(name = "会员ID")
+    private Long userId;
+    /** 额外订单号 */
+    @Excel(name = "管易云订单号")
+    private String extendOrderId;
+
+    @Excel(name = "所属公司")
+    private String companyName;
+    @Excel(name = "所属销售")
+    private String companyUserNickName;
+
+    @Excel(name = "推线编号")
+    private String pushCode;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "客户创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date customerCreateTime;
+
+    @Excel(name = "客户来源",dictType = "crm_customer_source")
+    private String source;
+
+    @Excel(name = "成单类型", dictType = "store_order_type")
+    private String orderType;
+
+
+
+    /** 用户姓名 */
+    @Excel(name = "收货人姓名")
+    private String realName;
+
+    /** 用户电话 */
+    @Excel(name = "收货人电话")
+    private String userPhone;
+
+    /** 详细地址 */
+    @Excel(name = "详细地址")
+    private String userAddress;
+
+//    /** 购物车id */
+//    private String cartId;
+//
+//    /** 运费金额 */
+//    private BigDecimal freightPrice;
+//
+//    /** 订单商品总数 */
+//    private Long totalNum;
+
+    /** 订单总价 */
+    @Excel(name = "商品金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal totalPrice;
+
+//    /** 邮费 */
+//    private BigDecimal totalPostage;
+
+    /** 实际支付金额 */
+    @Excel(name = "应付金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal payPrice;
+
+    @Excel(name = "实付金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal payMoney;
+
+    @Excel(name = "物流代收金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal payDelivery;
+
+
+
+
+//    /** 支付邮费 */
+//    private BigDecimal payPostage;
+
+    /** 抵扣金额 */
+    @Excel(name = "抵扣金额",cellType= Excel.ColumnType.NUMERIC)
+
+    private BigDecimal deductionPrice;
+
+//    /** 优惠券id */
+//    private Long couponId;
+
+    /** 优惠券金额 */
+    @Excel(name = "优惠券金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal couponPrice;
+
+//    /** 支付状态 */
+//    private Integer paid;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
+
+    /** 支付方式 */
+    @Excel(name = "支付方式")
+    private String payType;
+
+    /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:已完成;-1:已退款) */
+    @Excel(name = "订单状态", dictType = "store_order_status")
+    private String status;
+
+//    /** 0 未退款 1 申请中 2 已退款 */
+////    @Excel(name = "0 未退款 1 申请中 2 已退款")
+//    private Integer refundStatus;
+//
+//    /** 退款图片 */
+////    @Excel(name = "退款图片")
+//    private String refundReasonWapImg;
+//
+//    /** 退款用户说明 */
+////    @Excel(name = "退款用户说明")
+//    private String refundReasonWapExplain;
+
+    /** 退款时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "退款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date refundReasonTime;
+
+//    /** 前台退款原因 */
+////    @Excel(name = "前台退款原因")
+//    private String refundReasonWap;
+//
+//    /** 不退款的理由 */
+////    @Excel(name = "不退款的理由")
+//    private String refundReason;
+
+    /** 退款金额 */
+    @Excel(name = "退款金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal refundPrice;
+
+    /** 快递公司编号 */
+    @Excel(name = "快递公司编号")
+    private String deliverySn;
+
+    /** 快递名称/送货人姓名 */
+    @Excel(name = "快递公司")
+    private String deliveryName;
+
+    /** 快递单号/手机号 */
+    @Excel(name = "快递单号")
+    private String deliveryId;
+
+//    /** 消费赚取积分 */
+//    private BigDecimal gainIntegral;
+//
+//    /** 使用积分 */
+//    private BigDecimal useIntegral;
+//
+//    /** 实际支付积分 */
+//    private BigDecimal payIntegral;
+
+//    /** 给用户退了多少积分 */
+//    private BigDecimal backIntegral;
+
+    /** 备注 */
+    @Excel(name = "备注")
+    private String mark;
+
+//    /** 是否删除 */
+//    private Integer isDel;
+//
+//    /** 成本价 */
+//    private BigDecimal cost;
+//
+//    /** 核销码 */
+//    private String verifyCode;
+//
+//    /** 门店id */
+//    private Long storeId;
+//
+//    /** 配送方式 1=快递 ,2=门店自提 */
+//    private Integer shippingType;
+//
+//    /** 支付渠道(0微信公众号1微信小程序) */
+//    private Integer isChannel;
+//
+//    /** 是否提醒 */
+//    private Integer isRemind;
+//
+//    /** 是否系统删除 */
+//    private Integer isSysDel;
+//
+//    private String nickname;
+//
+    private String phone;
+//
+//
+//    private Date finishTime;
+//
+//    private Integer isPackage;
+//
+//    private List<FsStoreOrderItemVO> items;
+
+
+    @Excel(name = "物流代收结算状态", dictType = "store_delivery_pay_status")
+    private Integer deliveryPayStatus;
+
+    @Excel(name = "快递帐单日期")
+    private String deliveryTime;
+
+    @Excel(name = "快递结算日期")
+    private String deliveryPayTime;
+
+    @Excel(name = "物流结算费用")
+    private BigDecimal deliveryPayMoney;
+
+    @Excel(name = "物流状态" , dictType = "store_order_delivery_status")
+    private String deliveryStatus;
+
+    @Excel(name = "物流跟踪状态" , dictType = "store_order_delivery_type")
+    private String deliveryType;
+
+    @Excel(name = "客户编码")
+    private String customerCode;
+
+    @Excel(name = "套餐名称",width = 60)
+    private String packageTitle;
+
+    @Excel(name = "是否上传凭证 0:未上传 1:已上传")
+    private Integer isUpload;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date uploadTime;
+
+    @Excel(name = "归属档期")
+    private String scheduleName;
+}

+ 101 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderItemExportVO.java

@@ -0,0 +1,101 @@
+package com.fs.live.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;
+
+@Data
+public class LiveOrderItemExportVO implements Serializable
+{
+
+    private Long itemId;
+
+    /** 订单号 */
+    @Excel(name = "订单号")
+    private String orderCode;
+
+    @Excel(name = "订单状态", dictType = "store_order_status")
+    private String status;
+
+    @Excel(name = "会员ID")
+    private Long userId;
+
+    @Excel(name = "产品名称")
+    private String productName;
+
+    @Excel(name = "产品编码")
+    private String barCode;
+
+
+    @Excel(name = "规格")
+    private String sku;
+
+    @Excel(name = "产品数量")
+    private Integer num;
+
+
+    @Excel(name = "产品价格")
+    private BigDecimal price;
+
+
+    private String jsonInfo;
+
+    /** 用户姓名 */
+    @Excel(name = "收货人姓名")
+    private String realName;
+
+    /** 用户电话 */
+    @Excel(name = "收货人电话")
+    private String userPhone;
+
+    /** 详细地址 */
+    @Excel(name = "详细地址")
+    private String userAddress;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
+
+    /** 快递公司编号 */
+    @Excel(name = "快递公司编号")
+    private String deliverySn;
+
+    /** 快递名称/送货人姓名 */
+    @Excel(name = "快递公司")
+    private String deliveryName;
+
+    /** 快递单号/手机号 */
+    @Excel(name = "快递单号")
+    private String deliveryId;
+
+    @Excel(name = "所属公司")
+    private String companyName;
+    @Excel(name = "所属销售")
+    private String companyUserNickName;
+
+    @Excel(name = "套餐名称")
+    private String packageName;
+
+    @Excel(name = "组合码")
+    private String groupBarCode;
+
+    @Excel(name = "是否上传凭证 0:未上传 1:已上传")
+    private Integer isUpload;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date uploadTime;
+
+    @Excel(name = "归属档期")
+    private String scheduleName;
+
+
+}

+ 51 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderItemVO1.java

@@ -0,0 +1,51 @@
+package com.fs.live.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class LiveOrderItemVO1 implements Serializable
+{
+
+    private Long itemId;
+
+    /** 订单id */
+    @Excel(name = "订单id")
+    private Long orderId;
+
+    /** 订单号 */
+    @Excel(name = "订单号")
+    private String orderCode;
+
+    /** 购物车id 减数量用 */
+    @Excel(name = "购物车id 减数量用")
+    private Long cartId;
+
+    /** 商品ID */
+    @Excel(name = "商品ID")
+    private Long productId;
+
+    /** $column.columnComment */
+    @Excel(name = "商品ID")
+    private Long productAttrValueId;
+
+    /** $column.columnComment */
+    @Excel(name = "商品ID")
+    private String jsonInfo;
+
+    /** $column.columnComment */
+    @Excel(name = "商品ID")
+    private Long num;
+
+    /** 是否能售后0不能1能 */
+    @Excel(name = "是否能售后0不能1能")
+    private Integer isAfterSales;
+
+    @Excel(name = "是否为处方")
+    private Integer isPrescribe;
+
+    private Integer isDrug; //是否为药品
+
+}

+ 12 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderListAndStatisticsVo.java

@@ -0,0 +1,12 @@
+package com.fs.live.vo;
+
+import com.fs.common.core.page.TableDataInfo;
+import lombok.Data;
+
+@Data
+public class LiveOrderListAndStatisticsVo extends TableDataInfo{
+    private String payPriceTotal;
+    private String payMoneyTotal;
+    private String payRemainTotal;
+    private String productInfo;
+}

+ 1 - 1
fs-service/src/main/java/com/fs/live/vo/LiveOrderVo.java → fs-service/src/main/java/com/fs/live/vo/LiveOrderTimeVo.java

@@ -5,7 +5,7 @@ import lombok.Data;
 import java.util.Date;
 
 @Data
-public class LiveOrderVo {
+public class LiveOrderTimeVo {
     private String timeOptions;
     private String timeGranularity;
     private String liveId;

+ 259 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderVO.java

@@ -0,0 +1,259 @@
+package com.fs.live.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 订单对象 live_order
+ *
+ * @author fs
+ * @date 2022-03-15
+ */
+@Data
+public class LiveOrderVO implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 订单ID */
+    private Long id;
+
+    /** 订单号 */
+    @Excel(name = "订单号")
+    private String orderCode;
+    @Excel(name = "会员ID")
+    private Long userId;
+    /** 额外订单号 */
+    @Excel(name = "管易云订单号")
+    private String extendOrderId;
+
+    @Excel(name = "所属公司")
+    private String companyName;
+    @Excel(name = "所属销售")
+    private String companyUserNickName;
+    @Excel(name = "销售电话")
+    private String companyUserePhonenumber;
+
+    @Excel(name = "推线编号")
+    private String registerCode;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "推线时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date registerDate;
+
+    @Excel(name = "渠道来源")
+    private String source;
+
+    @Excel(name = "成单类型", dictType = "store_order_type")
+    private String orderType;
+
+
+
+    /** 用户姓名 */
+    @Excel(name = "收货人姓名")
+    private String realName;
+
+    /** 用户电话 */
+    @Excel(name = "收货人电话")
+    private String userPhone;
+
+    /** 详细地址 */
+    @Excel(name = "详细地址")
+    private String userAddress;
+
+    /** 购物车id */
+    private String cartId;
+
+    /** 运费金额 */
+    private BigDecimal freightPrice;
+
+    /** 订单商品总数 */
+    private Long totalNum;
+
+    /** 订单总价 */
+    @Excel(name = "商品金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal totalPrice;
+
+    /** 邮费 */
+    private BigDecimal totalPostage;
+
+    /** 实际支付金额 */
+    @Excel(name = "应付金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal payPrice;
+
+    @Excel(name = "实付金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal payMoney;
+
+    @Excel(name = "尾款实付金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal lastPayMoney;
+
+    @Excel(name = "物流代收金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal payDelivery;
+
+
+    /** 支付邮费 */
+
+    private BigDecimal payPostage;
+
+    /** 抵扣金额 */
+    private BigDecimal deductionPrice;
+
+    /** 优惠券id */
+    private Long couponId;
+
+    /** 优惠券金额 */
+    @Excel(name = "优惠券金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal couponPrice;
+
+    /** 支付状态 */
+    private Integer paid;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
+
+    /** 支付方式 */
+//    @Excel(name = "支付方式")
+    private String payType;
+
+    /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:已完成;-1:已退款) */
+    @Excel(name = "订单状态", dictType = "store_order_status")
+    private String status;
+
+    /** 0 未退款 1 申请中 2 已退款 */
+//    @Excel(name = "0 未退款 1 申请中 2 已退款")
+    private Integer refundStatus;
+
+    /** 退款图片 */
+//    @Excel(name = "退款图片")
+    private String refundReasonWapImg;
+
+    /** 退款用户说明 */
+//    @Excel(name = "退款用户说明")
+    private String refundReasonWapExplain;
+
+    /** 退款时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+//    @Excel(name = "退款时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date refundReasonTime;
+
+    /** 前台退款原因 */
+//    @Excel(name = "前台退款原因")
+    private String refundReasonWap;
+
+    /** 不退款的理由 */
+//    @Excel(name = "不退款的理由")
+    private String refundReason;
+
+    /** 退款金额 */
+//    @Excel(name = "退款金额",cellType= Excel.ColumnType.NUMERIC)
+    private BigDecimal refundPrice;
+
+    /** 快递公司编号 */
+    @Excel(name = "快递公司编号")
+    private String deliverySn;
+
+    /** 快递名称/送货人姓名 */
+    @Excel(name = "快递公司")
+    private String deliveryName;
+
+    /** 发货类型 */
+    @Excel(name = "发货类型")
+    private String deliveryType;
+
+    /** 快递单号/手机号 */
+    @Excel(name = "快递单号")
+    private String deliveryId;
+
+    /** 消费赚取积分 */
+    private BigDecimal gainIntegral;
+
+    /** 使用积分 */
+    private BigDecimal useIntegral;
+
+    /** 实际支付积分 */
+    private BigDecimal payIntegral;
+
+    /** 给用户退了多少积分 */
+    private BigDecimal backIntegral;
+
+    /** 备注 */
+    @Excel(name = "备注")
+    private String mark;
+
+    /** 是否删除 */
+    private Integer isDel;
+
+    /** 成本价 */
+    private BigDecimal cost;
+
+    /** 核销码 */
+    private String verifyCode;
+
+    /** 门店id */
+    private Long storeId;
+
+    /** 配送方式 1=快递 ,2=门店自提 */
+    private Integer shippingType;
+
+    /** 支付渠道(0微信公众号1微信小程序) */
+    private Integer isChannel;
+
+    /** 是否提醒 */
+    private Integer isRemind;
+
+    /** 是否系统删除 */
+    private Integer isSysDel;
+
+    private String nickname;
+
+    private String phone;
+
+
+    private Date finishTime;
+
+    private Integer isPackage;
+
+    private List<FsStoreOrderItemVO> items;
+
+    private Integer deliveryStatus;
+
+    @Excel(name = "物流代收结算状态", dictType = "store_delivery_pay_status")
+    private Integer deliveryPayStatus;
+
+    @Excel(name = "快递帐单日期")
+    private String deliveryTime;
+
+    @Excel(name = "快递结算日期")
+    private String deliveryPayTime;
+    @Excel(name = "物流代收金额")
+    private BigDecimal deliveryPayMoney;
+
+    private String itemJson;
+
+    private String orderVisit;
+
+    private String orderMedium;
+
+    //小程序名称
+    private String miniProgramName;
+
+
+    //erp推送号码
+    private String erpPhone;
+
+    //erp推送账号
+    private String erpAccount;
+
+
+}

+ 117 - 0
fs-service/src/main/resources/mapper/live/LiveOrderDfMapper.xml

@@ -0,0 +1,117 @@
+<?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.live.mapper.LiveOrderDfMapper">
+
+    <resultMap type="LiveOrderDf" id="LiveOrderDfResult">
+        <result property="orderId"    column="order_id"    />
+        <result property="orderCode"    column="order_code"    />
+        <result property="appKey"    column="app_key"    />
+        <result property="appSecret"    column="app_secret"    />
+        <result property="loginAccount"    column="login_account"    />
+        <result property="monthlyCard"    column="monthly_card"    />
+        <result property="expressProductCode"    column="express_product_code"    />
+        <result property="totalPrice"    column="total_price"    />
+        <result property="platformPrice"    column="platform_price"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="failMsg"    column="fail_msg"    />
+        <result property="parcelQuantity"    column="parcel_quantity"    />
+    </resultMap>
+
+    <sql id="selectLiveOrderDfVo">
+        select order_id, order_code, app_key, app_secret, login_account, monthly_card, express_product_code,total_price,
+               platform_price, status, create_time, update_time,fail_msg ,parcel_quantity from live_order_df
+    </sql>
+
+    <select id="selectLiveOrderDfList" parameterType="LiveOrderDf" resultMap="LiveOrderDfResult">
+        <include refid="selectLiveOrderDfVo"/>
+        <where>
+            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
+            <if test="appKey != null  and appKey != ''"> and app_key = #{appKey}</if>
+            <if test="appSecret != null  and appSecret != ''"> and app_secret = #{appSecret}</if>
+            <if test="loginAccount != null  and loginAccount != ''"> and login_account = #{loginAccount}</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="totalPrice != null "> and total_price = #{totalPrice}</if>
+            <if test="platformPrice != null "> and platform_price = #{platformPrice}</if>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="failMsg != null and failMsg != ''"> and fail_msg like concat(#{failMsg},'%')</if>
+            <if test="parcelQuantity != null"> and parcel_quantity = #{parcelQuantity}</if>
+        </where>
+    </select>
+
+    <select id="selectLiveOrderDfByOrderId" parameterType="Long" resultMap="LiveOrderDfResult">
+        <include refid="selectLiveOrderDfVo"/>
+        where order_id = #{orderId}
+    </select>
+
+    <insert id="insertLiveOrderDf" parameterType="LiveOrderDf">
+        insert into live_order_df
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderId != null">order_id,</if>
+            <if test="orderCode != null and orderCode != ''">order_code,</if>
+            <if test="appKey != null and appKey != ''">app_key,</if>
+            <if test="appSecret != null and appSecret != ''">app_secret,</if>
+            <if test="loginAccount != null and loginAccount != ''">login_account,</if>
+            <if test="monthlyCard != null and monthlyCard != ''">monthly_card,</if>
+            <if test="expressProductCode != null and expressProductCode != ''">express_product_code,</if>
+            <if test="totalPrice != null">total_price,</if>
+            <if test="platformPrice != null">platform_price,</if>
+            <if test="status != null">status,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="failMsg != null">fail_msg,</if>
+            <if test="parcelQuantity != null">parcel_quantity,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderId != null">#{orderId},</if>
+            <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
+            <if test="appKey != null and appKey != ''">#{appKey},</if>
+            <if test="appSecret != null and appSecret != ''">#{appSecret},</if>
+            <if test="loginAccount != null and loginAccount != ''">#{loginAccount},</if>
+            <if test="monthlyCard != null and monthlyCard != ''">#{monthlyCard},</if>
+            <if test="expressProductCode != null and expressProductCode != ''">#{expressProductCode},</if>
+            <if test="totalPrice != null">#{totalPrice},</if>
+            <if test="platformPrice != null">#{platformPrice},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="failMsg != null">#{failMsg},</if>
+            <if test="parcelQuantity != null">#{parcelQuantity},</if>
+         </trim>
+    </insert>
+
+    <update id="updateLiveOrderDf" parameterType="LiveOrderDf">
+        update live_order_df
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
+            <if test="appKey != null and appKey != ''">app_key = #{appKey},</if>
+            <if test="appSecret != null and appSecret != ''">app_secret = #{appSecret},</if>
+            <if test="loginAccount != null and loginAccount != ''">login_account = #{loginAccount},</if>
+            <if test="monthlyCard != null and monthlyCard != ''">monthly_card = #{monthlyCard},</if>
+            <if test="expressProductCode != null and expressProductCode != ''">express_product_code = #{expressProductCode},</if>
+            <if test="totalPrice != null">total_price = #{totalPrice},</if>
+            <if test="platformPrice != null">platform_price = #{platformPrice},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="failMsg != null and failMsg != ''">fail_msg = #{failMsg},</if>
+            <if test="parcelQuantity != null">parcel_quantity = #{parcelQuantity},</if>
+        </trim>
+        where order_id = #{orderId}
+    </update>
+
+    <delete id="deleteLiveOrderDfByOrderId" parameterType="Long">
+        delete from live_order_df where order_id = #{orderId}
+    </delete>
+
+    <delete id="deleteLiveOrderDfByOrderIds" parameterType="String">
+        delete from live_order_df where order_id in
+        <foreach item="orderId" collection="array" open="(" separator="," close=")">
+            #{orderId}
+        </foreach>
+    </delete>
+</mapper>

+ 479 - 12
fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="storeId"    column="store_id"    />
         <result property="orderCode"    column="order_code"    />
         <result property="userId"    column="user_id"    />
-        <result property="userName"    column="user_name"    />
+        <result property="realName"    column="real_name"    />
         <result property="userPhone"    column="user_phone"    />
         <result property="userAddress"    column="user_address"    />
         <result property="cartId"    column="cart_id"    />
@@ -77,11 +77,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="companyUserName"    column="company_user_name"    />
         <result property="companyName"    column="company_name"    />
         <result property="customerId"    column="customer_id"    />
+        <result property="couponPrice"    column="coupon_price"    />
     </resultMap>
 
     <sql id="selectLiveOrderVo">
         SELECT
-            a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
+            a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.real_name,
             a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
             a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
             a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
@@ -90,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.user_coupon_id,	a.company_id,	a.company_user_id,	a.store_house_code,	a.extend_order_id,	a.pay_delivery,
             a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
             a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
-            a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,
+            a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
             a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_introduce as product_introduce,a.customer_id
         FROM
             live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
@@ -98,7 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveOrderList" parameterType="LiveOrder" resultMap="LiveOrderResult">
         SELECT
-        c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
+        c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.real_name,
         a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
         a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
         a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
@@ -107,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         a.user_coupon_id,	a.company_id,	a.company_user_id,	a.store_house_code,	a.extend_order_id,	a.pay_delivery,
         a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
         a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
-        a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,
+        a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
         a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
         FROM
         live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
@@ -120,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="storeId != null "> and store_id = #{storeId}</if>
             <if test="orderCode != null  and orderCode != ''"> and a.order_code = #{orderCode}</if>
             <if test="userId != null  and userId != ''"> and a.user_id = #{userId}</if>
-            <if test="userName != null  and userName != ''"> and a.user_name like concat('%', #{userName}, '%')</if>
+            <if test="realName != null  and realName != ''"> and a.real_name like concat('%', #{realName}, '%')</if>
             <if test="userPhone != null  and userPhone != ''"> and a.user_phone = #{userPhone}</if>
             <if test="userAddress != null  and userAddress != ''"> and a.user_address = #{userAddress}</if>
             <if test="cartId != null  and cartId != ''"> and cart_id = #{cartId}</if>
@@ -186,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveOrderByOrderId" parameterType="String" resultMap="LiveOrderResult">
         SELECT
-            c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
+            c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.real_name,
             a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
             a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
             a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
@@ -195,7 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.user_coupon_id,	a.company_id,	a.company_user_id,	a.store_house_code,	a.extend_order_id,	a.pay_delivery,
             a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
             a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
-            a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,
+            a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
             a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
         FROM
             live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
@@ -212,7 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="storeId != null">store_id,</if>
             <if test="orderCode != null and orderCode != ''">order_code,</if>
             <if test="userId != null and userId != ''">user_id,</if>
-            <if test="userName != null">user_name,</if>
+            <if test="realName != null">real_name,</if>
             <if test="userPhone != null">user_phone,</if>
             <if test="userAddress != null">user_address,</if>
             <if test="cartId != null">cart_id,</if>
@@ -276,13 +277,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isEditMoney != null">is_edit_money,</if>
             <if test="productId != null">product_id,</if>
             <if test="customerId != null">customer_id,</if>
+            <if test="couponPrice != null">coupon_price,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
             <if test="storeId != null">#{storeId},</if>
             <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
             <if test="userId != null and userId != ''">#{userId},</if>
-            <if test="userName != null">#{userName},</if>
+            <if test="realName != null">#{realName},</if>
             <if test="userPhone != null">#{userPhone},</if>
             <if test="userAddress != null">#{userAddress},</if>
             <if test="cartId != null">#{cartId},</if>
@@ -346,6 +348,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isEditMoney != null">#{isEditMoney},</if>
             <if test="productId != null">#{productId},</if>
             <if test="customerId != null">#{customerId},</if>
+            <if test="couponPrice != null">#{couponPrice},</if>
          </trim>
     </insert>
 
@@ -356,7 +359,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="storeId != null">store_id = #{storeId},</if>
             <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
             <if test="userId != null and userId != ''">user_id = #{userId},</if>
-            <if test="userName != null">user_name = #{userName},</if>
+            <if test="realName != null">real_name = #{realName},</if>
             <if test="userPhone != null">user_phone = #{userPhone},</if>
             <if test="userAddress != null">user_address = #{userAddress},</if>
             <if test="cartId != null">cart_id = #{cartId},</if>
@@ -419,6 +422,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="backIntegral != null">back_integral = #{backIntegral},</if>
             <if test="isEditMoney != null">is_edit_money = #{isEditMoney},</if>
             <if test="customerId != null">customer_id = #{customerId},</if>
+            <if test="couponPrice != null">coupon_price = #{couponPrice},</if>
         </trim>
         where order_id = #{orderId}
     </update>
@@ -434,7 +438,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
-    <select id="getLiveOrderTimeGranularity" parameterType="com.fs.live.vo.LiveOrderVo" resultMap="LiveOrderResult">
+    <select id="getLiveOrderTimeGranularity" parameterType="com.fs.live.vo.LiveOrderTimeVo" resultMap="LiveOrderResult">
         <include refid="selectLiveOrderVo"/>
         where 1=1
         <if test="timeOptions != 'all'">and a.create_time >= #{createTime}</if>
@@ -450,4 +454,467 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         AND create_time < DATE_SUB(NOW(), INTERVAL 1800 MINUTE)
         ]]>
     </select>
+
+    <update id="batchUpdateErpByOrderIds">
+        UPDATE live_order
+        SET erp_phone =
+        <trim prefix="CASE order_id" suffix="END">
+            <foreach collection="maps" item="map">
+                WHEN #{map.orderId} THEN #{map.erpPhone}
+            </foreach>
+        </trim>
+        WHERE order_id IN
+        <foreach collection="maps" item="map" open="(" separator="," close=")">
+            #{map.orderId}
+        </foreach>
+    </update>
+
+    <select id="selectLiveOrderInId" resultType="com.fs.live.domain.LiveOrder">
+        <include refid="selectLiveOrderVo"/>
+        where order_id IN <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
+        #{item}
+    </foreach>
+    </select>
+
+    <select id="selectLiveOrderListVO" resultType="com.fs.live.vo.LiveOrderVO">
+
+    select o.*,u.phone,u.register_code,u.register_date,u.source, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber
+    , csc.name miniProgramName
+    from live_order 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 live_order_df df on df.order_id=o.order_id
+
+    </if>
+    <if test = "maps.productName != null and  maps.productName !=  '' ">
+        left join live_order_item oi on o.order_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 live_order_payment 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.order_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.order_id desc
+    </if>
+</select>
+    <select id="selectLiveOrderStatistics" resultType="java.util.Map">
+        select sum(o.pay_price) pay_price,sum(o.pay_money) pay_money,sum(o.pay_delivery) pay_remain
+        FROM live_order 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 live_order_df df on df.order_id=o.order_id
+        </if>
+        <if test = "maps.productName != null and  maps.productName !=  '' ">
+            left join live_order_item oi on o.order_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 live_order_payment 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="selectLiveOrderProductStatistics" 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 live_order_item soi ON soi.product_id = sp.product_id
+        INNER JOIN live_order o ON soi.order_id = o.order_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 live_order_df df on df.order_id=o.order_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 live_order_payment 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>
 </mapper>

+ 26 - 28
fs-user-app/src/main/java/com/fs/app/controller/live/LiveAfterSalesController.java

@@ -6,20 +6,20 @@ import com.fs.app.controller.AppBaseController;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.ParseUtils;
-import com.fs.common.utils.ServletUtils;
 import com.fs.live.domain.LiveAfterSales;
 import com.fs.live.domain.LiveAfterSalesItem;
 import com.fs.live.domain.LiveOrder;
-import com.fs.live.param.LiveAfterSalesApplyParam;
+import com.fs.live.domain.LiveOrderItem;
 import com.fs.live.param.LiveAfterSalesDeliveryParam;
-import com.fs.live.param.LiveAfterSalesListUParam;
+import com.fs.live.param.LiveAfterSalesParam;
+import com.fs.live.param.LiveAfterSalesQueryParam;
 import com.fs.live.param.LiveAfterSalesRevokeParam;
 import com.fs.live.service.ILiveAfterSalesItemService;
 import com.fs.live.service.ILiveAfterSalesService;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderService;
-import com.fs.live.vo.LiveAfterSalesListUVO;
-import com.fs.live.vo.LiveOrderItemListUVO;
+import com.fs.live.vo.LiveAfterSalesQueryVO;
+import com.fs.live.vo.LiveOrderItemVo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
@@ -50,11 +50,9 @@ public class LiveAfterSalesController extends AppBaseController {
     private ILiveOrderService orderService;
     @Login
     @ApiOperation("获取订单项列表")
-    @GetMapping("/getStoreOrderItems")
-    public R getStoreOrderItems(@RequestParam("orderId") Long orderId, HttpServletRequest request){
-        log.info("获取订单项列表,订单号:{}", orderId);
-
-        List<LiveOrderItemListUVO> list=itemService.selectLiveOrderItemListUVOByOrderId(orderId);
+    @GetMapping({"/getStoreOrderItems", "/getMyStoreOrderItemByOrderId"})
+    public R getMyStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
+        List<LiveOrderItem> list=itemService.selectCheckedByOrderId(orderId);
         LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(orderId));
         order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
         order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
@@ -66,52 +64,52 @@ public class LiveAfterSalesController extends AppBaseController {
     @PostMapping("/applyAfterSales")
     @ApiOperation(value = "申请售后", notes = "申请售后")
     @RepeatSubmit
-    public R applyAfterSales(@RequestBody LiveAfterSalesApplyParam param) {
-        log.info("申请售后,用户ID:{},参数:{}", getUserId(), param);
-
-        return storeAfterSalesService.applyAfterSales(getUserId(), param);
+    public R applyAfterSales(@RequestBody LiveAfterSalesParam param) {
+        return storeAfterSalesService.applyForAfterSales(getUserId(), param);
     }
     @Login
     @PostMapping("/revoke")
     @ApiOperation(value = "撤销售后", notes = "撤销售后")
     @RepeatSubmit
     public R revoke(@RequestBody LiveAfterSalesRevokeParam param) throws ParseException {
-        log.info("撤销售后,用户ID:{},参数:{}", getUserId(), param);
-
         return storeAfterSalesService.revoke(getUserId(), param);
     }
     @Login
     @PostMapping("/addDelivery")
     @ApiOperation(value = "提交物流信息", notes = "提交物流信息")
     public R addDelivery(@Validated @RequestBody LiveAfterSalesDeliveryParam param) {
-        log.info("提交物流信息,参数:{}", param);
-
         param.setUserId(Long.parseLong(getUserId()));
         return storeAfterSalesService.addDelivery(param);
     }
 
 
+
     @Login
+//    @GetMapping("/getAfterSalesList")
     @GetMapping("/getStoreAfterSalesList")
     @ApiOperation(value = "获取售后列表", notes = "获取售后列表")
-    public R getStoreAfterSalesList(LiveAfterSalesListUParam param) {
-        log.info("获取售后列表,用户ID:{},参数:{}", getUserId(), param);
-
+    public R getAfterSalesList(LiveAfterSalesQueryParam param) {
+        PageHelper.startPage(param.getPage(), param.getPageSize());
         param.setUserId(Long.parseLong(getUserId()));
-        PageHelper.startPage(Integer.parseInt(ServletUtils.getParameter("pageNum")) ,Integer.parseInt(ServletUtils.getParameter("pageSize")) );        List<LiveAfterSalesListUVO> list=storeAfterSalesService.selectLiveAfterSalesListUVO(param);
-        PageInfo<LiveAfterSalesListUVO> listPageInfo=new PageInfo<>(list);
+        List<LiveAfterSalesQueryVO> list=storeAfterSalesService.selectLiveAfterSalesListQuery(param);
+        PageInfo<LiveAfterSalesQueryVO> listPageInfo=new PageInfo<>(list);
         return R.ok().put("data",listPageInfo);
     }
+    @Login
+    @GetMapping("/getAfterSalesDetails")
+    @ApiOperation(value = "获取售后详情", notes = "获取售后详情")
+    public R getAfterSalesDetails(@RequestParam("salesId") Long id) {
+        LiveAfterSales sales=storeAfterSalesService.selectLiveAfterSalesById(id);
+        List<LiveAfterSalesItem>  items=salesItemService.selectLiveAfterSalesItemByAfterId(id);
+        return R.ok().put("sales",sales).put("items", items);
+    }
+
     @Login
     @GetMapping("/getStoreAfterSalesById")
     @ApiOperation(value = "获取售后详情", notes = "获取售后详情")
     public R getStoreAfterSalesById(@RequestParam("id") Long id) {
-        log.info("获取售后详情,售后ID:{}", id);
-
         LiveAfterSales sales=storeAfterSalesService.selectLiveAfterSalesById(id);
-        LiveAfterSalesItem map=new LiveAfterSalesItem();
-        map.setAfterSalesId(id);
-        List<LiveAfterSalesItem>  items=salesItemService.selectLiveAfterSalesItemList(map);
+        List<LiveAfterSalesItem>  items=salesItemService.selectLiveAfterSalesItemByAfterId(id);
         LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(sales.getOrderId()));
         return R.ok().put("sales",sales).put("items", items).put("order",order);
     }

+ 735 - 205
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -1,11 +1,15 @@
 package com.fs.app.controller.live;
 
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
-import com.fs.app.param.FsStoreOrderExpressParam;
 import com.fs.app.utils.JwtUtils;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.RepeatSubmit;
@@ -13,29 +17,67 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.exception.CustomException;
+import com.fs.common.utils.IpUtil;
+import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.ip.IpUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.core.config.WxMaConfiguration;
+import com.fs.erp.service.IErpOrderService;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.enums.ShipperCodeEnum;
 import com.fs.his.service.IFsExpressService;
+import com.fs.his.utils.ConfigUtil;
+import com.fs.hisStore.domain.*;
+import com.fs.hisStore.dto.FsStoreOrderComputeDTO;
+import com.fs.hisStore.enums.OrderInfoEnum;
+import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
+import com.fs.hisStore.param.*;
+import com.fs.hisStore.service.IFsUserScrmService;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.service.HuiFuService;
 import com.fs.live.domain.LiveOrder;
+import com.fs.live.domain.LiveOrderPayment;
 import com.fs.live.dto.LiveOrderComputeDTO;
 import com.fs.live.enums.LiveOrderCancleReason;
+import com.fs.live.mapper.LiveOrderPaymentMapper;
 import com.fs.live.param.*;
+import com.fs.live.service.ILiveAfterSalesService;
+import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderService;
+import com.fs.live.vo.FsMyLiveOrderListQueryVO;
+import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.live.vo.LiveOrderListVo;
+import com.fs.pay.pay.dto.OrderQueryDTO;
+import com.fs.pay.service.IPayService;
+import com.fs.store.config.StoreConfig;
+import com.fs.system.service.ISysConfigService;
+import com.fs.wx.miniapp.config.WxMaProperties;
+import com.fs.ybPay.domain.OrderResult;
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 /**
  * 订单Controller
@@ -49,281 +91,769 @@ import java.util.Map;
 public class LiveOrderController extends AppBaseController
 {
     @Autowired
-    private ILiveOrderService liveOrderService;
+    private ILiveOrderService orderService;
 
+    @Autowired
+    private ILiveOrderItemService liveOrderItemService;
 
     @Autowired
-    private IFsExpressService expressService;
+    private WxMaProperties properties;
+
     @Autowired
-    private JwtUtils jwtUtils;
+    private WxPayService wxPayService;
 
+    @Autowired
+    private LiveOrderPaymentMapper liveOrderPaymentMapper;
 
-    @Login
-    @ApiOperation("物流查询多运单号")
-    @PostMapping("/getExpressMulti")
-    public R getExpressMulti( @Validated @RequestBody FsStoreOrderExpressParam param){
-        log.info("物流查询多运单号 请求参数: {}", JSON.toJSONString(param));
+    @Autowired
+    private ISysConfigService configService;
 
-        LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
-        if (ObjectUtil.isNull(order)) {
-            throw new CustomException("订单不存在");
-        }
-//        if (order.getStatus() < 2) {
-//            throw new CustomException("未发货订单不能查询");
-//        }
-        return liveOrderService.getExpressMulti(order);
-    }
+    @Autowired
+    private IFsUserScrmService userService;
 
-    @Login
-    @ApiOperation("物流查询")
-    @PostMapping("/getExpress")
-    public R getExpress( @Validated @RequestBody FsStoreOrderExpressParam param){
-        log.info("物流查询 参数: {}", JSON.toJSONString(param));
+    @Autowired
+    private ILiveAfterSalesService liveAfterSalesService;
+    @Autowired
+    IPayService ybPayService;
+    @Autowired
+    private HuiFuService huiFuService;
 
-        LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
-        if (ObjectUtil.isNull(order)) {
-            throw new CustomException("订单不存在");
-        }
-        if (order.getStatus() <2) {
-            throw new CustomException("未发货订单不能查询");
-        }
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
 
-        return liveOrderService.getExpress(order);
-    }
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtOrderService;
 
+    @Autowired
+    @Qualifier("k9OrderScrmServiceImpl")
+    private IErpOrderService k9OrderService;
 
-    /**
-     * 查询订单列表
-     */
-    @Login
-    @GetMapping("/list")
-    public R list(LiveOrder liveOrder)
-    {
-        log.info("查询订单列表 参数: {}", JSON.toJSONString(liveOrder));
+    @Autowired
+    private ConfigUtil configUtil;
 
-        PageHelper.startPage(Integer.parseInt(ServletUtils.getParameter("pageNum")) ,Integer.parseInt(ServletUtils.getParameter("pageSize")) );
-        try {
-            liveOrder.setUserId(getUserId());
-            List<LiveOrderListVo> list = liveOrderService.selectLiveOrderListVo(liveOrder);
-            PageInfo<LiveOrderListVo> result = new PageInfo<>(list);
-            return R.ok().put("data", result);
-        } catch (Exception e) {
-            log.error("查询失败!",e);
-            return R.error("操作异常");
-        }
 
-    }
+    @Autowired
+    private IFsExpressService expressService;
+    @Autowired
+    private JwtUtils jwtUtils;
 
-    /**
-     * 导出订单列表
-     */
-    @Log(title = "订单", businessType = BusinessType.EXPORT)
-    @GetMapping("/export")
-    public AjaxResult export(LiveOrder liveOrder)
-    {
-        log.info("订单导出 参数: {}", JSON.toJSONString(liveOrder));
 
-        List<LiveOrder> list = liveOrderService.selectLiveOrderList(liveOrder);
-        ExcelUtil<LiveOrder> util = new ExcelUtil<LiveOrder>(LiveOrder.class);
-        return util.exportExcel(list, "订单数据");
+    @Login
+    @ApiOperation("获取我的订单列表")
+    @GetMapping("/getMyStoreOrderList")
+    public R getMyStoreOrderList(FsMyLiveOrderQueryParam param, HttpServletRequest request){
+        PageHelper.startPage(param.getPage(), param.getPageSize());
+        param.setUserId(Long.parseLong(getUserId()));
+        List<FsMyLiveOrderListQueryVO> list=orderService.selectFsMyLiveOrderListVO(param);
+        PageInfo<FsMyLiveOrderListQueryVO> listPageInfo=new PageInfo<>(list);
+        return R.ok().put("data",listPageInfo);
     }
 
-    /**
-     * 获取订单详细信息
-     */
     @Login
-    @GetMapping(value = "/info/{orderId}")
-    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
-    {
-        log.info("获取订单详细信息 参数: {}",orderId);
-
-        return AjaxResult.success(liveOrderService.selectLiveOrderByOrderId(orderId));
+    @ApiOperation("获取销售公司订单列表")
+    @GetMapping("/getCompanyStoreOrderList")
+    public R getCompanyStoreOrderList(FsMyLiveOrderQueryParam param, HttpServletRequest request){
+        PageHelper.startPage(param.getPage(), param.getPageSize());
+        List<FsMyLiveOrderListQueryVO> list=orderService.selectFsCompanyLiveOrderListVO(param);
+        PageInfo<FsMyLiveOrderListQueryVO> listPageInfo=new PageInfo<>(list);
+        return R.ok().put("data",listPageInfo);
     }
 
-    @ApiOperation("确认订单")
-    @PostMapping("/confirm")
-    public R confirm(@Validated @RequestBody LiveOrderConfirmParam param, HttpServletRequest request){
-        log.info("确认订单 参数: {}", JSON.toJSONString(param));
-
-        param.setUserId(Long.parseLong(getUserId()));
-        return liveOrderService.confirmOrder(param);
+    @Login
+    @ApiOperation("获取我的订单详情")
+    @GetMapping("/getMyStoreOrderById")
+    public R getMyStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
+        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(orderId));
+        order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
+        order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
+        List<LiveOrderItemListUVO> list = liveOrderItemService.selectLiveOrderItemListUVOByOrderId(orderId);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(order.getCreateTime());
+        String json=configService.selectConfigByKey("his.store");
+        StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
+        calendar.add(Calendar.MINUTE,config.getUnPayTime());
+        SimpleDateFormat format = new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String payLimitTime = format.format(calendar.getTime() );
+        //处理是否可以申请售后
+        Integer isAfterSales=0;
+        if(order.getStatus().equals(OrderInfoEnum.STATUS_3.getValue())) {
+            //已完成订单
+            isAfterSales=1;
+            if (order.getFinishTime() != null) {
+                if (config.getStoreAfterSalesDay() != null && config.getStoreAfterSalesDay() > 0) {
+                    //判断完成时间是否超过指定时间
+                    Calendar calendarAfterSales = new GregorianCalendar();
+                    calendarAfterSales.setTime(order.getFinishTime());
+                    calendarAfterSales.add(calendarAfterSales.DATE, config.getStoreAfterSalesDay()); //把日期往后增加一天,整数  往后推,负数往前移动
+                    if (calendarAfterSales.getTime().getTime() < new Date().getTime()) {
+                        isAfterSales = 0;
+                    }
+                }
+            }
+        }
+        else if(order.getStatus()==1||order.getStatus()==2){
+            isAfterSales=1;
+        }
+        return R.ok().put("isAfterSales",isAfterSales).put("order",order).put("items",list).put("payLimitTime",payLimitTime);
     }
 
-    @PostMapping("/buy")
-    @ApiOperation("购物车购买")
     @Login
-    @RepeatSubmit
-    public R buy(@RequestBody LiveOrder liveOrder)
-    {
-        log.info("购物车购买 参数: {}", JSON.toJSONString(liveOrder));
-
-        liveOrder.setUserId(getUserId());
-        return liveOrderService.buy(liveOrder);
+    @ApiOperation("获取订单")
+    @GetMapping("/getStoreOrderById")
+    public R getStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
+        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(orderId));
+
+        order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
+        order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
+
+        String json=configService.selectConfigByKey("his.store");
+        StoreConfig config=JSONUtil.toBean(json,StoreConfig.class);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(order.getCreateTime());
+        calendar.add(Calendar.MINUTE,config.getUnPayTime());
+        SimpleDateFormat format = new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String payLimitTime = format.format(calendar.getTime() );
+        return R.ok().put("order",order).put("payLimitTime",payLimitTime);
     }
 
-    /**
-     * 新增订单
-     */
-    @Login
-    @Log(title = "订单", businessType = BusinessType.INSERT)
-    @PostMapping("/create")
-    @RepeatSubmit
-    public R add(@RequestBody LiveOrder liveOrder)
-    {
-        log.info("新增订单: {}", JSON.toJSONString(liveOrder));
 
-        liveOrder.setUserId(getUserId());
-        return liveOrderService.createLiveOrder(liveOrder);
+    @Login
+    @ApiOperation("确认订单")
+    @PostMapping("/confirm")
+    public R confirm(@Validated @RequestBody LiveOrderConfirmParam param, HttpServletRequest request){
+        param.setUserId(Long.valueOf(getUserId()));
+        return orderService.confirmOrder(param);
     }
-
     @Login
     @ApiOperation("计算订单金额")
     @PostMapping("/computed")
-    public R computed(@Validated @RequestBody LiveOrderComputedParam param){
-        log.info("计算订单金额 {}",JSON.toJSONString(param));
-
-        LiveOrderComputeDTO dto=liveOrderService.computedOrder(Long.parseLong(getUserId()),param);
+    public R computed(@Validated @RequestBody LiveOrderComputedParam param, HttpServletRequest request){
+        LiveOrderComputeDTO dto=orderService.computedOrder(Long.parseLong(getUserId()),param);
         return R.ok().put("data",dto);
     }
 
-    /**
-     * 修改订单
-     */
     @Login
-    @Log(title = "订单", businessType = BusinessType.UPDATE)
-    @PutMapping("/update")
-    @RepeatSubmit
-    public R edit(@RequestBody LiveOrder liveOrder)
-    {
-        return R.ok().put("orderId",liveOrder.getOrderId());
+    @ApiOperation("创建订单")
+    @PostMapping("/create")
+    public R create(@Validated @RequestBody LiveOrder param, HttpServletRequest request){
+        String userId= getUserId();
+        log.info("开始创建订单,登录用户id:{}", userId);
+        return orderService.createLiveOrder(param);
     }
 
-
-    /**
-     * 查看物流状态
-     * */
-    @GetMapping(value = "/getExpress/{id}")
-    @Deprecated
-    public R getExpress(@PathVariable("id") Long id)
+    @Login
+    @ApiOperation("支付")
+    @PostMapping("/pay")
+    @Transactional
+    //@Synchronized
+    public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
     {
-        log.info("查看物流状态 {}",id);
+        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+        if(order==null){
+            return R.error("订单不存在");
+        }
+        if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
+            return R.error("订单状态不正确");
+        }
+        String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
+        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
+            return R.error("正在支付中...");
+        }
 
-        LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(id));
-        ExpressInfoDTO expressInfoDTO=null;
-        if(StringUtils.isNotEmpty(order.getDeliverySn())){
+        FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
+        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
+            //已改价处理
+            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
+                //改过价不做处理
 
-            String lastFourNumber = "";
-            if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue())) {
-                lastFourNumber = order.getUserPhone();
-                if (lastFourNumber.length() == 11) {
-                    lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+            }
+            else{
+                String config=configService.selectConfigByKey("his.store");
+                StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
+                if(param.getPayType().equals(1)){
+                    order.setPayType("1");
+                    order.setPayMoney(order.getPayPrice());
+                    order.setPayDelivery(BigDecimal.ZERO);
+                }
+                else if(param.getPayType().equals(2)){
+                    order.setPayType("2");
+                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+                    order.setPayMoney(payMoney);
+                }
+                else if(param.getPayType().equals(3)){
+                    //货到付款
+                    order.setPayType("3");
+                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
+                    BigDecimal payMoney = BigDecimal.ZERO;
+                    if (amount != null){
+                        payMoney=amount;
+                    }
+                    order.setPayMoney(payMoney);
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
+//                    order.setPayMoney(BigDecimal.ZERO);
+                }
+                orderService.updateLiveOrder(order);
+            }
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+//            order.setOrderCode(orderCode);
+//            if(order.getPayType().equals("1")||order.getPayType().equals("2")){
+            if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
+                String json = configService.selectConfigByKey("his.pay");
+                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+                LiveOrderPayment storePayment=new LiveOrderPayment();
+                storePayment.setCompanyId(order.getCompanyId());
+                storePayment.setCompanyUserId(order.getCompanyUserId());
+                storePayment.setPayMode(fsPayConfig.getType());
+                storePayment.setStatus(0);
+                storePayment.setPayCode(payCode);
+                storePayment.setPayMoney(order.getPayMoney());
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(2);
+                storePayment.setRemark("直播订单支付");
+                storePayment.setOpenId(user.getRealName());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessId(String.valueOf(order.getOrderId()));
+                liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
+
+                if (fsPayConfig.getType().equals("hf")){
+                    HuiFuCreateOrder o = new HuiFuCreateOrder();
+                    o.setTradeType("T_MINIAPP");
+                    o.setOpenid(user.getMaOpenId());
+                    o.setReqSeqId("live-"+storePayment.getPayCode());
+                    o.setTransAmt(storePayment.getPayMoney().toString());
+                    o.setGoodsDesc("直播订单支付");
+                    if (param != null && StringUtils.isNotBlank(param.getAppId())) {
+                        o.setAppId(param.getAppId());
+                    }
+                    HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                    if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+                        LiveOrderPayment mt=new LiveOrderPayment();
+                        mt.setPaymentId(storePayment.getPaymentId());
+                        mt.setTradeNo(result.getHf_seq_id());
+                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                        redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
+                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                        String s = (String) resultMap.get("package");
+                        resultMap.put("packageValue",s);
+                        return R.ok().put("payType",param.getPayType()).put("result",resultMap);
+                    }
+                    else{
+                        return R.error(result.getResp_desc());
+                    }
+                }else  if (fsPayConfig.getType().equals("wx")){
+                    WxPayConfig payConfig = new WxPayConfig();
+                    payConfig.setAppId(fsPayConfig.getAppId());
+                    payConfig.setMchId(fsPayConfig.getWxMchId());
+                    payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                    payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                    payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                    payConfig.setKeyPath(fsPayConfig.getKeyPath());
+                    payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                    wxPayService.setConfig(payConfig);
+                    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                    orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                    orderRequest.setBody("直播订单支付");
+                    orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
+                    orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                    //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+                    orderRequest.setTradeType("JSAPI");
+                    orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                    //调用统一下单接口,获取"预支付交易会话标识"
+                    try {
+                        WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
+                    } catch (WxPayException e) {
+                        e.printStackTrace();
+                        throw new CustomException("支付失败" + e.getMessage());
+                    }
                 }
             }
-            expressInfoDTO=expressService.getExpressInfo(order.getOrderCode(),order.getDeliverySn(),order.getDeliverySn(),lastFourNumber);
+//            else if(order.getPayType().equals("3")){
+            else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
+                //货到付款
+                orderService.payConfirm(2,order.getOrderId(),null,null,null,null);
+                return R.ok().put("payType",param.getPayType());
+            }
+            return R.error();
+        }
+        else{
+            return R.error("用户OPENID不存在");
         }
-        return R.ok().put("data",expressInfoDTO);
+
     }
 
-    /**
-     * 支付订单
-     * */
-    @PostMapping(value = "/pay")
-    public void pay(LiveOrder liveOrder)
-    {
-        log.info("支付订单 参数: {}",liveOrder);
 
-       liveOrderService.handlePay(liveOrder);
-    }
+
+
 
     @Login
-    @ApiOperation("支付宝支付")
-    @PostMapping("/aliPayment")
-    @RepeatSubmit
-    public R aliPayment(@Validated @RequestBody FsUserLiveOrderPayUParam param)
-    {
-        param.setUserId(Long.parseLong(getUserId()));
-        return R.ok();
+    @ApiOperation("修改支付类型")
+    @PostMapping("/editPayType")
+    @Transactional
+    public R editPayType(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
+        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+        if(order==null){
+            return R.error("订单不存在");
+        }
+        if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
+            return R.error("订单状态不正确");
+        }
+        String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
+        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
+            return R.error("正在支付中...");
+        }
+        List<LiveOrderPayment> payments = liveOrderPaymentMapper.selectLiveOrderPaymentByOrderId(order.getOrderId());
+        if(payments.size()>0){
+            for(LiveOrderPayment payment : payments){
+                OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
+                orderQueryDTO.setLowOrderId("live-"+payment.getPayCode());
+                OrderResult orderResult = ybPayService.getOrder(orderQueryDTO);
+                if(orderResult.getStatus()!= null&&orderResult.getStatus().equals("100")){
+                    if(orderResult.getState()!=null&&orderResult.getState().equals("0")){
+                        return R.error("订单已支付");
+                    }
+
+                }
+            }
+        }
+        FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
+        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
+            //已改价处理
+            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
+                //改过价不做处理
+            }
+            else{
+                String config=configService.selectConfigByKey("his.store");
+                StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
+                if(param.getPayType().equals(1)){
+                    order.setPayType("1");
+                    order.setPayMoney(order.getPayPrice());
+                    order.setPayDelivery(BigDecimal.ZERO);
+                }
+                else if(param.getPayType().equals(2)){
+
+                    order.setPayType("2");
+                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+                    order.setPayMoney(payMoney);
+                }
+                else if(param.getPayType().equals(3)){
+                    //货到付款
+                    order.setPayType("3");
+//                    order.setPayDelivery(order.getPayPrice() );
+//                    order.setPayMoney(BigDecimal.ZERO);
+                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
+                    BigDecimal payMoney = BigDecimal.ZERO;
+                    if (amount != null){
+                        payMoney=amount;
+                    }
+                    order.setPayMoney(payMoney);
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
+                }
+                orderService.updateLiveOrder(order);
+            }
+            return R.ok().put("order",order);
+        }
+        else{
+            return R.error("用户OPENID不存在");
+        }
+
     }
 
+
+//    @Login
+//    @ApiOperation("支付尾款")
+//    @PostMapping("/payRemain")
+//    @Transactional
+//    public R payRemain(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
+//        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+//        if(order==null){
+//            return R.error("订单不存在");
+//        }
+//        if(order.getStatus()!= OrderInfoEnum.STATUS_2.getValue()){
+//            return R.error("待收货订单可申请支付尾款");
+//        }
+//        if(order.getPayType().equals(1)){
+//            return R.error("此订单已支付");
+//        }
+//        //只有顺风才可以付尾
+//        if(!order.getDeliverySn().trim().equals("SF")){
+//            return R.error("只有顺丰物流支持尾款支付");
+//        }
+//
+//        if(!order.getIsPayRemain().equals(0)){
+//            return R.error("此订单已支付");
+//        }
+//        FsUserScrm user=userService.selectFsUserById(order.getUserId());
+//        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
+//            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+//            String json = configService.selectConfigByKey("his.pay");
+//            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+//            LiveOrderPayment storePayment=new LiveOrderPayment();
+//            storePayment.setCompanyId(order.getCompanyId());
+//            storePayment.setCompanyUserId(order.getCompanyUserId());
+//            storePayment.setStatus(0);
+//            storePayment.setPayMode(fsPayConfig.getType());
+//            storePayment.setPayCode(payCode);
+//            storePayment.setPayMoney(order.getPayDelivery());
+//            storePayment.setCreateTime(new Date());
+//            storePayment.setPayTypeCode("weixin");
+//            storePayment.setBusinessType(2);
+//            storePayment.setRemark("商城订单尾款支付");
+//            storePayment.setOpenId(user.getRealName());
+//            storePayment.setUserId(user.getUserId());
+//            storePayment.setBusinessOrderId(order.getId().toString());
+//            storePayment.setOrderId(order.getId());
+//            storePayment.setIsPayRemain(1);
+//            liveOrderPaymentMapper.insertFsStorePayment(storePayment);
+//
+//            if (fsPayConfig.getType().equals("hf")){
+//                HuiFuCreateOrder o = new HuiFuCreateOrder();
+//                o.setTradeType("T_MINIAPP");
+//                o.setOpenid(user.getMaOpenId());
+//                o.setReqSeqId("store_remain-"+storePayment.getPayCode());
+//                o.setTransAmt(storePayment.getPayMoney().toString());
+//                o.setGoodsDesc("商城订单尾款支付");
+//                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+//                //创建订单
+//                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+//
+//                    LiveOrderPayment mt=new LiveOrderPayment();
+//                    mt.setPaymentId(storePayment.getPaymentId());
+//                    mt.setTradeNo(result.getHf_seq_id());
+//                    liveOrderPaymentMapper.updateFsStorePayment(mt);
+//                    redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
+//                    Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+//                    String s = (String) resultMap.get("package");
+//                    resultMap.put("packageValue",s);
+//                    return R.ok().put("payType",param.getPayType()).put("result",resultMap);
+//                }
+//                else{
+//                    return R.error(result.getResp_desc());
+//                }
+//            }else if(fsPayConfig.getType().equals("wx")) {
+//                WxPayConfig payConfig = new WxPayConfig();
+//                payConfig.setAppId(fsPayConfig.getAppId());
+//                payConfig.setMchId(fsPayConfig.getWxMchId());
+//                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+//                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+//                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+//                payConfig.setKeyPath(null);
+//                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+//                wxPayService.setConfig(payConfig);
+//                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+//                orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+//                orderRequest.setBody("商城订单支付");
+//                orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
+//                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+//                //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+//                orderRequest.setTradeType("JSAPI");
+//                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+//                //调用统一下单接口,获取"预支付交易会话标识"
+//                try {
+//                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+//                    return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
+//                } catch (WxPayException e) {
+//                    e.printStackTrace();
+//                    throw new CustomException("支付失败" + e.getMessage());
+//                }
+//            }
+//        }
+//        else{
+//            return R.error("用户OPENID不存在");
+//        }
+//        return R.error("无支付类型");
+//    }
+
+
     @Login
-    @ApiOperation("微信支付")
-    @PostMapping("/weChatPayment")
-    @RepeatSubmit
-    public R payment(@Validated @RequestBody FsUserLiveOrderPayUParam param)
-    {
-        param.setUserId(Long.parseLong(getUserId()));
-        return liveOrderService.wxPayment(param);
-    }
+    @ApiOperation("亲友支付")
+    @PostMapping("/otherPayment")
+    @Transactional
+    public R otherPayment(@Validated @RequestBody FsStoreOrderOtherPayParam param, HttpServletRequest request){
+        final WxMaService wxService = WxMaConfiguration.getMaService(properties.getConfigs().get(0).getAppid());
+        try {
+            String ip = IpUtil.getRequestIp();
+            WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+            FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
+            if(user==null){
+                //创建
+                user=new FsUserScrm();
+                user.setUsername("");
+                user.setNickname("微信用户");
+                user.setStatus(1);
+                user.setMaOpenId(session.getOpenid());
+                user.setUnionId(session.getUnionid());
+                user.setIsWeixinAuth(0);
+                user.setLastIp(ip);
+                user.setCreateTime(new Date());
+                userService.insertFsUser(user);
+            }
+            LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+            if(order==null){
+                return R.error("订单不存在");
+            }
+            if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
+                return R.error("此订单不能支付");
+            }
+            if(order.getPayMoney().compareTo(new BigDecimal(0))<1){
+                return R.error("此订单没有可支付的金额");
+            }
 
-    @Log(title = "退款", businessType = BusinessType.UPDATE)
-    @PostMapping("/refundOrderMoney")
-    public synchronized R refundOrderMoney(@Validated @RequestBody LiveOrderRefundParam param, HttpServletRequest request) {
-        log.info("退款 {}",JSON.toJSONString(param));
+            String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
+            if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
+                return R.error("正在支付中...");
+            }
 
-        return liveOrderService.refundOrderMoney(param.getOrderId());
+            String json = configService.selectConfigByKey("his.pay");
+            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            //易宝支付
+            LiveOrderPayment storePayment=new LiveOrderPayment();
+            storePayment.setCompanyId(order.getCompanyId());
+            storePayment.setCompanyUserId(order.getCompanyUserId());
+            storePayment.setStatus(0);
+            storePayment.setPayCode(payCode);
+            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayMoney(order.getPayMoney());
+            storePayment.setCreateTime(new Date());
+            storePayment.setPayTypeCode("weixin");
+            storePayment.setBusinessType(2);
+            storePayment.setRemark("商城订单支付");
+            storePayment.setOpenId(session.getOpenid());
+            storePayment.setUserId(user.getUserId());
+            storePayment.setBusinessId(order.getOrderId().toString());
+            liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
+
+            if (fsPayConfig.getType().equals("hf")){
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(user.getMaOpenId());
+                o.setReqSeqId("store-"+storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("商城订单支付");
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+
+                    LiveOrderPayment mt=new LiveOrderPayment();
+                    mt.setPaymentId(storePayment.getPaymentId());
+                    mt.setTradeNo(result.getHf_seq_id());
+                    liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                    redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
+                    Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                    String s = (String) resultMap.get("package");
+                    resultMap.put("packageValue",s);
+                    return R.ok().put("result",resultMap);
+                }
+                else{
+                    return R.error(result.getResp_desc());
+                }
+            }else  if (fsPayConfig.getType().equals("wx")){
+                //创建微信订单
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(fsPayConfig.getAppId());
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setKeyPath(null);
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                wxPayService.setConfig(payConfig);
+                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                orderRequest.setBody("商城订单支付");
+                orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
+                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+                orderRequest.setTradeType("JSAPI");
+                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                //调用统一下单接口,获取"预支付交易会话标识"
+                try {
+                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                    return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
+                } catch (WxPayException e) {
+                    e.printStackTrace();
+                    throw new CustomException("支付失败" + e.getMessage());
+                }
+            }
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
+        }
+        return R.error("无支付类型");
     }
 
-    /**
-     * 订单确认
-     * */
     @Login
-    @GetMapping(value = "/updateConfirm/{orderId}/{type}")
-    @RepeatSubmit
-    public R cancelConfirm(@PathVariable String orderId,@PathVariable String type)
-    {
-        log.info("订单确认 参数 orderId: {} type: {}", orderId, type);
+    @ApiOperation("亲友支付")
+    @PostMapping("/otherPaymentRemain")
+    @Transactional
+    public R otherPaymentRemain(@Validated @RequestBody FsStoreOrderOtherPayParam param, HttpServletRequest request){
+        final WxMaService wxService = WxMaConfiguration.getMaService(properties.getConfigs().get(0).getAppid());
+        try {
+            String ip = IpUtil.getRequestIp();
+            WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+            FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
+            if(user==null){
+                //创建
+                user=new FsUserScrm();
+                user.setUsername("");
+                user.setNickname("微信用户");
+                user.setStatus(1);
+                user.setMaOpenId(session.getOpenid());
+                user.setUnionId(session.getUnionid());
+                user.setIsWeixinAuth(0);
+                user.setLastIp(ip);
+                user.setCreateTime(new Date());
+                userService.insertFsUser(user);
+            }
+            LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+            if(order==null){
+                return R.error("订单不存在");
+            }
+            if(order.getStatus()!= OrderInfoEnum.STATUS_2.getValue()){
+                return R.error("待收货订单可申请支付尾款");
+            }
+            if(order.getPayType().equals(1)){
+                return R.error("此订单已支付");
+            }
+            //只有顺风才可以付尾
+            if(!order.getDeliverySn().trim().equals("SF")){
+                return R.error("只有顺丰物流支持尾款支付");
+            }
 
-        LiveOrder byId = liveOrderService.getById(orderId);
-        List<Map<String, String>> allCodeDescMap = null;
-        if (type.equals("0"))
-            allCodeDescMap = LiveOrderCancleReason.getAllCodeDescMap();
-        return R.ok().put("reason",allCodeDescMap).put("data",byId);
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            String json = configService.selectConfigByKey("his.pay");
+            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            LiveOrderPayment storePayment=new LiveOrderPayment();
+            storePayment.setCompanyId(order.getCompanyId());
+            storePayment.setCompanyUserId(order.getCompanyUserId());
+            storePayment.setStatus(0);
+            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayCode(payCode);
+            storePayment.setPayMoney(order.getPayDelivery());
+            storePayment.setCreateTime(new Date());
+            storePayment.setPayTypeCode("weixin");
+            storePayment.setBusinessType(2);
+            storePayment.setRemark("直播订单尾款支付");
+            storePayment.setOpenId(user.getRealName());
+            storePayment.setUserId(user.getUserId());
+            storePayment.setBusinessId(order.getOrderId().toString());
+            liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
+
+            if (fsPayConfig.getType().equals("hf")){
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(user.getMaOpenId());
+                o.setReqSeqId("live-"+storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("直播订单支付");
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+
+                    LiveOrderPayment mt=new LiveOrderPayment();
+                    mt.setPaymentId(storePayment.getPaymentId());
+                    mt.setTradeNo(result.getHf_seq_id());
+                    liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                    redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
+                    Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                    String s = (String) resultMap.get("package");
+                    resultMap.put("packageValue",s);
+                    return R.ok().put("result",resultMap);
+                }
+                else{
+                    return R.error(result.getResp_desc());
+                }
+            }else  if (fsPayConfig.getType().equals("wx")){
+                //创建微信订单
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(fsPayConfig.getAppId());
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setKeyPath(null);
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                wxPayService.setConfig(payConfig);
+                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                orderRequest.setBody("直播订单支付");
+                orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
+                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+                orderRequest.setTradeType("JSAPI");
+                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                //调用统一下单接口,获取"预支付交易会话标识"
+                try {
+                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                    return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
+                } catch (WxPayException e) {
+                    e.printStackTrace();
+                    throw new CustomException("支付失败" + e.getMessage());
+                }
+            }
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
+        }
+        return R.error("无支付类型");
     }
 
-    /**
-     *正在购买的用户
-     * */
-    @GetMapping(value = "/liveOrderUser/{liveId}")
-    public R liveOrderUser(@PathVariable  String liveId)
-    {
-        log.info("正在购买的用户 参数: {}",liveId);
-        return liveOrderService.liveOrderUser(liveId);
-    }
 
     @Login
     @ApiOperation("取消订单")
     @PostMapping("/cancelOrder")
-    public R cancelOrder(@Validated @RequestBody LiveOrderCancelParam param, HttpServletRequest request){
-        log.info("取消订单 参数: {}",JSON.toJSONString(param));
-
-        LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+//    @Log(title = "取消订单", businessType = BusinessType.UPDATE)
+    public R cancelOrder( @Validated @RequestBody FsStoreOrderCancelParam param, HttpServletRequest request){
+        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
         if (ObjectUtil.isNull(order)) {
             throw new CustomException("订单不存在");
         }
-        return liveOrderService.cancelOrder(order);
+        if (order.getStatus() !=0) {
+            throw new CustomException("非法操作");
+        }
+        orderService.cancelOrder(order);
 
+        return R.ok("操作成功");
+    }
+    @Login
+    @ApiOperation("物流查询")
+    @PostMapping("/getExpress")
+    public R getExpress(@Validated @RequestBody FsStoreOrderExpressParam param, HttpServletRequest request){
+        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+        if (ObjectUtil.isNull(order)) {
+            throw new CustomException("订单不存在");
+        }
+        if (order.getStatus() <2) {
+            throw new CustomException("未发货订单不能查询");
+        }
+        return orderService.getExpress(order);
     }
 
+
+
     @Login
     @ApiOperation("完成订单")
     @PostMapping("/finishOrder")
-    public R finishOrder(@Validated @RequestBody LiveOrderCancelParam param, HttpServletRequest request){
-        log.info("完成订单 参数: {}",JSON.toJSONString(param));
-
-        return liveOrderService.finishOrder(param.getOrderId());
+    public R finishOrder( @Validated @RequestBody FsStoreOrderFinishParam param, HttpServletRequest request){
+        return orderService.finishOrder(param.getOrderId());
     }
-    @ApiOperation("完成订单")
-    @GetMapping("/test")
-    public R tes(){
-        List<Long> ids = liveOrderService.selectOrderIdByNoErp();
-        for (Long id : ids) {
-            try{
-                liveOrderService.createOmsOrder(id);
-            }catch (Exception e){
-                e.printStackTrace();
-            }
-        }
-        return null;
+
+
+    @Login
+    @ApiOperation("获取订单总数")
+    @GetMapping("/getOrderCount")
+    public R getOrderCount( HttpServletRequest request){
+        Integer count0=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),0);
+        Integer count1=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),1);
+        Integer count2=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),2);
+        Integer afterSalesCount=liveAfterSalesService.selectLiveAfterSalesCount(Long.parseLong(getUserId()),0);
+        return R.ok().put("count0",count0).put("count1",count1).put("count2",count2).put("afterSalesCount",afterSalesCount);
     }
 
 

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.