feat:修改优惠券加不进去问题

This commit is contained in:
luluyuyu 2024-12-14 21:48:09 +08:00
parent 2b8d85a75f
commit 4862fd4367
3 changed files with 10 additions and 21 deletions

View file

@ -26,5 +26,4 @@ public interface CouponService extends SkyeyeBusinessService<Coupon> {
void queryCouponListByMaterialId(InputObject inputObject, OutputObject outputObject);
Integer getUseCount(String couponId);
}

View file

@ -5,7 +5,6 @@
package com.skyeye.coupon.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -138,7 +137,7 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl<CouponDao, Coup
@Override
public void createPostpose(Coupon entity, String userId) {
if (CollectionUtil.isNotEmpty(entity.getStoreIdList())) {// 优惠券关联门店
couponStoreService.createEntity(entity.getId(),entity.getStoreIdList());
couponStoreService.createEntity(entity.getId(), entity.getStoreIdList());
}
if (StrUtil.isNotEmpty(entity.getTemplateId())) {// 优惠券
if (Objects.equals(entity.getValidityType(), CouponValidityType.DATE.getKey())) {
@ -215,7 +214,7 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl<CouponDao, Coup
String type = params.get("type").toString();
List<CouponStore> couponStoreList = couponStoreService.queryListByStoreId(storeId);
List<String> couponIdList = couponStoreList.stream().map(CouponStore::getCouponId).distinct().collect(Collectors.toList());
if(CollectionUtil.isEmpty(couponIdList)){
if (CollectionUtil.isEmpty(couponIdList)) {
return;
}
queryWrapper.in(CommonConstants.ID, couponIdList);
@ -276,15 +275,6 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl<CouponDao, Coup
outputObject.settotal(list.size());
}
@Override
public Integer getUseCount(String couponId) {
Coupon coupon = selectById(couponId);
if (ObjUtil.isEmpty(coupon)) {
throw new CustomException("优惠券不存在");
}
return coupon.getUseCount();
}
private void setDrawState(List<Coupon> list) {
if (CollectionUtil.isEmpty(list)) return;
List<String> couponIdList = list.stream().map(Coupon::getId).collect(Collectors.toList());

View file

@ -142,10 +142,10 @@ public class CouponUseServiceImpl extends SkyeyeBusinessServiceImpl<CouponUseDao
public void createPostpose(CouponUse couponUse, String userId) {
// 更新优惠券领取数量
couponService.updateTakeCount(couponUse.getCouponId(), couponUse.getCouponMation().getTakeCount() + 1);
Integer useCount = couponService.getUseCount(couponUse.getCouponId());
couponUse.setUsageCount(useCount);
// 新增优惠券可使用的商品信息
couponUseMaterialService.createEntity(couponUse.getCouponUseMaterialList(), userId);
Coupon coupon = couponService.selectById(couponUse.getCouponId());
couponUse.setUsageCount(coupon.getUseCount());
// 定时任务
Coupon couponMation = couponUse.getCouponMation();
if (Objects.equals(couponMation.getValidityType(), CouponValidityType.TERM.getKey())) {