Sfoglia il codice sorgente

谷物订单添加审核

wangxy 1 settimana fa
parent
commit
032012205c

+ 25 - 0
fs-company/src/main/java/com/fs/hisStore/controller/FsGuCoinOrderController.java

@@ -55,6 +55,19 @@ public class FsGuCoinOrderController extends BaseController
         return getDataTable(list);
     }
 
+    /**
+     * 导出谷币订单列表
+     */
+    @PreAuthorize("@ss.hasPermi('his:guCoinOrder:export')")
+    @Log(title = "谷币订单", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsGuCoinOrderParam param)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setCompanyId(loginUser.getUser().getCompanyId());
+        return fsGuCoinOrderService.export(param);
+    }
+
     /**
      * 获取谷币订单详细信息
      */
@@ -101,6 +114,18 @@ public class FsGuCoinOrderController extends BaseController
         return R.ok().put("data", fsGuCoinOrderService.getExpress(orderId));
     }
 
+    /**
+     * 审核谷币订单(待审核 → 待发货)
+     *
+     */
+    @PreAuthorize("@ss.hasPermi('his:guCoinOrder:audit')")
+    @Log(title = "谷币订单审核", businessType = BusinessType.UPDATE)
+    @PostMapping("/audit/{orderId}")
+    public R audit(@PathVariable("orderId") Long orderId) {
+        String auditor = SecurityUtils.getLoginUser().getUser().getUserName();
+        return fsGuCoinOrderService.auditGuCoinOrder(orderId, auditor);
+    }
+
     /**
      * 同步谷币订单物流状态
      */

+ 26 - 9
fs-service/src/main/java/com/fs/his/domain/FsGuCoinOrder.java

@@ -44,9 +44,18 @@ public class FsGuCoinOrder
     private String userAddress;
 
     /** 商品信息JSON */
-    @Excel(name = "商品信息")
     private String itemJson;
 
+    /** 商品名称(导出用,非数据库字段) */
+    @TableField(exist = false)
+    @Excel(name = "商品名称")
+    private String goodsName;
+
+    /** 购买数量(导出用,非数据库字段) */
+    @TableField(exist = false)
+    @Excel(name = "购买数量")
+    private Long num;
+
     /** 订单总谷币 */
     private Long totalGuCoin;
 
@@ -71,21 +80,31 @@ public class FsGuCoinOrder
     private BigDecimal deliveryMoney;
 
     /** 是否支付 0未支付 1已支付 */
-    @Excel(name = "是否支付 0未支付 1已支付")
+    @Excel(name = "是否支付", readConverterExp = "0=未支付,1=已支付")
     private Integer isPay;
 
     /** 支付时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "支付时间")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date payTime;
 
     /** 支付类型 1谷币 2现金 3谷币+现金 */
-    @Excel(name = "支付类型 1谷币 2现金 3谷币+现金")
+    @Excel(name = "支付类型", readConverterExp = "1=谷币,2=现金,3=谷币+现金")
     private Integer payType;
-    /** 1待发货 2待收货 3已完成 4待支付 5取消 */
-    @Excel(name = "状态")
+
+    /** 0待审核 1待发货 2待收货 3已完成 4待支付 5取消 */
+    @Excel(name = "订单状态", readConverterExp = "0=待审核,1=待发货,2=待收货,3=已完成,4=待支付,5=取消")
     private Integer status;
 
+    /** 审核人 */
+    @Excel(name = "审核人")
+    private String auditor;
+
+    /** 审核时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date auditTime;
+
     @Excel(name = "商品编号")
     private String barCode;
 
@@ -107,15 +126,12 @@ public class FsGuCoinOrder
     private Date deliveryTime;
 
     /** 企业微信ID */
-    @Excel(name = "企业微信ID")
     private Long qwUserId;
 
     /** 销售ID */
-    @Excel(name = "销售ID")
     private Long companyUserId;
 
     /** 销售公司ID */
-    @Excel(name = "销售公司ID")
     private Long companyId;
 
     private String loginAccount;
@@ -123,6 +139,7 @@ public class FsGuCoinOrder
     private String remark;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

+ 13 - 0
fs-service/src/main/java/com/fs/his/service/IFsGuCoinOrderService.java

@@ -1,5 +1,6 @@
 package com.fs.his.service;
 
+import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.domain.FsGuCoinOrder;
@@ -29,6 +30,11 @@ public interface IFsGuCoinOrderService {
 
     public List<FsGuCoinOrder> selectFsGuCoinOrderList(FsGuCoinOrderParam param);
 
+    /**
+     * 导出谷币订单列表
+     */
+    AjaxResult export(FsGuCoinOrderParam param);
+
     public int insertFsGuCoinOrder(FsGuCoinOrder fsGuCoinOrder);
 
     public int updateFsGuCoinOrder(FsGuCoinOrder fsGuCoinOrder);
@@ -111,4 +117,11 @@ public interface IFsGuCoinOrderService {
      * 同步谷币订单物流状态
      */
     R syncExpress(Long orderId);
+
+    /**
+     * 审核谷币订单(待审核 → 待发货)
+     * @param orderId  订单id
+     * @param auditor  审核人姓名
+     */
+    R auditGuCoinOrder(Long orderId, String auditor);
 }

+ 122 - 6
fs-service/src/main/java/com/fs/his/service/impl/FsGuCoinOrderServiceImpl.java

@@ -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("审核失败");
+    }
 }

+ 8 - 0
fs-service/src/main/resources/mapper/his/FsGuCoinOrderMapper.xml

@@ -23,6 +23,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="payTime"         column="pay_time"          />
         <result property="payType"         column="pay_type"          />
         <result property="status"          column="status"            />
+        <result property="auditor"         column="auditor"           />
+        <result property="auditTime"       column="audit_time"        />
         <result property="barCode"         column="bar_code"          />
         <result property="deliveryCode"    column="delivery_code"     />
         <result property="deliveryName"    column="delivery_name"     />
@@ -110,6 +112,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="payTime != null">pay_time,</if>
             <if test="payType != null">pay_type,</if>
             <if test="status != null">status,</if>
+            <if test="auditor != null">auditor,</if>
+            <if test="auditTime != null">audit_time,</if>
             <if test="barCode != null">bar_code,</if>
             <if test="deliveryCode != null">delivery_code,</if>
             <if test="deliveryName != null">delivery_name,</if>
@@ -141,6 +145,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="payTime != null">#{payTime},</if>
             <if test="payType != null">#{payType},</if>
             <if test="status != null">#{status},</if>
+            <if test="auditor != null">#{auditor},</if>
+            <if test="auditTime != null">#{auditTime},</if>
             <if test="barCode != null">#{barCode},</if>
             <if test="deliveryCode != null">#{deliveryCode},</if>
             <if test="deliveryName != null">#{deliveryName},</if>
@@ -166,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="payTime != null">pay_time = #{payTime},</if>
             <if test="payType != null">pay_type = #{payType},</if>
             <if test="status != null">status = #{status},</if>
+            <if test="auditor != null">auditor = #{auditor},</if>
+            <if test="auditTime != null">audit_time = #{auditTime},</if>
             <if test="deliveryCode != null">delivery_code = #{deliveryCode},</if>
             <if test="deliveryName != null">delivery_name = #{deliveryName},</if>
             <if test="deliverySn != null">delivery_sn = #{deliverySn},</if>