|
|
@@ -1,5 +1,6 @@
|
|
|
package com.fs.company.controller.store;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
@@ -9,6 +10,7 @@ import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.ParseUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.crm.service.ICrmCustomerService;
|
|
|
@@ -31,8 +33,14 @@ import com.fs.his.service.IFsStoreOrderService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.FsStoreOrderListVO;
|
|
|
+import com.fs.his.vo.FsStoreOrderListAndStatisticsVo;
|
|
|
import com.fs.his.vo.FsStoreOrderVO;
|
|
|
import com.fs.his.vo.FsStoreProductDeliverExcelVO;
|
|
|
+import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
|
+import com.fs.hisStore.service.IFsStoreOrderItemScrmService;
|
|
|
+import com.fs.hisStore.vo.FsStoreOrderErpExportVO;
|
|
|
+import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
|
|
|
+import com.fs.hisStore.dto.StoreOrderProductDTO;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
@@ -40,8 +48,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
|
import static com.fs.his.utils.PhoneUtil.encryptPhone;
|
|
|
@@ -67,6 +76,271 @@ public class FsStoreOrderController extends BaseController
|
|
|
@Autowired
|
|
|
@Qualifier("erpOrderServiceImpl")
|
|
|
IErpOrderService erpOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreOrderScrmService fsStoreOrderScrmService;
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreOrderItemScrmService orderItemScrmService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询直播订单列表(仅 fs_store_order_scrm 中 order_type=2)
|
|
|
+ * 分公司负责人(userType=00)可查公司下所有直播订单,否则仅能查自己的直播订单
|
|
|
+ */
|
|
|
+ @PostMapping("/healthLiveList")
|
|
|
+ public FsStoreOrderListAndStatisticsVo healthLiveList(@RequestBody com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ param.setOrderType(2);
|
|
|
+ if (!"00".equals(loginUser.getUser().getUserType())) {
|
|
|
+ param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
+ } else {
|
|
|
+ param.setCompanyUserId(null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getCreateTimeRange())) {
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getPayTimeRange())) {
|
|
|
+ param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getDeliveryImportTimeRange())) {
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getDeliverySendTimeRange())) {
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ Map<String, java.math.BigDecimal> statistics = fsStoreOrderScrmService.selectFsStoreOrderStatistics(param);
|
|
|
+ String productInfoStr = fsStoreOrderScrmService.selectFsStoreOrderProductStatistics(param);
|
|
|
+ PageHelper.startPage(param.getPageNum(), param.getPageSize());
|
|
|
+ List<com.fs.hisStore.vo.FsStoreOrderVO> list = fsStoreOrderScrmService.selectFsStoreOrderListVO(param);
|
|
|
+ if (list != null) {
|
|
|
+ for (com.fs.hisStore.vo.FsStoreOrderVO vo : list) {
|
|
|
+ if (StringUtils.isNotEmpty(vo.getPhone())) {
|
|
|
+ vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(vo.getUserPhone())) {
|
|
|
+ vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsStoreOrderListAndStatisticsVo vo = new FsStoreOrderListAndStatisticsVo();
|
|
|
+ vo.setRows(list);
|
|
|
+ vo.setTotal(new com.github.pagehelper.PageInfo<>(list).getTotal());
|
|
|
+ vo.setCode(200);
|
|
|
+ vo.setMsg("查询成功");
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ if (statistics != null && statistics.size() >= 3) {
|
|
|
+ vo.setPayPriceTotal(statistics.get("pay_price") != null ? statistics.get("pay_price").toString() : "0");
|
|
|
+ vo.setPayMoneyTotal(statistics.get("pay_money") != null ? statistics.get("pay_money").toString() : "0");
|
|
|
+ vo.setPayRemainTotal(statistics.get("pay_remain") != null ? statistics.get("pay_remain").toString() : "0");
|
|
|
+ } else {
|
|
|
+ vo.setPayPriceTotal("0");
|
|
|
+ vo.setPayMoneyTotal("0");
|
|
|
+ vo.setPayRemainTotal("0");
|
|
|
+ }
|
|
|
+ vo.setProductInfo(StringUtils.isNotBlank(productInfoStr) ? productInfoStr : "");
|
|
|
+ } else {
|
|
|
+ vo.setPayPriceTotal("0");
|
|
|
+ vo.setPayMoneyTotal("0");
|
|
|
+ vo.setPayRemainTotal("0");
|
|
|
+ vo.setProductInfo("");
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 直播订单导出:筛选条件与 healthLiveList 一致(orderType=2 + 公司/负责人权限) */
|
|
|
+ private void applyHealthLiveFilter(com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ param.setOrderType(2);
|
|
|
+ if (!"00".equals(loginUser.getUser().getUserType())) {
|
|
|
+ param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
+ } else {
|
|
|
+ param.setCompanyUserId(null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getCreateTimeRange())) {
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getPayTimeRange())) {
|
|
|
+ param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getDeliveryImportTimeRange())) {
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getDeliverySendTimeRange())) {
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void normalizeExportParam(com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())) {
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getCreateTimeRange())) {
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if ((param.getOrderCodes() == null || param.getOrderCodes().isEmpty())
|
|
|
+ && StringUtils.isNotBlank(param.getOrderCodeList())) {
|
|
|
+ String[] arr = param.getOrderCodeList().split("[,,\\s]+");
|
|
|
+ param.setOrderCodes(new ArrayList<>(Arrays.asList(arr)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出直播订单列表(脱敏)
|
|
|
+ */
|
|
|
+ @Log(title = "直播订单导出", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/healthExport")
|
|
|
+ public AjaxResult healthExport(@RequestBody com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())) {
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ applyHealthLiveFilter(param);
|
|
|
+ if (fsStoreOrderScrmService.isEntityNull(param)) {
|
|
|
+ return AjaxResult.error("请筛选数据导出");
|
|
|
+ }
|
|
|
+ List<FsStoreOrderErpExportVO> list = fsStoreOrderScrmService.selectFsStoreOrderListVOByExport(param);
|
|
|
+ if (list != null) {
|
|
|
+ for (FsStoreOrderErpExportVO 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()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String filter = param.getFilter();
|
|
|
+ ArrayList<String> filterList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(filter)) {
|
|
|
+ String[] filterArr = filter.split("\\s*,\\s*");
|
|
|
+ filterList.addAll(Arrays.asList(filterArr));
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<>(FsStoreOrderErpExportVO.class);
|
|
|
+ if (filter != null && !filter.isEmpty()) {
|
|
|
+ return util.exportExcelSelectedColumns(list, "订单数据", filterList);
|
|
|
+ } else {
|
|
|
+ return util.exportExcel(list, "订单数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出直播订单列表(明文)
|
|
|
+ */
|
|
|
+ @Log(title = "直播订单导出(明文)", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/healthExportDetails")
|
|
|
+ public AjaxResult healthExportDetails(@RequestBody com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())) {
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ applyHealthLiveFilter(param);
|
|
|
+ if (fsStoreOrderScrmService.isEntityNull(param)) {
|
|
|
+ return AjaxResult.error("请筛选数据导出");
|
|
|
+ }
|
|
|
+ List<FsStoreOrderErpExportVO> list = fsStoreOrderScrmService.selectFsStoreOrderListVOByExport(param);
|
|
|
+ String filter = param.getFilter();
|
|
|
+ ArrayList<String> filterList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(filter)) {
|
|
|
+ String[] filterArr = filter.split("\\s*,\\s*");
|
|
|
+ filterList.addAll(Arrays.asList(filterArr));
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<>(FsStoreOrderErpExportVO.class);
|
|
|
+ if (filter != null && !filter.isEmpty()) {
|
|
|
+ return util.exportExcelSelectedColumns(list, "订单数据", filterList);
|
|
|
+ } else {
|
|
|
+ return util.exportExcel(list, "订单数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出直播订单明细(脱敏)
|
|
|
+ */
|
|
|
+ @Log(title = "直播订单明细导出", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/healthExportItems")
|
|
|
+ public AjaxResult healthExportItems(com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ normalizeExportParam(param);
|
|
|
+ applyHealthLiveFilter(param);
|
|
|
+ if (fsStoreOrderScrmService.isEntityNull(param)) {
|
|
|
+ return AjaxResult.error("请筛选数据导出");
|
|
|
+ }
|
|
|
+ List<FsStoreOrderItemExportVO> list = orderItemScrmService.selectFsStoreOrderItemListExportVO(param);
|
|
|
+ if (list != null) {
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ for (FsStoreOrderItemExportVO vo : list) {
|
|
|
+ if (vo.getUserPhone() != null) {
|
|
|
+ vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{1})", "$1****$2"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(vo.getJsonInfo())) {
|
|
|
+ try {
|
|
|
+ StoreOrderProductDTO dto = com.alibaba.fastjson.JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
|
|
|
+ BeanUtil.copyProperties(dto, vo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // ignore
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (vo.getUserAddress() != null) {
|
|
|
+ vo.setUserAddress(ParseUtils.parseAddress(vo.getUserAddress()));
|
|
|
+ }
|
|
|
+ if ((loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) && vo.getCost() != null) {
|
|
|
+ vo.setFPrice(vo.getCost().multiply(java.math.BigDecimal.valueOf(vo.getTotalNum())));
|
|
|
+ } else {
|
|
|
+ vo.setPayPostage(java.math.BigDecimal.ZERO);
|
|
|
+ vo.setCost(java.math.BigDecimal.ZERO);
|
|
|
+ vo.setFPrice(java.math.BigDecimal.ZERO);
|
|
|
+ vo.setBarCode("");
|
|
|
+ vo.setCateName("");
|
|
|
+ vo.setBankTransactionId("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<>(FsStoreOrderItemExportVO.class);
|
|
|
+ return util.exportExcel(list, "订单明细数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出直播订单明细(明文)
|
|
|
+ */
|
|
|
+ @Log(title = "直播订单明细导出(明文)", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/healthExportItemsDetails")
|
|
|
+ public AjaxResult healthExportItemsDetails(com.fs.hisStore.param.FsStoreOrderParam param) {
|
|
|
+ normalizeExportParam(param);
|
|
|
+ applyHealthLiveFilter(param);
|
|
|
+ if (fsStoreOrderScrmService.isEntityNull(param)) {
|
|
|
+ return AjaxResult.error("请筛选数据导出");
|
|
|
+ }
|
|
|
+ List<FsStoreOrderItemExportVO> list = orderItemScrmService.selectFsStoreOrderItemListExportVO(param);
|
|
|
+ if (list != null) {
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ for (FsStoreOrderItemExportVO vo : list) {
|
|
|
+ if (StringUtils.isNotEmpty(vo.getJsonInfo())) {
|
|
|
+ try {
|
|
|
+ StoreOrderProductDTO dto = com.alibaba.fastjson.JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
|
|
|
+ BeanUtil.copyProperties(dto, vo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // ignore
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) && vo.getCost() != null) {
|
|
|
+ vo.setFPrice(vo.getCost().multiply(java.math.BigDecimal.valueOf(vo.getTotalNum())));
|
|
|
+ } else {
|
|
|
+ vo.setPayPostage(java.math.BigDecimal.ZERO);
|
|
|
+ vo.setCost(java.math.BigDecimal.ZERO);
|
|
|
+ vo.setFPrice(java.math.BigDecimal.ZERO);
|
|
|
+ vo.setBarCode("");
|
|
|
+ vo.setCateName("");
|
|
|
+ vo.setBankTransactionId("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<>(FsStoreOrderItemExportVO.class);
|
|
|
+ return util.exportExcel(list, "订单明细数据");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询订单列表
|
|
|
*/
|