| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | public PageData<Goodsorder> findPage(PageWrap<Goodsorder> pageWrap) { |
| | | IPage<Goodsorder> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<Goodsorder> queryWrapper = initQueryParamByModel(pageWrap.getModel()); |
| | | return PageData.from(goodsorderJoinMapper.selectJoinPage(page, Goodsorder.class,queryWrapper)); |
| | | IPage<Goodsorder> goodsorderIPage = goodsorderJoinMapper.selectJoinPage(page, Goodsorder.class, queryWrapper); |
| | | if (!CollectionUtils.isEmpty(goodsorderIPage.getRecords())){ |
| | | goodsorderIPage.getRecords().forEach(s->{ |
| | | s.setMoney(Constants.translateMoney(s.getMoney())); |
| | | s.setCloseMoney(Constants.translateMoney(s.getCloseMoney())); |
| | | s.setRefundMoney(Constants.translateMoney(s.getRefundMoney())); |
| | | }); |
| | | } |
| | | return PageData.from(goodsorderIPage); |
| | | } |
| | | |
| | | |
| | |
| | | homeResponse.setServerPhone(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.SERVER_PHONE).getCode()); |
| | | homeResponse.setLeaseNoticeUrl(fullPath + systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.LEASE_NOTICE_URL).getCode()); |
| | | homeResponse.setLeaseNotice(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.LEASE_NOTICE).getCode()); |
| | | homeResponse.setDeposit(new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_DEPOSIT).getCode())); |
| | | homeResponse.setDeposit(new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_DEPOSIT).getCode()).multiply(BigDecimal.valueOf(100))); |
| | | homeResponse.setTips(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.TIPS).getCode()); |
| | | homeResponse.setLeaseVideoUrl(fullPath + systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_TIPS_VIDEO).getCode()); |
| | | homeResponse.setStopServeTips(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.STOP_SERVE_TIPS).getCode()); |
| | |
| | | public void backGoodsorder(String orderId, BigDecimal money,String reason) { |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(orderId); |
| | | if(goodsorder == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,订单信息不存在,请刷新页面重试!"); |
| | | } |
| | | if (Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.CLOSE.getKey()){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,该订单请结算后再退款~"); |
| | | } |
| | | QueryWrapper<Refund> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Refund::getObjId,orderId) |
| | | .orderByDesc(Refund::getCreateDate) |
| | | .last("limit 1"); |
| | | Refund lastRefund = refundMapper.selectOne(wrapper); |
| | | if (Objects.isNull(lastRefund)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"改订单请结算后在退款"); |
| | | } |
| | | BigDecimal canBalance = lastRefund.getCanBalance(); |
| | | .eq(Refund::getStatus,Constants.TWO) |
| | | .eq(Refund::getIsdeleted,Constants.ZERO) ; |
| | | 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); |
| | | if(canBalance.compareTo(money) > Constants.ZERO){ |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setOrderId(orderId); |
| | | refundDTO.setCanBalance(lastRefund.getCanBalance().subtract(lastRefund.getMoney())); |
| | | refundDTO.setCanBalance(canBalance); |
| | | refundDTO.setRefundAmount(money); |
| | | refundDTO.setTotalAmount(goodsorder.getMoney()); |
| | | refundDTO.setMemberId(goodsorder.getMemberId()); |
| | | refundDTO.setCreator(principal.getId()); |
| | | refundDTO.setReason(reason); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | QueryWrapper<Refund> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Refund::getObjId,orderId) |
| | | .orderByDesc(Refund::getCreateDate); |
| | | List<Refund> refunds = refundMapper.selectList(wrapper); |
| | | .eq(Refund::getStatus,Constants.TWO) |
| | | .eq(Refund::getIsdeleted,Constants.ZERO) ; |
| | | wrapper.select("sum(money) as money").last(" limit 1"); |
| | | Refund total = refundMapper.selectOne(wrapper); |
| | | GoodsorderCanBanlanceDTO goodsorderCanBanlanceDTO = new GoodsorderCanBanlanceDTO(); |
| | | goodsorderCanBanlanceDTO.setGoodsorderMoney(goodsorder.getMoney()); |
| | | goodsorderCanBanlanceDTO.setCloseMoney(goodsorder.getCloseMoney()); |
| | | if (!CollectionUtils.isEmpty(refunds)){ |
| | | BigDecimal reduce = refunds.stream().map(s -> s.getMoney()).reduce(new BigDecimal("0"), (a, b) -> b.add(a)); |
| | | Refund refund = refunds.stream().findFirst().orElse(null); |
| | | goodsorderCanBanlanceDTO.setHasRefundMoney(reduce); |
| | | goodsorderCanBanlanceDTO.setCanBanlanceMoney(refund.getCanBalance().subtract(refund.getMoney())); |
| | | }else { |
| | | goodsorderCanBanlanceDTO.setHasRefundMoney(new BigDecimal("0")); |
| | | goodsorderCanBanlanceDTO.setCanBanlanceMoney(goodsorder.getMoney()); |
| | | } |
| | | BigDecimal reduce = total!=null?Constants.formatDecimalNum(total.getMoney()):new BigDecimal(0); |
| | | goodsorderCanBanlanceDTO.setHasRefundMoney(reduce); |
| | | goodsorderCanBanlanceDTO.setCanBanlanceMoney(Constants.formatDecimalNum(goodsorder.getMoney()).subtract(goodsorderCanBanlanceDTO.getHasRefundMoney())); |
| | | return goodsorderCanBanlanceDTO; |
| | | } |
| | | |
| | |
| | | memberRidesResponse.setUnitTime(s.getUnitTime()); |
| | | if ( Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey()!=(Constants.formatIntegerNum(s.getStatus()))){ |
| | | //如果是骑行中 |
| | | s.setDuration(rideTime> finalFreeTime ?(rideTime- finalFreeTime):0); |
| | | s.setDuration(rideTime> finalFreeTime ?(rideTime):0); |
| | | } |
| | | s.setRideTime(rideTime); |
| | | return memberRidesResponse; |
| | |
| | | goodsorder.setId(Constants.getUUID()); |
| | | goodsorder.setCreateDate(new Date()); |
| | | goodsorder.setIsdeleted(Constants.ZERO); |
| | | goodsorder.setCode(goodsorder.getId()); |
| | | goodsorder.setMemberId(memberId); |
| | | goodsorder.setMoney(new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_DEPOSIT).getCode())); |
| | | goodsorder.setMoney(new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_DEPOSIT).getCode()).multiply(new BigDecimal(100))); |
| | | goodsorder.setStatus(Constants.goodsorderStatus.waitPay); |
| | | goodsorder.setPreOrderid(goodsorder.getId()); |
| | | goodsorder.setPayStatus(Constants.goodsorderPayStatus.waitPay); |
| | |
| | | request.setBody("支付押金"); |
| | | request.setAttach("createGoodsOrder"); |
| | | request.setOutTradeNo(goodsorder.getId()); |
| | | request.setTotalFee(BaseWxPayRequest.yuanToFen(goodsorder.getMoney().toString())); |
| | | // request.setTotalFee(1); |
| | | request.setTotalFee(goodsorder.getMoney().intValue()); |
| | | request.setSpbillCreateIp(this.getIpAddr()); |
| | | request.setTimeStart(DateUtil.DateToString(new Date(), "yyyyMMddHHmmss")); |
| | | request.setOpenid(member.getOpenid()); |