| | |
| | | // 判断使用的数量是否大于记录可以使用积分数量 |
| | | if (opNumber.compareTo(userIntegralRecord.getNotUsedQuantity()) >= 0) { |
| | | // 操作减扣积分数量 |
| | | operatorUserIntegralRecord(userIntegralRecord, userIntegralRecord.getNotUsedQuantity().negate(), userMoneyUnclaimed); |
| | | operatorUserIntegralRecord(userIntegralRecord, userIntegralRecord.getNotUsedQuantity().negate(), userMoneyUnclaimed, BaseEntity.NO); |
| | | // 操作使用积分 |
| | | opNumber = opNumber.subtract(userIntegralRecord.getNotUsedQuantity()); |
| | | } else { |
| | | // 操作减扣积分数量 |
| | | operatorUserIntegralRecord(userIntegralRecord, opNumber.negate(), userMoneyUnclaimed); |
| | | operatorUserIntegralRecord(userIntegralRecord, opNumber.negate(), userMoneyUnclaimed, BaseEntity.NO); |
| | | // 操作使用积分 |
| | | opNumber = BigDecimal.ZERO; |
| | | } |
| | |
| | | // 判断在有效期的操作逻辑 |
| | | if (userIntegralRecord.getLimitStartTime().getTime() <= nowDate.getTime() && userIntegralRecord.getLimitEndTime().getTime() > nowDate.getTime()) { |
| | | // 操作回退积分数量 在有效期不用增加新的积分记录 |
| | | operatorUserIntegralRecord(userIntegralRecord, residueNumber, userMoneyUnclaimed); |
| | | operatorUserIntegralRecord(userIntegralRecord, residueNumber, userMoneyUnclaimed, BaseEntity.NO); |
| | | // 数量累计 不需要再添加记录的 |
| | | noRecordNumber = noRecordNumber.add(residueNumber); |
| | | } |
| | | // 不在有效期的回退逻辑 |
| | | if (userIntegralRecord.getLimitEndTime().getTime() <= nowDate.getTime()) { |
| | | else if (userIntegralRecord.getLimitEndTime().getTime() <= nowDate.getTime()) { |
| | | // 操作回退积分数量 不在有效期不用增加新的积分记录 直接让积分过期了 |
| | | operatorUserIntegralRecord(userIntegralRecord, residueNumber, userMoneyUnclaimed); |
| | | operatorUserIntegralRecord(userIntegralRecord, residueNumber, userMoneyUnclaimed, BaseEntity.YES); |
| | | // 数量累计 过期积分直接清除的 |
| | | noBackNumber = noBackNumber.add(residueNumber); |
| | | } |
| | |
| | | * @param userIntegralRecord 用户积分记录 |
| | | * @param opNumber 操作金额 |
| | | * @param userMoneyUnclaimed 待领取资产列表 |
| | | * @param isExpire 是否过期 0 否 1 是 |
| | | */ |
| | | private void operatorUserIntegralRecord(UserIntegralRecord userIntegralRecord, BigDecimal opNumber, UserMoneyUnclaimed userMoneyUnclaimed) { |
| | | private void operatorUserIntegralRecord(UserIntegralRecord userIntegralRecord, BigDecimal opNumber, UserMoneyUnclaimed userMoneyUnclaimed, int isExpire) { |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String, Object> sqlValue = new HashMap<>(); |
| | | sqlValue.put("isDel", BaseEntity.NO); |
| | |
| | | BigDecimal opAfterNumber = userIntegralRecord.getNotUsedQuantity().subtract(opNumber.negate()); |
| | | // 判断是减扣还是回退 正数是回退 负数是使用 |
| | | sql.append(" notUsedQuantity=notUsedQuantity+#{m.opNumber},usedQuantity = usedQuantity-#{m.opNumber} "); |
| | | sql.append(" WHERE id = #{m.id} AND userId = #{m.userId} AND isDel = #{m.isDel}"); |
| | | // 过期处理下过期时间 |
| | | if (BaseEntity.YES.equals(isExpire)){ |
| | | sql.append(" ,expirationTime = NOW() "); |
| | | } |
| | | sql.append(" WHERE id = #{m.id} AND userId = #{m.userId} AND isDel = #{m.isDel} "); |
| | | sqlSentence.sqlSentence(sql.toString(), sqlValue); |
| | | int count = commonService.updateWhere(UserIntegralRecordMapper.class, sqlSentence); |
| | | if (count != 1) { |
| | |
| | | // 判断使用的金额是否大于记录可以使用增值金金额 |
| | | if (opNumber.compareTo(userValueAddedFundRecord.getNotUsedAmount()) >= 0) { |
| | | // 操作减扣增值金数量 |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, userValueAddedFundRecord.getNotUsedAmount().negate(), userMoneyUnclaimed); |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, userValueAddedFundRecord.getNotUsedAmount().negate(), userMoneyUnclaimed, BaseEntity.NO); |
| | | // 操作使用增值金 |
| | | opNumber = opNumber.subtract(userValueAddedFundRecord.getNotUsedAmount()); |
| | | } else { |
| | | // 操作减扣增值金数量 |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, opNumber.negate(), userMoneyUnclaimed); |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, opNumber.negate(), userMoneyUnclaimed, BaseEntity.NO); |
| | | // 操作使用增值金 |
| | | opNumber = BigDecimal.ZERO; |
| | | } |
| | |
| | | // 判断在有效期的操作逻辑 在有效期不用增加新的增值金记录 |
| | | if (userValueAddedFundRecord.getLimitStartTime().getTime() <= nowDate.getTime() && userValueAddedFundRecord.getLimitEndTime().getTime() > nowDate.getTime()) { |
| | | // 操作回退增值金数量 不需要再添加记录的 |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, residueNumber, userMoneyUnclaimed); |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, residueNumber, userMoneyUnclaimed, BaseEntity.NO); |
| | | // 数量累计 不需要再添加记录的 |
| | | noRecordNumber = noRecordNumber.add(residueNumber); |
| | | } |
| | | // 不在有效期的回退逻辑 |
| | | else if (userValueAddedFundRecord.getLimitEndTime().getTime() <= nowDate.getTime()) { |
| | | // 操作回退增值金数量 不在有效期不用增加新的增值金记录 直接让增值金过期了 |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, residueNumber, userMoneyUnclaimed); |
| | | operatorUserValueAddedFundRecord(userValueAddedFundRecord, residueNumber, userMoneyUnclaimed, BaseEntity.YES); |
| | | // 数量累计 过期增值金直接清除的 |
| | | noBackNumber = noBackNumber.add(residueNumber); |
| | | } |
| | |
| | | * @param userValueAddedFundRecord 用户增值金记录 |
| | | * @param opNumber 操作金额 |
| | | * @param userMoneyUnclaimed 待领取资产列表 |
| | | * @param isExpire 是否过期 0 否 1 是 |
| | | */ |
| | | private void operatorUserValueAddedFundRecord(UserValueAddedFundRecord userValueAddedFundRecord, BigDecimal opNumber, UserMoneyUnclaimed userMoneyUnclaimed) { |
| | | private void operatorUserValueAddedFundRecord(UserValueAddedFundRecord userValueAddedFundRecord, BigDecimal opNumber, UserMoneyUnclaimed userMoneyUnclaimed, int isExpire) { |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String, Object> sqlValue = new HashMap<>(); |
| | | sqlValue.put("isDel", BaseEntity.NO); |
| | |
| | | BigDecimal opAfterNumber = userValueAddedFundRecord.getNotUsedAmount().subtract(opNumber.negate()); |
| | | // 判断是减扣还是回退 正数是回退 负数是使用 |
| | | sql.append(" notUsedAmount=notUsedAmount+#{m.opNumber},usedAmount = usedAmount-#{m.opNumber} "); |
| | | // 过期处理下过期时间 |
| | | if (BaseEntity.YES.equals(isExpire)){ |
| | | sql.append(" ,expirationTime = NOW() "); |
| | | } |
| | | sql.append(" WHERE isDel = #{m.isDel} AND id = #{m.id} AND userId = #{m.userId}"); |
| | | sqlSentence.sqlSentence(sql.toString(), sqlValue); |
| | | int count = commonService.updateWhere(UserValueAddedFundRecordMapper.class, sqlSentence); |