| | |
| | | String end_time = vo.getEnd_time(); |
| | | long start = sdfs.parse(start_time).getTime(); |
| | | long end = sdfs.parse(end_time).getTime(); |
| | | boolean b = false; |
| | | Class<? extends TransactionRecordMessageVO> clazz = vo.getClass(); |
| | | for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | | AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i); |
| | | long time = sdfs.parse(start_time.split(" ")[0] + " " + strategyDetail.getStartTime() + ":00").getTime(); |
| | | if(start >= time){ |
| | | b = true; |
| | | /** |
| | | * "start_time": "2025-01-03 23:06:43.00", |
| | | * "end_time": "2025-01-04 00:39:39.00", |
| | | */ |
| | | for (int i = accountingStrategyDetailOrderList.size(); i > 0; i--) { |
| | | AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i - 1); |
| | | long time = sdfs.parse(start_time.split(" ")[0] + " " + strategyDetail.getEndTime() + ":00").getTime(); |
| | | if(time < start){ |
| | | break; |
| | | } |
| | | //开始充电 |
| | | if(b){ |
| | | //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | Object invoke = null; |
| | | switch (strategyDetail.getType()){ |
| | | case 1: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 2: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 3: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 4: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | } |
| | | if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | continue; |
| | | } |
| | | BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | BeanUtils.copyProperties(strategyDetail, vo1); |
| | | vo1.setChargingCapacity(sharp_peak_charge); |
| | | lists.add(vo1); |
| | | //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | Object invoke = null; |
| | | switch (strategyDetail.getType()){ |
| | | case 1: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getSpike_charge" + (i)).invoke(vo); |
| | | break; |
| | | case 2: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getPeak_charge" + (i)).invoke(vo); |
| | | break; |
| | | case 3: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getFlat_charge" + (i)).invoke(vo); |
| | | break; |
| | | case 4: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getValley_charge" + (i)).invoke(vo); |
| | | break; |
| | | } |
| | | if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | continue; |
| | | } |
| | | BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | BeanUtils.copyProperties(strategyDetail, vo1); |
| | | vo1.setChargingCapacity(sharp_peak_charge); |
| | | lists.add(vo1); |
| | | } |
| | | |
| | | //第二天的 |
| | |
| | | if(time > end){ |
| | | break; |
| | | } |
| | | //开始充电 |
| | | if(b){ |
| | | //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | Object invoke = null; |
| | | switch (strategyDetail.getType()){ |
| | | case 1: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 2: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 3: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 4: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | } |
| | | if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | continue; |
| | | } |
| | | BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | BeanUtils.copyProperties(strategyDetail, vo1); |
| | | vo1.setChargingCapacity(sharp_peak_charge); |
| | | lists.add(vo1); |
| | | //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | Object invoke = null; |
| | | switch (strategyDetail.getType()){ |
| | | case 1: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 2: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 3: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 4: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | } |
| | | if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | continue; |
| | | } |
| | | BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | BeanUtils.copyProperties(strategyDetail, vo1); |
| | | vo1.setChargingCapacity(sharp_peak_charge); |
| | | lists.add(vo1); |
| | | } |
| | | }else{ |
| | | for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 停止充电返回账单后计算费用 |
| | | // * @param vo |
| | | // */ |
| | | // @Override |
| | | // @GlobalTransactional(rollbackFor = Exception.class) |
| | | // public void endChargeBillingCharge1(TransactionRecordMessageVO vo) { |
| | | // TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, vo.getTransaction_serial_number())); |
| | | // Integer status = chargingOrder.getStatus(); |
| | | //// if(status == 5){ |
| | | //// return; |
| | | //// } |
| | | // |
| | | // //如果使用优惠券需要判断优惠券是否满足使用条件 |
| | | // //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | // //退款金额=优惠券金额+剩余充电金额 |
| | | // BigDecimal periodElectricPrice_total = BigDecimal.ZERO; |
| | | // BigDecimal periodServicePrice_total = BigDecimal.ZERO; |
| | | // BigDecimal total = BigDecimal.ZERO; |
| | | // |
| | | // //获取订单的计费策略 |
| | | // List<AccountingStrategyDetailOrder> accountingStrategyDetailOrderList = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); |
| | | // accountingStrategyDetailOrderList.get(accountingStrategyDetailOrderList.size() - 1).setEndTime("23:59"); |
| | | // //开始处理计费明细数据和优惠数据 |
| | | //// chargingOrderAccountingStrategyService.remove(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId())); |
| | | // SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // List<AccountingStrategyDetailOrderVo> lists = new ArrayList<>(); |
| | | // try { |
| | | // //跨天 |
| | | // if(!vo.getStart_time().split(" ")[0].equals(vo.getEnd_time().split(" ")[0])){ |
| | | // //当天的 |
| | | // //开始通过计费策略遍历解析每个时段的费用明细 |
| | | // String start_time = vo.getStart_time(); |
| | | // String end_time = vo.getEnd_time(); |
| | | // long start = sdfs.parse(start_time).getTime(); |
| | | // long end = sdfs.parse(end_time).getTime(); |
| | | // Class<? extends TransactionRecordMessageVO> clazz = vo.getClass(); |
| | | // /** |
| | | // * "start_time": "2025-01-03 23:06:43.00", |
| | | // * "end_time": "2025-01-04 00:39:39.00", |
| | | // */ |
| | | // for (int i = accountingStrategyDetailOrderList.size(); i > 0; i--) { |
| | | // AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i - 1); |
| | | // long time = sdfs.parse(start_time.split(" ")[0] + " " + strategyDetail.getEndTime() + ":00").getTime(); |
| | | // if(time < start){ |
| | | // break; |
| | | // } |
| | | // //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | // Object invoke = null; |
| | | // switch (strategyDetail.getType()){ |
| | | // case 1: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getSpike_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // case 2: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getPeak_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // case 3: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getFlat_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // case 4: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getValley_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // } |
| | | // if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | // continue; |
| | | // } |
| | | // BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | // AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | // BeanUtils.copyProperties(strategyDetail, vo1); |
| | | // vo1.setChargingCapacity(sharp_peak_charge); |
| | | // lists.add(vo1); |
| | | // } |
| | | // |
| | | // //第二天的 |
| | | // //开始通过计费策略遍历解析每个时段的费用明细 |
| | | // for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | | // AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i); |
| | | // long time = sdfs.parse(end_time.split(" ")[0] + " " + strategyDetail.getStartTime() + ":00").getTime(); |
| | | // if(time > end){ |
| | | // break; |
| | | // } |
| | | // //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | // Object invoke = null; |
| | | // switch (strategyDetail.getType()){ |
| | | // case 1: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 2: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 3: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 4: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // } |
| | | // if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | // continue; |
| | | // } |
| | | // BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | // AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | // BeanUtils.copyProperties(strategyDetail, vo1); |
| | | // vo1.setChargingCapacity(sharp_peak_charge); |
| | | // lists.add(vo1); |
| | | // } |
| | | // }else{ |
| | | // for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | | // Class<? extends TransactionRecordMessageVO> clazz = vo.getClass(); |
| | | // AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i); |
| | | // //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | // Object invoke = null; |
| | | // switch (strategyDetail.getType()){ |
| | | // case 1: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 2: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 3: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 4: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // } |
| | | // if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | // continue; |
| | | // } |
| | | // BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | // AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | // BeanUtils.copyProperties(strategyDetail, vo1); |
| | | // vo1.setChargingCapacity(sharp_peak_charge); |
| | | // lists.add(vo1); |
| | | // } |
| | | // } |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // //开始处理明细 |
| | | // for (int i = 0; i < lists.size(); i++) { |
| | | // AccountingStrategyDetailOrderVo strategyDetail = lists.get(i); |
| | | // BigDecimal sharp_peak_charge = strategyDetail.getChargingCapacity(); |
| | | // TChargingOrderAccountingStrategy chargingOrderAccountingStrategy = new TChargingOrderAccountingStrategy(); |
| | | // chargingOrderAccountingStrategy.setChargingOrderId(chargingOrder.getId()); |
| | | // chargingOrderAccountingStrategy.setAccountingStrategyDetailId(strategyDetail.getId()); |
| | | // chargingOrderAccountingStrategy.setType(strategyDetail.getType()); |
| | | // chargingOrderAccountingStrategy.setElectrovalence(strategyDetail.getElectrovalence()); |
| | | // chargingOrderAccountingStrategy.setServiceCharge(strategyDetail.getServiceCharge()); |
| | | // chargingOrderAccountingStrategy.setCostServiceCharge(strategyDetail.getCostServiceCharge()); |
| | | // if(i == 0){ |
| | | // String time = vo.getStart_time().split(" ")[1]; |
| | | // chargingOrderAccountingStrategy.setStartTime(time.substring(0, time.lastIndexOf(":"))); |
| | | // }else{ |
| | | // chargingOrderAccountingStrategy.setStartTime(strategyDetail.getStartTime()); |
| | | // } |
| | | // if(i == lists.size() - 1){ |
| | | // String time = vo.getEnd_time().split(" ")[1]; |
| | | // chargingOrderAccountingStrategy.setEndTime(time.substring(0, time.lastIndexOf(":"))); |
| | | // }else{ |
| | | // chargingOrderAccountingStrategy.setEndTime(strategyDetail.getEndTime()); |
| | | // } |
| | | // |
| | | // //已充电总度数 |
| | | // BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(sharp_peak_charge); |
| | | // BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(sharp_peak_charge); |
| | | // BigDecimal serviceCharge = originalServicePrice; |
| | | // BigDecimal vipDiscountAmount = BigDecimal.ZERO; |
| | | // //计算优惠金额 |
| | | // if(null != chargingOrder.getVipDiscount()){ |
| | | // vipDiscountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(chargingOrder.getVipDiscount())); |
| | | // serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount()); |
| | | // } |
| | | // chargingOrderAccountingStrategy.setChargingCapacity(sharp_peak_charge); |
| | | // chargingOrderAccountingStrategy.setPeriodElectricPrice(electrovalenc.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setPeriodServicePrice(serviceCharge.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setPeriodOriginalServicePrice(originalServicePrice.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setVipDiscountAmount(vipDiscountAmount.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setCreateTime(LocalDateTime.now()); |
| | | //// chargingOrderAccountingStrategyService.save(chargingOrderAccountingStrategy); |
| | | // System.err.println("----------"+JSON.toJSONString(chargingOrderAccountingStrategy)); |
| | | // |
| | | // periodElectricPrice_total = periodElectricPrice_total.add(electrovalenc); |
| | | // periodServicePrice_total = periodServicePrice_total.add(originalServicePrice); |
| | | // total = total.add(electrovalenc.add(originalServicePrice)); |
| | | // |
| | | // } |
| | | // |
| | | // |
| | | // //原金额 |
| | | // BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | // BigDecimal vipDiscountAmount = chargingOrder.getVipDiscountAmount(); |
| | | // //总金额(充值金额+会员折扣金额) |
| | | // BigDecimal decimal = rechargeAmount.add(vipDiscountAmount); |
| | | // //退款金额(已经计算了折扣优惠部分) |
| | | // //如果充电总金额未使用完,则需要退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | // BigDecimal refundAmount = rechargeAmount.divide(decimal, new MathContext(4, RoundingMode.HALF_EVEN)).multiply(decimal.subtract(total)); |
| | | // BigDecimal orderAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | // BigDecimal payAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | // //折扣金额 |
| | | // BigDecimal discountAmount = BigDecimal.ZERO; |
| | | //// if(null != chargingOrder.getVipDiscount()){ |
| | | //// TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | //// //判断会员是否还有充电优惠次数 |
| | | //// GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | //// getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | //// getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | //// TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | //// if(null != data && data.getChargeNum() > 0){ |
| | | //// data.setChargeNum(data.getChargeNum() - 1); |
| | | //// appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | //// |
| | | //// //服务费折扣 |
| | | //// discountAmount = periodServicePrice_total.multiply((new BigDecimal(1).subtract(chargingOrder.getVipDiscount()))); |
| | | //// TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | //// BigDecimal maximumDeduction = vip.getMaximumDeduction(); |
| | | //// //普通会员有最高优惠限制 |
| | | //// if(vip.getType() == 1 && discountAmount.compareTo(maximumDeduction) > 0){ |
| | | //// discountAmount = maximumDeduction; |
| | | //// } |
| | | //// } |
| | | //// } |
| | | // //会员折扣金额 |
| | | // discountAmount = discountAmount.setScale(4, RoundingMode.HALF_EVEN); |
| | | // payAmount = payAmount.subtract(discountAmount); |
| | | // periodServicePrice_total = periodServicePrice_total.subtract(discountAmount); |
| | | // |
| | | // TChargingOrder order = new TChargingOrder(); |
| | | // order.setId(chargingOrder.getId()); |
| | | // order.setAppUserId(chargingOrder.getAppUserId()); |
| | | // UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | // if(null != uploadRealTimeMonitoringData && null == chargingOrder.getEndMode()){ |
| | | // Integer soc = uploadRealTimeMonitoringData.getSoc(); |
| | | // order.setEndMode(soc > 98 ? 2 : 3); |
| | | // }else{ |
| | | // order.setEndMode(1); |
| | | // } |
| | | // order.setResidualAmount(rechargeAmount.subtract(total).setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setStartTime(LocalDateTime.parse(vo.getStart_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | // order.setEndTime(LocalDateTime.parse(vo.getEnd_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | // order.setStatus(5); |
| | | // order.setOrderAmount(orderAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setVipDiscountAmount(discountAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setChargingCapacity(vo.getTotal_electricity()); |
| | | // order.setElectricity(vo.getTotal_electricity()); |
| | | // |
| | | // //计算优惠券 |
| | | // BigDecimal couponDiscount = BigDecimal.ZERO; |
| | | //// if(null != chargingOrder.getAppCouponId()){ |
| | | //// //判断实际充电金额是否满足优惠券使用条件,如果不满足则不适用优惠券。 |
| | | //// TAppCoupon appCoupon = appCouponClient.getAppCouponById(chargingOrder.getAppCouponId()).getData(); |
| | | //// String couponJson = appCoupon.getCouponJson(); |
| | | //// TCoupon tCoupon = JSON.parseObject(couponJson, TCoupon.class); |
| | | //// Integer preferentialMode = tCoupon.getPreferentialMode(); |
| | | //// if(1 == preferentialMode){ |
| | | //// //满减 |
| | | //// if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ |
| | | //// BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount(); |
| | | //// //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | //// if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){ |
| | | //// couponDiscount = periodServicePrice_total; |
| | | //// periodServicePrice_total = BigDecimal.ZERO; |
| | | //// }else{ |
| | | //// couponDiscount = couponDiscountAmount; |
| | | //// } |
| | | //// appCoupon.setStatus(2); |
| | | ////// appCouponClient.updateAppCoupon(appCoupon); |
| | | //// }else{ |
| | | //// order.setAppCouponId(null); |
| | | //// order.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | ////// appCouponClient.refund(chargingOrder.getAppCouponId().toString()); |
| | | //// } |
| | | //// } |
| | | //// if(2 == preferentialMode){ |
| | | //// //抵扣 |
| | | //// if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ |
| | | //// //折扣金额 |
| | | //// BigDecimal divide = payAmount.multiply(new BigDecimal(10).subtract(tCoupon.getDiscount())).divide(new BigDecimal(10)); |
| | | //// divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; |
| | | //// //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | //// if(periodServicePrice_total.compareTo(divide) < 0){ |
| | | //// couponDiscount = periodServicePrice_total; |
| | | //// periodServicePrice_total = BigDecimal.ZERO; |
| | | //// }else{ |
| | | //// couponDiscount = divide; |
| | | //// } |
| | | //// |
| | | //// appCoupon.setStatus(2); |
| | | //// appCouponClient.updateAppCoupon(appCoupon); |
| | | //// }else{ |
| | | //// order.setAppCouponId(null); |
| | | //// order.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | //// appCouponClient.refund(chargingOrder.getAppCouponId().toString()); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | // //优惠券优惠金额 |
| | | // couponDiscount = couponDiscount.setScale(4, RoundingMode.HALF_EVEN); |
| | | // refundAmount = refundAmount.add(couponDiscount); |
| | | // payAmount = payAmount.subtract(couponDiscount); |
| | | // if(periodServicePrice_total.compareTo(BigDecimal.ZERO) > 0){ |
| | | // periodServicePrice_total = periodServicePrice_total.subtract(couponDiscount); |
| | | // } |
| | | // order.setCouponDiscountAmount(couponDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setServiceCharge(periodServicePrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setPaymentAmount(payAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setRefundAmount(refundAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setRefundStatus(1); |
| | | //// this.updateById(order); |
| | | // System.err.println("----------"+JSON.toJSONString(order)); |
| | | //// chargingOrder = this.getById(order.getId()); |
| | | //// |
| | | //// //开始将优惠券优惠的金额添加到明细中 |
| | | //// BigDecimal couponDiscountAmount = order.getCouponDiscountAmount(); |
| | | //// if(null != couponDiscountAmount && couponDiscountAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | //// List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, order.getId())); |
| | | //// BigDecimal reduce = list.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //// for (TChargingOrderAccountingStrategy chargingOrderAccountingStrategy : list) { |
| | | //// BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodServicePrice(); |
| | | //// BigDecimal multiply = couponDiscountAmount.multiply(periodServicePrice.divide(reduce, new MathContext(4, RoundingMode.HALF_EVEN))); |
| | | //// periodServicePrice = periodServicePrice.subtract(multiply); |
| | | //// chargingOrderAccountingStrategy.setPeriodServicePrice(periodServicePrice.setScale(2, RoundingMode.HALF_EVEN)); |
| | | //// chargingOrderAccountingStrategy.setCouponDiscountAmount(multiply.setScale(2, RoundingMode.HALF_EVEN)); |
| | | //// } |
| | | ////// chargingOrderAccountingStrategyService.updateBatchById(list); |
| | | //// } |
| | | //// |
| | | //// // 将枪状态重置为空闲 |
| | | //// TChargingGun chargingGun = new TChargingGun(); |
| | | //// chargingGun.setId(chargingOrder.getChargingGunId()); |
| | | //// chargingGun.setStatus(2); |
| | | //// chargingGun.setChargingPower(BigDecimal.ZERO); |
| | | ////// chargingGunClient.updateChargingGunById(chargingGun); |
| | | //// |
| | | //// //添加积分 |
| | | //// TIntegralRule integralRule = integralRuleClient.getSet().getData(); |
| | | //// if(null != integralRule){ |
| | | //// TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | //// Integer num1 = JSON.parseObject(integralRule.getChargeCredit()).getInteger("num1"); |
| | | //// Integer integral = chargingOrder.getServiceCharge().intValue() * num1; |
| | | //// if(null != appUser.getVipId()){ |
| | | //// TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | //// Integer doubleIntegration = vip.getDoubleIntegration(); |
| | | //// //双倍积分 |
| | | //// if(1 == doubleIntegration){ |
| | | //// integral *= 2; |
| | | //// } |
| | | //// } |
| | | //// |
| | | //// if(integral > 0){ |
| | | //// TAppUserIntegralChange appUserIntegralChange = new TAppUserIntegralChange(); |
| | | //// appUserIntegralChange.setAppUserId(appUser.getId()); |
| | | //// appUserIntegralChange.setChangeType(2); |
| | | //// appUserIntegralChange.setHistoricalIntegral(appUser.getPoints()); |
| | | //// appUser.setPoints(appUser.getPoints() + integral); |
| | | //// appUserIntegralChange.setCurrentIntegral(appUser.getPoints()); |
| | | //// appUserIntegralChange.setCreateTime(LocalDateTime.now()); |
| | | //// appUserIntegralChange.setOrderCode(chargingOrder.getCode()); |
| | | //// appUserIntegralChange.setExtension(chargingOrder.getId().toString()); |
| | | //// appUserClient.updateAppUser(appUser); |
| | | //// appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange); |
| | | //// } |
| | | //// } |
| | | //// |
| | | //// //计算用户标签 |
| | | //// editUserTag(chargingOrder); |
| | | //// //用户推荐奖励 |
| | | //// referralReward(chargingOrder); |
| | | //// |
| | | //// //开始构建退款费用 |
| | | //// if(refundAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | //// Integer rechargePaymentType = chargingOrder.getRechargePaymentType(); |
| | | //// //构建退款明细 |
| | | //// TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); |
| | | //// chargingOrderRefund.setChargingOrderId(chargingOrder.getId()); |
| | | //// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | //// chargingOrderRefund.setRefundCode("CDF" + sdf.format(new Date()) + (Double.valueOf(Math.random() * 1000).intValue())); |
| | | //// chargingOrderRefund.setRefundAmount(refundAmount); |
| | | //// chargingOrderRefund.setRefundStatus(1); |
| | | //// chargingOrderRefund.setPayType(rechargePaymentType); |
| | | //// chargingOrderRefund.setRefundStatus(1); |
| | | //// chargingOrderRefund.setCode(chargingOrder.getCode()); |
| | | //// chargingOrderRefund.setRefundTitle("充电完成退款"); |
| | | //// chargingOrderRefund.setRefundContent("充电完成退款"); |
| | | //// chargingOrderRefund.setRefundReason("充电完成退款"); |
| | | //// chargingOrderRefund.setRefundRemark("实际充电消费金额:" + chargingOrder.getPaymentAmount()); |
| | | //// chargingOrderRefund.setRefundTotalAmount(refundAmount); |
| | | //// chargingOrderRefund.setPayAmount(rechargeAmount); |
| | | //// if(1 == rechargePaymentType){ |
| | | //// WxPaymentRefundModel model = new WxPaymentRefundModel(); |
| | | //// model.setOut_trade_no(chargingOrder.getCode()); |
| | | //// model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | //// model.setReason("充电完成退款"); |
| | | //// model.setNotify_url("/payment/wx/refund/notify"); |
| | | //// WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | //// amount.setRefund(refundAmount.multiply(new BigDecimal(100)).intValue()); |
| | | //// amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | //// amount.setCurrency("CNY"); |
| | | //// model.setAmount(amount); |
| | | //// R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | //// if(200 == orderR.getCode()){ |
| | | //// chargingOrderRefundService.save(chargingOrderRefund); |
| | | //// } |
| | | //// } |
| | | //// if(2 == rechargePaymentType){ |
| | | //// RefundReq dto = new RefundReq(); |
| | | //// dto.setOutTradeNo(chargingOrder.getCode()); |
| | | //// dto.setOutRequestNo(chargingOrderRefund.getCode()); |
| | | //// dto.setRefundAmount(refundAmount.toString()); |
| | | //// dto.setRefundReason("充电完成退款"); |
| | | //// RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | //// if(null != resp){ |
| | | //// AjaxResult success = chargingOrderStartupFailureWxRefund(resp.getOutTradeNo(), resp.getTradeNo(), "SUCCESS", null); |
| | | //// if(success.isSuccess()){ |
| | | //// chargingOrderRefundService.save(chargingOrderRefund); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | //// |
| | | //// } |
| | | // } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getByDate(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getByDate(chargingOrderIds); |