Commit dae6d0ea by 吕明尚

增加抽奖接口

parent e19e942a
...@@ -72,4 +72,6 @@ public interface ConsumerWalletService extends IService<ConsumerWallet> { ...@@ -72,4 +72,6 @@ public interface ConsumerWalletService extends IService<ConsumerWallet> {
void accumulatedConsumptionStatistics(Long consumerId); void accumulatedConsumptionStatistics(Long consumerId);
int giveDuration(ConsumerWallet consumerWallet); int giveDuration(ConsumerWallet consumerWallet);
public int giveIntegral(ConsumerWallet consumerWallet);
} }
...@@ -529,4 +529,58 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -529,4 +529,58 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
return 1; return 1;
} }
} }
@Override
public int giveIntegral(ConsumerWallet consumerWallet) {
ConsumerWallet oldConsumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, consumerWallet.getConsumerId()));
ConsumerMember oldConsumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, consumerWallet.getConsumerId()));
if (ObjectUtil.isNotEmpty(oldConsumerWallet) && ObjectUtil.isNotEmpty(oldConsumerMember)) {
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(oldConsumerWallet.getRemainingIntegral());
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
oldConsumerWallet.setRemainingIntegral(oldConsumerWallet.getRemainingIntegral().add(consumerWallet.getRemainingIntegral()));
integralLogService.save(integralLog);
consumerWalletService.updateById(oldConsumerWallet);
return 1;
} else {
ConsumerWallet newConsumerWallet = new ConsumerWallet();
newConsumerWallet.setConsumerId(consumerWallet.getConsumerId());
newConsumerWallet.setBalance(BigDecimal.ZERO);
newConsumerWallet.setRechargeAmount(BigDecimal.ZERO);
newConsumerWallet.setGiftAmount(BigDecimal.ZERO);
newConsumerWallet.setRemainingDuration(BigDecimal.ZERO);
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(newConsumerWallet.getRemainingIntegral());
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
newConsumerWallet.setRemainingDuration(BigDecimal.ZERO);
newConsumerWallet.setRemainingIntegral(newConsumerWallet.getRemainingIntegral().add(consumerWallet.getRemainingIntegral()));
newConsumerWallet.setEquityFund(BigDecimal.ZERO);
newConsumerWallet.setAccumulateEquityFund(BigDecimal.ZERO);
newConsumerWallet.setCreateTime(new Date());
ConsumerMember newConsumerMember = new ConsumerMember();
newConsumerMember.setConsumerId(consumerWallet.getConsumerId());
newConsumerMember.setMembershipLevel(0L);
String rechargeMembershipExpirationTime = sysConfigService.selectConfigByKey("rechargeMembershipExpirationTime");
newConsumerMember.setExpirationDate(DateUtils.addYears(new Date(), Integer.parseInt(rechargeMembershipExpirationTime)));
newConsumerMember.setMembershipProgress(BigDecimal.ZERO);
newConsumerMember.setIsRecharge(YesNoEnum.no.getIndex());
newConsumerMember.setIsRights(YesNoEnum.no.getIndex());
newConsumerMember.setCreateTime(new Date());
consumerWalletService.save(newConsumerWallet);
integralLogService.save(integralLog);
consumerMemberService.save(newConsumerMember);
return 1;
}
}
} }
...@@ -18,11 +18,9 @@ import share.common.utils.DateUtils; ...@@ -18,11 +18,9 @@ import share.common.utils.DateUtils;
import share.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.mapper.WheelGameMapper; import share.system.mapper.WheelGameMapper;
import share.system.service.ISConsumerCouponService; import share.system.service.*;
import share.system.service.LotteryRecordsLogService;
import share.system.service.PrizeService;
import share.system.service.WheelGameService;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -48,6 +46,8 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame ...@@ -48,6 +46,8 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
private ISConsumerCouponService sConsumerCouponService; private ISConsumerCouponService sConsumerCouponService;
@Autowired @Autowired
private LotteryRecordsLogService lotteryRecordsLogService; private LotteryRecordsLogService lotteryRecordsLogService;
@Autowired
private ConsumerWalletService consumerWalletService;
/** /**
* 查询转盘游戏 * 查询转盘游戏
...@@ -165,6 +165,10 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame ...@@ -165,6 +165,10 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
lotteryRecordsLogService.save(log); lotteryRecordsLogService.save(log);
break; break;
case INTEGRAL: case INTEGRAL:
ConsumerWallet consumerWallet = new ConsumerWallet();
consumerWallet.setConsumerId(user.getId());
consumerWallet.setRemainingIntegral(new BigDecimal(prize.getPrizeValue()));
consumerWalletService.giveIntegral(consumerWallet);
log.setIsHit(YesNoEnum.yes.getIndex()); log.setIsHit(YesNoEnum.yes.getIndex());
log.setIsSend(YesNoEnum.yes.getIndex()); log.setIsSend(YesNoEnum.yes.getIndex());
log.setHitPrize(PrizeTypeEnum.INTEGRAL.getName()); log.setHitPrize(PrizeTypeEnum.INTEGRAL.getName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment