| | |
| | | MoneyRule moneyRule = getMoneyRule(userMoneyUnclaimed.getMoneyRuleId(),userMoneyUnclaimed.getFundType()); |
| | | logger.info("操作资金-moneyRule规则数据:"+JSON.toJSONString(moneyRule)); |
| | | |
| | | //负数默认系统处理 |
| | | if (BigDecimal.ZERO.compareTo(userMoneyUnclaimed.getOpNumber()) > 0) { |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | }else { |
| | | // 操作类型,默认为系统处理 |
| | | if (userMoneyUnclaimed.getOpType() == null) { |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | } |
| | | // 判断是否是支持的类型 |
| | | if (UserMoneyUnclaimed.OP_TYPE_SYSTEM != userMoneyUnclaimed.getOpType() && UserMoneyUnclaimed.OP_TYPE_RECEIVE != userMoneyUnclaimed.getOpType()) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作类型错误"); |
| | | } |
| | | //非系统处理走判断 |
| | | if (UserMoneyUnclaimed.OP_TYPE_SYSTEM != userMoneyUnclaimed.getOpType()){ |
| | | // 有规则,且规则不需要校验用户勾选 |
| | | if (moneyRule != null && moneyRule.getIsUserReceive().equals(BaseEntity.NO)){ |
| | | // 校验基础规则中是否需要领取 |
| | | if (moneyRule.getIsNeedReceive().equals(BaseEntity.YES)){ |
| | | logger.info("操作用户资金(待领取记录)-不校验用户设置是否需要领取状态-但是需要用户领取"); |
| | | //需要领取 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_RECEIVE); |
| | | }else if (moneyRule.getIsNeedReceive().equals(BaseEntity.NO)){ |
| | | logger.info("操作用户资金(待领取记录)-不校验用户设置是否需要领取状态-并且不需要用户领取"); |
| | | //不需要领取,设置为系统处理 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | } |
| | | }else { |
| | | // 无规则或者需要判断用户是否勾选 |
| | | // 默认系统处理 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | // 暂时只有增值金需要判断用户是否勾选 |
| | | if (UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND == userMoneyUnclaimed.getFundType()){ |
| | | // 没有规则,或者需要用户勾选校验 查询用户设置是否领取状态 |
| | | UserInfo userInfo = userInfoMapper.selectOneByUserId(userMoneyUnclaimed.getUserId()); |
| | | if (userInfo != null && userInfo.getIsReceiveValueAddedFund() != null |
| | | && BaseEntity.NO.equals(userInfo.getIsReceiveValueAddedFund())){ |
| | | logger.info("操作用户资金(待领取记录)-用户设置增值金是否需要领取状态:{}", userInfo.getIsReceiveValueAddedFund()); |
| | | // 用户设置了不用再领取 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //获得操作类型 |
| | | checkGetOpType(userMoneyUnclaimed,moneyRule); |
| | | |
| | | } |
| | | // 判断操作数量或金额 |
| | | if (userMoneyUnclaimed.getOpNumber() == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作数量或金额不能为空"); |
| | |
| | | } |
| | | } |
| | | |
| | | /**校验并获得资金操作类型(系统/领取)*/ |
| | | private void checkGetOpType(UserMoneyUnclaimed userMoneyUnclaimed, MoneyRule moneyRule) { |
| | | // 负数默认系统处理 |
| | | if (BigDecimal.ZERO.compareTo(userMoneyUnclaimed.getOpNumber()) > 0) { |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | return; |
| | | } |
| | | // 如果是请求需要系统处理,则直接返回 |
| | | if (userMoneyUnclaimed.getOpType() != null && UserMoneyUnclaimed.OP_TYPE_SYSTEM == userMoneyUnclaimed.getOpType()){ |
| | | return; |
| | | } |
| | | |
| | | // 未有操作类型默认为系统处理(其中增值金默认需要领取) |
| | | if (userMoneyUnclaimed.getOpType() == null) { |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | } |
| | | // 判断是否是支持的类型 |
| | | if (UserMoneyUnclaimed.OP_TYPE_SYSTEM != userMoneyUnclaimed.getOpType() && UserMoneyUnclaimed.OP_TYPE_RECEIVE != userMoneyUnclaimed.getOpType()) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作类型错误"); |
| | | } |
| | | |
| | | // 有规则,且规则不需要校验用户勾选,则校验基础规则中是否需要领取 |
| | | if (moneyRule != null && moneyRule.getIsUserReceive().equals(BaseEntity.NO)){ |
| | | logger.info("操作用户资金(待领取记录)-不校验用户设置是否需要领取状态-是否需要用户领取:"+moneyRule.getIsNeedReceive()); |
| | | if (moneyRule.getIsNeedReceive().equals(BaseEntity.NO)){ |
| | | //不需要领取,设置为系统处理 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | }else { |
| | | //需要领取 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_RECEIVE); |
| | | } |
| | | }else { |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | // 需要判断用户是否勾选(暂时只有增值金需要判断用户是否勾选) |
| | | if (UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND == userMoneyUnclaimed.getFundType()){ |
| | | UserInfo userInfo = userInfoMapper.selectOneByUserId(userMoneyUnclaimed.getUserId()); |
| | | if (userInfo != null){ |
| | | logger.info("操作用户资金(待领取记录)-用户设置增值金是否需要领取状态:{}", userInfo.getIsReceiveValueAddedFund()); |
| | | if (userInfo.getIsReceiveValueAddedFund() != null && BaseEntity.NO.equals(userInfo.getIsReceiveValueAddedFund())){ |
| | | // 用户设置了不用再领取,设置为系统处理 |
| | | userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取金额规则信息 |
| | | * @param moneyRuleId 金额规则 |
| | |
| | | sqlMap.put("isDel",BaseEntity.NO); |
| | | sqlMap.put("isUp",BaseEntity.YES); |
| | | sqlMap.put("isDefault",BaseEntity.YES); |
| | | sqlMap.put("moneyType",-1); |
| | | if (fundType.equals(UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND)){ |
| | | //增值金 |
| | | sqlMap.put("moneyType",MoneyRule.MONEY_TYPE_ADDED_FUND); |
| | |
| | | //积分 |
| | | sqlMap.put("moneyType",MoneyRule.MONEY_TYPE_INTEGRAL); |
| | | } |
| | | sqlSentence.sqlSentence("SELECT * FROM money_rule WHERE isDle = #{m.isDel} " + |
| | | sqlSentence.sqlSentence("SELECT * FROM money_rule WHERE isDel = #{m.isDel} " + |
| | | " AND isUp = #{m.isUp} AND isDefault = #{m.isDefault} AND moneyType = #{m.moneyType} ",sqlMap); |
| | | moneyRule = moneyRuleMapper.selectOne(sqlSentence); |
| | | } |