|
|
@@ -29,12 +29,14 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.fs.his.utils.PhoneUtil.decryptAutoPhoneMk;
|
|
|
import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
|
@@ -45,6 +47,7 @@ import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
|
* @author fs
|
|
|
* @date 2023-11-02
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/his/integralOrder")
|
|
|
public class FsIntegralOrderController extends BaseController
|
|
|
@@ -84,11 +87,26 @@ public class FsIntegralOrderController extends BaseController
|
|
|
fsIntegralOrder.setStatus("1");
|
|
|
fsIntegralOrder.setIsPush(0);
|
|
|
}
|
|
|
- List<FsIntegralOrderListVO> list = fsIntegralOrderService.selectFsIntegralOrderListByJn(fsIntegralOrder);
|
|
|
- for (FsIntegralOrderListVO vo : list) {
|
|
|
- vo.setUserPhone(decryptAutoPhoneMk(vo.getUserPhone()));
|
|
|
+
|
|
|
+ // 金牛明医项目:支持多个订单ID查询
|
|
|
+ if (fsIntegralOrder.getOrderCodes() != null && !fsIntegralOrder.getOrderCodes().isEmpty()) {
|
|
|
+ // 如果传了orderIds参数,使用新的查询逻辑
|
|
|
+ List<FsIntegralOrder> orders = fsIntegralOrderService.selectFsIntegralOrderByOrderIdsv2(fsIntegralOrder.getOrderCodes());
|
|
|
+ List<FsIntegralOrderListVO> list = orders.stream()
|
|
|
+ .map(this::convertOrderToListVO)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (FsIntegralOrderListVO vo : list) {
|
|
|
+ vo.setUserPhone(decryptAutoPhoneMk(vo.getUserPhone()));
|
|
|
+ }
|
|
|
+ return getDataTable(list);
|
|
|
+ } else {
|
|
|
+ // 原有逻辑:单个orderId或其他条件查询
|
|
|
+ List<FsIntegralOrderListVO> list = fsIntegralOrderService.selectFsIntegralOrderListByJn(fsIntegralOrder);
|
|
|
+ for (FsIntegralOrderListVO vo : list) {
|
|
|
+ vo.setUserPhone(decryptAutoPhoneMk(vo.getUserPhone()));
|
|
|
+ }
|
|
|
+ return getDataTable(list);
|
|
|
}
|
|
|
- return getDataTable(list);
|
|
|
}
|
|
|
List<FsIntegralOrderListVO> list = fsIntegralOrderService.selectFsIntegralOrderListVO(fsIntegralOrder);
|
|
|
for (FsIntegralOrderListVO vo : list) {
|
|
|
@@ -112,6 +130,37 @@ public class FsIntegralOrderController extends BaseController
|
|
|
param.setStatus("1");
|
|
|
param.setIsPush(0);
|
|
|
List<FsIntegralOrderListVO> fsIntegralOrderListVOS = fsIntegralOrderService.selectFsIntegralOrderListByJn(param);
|
|
|
+
|
|
|
+ // 处理商品名称:解析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"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 解析失败时保持goodsName为空,避免导出出错
|
|
|
+ log.warn("解析商品信息失败,订单编号:{}, 商品信息:{}", vo.getOrderCode(), vo.getItemJson());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 解密手机号
|
|
|
+ vo.setUserPhone(decryptAutoPhoneMk(vo.getUserPhone()));
|
|
|
+ }
|
|
|
+
|
|
|
ExcelUtil<FsIntegralOrderListVO> util = new ExcelUtil<>(FsIntegralOrderListVO.class);
|
|
|
return util.exportExcel(new ArrayList<>(fsIntegralOrderListVOS), "积分商品订单数据");
|
|
|
}
|
|
|
@@ -410,4 +459,33 @@ public class FsIntegralOrderController extends BaseController
|
|
|
}
|
|
|
return df;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将 FsIntegralOrder 转换为 FsIntegralOrderListVO
|
|
|
+ * @param order 积分订单实体
|
|
|
+ * @return 转换后的VO对象
|
|
|
+ */
|
|
|
+ private FsIntegralOrderListVO convertOrderToListVO(FsIntegralOrder order) {
|
|
|
+ FsIntegralOrderListVO vo = new FsIntegralOrderListVO();
|
|
|
+ vo.setOrderId(order.getOrderId());
|
|
|
+ vo.setOrderCode(order.getOrderCode());
|
|
|
+ vo.setUserId(order.getUserId());
|
|
|
+ vo.setUserName(order.getUserName());
|
|
|
+ vo.setUserPhone(order.getUserPhone());
|
|
|
+ vo.setUserAddress(order.getUserAddress());
|
|
|
+ vo.setItemJson(order.getItemJson());
|
|
|
+ vo.setIntegral(order.getIntegral());
|
|
|
+ vo.setStatus(order.getStatus() != null ? order.getStatus().toString() : null);
|
|
|
+ vo.setDeliveryCode(order.getDeliveryCode());
|
|
|
+ vo.setDeliveryName(order.getDeliveryName());
|
|
|
+ vo.setDeliverySn(order.getDeliverySn());
|
|
|
+ vo.setDeliveryTime(order.getDeliveryTime());
|
|
|
+ vo.setCreateTime(order.getCreateTime());
|
|
|
+ vo.setQwUserId(order.getQwUserId());
|
|
|
+ vo.setCompanyUserId(order.getCompanyUserId());
|
|
|
+ vo.setCompanyId(order.getCompanyId());
|
|
|
+ vo.setPayMoney(order.getPayMoney());
|
|
|
+ vo.setLoginAccount(order.getLoginAccount());
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|