| | |
| | | public R<TAppCoupon> getAppCouponById(Long id) { |
| | | return R.fail("根据id获取优惠券领取记录失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<TAppCoupon>> getAppCouponByIds(List<Long> ids) { |
| | | return R.fail("批量获取优惠券领取记录失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R updateAppCoupon(TAppCoupon appCoupon) { |
| | |
| | | */ |
| | | @PostMapping(value = "/t-app-coupon/getAppCouponById") |
| | | R<TAppCoupon> getAppCouponById(@RequestParam("id") Long id); |
| | | |
| | | @PostMapping(value = "/t-app-coupon/getAppCouponByIds") |
| | | R<List<TAppCoupon>> getAppCouponByIds(@RequestBody List<Long> ids); |
| | | |
| | | |
| | | /** |
| | |
| | | private BigDecimal whitelistServiceRefundAmount; |
| | | @ApiModelProperty(value = "订单编号") |
| | | private String code; |
| | | @ApiModelProperty(value = "用户优惠券领取记录id") |
| | | private Long appCouponId; |
| | | @ApiModelProperty(value = "订单类型(1=充电订单(小程序),2=充电订单(刷卡))") |
| | | private String orderType; |
| | | @ApiModelProperty(value = "充电终端名称 桩+枪") |
| | |
| | | private Boolean authCurve = true; |
| | | @ApiModelProperty(value = "计费策略名称") |
| | | private String accountingStrategyName; |
| | | @ApiModelProperty(value = "优惠券来源") |
| | | private String couponSource; |
| | | @ApiModelProperty(value = "VIN码") |
| | | private String actualVin; |
| | | } |
| | |
| | | TAppCoupon appCoupon = tAppCouponService.getById(id); |
| | | return R.ok(appCoupon); |
| | | } |
| | | |
| | | @PostMapping("/getAppCouponByIds") |
| | | public R<List<TAppCoupon>> getAppCouponByIds(@RequestBody List<Long> ids){ |
| | | if (ids == null || ids.isEmpty()) { |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | return R.ok(tAppCouponService.listByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户优惠券 |
| | |
| | | tChargingOrderExport.setBusinessCategory("1"); |
| | | tChargingOrderExport.setId(i); |
| | | tChargingOrderExport.setCode(chargingOrderListVO.getCode()); |
| | | tChargingOrderExport.setCouponSource(chargingOrderListVO.getCouponSource()); |
| | | tChargingOrderExport.setActualVin(chargingOrderListVO.getActualVin()); |
| | | tChargingOrderExport.setTerminalName(chargingOrderListVO.getTerminalName()); |
| | | tChargingOrderExport.setName(chargingOrderListVO.getAccountingStrategyName()); |
| | | tChargingOrderExport.setOrderClassification("1"); |
| | |
| | | private Integer id; |
| | | @Excel(name = "订单编号",width = 30) |
| | | private String code; |
| | | @Excel(name = "优惠券来源",width = 20) |
| | | private String couponSource; |
| | | @Excel(name = "VIN码",width = 24) |
| | | private String actualVin; |
| | | private String siteCode; |
| | | @Excel(name = "电站名称",width = 30) |
| | | private String siteName; |
| | |
| | | private String code; |
| | | @Excel(name = "VIN码", width = 24) |
| | | private String vin; |
| | | @Excel(name = "车牌号", width = 16) |
| | | private String plateNum; |
| | | @Excel(name = "手机号", width = 18) |
| | | private String phone; |
| | | @Excel(name = "站点名称", width = 24) |
| | | private String siteName; |
| | | @Excel(name = "充电终端名称", width = 24) |
| | |
| | | private Long chargingSecond; |
| | | @Excel(name = "实付", width = 12, numFormat = "0.00") |
| | | private BigDecimal paymentAmount; |
| | | @Excel(name = "手机号", width = 18) |
| | | private String phone; |
| | | @Excel(name = "车牌号", width = 16) |
| | | private String plateNum; |
| | | @Excel(name = "开始时间", width = 22) |
| | | private String startTime; |
| | | @Excel(name = "最后时间", width = 22) |
| | |
| | | private BigDecimal electrovalence; |
| | | @Excel(name = "累计服务费", width = 14, numFormat = "0.0000") |
| | | private BigDecimal serviceCharge; |
| | | @Excel(name = "结束原因", width = 16, replace = {"异常终止_0", "主动终止_1", "满电终止_2", "费用不足终止_3"}) |
| | | private Integer endMode; |
| | | @Excel(name = "时段数", width = 12) |
| | | private Integer count; |
| | | @Excel(name = "充电电流", width = 12, numFormat = "0.0") |
| | | private BigDecimal chargeCurrent; |
| | | @Excel(name = "充电电压", width = 12, numFormat = "0.0") |
| | | private BigDecimal chargeVoltage; |
| | | @Excel(name = "实时总功率", width = 12, numFormat = "0.0") |
| | | private BigDecimal chargePower; |
| | | } |
| | |
| | | } |
| | | dto.setSiteIds(siteIds); |
| | | List<ChargingOrderListVO> list1 = this.baseMapper.chargingList(dto, startTime1, startTime2, endTime1, endTime2); |
| | | fillChargingPeriodCouponSource(list1); |
| | | fillChargingPeriodExportBalanceIncome(list1); |
| | | fillChargingPeriodShareIncome(list1); |
| | | return list1; |
| | | } |
| | | |
| | | private void fillChargingPeriodCouponSource(List<ChargingOrderListVO> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Long> couponIds = list.stream() |
| | | .map(ChargingOrderListVO::getAppCouponId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (couponIds.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<Long, TAppCoupon> couponMap = new HashMap<>(); |
| | | int batchSize = 500; |
| | | for (int i = 0; i < couponIds.size(); i += batchSize) { |
| | | List<Long> batchIds = couponIds.subList(i, Math.min(i + batchSize, couponIds.size())); |
| | | R<List<TAppCoupon>> response = appCouponClient.getAppCouponByIds(batchIds); |
| | | List<TAppCoupon> coupons = response == null ? null : response.getData(); |
| | | couponMap.putAll(indexByLongId(coupons, TAppCoupon::getId)); |
| | | } |
| | | for (ChargingOrderListVO order : list) { |
| | | TAppCoupon coupon = couponMap.get(order.getAppCouponId()); |
| | | if (coupon == null || coupon.getWaysToObtain() == null) { |
| | | continue; |
| | | } |
| | | switch (coupon.getWaysToObtain()) { |
| | | case 1: |
| | | order.setCouponSource("积分兑换"); |
| | | break; |
| | | case 2: |
| | | order.setCouponSource("会员购买"); |
| | | break; |
| | | case 3: |
| | | case 4: |
| | | order.setCouponSource("后台赠送"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void fillChargingPeriodShareIncome(List<ChargingOrderListVO> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | |
| | | result.addAll(batch); |
| | | } |
| | | fillExtra(result); |
| | | fillRealtimeData(result); |
| | | return result; |
| | | } |
| | | |
| | |
| | | item.setPartnerIncome(BigDecimal.ZERO); |
| | | } |
| | | } |
| | | |
| | | private void fillRealtimeData(List<ChargingOrderVO> list) { |
| | | for (ChargingOrderVO item : list) { |
| | | if (item.getCode() == null || item.getCode().trim().isEmpty()) { |
| | | continue; |
| | | } |
| | | UploadRealTimeMonitoringData data = monitoringDataService.getLastDataById(item.getCode()); |
| | | if (data == null) { |
| | | continue; |
| | | } |
| | | item.setChargeCurrent(data.getOutput_current()); |
| | | item.setChargeVoltage(data.getOutput_voltage()); |
| | | BigDecimal power = data.getPower(); |
| | | if (power == null && data.getOutput_current() != null && data.getOutput_voltage() != null) { |
| | | power = data.getOutput_current().multiply(data.getOutput_voltage()) |
| | | .divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | item.setChargePower(power); |
| | | } |
| | | } |
| | | } |
| | |
| | | a.recharge_serial_number as rechargeSerialNumber, |
| | | a.`code`, |
| | | a.order_type as orderType, |
| | | a.actual_vin as actualVin, |
| | | a.app_coupon_id as appCouponId, |
| | | d.`name` as terminalName, |
| | | UNIX_TIMESTAMP(a.end_time) - UNIX_TIMESTAMP(a.start_time) as chargingSecond, |
| | | a.electricity as chargingCapacity, |
| | |
| | | class ChargingPeriodPaginationMapperTest { |
| | | |
| | | @Test |
| | | void chargingListShouldExposeCouponAndVinColumns() throws IOException { |
| | | InputStream input = getClass().getClassLoader() |
| | | .getResourceAsStream("mapper/order/TChargingOrderMapper.xml"); |
| | | assertNotNull(input); |
| | | String mapper; |
| | | try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) { |
| | | mapper = reader.lines().collect(Collectors.joining("\n")); |
| | | } |
| | | int chargingListStart = mapper.indexOf("<select id=\"chargingList\""); |
| | | int chargingListEnd = mapper.indexOf("</select>", chargingListStart); |
| | | String chargingList = mapper.substring(chargingListStart, chargingListEnd); |
| | | assertTrue(chargingList.contains("a.actual_vin as actualVin")); |
| | | assertTrue(chargingList.contains("a.app_coupon_id as appCouponId")); |
| | | } |
| | | |
| | | @Test |
| | | void pagesOrdersBeforeLoadingAccountingSummaries() throws IOException { |
| | | InputStream input = getClass().getClassLoader() |
| | | .getResourceAsStream("mapper/order/TChargingOrderMapper.xml"); |