Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松 2025-09-25 17:40:35 +08:00
commit aafe9937a8
1 changed files with 13 additions and 2 deletions

View File

@ -6,9 +6,13 @@ import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService;
import com.czg.constant.TableValueConstant;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException;
import com.czg.market.entity.MkConsumeDiscountRandom;
import com.czg.market.service.MkConsumeDiscountService;
import com.czg.market.vo.MkConsumeDiscountVO;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoService;
import com.czg.service.market.enums.OrderStatusEnums;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
@ -31,16 +35,23 @@ import java.util.Random;
* @since 2025-09-17
*/
@Service
public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopConsumeDiscountRecordMapper, MkShopConsumeDiscountRecord> implements MkShopConsumeDiscountRecordService{
public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopConsumeDiscountRecordMapper, MkShopConsumeDiscountRecord> implements MkShopConsumeDiscountRecordService {
@Resource
private MkConsumeDiscountService consumeDiscountService;
@DubboReference
private ShopUserService shopUserService;
@DubboReference
private OrderInfoService orderInfoService;
@Override
public void useDiscount(Long recordId, Long shopUserId, Long orderId, BigDecimal amount) {
AssertUtil.isTrue(recordId == null || shopUserId == null || orderId == null || amount == null, "参数不能为空");
ShopUser shopUser = shopUserService.getById(shopUserId);
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE));
if (count > 0) {
throw new CzgException("新客立减仅新用户可用");
}
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getId, recordId)
.eq(MkShopConsumeDiscountRecord::getShopUserId, shopUserId)
.eq(MkShopConsumeDiscountRecord::getOrderId, orderId));