| | |
| | | if (Objects.nonNull(model.getEndDate())){ |
| | | queryWrapper.le( Goodsorder::getPayDate, Utils.Date.getEnd(model.getEndDate())); |
| | | } |
| | | |
| | | queryWrapper.eq(model.getPayStatus() !=null,Goodsorder::getPayStatus,model.getPayStatus()); |
| | | queryWrapper.like(model.getCode() !=null,Goodsorder::getCode,model.getCode()); |
| | | queryWrapper.like(model.getId() !=null,Goodsorder::getId,model.getId()); |
| | |
| | | IPage<Goodsorder> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<Goodsorder> queryWrapper = initQueryParamByModel(pageWrap.getModel()); |
| | | queryWrapper.select("(select er.status from member_rides er where er.ordre_id=t.id order by er.create_date limit 1) as memberRidesStatus"); |
| | | if(Objects.nonNull(pageWrap.getModel().getCloseStatus()) && pageWrap.getModel().getCloseStatus().equals(Constants.ZERO)){ |
| | | queryWrapper.ne(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CLOSE.getKey()); |
| | | } |
| | | if(Objects.nonNull(pageWrap.getModel().getCloseStatus()) && pageWrap.getModel().getCloseStatus().equals(Constants.ONE)){ |
| | | queryWrapper.eq(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CLOSE.getKey()); |
| | | } |
| | | IPage<Goodsorder> goodsorderIPage = goodsorderJoinMapper.selectJoinPage(page, Goodsorder.class, queryWrapper); |
| | | if (!CollectionUtils.isEmpty(goodsorderIPage.getRecords())){ |
| | | goodsorderIPage.getRecords().forEach(s->{ |
| | |
| | | wrapper.select("sum(money) as money").last(" limit 1"); |
| | | Refund total = refundMapper.selectOne(wrapper); |
| | | BigDecimal refundMoney = total == null?new BigDecimal(0):Constants.formatDecimalNum(total.getMoney()); |
| | | BigDecimal canBalance =Constants.formatDecimalNum(goodsorder.getMoney()).subtract(money); |
| | | //可退剩余 单位元 |
| | | BigDecimal canBalance =Constants.translateMoney(Constants.formatDecimalNum(goodsorder.getMoney()).subtract(refundMoney)); |
| | | if(canBalance.compareTo(money) > Constants.ZERO){ |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setOrderId(orderId); |
| | |
| | | refundDTO.setType(Constants.REFUND_TYPE.BACK.getKey()); |
| | | Refund refund = wxMiniUtilService.wxRefund(refundDTO); |
| | | }else { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,退款金额不允许超过"+canBalance); |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,退款金额不允许超过"+canBalance+"元"); |
| | | } |
| | | } |
| | | |
| | |
| | | goodsorderCanBanlanceDTO.setCloseMoney(Constants.translateMoney(goodsorder.getCloseMoney())); |
| | | BigDecimal reduce = total!=null?Constants.formatDecimalNum(total.getMoney()):new BigDecimal(0); |
| | | goodsorderCanBanlanceDTO.setHasRefundMoney(Constants.translateMoney(reduce)); |
| | | goodsorderCanBanlanceDTO.setCanBanlanceMoney(Constants.translateMoney(goodsorder.getMoney()).subtract(goodsorderCanBanlanceDTO.getHasRefundMoney())); |
| | | |
| | | BigDecimal subtract = Constants.translateMoney(goodsorder.getMoney()).subtract(goodsorderCanBanlanceDTO.getCloseMoney()).subtract(goodsorderCanBanlanceDTO.getHasRefundMoney()); |
| | | goodsorderCanBanlanceDTO.setCanBanlanceMoney(subtract.compareTo(new BigDecimal("0")) > 0 ? subtract : new BigDecimal("0")); |
| | | return goodsorderCanBanlanceDTO; |
| | | } |
| | | |