update:
1. 新增快递单号填写并更改订单状态
This commit is contained in:
@@ -172,7 +172,7 @@ public class CommonUserOrderController extends BladeController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/exportOrderToExcel")
|
||||
@GetMapping("/export-order-to-excel")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "导出用户订单")
|
||||
public void exportFlowToExcel(@RequestParam String account , @RequestParam List<String> searchDateRange , HttpServletResponse response) {
|
||||
@@ -188,5 +188,15 @@ public class CommonUserOrderController extends BladeController {
|
||||
return R.data(commonUserManager.importUserBackOrder(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户订单 填写快递
|
||||
*/
|
||||
@PostMapping("/fill-express")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "填写快递", description = "传入order")
|
||||
public R fillExpress(@Valid @RequestBody CommonUserOrderEntity order) {
|
||||
return R.status(orderService.fillExpress(order.getId(), order.getExpressNo()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.springblade.modules.common.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class FillExpressEvent {
|
||||
|
||||
private final Long orderId;
|
||||
|
||||
private final Long userId;
|
||||
|
||||
private final BusinessModule businessModule;
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.modules.common.eums.NoticeType;
|
||||
import org.springblade.modules.common.eums.OrderStatus;
|
||||
import org.springblade.modules.common.eums.UserPointFlowType;
|
||||
import org.springblade.modules.common.event.FillExpressEvent;
|
||||
import org.springblade.modules.common.event.GrantUserPointEvent;
|
||||
import org.springblade.modules.common.event.PaymentSuccessEvent;
|
||||
import org.springblade.modules.common.event.SpendUserPointEvent;
|
||||
@@ -128,4 +129,21 @@ public class NoticeListener {
|
||||
log.warn("用户动态升级事务回滚,userId={}", event.getNoticeItems());
|
||||
}
|
||||
|
||||
|
||||
@Async
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
public void onFillExpress(FillExpressEvent event) {
|
||||
CommonUserNoticeEntity notice = new CommonUserNoticeEntity();
|
||||
notice.setUserId(event.getUserId());
|
||||
notice.setNoticeType(NoticeType.APP_USER.getCode());
|
||||
notice.setModuleType(event.getBusinessModule().getCode());
|
||||
notice.setTitle(event.getBusinessModule().getDisplayName());
|
||||
notice.setContent(OrderStatus.SHIPPED.formatUserMessage(String.valueOf(event.getOrderId())));
|
||||
noticeService.save(notice);
|
||||
}
|
||||
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_ROLLBACK)
|
||||
public void onFillExpressFailure(FillExpressEvent event) {
|
||||
log.warn("支付事务回滚,orderId={}", event.getOrderId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,4 +76,5 @@ public interface ICommonUserOrderService extends IService<CommonUserOrderEntity>
|
||||
|
||||
boolean confirmPayment(Long id);
|
||||
|
||||
boolean fillExpress(Long id, String expressNo);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import io.jsonwebtoken.lang.Assert;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.redis.debounce.RedisDebounce;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.modules.api.request.CreateOrderRequest;
|
||||
@@ -42,6 +43,8 @@ import org.springblade.modules.common.convert.AppCommonConvert;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.eums.OrderStatus;
|
||||
import org.springblade.modules.common.eums.PaymentStatus;
|
||||
import org.springblade.modules.common.eums.PaymentType;
|
||||
import org.springblade.modules.common.event.FillExpressEvent;
|
||||
import org.springblade.modules.common.event.PaymentSuccessEvent;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonUserOrderVO;
|
||||
@@ -85,10 +88,10 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
@Override
|
||||
public IPage<CommonUserOrderVO> selectOrderPage(IPage<CommonUserOrderVO> page, CommonUserOrderVO order) {
|
||||
|
||||
if (order.getSearchDateRange() != null){
|
||||
if (order.getSearchDateRange() != null) {
|
||||
order.setStartDate(DateUtil.convertFromString(order.getSearchDateRange().get(0), "yyyy-MM-dd hh:mm:ss"));
|
||||
order.setEndDate(DateUtil.convertFromString(order.getSearchDateRange().get(1), "yyyy-MM-dd hh:mm:ss"));
|
||||
if (order.getStartDate().getTime() >= order.getEndDate().getTime()){
|
||||
if (order.getStartDate().getTime() >= order.getEndDate().getTime()) {
|
||||
throw new RuntimeException("开始时间不能大于结束时间");
|
||||
}
|
||||
}
|
||||
@@ -97,9 +100,9 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonUserOrderVO> exportUserOrderToExcel(Long userId , Date startDate , Date endDate) {
|
||||
public List<CommonUserOrderVO> exportUserOrderToExcel(Long userId, Date startDate, Date endDate) {
|
||||
|
||||
return baseMapper.selectOrderExcelList(userId, startDate , endDate);
|
||||
return baseMapper.selectOrderExcelList(userId, startDate, endDate);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,9 +180,9 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
.set(CommonUserOrderEntity::getPaymentStatus, PaymentStatus.PAID.getCode())
|
||||
.set(CommonUserOrderEntity::getPaymentTime, new Date())
|
||||
.eq(CommonUserOrderEntity::getId, id)
|
||||
.eq(CommonUserOrderEntity::getPaymentType, 99)
|
||||
.eq(CommonUserOrderEntity::getOrderStatus, 0)
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, 0)
|
||||
.eq(CommonUserOrderEntity::getPaymentType, PaymentType.OFFLINE.getCode())
|
||||
.eq(CommonUserOrderEntity::getOrderStatus, OrderStatus.PENDING_PAYMENT.getCode())
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, PaymentStatus.UNPAID.getCode())
|
||||
.eq(CommonUserOrderEntity::getIsDeleted, 0)
|
||||
);
|
||||
if (!updated) {
|
||||
@@ -198,5 +201,26 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean fillExpress(Long id, String expressNo) {
|
||||
boolean updated = update(Wrappers.<CommonUserOrderEntity>lambdaUpdate()
|
||||
.set(CommonUserOrderEntity::getExpressNo, expressNo)
|
||||
.set(CommonUserOrderEntity::getOrderStatus, OrderStatus.SHIPPED.getCode())
|
||||
.eq(CommonUserOrderEntity::getId, id)
|
||||
.eq(CommonUserOrderEntity::getOrderStatus, OrderStatus.PAID.getCode())
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, PaymentStatus.PAID.getCode())
|
||||
.eq(CommonUserOrderEntity::getIsDeleted, 0)
|
||||
);
|
||||
if (!updated) {
|
||||
throw new ServiceException("状态更新无效,id=" + id);
|
||||
}
|
||||
CommonUserOrderEntity order = getById(id);
|
||||
if (order == null) {
|
||||
throw new IllegalStateException("订单更新成功但查询不到,id=" + id);
|
||||
}
|
||||
eventPublisher.publishEvent(new FillExpressEvent(id, order.getUserId(), BusinessModule.SELF_OPERATED_MALL));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user