|
|
@@ -1,6 +1,5 @@
|
|
|
package com.fs.his.controller;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
@@ -15,6 +14,10 @@ import com.fs.common.utils.CloudHostUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.common.utils.uuid.IdUtils;
|
|
|
+import com.fs.company.cache.ICompanyUserCacheService;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.course.domain.FsUserCompanyUser;
|
|
|
+import com.fs.course.service.IFsUserCompanyUserService;
|
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.dto.ExpressInfoDTO;
|
|
|
import com.fs.his.enums.ShipperCodeEnum;
|
|
|
@@ -74,6 +77,10 @@ public class FsIntegralOrderController extends BaseController
|
|
|
private FsIntegralOrderMapper integralOrderMapper;
|
|
|
@Autowired
|
|
|
private FsIntegralOrderMapper fsIntegralOrderMapper;
|
|
|
+ @Autowired
|
|
|
+ private IFsUserCompanyUserService iFsUserCompanyUserService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyUserCacheService companyUserCacheService;
|
|
|
|
|
|
/**
|
|
|
* 查询积分商品订单列表
|
|
|
@@ -150,154 +157,101 @@ public class FsIntegralOrderController extends BaseController
|
|
|
@GetMapping("/export")
|
|
|
|
|
|
public AjaxResult export(FsIntegralOrderParam fsIntegralOrder) {
|
|
|
- List<FsIntegralOrderListVO> fsIntegralOrderListVOS = new ArrayList<>();
|
|
|
+ List<FsIntegralOrderListVO> list = new ArrayList<>();
|
|
|
if (CloudHostUtils.hasCloudHostName("金牛明医")){
|
|
|
/*目前只有金牛有状态为6的查询,其他项目避免使用6状态码*/
|
|
|
- if (fsIntegralOrder.getStatus() != null && fsIntegralOrder.getStatus().equals("6")) {
|
|
|
+ if ("6".equals(fsIntegralOrder.getStatus())) {
|
|
|
fsIntegralOrder.setStatus("1");
|
|
|
fsIntegralOrder.setIsPush(0);
|
|
|
}
|
|
|
- fsIntegralOrderListVOS = fsIntegralOrderService.selectFsIntegralOrderListByJn(fsIntegralOrder);
|
|
|
+ list = fsIntegralOrderService.selectFsIntegralOrderListByJn(fsIntegralOrder);
|
|
|
} else {
|
|
|
- fsIntegralOrderListVOS = fsIntegralOrderService.selectFsIntegralOrderListVO(fsIntegralOrder);
|
|
|
+ list = fsIntegralOrderService.selectFsIntegralOrderListVO(fsIntegralOrder);
|
|
|
}
|
|
|
SysRole sysRole = isCheckPermission();
|
|
|
- // 处理商品名称:解析item_json并设置goodsName
|
|
|
- for (FsIntegralOrderListVO vo : fsIntegralOrderListVOS) {
|
|
|
- if (StringUtils.isNotEmpty(vo.getItemJson())) {
|
|
|
- try {
|
|
|
- // 尝试解析JSON格式的商品信息
|
|
|
- if (vo.getItemJson().startsWith("[")) {
|
|
|
- // 数组格式,遍历所有商品,用换行符分隔
|
|
|
- com.alibaba.fastjson.JSONArray jsonArray = com.alibaba.fastjson.JSONArray.parseArray(vo.getItemJson());
|
|
|
- if (jsonArray != null && !jsonArray.isEmpty()) {
|
|
|
- StringBuilder goodsNameBuilder = new StringBuilder();
|
|
|
- StringBuilder barCodeBuilder = new StringBuilder();
|
|
|
-
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- com.alibaba.fastjson.JSONObject goods = jsonArray.getJSONObject(i);
|
|
|
-
|
|
|
- // 处理商品名称和数量
|
|
|
- if (goods != null && goods.getString("goodsName") != null) {
|
|
|
- String name = goods.getString("goodsName");
|
|
|
- String num = goods.getString("num");
|
|
|
- if (StringUtils.isEmpty(num)) {
|
|
|
- num = "1"; // 默认数量为1
|
|
|
- }
|
|
|
- if (goodsNameBuilder.length() > 0) {
|
|
|
- goodsNameBuilder.append("\r\n");
|
|
|
- }
|
|
|
- goodsNameBuilder.append(name).append(",数量:").append(num).append("个");
|
|
|
- }
|
|
|
-
|
|
|
- // 处理商品编码
|
|
|
- if (goods != null && goods.getString("barCode") != null) {
|
|
|
- String barCode = goods.getString("barCode");
|
|
|
- if (barCodeBuilder.length() > 0) {
|
|
|
- barCodeBuilder.append("\r\n");
|
|
|
- }
|
|
|
- barCodeBuilder.append(barCode);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 设置商品名称
|
|
|
- if (goodsNameBuilder.length() > 0) {
|
|
|
- vo.setGoodsName(goodsNameBuilder.toString());
|
|
|
- }
|
|
|
-
|
|
|
- // 设置商品编码
|
|
|
- if (barCodeBuilder.length() > 0) {
|
|
|
- vo.setBarCode(barCodeBuilder.toString());
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (vo.getItemJson().startsWith("{")) {
|
|
|
- // 对象格式
|
|
|
- com.alibaba.fastjson.JSONObject goods = com.alibaba.fastjson.JSONObject.parseObject(vo.getItemJson());
|
|
|
-
|
|
|
- // 处理商品名称和数量
|
|
|
- if (goods != null && goods.getString("goodsName") != null) {
|
|
|
- String name = goods.getString("goodsName");
|
|
|
- String num = goods.getString("num");
|
|
|
- if (StringUtils.isEmpty(num)) {
|
|
|
- num = "1"; // 默认数量为1
|
|
|
- }
|
|
|
- vo.setGoodsName(name + ",数量:" + num + "个");
|
|
|
- }
|
|
|
-
|
|
|
- // 处理商品编码
|
|
|
- if (goods != null && goods.getString("barCode") != null) {
|
|
|
- vo.setBarCode(goods.getString("barCode"));
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- // 解析失败时保持goodsName为空,避免导出出错
|
|
|
- log.warn("解析商品信息失败,订单编号:{}, 商品信息:{}", vo.getOrderCode(), vo.getItemJson());
|
|
|
- }
|
|
|
- }
|
|
|
- if (!(sysRole.getIsCheckPhone()==1)){
|
|
|
- // 加密手机号
|
|
|
+ for (FsIntegralOrderListVO vo : list) {
|
|
|
+ fillCompanyUserName(vo);
|
|
|
+ parseItemJson(vo);
|
|
|
+ if (sysRole == null || sysRole.getIsCheckPhone() != 1) {
|
|
|
vo.setUserPhone(decryptAutoPhoneMk(vo.getUserPhone()));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
ExcelUtil<FsIntegralOrderListVO> util = new ExcelUtil<>(FsIntegralOrderListVO.class);
|
|
|
- return util.exportExcel(new ArrayList<>(fsIntegralOrderListVOS), "积分商品订单数据");
|
|
|
+ return util.exportExcel(new ArrayList<>(list), "积分商品订单数据");
|
|
|
}
|
|
|
|
|
|
- /*public AjaxResult export(FsIntegralOrderParam fsIntegralOrder) {
|
|
|
- List<FsIntegralOrderListVO> fsIntegralOrderListVOS = new ArrayList<>();
|
|
|
- if (CloudHostUtils.hasCloudHostName("金牛明医")){
|
|
|
- *//*目前只有金牛有状态为6的查询,其他项目避免使用6状态码*//*
|
|
|
- if (fsIntegralOrder.getStatus() != null && fsIntegralOrder.getStatus().equals("6")) {
|
|
|
- fsIntegralOrder.setStatus("1");
|
|
|
- fsIntegralOrder.setIsPush(0);
|
|
|
+ private void fillCompanyUserName(FsIntegralOrderListVO vo) {
|
|
|
+ if (vo.getUserId() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ FsUserCompanyUser userCompanyUser = iFsUserCompanyUserService.selectFsUserCompanyUserByUserId(vo.getUserId());
|
|
|
+ if (userCompanyUser != null && userCompanyUser.getCompanyUserId() != null) {
|
|
|
+ CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(userCompanyUser.getCompanyUserId());
|
|
|
+ if (companyUser != null && StringUtils.isNotEmpty(companyUser.getNickName())) {
|
|
|
+ vo.setCompanyUserName(companyUser.getNickName());
|
|
|
+ }
|
|
|
}
|
|
|
- fsIntegralOrderListVOS = fsIntegralOrderService.selectFsIntegralOrderListByJn(fsIntegralOrder);
|
|
|
- } else {
|
|
|
- fsIntegralOrderListVOS = fsIntegralOrderService.selectFsIntegralOrderListVO(fsIntegralOrder);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("查询销售名称失败,订单编号:{}, 用户ID:{}", vo.getOrderCode(), vo.getUserId());
|
|
|
}
|
|
|
- SysRole sysRole = isCheckPermission();
|
|
|
- // 处理商品名称:解析item_json并设置goodsName
|
|
|
- for (FsIntegralOrderListVO vo : fsIntegralOrderListVOS) {
|
|
|
- if (StringUtils.isNotEmpty(vo.getItemJson())) {
|
|
|
- try {
|
|
|
- // 尝试解析JSON格式的商品信息
|
|
|
- if (vo.getItemJson().startsWith("[")) {
|
|
|
- // 数组格式,取第一个商品
|
|
|
- com.alibaba.fastjson.JSONArray jsonArray = com.alibaba.fastjson.JSONArray.parseArray(vo.getItemJson());
|
|
|
- if (jsonArray != null && !jsonArray.isEmpty()) {
|
|
|
- com.alibaba.fastjson.JSONObject goods = jsonArray.getJSONObject(0);
|
|
|
- if (goods != null && goods.getString("goodsName") != null) {
|
|
|
- vo.setGoodsName(goods.getString("goodsName"));
|
|
|
- }
|
|
|
- if (goods != null && goods.getString("barCode") != null) {
|
|
|
- vo.setBarCode(goods.getString("barCode"));
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (vo.getItemJson().startsWith("{")) {
|
|
|
- // 对象格式
|
|
|
- com.alibaba.fastjson.JSONObject goods = com.alibaba.fastjson.JSONObject.parseObject(vo.getItemJson());
|
|
|
- if (goods != null && goods.getString("goodsName") != null) {
|
|
|
- vo.setGoodsName(goods.getString("goodsName"));
|
|
|
- }
|
|
|
- if (goods != null && goods.getString("barCode") != null) {
|
|
|
- vo.setGoodsName(goods.getString("barCode"));
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void parseItemJson(FsIntegralOrderListVO vo) {
|
|
|
+ if (StringUtils.isEmpty(vo.getItemJson())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (vo.getItemJson().startsWith("[")) {
|
|
|
+ com.alibaba.fastjson.JSONArray jsonArray = com.alibaba.fastjson.JSONArray.parseArray(vo.getItemJson());
|
|
|
+ if (jsonArray == null || jsonArray.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ StringBuilder goodsNameBuilder = new StringBuilder();
|
|
|
+ StringBuilder barCodeBuilder = new StringBuilder();
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ com.alibaba.fastjson.JSONObject goods = jsonArray.getJSONObject(i);
|
|
|
+ appendGoodsInfo(goods, goodsNameBuilder, barCodeBuilder);
|
|
|
+ }
|
|
|
+ if (goodsNameBuilder.length() > 0) {
|
|
|
+ vo.setGoodsName(goodsNameBuilder.toString());
|
|
|
+ }
|
|
|
+ if (barCodeBuilder.length() > 0) {
|
|
|
+ vo.setBarCode(barCodeBuilder.toString());
|
|
|
+ }
|
|
|
+ } else if (vo.getItemJson().startsWith("{")) {
|
|
|
+ com.alibaba.fastjson.JSONObject goods = com.alibaba.fastjson.JSONObject.parseObject(vo.getItemJson());
|
|
|
+ if (goods != null) {
|
|
|
+ if (goods.getString("goodsName") != null) {
|
|
|
+ vo.setGoodsName(goods.getString("goodsName") + ",数量:" + StringUtils.defaultString(goods.getString("num"), "1") + "个");
|
|
|
+ }
|
|
|
+ if (goods.getString("barCode") != null) {
|
|
|
+ vo.setBarCode(goods.getString("barCode"));
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- // 解析失败时保持goodsName为空,避免导出出错
|
|
|
- log.warn("解析商品信息失败,订单编号:{}, 商品信息:{}", vo.getOrderCode(), vo.getItemJson());
|
|
|
}
|
|
|
}
|
|
|
- if (!(sysRole.getIsCheckPhone()==1)){
|
|
|
- // 加密手机号
|
|
|
- vo.setUserPhone(decryptAutoPhoneMk(vo.getUserPhone()));
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("解析商品信息失败,订单编号:{}, 商品信息:{}", vo.getOrderCode(), vo.getItemJson());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ private void appendGoodsInfo(com.alibaba.fastjson.JSONObject goods, StringBuilder goodsNameBuilder, StringBuilder barCodeBuilder) {
|
|
|
+ if (goods == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
- ExcelUtil<FsIntegralOrderListVO> util = new ExcelUtil<>(FsIntegralOrderListVO.class);
|
|
|
- return util.exportExcel(new ArrayList<>(fsIntegralOrderListVOS), "积分商品订单数据");
|
|
|
- }*/
|
|
|
+ if (goods.getString("goodsName") != null) {
|
|
|
+ if (goodsNameBuilder.length() > 0) {
|
|
|
+ goodsNameBuilder.append("\r\n");
|
|
|
+ }
|
|
|
+ goodsNameBuilder.append(goods.getString("goodsName")).append(",数量:").append(StringUtils.defaultString(goods.getString("num"), "1")).append("个");
|
|
|
+ }
|
|
|
+ if (goods.getString("barCode") != null) {
|
|
|
+ if (barCodeBuilder.length() > 0) {
|
|
|
+ barCodeBuilder.append("\r\n");
|
|
|
+ }
|
|
|
+ barCodeBuilder.append(goods.getString("barCode"));
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 发货
|
|
|
*/
|