活动 置空问题
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.ysk.cashier.mybatis.mapper.TbActivateMapper;
|
|||||||
import cn.ysk.cashier.mybatis.service.TbActivateService;
|
import cn.ysk.cashier.mybatis.service.TbActivateService;
|
||||||
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
|
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -44,7 +45,15 @@ public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActiv
|
|||||||
@Override
|
@Override
|
||||||
public void modifyActivate(TbActivate activate) {
|
public void modifyActivate(TbActivate activate) {
|
||||||
if (Objects.nonNull(activate.getId()) && activate.getId() > 0) {
|
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 {
|
} else {
|
||||||
activateMapper.insert(activate);
|
activateMapper.insert(activate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ public class TbShopShareRecordServiceImpl extends ServiceImpl<TbShopShareRecordM
|
|||||||
TbShopShare shopShare = tbShopShareMapper.selectById(shareRecord.getShareId());
|
TbShopShare shopShare = tbShopShareMapper.selectById(shareRecord.getShareId());
|
||||||
TbShopUser tbShopUser = shopUserRepository.selectByUserIdAndShopId(userId.toString(), shopShare.getShopId().toString());
|
TbShopUser tbShopUser = shopUserRepository.selectByUserIdAndShopId(userId.toString(), shopShare.getShopId().toString());
|
||||||
if (userId.equals(shareRecord.getInvitedId())) {
|
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())) {
|
} 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) {
|
for (TbShopShare.ShareCoupons newCoupon : coupons) {
|
||||||
TbShopCoupon tbShopCoupon = couponMapper.selectById(newCoupon.getCouponId());
|
TbShopCoupon tbShopCoupon = couponMapper.selectById(newCoupon.getCouponId());
|
||||||
Date start = new Date();
|
Date start = new Date();
|
||||||
@@ -89,6 +89,7 @@ public class TbShopShareRecordServiceImpl extends ServiceImpl<TbShopShareRecordM
|
|||||||
record.setOverNum(newCoupon.getCouponNum());
|
record.setOverNum(newCoupon.getCouponNum());
|
||||||
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
|
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
|
||||||
record.setSourceActId(shopShare.getId());
|
record.setSourceActId(shopShare.getId());
|
||||||
|
record.setSourceFlowId(flowId);
|
||||||
record.setUseStartTime(start);
|
record.setUseStartTime(start);
|
||||||
record.setUseEndTime(end);
|
record.setUseEndTime(end);
|
||||||
if(isReward){
|
if(isReward){
|
||||||
@@ -111,6 +112,7 @@ public class TbShopShareRecordServiceImpl extends ServiceImpl<TbShopShareRecordM
|
|||||||
record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber());
|
record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber());
|
||||||
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
|
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
|
||||||
record.setSourceActId(shopShare.getId());
|
record.setSourceActId(shopShare.getId());
|
||||||
|
record.setSourceFlowId(flowId);
|
||||||
record.setUseStartTime(start);
|
record.setUseStartTime(start);
|
||||||
record.setUseEndTime(end);
|
record.setUseEndTime(end);
|
||||||
if(isReward){
|
if(isReward){
|
||||||
|
|||||||
Reference in New Issue
Block a user