|
|
@@ -5,10 +5,12 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
@@ -138,6 +140,95 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
|
|
|
return fsGuCoinOrderMapper.selectFsGuCoinOrderList(param);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult export(FsGuCoinOrderParam param) {
|
|
|
+ List<FsGuCoinOrder> list = fsGuCoinOrderMapper.selectFsGuCoinOrderList(param);
|
|
|
+ // 解析商品信息JSON,按商品拆行;同时处理手机号脱敏
|
|
|
+ List<FsGuCoinOrder> exportList = new ArrayList<>();
|
|
|
+ for (FsGuCoinOrder order : list) {
|
|
|
+ if (StringUtils.isNotEmpty(order.getUserPhone()) && order.getUserPhone().length() > 11) {
|
|
|
+ order.setUserPhone(decryptPhone(order.getUserPhone()));
|
|
|
+ }
|
|
|
+ processGoodsInfo(order, exportList);
|
|
|
+ }
|
|
|
+ ExcelUtil<FsGuCoinOrder> util = new ExcelUtil<>(FsGuCoinOrder.class);
|
|
|
+ return util.exportExcel(exportList, "谷币订单数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析itemJson,按商品拆分订单行(同积分订单导出逻辑)
|
|
|
+ */
|
|
|
+ private void processGoodsInfo(FsGuCoinOrder order, List<FsGuCoinOrder> exportList) {
|
|
|
+ String itemJson = order.getItemJson();
|
|
|
+ if (StringUtils.isBlank(itemJson)) {
|
|
|
+ exportList.add(order);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (itemJson.startsWith("[") && itemJson.endsWith("]")) {
|
|
|
+ // 数组格式 - 多个商品按行拆分
|
|
|
+ JSONArray goodsArray = JSONUtil.parseArray(itemJson);
|
|
|
+ List<FsGuCoinGoods> goodsList = JSONUtil.toList(goodsArray, FsGuCoinGoods.class);
|
|
|
+ for (FsGuCoinGoods goods : goodsList) {
|
|
|
+ if (ObjectUtil.isNotEmpty(goods)) {
|
|
|
+ FsGuCoinOrder newOrder = cloneOrder(order);
|
|
|
+ newOrder.setGoodsName(goods.getGoodsName());
|
|
|
+ newOrder.setNum(goods.getNum());
|
|
|
+ exportList.add(newOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 单商品格式
|
|
|
+ FsGuCoinGoods goods = JSONUtil.toBean(itemJson, FsGuCoinGoods.class);
|
|
|
+ if (ObjectUtil.isNotEmpty(goods)) {
|
|
|
+ order.setGoodsName(goods.getGoodsName());
|
|
|
+ order.setNum(goods.getNum());
|
|
|
+ }
|
|
|
+ exportList.add(order);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("解析itemJson失败, orderCode={}, itemJson={}", order.getOrderCode(), itemJson, e);
|
|
|
+ exportList.add(order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 浅拷贝订单(保留基础字段,用于按商品拆行)
|
|
|
+ */
|
|
|
+ private FsGuCoinOrder cloneOrder(FsGuCoinOrder source) {
|
|
|
+ FsGuCoinOrder target = new FsGuCoinOrder();
|
|
|
+ target.setOrderId(source.getOrderId());
|
|
|
+ target.setOrderCode(source.getOrderCode());
|
|
|
+ target.setUserId(source.getUserId());
|
|
|
+ target.setUserName(source.getUserName());
|
|
|
+ target.setUserPhone(source.getUserPhone());
|
|
|
+ target.setUserAddress(source.getUserAddress());
|
|
|
+ target.setItemJson(source.getItemJson());
|
|
|
+ target.setTotalGuCoin(source.getTotalGuCoin());
|
|
|
+ target.setDiscountGuCoin(source.getDiscountGuCoin());
|
|
|
+ target.setGuCoin(source.getGuCoin());
|
|
|
+ target.setTotalMoney(source.getTotalMoney());
|
|
|
+ target.setDiscountMoney(source.getDiscountMoney());
|
|
|
+ target.setPayMoney(source.getPayMoney());
|
|
|
+ target.setDeliveryMoney(source.getDeliveryMoney());
|
|
|
+ target.setIsPay(source.getIsPay());
|
|
|
+ target.setPayTime(source.getPayTime());
|
|
|
+ target.setPayType(source.getPayType());
|
|
|
+ target.setStatus(source.getStatus());
|
|
|
+ target.setBarCode(source.getBarCode());
|
|
|
+ target.setDeliveryCode(source.getDeliveryCode());
|
|
|
+ target.setDeliveryName(source.getDeliveryName());
|
|
|
+ target.setDeliverySn(source.getDeliverySn());
|
|
|
+ target.setDeliveryTime(source.getDeliveryTime());
|
|
|
+ target.setQwUserId(source.getQwUserId());
|
|
|
+ target.setCompanyUserId(source.getCompanyUserId());
|
|
|
+ target.setCompanyId(source.getCompanyId());
|
|
|
+ target.setLoginAccount(source.getLoginAccount());
|
|
|
+ target.setRemark(source.getRemark());
|
|
|
+ target.setCreateTime(source.getCreateTime());
|
|
|
+ return target;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<FsGuCoinOrder> selectFsGuCoinOrderListU(FsGuCoinOrderListUParam param) {
|
|
|
return fsGuCoinOrderMapper.selectFsGuCoinOrderListU(param);
|
|
|
@@ -324,7 +415,7 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
|
|
|
} else {
|
|
|
// 纯谷币
|
|
|
order.setPayType(1);
|
|
|
- order.setStatus(1); // 待发货
|
|
|
+ order.setStatus(0); // 待审核
|
|
|
order.setIsPay(1);
|
|
|
order.setPayTime(new Date());
|
|
|
}
|
|
|
@@ -477,14 +568,14 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
|
|
|
}
|
|
|
order.setCreateTime(new Date());
|
|
|
|
|
|
- // 用户自助下单:纯谷币=待发货,混合支付=待支付(与 createOrder 一致)
|
|
|
+ // 用户自助下单:纯谷币=待审核,混合支付=待支付(与 createOrder 一致)
|
|
|
if (totalCash.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
order.setPayType(totalGuCoin > 0 ? 3 : 2);
|
|
|
order.setStatus(4); // 待支付
|
|
|
order.setIsPay(0);
|
|
|
} else {
|
|
|
order.setPayType(1);
|
|
|
- order.setStatus(1); // 待发货
|
|
|
+ order.setStatus(0); // 待审核
|
|
|
order.setIsPay(1);
|
|
|
order.setPayTime(new Date());
|
|
|
}
|
|
|
@@ -628,14 +719,14 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
|
|
|
}
|
|
|
order.setCreateTime(new Date());
|
|
|
|
|
|
- // 代下单统一为待发货(销售线下收款,无需在线支付)
|
|
|
+ // 代下单统一为待审核(销售线下收款,无需在线支付,需审核后发货)
|
|
|
// 支付类型仅作展示记录:纯谷币=1,纯现金=2,谷币+现金=3
|
|
|
if (totalCash.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
order.setPayType(totalGuCoin > 0 ? 3 : 2);
|
|
|
} else {
|
|
|
order.setPayType(1);
|
|
|
}
|
|
|
- order.setStatus(1); // 待发货
|
|
|
+ order.setStatus(0); // 待审核
|
|
|
order.setIsPay(1);
|
|
|
order.setPayTime(new Date());
|
|
|
|
|
|
@@ -782,7 +873,7 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
|
|
|
}
|
|
|
|
|
|
order.setIsPay(1);
|
|
|
- order.setStatus(1); // 待发货
|
|
|
+ order.setStatus(0); // 待审核
|
|
|
order.setPayTime(new Date());
|
|
|
fsGuCoinOrderMapper.updateFsGuCoinOrder(order);
|
|
|
log.info("谷币商城订单支付成功 orderCode={}, userId={}", order.getOrderCode(), order.getUserId());
|
|
|
@@ -1054,4 +1145,29 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
|
|
|
String phone = "19331276912";
|
|
|
return StrUtil.sub(phone, phone.length(), -4);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核谷币订单(待审核 → 待发货)
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R auditGuCoinOrder(Long orderId, String auditor) {
|
|
|
+ FsGuCoinOrder order = fsGuCoinOrderMapper.selectFsGuCoinOrderByOrderId(orderId);
|
|
|
+ if (order == null) {
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if (order.getStatus() != null && order.getStatus() != 0) {
|
|
|
+ return R.error("订单不是待审核状态,无法审核");
|
|
|
+ }
|
|
|
+ FsGuCoinOrder update = new FsGuCoinOrder();
|
|
|
+ update.setOrderId(orderId);
|
|
|
+ update.setStatus(1); // 待发货
|
|
|
+ update.setAuditor(auditor);
|
|
|
+ update.setAuditTime(new Date());
|
|
|
+ int result = fsGuCoinOrderMapper.updateFsGuCoinOrder(update);
|
|
|
+ if (result > 0) {
|
|
|
+ return R.ok("审核成功");
|
|
|
+ }
|
|
|
+ return R.error("审核失败");
|
|
|
+ }
|
|
|
}
|