活动 置空问题

This commit is contained in:
2024-11-14 10:34:35 +08:00
parent 1d2ef2fdf5
commit 47fd21e1d1
2 changed files with 15 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import cn.ysk.cashier.mybatis.mapper.TbActivateMapper;
import cn.ysk.cashier.mybatis.service.TbActivateService;
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -44,7 +45,15 @@ public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActiv
@Override
public void modifyActivate(TbActivate activate) {
if (Objects.nonNull(activate.getId()) && activate.getId() > 0) {
activateMapper.updateById(activate);
UpdateWrapper<TbActivate> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", activate.getId()).setEntity(activate);
if (Objects.isNull(activate.getCouponId())) {
updateWrapper.set("couponId", null);
}
if (Objects.isNull(activate.getGiftPoints())) {
updateWrapper.set("giftPoints", null);
}
activateMapper.update(updateWrapper);
} else {
activateMapper.insert(activate);
}

View File

@@ -54,14 +54,14 @@ public class TbShopShareRecordServiceImpl extends ServiceImpl<TbShopShareRecordM
TbShopShare shopShare = tbShopShareMapper.selectById(shareRecord.getShareId());
TbShopUser tbShopUser = shopUserRepository.selectByUserIdAndShopId(userId.toString(), shopShare.getShopId().toString());
if (userId.equals(shareRecord.getInvitedId())) {
giveCoupon(shopShare, tbShopUser, shopShare.getRewardCoupons(), true);
giveCoupon(shopShare, tbShopUser, shopShare.getRewardCoupons(),shareRecord.getId(), true);
} else if (userId.equals(shareRecord.getBeInvitedId())) {
giveCoupon(shopShare, tbShopUser, shopShare.getNewCoupons(),true);
giveCoupon(shopShare, tbShopUser, shopShare.getNewCoupons(),shareRecord.getId(),false);
}
}
public void giveCoupon(TbShopShare shopShare, TbShopUser tbShopUser, List<TbShopShare.ShareCoupons> coupons, boolean isReward) {
public void giveCoupon(TbShopShare shopShare, TbShopUser tbShopUser, List<TbShopShare.ShareCoupons> coupons ,Integer flowId, boolean isReward) {
for (TbShopShare.ShareCoupons newCoupon : coupons) {
TbShopCoupon tbShopCoupon = couponMapper.selectById(newCoupon.getCouponId());
Date start = new Date();
@@ -89,6 +89,7 @@ public class TbShopShareRecordServiceImpl extends ServiceImpl<TbShopShareRecordM
record.setOverNum(newCoupon.getCouponNum());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setSourceActId(shopShare.getId());
record.setSourceFlowId(flowId);
record.setUseStartTime(start);
record.setUseEndTime(end);
if(isReward){
@@ -111,6 +112,7 @@ public class TbShopShareRecordServiceImpl extends ServiceImpl<TbShopShareRecordM
record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setSourceActId(shopShare.getId());
record.setSourceFlowId(flowId);
record.setUseStartTime(start);
record.setUseEndTime(end);
if(isReward){