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