| | |
| | | } |
| | | |
| | | // 每日上限校验(分别校验) |
| | | if (applyUser && userRule.getIsLimit() != null && userRule.getIsLimit() == 0) { |
| | | if (applyUser && userRule.getIsLimit() != null && userRule.getIsLimit() == 1) { |
| | | checkDailyLimitByRule(userId, unitId, userRule, userPointsChange); |
| | | } |
| | | if (applyProvider && providerRule.getIsLimit() != null && providerRule.getIsLimit() == 0) { |
| | | checkDailyLimitByRule(providerId, providerId, providerRule, providerPointsChange); |
| | | if (applyProvider && providerRule.getIsLimit() != null && providerRule.getIsLimit() == 1) { |
| | | checkDailyLimitByRule(providerId, null, providerRule, providerPointsChange); |
| | | } |
| | | |
| | | // 余额校验(仅在扣减时) |
| | |
| | | if (applyProvider && providerPointsChange != 0) { |
| | | PointsFlow providerFlow = new PointsFlow(); |
| | | providerFlow.setUserId(providerId); |
| | | providerFlow.setUnitId(providerId); |
| | | providerFlow.setUnitId(null); |
| | | providerFlow.setDataType(ruleType); |
| | | providerFlow.setDataCategory(addPointsFlowDTO.getCategory()); |
| | | providerFlow.setPoints(providerPointsChange); |
| | |
| | | if (!providerSaved) { |
| | | throw new BusinessException("保存提供者积分流水失败"); |
| | | } |
| | | |
| | | updateProviderUnitPoints(providerId, providerPointsChange); |
| | | updateUserPointsByRule(providerId, null, userPointsChange); |
| | | // updateProviderUnitPoints(providerId, providerPointsChange); |
| | | } |
| | | |
| | | return true; |
| | |
| | | QueryWrapper<PointsFlow> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("deleted", 0) |
| | | .eq("user_id", userId) |
| | | .eq("unit_id", unitId) |
| | | // .eq("data_category", pointsRule.getRuleName()) |
| | | .eq("rule_id",pointsRule.getId()) |
| | | // .eq("data_type", 0) |
| | | .ge("flow_time", startOfDay) |
| | | .le("flow_time", endOfDay); |
| | | if(StringUtils.hasText(unitId)){ |
| | | wrapper.eq("unit_id", unitId); |
| | | } |
| | | |
| | | List<PointsFlow> todayFlows = list(wrapper); |
| | | |
| | |
| | | Integer dailyLimit = pointsRule.getDailyLimit(); |
| | | if (dailyLimit != null && dailyLimit > 0) { |
| | | // 如果今日累计积分超过每日上限,则抛出异常 |
| | | if (Math.abs(todayTotal) >= dailyLimit) { |
| | | if (Math.abs(todayTotal) > dailyLimit) { |
| | | throw new BusinessException("今日该规则积分已达上限: " + dailyLimit); |
| | | } |
| | | |
| | | // 如果加上当前积分会超过每日上限,则抛出异常 |
| | | if (Math.abs(todayTotal + currentPoints) > dailyLimit) { |
| | | throw new BusinessException("本次积分操作将超过每日上限: " + dailyLimit + ",当前已累计: " + Math.abs(todayTotal)); |
| | | } |
| | | // if (Math.abs(todayTotal + currentPoints) > dailyLimit) { |
| | | // throw new BusinessException("本次积分操作将超过每日上限: " + dailyLimit + ",当前已累计: " + Math.abs(todayTotal)); |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | userPoints = new UserPoints(); |
| | | userPoints.setUserId(userId); |
| | | userPoints.setUnitId(unitId); |
| | | if(StringUtils.hasText(unitId)){ |
| | | userPoints.setUnitId(unitId); |
| | | } |
| | | userPoints.setBalance(pointsValue); |
| | | userPoints.setTotalEarned(pointsValue > 0 ? pointsValue : 0); |
| | | userPoints.setTotalConsumed(pointsValue < 0 ? Math.abs(pointsValue) : 0); |
| | |
| | | } |
| | | |
| | | // 更新单位积分账户 |
| | | QueryWrapper<UserPoints> unitWrapper = new QueryWrapper<>(); |
| | | /* QueryWrapper<UserPoints> unitWrapper = new QueryWrapper<>(); |
| | | unitWrapper.eq("deleted", 0) |
| | | .eq("unit_id", unitId); |
| | | |
| | |
| | | |
| | | unitPoints.setUpdateTime(LocalDateTime.now()); |
| | | userPointsMapper.updateById(unitPoints); |
| | | } |
| | | } */ |
| | | } |
| | | |
| | | /** |