xin
2025-08-14 9b867103f0d53bf913bb4ea93687820d92ee0515
退款订单
7 files deleted
24 files modified
659 ■■■■■ changed files
oying-common/src/main/java/com/oying/utils/DateUtil.java 32 ●●●● patch | view | raw | blame | history
oying-common/src/main/java/com/oying/utils/RedisUtils.java 6 ●●●●● patch | view | raw | blame | history
oying-common/src/main/java/com/oying/utils/enums/GenerateEnum.java 16 ●●●● patch | view | raw | blame | history
oying-common/src/main/java/com/oying/utils/enums/OrderStatusEnum.java 30 ●●●●● patch | view | raw | blame | history
oying-common/src/main/java/com/oying/utils/enums/ReturnAuditEnum.java 4 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/security/config/SecurityProperties.java 5 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/Order.java 6 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/OrderOperationLog.java 4 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/OrderReturn.java 4 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/OrderReturnOperationLog.java 63 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderOperationLogQueryCriteria.java 3 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderReturnOperationLogQueryCriteria.java 30 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/domain/request/AuditOrderReturn.java 3 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/mapper/OrderOperationLogMapper.java 2 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/mapper/OrderReturnMapper.java 4 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/mapper/OrderReturnOperationLogMapper.java 24 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/rest/OrderOperationLogController.java 4 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/rest/OrderReturnOperationLogController.java 50 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/OrderOperationLogService.java 2 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/OrderReturnOperationLogService.java 61 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/OrderService.java 2 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java 7 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnOperationLogServiceImpl.java 84 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java 124 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java 18 ●●●● patch | view | raw | blame | history
oying-system/src/main/resources/config/application-dev.yml 2 ●●●●● patch | view | raw | blame | history
oying-system/src/main/resources/config/application-prod.yml 2 ●●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/sh/OrderMapper.xml 3 ●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/sh/OrderOperationLogMapper.xml 9 ●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/sh/OrderReturnMapper.xml 8 ●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/sh/OrderReturnOperationLogMapper.xml 47 ●●●●● patch | view | raw | blame | history
oying-common/src/main/java/com/oying/utils/DateUtil.java
@@ -17,16 +17,38 @@
    public static final DateTimeFormatter DFY_MD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    public static final DateTimeFormatter DFY_M = DateTimeFormatter.ofPattern("yyyy-MM");
    public static final DateTimeFormatter SDF_YMDHMS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
    public static final Integer DAY = 30;
    public static boolean isBefore(String date, int count) {
        LocalDateTime time = LocalDateTime.parse(date, SDF_YMDHMS);
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime nowPlus30 = time.plusDays(count);
        // 检查目标时间是否在 [time, time+count天] 区间内
        return !now.isBefore(time) && !now.isAfter(nowPlus30);
    }
    /**
     * Timestamp增加分钟
     * Timestamp增减天
     */
    public static Timestamp addMinute(Timestamp time, int month) {
    public static Timestamp addDay(Timestamp time, int count) {
        // 创建 Calendar 对象并设置为当前日期和时间的值
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(time.getTime());
        // 将MINUTE字段添加到当前日期和时间
        calendar.add(Calendar.MINUTE, month);
        calendar.add(Calendar.DATE, count);
        return new Timestamp(calendar.getTime().getTime());
    }
    /**
     * Timestamp增减分钟
     */
    public static Timestamp addMinute(Timestamp time, int count) {
        // 创建 Calendar 对象并设置为当前日期和时间的值
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(time.getTime());
        // 将MINUTE字段添加到当前日期和时间
        calendar.add(Calendar.MINUTE, count);
        return new Timestamp(calendar.getTime().getTime());
    }
@@ -128,6 +150,7 @@
    /**
     * 获取当前时间yyyyMMdd
     *
     * @return 、yyyyMMdd
     */
    public static String getNowTimeTypeYYYYMMDD() {
@@ -136,12 +159,13 @@
    /**
     * 获取当前时间yyyyMM
     *
     * @return 、yyyyMM
     */
    public static String getNowTimeTypeYYYYMM() {
        return DFY_M.format(LocalDateTime.now());
    }
    /**
     * 日期格式化 yyyy-MM-dd
     *
oying-common/src/main/java/com/oying/utils/RedisUtils.java
@@ -24,8 +24,6 @@
@SuppressWarnings({"unchecked", "all"})
public class RedisUtils {
    private static final Logger log = LoggerFactory.getLogger(RedisUtils.class);
    @Value("${jwt.generate-order-sn}")
    private String generateOrderSn;
    @Value("${wx.enabled}")
    private Boolean wxEnabled;
    private static final String T = "T-";
@@ -44,10 +42,10 @@
     * @param i
     * @return
     */
    public String generateOrderSn(Integer i) {
    public String generateSn(String generate, Integer i) {
        StringBuilder sb = new StringBuilder();
        String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
        String key = generateOrderSn + i + date;
        String key = generate + i + date;
        Long increment = increment(key);
        sb.append(date);
        sb.append(String.format("%04d", i));
oying-common/src/main/java/com/oying/utils/enums/GenerateEnum.java
@@ -13,15 +13,15 @@
public enum GenerateEnum {
    ORDER(10, "订单编号"),
    RETURN_ORDER(20, "退单编号"),
    ORDER_RETURN(20, "退单编号"),
    BUSINESS_NO(30,"未使用"),
    FREE_DEPOSIT(40,"未使用"),
    PENETRATE_ID(50,"未使用"),
    RETURN_FREE_DEPOSIT(60,"未使用"),
    CONTRACT_NUM(70,"未使用"),
    EIGHT(80,"未使用"),
    NINE(90,"未使用"),
    BUSINESS_NO(30, "未使用"),
    FREE_DEPOSIT(40, "未使用"),
    PENETRATE_ID(50, "未使用"),
    RETURN_FREE_DEPOSIT(60, "未使用"),
    CONTRACT_NUM(70, "未使用"),
    EIGHT(80, "未使用"),
    NINE(90, "未使用"),
    UNKNOWN(0, "未知枚举");
    private final Integer key;
oying-common/src/main/java/com/oying/utils/enums/OrderStatusEnum.java
@@ -7,21 +7,25 @@
@Getter
@AllArgsConstructor
public enum OrderStatusEnum {
    ZERO(0, "订单已提交"),
    ONE(1, "支付成功"),
    TWO(2, "商家已接单"),
    THREE(3, "骑手已接单"),
    FOUR(4, "商家已备货"),
    FIVE(5, "骑手已到店"),
    SIX(6, "骑手已取货,正在送货"),
    SEVEN(7, "商品已送达"),
    EIGHT(8, "订单已完成"),
    NINE(9, "取消订单"),
    TEN(10, "申请售后"),
    UNKNOWN(99, "未知枚举");
    ZERO(0, "ORDER", "订单已提交"),
    ONE(1, "ORDER", "支付成功"),
    TWO(2, "ORDER", "商家已接单"),
    THREE(3, "ORDER", "商家已备货"),
    FOUR(4, "ORDER", "骑手已接单"),
    FIVE(5, "ORDER", "骑手已到店"),
    SIX(6, "ORDER", "骑手已取货"),
    SEVEN(7, "ORDER", "商品已送达"),
    EIGHT(8, "ORDER", "订单已完成"),
    NINE(9, "ORDER", "订单已取消"),
    TEN(10, "REFUND", "申请退款"),
    ELEVEN(11, "REFUND", "申请拒绝"),
    TWELVE(12, "REFUND", "退款申诉"),
    THIRTEEN(13, "REFUND", "申请同意"),
    FOURTEEN(14, "REFUND", "退款成功"),
    UNKNOWN(99, "UNKNOWN", "未知枚举");
    private final Integer key;
    private final String code;
    private final String value;
    public static OrderStatusEnum find(Integer val) {
oying-common/src/main/java/com/oying/utils/enums/ReturnAuditEnum.java
@@ -13,8 +13,8 @@
public enum ReturnAuditEnum {
    ZERO(0, "申请"),
    ONE(1, "通过"),
    TWO(2, "拒绝"),
    ONE(1, "拒绝"),
    TWO(2, "通过"),
    THREE(3, "未知");
    private final Integer key;
oying-system/src/main/java/com/oying/modules/security/config/SecurityProperties.java
@@ -55,11 +55,6 @@
     */
    private Long renew;
    /**
     * 自定义redis key
     */
    private String generateOrderSn;
    public String getTokenStartWith() {
        return tokenStartWith + " ";
    }
oying-system/src/main/java/com/oying/modules/sh/domain/Order.java
@@ -9,6 +9,7 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects;
import java.util.Set;
@@ -56,9 +57,12 @@
    private String orderRemark;
    @NotBlank
    @ApiModelProperty(value = "预计送达时间")
    @ApiModelProperty(value = "送达预计时间")
    private String orderTime;
    @ApiModelProperty(value = "送达完成时间")
    private Timestamp orderFinishTime;
    @NotNull
    @ApiModelProperty(value = "打包费")
    private BigDecimal packagingPrice;
oying-system/src/main/java/com/oying/modules/sh/domain/OrderOperationLog.java
@@ -42,6 +42,10 @@
    private Integer operation = 0;
    @NotBlank
    @ApiModelProperty(value = "类型")
    private String operationType;
    @NotBlank
    @ApiModelProperty(value = "用户操作描述")
    private String operationDescribe = "提交订单";
oying-system/src/main/java/com/oying/modules/sh/domain/OrderReturn.java
@@ -115,7 +115,7 @@
    @ApiModelProperty(value = "实付金额")
    private BigDecimal actuallyPayPrice;
    @ApiModelProperty(value = "退款价格")
    @ApiModelProperty(value = "退款金额")
    private BigDecimal refundPrice;
    @ApiModelProperty(value = "退款状态")
@@ -127,7 +127,7 @@
    @ApiModelProperty(value = "退款渠道")
    private String channel;
    @ApiModelProperty(value = "退款原因")
    @ApiModelProperty(value = "退货类型")
    private String reason;
    @ApiModelProperty(value = "备注")
oying-system/src/main/java/com/oying/modules/sh/domain/OrderReturnOperationLog.java
File was deleted
oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderOperationLogQueryCriteria.java
@@ -24,6 +24,9 @@
    @ApiModelProperty(value = "用户类型")
    private String userType;
    @ApiModelProperty(value = "类型")
    private String operationType;
    @ApiModelProperty(value = "订单号")
    private String orderNum;
    private List<Timestamp> operationTime;
oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderReturnOperationLogQueryCriteria.java
File was deleted
oying-system/src/main/java/com/oying/modules/sh/domain/request/AuditOrderReturn.java
@@ -1,5 +1,6 @@
package com.oying.modules.sh.domain.request;
import com.oying.utils.enums.ReturnAuditEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -18,7 +19,7 @@
    @ApiModelProperty(value = "退单号")
    private String returnNum;
    @ApiModelProperty(value = "审核状态")
    private String auditStatus;
    private ReturnAuditEnum auditStatus;
    @ApiModelProperty(value = "备注")
    private String message;
    @ApiModelProperty(value = "金额")
oying-system/src/main/java/com/oying/modules/sh/mapper/OrderOperationLogMapper.java
@@ -20,5 +20,5 @@
    List<OrderOperationLog> findAll(@Param("criteria") OrderOperationLogQueryCriteria criteria);
    List<OrderOperationLog> getByOrderNum(String orderNum);
    List<OrderOperationLog> getByOrderNum(String orderNum, String type);
}
oying-system/src/main/java/com/oying/modules/sh/mapper/OrderReturnMapper.java
@@ -24,7 +24,9 @@
    OrderReturn getByReturnNum(String returnNum);
    void updatePayStatus(String returnNum, String status, String time);
    void updatePayStatus(String returnNum, String payState, String payTime);
    Long countAll(@Param("criteria") OrderReturnQueryCriteria criteria, @Param("blurry") String blurry);
    OrderReturn getByOrderNum(String orderNum, Integer status);
}
oying-system/src/main/java/com/oying/modules/sh/mapper/OrderReturnOperationLogMapper.java
File was deleted
oying-system/src/main/java/com/oying/modules/sh/rest/OrderOperationLogController.java
@@ -46,7 +46,7 @@
    @GetMapping("getByOrderNum")
    @ApiOperation("根据订单号查询订单操作日志")
    @PreAuthorize("@el.check('orderOperationLog:list')")
    public ResponseEntity<Object> queryOrderOperationLog(@RequestParam String orderNum) {
        return new ResponseEntity<>(R.success(orderOperationLogService.getByOrderNum(orderNum)), HttpStatus.OK);
    public ResponseEntity<Object> queryOrderOperationLog(@RequestParam String orderNum, @RequestParam String type) {
        return new ResponseEntity<>(R.success(orderOperationLogService.getByOrderNum(orderNum, type)), HttpStatus.OK);
    }
}
oying-system/src/main/java/com/oying/modules/sh/rest/OrderReturnOperationLogController.java
File was deleted
oying-system/src/main/java/com/oying/modules/sh/service/OrderOperationLogService.java
@@ -58,5 +58,5 @@
    */
    void download(List<OrderOperationLog> all, HttpServletResponse response) throws IOException;
    List<OrderOperationLog> getByOrderNum(String orderNum);
    List<OrderOperationLog> getByOrderNum(String orderNum, String type);
}
oying-system/src/main/java/com/oying/modules/sh/service/OrderReturnOperationLogService.java
File was deleted
oying-system/src/main/java/com/oying/modules/sh/service/OrderService.java
@@ -49,6 +49,8 @@
    OrderResponse getByOrderNum(String orderNum);
    Order queryByOrderNum(String orderNum);
    void operationLog(OrderResponse order, OrderStatusEnum stateEnum,String cardName);
    void updatePayStatus(String outTradeNo, PayStateEnum stateEnum, String payInfo, String timeEnd);
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java
@@ -47,8 +47,8 @@
    }
    @Override
    public List<OrderOperationLog> getByOrderNum(String orderNum) {
        return orderOperationLogMapper.getByOrderNum(orderNum);
    public List<OrderOperationLog> getByOrderNum(String orderNum, String type) {
        return orderOperationLogMapper.getByOrderNum(orderNum, type);
    }
    @Override
@@ -77,6 +77,7 @@
                log1.setUsername(username);
                log1.setUserType(userType);
                log1.setOperation(OrderStatusEnum.ONE.getKey());
                log1.setOperationType(OrderStatusEnum.ONE.getCode());
                log1.setOperationDescribe(OrderStatusEnum.ONE.getValue());
                log1.setRemark(username + ":" + time + ">" + OrderStatusEnum.ONE.getValue() + ":" + response.getOrder().getOrderNum());
                Map<String, Object> map1 = new LinkedHashMap<>();
@@ -104,6 +105,7 @@
                log2.setUsername(username);
                log2.setUserType(userType);
                log2.setOperation(statusEnum.getKey());
                log2.setOperationType(statusEnum.getCode());
                log2.setOperationDescribe(statusEnum.getValue());
                log2.setRemark(username + ":" + time + ">" + statusEnum.getValue() + ":" + response.getOrder().getOrderNum());
                Map<String, Object> map2 = new LinkedHashMap<>();
@@ -125,6 +127,7 @@
        resources.setUsername(username);
        resources.setUserType(userType);
        resources.setOperation(statusEnum.getKey());
        resources.setOperationType(statusEnum.getCode());
        resources.setOperationDescribe(statusEnum.getValue());
        resources.setRemark(username + ":" + time + ">" + statusEnum.getValue() + ":" + response.getOrder().getOrderNum());
        Map<String, Object> map = new LinkedHashMap<>();
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnOperationLogServiceImpl.java
File was deleted
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java
@@ -1,9 +1,17 @@
package com.oying.modules.sh.service.impl;
import com.oying.exception.BadRequestException;
import com.oying.modules.hwc.service.SwiftPassService;
import com.oying.modules.sh.domain.Order;
import com.oying.modules.sh.domain.OrderReturn;
import com.oying.modules.sh.domain.request.AuditOrderReturn;
import com.oying.modules.sh.domain.request.ReturnOrder;
import com.oying.utils.FileUtil;
import com.oying.modules.sh.service.OrderReturnProductSnapshotService;
import com.oying.modules.sh.service.OrderService;
import com.oying.utils.*;
import com.oying.utils.enums.GenerateEnum;
import com.oying.utils.enums.OrderStatusEnum;
import com.oying.utils.enums.PayTypeEnum;
import com.oying.utils.enums.ReturnAuditEnum;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,16 +21,11 @@
import com.oying.modules.sh.mapper.OrderReturnMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.oying.utils.PageUtil;
import java.util.List;
import java.util.Map;
import java.sql.Timestamp;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import com.oying.utils.PageResult;
/**
 * @author lixin
@@ -34,6 +37,11 @@
public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, OrderReturn> implements OrderReturnService {
    private final OrderReturnMapper orderReturnMapper;
    private final OrderService orderService;
    private final OrderReturnProductSnapshotService productSnapshotService;
    private final RedisUtils redisUtils;
    private final SwiftPassService swiftPassService;
    private static final String ORDER_RETURN_KEY = "oying:order:refund";
    @Override
    public PageResult<OrderReturn> queryAll(OrderReturnQueryCriteria criteria, Page<Object> page) {
@@ -60,8 +68,56 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void create(ReturnOrder resources) {
    public synchronized void create(ReturnOrder resources) {
        Order order = orderService.queryByOrderNum(resources.getOrderNum());
        if (order == null) {
            throw new BadRequestException("订单不存在!");
        }
        if (Objects.equals(order.getOrderStatus(), OrderStatusEnum.ZERO.getKey())) {
            throw new BadRequestException("订单未支付");
        }
        OrderReturn returnOrder1 = orderReturnMapper.getByOrderNum(resources.getOrderNum(), ReturnAuditEnum.ZERO.getKey());
        if (returnOrder1 != null) {
            throw new BadRequestException("退款订单已提交");
        }
        OrderReturn returnOrder2 = orderReturnMapper.getByOrderNum(resources.getOrderNum(), ReturnAuditEnum.TWO.getKey());
        if (returnOrder2 != null) {
            throw new BadRequestException("退款订单已处理");
        }
        if (!DateUtil.isBefore(order.getPayTime(), DateUtil.DAY)) {
            throw new BadRequestException("订单已超过售后有效期");
        }
        // 退款订单
        OrderReturn returnOrder = new OrderReturn();
        // 退款订单号
        String returnNum = redisUtils.generateSn(ORDER_RETURN_KEY, GenerateEnum.ORDER_RETURN.getKey());
        returnOrder.setReturnNum(returnNum);
        returnOrder.setReturnStatus(ReturnAuditEnum.ZERO.getKey());
        returnOrder.setReturnStatusDescribe(ReturnAuditEnum.ZERO.getValue());
        returnOrder.setOrderNum(resources.getOrderNum());
        returnOrder.setOrderTime(order.getOrderTime());
        returnOrder.setOrderStoreNum(order.getOrderStoreNum());
        returnOrder.setPackagingPrice(order.getPackagingPrice());
        returnOrder.setSendPrice(order.getSendPrice());
        returnOrder.setSendType(order.getSendType() != null ? order.getSendType() : null);
        returnOrder.setRiderId(order.getRiderId() != null ? order.getRiderId() : null);
        returnOrder.setRiderPhone(order.getRiderPhone() != null ? order.getRiderPhone() : null);
        returnOrder.setRiderName(order.getRiderName() != null ? order.getRiderName() : null);
        returnOrder.setPayType(order.getPayType());
        returnOrder.setUserId(order.getUserId());
        returnOrder.setUsername(order.getUsername());
        returnOrder.setStoreId(order.getStoreId());
        returnOrder.setStoreName(order.getStoreName());
        returnOrder.setStoreLogo(order.getStoreLogo());
        returnOrder.setOriginalPrice(order.getOriginalPrice());
        returnOrder.setPaidPrice(order.getPaidPrice());
        returnOrder.setActuallyPayPrice(order.getActuallyPayPrice());
        returnOrder.setReason(resources.getReason());
        returnOrder.setRemark(resources.getRemark());
        returnOrder.setPhotos(resources.getPhotos());
        returnOrder.setAuditStatus(ReturnAuditEnum.ZERO.getKey());
        orderReturnMapper.insert(returnOrder);
    }
    @Override
@@ -74,8 +130,50 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void audit(AuditOrderReturn resources) {
    public synchronized void audit(AuditOrderReturn resources) {
        OrderReturn orderReturn = orderReturnMapper.getByReturnNum(resources.getReturnNum());
        if (orderReturn == null) {
            throw new BadRequestException("订单不存在");
        }
        if (!Objects.equals(orderReturn.getReturnStatus(), ReturnAuditEnum.ZERO.getKey())) {
            throw new BadRequestException("订单已处理或取消");
        }
        if (resources.getAmount().compareTo(orderReturn.getActuallyPayPrice()) > 0) {
            throw new BadRequestException("退款金额超过订单金额");
        }
        switch (resources.getAuditStatus()) {
            case ONE:
                break;
            case TWO:
                long total = BigDecimalUtils.yuanToCents(orderReturn.getActuallyPayPrice());
                long refund = BigDecimalUtils.yuanToCents(resources.getAmount());
                orderReturn.setRefundPrice(resources.getAmount());
                PayTypeEnum status = PayTypeEnum.find(orderReturn.getPayType());
                switch (status) {
                    case HWC:
                    case HWC2:
                        if (refund > 0) {
                            Map<String, String> re = swiftPassService.refund(orderReturn.getReturnNum(), orderReturn.getOrderNum(),
                                    resources.getMessage(), refund, total, status);
                            orderReturn.setChannel(re.get("refund_channel"));
                        }
                        break;
                    default:
                        throw new BadRequestException("暂未开通其余支付模式");
                }
                break;
            default:
                throw new BadRequestException("审核状态错误");
        }
        // 审核状态
        orderReturn.setAuditStatus(resources.getAuditStatus().getKey());
        // 审核人
        orderReturn.setAuditUser(SecurityUtils.getCurrentUsername());
        // 审核时间
        orderReturn.setAuditTime(new Timestamp(System.currentTimeMillis()));
        // 审核信息
        orderReturn.setAuditMessage(resources.getMessage());
        orderReturnMapper.updateById(orderReturn);
    }
    @Override
@@ -100,7 +198,7 @@
            map.put("退款状态", orderReturn.getRefundStatus());
            map.put("退款成功时间", orderReturn.getSuccessTime());
            map.put("退款渠道", orderReturn.getChannel());
            map.put("退款原因", orderReturn.getReason());
            map.put("退货类型", orderReturn.getReason());
            map.put("备注", orderReturn.getRemark());
            map.put("图片", orderReturn.getPhotos());
            map.put("审核状态", ReturnAuditEnum.getValue(orderReturn.getAuditStatus()));
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java
@@ -54,7 +54,9 @@
    private final RedisUtils redisUtils;
    private final StoreService storeService;
    private final OrderOperationLogService operationLogService;
    private final static String DESCRIBE = "哦应:";
    private static final String DESCRIBE = "哦应:";
    private static final String ORDER_KEY = "oying:order";
    private static final String ORDER_STORE_KEY = "oying:order:store";
    @Override
    public PageResult<Order> queryAll(OrderQueryCriteria criteria, Page<Object> page) {
@@ -91,7 +93,8 @@
        if (!(address.getDistance().compareTo(BigDecimal.valueOf(store.getRadius())) <= 0)) {
            throw new BadRequestException("超出配送范围");
        }
        String orderNum = redisUtils.generateOrderSn(GenerateEnum.ORDER.getKey());
        // 订单号
        String orderNum = redisUtils.generateSn(ORDER_KEY, GenerateEnum.ORDER.getKey());
        // 总金额
        BigDecimal amount = BigDecimal.ZERO;
        // 商品快照
@@ -128,7 +131,7 @@
        // 订单信息
        Order order = new Order();
        order.setOrderNum(orderNum);
        order.setOrderStoreNum(redisUtils.generateOrderSn(Math.toIntExact(submit.getStoreId())).substring(orderNum.length() - 4));
        order.setOrderStoreNum(redisUtils.generateSn(ORDER_STORE_KEY, Math.toIntExact(submit.getStoreId())).substring(orderNum.length() - 4));
        order.setOrderStatus(OrderStatusEnum.ZERO.getKey());
        order.setOrderStatusDescribe(OrderStatusEnum.ZERO.getValue());
        order.setOrderRemark(submit.getRemark() != null ? submit.getRemark() : "");
@@ -172,7 +175,6 @@
        }
        OrderAddressSnapshot addressSnapshot = getOrderAddressSnapshot(orderNum, address);
        addressSnapshotService.save(addressSnapshot);
        orderMapper.insert(order);
@@ -265,7 +267,13 @@
    public OrderResponse getByOrderNum(String orderNum) {
        return new OrderResponse(orderMapper.getByOrderNum(orderNum),
                addressSnapshotService.queryByOrderNum(orderNum),
                operationLogService.getByOrderNum(orderNum));
                operationLogService.getByOrderNum(orderNum, null));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Order queryByOrderNum(String orderNum) {
        return orderMapper.getByOrderNum(orderNum);
    }
    @Override
oying-system/src/main/resources/config/application-dev.yml
@@ -89,8 +89,6 @@
  online-key: "online_token:"
  # 验证码
  code-key: "captcha_code:"
  # 自定义redis key
  generate-order-sn: oying:generate:sn
  # token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
  detect: 1800000
  # 续期时间范围,默认1小时,单位毫秒
oying-system/src/main/resources/config/application-prod.yml
@@ -93,8 +93,6 @@
  online-key: "online_token:"
  # 验证码
  code-key: "captcha_code:"
  # 自定义redis key
  generate-order-sn: oying:generate:sn
  # token 续期检查时间范围(默认30分钟,单位默认毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
  detect: 1800000
  # 续期时间范围,默认 1小时,这里单位毫秒
oying-system/src/main/resources/mapper/sh/OrderMapper.xml
@@ -9,6 +9,7 @@
        <result column="order_status_describe" property="orderStatusDescribe"/>
        <result column="order_remark" property="orderRemark"/>
        <result column="order_time" property="orderTime"/>
        <result column="order_finish_time" property="orderFinishTime"/>
        <result column="packaging_price" property="packagingPrice"/>
        <result column="send_price" property="sendPrice"/>
        <result column="send_type" property="sendType"/>
@@ -64,7 +65,7 @@
    <sql id="Base_Column_List">
        o.order_id, o.order_num, o.order_store_num, o.order_status, o.order_status_describe,
        o.order_remark, o.order_time, o.packaging_price, o.send_price, o.send_type, o.user_id, o.username, o.store_id,
        o.order_remark, o.order_time, o.order_finish_time, o.packaging_price, o.send_price, o.send_type, o.user_id, o.username, o.store_id,
        o.store_name, o.store_logo, o.store_address, o.store_longitude, o.store_latitude,
        o.order_describe, o.original_price order_original_price, o.paid_price order_paid_price,
        o.actually_pay_price order_actually_pay_price, o.pay_state order_pay_state, o.pay_message, o.pay_type, o.pay_time, o.expire_time,
oying-system/src/main/resources/mapper/sh/OrderOperationLogMapper.xml
@@ -6,6 +6,7 @@
        <result column="username" property="username"/>
        <result column="user_type" property="userType"/>
        <result column="operation" property="operation"/>
        <result column="operation_type" property="operationType"/>
        <result column="operation_describe" property="operationDescribe"/>
        <result column="remark" property="remark"/>
        <result column="snapshot_data" property="snapshotData"/>
@@ -14,7 +15,7 @@
    </resultMap>
    <sql id="Base_Column_List">
        log_id, username, user_type, operation, operation_describe, remark, snapshot_data, operation_time, order_num
        log_id, username, user_type, operation, operation_type, operation_describe, remark, snapshot_data, operation_time, order_num
    </sql>
    <select id="findAll" resultMap="BaseResultMap">
@@ -41,6 +42,10 @@
        select
        <include refid="Base_Column_List"/>
        from sh_order_operation_log
        where order_num = #{orderNum} order by log_id
        where order_num = #{orderNum}
        <if test="type!= null and type != ''">
            operation_type = #{type}
        </if>
        order by log_id
    </select>
</mapper>
oying-system/src/main/resources/mapper/sh/OrderReturnMapper.xml
@@ -134,7 +134,7 @@
        update sh_order_return
        set return_status = #{payState},
            success_time  = #{payTime}
        where order_num = #{orderNum}
        where return_num = #{returnNum}
    </update>
    <select id="findAll" resultMap="BaseResultMap">
@@ -173,4 +173,10 @@
        <include refid="Where_Sql_Product"/>
        ) t
    </select>
    <select id="getByOrderNum" resultType="com.oying.modules.sh.domain.OrderReturn">
        select
        <include refid="Base_Column_List"/>
        from sh_order_return as o
        where o.order_num = #{orderNum} and o.audit_status = #{status}
    </select>
</mapper>
oying-system/src/main/resources/mapper/sh/OrderReturnOperationLogMapper.xml
File was deleted