This commit is contained in:
huchuansai
2025-05-08 16:39:42 +08:00
parent e588acf896
commit 3d0a8493c5

View File

@@ -49,7 +49,6 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;
@Override
public PlayCustomUserInfoEntity selectByOpenid(String openId) {
LambdaQueryWrapper<PlayCustomUserInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -84,11 +83,37 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
public void customAccountBalanceRecharge(BigDecimal rechargeAmount, String customId, String orderId) {
PlayCustomUserInfoEntity userInfo = this.selectById(customId);
//查询充值赠送金额暂是设置为0
BigDecimal giftAmount = BigDecimal.ZERO;
// 此处我想实现超过50送5超过100送10200送20300送30400送40500送50
BigDecimal giftAmount = calculateGiftMoney(rechargeAmount);
//修改用户账户余额
this.updateAccountBalanceById(customId, userInfo.getAccountBalance(), userInfo.getAccountBalance().add(rechargeAmount).add(giftAmount), "0", "重置", rechargeAmount.add(giftAmount), giftAmount, orderId);
this.updateAccountBalanceById(customId, userInfo.getAccountBalance(), userInfo.getAccountBalance().add(rechargeAmount).add(giftAmount), "0", "充值", rechargeAmount.add(giftAmount), giftAmount, orderId);
}
private static BigDecimal calculateGiftMoney(BigDecimal rechargeAmount) {
//此处我想实现超过50送5超过100送10200送20300送30400送40500送50
BigDecimal giftAmount = BigDecimal.ZERO;
if (rechargeAmount.compareTo(new BigDecimal(50)) >= 0) {
giftAmount = new BigDecimal(5);
}
if (rechargeAmount.compareTo(new BigDecimal(100)) >= 0) {
giftAmount = new BigDecimal(10);
}
if (rechargeAmount.compareTo(new BigDecimal(200)) >= 0) {
giftAmount = new BigDecimal(20);
}
if (rechargeAmount.compareTo(new BigDecimal(300)) >= 0) {
giftAmount = new BigDecimal(30);
}
if (rechargeAmount.compareTo(new BigDecimal(400)) >= 0) {
giftAmount = new BigDecimal(40);
}
if (rechargeAmount.compareTo(new BigDecimal(500)) >= 0) {
giftAmount = new BigDecimal(50);
}
return giftAmount;
}
/**
* 查询顾客
*
@@ -220,7 +245,7 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
IPage<PlayCustomUserReturnVo> page = this.baseMapper.selectJoinPage(new Page<>(vo.getPageNum(), vo.getPageSize()), PlayCustomUserReturnVo.class, lambdaQueryWrapper);
for (PlayCustomUserReturnVo record : page.getRecords()) {
List<PlayOrderInfoEntity> orderInfoEntities = playOrderInfoService.list(Wrappers.lambdaQuery(PlayOrderInfoEntity.class).eq(PlayOrderInfoEntity::getPurchaserBy,record.getId()).in(PlayOrderInfoEntity::getPlaceType, "0","2"));
List<PlayOrderInfoEntity> orderInfoEntities = playOrderInfoService.list(Wrappers.lambdaQuery(PlayOrderInfoEntity.class).eq(PlayOrderInfoEntity::getPurchaserBy, record.getId()).in(PlayOrderInfoEntity::getPlaceType, "0", "2"));
BigDecimal orderTotalAmount = new BigDecimal("0");
for (PlayOrderInfoEntity orderInfoEntity : orderInfoEntities) {
orderTotalAmount = orderTotalAmount.add(orderInfoEntity.getFinalAmount());
@@ -326,10 +351,10 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
String id = entity.getPurchaserBy();
LambdaUpdateWrapper<PlayCustomUserInfoEntity> wrapper = Wrappers.lambdaUpdate(PlayCustomUserInfoEntity.class).eq(PlayCustomUserInfoEntity::getId, id).set(PlayCustomUserInfoEntity::getLastPurchaseTime, new Date());
PlayCustomUserInfoEntity userInfoEntity = selectById(id);
if(Objects.isNull(userInfoEntity.getFirstPurchaseTime())){
wrapper.set(PlayCustomUserInfoEntity::getFirstPurchaseTime,new Date());
if (Objects.isNull(userInfoEntity.getFirstPurchaseTime())) {
wrapper.set(PlayCustomUserInfoEntity::getFirstPurchaseTime, new Date());
}
wrapper.set(PlayCustomUserInfoEntity::getWeiChatCode,entity.getWeiChatCode());
wrapper.set(PlayCustomUserInfoEntity::getWeiChatCode, entity.getWeiChatCode());
this.update(wrapper);
}
}