fix: 优惠券使用状态不正确修复

This commit is contained in:
张松 2024-11-11 14:20:57 +08:00
parent 98ca9d50bc
commit 586bede415
3 changed files with 5 additions and 4 deletions

View File

@ -69,7 +69,7 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
* @param orderId 订单id
* @param status 状态 可为空
*/
List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status);
boolean updateMemberAndAmountByOrderId(Integer orderId, boolean isMember);

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.cons.TableConstant;
@ -131,10 +132,10 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
}
@Override
public List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status status) {
public List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status) {
LambdaQueryChainWrapper<TbCashierCart> queryChainWrapper = lambdaQuery().eq(TbCashierCart::getOrderId, orderId);
if (status != null) {
queryChainWrapper.eq(TbCashierCart::getStatus, status.getValue());
queryChainWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(status));
}
return queryChainWrapper.list();
}

View File

@ -405,7 +405,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
throw new BadRequestException("用户信息不存在");
}
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId, null);
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.CLOSED);
List<TbUserCouponVo> activateCouponList = getActivateCoupon(shopUser, orderInfo.getOrderAmount(), shopId, cashierCarts.stream().map(TbCashierCart::getProductId).collect(Collectors.toSet()));
// 将优惠券分类为满减和商品
ArrayList<TbUserCouponVo> fullReductionCoupon = new ArrayList<>();