| | |
| | | if(!orderItem.getOrderId().equals(ordersTotal.getId())){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到退款项[012]"); |
| | | } |
| | | |
| | | //判断这个项目能不能显示处理 |
| | | switch (orderItem.getType()) { |
| | | case OrderItemConstants.TYPE_PROJECT: |
| | |
| | | public List<OrderPayMethodDto> rechargeRefundWay(OrdersTotal ordersTotal,BigDecimal totalAmount){ |
| | | |
| | | //获取总支付方式 |
| | | List<PayMethodVo> payMethodVoList = refundMapper.selectConsumePayList(ordersTotal.getId()); |
| | | List<PayMethodVo> payMethodVoList = refundMapper.getConsumePayGroupByNumberNo(ordersTotal.getId()); |
| | | |
| | | List<OrderPayMethodDto> consumeList = new ArrayList<>(); |
| | | OrderPayMethodDto orderPayMethodDto; |
| | |
| | | } |
| | | |
| | | //获取该子单的支付方式,相同的支付方式求和返回 |
| | | List<PayMethodVo> payMethodVoList = refundMapper.selectConsumePayOneList(orderItem.getId()); |
| | | List<PayMethodVo> payMethodVoList = refundMapper.getConsumePayOneGroupByNumberNo(orderItem.getId()); |
| | | |
| | | //获取已退款的金额 |
| | | sqlMap.clear(); |
| | |
| | | } |
| | | |
| | | //获取该子单的支付方式,相同的支付方式算和返回 |
| | | List<PayMethodVo> payMethodVoList = refundMapper.selectConsumePayTwoList(orderItemSon.getId()); |
| | | List<PayMethodVo> payMethodVoList = refundMapper.getConsumePayTwoGroupByNumberNo(orderItemSon.getId()); |
| | | |
| | | //获取已退款的金额 |
| | | sqlMap.clear(); |
| | |
| | | * 校验参数,拼接参数 |
| | | */ |
| | | public OrderRefundDto parameterVerification(OrdersTotal ordersTotal,OrderRefundDto orderRefundDto){ |
| | | |
| | | if(orderRefundDto.getRefundPayMethod() == null){ |
| | | throw new TipsException("退款方式结构不能空"); |
| | | } |
| | | |
| | | //怕被获取到项目信息收到被改了项目价格,重新去获取一下项目价格 |
| | | orderRefundDto = nextStep(ordersTotal,orderRefundDto); |
| | |
| | | //记录取消日志 |
| | | CancelOrder cancelOrder=new CancelOrder(); |
| | | cancelOrder.setOrderId(ordersTotal.getId()); |
| | | Employee employee = commonService.selectOneByKey(EmployeeMapper.class,orderRefundDto.getOperatorId()); |
| | | if(employee==null){ |
| | | cancelOrder.setOperatorId(orderRefundDto.getOperatorId()); |
| | | cancelOrder.setOperatorName("找不到对应员工"); |
| | | }else { |
| | | if(StringUtils.noNull(orderRefundDto.getOperatorId())){ |
| | | Employee employee = commonService.selectOneByKey(EmployeeMapper.class,orderRefundDto.getOperatorId()); |
| | | if(employee==null){ |
| | | throw new TipsException("操作人标识错误!"); |
| | | } |
| | | cancelOrder.setOperatorId(employee.getId()); |
| | | cancelOrder.setOperatorName(employee.getCnName()); |
| | | } |
| | | |
| | | EmployeeRole employeeRole=commonService.selectOneByKey(EmployeeRoleMapper.class,orderRefundDto.getRoleId()); |
| | | if(employeeRole==null){ |
| | | cancelOrder.setRoleId(orderRefundDto.getRoleId()); |
| | | cancelOrder.setRoleStr("找不到对应角色"); |
| | | cancelOrder.setShopId(employeeRole.getShopId()); |
| | | cancelOrder.setShopName("找不到对应的门店"); |
| | | }else { |
| | | |
| | | if(StringUtils.noNull(orderRefundDto.getRoleId())){ |
| | | EmployeeRole employeeRole=commonService.selectOneByKey(EmployeeRoleMapper.class,orderRefundDto.getRoleId()); |
| | | if(employeeRole==null){ |
| | | throw new TipsException("操作角色标识错误!"); |
| | | } |
| | | cancelOrder.setRoleId(employeeRole.getRoleTypeId()); |
| | | cancelOrder.setRoleStr(employeeRole.getRoleUniqueStr()); |
| | | Shop shop=commonService.selectOneByKey(ShopMapper.class,employeeRole.getShopId()); |
| | |
| | | cancelOrder.setShopId(shop.getId()); |
| | | cancelOrder.setShopName(shop.getName()); |
| | | } |
| | | |
| | | } |
| | | |
| | | cancelOrder.setIsApproval(orderRefundDto.getIsApproval()); |
| | | cancelOrder.setIsRefund(orderRefundDto.getIsRefund()); |
| | | cancelOrder.setPlatformSource(orderRefundDto.getPlatformSource()); |
| | |
| | | orderNodeBuilder.append("-记录退款方式:"); |
| | | |
| | | //获取订单可退款方式,就是支付方式总表的信息,已经支付编号求和 |
| | | List<PayMethodVo> payMethodVoList = refundMapper.selectConsumePayList(ordersTotal.getId()); |
| | | List<PayMethodVo> payMethodVoList = refundMapper.getConsumePayGroupByNumberNo(ordersTotal.getId()); |
| | | |
| | | //用map装载,后面根据支付编号直接获取便可 |
| | | Map<String, PayMethodVo> payMethodVoMap = payMethodVoList.stream().collect(Collectors.toMap(PayMethodVo::getNumberNo,(a) -> a)); |
| | |
| | | refundRecordMethod.setRefundName(refundMethod.getName()); |
| | | refundRecordMethod.setRefundMethodId(refundMethod.getId()); |
| | | |
| | | refundRecordMethod.setRefundMethodId(refundMethod.getId()); |
| | | refundRecordMethod.setIsMoneyPayRefund(refundMethod.getIsMoneyPay()); |
| | | refundRecordMethod.setIsExecuteRefund(refundMethod.getIsExecute()); |
| | | |
| | | refundRecordMethod.setRefundRecordId(refundRecord.getId()); |
| | | refundRecordMethod.setOrderId(ordersTotal.getId()); |
| | | //refundRecordMethod.setRemarks(orderPayMethodDto.getRemarks()); |
| | | |
| | | refundRecordMethodService.insert(refundRecordMethod); |
| | |
| | | refundRecordItem = new RefundRecordItem(); |
| | | refundRecordItem.setType(orderItem.getType()); |
| | | refundRecordItem.setGoodsNo(orderItem.getGoodsNo()); |
| | | refundRecordItem.setGoodsName(orderItem.getGoodsName()); |
| | | refundRecordItem.setSpecs(orderItem.getSpecs()); |
| | | refundRecordItem.setCommonId(orderItem.getCommonId()); |
| | | refundRecordItem.setHeadPrice(orderItem.getCurPrice()); |
| | | refundRecordItem.setRefundNum(orderItemRefundDto.getRefundNum()); |
| | | if(PartialRefundUtil.CONTAIN_SON_TYPE_SET.contains(orderItem.getType())){ |
| | | refundRecordItem.setRefundNum(0); |
| | | }else{ |
| | | refundRecordItem.setRefundNum(orderItemRefundDto.getRefundNum()); |
| | | } |
| | | refundRecordItem.setRefundRecordId(refundRecord.getId()); |
| | | refundRecordItem.setOrderItemId(orderItem.getId()); |
| | | refundRecordItem.setOccupyRefundTotal(orderItemRefundDto.getApproveRefundTotal()); |
| | |
| | | orderItemRefundDto.setRemarks(refundRecord.getRemarks()); |
| | | } |
| | | if(StringUtils.isEmpty(orderItemRefundDto.getRefundReason())){ |
| | | orderItemRefundDto.setRemarks(refundRecord.getRefundReason()); |
| | | orderItemRefundDto.setRefundReason(orderItemRefundDto.getRefundReason()); |
| | | } |
| | | refundRecordItem.setRemarks(orderItemRefundDto.getRemarks()); |
| | | refundRecordItem.setRefundReason(orderItemRefundDto.getRefundReason()); |
| | |
| | | if(refundRecordItem.getRefundMoney().compareTo(refundTotal) > 0){ |
| | | refundRecordItem.setRefundMoney(refundTotal); |
| | | } |
| | | |
| | | refundRecordItem.setRealRefundNum(refundRecordItem.getRefundNum()); |
| | | refundRecordItem.setRealRefundTotal(refundRecordItem.getRealRefundTotal()); |
| | | |
| | | refundRecordItemService.insert(refundRecordItem); |
| | | //减去已经分配的退款金额 |
| | | refundTotal = refundTotal.subtract(refundRecordItem.getRefundMoney()).setScale(2,RoundingMode.HALF_UP); |
| | | //子单子项处理 |
| | | insertRefundRecordItemTwo(refundRecordItem,refundRecord,orderItemRefundDto.getOrderItemSourceRefundDtos()); |
| | | if(PartialRefundUtil.CONTAIN_SON_TYPE_SET.contains(orderItem.getType())){ |
| | | //子单子项处理 |
| | | insertRefundRecordItemTwo(refundRecordItem,refundRecord,orderItemRefundDto.getOrderItemSourceRefundDtos()); |
| | | } |
| | | } |
| | | |
| | | if(refundTotal.compareTo(BigDecimal.ZERO) > 0){ |
| | |
| | | refundRecordItemSource = new RefundRecordItemSource(); |
| | | refundRecordItemSource.setType(orderItemSon.getType()); |
| | | refundRecordItemSource.setGoodsNo(orderItemSon.getGoodsNo()); |
| | | refundRecordItemSource.setGoodsName(orderItemSon.getGoodsName()); |
| | | refundRecordItemSource.setSpecs(orderItemSon.getSpecs()); |
| | | refundRecordItemSource.setCommonId(orderItemSon.getGoodsId()); |
| | | refundRecordItemSource.setHeadPrice(orderItemSon.getCurPrice()); |
| | | refundRecordItemSource.setRefundNum(orderItemSourceRefundDto.getRefundNum()); |
| | | refundRecordItemSource.setRefundRecordId(orderItemSon.getId()); |
| | | refundRecordItemSource.setRefundRecordId(refundRecord.getId()); |
| | | refundRecordItemSource.setOrderItemSonId(orderItemSon.getId()); |
| | | refundRecordItemSource.setOccupyRefundTotal(orderItemSourceRefundDto.getApproveRefundTotal()); |
| | | refundRecordItemSource.setRefundRecordItemId(recordItem.getId()); |
| | | ////退款备注 |
| | | if(StringUtils.isEmpty(orderItemSourceRefundDto.getRemarks())){ |
| | | orderItemSourceRefundDto.setRemarks(refundRecord.getRemarks()); |
| | | } |
| | | if(StringUtils.isEmpty(orderItemSourceRefundDto.getRefundReason())){ |
| | | orderItemSourceRefundDto.setRemarks(refundRecord.getRefundReason()); |
| | | orderItemSourceRefundDto.setRefundReason(refundRecord.getRefundReason()); |
| | | } |
| | | refundRecordItemSource.setRemarks(orderItemSourceRefundDto.getRemarks()); |
| | | refundRecordItemSource.setRefundReason(orderItemSourceRefundDto.getRefundReason()); |
| | |
| | | if(refundRecordItemSource.getRefundMoney().compareTo(refundTotal) > 0){ |
| | | refundRecordItemSource.setRefundMoney(refundTotal); |
| | | } |
| | | |
| | | refundRecordItemSource.setRealRefundNum(refundRecordItemSource.getRefundNum()); |
| | | refundRecordItemSource.setRealRefundTotal(refundRecordItemSource.getRefundMoney()); |
| | | |
| | | refundRecordItemSourceMapper.insert(refundRecordItemSource); |
| | | //减去已经分配退款金额 |
| | | refundTotal = refundTotal.subtract(refundRecordItemSource.getRefundMoney()).setScale(2,RoundingMode.HALF_UP); |
| | | System.out.println("refundRecordItemSource.getRefundMoney():"+refundRecordItemSource.getRefundMoney()); |
| | | } |
| | | |
| | | System.out.println("refundTotal:"+refundTotal); |
| | | if(refundTotal.compareTo(BigDecimal.ZERO) > 0){ |
| | | throw new TipsException("退款金额分配错误[02]!"); |
| | | } |
| | |
| | | BigDecimal total=new BigDecimal(String.valueOf(totalMap.get("total"))) ; |
| | | if(BigDecimal.ZERO.compareTo(total) < 0){ |
| | | try { |
| | | orderNodeBuilder.append("-开始处理用户升降级,金额:"+total.negate()); |
| | | orderNodeBuilder.append("-开始处理用户升降级,金额:").append(total.negate()); |
| | | UserLevelUtil.refund(ordersTotal.getUserId(),ordersTotal.getId(),total.negate(),ordersTotal.getAppIdCode()); |
| | | orderNodeBuilder.append("-处理用户升降级成功"); |
| | | }catch (Exception e){ |
| | | String snapshot="处理用户升降级失败"; |
| | | orderNodeBuilder.append("-处理用户升降级失败,异常原因:"+e.getMessage()); |
| | | orderNodeBuilder.append("-处理用户升降级失败,异常原因:").append(e.getMessage()); |
| | | logger.error("处理用户升降级失败:" + e.getMessage()); |
| | | //发送企业微信通知给工作人员 |
| | | SendNoticeUtil.failOrderSendNotice(ordersTotal,e.getMessage(),snapshot,commonService,customParameter); |