| | |
| | | @TableField("whitelist_discount_amount") |
| | | private BigDecimal whitelistDiscountAmount; |
| | | |
| | | @ApiModelProperty(value = "白名单电费退款金额") |
| | | @TableField("whitelist_electric_refund_amount") |
| | | private BigDecimal whitelistElectricRefundAmount; |
| | | |
| | | @ApiModelProperty(value = "白名单服务费退款金额") |
| | | @TableField("whitelist_service_refund_amount") |
| | | private BigDecimal whitelistServiceRefundAmount; |
| | | |
| | | @ApiModelProperty(value = "会员折扣") |
| | | @TableField("vip_discount") |
| | | private BigDecimal vipDiscount; |
| | |
| | | private Integer chargingGunId; |
| | | @ApiModelProperty(value = "订单来源(1=自己平台,2=三方平台)") |
| | | private Integer orderSource; |
| | | @ApiModelProperty(value = "是否白名单用户") |
| | | private Integer isWhitelist; |
| | | @ApiModelProperty(value = "白名单用户退款金额") |
| | | private BigDecimal whitelistRefundAmount; |
| | | @ApiModelProperty(value = "白名单电费退款金额") |
| | | private BigDecimal whitelistElectricRefundAmount; |
| | | @ApiModelProperty(value = "白名单服务费退款金额") |
| | | private BigDecimal whitelistServiceRefundAmount; |
| | | @ApiModelProperty(value = "订单编号") |
| | | private String code; |
| | | @ApiModelProperty(value = "订单类型(1=充电订单(小程序),2=充电订单(刷卡))") |
| | |
| | | private BigDecimal balanceIncome; |
| | | @ApiModelProperty(value = "赠送费用") |
| | | private BigDecimal balanceGiftIncome; |
| | | @ApiModelProperty(value = "白名单用户退款金额") |
| | | private BigDecimal whitelistRefundAmount; |
| | | |
| | | @ApiModelProperty(value = "车牌号") |
| | | private String licensePlate; |
| | |
| | | tChargingOrderExport.setSettlementCompanyName("四川明星新能源科技有限公司"); |
| | | tChargingOrderExport.setPrePaymentType("先付后退"); |
| | | tChargingOrderExport.setIsSecurity("是"); |
| | | tChargingOrderExport.setIsWhitelist(Integer.valueOf(1).equals(chargingOrderListVO.getIsWhitelist()) ? "是" : "否"); |
| | | tChargingOrderExport.setWhitelistElectricRefundAmount(formatMoney(chargingOrderListVO.getWhitelistElectricRefundAmount())); |
| | | tChargingOrderExport.setWhitelistServiceRefundAmount(formatMoney(chargingOrderListVO.getWhitelistServiceRefundAmount())); |
| | | tChargingOrderExports.add(tChargingOrderExport); |
| | | i++; |
| | | } |
| | |
| | | private String prePaymentType; |
| | | @Excel(name = "是否安全防护订单",width = 30) |
| | | private String isSecurity; |
| | | @Excel(name = "是否白名单",width = 30) |
| | | private String isWhitelist; |
| | | @Excel(name = "白名单电费退款金额",width = 30) |
| | | private String whitelistElectricRefundAmount; |
| | | @Excel(name = "白名单服务费退款金额",width = 30) |
| | | private String whitelistServiceRefundAmount; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据白名单权益计算订单应减免的电费或服务费 |
| | | * 按白名单权益拆分电费和服务费减免金额,财务统计需要分开展示两类退款金额 |
| | | * |
| | | * @param chargingOrder 充电订单 |
| | | * @param electrovalence 电费 |
| | | * @param serviceCharge 服务费 |
| | | * @return 白名单减免金额 |
| | | * @param electrovalence 原始电费 |
| | | * @param serviceCharge 原始服务费 |
| | | * @return 数组下标0=电费减免,下标1=服务费减免 |
| | | */ |
| | | private BigDecimal calculateWhitelistDiscount(TChargingOrder chargingOrder, BigDecimal electrovalence, BigDecimal serviceCharge) { |
| | | private BigDecimal[] calculateWhitelistRefundSplit(TChargingOrder chargingOrder, BigDecimal electrovalence, BigDecimal serviceCharge) { |
| | | BigDecimal electricDiscount = BigDecimal.ZERO; |
| | | BigDecimal serviceDiscount = BigDecimal.ZERO; |
| | | if (!isWhitelistOrder(chargingOrder)) { |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal[]{electricDiscount, serviceDiscount}; |
| | | } |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_ALL_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | return money(electrovalence).add(money(serviceCharge)).setScale(4, RoundingMode.HALF_EVEN); |
| | | electricDiscount = electrovalence == null ? BigDecimal.ZERO : electrovalence; |
| | | serviceDiscount = serviceCharge == null ? BigDecimal.ZERO : serviceCharge; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_ELECTRIC_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | electricDiscount = electrovalence == null ? BigDecimal.ZERO : electrovalence; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_SERVICE_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | serviceDiscount = serviceCharge == null ? BigDecimal.ZERO : serviceCharge; |
| | | } |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_ELECTRIC_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | return money(electrovalence).setScale(4, RoundingMode.HALF_EVEN); |
| | | } |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_SERVICE_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | return money(serviceCharge).setScale(4, RoundingMode.HALF_EVEN); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal[]{electricDiscount, serviceDiscount}; |
| | | } |
| | | |
| | | @Override |
| | |
| | | chargingOrder.setWhitelistId(whitelistMatched ? whitelist.getWhitelistId() : null); |
| | | chargingOrder.setWhitelistBenefitType(whitelistMatched ? whitelist.getBenefitType() : null); |
| | | chargingOrder.setWhitelistDiscountAmount(BigDecimal.ZERO); |
| | | chargingOrder.setWhitelistElectricRefundAmount(BigDecimal.ZERO); |
| | | chargingOrder.setWhitelistServiceRefundAmount(BigDecimal.ZERO); |
| | | chargingOrder.setVipDiscountAmount(BigDecimal.ZERO); |
| | | chargingOrder.setOrderSource(1); |
| | | chargingOrder.setTitle("【充电桩充电】" + chargingPile.getNumber() + "号桩/" + tChargingGun.getCode() + "号枪"); |
| | |
| | | if(null != map.get("licensePlate")){ |
| | | chargingOrderListVO.setLicensePlate(map.get("licensePlate").toString()); |
| | | } |
| | | chargingOrderListVO.setIsWhitelist(null == map.get("isWhitelist") ? 0 : Integer.valueOf(map.get("isWhitelist").toString())); |
| | | // 白名单退款金额由电费退款和服务费退款组成,列表展示总额,财务导出继续保留拆分字段。 |
| | | chargingOrderListVO.setWhitelistElectricRefundAmount(getSummaryDecimal(map, "whitelistElectricRefundAmount")); |
| | | chargingOrderListVO.setWhitelistServiceRefundAmount(getSummaryDecimal(map, "whitelistServiceRefundAmount")); |
| | | chargingOrderListVO.setWhitelistRefundAmount(getSummaryDecimal(map, "whitelistRefundAmount")); |
| | | BigDecimal jian = null == map.get("jian") ? BigDecimal.ZERO : new BigDecimal(map.get("jian").toString()); |
| | | BigDecimal feng = null == map.get("feng") ? BigDecimal.ZERO : new BigDecimal(map.get("feng").toString()); |
| | | BigDecimal ping = null == map.get("ping") ? BigDecimal.ZERO : new BigDecimal(map.get("ping").toString()); |
| | |
| | | } |
| | | } |
| | | } |
| | | BigDecimal whitelistDiscount = calculateWhitelistDiscount(chargingOrder, periodElectricPrice_total, serviceCharge_total); |
| | | BigDecimal[] whitelistRefundSplit = calculateWhitelistRefundSplit(chargingOrder, periodElectricPrice_total, serviceCharge_total); |
| | | BigDecimal electricDiscount = whitelistRefundSplit[0]; |
| | | BigDecimal serviceDiscount = whitelistRefundSplit[1]; |
| | | BigDecimal whitelistDiscount = electricDiscount.add(serviceDiscount).setScale(4, RoundingMode.HALF_EVEN); |
| | | if (whitelistDiscount.compareTo(BigDecimal.ZERO) > 0) { |
| | | BigDecimal electricDiscount = BigDecimal.ZERO; |
| | | BigDecimal serviceDiscount = BigDecimal.ZERO; |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_ALL_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | electricDiscount = periodElectricPrice_total; |
| | | serviceDiscount = serviceCharge_total; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_ELECTRIC_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | electricDiscount = periodElectricPrice_total; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_SERVICE_FREE).equals(chargingOrder.getWhitelistBenefitType())) { |
| | | serviceDiscount = serviceCharge_total; |
| | | } |
| | | // 白名单退款按权益拆分入库,订单金额仍沿用原有应收减免逻辑。 |
| | | periodElectricPrice_total = periodElectricPrice_total.subtract(electricDiscount).max(BigDecimal.ZERO); |
| | | serviceCharge_total = serviceCharge_total.subtract(serviceDiscount).max(BigDecimal.ZERO); |
| | | refundAmount = refundAmount.add(whitelistDiscount); |
| | |
| | | } |
| | | chargingOrder.setCouponDiscountAmount(couponDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | chargingOrder.setWhitelistDiscountAmount(whitelistDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | chargingOrder.setWhitelistElectricRefundAmount(electricDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | chargingOrder.setWhitelistServiceRefundAmount(serviceDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | chargingOrder.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | chargingOrder.setServiceCharge(serviceCharge_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | refundAmount = refundAmount.max(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据白名单权益计算补偿结算时应减免的电费或服务费 |
| | | * 按白名单权益拆分补偿结算的电费和服务费减免金额,确保任务补偿与正常结算口径一致 |
| | | * |
| | | * @param order 充电订单 |
| | | * @param electrovalence 电费 |
| | | * @param serviceCharge 服务费 |
| | | * @return 白名单减免金额 |
| | | * @param electrovalence 原始电费 |
| | | * @param serviceCharge 原始服务费 |
| | | * @return 数组下标0=电费减免,下标1=服务费减免 |
| | | */ |
| | | private BigDecimal calculateWhitelistDiscount(TChargingOrder order, BigDecimal electrovalence, BigDecimal serviceCharge) { |
| | | private BigDecimal[] calculateWhitelistRefundSplit(TChargingOrder order, BigDecimal electrovalence, BigDecimal serviceCharge) { |
| | | BigDecimal electricDiscount = BigDecimal.ZERO; |
| | | BigDecimal serviceDiscount = BigDecimal.ZERO; |
| | | if (!isWhitelistOrder(order)) { |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal[]{electricDiscount, serviceDiscount}; |
| | | } |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_ALL_FREE).equals(order.getWhitelistBenefitType())) { |
| | | return money(electrovalence).add(money(serviceCharge)).setScale(4, RoundingMode.HALF_EVEN); |
| | | electricDiscount = electrovalence == null ? BigDecimal.ZERO : electrovalence; |
| | | serviceDiscount = serviceCharge == null ? BigDecimal.ZERO : serviceCharge; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_ELECTRIC_FREE).equals(order.getWhitelistBenefitType())) { |
| | | electricDiscount = electrovalence == null ? BigDecimal.ZERO : electrovalence; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_SERVICE_FREE).equals(order.getWhitelistBenefitType())) { |
| | | serviceDiscount = serviceCharge == null ? BigDecimal.ZERO : serviceCharge; |
| | | } |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_ELECTRIC_FREE).equals(order.getWhitelistBenefitType())) { |
| | | return money(electrovalence).setScale(4, RoundingMode.HALF_EVEN); |
| | | } |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_SERVICE_FREE).equals(order.getWhitelistBenefitType())) { |
| | | return money(serviceCharge).setScale(4, RoundingMode.HALF_EVEN); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal[]{electricDiscount, serviceDiscount}; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | } |
| | | BigDecimal whitelistDiscount = calculateWhitelistDiscount(order, periodElectricPrice_total, serviceCharge_total); |
| | | BigDecimal[] whitelistRefundSplit = calculateWhitelistRefundSplit(order, periodElectricPrice_total, serviceCharge_total); |
| | | BigDecimal electricDiscount = whitelistRefundSplit[0]; |
| | | BigDecimal serviceDiscount = whitelistRefundSplit[1]; |
| | | BigDecimal whitelistDiscount = electricDiscount.add(serviceDiscount).setScale(4, RoundingMode.HALF_EVEN); |
| | | if (whitelistDiscount.compareTo(BigDecimal.ZERO) > 0) { |
| | | BigDecimal electricDiscount = BigDecimal.ZERO; |
| | | BigDecimal serviceDiscount = BigDecimal.ZERO; |
| | | if (Integer.valueOf(WHITELIST_BENEFIT_ALL_FREE).equals(order.getWhitelistBenefitType())) { |
| | | electricDiscount = periodElectricPrice_total; |
| | | serviceDiscount = serviceCharge_total; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_ELECTRIC_FREE).equals(order.getWhitelistBenefitType())) { |
| | | electricDiscount = periodElectricPrice_total; |
| | | } else if (Integer.valueOf(WHITELIST_BENEFIT_SERVICE_FREE).equals(order.getWhitelistBenefitType())) { |
| | | serviceDiscount = serviceCharge_total; |
| | | } |
| | | // 补偿任务需与实时结算使用同一拆分口径,避免财务导出金额不一致。 |
| | | periodElectricPrice_total = periodElectricPrice_total.subtract(electricDiscount).max(BigDecimal.ZERO); |
| | | serviceCharge_total = serviceCharge_total.subtract(serviceDiscount).max(BigDecimal.ZERO); |
| | | refundAmount = refundAmount.add(whitelistDiscount); |
| | |
| | | } |
| | | order.setCouponDiscountAmount(couponDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setWhitelistDiscountAmount(whitelistDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setWhitelistElectricRefundAmount(electricDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setWhitelistServiceRefundAmount(serviceDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setServiceCharge(serviceCharge_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setPaymentAmount(payAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | |
| | | <result column="whitelist_id" property="whitelistId"/> |
| | | <result column="whitelist_benefit_type" property="whitelistBenefitType"/> |
| | | <result column="whitelist_discount_amount" property="whitelistDiscountAmount"/> |
| | | <result column="whitelist_electric_refund_amount" property="whitelistElectricRefundAmount"/> |
| | | <result column="whitelist_service_refund_amount" property="whitelistServiceRefundAmount"/> |
| | | <result column="vip_discount" property="vipDiscount"/> |
| | | <result column="vip_discount_amount" property="vipDiscountAmount"/> |
| | | <result column="payment_amount" property="paymentAmount"/> |
| | |
| | | charging_pile_id, charging_gun_id, |
| | | start_time, end_time, status, recharge_amount, recharge_payment_type, recharge_payment_status, pay_method, balance_pay_amount, third_pay_amount, balance_refund_amount, third_refund_amount, |
| | | recharge_serial_number, |
| | | order_amount, app_coupon_id, coupon_discount_amount, is_whitelist, whitelist_id, whitelist_benefit_type, whitelist_discount_amount, vip_discount, vip_discount_amount, payment_amount, |
| | | order_amount, app_coupon_id, coupon_discount_amount, is_whitelist, whitelist_id, whitelist_benefit_type, whitelist_discount_amount, whitelist_electric_refund_amount, whitelist_service_refund_amount, vip_discount, vip_discount_amount, payment_amount, |
| | | refund_code, |
| | | refund_amount, refund_status, refund_serial_number, refund_time, create_time, |
| | | del_flag,need_elec,total_electricity |
| | |
| | | </select> |
| | | |
| | | <select id="chargingOrder" resultType="com.ruoyi.order.api.vo.ChargingOrderVO"> |
| | | select t1.* |
| | | select t1.*, |
| | | IFNULL(t1.whitelist_electric_refund_amount, 0) + IFNULL(t1.whitelist_service_refund_amount, 0) as whitelistRefundAmount |
| | | from t_charging_order t1 |
| | | where t1.del_flag = 0 |
| | | <if test="null != req.code and req.code!=''"> |
| | |
| | | a.payment_amount as orderAmount, |
| | | a.vip_discount_amount as vipDiscountAmount, |
| | | e.refund_amount as refundAmount, |
| | | a.is_whitelist as isWhitelist, |
| | | IFNULL(a.whitelist_electric_refund_amount, 0) + IFNULL(a.whitelist_service_refund_amount, 0) as whitelistRefundAmount, |
| | | IFNULL(a.whitelist_electric_refund_amount, 0) as whitelistElectricRefundAmount, |
| | | IFNULL(a.whitelist_service_refund_amount, 0) as whitelistServiceRefundAmount, |
| | | c.license_plate as licensePlate, |
| | | f.phone, |
| | | a.payment_amount as paymentAmount, |
| | |
| | | aa.rechargeAmount, |
| | | aa.rechargePaymentType, |
| | | aa.payMethod, |
| | | aa.isWhitelist, |
| | | aa.whitelistRefundAmount, |
| | | aa.whitelistElectricRefundAmount, |
| | | aa.whitelistServiceRefundAmount, |
| | | aa.paymentAmount, |
| | | aa.thirdPayAmount, |
| | | aa.balancePayAmount, |
| | |
| | | b.recharge_amount as rechargeAmount, |
| | | b.recharge_payment_type as rechargePaymentType, |
| | | b.pay_method as payMethod, |
| | | b.is_whitelist as isWhitelist, |
| | | IFNULL(b.whitelist_electric_refund_amount, 0) + IFNULL(b.whitelist_service_refund_amount, 0) as whitelistRefundAmount, |
| | | IFNULL(b.whitelist_electric_refund_amount, 0) as whitelistElectricRefundAmount, |
| | | IFNULL(b.whitelist_service_refund_amount, 0) as whitelistServiceRefundAmount, |
| | | b.payment_amount as paymentAmount, |
| | | b.third_pay_amount as thirdPayAmount, |
| | | b.balance_pay_amount as balancePayAmount, |
| | |
| | | </if> |
| | | and b.start_time IS NOT NULL and b.end_time is not null |
| | | ) as aa group by aa.id, aa.`code`, aa.siteId, aa.siteName, aa.orderType, aa.terminalName, aa.electricity, aa.rechargeAmount, aa.paymentAmount, aa.thirdPayAmount, aa.balancePayAmount, aa.electrovalence, aa.serviceCharge, aa.tripartitePlatformName, |
| | | aa.startTime, aa.endTime, aa.chargingSecond, aa.startSoc, aa.endSoc, aa.`status`, aa.endMode, aa.phone, aa.licensePlate, aa.orderSource, aa.rechargePaymentType, aa.payMethod order by aa.startTime desc |
| | | aa.startTime, aa.endTime, aa.chargingSecond, aa.startSoc, aa.endSoc, aa.`status`, aa.endMode, aa.phone, aa.licensePlate, aa.orderSource, aa.rechargePaymentType, aa.payMethod, |
| | | aa.isWhitelist, aa.whitelistRefundAmount, aa.whitelistElectricRefundAmount, aa.whitelistServiceRefundAmount order by aa.startTime desc |
| | | </select> |
| | | |
| | | |
| | |
| | | 0 as balanceIncome, |
| | | 0 as platformIncomeTotal, |
| | | 0 as partnerIncomeTotal, |
| | | 0 as whitelistChargingIncome, |
| | | 0 as whitelistRefund |
| | | sum(CASE WHEN aa.is_whitelist = 1 THEN IFNULL(aa.electrovalence, 0) + IFNULL(aa.serviceCharge, 0) ELSE 0 END) as whitelistChargingIncome, |
| | | sum(CASE WHEN aa.is_whitelist = 1 THEN IFNULL(aa.whitelist_electric_refund_amount, 0) + IFNULL(aa.whitelist_service_refund_amount, 0) ELSE 0 END) as whitelistRefund |
| | | from ( |
| | | select |
| | | b.id, |
| | | b.recharge_payment_type, |
| | | b.is_whitelist, |
| | | b.electrovalence, |
| | | b.service_charge as serviceCharge, |
| | | b.whitelist_electric_refund_amount, |
| | | b.whitelist_service_refund_amount, |
| | | IFNULL(b.third_pay_amount, CASE WHEN b.pay_method = 3 THEN IFNULL(b.payment_amount, IFNULL(b.recharge_amount, 0)) ELSE 0 END) - IFNULL(b.third_refund_amount, CASE WHEN b.pay_method = 3 THEN IFNULL(b.refund_amount, 0) ELSE 0 END) as thirdNetAmount |
| | | from `charging_pile_order`.t_charging_order b |
| | | <include refid="ChargingOrderSummaryWhere"/> |