| | |
| | | import com.webmanage.mapper.UserPointsMapper; |
| | | import com.webmanage.mapper.PointsTransactionMapper; |
| | | import com.webmanage.entity.PointsTransaction; |
| | | import com.webmanage.service.OrderInfoService; |
| | | import com.webmanage.service.PointsFlowService; |
| | | import com.webmanage.service.PointsRuleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | @Resource |
| | | private PointsTransactionMapper pointsTransactionMapper; |
| | | |
| | | |
| | | @Override |
| | | public PageResult<PointsFlow> getPersonalPointsFlowPage(PointsFlowQueryDTO queryDTO) { |
| | |
| | | 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; |
| | |
| | | |
| | | 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); |
| | | } |
| | | } */ |
| | | } |
| | | |
| | | /** |
| | |
| | | public boolean deductUserPoints(DeductUserPointsDTO deductDTO) { |
| | | try { |
| | | String userId = deductDTO.getUserId(); |
| | | String providerId = deductDTO.getProviderId(); |
| | | String unitId = deductDTO.getUnitId(); |
| | | Integer points = deductDTO.getPoints(); |
| | | String orderId = deductDTO.getOrderId(); |
| | |
| | | if (inserted <= 0 || trans.getId() == null) { |
| | | throw new BusinessException("保存积分交易记录失败"); |
| | | } |
| | | |
| | | // 为提供者新增积分 |
| | | AddPointsFlowDTO addPointsFlowDTO = new AddPointsFlowDTO(); |
| | | addPointsFlowDTO.setCategory("资源交易"); |
| | | addPointsFlowDTO.setCount(1); |
| | | addPointsFlowDTO.setProviderId(providerId); |
| | | addPointsFlowDTO.setRuleType(0); |
| | | addPointsFlowDTO.setRuleNameCode("digital_product_transaction"); |
| | | addPointsFlowDTO.setDescription("产品交易"); |
| | | addPointsFlowByRule(addPointsFlowDTO); |
| | | return true; |
| | | } catch (Exception e) { |
| | | log.error("扣减用户积分失败", e); |