From ab53b52282c4ee0e57ae0fdb398de23b0949651a Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期五, 25 十月 2024 19:11:37 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 65 +++++++++++++++++++++++--------- 1 files changed, 47 insertions(+), 18 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 f07ea73..c41c544 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 @@ -608,12 +608,16 @@ if(times > m){ //充电时间跨度两个计费策略,需要继续对下一个策略进行计算 serviceCharge = s_server_amount.multiply(new BigDecimal(m)); - discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); rechargeAmount1 = rechargeAmount1.subtract(s_total_amount.multiply(new BigDecimal(m))); + if(null != discount){ + discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); + } nowTimeMillis = null; }else{ serviceCharge = s_server_amount.multiply(new BigDecimal(times)); - discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); + if(null != discount){ + discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); + } break; } } @@ -708,6 +712,9 @@ preChargeCheck1.setStartupSuccess(2); order.setStatus(3); order.setStartTime(LocalDateTime.now()); + TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData(); + chargingGun.setStatus(4); + chargingGunClient.updateChargingGunById(chargingGun); } redisService.setCacheObject("AQJC_" + order.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS); this.updateById(order); @@ -789,6 +796,9 @@ one.setRefundStatus(2); one.setRefundTime(LocalDateTime.now()); chargingOrderRefundService.updateById(one); + TChargingOrder chargingOrder = this.getById(one.getChargingOrderId()); + chargingOrder.setPayTime(LocalDateTime.now()); + this.updateById(chargingOrder); return AjaxResult.success(); } @@ -1275,12 +1285,12 @@ List<ChargingOrderListVO> list = this.baseMapper.chargingList(pageInfo,dto,startTime1,startTime2,endTime1,endTime2); for (ChargingOrderListVO chargingOrderListVO : list) { chargingOrderListVO.setChargingCapacity(chargingOrderListVO.getElectricity()); - chargingOrderListVO.setPaymentAmount(chargingOrderListVO.getOrderAmount()); + chargingOrderListVO.setPaymentAmount(chargingOrderListVO.getPaymentAmount()); BigDecimal bigDecimal = new BigDecimal("0.006"); - if (chargingOrderListVO.getServiceCharge()!=null){ - chargingOrderListVO.setCommissionAmount(chargingOrderListVO.getServiceCharge().multiply(bigDecimal)); + if (chargingOrderListVO.getOrderAmount()!=null){ + chargingOrderListVO.setCommissionAmount(chargingOrderListVO.getOrderAmount().multiply(bigDecimal)); } - chargingOrderListVO.setPaymentAmount(chargingOrderListVO.getResidualAmount()==null?chargingOrderListVO.getPaymentAmount():chargingOrderListVO.getPaymentAmount().subtract(chargingOrderListVO.getResidualAmount())); + chargingOrderListVO.setPaymentAmount(chargingOrderListVO.getResidualAmount()==null?chargingOrderListVO.getPaymentAmount():chargingOrderListVO.getPaymentAmount()); chargingOrderListVO.setUid(chargingOrderListVO.getId()+""); List<Integer> integers = new ArrayList<>(); integers.add(chargingOrderListVO.getSiteId()); @@ -1404,7 +1414,7 @@ for (ChargingOrderListVO chargingOrderListVO : list1) { if (chargingOrderListVO.getChargingCapacity()!=null)electronic = electronic.add(chargingOrderListVO.getElectricity()); - if (chargingOrderListVO.getPaymentAmount()!=null)paymentAmount = paymentAmount.add(chargingOrderListVO.getOrderAmount()); + if (chargingOrderListVO.getPaymentAmount()!=null)paymentAmount = paymentAmount.add(chargingOrderListVO.getPaymentAmount()); if (chargingOrderListVO.getElectrovalence()!=null)electrovalence = electrovalence.add(chargingOrderListVO.getElectrovalence()); if (chargingOrderListVO.getServiceCharge()!=null)serviceCharge = serviceCharge.add(chargingOrderListVO.getServiceCharge()); List<TChargingOrderAccountingStrategy> list2 = chargingOrderAccountingStrategyService.lambdaQuery() @@ -1494,8 +1504,8 @@ chargingOrderListInfoVO.setStatus(chargingOrder.getStatus()); BigDecimal bigDecimal = new BigDecimal("0.006"); - if (chargingOrder.getServiceCharge()!=null){ - chargingOrderListInfoVO.setCommissionAmount(chargingOrder.getServiceCharge().multiply(bigDecimal)); + if (chargingOrder.getOrderAmount()!=null){ + chargingOrderListInfoVO.setCommissionAmount(chargingOrder.getOrderAmount().multiply(bigDecimal)); } chargingOrderListInfoVO.setElectrovalence(chargingOrder.getElectrovalence()); chargingOrderListInfoVO.setServiceCharge(chargingOrder.getServiceCharge()); @@ -1859,7 +1869,7 @@ //开始将优惠券优惠的金额添加到明细中 BigDecimal couponDiscountAmount = order.getCouponDiscountAmount(); - if(couponDiscountAmount.compareTo(BigDecimal.ZERO) > 0){ + if(null != couponDiscountAmount && couponDiscountAmount.compareTo(BigDecimal.ZERO) > 0){ List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, order.getId())); for (TChargingOrderAccountingStrategy chargingOrderAccountingStrategy : list) { BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodServicePrice(); @@ -1927,7 +1937,7 @@ chargingOrderRefund.setRefundTitle("充电完成退款"); chargingOrderRefund.setRefundContent("充电完成退款"); chargingOrderRefund.setRefundReason("充电完成退款"); - chargingOrderRefund.setRefundRemark("充电完成退款"); + chargingOrderRefund.setRefundRemark("实际充电消费金额:" + refundAmount); chargingOrderRefund.setRefundTotalAmount(refundAmount); chargingOrderRefund.setPayAmount(rechargeAmount); if(1 == rechargePaymentType){ @@ -1957,6 +1967,8 @@ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); AjaxResult success = chargingOrderStartupFailureWxRefund(resp.getOutTradeNo(), resp.getTradeNo(), "SUCCESS", sdf1.format(new Date())); if(success.isSuccess()){ + chargingOrder.setPayTime(LocalDateTime.now()); + this.updateById(chargingOrder); chargingOrderRefundService.save(chargingOrderRefund); } } @@ -2035,7 +2047,7 @@ } @Override - public Long getAver(List<Integer> siteIds) { + public Double getAver(List<Integer> siteIds) { return this.baseMapper.getAver(siteIds); } @@ -2053,6 +2065,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()); @@ -2078,7 +2095,7 @@ model.setNotify_url("/order/t-shopping-order/cancelShoppingOrderWxRefund"); WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); amount.setRefund(payOrderQueryDto.getRefundAmount().multiply(new BigDecimal(100)).intValue()); - amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); + amount.setTotal(tChargingOrder.getRechargeAmount().multiply(new BigDecimal(100)).intValue()); amount.setCurrency("CNY"); model.setAmount(amount); R<String> orderR = wxPaymentClient.refundOrderR(model); @@ -2114,6 +2131,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()); @@ -2163,6 +2183,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); @@ -2282,10 +2306,10 @@ } if (tChargingOrder.getRefundStatus()!=null &&tChargingOrder.getRefundStatus() == 2){ // 如果成功退款 那么减去退款金额 - paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount().subtract(tChargingOrder.getRefundAmount())); + paymentAmount = paymentAmount.add(tChargingOrder.getOrderAmount()); }else{ if (tChargingOrder.getPaymentAmount()!=null){ - paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); + paymentAmount = paymentAmount.add(tChargingOrder.getOrderAmount()); } } } @@ -2293,8 +2317,8 @@ commissionAmount = sharingAmount.multiply(new BigDecimal("0.006")); // 订单手续费 订单支付金额 - 退款金额*0.6% orderCommission = paymentAmount.multiply(new BigDecimal("0.006")); - tSettlementConfirm.setSharingAmount(sharingAmount); - tSettlementConfirm.setCommissionAmount(commissionAmount); + tSettlementConfirm.setSharingAmount(sharingAmount.setScale(2, RoundingMode.HALF_DOWN)); + tSettlementConfirm.setCommissionAmount(commissionAmount.setScale(2, RoundingMode.HALF_DOWN)); tSettlementConfirm.setElectrovalence(electrovalence); // 服务费=总服务费-三费收费-交易手续费-交易手续费-服务费会员抵扣-服务费优惠券抵扣 tSettlementConfirm.setServiceCharge(serviceCharge.subtract(commissionAmount).subtract(sharingAmount).subtract(orderCommission).subtract(vipDiscount).subtract(couponDiscount)); @@ -2536,7 +2560,7 @@ tSettlementConfirm.setIncomePercentage(0+"%"); tSettlementConfirm.setIncomePercentage(0+"%"); }else{ - BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")); + BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome,2,RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")); tSettlementConfirm.setIncomePercentage(subtract+"%"); tSettlementConfirm.setIncomePercentage(subtract+"%"); @@ -2656,4 +2680,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