|
@@ -10,12 +10,14 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.fs.common.constant.FsConstants;
|
|
import com.fs.common.constant.FsConstants;
|
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.ServiceException;
|
|
import com.fs.common.exception.ServiceException;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
|
+import com.fs.common.utils.poi.ExcelUtil;
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
@@ -29,6 +31,7 @@ import com.fs.his.service.IFsIntegralCartService;
|
|
import com.fs.his.service.IFsIntegralOrderService;
|
|
import com.fs.his.service.IFsIntegralOrderService;
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
import com.fs.his.service.IFsUserIntegralLogsService;
|
|
import com.fs.his.service.IFsUserIntegralLogsService;
|
|
|
|
+import com.fs.his.utils.PhoneUtil;
|
|
import com.fs.his.vo.FsIntegralOrderListUVO;
|
|
import com.fs.his.vo.FsIntegralOrderListUVO;
|
|
import com.fs.his.vo.FsIntegralOrderListVO;
|
|
import com.fs.his.vo.FsIntegralOrderListVO;
|
|
import com.fs.his.vo.FsIntegralOrderPVO;
|
|
import com.fs.his.vo.FsIntegralOrderPVO;
|
|
@@ -41,6 +44,7 @@ import com.fs.ybPay.dto.OrderQueryDTO;
|
|
import com.fs.ybPay.service.IPayService;
|
|
import com.fs.ybPay.service.IPayService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -596,4 +600,82 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public AjaxResult export(FsIntegralOrder fsIntegralOrder) {
|
|
|
|
+ List<FsIntegralOrder> list = fsIntegralOrderMapper.selectFsIntegralOrderList(fsIntegralOrder);
|
|
|
|
+
|
|
|
|
+ // 使用Set避免重复数据
|
|
|
|
+ Set<FsIntegralOrder> fsIntegralOrderSet = new LinkedHashSet<>();
|
|
|
|
+
|
|
|
|
+ for (FsIntegralOrder order : list) {
|
|
|
|
+ // 处理手机号脱敏
|
|
|
|
+ processPhoneNumber(order);
|
|
|
|
+
|
|
|
|
+ // 处理商品信息
|
|
|
|
+ processGoodsInfo(order, fsIntegralOrderSet);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExcelUtil<FsIntegralOrder> util = new ExcelUtil<>(FsIntegralOrder.class);
|
|
|
|
+ return util.exportExcel(new ArrayList<>(fsIntegralOrderSet), "积分商品订单数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 处理手机号脱敏
|
|
|
|
+ */
|
|
|
|
+ private void processPhoneNumber(FsIntegralOrder order) {
|
|
|
|
+ String userPhone = order.getUserPhone();
|
|
|
|
+ if (StringUtils.isNotBlank(userPhone) && !userPhone.chars().allMatch(Character::isDigit)) {
|
|
|
|
+ order.setUserPhone(PhoneUtil.decryptPhone(userPhone));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 处理商品信息
|
|
|
|
+ */
|
|
|
|
+ private void processGoodsInfo(FsIntegralOrder order, Set<FsIntegralOrder> resultSet) {
|
|
|
|
+ String itemJson = order.getItemJson();
|
|
|
|
+ if (StringUtils.isBlank(itemJson)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // 判断是否为数组格式
|
|
|
|
+ if (itemJson.startsWith("[") && itemJson.endsWith("]")) {
|
|
|
|
+ // 数组格式 - 多个商品
|
|
|
|
+ List<FsIntegralGoods> goodsList = JSONUtil.toBean(itemJson,
|
|
|
|
+ new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
|
+
|
|
|
|
+ for (FsIntegralGoods goods : goodsList) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(goods)) {
|
|
|
|
+ FsIntegralOrder newOrder = cloneOrder(order);
|
|
|
|
+ newOrder.setGoodsName(goods.getGoodsName());
|
|
|
|
+ newOrder.setOtPrice(goods.getOtPrice());
|
|
|
|
+ resultSet.add(newOrder);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 单商品格式
|
|
|
|
+ FsIntegralGoods goods = JSONUtil.toBean(itemJson, FsIntegralGoods.class);
|
|
|
|
+ if (ObjectUtil.isNotEmpty(goods)) {
|
|
|
|
+ order.setGoodsName(goods.getGoodsName());
|
|
|
|
+ order.setOtPrice(goods.getOtPrice());
|
|
|
|
+ resultSet.add(order);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // JSON解析异常处理,可以根据需要记录日志
|
|
|
|
+ log.warn("解析商品JSON数据失败,orderId: {}, json: {}", order.getOrderId(), itemJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 克隆订单对象(用于多商品情况)
|
|
|
|
+ */
|
|
|
|
+ private FsIntegralOrder cloneOrder(FsIntegralOrder original) {
|
|
|
|
+ // 这里需要根据实际情况实现对象的深拷贝或浅拷贝
|
|
|
|
+ // 以下是简单示例,实际项目中可能需要使用BeanUtils或序列化方式
|
|
|
|
+ FsIntegralOrder cloned = new FsIntegralOrder();
|
|
|
|
+ BeanUtils.copyProperties(original, cloned);
|
|
|
|
+ return cloned;
|
|
|
|
+ }
|
|
}
|
|
}
|