| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hx.common.service.CommonService; |
| | | import com.hx.phiappt.common.OperationReasonConstants; |
| | | import com.hx.phiappt.common.OriginChannelConstants; |
| | | import com.hx.phiappt.constants.tool.UserInfoTool; |
| | | import com.hx.phiappt.constants.tool.money.UserMoneyTool; |
| | | import com.hx.phiappt.model.*; |
| | | import com.hx.phip.common.wx.corp.WeiXinMpUtil; |
| | |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(UserMoneyUnclaimedServiceImpl.class); |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | @Resource |
| | | private CommonService commonService; |
| | | @Resource |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取操作用户资金信息消息 |
| | | * @param userMoneyUnclaimed 参数 |
| | | * @param type 是否领取资金 |
| | | * @return 返回 |
| | | */ |
| | | private JSONObject getOpInfo(UserMoneyUnclaimed userMoneyUnclaimed, Integer type) { |
| | | BigDecimal before = BigDecimal.ZERO; |
| | | BigDecimal after = BigDecimal.ZERO; |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // 获取处理信息 |
| | | StringBuilder info = new StringBuilder(); |
| | | info.append(userMoneyUnclaimed.getOriginSubject()); |
| | | // 查询用户资金信息 |
| | | UserMoney userMoney = userMoneyService.selectUserIdDecrypt(userMoneyUnclaimed.getUserId()); |
| | | switch (userMoneyUnclaimed.getFundType()) { |
| | | case UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND: |
| | | info.append(", 储值金"); |
| | | before = new BigDecimal(userMoney.getStoredValueFund()); |
| | | after = before.add(userMoneyUnclaimed.getOpNumber()); |
| | | break; |
| | | case UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND: |
| | | info.append(", 增值金"); |
| | | before = new BigDecimal(userMoney.getValueAddedFund()); |
| | | after = before.add(userMoneyUnclaimed.getOpNumber()); |
| | | break; |
| | | case UserMoneyUnclaimed.FUND_TYPE_INTEGRAL: |
| | | info.append(", 积分"); |
| | | before = new BigDecimal(userMoney.getIntegral()); |
| | | after = before.add(userMoneyUnclaimed.getOpNumber()); |
| | | break; |
| | | case UserMoneyUnclaimed.FUND_TYPE_DEPOSIT: |
| | | info.append(", 预定金"); |
| | | before = new BigDecimal(userMoney.getDeposit()); |
| | | after = before.add(userMoneyUnclaimed.getOpNumber()); |
| | | break; |
| | | } |
| | | info.append(", 操作数量:").append(userMoneyUnclaimed.getOpNumber()); |
| | | if (UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND == userMoneyUnclaimed.getFundType()) { |
| | | // 增值金添加是否需要领取 |
| | | int opType = userMoneyUnclaimed.getOpType() == null ? BaseEntity.YES : userMoneyUnclaimed.getOpType(); |
| | | info.append(", 是否需要领取:").append(BaseEntity.YES.equals(opType) ? "是" : "否"); |
| | | if (BaseEntity.YES.equals(opType)){ |
| | | before = null; |
| | | after = null; |
| | | } |
| | | } |
| | | if (BaseEntity.YES.equals(type)){ |
| | | info.append(", 领取资金: ").append(userMoneyUnclaimed.getOpNumber()); |
| | | } |
| | | if (3 == type){ |
| | | info.append(", 作废待领取资金: ").append(userMoneyUnclaimed.getOpNumber()); |
| | | before = null; |
| | | after = null; |
| | | } |
| | | jsonObject.put("key", info.toString()); |
| | | jsonObject.put("before", before); |
| | | jsonObject.put("after", after); |
| | | return jsonObject; |
| | | } |
| | | |
| | | /** |
| | | * 添加用户日志 |
| | | * @param userMoneyUnclaimed 用户资金对象 |
| | | * @param type 是否领取资金 |
| | | */ |
| | | private void addUserLog(UserMoneyUnclaimed userMoneyUnclaimed, Integer type){ |
| | | // 处理用户日志 |
| | | User user = userMapper.selectOneByKey(userMoneyUnclaimed.getUserId()); |
| | | if (user != null) { |
| | | // 用户日志 |
| | | JSONArray logArray = new JSONArray(); |
| | | JSONObject jsonObject = getOpInfo(userMoneyUnclaimed, type); |
| | | logArray.add(jsonObject); |
| | | // 操作人转换 |
| | | UserUpdateLog userUpdateLog = new UserUpdateLog(); |
| | | switch (userMoneyUnclaimed.getOperatorType()) { |
| | | case UserMoneyUnclaimed.OPERATOR_TYPE_USER: |
| | | userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_USER); |
| | | userUpdateLog.setOperatorId(userMoneyUnclaimed.getOperatorId()); |
| | | userUpdateLog.setOperatorName(userMoneyUnclaimed.getOperatorName()); |
| | | break; |
| | | case UserMoneyUnclaimed.OPERATOR_TYPE_EMPLOYEE: |
| | | userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_EMPLOYEE); |
| | | userUpdateLog.setOperatorId(userMoneyUnclaimed.getOperatorId()); |
| | | userUpdateLog.setOperatorName(userMoneyUnclaimed.getOperatorName()); |
| | | break; |
| | | case UserMoneyUnclaimed.OPERATOR_TYPE_ADMIN: |
| | | userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_ADMIN); |
| | | userUpdateLog.setOperatorId(userMoneyUnclaimed.getOperatorId()); |
| | | userUpdateLog.setOperatorName(userMoneyUnclaimed.getOperatorName()); |
| | | break; |
| | | case UserMoneyUnclaimed.OPERATOR_TYPE_SYSTEM: |
| | | userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_SYSTEM); |
| | | break; |
| | | } |
| | | // 添加用户日志 |
| | | UserInfoTool.addUserUpdateLogOp(commonService, user, user.getShopId(), userUpdateLog, "用户资金调整", logArray, userMoneyUnclaimed.getRemarks()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @Override |
| | |
| | | if(checkUserMoneyUnclaimed != null) { |
| | | // 过滤待领取的数据 |
| | | this.handlerReceiveData(checkUserMoneyUnclaimed, BaseEntity.YES); |
| | | // 添加用户日志 |
| | | addUserLog(userMoneyUnclaimed, BaseEntity.NO); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void updateAll(UserMoneyUnclaimed userMoneyUnclaimed) { |
| | | if(BaseEntity.YES.equals(userMoneyUnclaimed.getIsDel())){ |
| | | // 添加用户日志 |
| | | addUserLog(userMoneyUnclaimed, 3); |
| | | } |
| | | int count = userMoneyUnclaimedMapper.updateAll(userMoneyUnclaimed); |
| | | if (count != 1) { |
| | | throw new TipsException("保存失败!"); |
| | |
| | | break; |
| | | case UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND: |
| | | // 金额操作 不做校验可以减成负数 |
| | | /*BigDecimal valueAddedFund = new BigDecimal(userMoney.getValueAddedFund()); |
| | | checkCanOperation(valueAddedFund, userMoneyUnclaimed.getOpNumber());*/ |
| | | BigDecimal valueAddedFund = new BigDecimal(userMoney.getValueAddedFund()); |
| | | checkCanOperation(valueAddedFund, userMoneyUnclaimed.getOpNumber()); |
| | | break; |
| | | case UserMoneyUnclaimed.FUND_TYPE_INTEGRAL: |
| | | // 积分操作 |
| | |
| | | sqlValue.put("nowTime",new Date()); |
| | | sqlSentence.sqlSentence(sql, sqlValue); |
| | | commonService.updateWhere(UserMoneyUnclaimedMapper.class, sqlSentence); |
| | | |
| | | // 添加用户日志 |
| | | if(BaseEntity.NO.equals(isReceive)) { |
| | | addUserLog(userMoneyUnclaimed, BaseEntity.YES); |
| | | } |
| | | } |
| | | } |
| | | } |