Commit 8e8eda65 by 吕明尚

增加赠送时长接口

parent 84281c5c
...@@ -89,4 +89,12 @@ public class ConsumerWalletController extends BaseController { ...@@ -89,4 +89,12 @@ public class ConsumerWalletController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(consumerWalletService.deleteConsumerWalletByIds(ids)); return toAjax(consumerWalletService.deleteConsumerWalletByIds(ids));
} }
/**
* 赠送时长
*/
@PostMapping("/giveDuration")
public AjaxResult giveDuration(@RequestBody ConsumerWallet consumerWallet) {
return toAjax(consumerWalletService.giveDuration(consumerWallet));
}
} }
...@@ -70,4 +70,6 @@ public interface ConsumerWalletService extends IService<ConsumerWallet> { ...@@ -70,4 +70,6 @@ public interface ConsumerWalletService extends IService<ConsumerWallet> {
boolean editConsumerWallet(ConsumerWallet consumerWallet, Recharge recharge, ConsumerMember one); boolean editConsumerWallet(ConsumerWallet consumerWallet, Recharge recharge, ConsumerMember one);
void accumulatedConsumptionStatistics(Long consumerId); void accumulatedConsumptionStatistics(Long consumerId);
int giveDuration(ConsumerWallet consumerWallet);
} }
...@@ -471,4 +471,58 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -471,4 +471,58 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, one.getMembershipLevel())); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, one.getMembershipLevel()));
accumulatedConsumptionStatistics(consumerWallet, one, memberConfig); accumulatedConsumptionStatistics(consumerWallet, one, memberConfig);
} }
@Override
public int giveDuration(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)) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setCurrentDuration(oldConsumerWallet.getRemainingDuration());
durationLog.setVariableDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(new Date());
durationLog.setCreateTime(new Date());
oldConsumerWallet.setRemainingDuration(oldConsumerWallet.getRemainingDuration().add(consumerWallet.getRemainingDuration()));
durationLogService.save(durationLog);
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);
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setCurrentDuration(newConsumerWallet.getRemainingDuration());
durationLog.setVariableDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(new Date());
durationLog.setCreateTime(new Date());
newConsumerWallet.setRemainingDuration(newConsumerWallet.getRemainingDuration().add(consumerWallet.getRemainingDuration()));
newConsumerWallet.setRemainingIntegral(BigDecimal.ZERO);
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);
durationLogService.save(durationLog);
consumerMemberService.save(newConsumerMember);
return 1;
}
}
} }
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