| | |
| | | long times = rechargeAmount1.divide(s_total_amount, 0, RoundingMode.DOWN).longValue(); |
| | | if(times > m){ |
| | | //充电时间跨度两个计费策略,需要继续对下一个策略进行计算 |
| | | serviceCharge = s_server_amount.multiply(new BigDecimal(m)); |
| | | serviceCharge = serviceCharge.add(s_server_amount.multiply(new BigDecimal(m))); |
| | | 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)); |
| | | if(null != discount){ |
| | | discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); |
| | | } |
| | | serviceCharge = serviceCharge.add(s_server_amount.multiply(new BigDecimal(times))); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(null != discount){ |
| | | discountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(discount)); |
| | | } |
| | | |
| | | if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ |
| | | //计算会员最大优惠金额 |
| | | TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | |
| | | } |
| | | } |
| | | discountAmount = discountAmount.setScale(4, RoundingMode.HALF_EVEN); |
| | | if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ |
| | | data.setChargeNum(data.getChargeNum() - 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //机子上显示的金额为用户充值的金额+会员折扣金额 |
| | | BigDecimal account_balance = chargingOrder.getRechargeAmount().add(discountAmount).setScale(4, RoundingMode.HALF_EVEN); |
| | |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | chargingOrderRefundService.updateById(chargingOrderRefund); |
| | | //回退会员折扣次数 |
| | | if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ |
| | | 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.setChargeNum(data.getChargeNum() + 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(2 == rechargePaymentType){ |
| | |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | //回退会员折扣次数 |
| | | if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ |
| | | 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.setChargeNum(data.getChargeNum() + 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | |
| | | List<TChargingPile> allPile = chargingGunClient.getAllPile().getData(); |
| | | List<Site> data9 = siteClient.getSiteAll().getData(); |
| | | List<TAppUser> data6 = appUserClient.getAllUser().getData(); |
| | | List<Partner> data7 = siteClient.getAllPartner().getData(); |
| | | List<TAppUserCar> data4 = appUserCarClient.getAllCar().getData(); |
| | | String startTime1 = null; |
| | | String startTime2 = null; |
| | |
| | | List<ChargingOrderVO> list1 = this.baseMapper.chargingOrder(pageInfo1,dto,startTime1,startTime2,endTime1,endTime2); |
| | | BigDecimal total = new BigDecimal("0"); |
| | | long time = 0L; |
| | | BigDecimal income = new BigDecimal("0"); |
| | | BigDecimal electronicMoney = new BigDecimal("0"); |
| | | BigDecimal serviceMoney = new BigDecimal("0"); |
| | | BigDecimal commissionMoney = new BigDecimal("0"); |
| | | BigDecimal refundMoney = new BigDecimal("0"); |
| | | BigDecimal paymentMoney = new BigDecimal("0"); |
| | | List<Long> collect = list.stream().map(TChargingOrder::getId).collect(Collectors.toList()); |
| | | List<TChargingOrderAccountingStrategy> list3 = new ArrayList<>(); |
| | | if(collect.size()>=800){ |
| | | int i = collect.size() / 800; |
| | | int k = collect.size() % 800; |
| | | for (int j = 0; j <= i; j++) { |
| | | if(j==i&& k>0){ |
| | | list3.addAll(chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,collect.subList(j * 800, j * 800 + k)).list()); |
| | | }else { |
| | | List<Long> longs = collect.subList(j * 800, (j + 1) * 800); |
| | | list3.addAll(chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,longs).list()); |
| | | } |
| | | } |
| | | }else { |
| | | list3 = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,collect).list(); |
| | | } |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | |
| | | for (ChargingOrderVO chargingOrderVO : list) { |
| | | if (roleType == 2){ |
| | | for (Integer siteId : siteIds) { |
| | |
| | | } |
| | | |
| | | |
| | | List<Long> orderIds = list1.stream().map(TChargingOrder::getId).collect(Collectors.toList()); |
| | | if(orderIds.isEmpty())orderIds.add(-1L); |
| | | List<TChargingOrderRefund> chargingOrderRefunds = chargingOrderRefundService.lambdaQuery() |
| | | .in(TChargingOrderRefund::getChargingOrderId, orderIds) |
| | | .eq(TChargingOrderRefund::getRefundStatus,2).list(); |
| | | |
| | | for (ChargingOrderVO chargingOrderVO : list1) { |
| | |
| | | BigDecimal feng = new BigDecimal("0"); |
| | | BigDecimal ping = new BigDecimal("0"); |
| | | BigDecimal gu = new BigDecimal("0"); |
| | | List<Long> collect = list1.stream().map(ChargingOrderListVO::getId).collect(Collectors.toList()); |
| | | List<TChargingOrderAccountingStrategy> chargingOrderAccountingStrategies = new ArrayList<>(); |
| | | if(collect.size()>=800){ |
| | | int i = collect.size() / 800; |
| | | int k = collect.size() % 800; |
| | | for (int j = 0; j <= i; j++) { |
| | | if(j==i&& k>0){ |
| | | chargingOrderAccountingStrategies.addAll(chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,collect.subList(j * 800, j * 800 + k)).list()); |
| | | }else { |
| | | List<Long> longs = collect.subList(j * 800, (j + 1) * 800); |
| | | chargingOrderAccountingStrategies.addAll(chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,longs).list()); |
| | | } |
| | | } |
| | | }else { |
| | | chargingOrderAccountingStrategies = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,collect).list(); |
| | | } |
| | | |
| | | List<TChargingOrderAccountingStrategy> chargingOrderAccountingStrategies = chargingOrderAccountingStrategyService.list(); |
| | | for (ChargingOrderListVO chargingOrderListVO : list1) { |
| | | if (chargingOrderListVO.getChargingCapacity()!=null)electronic = electronic.add(chargingOrderListVO.getElectricity()); |
| | | |
| | |
| | | if(null == chargingOrder){ |
| | | return R.ok(); |
| | | } |
| | | // Integer status = chargingOrder.getStatus(); |
| | | // if(status == 5){ |
| | | // return R.ok(); |
| | | // } |
| | | Integer status = chargingOrder.getStatus(); |
| | | if(status == 5){ |
| | | return R.ok(); |
| | | } |
| | | |
| | | //如果使用优惠券需要判断优惠券是否满足使用条件 |
| | | //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | |
| | | |
| | | } |
| | | // 累加分佣 |
| | | if (tChargingOrder.getSharingAmount()!=null) { |
| | | sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount()); |
| | | if (tChargingOrder.getOrderSource()==2) { |
| | | sharingAmount = sharingAmount.add(tChargingOrder.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | // 累加电费 |
| | | if (tChargingOrder.getElectrovalence()!=null) { |
| | |
| | | } |
| | | // 累加服务费 |
| | | if (tChargingOrder.getServiceCharge()!=null){ |
| | | serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge()); |
| | | |
| | | if (tChargingOrder.getOrderSource()==2) { |
| | | serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | }else{ |
| | | serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge()); |
| | | } |
| | | } |
| | | // 累加会员折扣 |
| | | if (tChargingOrder.getVipDiscountAmount()!=null){ |
| | |
| | | chargingOrder.setStatus(2); |
| | | chargingOrder.setPayTime(LocalDateTime.now()); |
| | | chargingOrder.setChargeAmount(chargingOrder.getRechargeAmount()); |
| | | chargingOrder.setVipDiscountAmount(BigDecimal.ZERO); |
| | | this.save(chargingOrder); |
| | | |
| | | Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); |