From 98e9a42aedf088116ca8b5d632d6832a39648046 Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期五, 25 十月 2024 11:53:22 +0800 Subject: [PATCH] merge --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 69 ++++++++++++++++++++++------------ 1 files changed, 45 insertions(+), 24 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index c337f27..28f4464 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -889,29 +889,22 @@ //处理用户标签数据 List<TUserTag> data = userTagClient.getAllUserTag().getData(); //累计充电次数 - long count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) - .eq(TChargingOrder::getRechargePaymentStatus, 2).isNotNull(TChargingOrder::getPaymentAmount).eq(TChargingOrder::getDelFlag, 0)); List<TUserTag> userTagList1 = data.stream().filter(s -> s.getStandardCondition() == 1).collect(Collectors.toList()); - int old_times = 0; - Integer userTagId = null; for (TUserTag tUserTag : userTagList1) { Integer times = JSON.parseObject(tUserTag.getConditions()).getInteger("times"); - //加上本次充电 - //获取最大值标签 - if((count1 + 1) >= times && old_times < times){ - userTagId = tUserTag.getId(); - old_times = times; - } - } - if(null != userTagId){ TAppUserTag appUserTag = new TAppUserTag(); appUserTag.setAppUserId(chargingOrder.getAppUserId()); - appUserTag.setUserTagId(userTagId); + appUserTag.setUserTagId(tUserTag.getId()); TAppUserTag data1 = appUserTagClient.getUserTag(appUserTag).getData(); - if(null == data1){ + + String start = tUserTag.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + String end = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + long count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) + .eq(TChargingOrder::getRechargePaymentStatus, 2).between(TChargingOrder::getStartTime, start, end).eq(TChargingOrder::getDelFlag, 0)); + if(null == data1 && count1 >= times){ data1 = new TAppUserTag(); data1.setAppUserId(chargingOrder.getAppUserId()); - data1.setUserTagId(userTagId); + data1.setUserTagId(tUserTag.getId()); data1.setCreateTime(LocalDateTime.now()); appUserTagClient.addUserTag(data1); } @@ -930,10 +923,9 @@ endTime.plusDays(day); String start = tUserTag.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String end = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) - .eq(TChargingOrder::getRechargePaymentStatus, 2).isNotNull(TChargingOrder::getPaymentAmount) - .between(TChargingOrder::getStartTime, start, end).eq(TChargingOrder::getDelFlag, 0)); - if(null == data1 && (count1 + 1) >= times){ + long count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) + .eq(TChargingOrder::getRechargePaymentStatus, 2).between(TChargingOrder::getStartTime, start, end).eq(TChargingOrder::getDelFlag, 0)); + if(null == data1 && count1 >= times){ data1 = new TAppUserTag(); data1.setAppUserId(chargingOrder.getAppUserId()); data1.setUserTagId(tUserTag.getId()); @@ -1166,6 +1158,16 @@ public R<PageInfo<PayOrderDto>> payOrderQuery(PayOrderQueryDto payOrderQueryDto) { PageInfo<PayOrderDto> pageInfo = new PageInfo<>(payOrderQueryDto.getPageCurr(),payOrderQueryDto.getPageSize()); List<PayOrderDto> list = this.baseMapper.payOrderQuery(pageInfo,payOrderQueryDto); + for (PayOrderDto payOrderDto : list) { + if (payOrderDto.getType()==2||payOrderDto.getType()==3){ + payOrderDto.setFinalAmount(payOrderDto.getOrderAmount()); + } + if (payOrderDto.getType()==1&&payOrderDto.getStatus()==3){ + payOrderDto.setFinalAmount(payOrderDto.getRechargeAmount()); + payOrderDto.setOrderAmount(payOrderDto.getRechargeAmount()); + payOrderDto.setPaymentAmount(payOrderDto.getRechargeAmount()); + } + } pageInfo.setRecords(list); return R.ok(pageInfo); } @@ -1319,7 +1321,9 @@ carId.add(chargingOrderListVO.getAppUserCarId()); if (!carId.isEmpty()){ List<TAppUserCar> data4 = appUserCarClient.getCarByIds(carId).getData(); - if (data4!=null && !data4.isEmpty()) chargingOrderListVO.setLicensePlate(data4.get(0).getLicensePlate()); + if (data4!=null && !data4.isEmpty()) { + chargingOrderListVO.setLicensePlate(data4.get(0).getLicensePlate()); + } } } chargingOrderListVO.setPhone(data3.getPhone()); @@ -1977,7 +1981,7 @@ } @Override public List<Map<String, Object>> usersByQuery1(ChargingStatisticsQueryDto statisticsQueryDto) { - return this.baseMapper.usersByQuery(statisticsQueryDto); + return this.baseMapper.usersByQuery1(statisticsQueryDto); } @Override @@ -2011,7 +2015,7 @@ } @Override - public Long getAver(List<Integer> siteIds) { + public Double getAver(List<Integer> siteIds) { return this.baseMapper.getAver(siteIds); } @@ -2029,6 +2033,11 @@ public R payRefund(PayOrderRefundDto payOrderQueryDto) { if (payOrderQueryDto.getType()==1){ TChargingOrder tChargingOrder = this.baseMapper.selectById(payOrderQueryDto.getOrderId()); + if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount())==-1){ + return R.fail("退款金额需小于支付金额"); + } + + TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); chargingOrderRefund.setChargingOrderId(tChargingOrder.getId()); chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount()); @@ -2041,7 +2050,7 @@ chargingOrderRefund.setRefundTitle("后台退款"); chargingOrderRefund.setRefundContent("后台退款"); chargingOrderRefund.setRefundReason("后台退款"); - chargingOrderRefund.setRefundRemark("后台退款"); + chargingOrderRefund.setRefundRemark(payOrderQueryDto.getRemark()); chargingOrderRefund.setRefundTotalAmount(tChargingOrder.getRefundAmount().add(payOrderQueryDto.getRefundAmount())); chargingOrderRefund.setPayAmount(tChargingOrder.getPaymentAmount()); @@ -2090,6 +2099,9 @@ } if (payOrderQueryDto.getType()==2){ TShoppingOrder tChargingOrder = shoppingOrderService.getById(payOrderQueryDto.getOrderId()); + if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount())==-1){ + return R.fail("退款金额需小于支付金额"); + } TShoppingOrderRefund chargingOrderRefund = new TShoppingOrderRefund(); chargingOrderRefund.setShoppingOrderId(tChargingOrder.getId()); chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount()); @@ -2102,7 +2114,7 @@ chargingOrderRefund.setRefundTitle("后台退款"); chargingOrderRefund.setRefundContent("后台退款"); chargingOrderRefund.setRefundReason("后台退款"); - chargingOrderRefund.setRefundRemark("后台退款"); + chargingOrderRefund.setRefundRemark(payOrderQueryDto.getRemark()); chargingOrderRefund.setRefundTotalAmount(tChargingOrder.getRefundAmount().add(payOrderQueryDto.getRefundAmount())); chargingOrderRefund.setPayAmount(tChargingOrder.getPaymentAmount()); @@ -2139,6 +2151,10 @@ tChargingOrder.setRefundStatus(2); tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); + + if (payOrderQueryDto.getRefundAmount().compareTo(tChargingOrder.getPaymentAmount())==0){ + tChargingOrder.setStatus(5); + } shoppingOrderService.updateById(tChargingOrder); shoppingOrderRefundService.save(chargingOrderRefund); @@ -2632,4 +2648,9 @@ info.setDuration(0 == hour ? String.format("%s分钟", second) : String.format("%s小时%s分钟", hour, second)); return info; } + + @Override + public Long countNoTag() { + return this.baseMapper.countNoTag(); + } } -- Gitblit v1.7.1