trade:发货逻辑,增加订单日志

This commit is contained in:
YunaiV 2023-09-27 09:55:04 +08:00
parent 53bd1b9ec1
commit 26dfbfb2ac
3 changed files with 15 additions and 6 deletions

View File

@ -14,7 +14,8 @@ import lombok.RequiredArgsConstructor;
public enum TradeOrderOperateTypeEnum {
MEMBER_CREATE(1, "用户下单"),
MEMBER_PAY(20, "用户付款成功"),
MEMBER_PAY(10, "用户付款成功"),
ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"),
MEMBER_RECEIVE(30, "用户已收货"),
SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"),
MEMBER_COMMENT(33, "用户评价"),

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.order;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
@ -40,6 +41,7 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettle
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper;
@ -412,6 +414,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override
@Transactional(rollbackFor = Exception.class)
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL)
public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) {
// 1.1 校验并获得交易订单可发货
TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
@ -423,8 +426,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// 2. 更新订单为已发货
TradeOrderDO updateOrderObj = new TradeOrderDO();
// 2.1 快递发货
DeliveryExpressDO express = null;
if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) {
deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
} else {
// 2.2 无需发货
@ -437,11 +441,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
}
// 发送站内信
// 3. 记录订单日志
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(),
MapUtil.<String, Object>builder().put("expressName", express != null ? express.getName() : "")
.put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build());
// 4. 发送站内信
tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId())
.setUserId(order.getUserId()).setMessage(null));
// TODO 芋艿OrderLog
}
/**
@ -468,6 +475,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// 订单类类型砍价
if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) {
// 校验订单砍价是否成功
// TODO @puhui999砍价的话应该不用校验因为是砍价成功后才可以下单
if (!bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) {
throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS);
}

View File

@ -78,7 +78,7 @@ spring:
# Quartz 配置项,对应 QuartzProperties 配置类
spring:
quartz:
auto-startup: false # 本地开发环境,尽量不要开启 Job
auto-startup: true # 本地开发环境,尽量不要开启 Job
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true