|
|
@@ -2,51 +2,79 @@ package com.fs.hisStore.controller;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fs.common.annotation.DataScope;
|
|
|
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.domain.R;
|
|
|
+import com.fs.common.core.domain.entity.SysDept;
|
|
|
+import com.fs.framework.security.LoginUser;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.exception.base.BaseException;
|
|
|
+import com.fs.common.utils.CloudHostUtils;
|
|
|
import com.fs.common.utils.ParseUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
-import com.fs.crm.domain.CrmCustomer;
|
|
|
-import com.fs.crm.service.ICrmCustomerService;
|
|
|
-import com.fs.framework.security.LoginUser;
|
|
|
import com.fs.framework.service.TokenService;
|
|
|
+import com.fs.company.param.CompanyStoreOrderMoneyLogsListParam;
|
|
|
+import com.fs.company.service.ICompanyMoneyLogsService;
|
|
|
+import com.fs.company.vo.CompanyStoreOrderMoneyLogsVO;
|
|
|
+import com.fs.erp.domain.ErpDeliverys;
|
|
|
+import com.fs.erp.domain.ErpOrderQuery;
|
|
|
+import com.fs.erp.dto.ErpOrderQueryRequert;
|
|
|
+import com.fs.erp.dto.ErpOrderQueryResponse;
|
|
|
+import com.fs.erp.service.IErpOrderService;
|
|
|
+import com.fs.his.domain.FsDfAccount;
|
|
|
+import com.fs.his.domain.FsStoreOrderDf;
|
|
|
+import com.fs.his.domain.FsStoreOrderScrmComment;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
-import com.fs.his.service.IFsUserService;
|
|
|
-import com.fs.hisStore.config.StoreConfig;
|
|
|
-import com.fs.hisStore.domain.FsStoreOrderItemScrm;
|
|
|
-import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
-import com.fs.hisStore.domain.FsStoreOrderStatusScrm;
|
|
|
-import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
|
-import com.fs.hisStore.dto.ExpressInfoDTO;
|
|
|
+import com.fs.his.dto.ExpressInfoDTO;
|
|
|
+import com.fs.his.enums.FsStoreOrderLogEnum;
|
|
|
+import com.fs.his.service.*;
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
+import com.fs.his.vo.FsStoreOrderListAndStatisticsVo;
|
|
|
+import com.fs.hisStore.config.FsErpConfig;
|
|
|
+import com.fs.hisStore.domain.*;
|
|
|
+import com.fs.hisStore.dto.StoreOrderExpressExportDTO;
|
|
|
import com.fs.hisStore.dto.StoreOrderProductDTO;
|
|
|
-import com.fs.hisStore.enums.OrderLogEnum;
|
|
|
import com.fs.hisStore.enums.ShipperCodeEnum;
|
|
|
-import com.fs.hisStore.param.FsStoreOrderBindCustomerParam;
|
|
|
-import com.fs.hisStore.param.FsStoreOrderCreateUserParam;
|
|
|
-import com.fs.hisStore.param.FsStoreOrderFinishParam;
|
|
|
-import com.fs.hisStore.param.FsStoreOrderParam;
|
|
|
+import com.fs.hisStore.mapper.FsStoreVerifyCodeScrmMapper;
|
|
|
+import com.fs.hisStore.param.*;
|
|
|
import com.fs.hisStore.service.*;
|
|
|
import com.fs.hisStore.vo.*;
|
|
|
-import com.fs.system.service.ISysConfigService;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
+import com.fs.system.mapper.SysDeptMapper;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.BigInteger;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 订单Controller
|
|
|
@@ -54,13 +82,11 @@ import java.util.List;
|
|
|
* @author fs
|
|
|
* @date 2022-03-15
|
|
|
*/
|
|
|
-
|
|
|
@RestController
|
|
|
@RequestMapping("/store/store/storeOrder")
|
|
|
-public class FsStoreOrderScrmController extends BaseController
|
|
|
-{
|
|
|
+public class FsStoreOrderScrmController extends BaseController {
|
|
|
@Autowired
|
|
|
- private IFsExpressScrmService expressService;
|
|
|
+ private IFsExpressService expressService;
|
|
|
@Autowired
|
|
|
private IFsStoreOrderScrmService fsStoreOrderService;
|
|
|
@Autowired
|
|
|
@@ -71,28 +97,106 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
|
|
|
@Autowired
|
|
|
private IFsStoreOrderStatusScrmService orderStatusService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private IFsStorePaymentScrmService fsStorePaymentService;
|
|
|
+ IFsStorePaymentScrmService paymentService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private TokenService tokenService;
|
|
|
+ private ICompanyMoneyLogsService moneyLogsService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("erpOrderServiceImpl")
|
|
|
+ private IErpOrderService gyOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("wdtErpOrderServiceImpl")
|
|
|
+ private IErpOrderService wdtOrderService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("hzOMSErpOrderServiceImpl")
|
|
|
+ private IErpOrderService hzOMSErpOrderService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("dfOrderServiceImpl")
|
|
|
+ private IErpOrderService dfOrderService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("k9OrderScrmServiceImpl")
|
|
|
+ private IErpOrderService k9OrderService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("JSTErpOrderServiceImpl")
|
|
|
+ private IErpOrderService jSTOrderService;
|
|
|
@Autowired
|
|
|
- private ICrmCustomerService crmCustomerService;
|
|
|
+ private ConfigUtil configUtil;
|
|
|
@Autowired
|
|
|
private IFsStoreOrderAuditLogScrmService orderAuditLogService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysConfigMapper sysConfigMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsDfAccountService fsDfAccountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreOrderDfService fsStoreOrderDfService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreOrderLogsScrmService fsStoreOrderLogsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreScrmService iFsStoreScrmService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private ISysConfigService configService;
|
|
|
+ private IFsStoreProductScrmService fsStoreProductService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreAfterSalesScrmService fsStoreAfterSalesService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreAfterSalesItemScrmService fsStoreAfterSalesItemService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ private IErpOrderService getErpService(){
|
|
|
+ //判断是否开启erp
|
|
|
+ IErpOrderService erpOrderService = null;
|
|
|
+ FsErpConfig erpConfig = configUtil.getErpConfig();
|
|
|
+ Integer erpOpen = erpConfig.getErpOpen();
|
|
|
+ if (erpOpen != null && erpOpen == 1) {
|
|
|
+ //判断erp类型
|
|
|
+ Integer erpType = erpConfig.getErpType();
|
|
|
+ if (erpType != null) {
|
|
|
+ if (erpType == 1){
|
|
|
+ //管易
|
|
|
+ erpOrderService = gyOrderService;
|
|
|
+ } else if (erpType == 2){
|
|
|
+ //旺店通
|
|
|
+ erpOrderService = wdtOrderService;
|
|
|
+ } 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;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询订单列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:list')")
|
|
|
- @GetMapping("/list")
|
|
|
- @DataScope(deptAlias = "cu",userAlias = "cu")
|
|
|
- public TableDataInfo list(FsStoreOrderParam param)
|
|
|
- {
|
|
|
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ @PostMapping("/list")
|
|
|
+ public TableDataInfo list(@RequestBody FsStoreOrderParam param) {
|
|
|
startPage();
|
|
|
+ // 数据隔离:非超级管理员且非总公司部门时,按登录用户部门ID过滤(含下级部门)
|
|
|
+ this.applyDeptDataScope(param);
|
|
|
if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
}
|
|
|
@@ -102,14 +206,59 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
}
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ param.setNotHealth(1);
|
|
|
List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
|
|
|
- return getDataTable(list);
|
|
|
- }
|
|
|
+ //金牛需求 区别其他项目 status = 6 (金牛代服管家) ,其他项目请避免使用订单状态status = 6
|
|
|
+ TableDataInfo dataTable = getDataTable(list);
|
|
|
+ if (CloudHostUtils.hasCloudHostName("康年堂")){
|
|
|
+ dataTable.setMsg("knt");
|
|
|
+ }
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStoreOrderVO vo : list) {
|
|
|
+ if(vo.getPhone()!=null){
|
|
|
+ vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ }
|
|
|
+ if (CloudHostUtils.hasCloudHostName("康年堂")){
|
|
|
+ //查询顺丰代服账号
|
|
|
+ FsStoreOrderDf df = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(vo.getId());
|
|
|
+ if (df != null){
|
|
|
+ vo.setErpAccount(df.getLoginAccount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsStoreOrderListAndStatisticsVo vo = new FsStoreOrderListAndStatisticsVo();
|
|
|
+ BeanUtils.copyProperties(dataTable, vo);
|
|
|
+ if (dataTable.getTotal()>0){
|
|
|
+ Map<String, BigDecimal> statistics= fsStoreOrderService.selectFsStoreOrderStatistics(param);
|
|
|
+ if (statistics != null && statistics.size() >= 3){
|
|
|
+ vo.setPayPriceTotal(statistics.get("pay_price").toString());
|
|
|
+ vo.setPayMoneyTotal(statistics.get("pay_money").toString());
|
|
|
+ vo.setPayRemainTotal(statistics.get("pay_remain").toString());
|
|
|
+ }else {
|
|
|
+ vo.setPayPriceTotal("0");
|
|
|
+ vo.setPayMoneyTotal("0");
|
|
|
+ vo.setPayRemainTotal("0");
|
|
|
+ }
|
|
|
+ //商品数量合计
|
|
|
+ String productStatistics= fsStoreOrderService.selectFsStoreOrderProductStatistics(param);
|
|
|
+ if (StringUtils.isNotBlank(productStatistics)){
|
|
|
+ vo.setProductInfo(productStatistics);
|
|
|
+ } else {
|
|
|
+ vo.setProductInfo("");
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
|
|
|
- @GetMapping("/allList")
|
|
|
- public TableDataInfo allList(FsStoreOrderParam param)
|
|
|
- {
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:payRemainList')")
|
|
|
+ @GetMapping("/payRemainList")
|
|
|
+ public TableDataInfo payRemainList(FsStoreOrderParam param) {
|
|
|
startPage();
|
|
|
if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
@@ -120,18 +269,25 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
}
|
|
|
- List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderAllListVO(param);
|
|
|
+ List<FsStoreOrderVO> list = fsStoreOrderService.selectPayRemainListVO(param);
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStoreOrderVO vo : list) {
|
|
|
+ if(vo.getPhone()!=null){
|
|
|
+ vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:myList')")
|
|
|
- @GetMapping("/myList")
|
|
|
- public TableDataInfo myList(FsStoreOrderParam param)
|
|
|
- {
|
|
|
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
- startPage();
|
|
|
+ /**
|
|
|
+ * 导出付尾款订单列表
|
|
|
+ */
|
|
|
+ @Log(title = "付尾款订单", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/payRemainExport")
|
|
|
+ public AjaxResult payRemainExport(FsStoreOrderParam param) {
|
|
|
if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
}
|
|
|
@@ -141,39 +297,59 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
}
|
|
|
- List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
|
|
|
- return getDataTable(list);
|
|
|
- }
|
|
|
+ List<FsStorePayRemainOrderExportVO> list = fsStoreOrderService.selectFsStorePayRemainOrderListVOByExport(param);
|
|
|
+ //对手机号脱敏
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStorePayRemainOrderExportVO 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"));
|
|
|
+ }
|
|
|
+ if (vo.getUserAddress()!=null){
|
|
|
+ vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStorePayRemainOrderExportVO> util = new ExcelUtil<FsStorePayRemainOrderExportVO>(FsStorePayRemainOrderExportVO.class);
|
|
|
+ return util.exportExcel(list, "付尾款订单数据");
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出订单列表
|
|
|
+ */
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:export')")
|
|
|
@Log(title = "订单", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
- @DataScope(deptAlias = "cu",userAlias = "cu")
|
|
|
- public AjaxResult export (FsStoreOrderParam param)
|
|
|
- {
|
|
|
- if (param.getBeginTime().equals("") && param.getEndTime().equals("")){
|
|
|
+ public AjaxResult export(FsStoreOrderParam param) {
|
|
|
+ // 数据隔离:非超级管理员且非总公司部门时,按登录用户部门ID过滤(含下级部门)
|
|
|
+ this.applyDeptDataScope(param);
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
|
|
|
param.setBeginTime(null);
|
|
|
param.setEndTime(null);
|
|
|
}
|
|
|
if (fsStoreOrderService.isEntityNull(param)){
|
|
|
return AjaxResult.error("请筛选数据导出");
|
|
|
}
|
|
|
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
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.setNotHealth(1);
|
|
|
List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
|
|
|
//对手机号脱敏
|
|
|
- if(list!=null){
|
|
|
- for(FsStoreOrderExportVO vo:list){
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStoreOrderErpExportVO vo : list) {
|
|
|
if (vo.getPhone() != null) {
|
|
|
vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
}
|
|
|
@@ -183,10 +359,59 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
if (vo.getUserAddress()!=null){
|
|
|
vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
+ String filter = param.getFilter();
|
|
|
+ // 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
|
|
|
+ ArrayList<String> filterList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(filter)) {
|
|
|
+ // 按逗号拆分,同时去除可能的空格(如filter传"orderId, orderCode"时兼容)
|
|
|
+ String[] filterArr = filter.split("\\s*,\\s*");
|
|
|
+ filterList.addAll(Arrays.asList(filterArr));
|
|
|
+ }
|
|
|
+ // 动态导出:根据选中的字段生成Excel
|
|
|
+ ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
|
|
|
+ AjaxResult result;
|
|
|
+ // 如果有选中的字段,只导出这些字段
|
|
|
+ if (filter != null && !filter.isEmpty()) {
|
|
|
+ return util.exportExcelSelectedColumns(list, "订单数据", filterList);
|
|
|
+ } else {
|
|
|
+ // 导出所有字段
|
|
|
+ return util.exportExcel(list, "订单数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出订单列表(明文)
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:export:details')")
|
|
|
+ @Log(title = "订单", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/exportDetails")
|
|
|
+ public AjaxResult exportDetails(FsStoreOrderParam param) {
|
|
|
+ // 数据隔离:非超级管理员且非总公司部门时,按登录用户部门ID过滤(含下级部门)
|
|
|
+ this.applyDeptDataScope(param);
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ if (fsStoreOrderService.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.setNotHealth(1);
|
|
|
+ List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
|
|
|
String filter = param.getFilter();
|
|
|
// 1. 处理filter参数:将逗号分隔的字符串拆分为ArrayList<String>
|
|
|
ArrayList<String> filterList = new ArrayList<>();
|
|
|
@@ -207,35 +432,202 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:exportItems')")
|
|
|
+ @Log(title = "订单明细导出", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/exportItems")
|
|
|
+ public AjaxResult exportItems(FsStoreOrderParam param) {
|
|
|
+ // 数据隔离:非超级管理员且非总公司部门时,按登录用户部门ID过滤(含下级部门)
|
|
|
+ this.applyDeptDataScope(param);
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ if (fsStoreOrderService.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.getDeliveryImportTimeRange())){
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ param.setNotHealth(1);
|
|
|
+ List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
|
|
|
+ //对手机号脱敏
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStoreOrderItemExportVO vo : list) {
|
|
|
+ if (vo.getUserPhone() != null) {
|
|
|
+ String phone = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{1})", "$1****$2");
|
|
|
+ vo.setUserPhone(phone);
|
|
|
+ }
|
|
|
+ if (vo.getUserAddress()!=null){
|
|
|
+ vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(vo.getJsonInfo())) {
|
|
|
+ try {
|
|
|
+ StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
|
|
|
+ BeanUtil.copyProperties(orderProductDTO, vo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<FsStoreOrderItemExportVO>(FsStoreOrderItemExportVO.class);
|
|
|
+ return util.exportExcel(list, "订单明细数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单明细导出(明文)
|
|
|
+ * **/
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:exportItems:details')")
|
|
|
+ @Log(title = "订单明细导出", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/exportItemsDetails")
|
|
|
+ public AjaxResult exportItemsDetails(FsStoreOrderParam param) {
|
|
|
+ // 数据隔离:非超级管理员且非总公司部门时,按登录用户部门ID过滤(含下级部门)
|
|
|
+ this.applyDeptDataScope(param);
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ if (fsStoreOrderService.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.getDeliveryImportTimeRange())){
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ param.setNotHealth(1);
|
|
|
+ List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
|
|
|
+ //对手机号脱敏
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStoreOrderItemExportVO vo : list) {
|
|
|
+ if (!StringUtils.isEmpty(vo.getJsonInfo())) {
|
|
|
+ try {
|
|
|
+ StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
|
|
|
+ BeanUtil.copyProperties(orderProductDTO, vo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<FsStoreOrderItemExportVO>(FsStoreOrderItemExportVO.class);
|
|
|
+ return util.exportExcel(list, "订单明细数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/orderItemsNum")
|
|
|
+ public R orderItemsNum(FsStoreOrderParam param) {
|
|
|
+ // 数据隔离:非超级管理员且非总公司部门时,按登录用户部门ID过滤(含下级部门)
|
|
|
+ this.applyDeptDataScope(param);
|
|
|
+ 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);
|
|
|
+ Long orderItemsNum = orderItemService.countFsStoreOrderItemListExportVO(param);
|
|
|
+ return R.ok().put("orderItemsNum","订单明细数目:"+orderItemsNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IFsStoreOrderScrmCommentService fsStoreOrderScrmCommentService;
|
|
|
|
|
|
/**
|
|
|
* 获取订单详细信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public R getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
- FsStoreOrderScrm order=fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
+ public R getInfo(@PathVariable("id") Long id) {
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
+ //获取店铺信息
|
|
|
+ FsStoreScrm fsStoreScrm = new FsStoreScrm();
|
|
|
+ List<FsStoreScrm> allStoreList = iFsStoreScrmService.selectFsStoreList(fsStoreScrm);
|
|
|
+ if(Objects.isNull(allStoreList)){
|
|
|
+ throw new BaseException("店铺信息为空");
|
|
|
+ }
|
|
|
+ Map<Long, FsStoreScrm> storeScrmMap = allStoreList.stream().collect(Collectors.toMap(FsStoreScrm::getStoreId, StoreScrm -> StoreScrm));
|
|
|
+ FsStoreScrm storeScrm = storeScrmMap.get(order.getStoreId());
|
|
|
+ if(storeScrm==null){
|
|
|
+ throw new BaseException("该订单的店铺信息为空");
|
|
|
+ }
|
|
|
order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
|
|
|
order.setUserAddress(ParseUtils.parseAddress(order.getUserAddress()));
|
|
|
- FsUser user=userService.selectFsUserById(order.getUserId());
|
|
|
- user.setPhone(ParseUtils.parsePhone(user.getPhone()));
|
|
|
- FsStoreOrderItemScrm itemMap=new FsStoreOrderItemScrm();
|
|
|
+ //填充用户评论内容
|
|
|
+ FsStoreOrderScrmComment comment = fsStoreOrderScrmCommentService.getCommentByOrderId(order.getId());
|
|
|
+ if(null != comment){
|
|
|
+ order.setCommentContent(comment.getContent());
|
|
|
+ order.setCommentImageUrl(comment.getImageUrl());
|
|
|
+ order.setRating(comment.getRating());
|
|
|
+ order.setMerchantReply(comment.getMerchantReply());
|
|
|
+ order.setCommentTime(comment.getCreateTime());
|
|
|
+ order.setCommentId(comment.getCommentId());
|
|
|
+ }
|
|
|
+ FsUser user = userService.selectFsUserById(order.getUserId());
|
|
|
+ if (user != null) {
|
|
|
+ user.setPhone(ParseUtils.parsePhone(user.getPhone()));
|
|
|
+ }
|
|
|
+ FsStoreOrderItemScrm itemMap = new FsStoreOrderItemScrm();
|
|
|
itemMap.setOrderId(order.getId());
|
|
|
- List<FsStoreOrderItemScrm> items=orderItemService.selectFsStoreOrderItemList(itemMap);
|
|
|
- FsStoreOrderStatusScrm statusMap=new FsStoreOrderStatusScrm();
|
|
|
+ List<FsStoreOrderItemScrm> items = orderItemService.selectFsStoreOrderItemList(itemMap);
|
|
|
+ FsStoreOrderStatusScrm statusMap = new FsStoreOrderStatusScrm();
|
|
|
statusMap.setOrderId(order.getId());
|
|
|
- List<FsStoreOrderStatusScrm> logs=orderStatusService.selectFsStoreOrderStatusList(statusMap);
|
|
|
- List<FsStorePaymentScrm> payments=fsStorePaymentService.selectFsStorePaymentByOrderId(order.getId());
|
|
|
-
|
|
|
- CrmCustomer customer=null;
|
|
|
- if(order.getCustomerId()!=null&&order.getCustomerId()>0){
|
|
|
- customer=crmCustomerService.selectCrmCustomerById(order.getCustomerId());
|
|
|
+ List<FsStoreOrderStatusScrm> logs = orderStatusService.selectFsStoreOrderStatusList(statusMap);
|
|
|
+ List<FsStorePaymentScrm> payments=paymentService.selectFsStorePaymentByOrderId(order.getId());
|
|
|
+ List<CompanyStoreOrderMoneyLogsVO> tuiMoneyLogs=new ArrayList<>();
|
|
|
+ if(order.getCompanyId()!=null){
|
|
|
+ CompanyStoreOrderMoneyLogsListParam moneyLogsMap=new CompanyStoreOrderMoneyLogsListParam();
|
|
|
+ moneyLogsMap.setCompanyId(order.getCompanyId());
|
|
|
+ moneyLogsMap.setBusinessId(order.getId().toString());
|
|
|
+ tuiMoneyLogs=moneyLogsService.selectCompanyStoreOrderMoneyLogsList(moneyLogsMap);
|
|
|
}
|
|
|
|
|
|
+// //获取溯源码相关数据
|
|
|
+// List<FsStoreVerifyCodeScrm> verifyCodes = fsStoreVerifyCodeService.selectList(new LambdaQueryWrapper<FsStoreVerifyCodeScrm>().select(FsStoreVerifyCodeScrm::getVerifyCode,FsStoreVerifyCodeScrm::getProductId).eq(FsStoreVerifyCodeScrm::getOrderId, order.getId()));
|
|
|
+// if(!verifyCodes.isEmpty()){
|
|
|
+// Map<Long, String> verifyCodMap=new HashMap<>();
|
|
|
+// for (FsStoreVerifyCodeScrm v : verifyCodes){
|
|
|
+// if(verifyCodMap.containsKey(v.getProductId())){
|
|
|
+// verifyCodMap.put(v.getProductId(),verifyCodMap.get(v.getProductId())+","+v.getVerifyCode());
|
|
|
+// }else {
|
|
|
+// verifyCodMap.put(v.getProductId(),v.getVerifyCode());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// for (FsStoreOrderItemScrm item : items){
|
|
|
+// item.setVerifyCode("112344567789");
|
|
|
+// item.setBatchNumber("16699878855");
|
|
|
+// if(verifyCodMap.containsKey(item.getProductId())){
|
|
|
+// JSONObject jsonObject = JSONObject.parseObject(item.getJsonInfo());
|
|
|
+// jsonObject.put("verifyCods", verifyCodMap.get(item.getProductId()));
|
|
|
+// item.setJsonInfo(jsonObject.toJSONString());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
List<FsStoreOrderAuditLogVO> auditLogs = orderAuditLogService.selectStoreOrderAuditLogVOByOrderId(order.getId());
|
|
|
- return R.ok().put("order", order).put("items", items).put("logs",logs).put("user",user).put("customer",customer).put("payments",payments)
|
|
|
- .put("auditLogs", auditLogs);
|
|
|
+ return R.ok().put("order", order).put("items", items).put("logs", logs).put("user", user).put("payments",payments).put("tuiMoneyLogs",tuiMoneyLogs)
|
|
|
+ .put("auditLogs",auditLogs).put("storeScrm",storeScrm);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/queryAddress/{id}")
|
|
|
@@ -248,27 +640,21 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/queryPhone/{id}")
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:queryPhone')")
|
|
|
@Log(title = "查看电话", businessType = BusinessType.GRANT)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:queryPhone')")
|
|
|
public R getPhone(@PathVariable("id") Long id)
|
|
|
{
|
|
|
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- if (loginUser.getUser().getUserType().equals("00")){
|
|
|
- FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
- String userPhone = order.getUserPhone();
|
|
|
- return R.ok().put("userPhone",userPhone);
|
|
|
- }
|
|
|
- return R.error("无权查看");
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
+ String userPhone = order.getUserPhone();
|
|
|
+ return R.ok().put("userPhone",userPhone);
|
|
|
}
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:express')")
|
|
|
@GetMapping(value = "/getExpress/{id}")
|
|
|
- public R getExpress(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
- FsStoreOrderScrm order=fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
- ExpressInfoDTO expressInfoDTO=null;
|
|
|
- if(StringUtils.isNotEmpty(order.getDeliveryId())){
|
|
|
-
|
|
|
+ public R getExpress(@PathVariable("id") Long id) {
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
+ ExpressInfoDTO expressInfoDTO = null;
|
|
|
+ if (StringUtils.isNotEmpty(order.getDeliveryId())) {
|
|
|
String lastFourNumber = "";
|
|
|
if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue())) {
|
|
|
lastFourNumber = order.getUserPhone();
|
|
|
@@ -276,19 +662,18 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
|
|
|
}
|
|
|
}
|
|
|
- expressInfoDTO=expressService.getExpressInfo(order.getOrderCode(),order.getDeliverySn(),order.getDeliveryId(),lastFourNumber);
|
|
|
+ expressInfoDTO = expressService.getExpressInfo(order.getOrderCode(), order.getDeliverySn(), order.getDeliveryId(), lastFourNumber);
|
|
|
}
|
|
|
- return R.ok().put("data",expressInfoDTO);
|
|
|
+ return R.ok().put("data", expressInfoDTO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增订单
|
|
|
*/
|
|
|
-
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:add')")
|
|
|
@Log(title = "订单", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody FsStoreOrderScrm fsStoreOrder)
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody FsStoreOrderScrm fsStoreOrder) {
|
|
|
return toAjax(fsStoreOrderService.insertFsStoreOrder(fsStoreOrder));
|
|
|
}
|
|
|
|
|
|
@@ -298,104 +683,150 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:edit')")
|
|
|
@Log(title = "订单", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody FsStoreOrderScrm fsStoreOrder)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody FsStoreOrderScrm fsStoreOrder) {
|
|
|
return toAjax(fsStoreOrderService.updateFsStoreOrder(fsStoreOrder));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改物流
|
|
|
+ * @param fsStoreOrder
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Log(title = "修改物流", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:editDeliveryId')")
|
|
|
+ @PutMapping("/editDeliveryId")
|
|
|
+ public AjaxResult editDeliveryId(@RequestBody FsStoreOrderScrm fsStoreOrder) {
|
|
|
+ return toAjax(fsStoreOrderService.updateFsStoreOrder(fsStoreOrder));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "同步管易物流单号", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:updateErpOrder')")
|
|
|
+ @PostMapping("/updateErpOrder")
|
|
|
+ public R updateErpOrder(@Validated @RequestBody FsStoreOrderExpressEditParam param) {
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(param.getOrderId());
|
|
|
+ FsErpConfig erpConfig = configUtil.getErpConfig();
|
|
|
+ List<Long> noErpCompany = erpConfig.getNoErpCompany();
|
|
|
+ if (noErpCompany.contains(order.getCompanyId())) {
|
|
|
+ logger.info("订单:{},相关公司不推送erp", order.getOrderCode());
|
|
|
+ return R.ok("订单:"+ order.getOrderCode()+"相关公司不推送erp");
|
|
|
+ }
|
|
|
+ IErpOrderService erpOrderService = getErpService();
|
|
|
+ ErpOrderQueryRequert request = new ErpOrderQueryRequert();
|
|
|
+ request.setCode(order.getExtendOrderId());
|
|
|
+ ErpOrderQueryResponse response = erpOrderService.getScrmOrder(request);
|
|
|
+ if(response.getOrders()!=null&&response.getOrders().size()>0){
|
|
|
+ for(ErpOrderQuery orderQuery : response.getOrders()){
|
|
|
+ if(orderQuery.getDeliverys()!=null&&orderQuery.getDeliverys().size()>0){
|
|
|
+ for(ErpDeliverys delivery:orderQuery.getDeliverys()){
|
|
|
+ if(delivery.getDelivery()&& StringUtils.isNotEmpty(delivery.getMail_no())){
|
|
|
+ //更新商订单状态
|
|
|
+ fsStoreOrderService.updateDeliveryOrder(param.getOrderId(), delivery.getMail_no(),delivery.getExpress_code(),delivery.getExpress_name());
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.error("未查询到快递信息");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除订单
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:remove')")
|
|
|
@Log(title = "订单", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(fsStoreOrderService.deleteFsStoreOrderByIds(ids));
|
|
|
}
|
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:add')")
|
|
|
- @PostMapping("/createUserOrder")
|
|
|
- public R createUserOrder(@Validated @RequestBody FsStoreOrderCreateUserParam param, HttpServletRequest request){
|
|
|
|
|
|
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
+ @PostMapping("/createUserOrder")
|
|
|
+ public R createUserOrder(@Validated @RequestBody FsStoreOrderCreateUserParam param, HttpServletRequest request) {
|
|
|
return fsStoreOrderService.createUserOrder(param);
|
|
|
}
|
|
|
|
|
|
+ @Log(title = "确认订单", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:finishOrder')")
|
|
|
+ @PostMapping("/finishOrder")
|
|
|
+ public R finishOrder(@Validated @RequestBody FsStoreOrderFinishParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.finishOrder(param.getOrderId());
|
|
|
+ }
|
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:editPayPrice')")
|
|
|
- @PostMapping("/editPayPrice")
|
|
|
- public R editPayPrice(@RequestBody FsStoreOrderScrm fsStoreOrder)
|
|
|
- {
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:auditPayRemain')")
|
|
|
+ @PostMapping("/auditPayRemain")
|
|
|
+ public R auditPayRemain(@Validated @RequestBody FsStoreOrderAuditPayRemainParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.auditPayRemain(param.getOrderId());
|
|
|
+ }
|
|
|
|
|
|
- if(fsStoreOrderService.updateFsStoreOrder(fsStoreOrder)>0){
|
|
|
- //写日志
|
|
|
- orderStatusService.create(fsStoreOrder.getId(), OrderLogEnum.ORDER_EDIT.getValue(),
|
|
|
- OrderLogEnum.ORDER_EDIT.getDesc());
|
|
|
- return R.ok("操作成功");
|
|
|
- }
|
|
|
- else{
|
|
|
- return R.error("操作失败");
|
|
|
- }
|
|
|
|
|
|
+ @Log(title = "导入", businessType = BusinessType.IMPORT)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:importExpress')")
|
|
|
+ @PostMapping("/importExpress")
|
|
|
+ public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
+ ExcelUtil<StoreOrderExpressExportDTO> util = new ExcelUtil<StoreOrderExpressExportDTO>(StoreOrderExpressExportDTO.class);
|
|
|
+ List<StoreOrderExpressExportDTO> list = util.importExcel(file.getInputStream());
|
|
|
+ String message = fsStoreOrderService.importExpress(list, updateSupport);
|
|
|
+ return AjaxResult.success(message);
|
|
|
}
|
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:finishOrder')")
|
|
|
- @PostMapping("/finishOrder")
|
|
|
- public R finishOrder(@Validated @RequestBody FsStoreOrderFinishParam param, HttpServletRequest request){
|
|
|
- return fsStoreOrderService.finishOrder(param.getOrderId());
|
|
|
+ //下载模板
|
|
|
+ @GetMapping("/importTemplate")
|
|
|
+ public AjaxResult importTemplate() {
|
|
|
+ ExcelUtil<StoreOrderExpressExportDTO> util = new ExcelUtil<StoreOrderExpressExportDTO>(StoreOrderExpressExportDTO.class);
|
|
|
+ return util.importTemplateExcel("物流回单数据");
|
|
|
}
|
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:exportItems')")
|
|
|
- @Log(title = "订单明细导出", businessType = BusinessType.EXPORT)
|
|
|
- @GetMapping("/exportItems")
|
|
|
- public AjaxResult exportItems(FsStoreOrderParam param)
|
|
|
- {
|
|
|
- if (param.getBeginTime().equals("") && param.getEndTime().equals("")){
|
|
|
- param.setBeginTime(null);
|
|
|
- param.setEndTime(null);
|
|
|
- }
|
|
|
- if (fsStoreOrderService.isEntityNull(param)){
|
|
|
- return AjaxResult.error("请筛选数据导出");
|
|
|
- }
|
|
|
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
|
|
|
- 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("--"));
|
|
|
- }
|
|
|
+ @GetMapping("/getStoreOrder")
|
|
|
+ public R getStoreOrder(@RequestParam("orderCode") String orderCode) {
|
|
|
+ FsStoreOrderVO vo = fsStoreOrderService.selectFsStoreOrderVOByOrderCode(orderCode);
|
|
|
+ return R.ok().put("data", vo);
|
|
|
+ }
|
|
|
|
|
|
- List<FsStoreOrderItemExportVO> list=orderItemService.selectFsStoreOrderItemListExportVO(param);
|
|
|
- //对手机号脱敏
|
|
|
- if(list!=null){
|
|
|
- for(FsStoreOrderItemExportVO vo:list){
|
|
|
- if(vo.getUserPhone()!=null){
|
|
|
- String phone = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{1})", "$1****$2");
|
|
|
- vo.setUserPhone(phone);
|
|
|
- }
|
|
|
- if (vo.getUserAddress()!=null){
|
|
|
- vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(vo.getJsonInfo())){
|
|
|
- try {
|
|
|
- StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
|
|
|
- BeanUtil.copyProperties(orderProductDTO,vo);
|
|
|
- }
|
|
|
- catch (Exception e){
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<FsStoreOrderItemExportVO>(FsStoreOrderItemExportVO.class);
|
|
|
- return util.exportExcel(list, "订单明细数据");
|
|
|
+ @Log(title = "冻结、解冻佣金", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:editTuiMoney')")
|
|
|
+ @PostMapping("/editTuiMoney")
|
|
|
+ public R editTuiMoney(@Validated @RequestBody FsStoreOrderEditTuiMoneyParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.editTuiMoney(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "退款", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:refundOrderMoney')")
|
|
|
+ @PostMapping("/refundOrderMoney")
|
|
|
+ public synchronized R refundOrderMoney(@Validated @RequestBody FsStoreOrderRefundParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.refundOrderMoney(param.getOrderId());
|
|
|
+ }
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:getEroOrder')")
|
|
|
+ @GetMapping("/getEroOrder")
|
|
|
+ public R getEroOrder(@RequestParam("extendOrderId") String extendOrderId) {
|
|
|
+ IErpOrderService erpOrderService = getErpService();
|
|
|
+ ErpOrderQueryRequert request = new ErpOrderQueryRequert();
|
|
|
+ request.setCode(extendOrderId);
|
|
|
+ ErpOrderQueryResponse response = erpOrderService.getScrmOrder(request);
|
|
|
+ return R.ok().put("data",response);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:updateExpress')")
|
|
|
+ @PostMapping("/updateExpress")
|
|
|
+ public R updateExpress(@Validated @RequestBody FsStoreOrderExpressEditParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.updateExpress(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "同步物流", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:syncExpress')")
|
|
|
+ @PostMapping("/syncExpress")
|
|
|
+ public R syncExpress(@Validated @RequestBody FsStoreOrderExpressEditParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.syncExpress(param);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Log(title = "分佣", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:addTuiMoney')")
|
|
|
+ @PostMapping("/addTuiMoney")
|
|
|
+ public R addTuiMoney(@Validated @RequestBody FsStoreOrderAddTuiMoneyParam param, HttpServletRequest request) {
|
|
|
+ return fsStoreOrderService.addTuiMoney(param);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -415,61 +846,441 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:bindCustomer')")
|
|
|
- @PostMapping("/bindCustomer")
|
|
|
- public R bindCustomer(@RequestBody FsStoreOrderBindCustomerParam param)
|
|
|
+ @Log(title = "手动推管易", businessType = BusinessType.INSERT)
|
|
|
+ @ApiOperation("创建ERP订单")
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:createErpOrder')")
|
|
|
+ @GetMapping("/createErpOrder")
|
|
|
+ public R createErpOrder(@RequestParam("orderCode") String orderCode) throws Exception
|
|
|
{
|
|
|
- if(param.getCustomerIds().length>1){
|
|
|
- return R.error("只能关联一个客户");
|
|
|
+ logger.info("手动推管易订单号:{}",orderCode);
|
|
|
+ FsStoreOrderScrm order=fsStoreOrderService.selectFsStoreOrderByOrderCode(orderCode);
|
|
|
+ return fsStoreOrderService.createOmsOrder(order.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单维度分页查询接口
|
|
|
+ * @param param 查询条件
|
|
|
+ * @return AjaxResult
|
|
|
+ * **/
|
|
|
+ @GetMapping("/orderDimensionStatisticsList")
|
|
|
+ public TableDataInfo orderDimensionStatisticsList(OrderStatisticsParam param){
|
|
|
+ return getDataTable(fsStoreOrderService.selectOrderDimensionStatisticsList(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出订单维度统计接口
|
|
|
+ * @param param 查询条件
|
|
|
+ * @return AjaxResult
|
|
|
+ * **/
|
|
|
+ @Log(title = "订单维度统计", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/orderDimensionStatisticsExport")
|
|
|
+ public AjaxResult orderDimensionStatisticsExport(OrderStatisticsParam param){
|
|
|
+ List<OrderStatisticsVo> list = fsStoreOrderService.selectOrderDimensionStatisticsList(param);
|
|
|
+// switch (param.getGroupType()){
|
|
|
+// case 2:
|
|
|
+// List<OrderCateStatisticsVo> cateStatisticsVoList = convertTo(list,OrderCateStatisticsVo.class);
|
|
|
+// ExcelUtil<OrderCateStatisticsVo> cateUtil = new ExcelUtil<>(OrderCateStatisticsVo.class);
|
|
|
+// return cateUtil.exportExcel(cateStatisticsVoList, "订单标签维度统计");
|
|
|
+// case 3:
|
|
|
+// List<OrderProductStatisticsVo> productStatisticsVoList = convertTo(list,OrderProductStatisticsVo.class);
|
|
|
+// ExcelUtil<OrderProductStatisticsVo> productUtil = new ExcelUtil<>(OrderProductStatisticsVo.class);
|
|
|
+// return productUtil.exportExcel(productStatisticsVoList, "订单商品维度统计");
|
|
|
+// }
|
|
|
+
|
|
|
+ ExcelUtil<OrderStatisticsVo> util = new ExcelUtil<>(OrderStatisticsVo.class);
|
|
|
+ return util.exportExcel(list, "订单员工维度统计");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对象列表类型转换
|
|
|
+ */
|
|
|
+ public static <T> List<T> convertTo(List<?> sourceList, Class<T> targetClass) {
|
|
|
+ if (sourceList == null || sourceList.isEmpty()) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<T> resultList = new ArrayList<>(sourceList.size());
|
|
|
+ try {
|
|
|
+ for (Object source : sourceList) {
|
|
|
+ T target = targetClass.getDeclaredConstructor().newInstance();
|
|
|
+ BeanUtils.copyProperties(source, target);
|
|
|
+ resultList.add(target);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("数据转换异常", e);
|
|
|
}
|
|
|
- for(Long customerId:param.getCustomerIds()){
|
|
|
- FsStoreOrderScrm order=new FsStoreOrderScrm();
|
|
|
- order.setId(param.getOrderId());
|
|
|
- order.setCustomerId(customerId);
|
|
|
- fsStoreOrderService.updateFsStoreOrder(order);
|
|
|
- //更新CRM客户订单数
|
|
|
- crmCustomerService.updateBuyCount(customerId);
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询erp默认手机号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/queryErpPhone")
|
|
|
+ public AjaxResult queryErpPhone()
|
|
|
+ {
|
|
|
+ SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("erp.phone");
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ if(sysConfig!=null){
|
|
|
+ String configValue = sysConfig.getConfigValue();
|
|
|
+ if(StringUtils.isNotEmpty(configValue)){
|
|
|
+ list = JSON.parseArray(configValue, String.class);
|
|
|
+ }
|
|
|
}
|
|
|
- return R.ok("操作成功");
|
|
|
+ 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));
|
|
|
}
|
|
|
|
|
|
- @Log(title = "订单凭证上传", businessType = BusinessType.UPDATE)
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:uploadCredentials')")
|
|
|
- @PostMapping("/uploadCredentials")
|
|
|
- public R UploadCredentials(@RequestBody FsStoreOrderScrm order)
|
|
|
+ /**
|
|
|
+ * 批量设置erp手机号
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
|
|
|
+ @Log(title = "订单", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/editErpPhone")
|
|
|
+ public AjaxResult editErpPhone(@RequestBody FsStoreOrderScrmSetErpPhoneParam param)
|
|
|
{
|
|
|
-// String[] imageUrls = order.getCredentials().split(",");
|
|
|
- if (order.getCertificates() == null ){
|
|
|
- return R.error("请选择图片上传");
|
|
|
+ param.setOpeName(getLoginUser().getUser().getNickName());
|
|
|
+ List<String> erpPhone = param.getErpPhone();
|
|
|
+ if (erpPhone == null || erpPhone.isEmpty()) {
|
|
|
+ return AjaxResult.error("请选择手机号");
|
|
|
}
|
|
|
- fsStoreOrderService.uploadCredentials(order);
|
|
|
- return R.ok();
|
|
|
+ return toAjax(fsStoreOrderService.batchUpdateErpByOrderIds(param));
|
|
|
}
|
|
|
|
|
|
- @Log(title = "修改地址", businessType = BusinessType.UPDATE)
|
|
|
- @PreAuthorize("@ss.hasPermi('store:storeOrder:editAddress')")
|
|
|
- @PostMapping("/editAddress")
|
|
|
- public R editAddress(@RequestBody FsStoreOrderScrm order) throws ParseException
|
|
|
+ /**
|
|
|
+ * 获取erp账户
|
|
|
+ */
|
|
|
+ @GetMapping("/getErpAccount")
|
|
|
+ public R getErpAccount()
|
|
|
{
|
|
|
- FsStoreOrderScrm storeOrder = fsStoreOrderService.selectFsStoreOrderById(order.getId());
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ if (CloudHostUtils.hasCloudHostName("金牛明医","康年堂")) {
|
|
|
+ List<FsDfAccount> erpAccounts = fsDfAccountService.selectFsDfAccountList(null);
|
|
|
+ list = erpAccounts.stream().map(FsDfAccount::getLoginAccount).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return R.ok().put("data", list);
|
|
|
+ }
|
|
|
|
|
|
- int a = fsStoreOrderService.updateFsStoreOrder(order);
|
|
|
- if (storeOrder.getExtendOrderId()!=null && a>0){
|
|
|
- fsStoreOrderService.createOmsOrder(storeOrder.getId());
|
|
|
+ @Log(title = "手动推管易", businessType = BusinessType.INSERT)
|
|
|
+ @ApiOperation("批量创建ERP订单")
|
|
|
+ @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
|
|
|
+ @PostMapping(value = "/batchCreateErpOrder")
|
|
|
+ public R batchCreateErpOrder(@RequestBody FsStoreOrderScrmSetErpPhoneParam param)
|
|
|
+ {
|
|
|
+ String nickName = getLoginUser().getUser().getNickName();
|
|
|
+ String loginAccount = param.getLoginAccount();
|
|
|
+ if (StringUtils.isBlank(loginAccount)){
|
|
|
+ return R.error("未选择推送erp账户");
|
|
|
+ }
|
|
|
+ FsStoreOrderDf df = getDFInfo(loginAccount);
|
|
|
+ if (df.getLoginAccount() == null){
|
|
|
+ return R.error("未查询到所选erp账户");
|
|
|
+ }
|
|
|
+ List<Long> orderIds = param.getOrderIds();
|
|
|
+ if (orderIds == null || orderIds.isEmpty()) {
|
|
|
+ if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getPayTimeRange())){
|
|
|
+ param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ param.setNotHealth(1);
|
|
|
+ List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
|
|
|
+ orderIds = list.stream().map(FsStoreOrderVO::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (orderIds.isEmpty()){
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
+ orderIds.forEach(orderId->{
|
|
|
+ try {
|
|
|
+ df.setOrderId(orderId);
|
|
|
+ FsStoreOrderDf temp = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(df.getOrderId());
|
|
|
+ if (temp == null){
|
|
|
+ df.setParcelQuantity(param.getParcelQuantity()); //设置包裹数量
|
|
|
+ fsStoreOrderDfService.insertFsStoreOrderDf(df);
|
|
|
+ fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getValue(),
|
|
|
+ nickName + " " +FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getDesc() + ":" + df.getLoginAccount());
|
|
|
+ }
|
|
|
+ fsStoreOrderService.createOmsOrder(orderId);
|
|
|
+ fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.PUSH_ORDER_ERP.getValue(),
|
|
|
+ nickName + " " +FsStoreOrderLogEnum.PUSH_ORDER_ERP.getDesc() + ":" + df.getLoginAccount());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ @ApiOperation("批量设置订单账户")
|
|
|
+ @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
|
|
|
+ @PostMapping(value = "/batchSetErpOrder")
|
|
|
+ public R batchSetErpOrder(@RequestBody FsStoreOrderScrmSetErpPhoneParam param)
|
|
|
+ {
|
|
|
+ String nickName = getLoginUser().getUser().getNickName();
|
|
|
+ String loginAccount = param.getLoginAccount();
|
|
|
+ if (StringUtils.isBlank(loginAccount)){
|
|
|
+ return R.error("未选择erp账户");
|
|
|
+ }
|
|
|
+ FsStoreOrderDf df = getDFInfo(loginAccount);
|
|
|
+ if (df.getLoginAccount() == null){
|
|
|
+ return R.error("未查询到所选erp账户");
|
|
|
+ }
|
|
|
+ List<Long> orderIds = param.getOrderIds();
|
|
|
+ if (orderIds == null || orderIds.isEmpty()) {
|
|
|
+ if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getPayTimeRange())){
|
|
|
+ param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ param.setNotHealth(1);
|
|
|
+ List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
|
|
|
+ orderIds = list.stream().map(FsStoreOrderVO::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (orderIds.isEmpty()){
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ orderIds.forEach(orderId->{
|
|
|
+ df.setOrderId(orderId);
|
|
|
+ FsStoreOrderDf temp = fsStoreOrderDfService.selectFsStoreOrderDfByOrderId(df.getOrderId());
|
|
|
+ df.setParcelQuantity(param.getParcelQuantity());
|
|
|
+ if (temp != null){
|
|
|
+ df.setUpdateTime(new Date());
|
|
|
+ fsStoreOrderDfService.updateFsStoreOrderDf(df);
|
|
|
+ } else {
|
|
|
+ fsStoreOrderDfService.insertFsStoreOrderDf(df);
|
|
|
+ }
|
|
|
+ fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getValue(),
|
|
|
+ nickName + " " +FsStoreOrderLogEnum.SET_PUSH_ACCOUNT.getDesc() + ":" + df.getLoginAccount());
|
|
|
+ });
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ private FsStoreOrderDf getDFInfo(String loginAccount) {
|
|
|
+ //查询订单账户 判断是否存在该订单账户
|
|
|
+ List<FsDfAccount> erpAccounts = fsDfAccountService.selectFsDfAccountList(null);
|
|
|
+ FsStoreOrderDf df = new FsStoreOrderDf();
|
|
|
+ for (FsDfAccount erpAccount : erpAccounts) {
|
|
|
+ if (loginAccount.equals(erpAccount.getLoginAccount())){
|
|
|
+ //添加df记录
|
|
|
+ df.setAppKey(erpAccount.getDfAppKey());
|
|
|
+ df.setAppSecret(erpAccount.getDfAppsecret());
|
|
|
+ df.setLoginAccount(loginAccount);
|
|
|
+ df.setMonthlyCard(erpAccount.getMonthlyCard());
|
|
|
+ df.setExpressProductCode(erpAccount.getExpressProductCode());
|
|
|
+ df.setStatus(0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return df;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 销售端数据隔离:管理员查看当前销售公司的全部数据,
|
|
|
+ * 非管理员仅查看当前销售人员(companyUserId)关联的数据
|
|
|
+ */
|
|
|
+ private void applyDeptDataScope(FsStoreOrderParam param) {
|
|
|
+ if (param == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ if (loginUser == null || loginUser.getUser() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (loginUser.getUser().isAdmin()) {
|
|
|
+ // 管理员:限定本销售公司数据
|
|
|
+ if (loginUser.getCompany() != null) {
|
|
|
+ param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 非管理员:仅限定当前销售人员关联的数据
|
|
|
+ param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
+ }
|
|
|
+ } catch (Exception ignore) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验是否为总公司部门(deptId = 1)
|
|
|
+ */
|
|
|
+ public boolean checkDept(Long deptId) {
|
|
|
+ if (deptId == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ SysDept dept = sysDeptMapper.selectDeptById(deptId);
|
|
|
+ if (dept == null || !dept.getDeptId().equals(1L)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 获取下单类型
|
|
|
+ * 下载订单/退款明细Excel(销售端预览打印使用)
|
|
|
*/
|
|
|
- @GetMapping("/getCreateOrderType")
|
|
|
- public R getCreateOrderType() {
|
|
|
- String json=configService.selectConfigByKey("store.config");
|
|
|
- StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
|
|
|
- Integer createSalesOrderType = config.getCreateSalesOrderType();
|
|
|
- return R.ok().put("createSalesOrderType",createSalesOrderType);
|
|
|
+ @GetMapping("/downloadExcel/{id}")
|
|
|
+ public void downloadExcel(@PathVariable("id") Long id, HttpServletResponse response) {
|
|
|
+ FsStoreOrderScrm fsStoreOrderScrm = fsStoreOrderService.selectFsStoreOrderById(id);
|
|
|
+ FsStoreScrm fsStoreScrm = iFsStoreScrmService.selectFsStoreByStoreId(fsStoreOrderScrm.getStoreId());
|
|
|
+ paymentService.selectFsStorePaymentByOrderId(fsStoreOrderScrm.getId());
|
|
|
+ List<FsStoreOrderItemVO> orderItems = orderItemService.selectFsStoreOrderItemListByOrderId(fsStoreOrderScrm.getId());
|
|
|
+ boolean statusFlag = fsStoreOrderScrm.getStatus() != null && fsStoreOrderScrm.getStatus() == -2;
|
|
|
+ String templatePath = statusFlag ? "/退款详情表格.xlsx" : "/打印详情表格.xlsx";
|
|
|
+ Workbook workbook = null;
|
|
|
+ InputStream fis = null;
|
|
|
+ ServletOutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ fis = this.getClass().getResourceAsStream(templatePath);
|
|
|
+ if (fis == null) {
|
|
|
+ throw new RuntimeException("模板文件未找到: " + templatePath);
|
|
|
+ }
|
|
|
+ workbook = new XSSFWorkbook(fis);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ int startCol = 1;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (int i = 0; i < orderItems.size(); i++) {
|
|
|
+ StoreOrderProductDTO cartInfo = JSONObject.parseObject(orderItems.get(i).getJsonInfo(), StoreOrderProductDTO.class);
|
|
|
+ logger.info("出库,carInfo:{},{}", i, orderItems.get(i).getJsonInfo());
|
|
|
+ setCellValue(sheet, 9, startCol + i, cartInfo.getSku());
|
|
|
+ setCellValue(sheet, 13, startCol + i, String.valueOf(cartInfo.getNum()));
|
|
|
+ setCellValue(sheet, 14, startCol + i, String.valueOf(cartInfo.getPrice()));
|
|
|
+ setCellValue(sheet, 15, startCol + i, String.valueOf(cartInfo.getPrice()));
|
|
|
+ FsStoreProductScrm fsStoreProductScrm = fsStoreProductService.selectFsStoreProductById(cartInfo.getProductId());
|
|
|
+ setCellValue(sheet, 10, startCol + i, fsStoreProductScrm != null && fsStoreProductScrm.getManufacturer() != null ? fsStoreProductScrm.getManufacturer() : "");
|
|
|
+ setCellValue(sheet, 8, startCol + i, cartInfo.getProductName() != null && !"-".equals(cartInfo.getProductName()) ? cartInfo.getProductName() : (fsStoreProductScrm != null && fsStoreProductScrm.getCommonName() != null ? fsStoreProductScrm.getCommonName() : ""));
|
|
|
+ setCellValue(sheet, 11, startCol + i, orderItems.get(i).getBatchNumber());
|
|
|
+ setCellValue(sheet, 12, startCol + i, orderItems.get(i).getVerifyCode());
|
|
|
+ }
|
|
|
+ String payTimeStr = null;
|
|
|
+ Date payTime = fsStoreOrderScrm.getPayTime();
|
|
|
+ if (payTime != null) {
|
|
|
+ payTimeStr = sdf.format(payTime);
|
|
|
+ }
|
|
|
+ setCellValue(sheet, 2, 1, fsStoreOrderScrm.getOrderCode());
|
|
|
+ setCellValue(sheet, 3, 1, fsStoreScrm != null ? fsStoreScrm.getStoreName() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 4, 1, fsStoreScrm != null ? fsStoreScrm.getFullName() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 5, 1, fsStoreScrm != null ? fsStoreScrm.getEnterpriseAddress() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 6, 1, fsStoreScrm != null ? fsStoreScrm.getRefundPhone() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 7, 1, payTimeStr);
|
|
|
+ setCellValue(sheet, 16, 1, String.valueOf(fsStoreOrderScrm.getTotalPrice()));
|
|
|
+ if (statusFlag) {
|
|
|
+ List<FsStorePaymentScrm> fsStorePaymentScrms = paymentService.selectFsStorePaymentByOrderIdAndStatus(fsStoreOrderScrm.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(fsStorePaymentScrms)) {
|
|
|
+ List<FsStoreAfterSalesVO> fsStoreAfterSalesVOS = fsStoreAfterSalesService.selectFsStoreAfterSalesVOByOrderCode(fsStoreOrderScrm.getOrderCode());
|
|
|
+ FsStoreAfterSalesItemScrm map = new FsStoreAfterSalesItemScrm();
|
|
|
+ map.setStoreAfterSalesId(fsStoreAfterSalesVOS.get(0).getId());
|
|
|
+ List<FsStoreAfterSalesItemScrm> items = fsStoreAfterSalesItemService.selectFsStoreAfterSalesItemList(map);
|
|
|
+ setCellValue(sheet, 20, 1, fsStorePaymentScrms.get(0).getBankSerialNo());
|
|
|
+ setCellValue(sheet, 21, 1, fsStoreOrderScrm.getOrderCode());
|
|
|
+ setCellValue(sheet, 22, 1, fsStoreScrm != null ? fsStoreScrm.getStoreName() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 23, 1, fsStoreScrm != null ? fsStoreScrm.getEnterpriseAddress() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 24, 1, fsStoreScrm != null ? fsStoreScrm.getRefundPhone() : "该店铺已不存在");
|
|
|
+ setCellValue(sheet, 25, 1, sdf.format(fsStorePaymentScrms.get(0).getRefundTime()));
|
|
|
+ int startNul = 1;
|
|
|
+ BigDecimal total = new BigDecimal(BigInteger.ZERO);
|
|
|
+ for (int i = 0; i < items.size(); i++) {
|
|
|
+ setCellValue(sheet, 28, startNul + i, items.get(0).getMah());
|
|
|
+ BigDecimal tal = new BigDecimal(BigInteger.ZERO);
|
|
|
+ String jsonInfo = items.get(i).getJsonInfo();
|
|
|
+ if (StringUtils.isNotEmpty(jsonInfo)) {
|
|
|
+ StoreOrderProductDTO cartInfo = JSONObject.parseObject(jsonInfo, StoreOrderProductDTO.class);
|
|
|
+ logger.info("退款,carInfo:{},{}", i, jsonInfo);
|
|
|
+ FsStoreProductScrm fsStoreProductScrm = fsStoreProductService.selectFsStoreProductById(cartInfo.getProductId());
|
|
|
+ setCellValue(sheet, 26, startCol + i, cartInfo.getProductName() != null && !"-".equals(cartInfo.getProductName()) ? cartInfo.getProductName() : (fsStoreProductScrm != null && fsStoreProductScrm.getCommonName() != null ? fsStoreProductScrm.getCommonName() : ""));
|
|
|
+ setCellValue(sheet, 27, startNul + i, cartInfo.getSku());
|
|
|
+ setCellValue(sheet, 29, startNul + i, orderItems.get(i).getBatchNumber());
|
|
|
+ setCellValue(sheet, 30, startNul + i, orderItems.get(i).getVerifyCode());
|
|
|
+ setCellValue(sheet, 31, startNul + i, String.valueOf(cartInfo.getNum()));
|
|
|
+ setCellValue(sheet, 32, startNul + i, String.valueOf(cartInfo.getPrice()));
|
|
|
+ setCellValue(sheet, 33, startNul + i, cartInfo.getNum() == null || cartInfo.getPrice() == null ? "" : String.valueOf(cartInfo.getPrice().multiply(new BigDecimal(cartInfo.getNum()))));
|
|
|
+ if (cartInfo.getNum() != null && cartInfo.getPrice() != null) {
|
|
|
+ tal = new BigDecimal(cartInfo.getNum()).multiply(cartInfo.getPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ total = total.add(tal);
|
|
|
+ }
|
|
|
+ setCellValue(sheet, 34, 1, String.valueOf(total));
|
|
|
+ setCellValue(sheet, 35, 1, fsStoreAfterSalesVOS.get(0).getReasons());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = "打印详情表格.xlsx";
|
|
|
+ fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+ workbook.close();
|
|
|
+ outputStream.flush();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ try {
|
|
|
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "生成Excel文件时出错");
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (workbook != null) {
|
|
|
+ workbook.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("关闭Workbook失败", e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (fis != null) {
|
|
|
+ fis.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("关闭输入流失败", e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (outputStream != null) {
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("关闭输出流失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setCellValue(Sheet sheet, int rowNum, int colNum, String value) {
|
|
|
+ Row row = sheet.getRow(rowNum);
|
|
|
+ if (row == null) {
|
|
|
+ row = sheet.createRow(rowNum);
|
|
|
+ }
|
|
|
+ Cell cell = row.getCell(colNum);
|
|
|
+ if (cell == null) {
|
|
|
+ cell = row.createCell(colNum);
|
|
|
+ }
|
|
|
+ cell.setCellValue(value);
|
|
|
}
|
|
|
}
|