| | |
| | | return; |
| | | } |
| | | //订单取消状态才处理 |
| | | if(ordersTotal.getStatus() != OrderTotalConstants.STATUS_CANCEL){ |
| | | if(ordersTotal.getRefundStatus() != OrderTotalConstants.STATUS_REFUND_FINSH){ |
| | | return; |
| | | } |
| | | |
| | |
| | | if(userMoneyUnclaimed == null){ |
| | | return; |
| | | } |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | |
| | | //-----生成一条记录,可以回溯 |
| | | RefundUserAssets refundUserAssets; |
| | | //生成记录 |
| | | refundUserAssets = new RefundUserAssets(); |
| | | //设置未102是当前的记录类型 |
| | | refundUserAssets.setIsDel(102); |
| | | refundUserAssets.setType(userMoneyUnclaimed.getOperationReason()); |
| | | refundUserAssets.setStatus(RefundUserAssets.STATUS_NORMAL); |
| | | refundUserAssets.setAmountType(userMoneyUnclaimed.getFundType()); |
| | | refundUserAssets.setAmount(userMoneyUnclaimed.getOpNumber().negate()); |
| | | refundUserAssets.setOperatorId(refundRecord.getOperatorId()); |
| | | refundUserAssets.setOperatorNo(refundRecord.getOperatorNo()); |
| | | refundUserAssets.setOperatorName(refundRecord.getOperatorName()); |
| | | refundUserAssets.setOrderId(refundRecord.getOrderId()); |
| | | refundUserAssets.setRefundRecordId(refundRecord.getId()); |
| | | refundUserAssets.setUserMoneyUnclaimedId(userMoneyUnclaimed.getId()); |
| | | refundUserAssets.setUserId(userMoneyUnclaimed.getUserId()); |
| | | |
| | | if(userMoneyUnclaimed.getStatus() == UserMoneyUnclaimed.STATUS_SUCCEED){ |
| | | //已领取,那么就扣回来 |
| | | if(userMoneyUnclaimed.getOpNumber().compareTo(BigDecimal.ZERO) < 1){ |
| | | return; |
| | | } |
| | | refundUserAssets.setAmountStatus(RefundUserAssets.AMOUNT_STATUS_NORMAL); |
| | | UserMoneyUtil.setUserMoneyHandle(userMoneyUnclaimed.getUserId(),UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND,userMoneyUnclaimed.getOpNumber().negate(),BaseEntity.NO,OperationReasonConstants.OP_REASON_INVITE_ORDER_CANCEL,"好友订单退款-活动赠送扣除["+ordersTotal.getOrderNo()+"]","操作原因:退款审核通过,活动赠送扣除资金,退款方式:退回增值金",ordersTotal.getOperatorId() |
| | | ,ordersTotal.getId(),ordersTotal.getActivityPageCode(),null,commonService); |
| | | }else{ |
| | | if(!UserMoneyUnclaimed.YES.equals(userMoneyUnclaimed.getIsValid())){ |
| | | return; |
| | | } |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | refundUserAssets.setAmountStatus(RefundUserAssets.AMOUNT_STATUS_NOT_RECEIVE); |
| | | //没有领取就作废 |
| | | values.put("id",userMoneyUnclaimed.getId()); |
| | | values.put("isValid",UserMoneyUnclaimed.NO); |
| | |
| | | activityPageGiveIncrease(ordersTotal,refundRecord,operationId,circulateNum,commonService); |
| | | } |
| | | } |
| | | //保存记录,正常扣减和未领取才去保存这个记录 |
| | | commonService.insert(RefundUserAssetsMapper.class,refundUserAssets); |
| | | |
| | | //查看是否有第二张订单符合 |
| | | values.clear(); |
| | | values.put("status",OrderTotalConstants.STATUS_CANCEL); |
| | | values.put("payStatus",OrderTotalConstants.PAY_STATUS_SUC); |
| | | values.put("id",ordersTotal.getId()); |
| | | values.put("activityPageType",ordersTotal.getActivityPageType()); |
| | | values.put("activityPageCode",ordersTotal.getActivityPageCode()); |
| | | sqlSentence.sqlSentence("SELECT * FROM orders_total WHERE isDel = 0 AND status != #{m.status} AND payStatus = #{m.payStatus}" + |
| | | " AND id != #{m.id} AND activityPageType = #{m.activityPageType} AND activityPageCode = #{m.activityPageCode} ORDER BY createTime ASC LIMIT 1",values); |
| | | OrdersTotal ordersTotal1 = commonService.selectOne(OrdersTotalMapper.class,sqlSentence); |
| | | if(ordersTotal1 != null){ |
| | | Integer opType = BaseEntity.NO; |
| | | if(userMoneyUnclaimed.getStatus() == UserMoneyUnclaimed.STATUS_SUCCEED){ |
| | | opType = BaseEntity.YES; |
| | | } |
| | | //增值金到账处理 |
| | | UserMoneyUtil.setUserMoneyHandle(userMoneyUnclaimed.getUserId(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND,userMoneyUnclaimed.getOpNumber(),opType, OperationReasonConstants.OP_REASON_INVITE_ORDER,userMoneyUnclaimed.getOriginSubject(),userMoneyUnclaimed.getRemarks(),userMoneyUnclaimed.getOperatorId() |
| | | ,ordersTotal1.getId(),ordersTotal.getActivityPageCode(),userMoneyUnclaimed.getMoneyRuleId(),commonService); |
| | | } |
| | | |
| | | } |
| | | |