| | |
| | | //退款总订单状态变更 |
| | | values.put("refundStatus", RefundStatus.STATUS_SUCC_REFUND); |
| | | values.put("oldRefundStatus", RefundStatus.STATUS_APPLY_REFUND); |
| | | values.put("refundTotal", refundRecord.getRefundTotal()); |
| | | values.put("createTime", new Date()); |
| | | values.put("isDel", BaseEntity.NO); |
| | | values.put("id",refundRecord.getId()); |
| | | sqlSentence.sqlSentence(" refundTotal = #{m.refundTotal},refundStatus=#{m.refundStatus},createTime = #{m.createTime} WHERE id = #{m.id} AND isDel=#{m.isDel} AND refundStatus = #{m.oldRefundStatus}",values); |
| | | sqlSentence.sqlSentence(" refundStatus=#{m.refundStatus},createTime = #{m.createTime} WHERE id = #{m.id} AND isDel=#{m.isDel} AND refundStatus = #{m.oldRefundStatus}",values); |
| | | if(commonService.updateWhere(RefundRecordMapper.class,sqlSentence) != 1){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作失败,退款单状态已改变!"); |
| | | } |
| | |
| | | handCoupon(refundRecord,commonService); |
| | | //处理总退款方式数据 |
| | | refundCarryVo = refundRecordMotnedHandle(refundCarryVo,operationId,operationNme,refundRecord,ordersTotal,commonService); |
| | | |
| | | //-----存储退款金额 |
| | | values.put("id",refundRecord.getId()); |
| | | values.put("realRefundTotal",refundCarryVo.getRefundTotal()); |
| | | values.put("realRefundIntegral",refundCarryVo.getIntegralTotal()); |
| | | values.put("deductionTotal",refundRecord.getDeductionTotal()); |
| | | values.put("cashTotal",refundRecord.getCashTotal()); |
| | | values.put("cashPurenessTotal",refundRecord.getCashPurenessTotal()); |
| | | values.put("rechargeTotal",refundRecord.getRechargeTotal()); |
| | | values.put("incrementTotal",refundRecord.getIncrementTotal()); |
| | | sqlSentence.sqlSentence(" realRefundTotal = #{m.realRefundTotal},realRefundIntegral = #{m.realRefundIntegral},deductionTotal=#{m.deductionTotal},cashTotal = #{m.cashTotal}" + |
| | | ",cashPurenessTotal = #{m.cashPurenessTotal},rechargeTotal = #{m.rechargeTotal},incrementTotal = #{m.incrementTotal} WHERE id = #{m.id}",values); |
| | | if(commonService.updateWhere(RefundRecordMapper.class,sqlSentence) != 1){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"操作失败,变更退款单金额失败!"); |
| | | } |
| | | |
| | | //更改总订单退款状态 |
| | | values.clear(); |
| | |
| | | } |
| | | refundCarryVo.setRefundConsumePayList(refundRecordConsumePayList); |
| | | |
| | | |
| | | //计算各种金额 |
| | | refundCarryVo.setRefundTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setDeductionTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setCashTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setCashPurenessTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setRechargeTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setIncrementTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setIntegralTotal(BigDecimal.ZERO); |
| | | |
| | | //处理回退到账 |
| | | for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){ |
| | | if(PayMethodTypeConstants.PAY_STORED.equals(refundRecordMethod.getRefundNumberNo())){ |
| | | //储值金额 |
| | | refundCarryVo.setRechargeTotal(refundCarryVo.getRechargeTotal().add(refundRecordMethod.getActualTotal())); |
| | | refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordMethod.getActualTotal())); |
| | | //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0 |
| | | if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)>0){ |
| | | UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"操作原因:退款审核通过,退款方式:退回储值金",operationId,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundRecord.getId(),refundRecordMethod.getActualTotal(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO); |
| | |
| | | } |
| | | }else if(PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordMethod.getRefundNumberNo())){ |
| | | //增值金 |
| | | refundCarryVo.setIncrementTotal(refundCarryVo.getIncrementTotal().add(refundRecordMethod.getActualTotal())); |
| | | refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordMethod.getActualTotal())); |
| | | //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0 |
| | | if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)!=0){ |
| | | if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)>0){ |
| | | UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"操作原因:退款审核通过,退款方式:退回增值金",operationId,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundRecord.getId(),refundRecordMethod.getActualTotal(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.YES); |
| | | OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,operationId,operationNme,refundRecordMethod.getName(),0, OrderLogConstants.LOG_TYPE_REFUND); |
| | | commonService.insert(OrderLogMapper.class,orderLog); |
| | | } |
| | | }else if(PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordMethod.getRefundNumberNo())){ |
| | | //积分 |
| | | refundCarryVo.setIntegralTotal(refundCarryVo.getIntegralTotal().add(refundRecordMethod.getActualTotal())); |
| | | //判断金额不等于0,才执行操作,不然操作余额的时候会爆操作数量或金额不能为0 |
| | | if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)!=0){ |
| | | if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)>0){ |
| | | UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"操作原因:退款审核通过,退款方式:退回积分",operationId,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundRecord.getId(),refundRecordMethod.getActualTotal(), UserMoneyUnclaimed.FUND_TYPE_INTEGRAL,OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.YES); |
| | | OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,operationId,operationNme,refundRecordMethod.getName()+"退款金额:"+refundRecordMethod.getActualTotal(),0, OrderLogConstants.LOG_TYPE_REFUND); |
| | | commonService.insert(OrderLogMapper.class,orderLog); |
| | | } |
| | | }else { |
| | | //现金支付 |
| | | refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordMethod.getActualTotal())); |
| | | if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO)<1){ |
| | | continue; |
| | | } |
| | |
| | | orderLog.setOrderId(ordersTotal.getId()); |
| | | commonService.insert(OrderLogMapper.class,orderLog); |
| | | } |
| | | //是否现金 |
| | | if(refundRecordMethod.getIsMoneyPay().equals(BaseEntity.YES)){ |
| | | refundCarryVo.setCashTotal(refundCarryVo.getCashTotal().add(refundRecordMethod.getActualTotal())); |
| | | //不是退到储值金、增值金、积分 |
| | | if(!PayMethodTypeConstants.PAY_STORED.equals(refundRecordMethod.getRefundNumberNo()) |
| | | &&!PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordMethod.getRefundNumberNo()) |
| | | &&!PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordMethod.getRefundNumberNo())){ |
| | | refundCarryVo.setCashPurenessTotal(refundCarryVo.getCashPurenessTotal().add(refundRecordMethod.getActualTotal())); |
| | | } |
| | | } |
| | | //判断是否划扣的 |
| | | if(refundRecordMethod.getIsExecute().equals(BaseEntity.YES)){ |
| | | refundCarryVo.setDeductionTotal(refundCarryVo.getDeductionTotal().add(refundRecordMethod.getActualTotal())); |
| | | } |
| | | |
| | | } |
| | | return refundCarryVo; |
| | | } |
| | |
| | | } |
| | | |
| | | /**处理一级子退款方式数据 |
| | | * @param deductionTotalUser 用户项目被扣减的划扣金额,可空 |
| | | * @param refundRecord 退款记录总表 |
| | | * @param refundRecordItem 退款记录子表 |
| | | * @param refundCarryVo 总携带参数结构 |
| | | * @param commonService 映射 |
| | | * @return 总携带参数结构 |
| | | */ |
| | | public static RefundCarryVo refundRecordMotnedItemHandle(BigDecimal deductionTotalUser,RefundRecord refundRecord,RefundRecordItem refundRecordItem |
| | | public static RefundCarryVo refundRecordMotnedItemHandle(RefundRecord refundRecord,RefundRecordItem refundRecordItem |
| | | ,RefundCarryVo refundCarryVo,CommonService commonService){ |
| | | |
| | | //没有退款方式,跳过当前处理,因为这里是处理退款方式金额的,如果没有退款金额,那么可以跳过该环节 |
| | |
| | | payMothedPercentage = BigDecimal.ZERO; |
| | | } |
| | | |
| | | //处理退款方式 |
| | | //处理退款方式,存储信息 |
| | | refundCarryVo = insertRefundItemMothed(refundRecordItem.getId(),refundRecordItem.getRefundMoney(),payMothedPercentage,OrderSourceConstans.TYPE_PROJECT |
| | | ,refundRecordItem.getOrderItemId(),refundCarryVo,refundRecord,commonService); |
| | | |
| | | //更新退款子单 |
| | | updateRefundItem(refundCarryVo.getDeductionTotal(),refundCarryVo.getCashTotal(),deductionTotalUser |
| | | ,refundRecordItem.getId(),commonService); |
| | | updateRefundItem(refundCarryVo,refundRecordItem.getId(),commonService); |
| | | |
| | | return refundCarryVo; |
| | | } |
| | | |
| | | /**更新退款一级子单的信息 |
| | | * @param deductionTotal 退款方式的划扣金额 |
| | | * @param cashTotal 退款方式的现金金额 |
| | | * @param deductionTotalUser 用户项目的划扣金额 |
| | | * @param refundItemId 退款记录一级子单标识 |
| | | * @param commonService 映射 |
| | | */ |
| | | public static void updateRefundItem(BigDecimal deductionTotal,BigDecimal cashTotal,BigDecimal deductionTotalUser |
| | | public static void updateRefundItem(RefundCarryVo refundCarryVo |
| | | ,String refundItemId,CommonService commonService){ |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | |
| | | //更新退款子单的信息,更新现金和划扣金额保存 |
| | | values.put("deductionTotal",deductionTotal); |
| | | values.put("deductionTotalUser",deductionTotalUser==null?BigDecimal.ZERO:deductionTotalUser); |
| | | values.put("cashTotal",cashTotal); |
| | | values.put("realRefundTotal",refundCarryVo.getRefundTotal()); |
| | | values.put("realRefundIntegral",refundCarryVo.getIntegralTotal()); |
| | | values.put("deductionTotal",refundCarryVo.getDeductionTotal()); |
| | | values.put("deductionTotalUser",refundCarryVo.getDeductionTotalUser()); |
| | | values.put("cashTotal",refundCarryVo.getCashTotal()); |
| | | values.put("cashPurenessTotal",refundCarryVo.getCashPurenessTotal()); |
| | | values.put("rechargeTotal",refundCarryVo.getRechargeTotal()); |
| | | values.put("incrementTotal",refundCarryVo.getIncrementTotal()); |
| | | values.put("id",refundItemId); |
| | | sqlSentence.sqlUpdate("deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal} WHERE id = #{m.id}",values); |
| | | sqlSentence.sqlUpdate("realRefundTotal = #{m.realRefundTotal},realRefundIntegral = #{m.realRefundIntegral},deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal}" + |
| | | ",cashPurenessTotal = #{m.cashPurenessTotal},rechargeTotal = #{m.rechargeTotal},incrementTotal = #{m.incrementTotal} WHERE id = #{m.id}",values); |
| | | if(commonService.updateWhere(RefundRecordItemMapper.class,sqlSentence) != 1){ |
| | | throw new TipsException("更新退款子项信息失败!"); |
| | | } |
| | | } |
| | | |
| | | /**处理二级子退款方式数据 |
| | | * @param deductionTotalUser 用户项目被扣减的划扣金额 |
| | | * @param refundRecord 退款记录总表 |
| | | * @param refundRecordItemSource 退款记录子表 |
| | | * @param refundCarryVo 总携带参数结构 |
| | | * @param commonService 映射 |
| | | * @return 总携带参数结构 |
| | | */ |
| | | public static RefundCarryVo refundRecordMotnedItemTwoHandle(BigDecimal deductionTotalUser,RefundRecord refundRecord,RefundRecordItemSource refundRecordItemSource |
| | | public static RefundCarryVo refundRecordMotnedItemTwoHandle(RefundRecord refundRecord,RefundRecordItemSource refundRecordItemSource |
| | | ,RefundCarryVo refundCarryVo,CommonService commonService){ |
| | | |
| | | //装载支付方式退款信息 |
| | |
| | | ,refundRecordItemSource.getOrderItemSonId(),refundCarryVo,refundRecord,commonService); |
| | | |
| | | values.put("deductionTotal",refundCarryVo.getDeductionTotal()); |
| | | values.put("deductionTotalUser",deductionTotalUser==null?BigDecimal.ZERO:deductionTotalUser); |
| | | values.put("deductionTotalUser",refundCarryVo.getDeductionTotalUser()); |
| | | values.put("realRefundTotal",refundCarryVo.getRefundTotal()); |
| | | values.put("realRefundIntegral",refundCarryVo.getIntegralTotal()); |
| | | values.put("cashTotal",refundCarryVo.getCashTotal()); |
| | | values.put("cashPurenessTotal",refundCarryVo.getCashPurenessTotal()); |
| | | values.put("rechargeTotal",refundCarryVo.getRechargeTotal()); |
| | | values.put("incrementTotal",refundCarryVo.getIncrementTotal()); |
| | | values.put("id",refundRecordItemSource.getId()); |
| | | sqlSentence.sqlUpdate("deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal} WHERE id = #{m.id}",values); |
| | | sqlSentence.sqlUpdate("deductionTotal = #{m.deductionTotal},deductionTotalUser = #{m.deductionTotalUser},cashTotal = #{m.cashTotal}" + |
| | | ",realRefundTotal = #{m.realRefundTotal},realRefundIntegral = #{m.realRefundIntegral},cashPurenessTotal = #{m.cashPurenessTotal}" + |
| | | ",rechargeTotal = #{m.rechargeTotal},incrementTotal = #{m.incrementTotal} WHERE id = #{m.id}",values); |
| | | if(commonService.updateWhere(RefundRecordItemSourceMapper.class,sqlSentence) != 1){ |
| | | throw new TipsException("更新退款子项信息失败[94]!"); |
| | | } |
| | |
| | | BigDecimal mothedTotal; |
| | | //支付编号分配的退款金额 |
| | | BigDecimal mothedCutTotal; |
| | | //分配的划扣金额总和 |
| | | BigDecimal deductionTotal = BigDecimal.ZERO; |
| | | //分配的现金金额总和 |
| | | BigDecimal cashTotal = BigDecimal.ZERO; |
| | | |
| | | //装载已经分配的退款金额记录,key值:总退款方式记录标识 |
| | | Map<String,RefundRecordItemMethod> refundRecordItemMethodMap = new HashMap<>(); |
| | |
| | | //获取分配的退款方式记录 |
| | | refundRecordItemMethod = refundRecordItemMethodMap.get(refundRecordMethod.getId()); |
| | | |
| | | if(PayMethodTypeConstants.PAY_STORED.equals(refundRecordItemMethod.getRefundNumberNo())){ |
| | | //储值金额 |
| | | refundCarryVo.setRechargeTotal(refundCarryVo.getRechargeTotal().add(refundRecordItemMethod.getActualTotal())); |
| | | refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordItemMethod.getActualTotal())); |
| | | }else if(PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordItemMethod.getRefundNumberNo())){ |
| | | //增值金 |
| | | refundCarryVo.setIncrementTotal(refundCarryVo.getIncrementTotal().add(refundRecordItemMethod.getActualTotal())); |
| | | refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordItemMethod.getActualTotal())); |
| | | }else if(PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordItemMethod.getRefundNumberNo())){ |
| | | //积分 |
| | | refundCarryVo.setIntegralTotal(refundCarryVo.getIntegralTotal().add(refundRecordItemMethod.getActualTotal())); |
| | | }else { |
| | | refundCarryVo.setRefundTotal(refundCarryVo.getRefundTotal().add(refundRecordItemMethod.getActualTotal())); |
| | | } |
| | | |
| | | ///////生成关联支付方式记录和退款方式关联 |
| | | //根据支付编号获取支付方式记录 |
| | | noPayItemList = noPayItemMap.computeIfAbsent(refundRecordItemMethod.getNumberNo(),k->new ArrayList<>()); |
| | |
| | | |
| | | //现金金额 |
| | | if(consumePayItem.getIsMoneyPay().equals(ConsumePayItem.YES)){ |
| | | cashTotal = cashTotal.add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP); |
| | | refundCarryVo.setCashTotal(refundCarryVo.getCashTotal().add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP)); |
| | | //不是退到储值金、增值金、积分 |
| | | if(!PayMethodTypeConstants.PAY_STORED.equals(refundRecordItemMethod.getRefundNumberNo()) |
| | | &&!PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordItemMethod.getRefundNumberNo()) |
| | | &&!PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordItemMethod.getRefundNumberNo())){ |
| | | refundCarryVo.setCashPurenessTotal(refundCarryVo.getCashPurenessTotal().add(mothedCutTotal)); |
| | | } |
| | | } |
| | | //划扣金额 |
| | | if(consumePayItem.getIsExecute().equals(ConsumePayItem.YES)){ |
| | | deductionTotal = deductionTotal.add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP); |
| | | refundCarryVo.setDeductionTotal(refundCarryVo.getDeductionTotal().add(mothedCutTotal).setScale(2,RoundingMode.HALF_UP)); |
| | | } |
| | | |
| | | //生成关联记录 |
| | |
| | | } |
| | | } |
| | | |
| | | refundCarryVo.setDeductionTotal(deductionTotal); |
| | | refundCarryVo.setCashTotal(cashTotal); |
| | | refundCarryVo.setRefundConsumePayList(refundConsumePayList); |
| | | refundCarryVo.setRefundRecordItemMethodList(refundRecordItemMethodList); |
| | | |
| | |
| | | refundCarryVo.setDeductionTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setCashTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setDeductionTotalUser(BigDecimal.ZERO); |
| | | refundCarryVo.setCashPurenessTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setRechargeTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setIntegralTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setIncrementTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setRefundTotal(BigDecimal.ZERO); |
| | | //商品类型判断 |
| | | switch (refundRecordItem.getType()){ |
| | | case OrderItemConstants.TYPE_RETAIL: |
| | |
| | | refundStatus = OrderTotalConstants.STATUS_REFUND_PART; |
| | | } |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundRecordItem.getRefundNum(),commonService); |
| | | |
| | | //退款方式处理 |
| | | return refundRecordMotnedItemHandle(null,refundRecord,refundRecordItem,refundCarryVo,commonService); |
| | | refundCarryVo = refundRecordMotnedItemHandle(refundRecord,refundRecordItem,refundCarryVo,commonService); |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundRecordItem.getRefundNum(),commonService); |
| | | |
| | | return refundCarryVo; |
| | | } |
| | | |
| | | /** |
| | |
| | | refundStatus=OrderTotalConstants.STATUS_REFUND_PART; |
| | | } |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundRecordItem.getRefundNum(),commonService); |
| | | |
| | | //退款方式处理 |
| | | return refundRecordMotnedItemHandle(userProjectDeductionVo.getDeductionTotal(),refundRecord,refundRecordItem,refundCarryVo,commonService); |
| | | refundCarryVo = refundRecordMotnedItemHandle(refundRecord,refundRecordItem,refundCarryVo,commonService); |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundRecordItem.getRefundNum(),commonService); |
| | | |
| | | return refundCarryVo; |
| | | } |
| | | |
| | | /**退款-处理卡项 |
| | |
| | | refundStatus = OrderTotalConstants.STATUS_REFUND_PART; |
| | | } |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundRecordItem.getRefundNum(),commonService); |
| | | |
| | | //退款方式处理 |
| | | refundCarryVo = refundRecordMotnedItemHandle(null,refundRecord,refundRecordItem,refundCarryVo,commonService); |
| | | refundCarryVo = refundRecordMotnedItemHandle(refundRecord,refundRecordItem,refundCarryVo,commonService); |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundRecordItem.getRefundNum(),commonService); |
| | | |
| | | //--卡项部分退处理 |
| | | if(RefundSoruceConstants.TYPE_SOURCE_USER_CARD.equals(refundRecord.getSourceAssistantType())){ |
| | |
| | | RefundRecordConsumePay refundRecordConsumePay; |
| | | //计算本次退款方式的划扣金额 |
| | | BigDecimal deductionTotal = BigDecimal.ZERO; |
| | | //计算本次退款方式的现金金额 |
| | | BigDecimal cashTotal = BigDecimal.ZERO; |
| | | //分配的用户项目划扣金额 |
| | | BigDecimal deductionTotalUser = BigDecimal.ZERO; |
| | | //计算本次退款方式的现金金额 |
| | | BigDecimal cashTotal = BigDecimal.ZERO; |
| | | //退款现金总金额(元,不包含退到储值金的) |
| | | BigDecimal cashPurenessTotal = BigDecimal.ZERO;; |
| | | //退款储值金总金额(元) |
| | | BigDecimal rechargeTotal = BigDecimal.ZERO;; |
| | | //退款增值金总金额(元) |
| | | BigDecimal incrementTotal = BigDecimal.ZERO;; |
| | | //退款积分 |
| | | BigDecimal integralTotal = BigDecimal.ZERO;; |
| | | //退款总金额(元) |
| | | BigDecimal refundTotal = BigDecimal.ZERO;; |
| | | |
| | | for (RefundRecordItemSource son : sons) { |
| | | //初始化总结构携带参数 |
| | |
| | | refundCarryVo.setDeductionTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setCashTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setDeductionTotalUser(BigDecimal.ZERO); |
| | | refundCarryVo.setDeductionTotalUser(BigDecimal.ZERO); |
| | | refundCarryVo.setCashPurenessTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setRechargeTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setIntegralTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setIncrementTotal(BigDecimal.ZERO); |
| | | refundCarryVo.setRefundTotal(BigDecimal.ZERO); |
| | | switch (GroupTypeEnum.getCode(son.getType())){ |
| | | case PROJECT: |
| | | refundCarryVo = handRefundNoSonExecution(refundRecord,refundRecordItem,son,refundCarryVo,orderItem.getUserCardId(),commonService,deductionSingleService); |
| | |
| | | deductionTotal = deductionTotal.add(refundCarryVo.getDeductionTotal()); |
| | | cashTotal = cashTotal.add(refundCarryVo.getCashTotal()); |
| | | deductionTotalUser = deductionTotalUser.add(refundCarryVo.getDeductionTotalUser()); |
| | | cashPurenessTotal = cashPurenessTotal.add(refundCarryVo.getCashPurenessTotal()); |
| | | rechargeTotal = rechargeTotal.add(refundCarryVo.getRechargeTotal()); |
| | | incrementTotal = incrementTotal.add(refundCarryVo.getIncrementTotal()); |
| | | integralTotal = integralTotal.add(refundCarryVo.getIntegralTotal()); |
| | | refundTotal = refundTotal.add(refundCarryVo.getRefundTotal()); |
| | | //遍历叠加支付方式记录的退款金额 |
| | | for(RefundRecordConsumePay re:refundCarryVo.getRefundConsumePayList()){ |
| | | refundRecordConsumePay = refundRecordConsumePayMap.computeIfAbsent(re.getConsumePayId(),k->new RefundRecordConsumePay(BigDecimal.ZERO,re.getNumberNo(),re.getName(),re.getIsMoneyPay(),re.getIsExecute(),re.getConsumePayId())); |
| | |
| | | refundCarryVo.setDeductionTotal(deductionTotal); |
| | | refundCarryVo.setDeductionTotalUser(deductionTotalUser); |
| | | refundCarryVo.setRefundConsumePayList(refundRecordConsumePayList); |
| | | refundCarryVo.setCashPurenessTotal(cashPurenessTotal); |
| | | refundCarryVo.setRechargeTotal(rechargeTotal); |
| | | refundCarryVo.setIncrementTotal(incrementTotal); |
| | | refundCarryVo.setRefundTotal(refundTotal); |
| | | |
| | | //更新退款子单 |
| | | updateRefundItem(refundCarryVo.getDeductionTotal(),refundCarryVo.getCashTotal(),refundCarryVo.getDeductionTotalUser() |
| | | ,refundRecordItem.getId(),commonService); |
| | | updateRefundItem(refundCarryVo,refundRecordItem.getId(),commonService); |
| | | |
| | | //获取其子项 |
| | | map.put("orderItemId",orderItem.getId()); |
| | |
| | | } |
| | | |
| | | //更新子订单信息 |
| | | updateOrderItemOne(orderItem,refundStatus,refundRecordItem.getRefundMoney(),refundNum,commonService); |
| | | updateOrderItemOne(orderItem,refundStatus,refundCarryVo,refundNum,commonService); |
| | | |
| | | return refundCarryVo; |
| | | } |
| | |
| | | refundStatus=OrderTotalConstants.STATUS_REFUND_PART; |
| | | } |
| | | |
| | | //更新子单信息 |
| | | updateOrderItemTwo(orderItemSon,refundStatus,refundRecordItemSource.getRefundMoney(),refundRecordItemSource.getRefundNum(),commonService); |
| | | |
| | | //处理退款支付方式 |
| | | refundCarryVo = refundRecordMotnedItemTwoHandle(userProjectDeductionVo.getDeductionTotal(),refundRecord,refundRecordItemSource,refundCarryVo,commonService); |
| | | refundCarryVo = refundRecordMotnedItemTwoHandle(refundRecord,refundRecordItemSource,refundCarryVo,commonService); |
| | | //更新子单信息 |
| | | updateOrderItemTwo(orderItemSon,refundStatus,refundCarryVo,refundRecordItemSource.getRefundNum(),commonService); |
| | | |
| | | if(refundRecordItem.getType().equals(OrderItemConstants.CARD_BAG)){ |
| | | //是卡包的,刪除卡包使用 |
| | |
| | | refundStatus=OrderTotalConstants.STATUS_REFUND_PART; |
| | | } |
| | | |
| | | updateOrderItemTwo(orderItemSon,refundStatus,refundRecordItemSource.getRefundMoney(),refundRecordItemSource.getRefundNum(),commonService); |
| | | |
| | | //处理退款支付方式 |
| | | refundCarryVo = refundRecordMotnedItemTwoHandle(null,refundRecord,refundRecordItemSource,refundCarryVo,commonService); |
| | | refundCarryVo = refundRecordMotnedItemTwoHandle(refundRecord,refundRecordItemSource,refundCarryVo,commonService); |
| | | |
| | | updateOrderItemTwo(orderItemSon,refundStatus,refundCarryVo,refundRecordItemSource.getRefundNum(),commonService); |
| | | |
| | | if(refundRecordItem.getType().equals(OrderItemConstants.CARD_BAG)){ |
| | | //是卡包的,刪除卡包使用 |
| | |
| | | /**更新订单一级子单的信息 |
| | | * @param orderItem 订单子单 |
| | | * @param refundStatus 退款状态 |
| | | * @param refundTotal 退款金额,正负数 |
| | | * @param refundCarryVo 传参 |
| | | * @param refundNum 退款数量 正负数 |
| | | * @param commonService 映射 |
| | | */ |
| | | public static void updateOrderItemOne(OrderItem orderItem,Integer refundStatus,BigDecimal refundTotal,Integer refundNum |
| | | public static void updateOrderItemOne(OrderItem orderItem,Integer refundStatus,RefundCarryVo refundCarryVo,Integer refundNum |
| | | ,CommonService commonService){ |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | |
| | | values.put("id", orderItem.getId()); |
| | | values.put("refundStatus", refundStatus); |
| | | values.put("refundTotal",refundTotal); |
| | | values.put("refundNum",refundNum); |
| | | values.put("oldHasReNum",orderItem.getHasReNum()); |
| | | values.put("refundNum",refundNum); |
| | | values.put("refundTotal",refundCarryVo.getRefundTotal()); |
| | | values.put("reIntegralTotal",refundCarryVo.getIntegralTotal()); |
| | | values.put("reCashTotal",refundCarryVo.getCashTotal()); |
| | | values.put("reCashPurenessTotal",refundCarryVo.getCashPurenessTotal()); |
| | | values.put("reRechargeTotal",refundCarryVo.getRechargeTotal()); |
| | | values.put("reIncrementTotal",refundCarryVo.getIncrementTotal()); |
| | | sqlSentence.sqlUpdate(" refundStatus=#{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" + |
| | | ",reIntegralTotal = reIntegralTotal+#{m.reIntegralTotal},reCashTotal = reCashTotal+#{m.reCashTotal}" + |
| | | ",reCashPurenessTotal = reCashPurenessTotal+#{m.reCashPurenessTotal},reRechargeTotal = reRechargeTotal+#{m.reRechargeTotal}" + |
| | | ",reIncrementTotal = reIncrementTotal+#{m.reIncrementTotal}" + |
| | | " WHERE isDel = 0 AND id = #{m.id} AND hasReNum = #{m.oldHasReNum}",values); |
| | | if(commonService.updateWhere(OrderItemMapper.class,sqlSentence) != 1){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"当前订单信息已发生变化,请重试[012]!"); |
| | |
| | | /**更新订单二级子单的信息 |
| | | * @param orderItemSon 订单子单 |
| | | * @param refundStatus 退款状态 |
| | | * @param refundTotal 退款金额 |
| | | * @param refundCarryVo 传参 |
| | | * @param refundNum 退款数量 |
| | | * @param commonService 映射 |
| | | */ |
| | | public static void updateOrderItemTwo(OrderItemSon orderItemSon,Integer refundStatus,BigDecimal refundTotal,Integer refundNum |
| | | public static void updateOrderItemTwo(OrderItemSon orderItemSon,Integer refundStatus,RefundCarryVo refundCarryVo,Integer refundNum |
| | | ,CommonService commonService){ |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | |
| | | values.put("id", orderItemSon.getId()); |
| | | values.put("refundStatus", refundStatus); |
| | | values.put("refundTotal",refundTotal); |
| | | values.put("refundNum",refundNum); |
| | | values.put("oldHasReNum",orderItemSon.getHasReNum()); |
| | | values.put("refundTotal",refundCarryVo.getRefundTotal()); |
| | | values.put("refundNum",refundNum); |
| | | values.put("reIntegralTotal",refundCarryVo.getIntegralTotal()); |
| | | values.put("reCashTotal",refundCarryVo.getCashTotal()); |
| | | values.put("reCashPurenessTotal",refundCarryVo.getCashPurenessTotal()); |
| | | values.put("reRechargeTotal",refundCarryVo.getRechargeTotal()); |
| | | values.put("reIncrementTotal",refundCarryVo.getIncrementTotal()); |
| | | sqlSentence.sqlUpdate(" refundStatus = #{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" + |
| | | ",reIntegralTotal = reIntegralTotal+#{m.reIntegralTotal},reCashTotal = reCashTotal+#{m.reCashTotal}" + |
| | | ",reCashPurenessTotal = reCashPurenessTotal+#{m.reCashPurenessTotal},reRechargeTotal = reRechargeTotal+#{m.reRechargeTotal}" + |
| | | ",reIncrementTotal = reIncrementTotal+#{m.reIncrementTotal}" + |
| | | " where isDel=0 AND id = #{m.id} AND hasReNum = #{m.oldHasReNum}",values); |
| | | if(commonService.updateWhere(OrderItemSonMapper.class,sqlSentence) != 1){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"当前订单信息已发生变化,请重试[012]!"); |