update:
1.fix update_time autofill
This commit is contained in:
@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.cache.DictCache;
|
||||
import org.springblade.common.cache.PaymentCache;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.api.request.PaymentRequest;
|
||||
@@ -146,19 +147,18 @@ public class IPaymentServiceImpl implements IPaymentService {
|
||||
}
|
||||
|
||||
userPointService.spendPointForOrder(userOrder);
|
||||
boolean updated = commonUserOrderService.update(Wrappers.lambdaUpdate(CommonUserOrderEntity.class)
|
||||
.set(CommonUserOrderEntity::getOrderStatus, OrderStatus.PAID.getCode())
|
||||
.set(CommonUserOrderEntity::getPaymentStatus, PaymentStatus.PAID.getCode())
|
||||
.set(CommonUserOrderEntity::getPaymentTime, new Date())
|
||||
.eq(CommonUserOrderEntity::getId, userOrder.getId())
|
||||
.eq(CommonUserOrderEntity::getPaymentType, PaymentType.USER_POINT.getCode())
|
||||
.eq(CommonUserOrderEntity::getOrderStatus, OrderStatus.PENDING_PAYMENT.getCode())
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, PaymentStatus.UNPAID.getCode())
|
||||
.eq(CommonUserOrderEntity::getIsDeleted, 0));
|
||||
if (!updated){
|
||||
if (userOrder.getOrderStatus().equals(OrderStatus.PENDING_PAYMENT.getCode()) && userOrder.getPaymentStatus().equals(PaymentStatus.UNPAID.getCode()) && userOrder.getPaymentType().equals(PaymentType.USER_POINT.getCode()) && userOrder.getIsDeleted().equals(0)) {
|
||||
userOrder.setPaymentStatus(PaymentStatus.PAID.getCode());
|
||||
userOrder.setOrderStatus(OrderStatus.PAID.getCode());
|
||||
userOrder.setPaymentTime(DateUtil.now());
|
||||
userOrder.setUpdateTime(DateUtil.now());
|
||||
boolean updated = commonUserOrderService.saveOrUpdate(userOrder);
|
||||
if (!updated) {
|
||||
throw new ServiceException("支付失败");
|
||||
}
|
||||
eventPublisher.publishEvent(new PaymentSuccessEvent(orderId, userId, BusinessModule.fromCodeIgnoreCaseOrNull(userOrder.getOrderType())));
|
||||
return true;
|
||||
}
|
||||
throw new ServiceException("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package org.springblade.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.modules.api.request.ConfirmOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateMallOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateTravelOrderRequest;
|
||||
@@ -53,7 +54,7 @@ import java.util.List;
|
||||
* @author RayLiu
|
||||
* @since 2026-02-06
|
||||
*/
|
||||
public interface ICommonUserOrderService extends IService<CommonUserOrderEntity> {
|
||||
public interface ICommonUserOrderService extends BaseService<CommonUserOrderEntity> {
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
|
||||
@@ -25,11 +25,9 @@
|
||||
*/
|
||||
package org.springblade.modules.common.service.impl;
|
||||
|
||||
import io.jsonwebtoken.lang.Assert;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.redis.debounce.DebounceClient;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.modules.api.request.LotteryDrawRequest;
|
||||
import org.springblade.modules.api.vo.CommonLotteryPrizeApiVO;
|
||||
@@ -62,8 +60,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@AllArgsConstructor
|
||||
public class CommonLotteryPrizeServiceImpl extends BaseServiceImpl<CommonLotteryPrizeMapper, CommonLotteryPrizeEntity> implements ICommonLotteryPrizeService {
|
||||
|
||||
private final DebounceClient debounceClient;
|
||||
|
||||
private final ICommonUserPointService userPointService;
|
||||
|
||||
private final IMarketCashCouponService cashCouponService;
|
||||
|
||||
@@ -36,11 +36,9 @@ import org.springblade.modules.common.pojo.entity.CommonUserNoticeEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonUserNoticeVO;
|
||||
import org.springblade.modules.common.mapper.CommonUserNoticeMapper;
|
||||
import org.springblade.modules.common.service.ICommonUserNoticeService;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
@@ -55,8 +53,6 @@ import java.util.Objects;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CommonUserNoticeServiceImpl extends BaseServiceImpl<CommonUserNoticeMapper, CommonUserNoticeEntity> implements ICommonUserNoticeService {
|
||||
private final IUserService userService;
|
||||
private final static long PAGE_SIZE = 1000L;
|
||||
|
||||
@Override
|
||||
public IPage<CommonUserNoticeVO> selectUserNoticePage(IPage<CommonUserNoticeVO> page, CommonUserNoticeVO userNotice) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.modules.api.request.ConfirmOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateMallOrderRequest;
|
||||
@@ -84,7 +85,7 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMapper, CommonUserOrderEntity> implements ICommonUserOrderService {
|
||||
public class CommonUserOrderServiceImpl extends BaseServiceImpl<CommonUserOrderMapper, CommonUserOrderEntity> implements ICommonUserOrderService {
|
||||
|
||||
private final IMallProductService productService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
@@ -206,7 +207,7 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
if (product.getStatus() != 1) {
|
||||
throw new ServiceException("商品已下架");
|
||||
}
|
||||
if (request.getPaymentType() == PaymentType.ALI.getCode() || request.getPaymentType() == PaymentType.WECHAT.getCode()){
|
||||
if (request.getPaymentType() == PaymentType.ALI.getCode() || request.getPaymentType() == PaymentType.WECHAT.getCode()) {
|
||||
discount = BigDecimal.valueOf(new Random().nextInt(99) + 1, 2);
|
||||
}
|
||||
CommonUserOrderEntity order = AppCommonConvert.INSTANCE.convertMallProductToOrder(request, product);
|
||||
@@ -218,7 +219,6 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
order.setActualAmount(actualAmount);
|
||||
order.setOrderType(orderType);
|
||||
order.setPaymentType(request.getPaymentType());
|
||||
order.setCreateTime(new Date());
|
||||
save(order);
|
||||
return new CreateOrderResponse(String.valueOf(order.getId()), actualAmount, totalAmount, discount);
|
||||
|
||||
@@ -229,7 +229,7 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
|
||||
BigDecimal discount = BigDecimal.ZERO;
|
||||
String orderType = request.getOrderType().toUpperCase();
|
||||
if (request.getPaymentType() == PaymentType.ALI.getCode() || request.getPaymentType() == PaymentType.WECHAT.getCode()){
|
||||
if (request.getPaymentType() == PaymentType.ALI.getCode() || request.getPaymentType() == PaymentType.WECHAT.getCode()) {
|
||||
discount = BigDecimal.valueOf(new Random().nextInt(99) + 1, 2);
|
||||
}
|
||||
|
||||
@@ -429,26 +429,23 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
@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())
|
||||
.set(CommonUserOrderEntity::getUpdateTime, new Date())
|
||||
.eq(CommonUserOrderEntity::getId, id)
|
||||
.eq(CommonUserOrderEntity::getOrderStatus, OrderStatus.PAID.getCode())
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, PaymentStatus.PAID.getCode())
|
||||
.eq(CommonUserOrderEntity::getIsDeleted, 0)
|
||||
);
|
||||
CommonUserOrderEntity userOrder = getById(id);
|
||||
if (userOrder == null) {
|
||||
throw new ServiceException("无效订单");
|
||||
}
|
||||
if (userOrder.getOrderStatus().equals(OrderStatus.PAID.getCode()) && userOrder.getPaymentStatus().equals(PaymentStatus.PAID.getCode()) && userOrder.getIsDeleted().equals(0)) {
|
||||
userOrder.setExpressNo(expressNo);
|
||||
userOrder.setOrderStatus(OrderStatus.SHIPPED.getCode());
|
||||
userOrder.setUpdateTime(new Date());
|
||||
boolean updated = updateById(userOrder);
|
||||
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));
|
||||
|
||||
eventPublisher.publishEvent(new FillExpressEvent(id, userOrder.getUserId(), BusinessModule.SELF_OPERATED_MALL));
|
||||
return true;
|
||||
}
|
||||
throw new ServiceException("操作失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -460,11 +457,12 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
if (!BusinessModule.fromCodeIgnoreCaseOrNull(order.getOrderType()).equals(BusinessModule.SELF_OPERATED_MALL)) {
|
||||
throw new ServiceException("无效业务订单");
|
||||
}
|
||||
boolean updated = update(Wrappers.lambdaUpdate(CommonUserOrderEntity.class)
|
||||
.set(CommonUserOrderEntity::getOrderStatus, OrderStatus.COMPLETED.getCode())
|
||||
.set(CommonUserOrderEntity::getUpdateTime, new Date())
|
||||
.eq(CommonUserOrderEntity::getId, order.getId())
|
||||
.eq(CommonUserOrderEntity::getOrderStatus, OrderStatus.SHIPPED.getCode()));
|
||||
if (!order.getOrderStatus().equals(OrderStatus.SHIPPED.getCode())) {
|
||||
throw new ServiceException("无效订单状态");
|
||||
}
|
||||
order.setOrderStatus(OrderStatus.COMPLETED.getCode());
|
||||
order.setUpdateTime(new Date());
|
||||
boolean updated = this.updateById(order);
|
||||
if (!updated) {
|
||||
throw new ServiceException("无效订单");
|
||||
}
|
||||
@@ -499,7 +497,7 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
public CreateOrderResponse createEcoOrder(CreateMallOrderRequest request) {
|
||||
BigDecimal discount = BigDecimal.ZERO;
|
||||
String orderType = request.getOrderType().toUpperCase();
|
||||
if (request.getPaymentType() == PaymentType.ALI.getCode() || request.getPaymentType() == PaymentType.WECHAT.getCode()){
|
||||
if (request.getPaymentType() == PaymentType.ALI.getCode() || request.getPaymentType() == PaymentType.WECHAT.getCode()) {
|
||||
discount = BigDecimal.valueOf(new Random().nextInt(99) + 1, 2);
|
||||
}
|
||||
if (!BusinessModule.fromCodeIgnoreCaseOrNull(orderType).equals(BusinessModule.ECOSYSTEM_PRODUCT)) {
|
||||
@@ -611,6 +609,7 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
}
|
||||
userOrder.setOrderStatus(OrderStatus.CLOSED_TIMEOUT.getCode());
|
||||
userOrder.setPaymentStatus(PaymentStatus.FAILED.getCode());
|
||||
userOrder.setUpdateTime(new Date());
|
||||
return updateById(userOrder);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user