From 46367116aef9a54c43c9348e095d62105f16aebe Mon Sep 17 00:00:00 2001
From: zhibing.pu <393733352@qq.com>
Date: 星期四, 05 九月 2024 17:54:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 184 ++++-
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java | 16
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java | 72 ++
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/TChargingBillExport.java | 39 +
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillPayExport.java | 28
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java | 3
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java | 7
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillExport.java | 41 +
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java | 50 +
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TVipOrderService.java | 2
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillDetailExport.java | 62 ++
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/CallBackController.java | 50 +
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingBillMapper.java | 30
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java | 10
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java | 2
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java | 6
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java | 6
ruoyi-service/ruoyi-chargingPile/src/main/resources/template/充电算帐单已出账.xlsx | 0
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java | 52 +
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml | 91 +-
ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/WxPayController.java | 4
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java | 62 ++
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java | 3
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java | 22
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java | 26
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java | 327 ++++++++++
ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/AliPayController.java | 24
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java | 361 +++++++++-
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TVipService.java | 3
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java | 8
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java | 7
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java | 8
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java | 96 +++
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrderRefund.java | 14
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java | 2
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillRefundExport.java | 37 +
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java | 5
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingBillMapper.xml | 22
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillListVO.java | 37 +
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingBillService.java | 20
40 files changed, 1,658 insertions(+), 181 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
index 92cce5c..cb89711 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
@@ -4,9 +4,11 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
+import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
+import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.vo.GetChargingOrderByLicensePlate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +39,11 @@
}
@Override
+ public R<ChargingBillVO> chargingBillListR(ChargingListQuery dto) {
+ return R.fail("查询充电算帐单失败" + throwable.getMessage());
+ }
+
+ @Override
public R<TChargingOrder> orderDetail(Long orderId) {
return R.fail("订单详情:" + throwable.getMessage());
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java
index ada6228..35c5873 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java
@@ -4,6 +4,7 @@
import com.ruoyi.common.core.dto.ExchangeDto;
import com.ruoyi.order.api.feignClient.OrderClient;
import com.ruoyi.order.api.model.TShoppingOrder;
+import com.ruoyi.order.api.model.TVipOrder;
import com.ruoyi.order.api.query.TActivityStatisticsQuery;
import com.ruoyi.order.api.vo.TActivityVO;
import org.slf4j.Logger;
@@ -51,6 +52,12 @@
}
@Override
+ public R<Long> addVipOrder(TVipOrder vipOrder) {
+ return null;
+ }
+
+
+ @Override
public R<TShoppingOrder> shopCreate(ExchangeDto exchangeDto) {
return R.fail("订单创建" + cause.getMessage());
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
index 5958408..366a8c3 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
@@ -5,9 +5,12 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory;
+import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
+import com.ruoyi.order.api.vo.ChargingBillVO;
+import io.swagger.annotations.ApiOperation;
import com.ruoyi.order.api.vo.GetChargingOrderByLicensePlate;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -22,7 +25,8 @@
public interface ChargingOrderClient {
@PostMapping(value = "/t-charging-order/useOrderCount")
R<Long> useOrderCount(@RequestParam("userId") Long userId);
-
+ @PostMapping(value = "/t-charging-order/chargingBillListR")
+ R<ChargingBillVO> chargingBillListR(@RequestBody ChargingListQuery dto);
@PostMapping(value = "/t-charging-order/detail")
R<TChargingOrder> orderDetail(@RequestParam("orderId") Long orderId);
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java
index fc54b0f..c0f9cd8 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.core.dto.ExchangeDto;
import com.ruoyi.order.api.factory.OrderFallbackFactory;
import com.ruoyi.order.api.model.TShoppingOrder;
+import com.ruoyi.order.api.model.TVipOrder;
import com.ruoyi.order.api.query.TActivityStatisticsQuery;
import com.ruoyi.order.api.vo.TActivityVO;
import org.springframework.cloud.openfeign.FeignClient;
@@ -35,6 +36,8 @@
@PostMapping("/t-exchange-order/create")
public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto);
+ @PostMapping("/t-vip-order//addVipOrder")
+ public R<Long> addVipOrder(@RequestBody TVipOrder vipOrder);
@PostMapping("/t-shopping-order/create")
public R<TShoppingOrder> shopCreate(@RequestBody ExchangeDto exchangeDto);
@PostMapping("/t-shopping-order/callBack")
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingListQuery.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java
similarity index 70%
rename from ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingListQuery.java
rename to ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java
index 875df2f..10e711c 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingListQuery.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java
@@ -1,4 +1,4 @@
-package com.ruoyi.order.dto;
+package com.ruoyi.order.api.model;
import com.ruoyi.common.core.web.page.BasePage;
import io.swagger.annotations.ApiModel;
@@ -12,9 +12,11 @@
@ApiModel(value = "充电账单列表查询参数")
public class ChargingListQuery extends BasePage {
@ApiModelProperty("订单分类 1全站 2各个站点")
- private String category;
- @ApiModelProperty("账单周期2020-01-01 - 2020-01-01")
+ private String type;
+ @ApiModelProperty("账单周期2020-01-01 00:00:00 - 2020-01-01 23:59:59")
private String startTime;
@ApiModelProperty("1已出账 2未出账")
private Integer state;
+ @ApiModelProperty("uid 前端忽略")
+ private String uid;
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java
new file mode 100644
index 0000000..8116db2
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingBill.java
@@ -0,0 +1,62 @@
+package com.ruoyi.order.api.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.web.domain.BasePojo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.cglib.core.Local;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 充电算帐单
+ * </p>
+ *
+ * @author 无关风月
+ * @since 2024-09-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("t_charging_bill")
+@ApiModel(value="TChargingBill对象", description="")
+public class TChargingBill extends BasePojo {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.NONE)
+ private Long id;
+
+ @ApiModelProperty(value = "账单编号")
+ @TableField("code")
+ private String code;
+
+ @ApiModelProperty(value = "账单类型 1全站账单 2站点账单")
+ @TableField("type")
+ private Integer type;
+
+ @ApiModelProperty(value = "站点id")
+ @TableField("site_id")
+ private Integer siteId;
+
+ @ApiModelProperty(value = "账单生成时间 每月二号")
+ @TableField("bill_time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ private LocalDateTime billTime;
+
+ @ApiModelProperty(value = "1未出账2已出账")
+ @TableField("status")
+ private Integer status;
+
+ @ApiModelProperty(value = "uid")
+ @TableField(exist = false)
+ private String uid;
+}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java
index 0059cad..5cfac91 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrder.java
@@ -158,6 +158,9 @@
@ApiModelProperty(value = "退款流水号")
@TableField("refund_code")
private String refundCode;
+ @ApiModelProperty(value = "退款原因")
+ @TableField("refund_reason")
+ private String refundReason;
@ApiModelProperty(value = "退款金额")
@TableField("refund_amount")
@@ -190,4 +193,53 @@
@TableField("pay_time")
private LocalDateTime payTime;
+ @ApiModelProperty(value = "站点名称")
+ @TableField(exist = false)
+ private String siteName;
+ @ApiModelProperty(value = "终端名称")
+ @TableField(exist = false)
+ private String terminalName;
+ @ApiModelProperty(value = "终端编号")
+ @TableField(exist = false)
+ private String terminalCode;
+ @ApiModelProperty(value = "订单分类")
+ @TableField(exist = false)
+ private String orderClassification1;
+ @ApiModelProperty(value = "支付方式")
+ @TableField(exist = false)
+ private String rechargePaymentType1;
+ @ApiModelProperty(value = "充电启动方式")
+ @TableField(exist = false)
+ private String chargingType;
+ @ApiModelProperty(value = "订单状态")
+ @TableField(exist = false)
+ private String status1;
+ @ApiModelProperty(value = "终端名称")
+ @TableField(exist = false)
+ private String endMode1;
+ @ApiModelProperty(value = "充电费用")
+ @TableField(exist = false)
+ private String totalAmount;
+ @ApiModelProperty(value = "优惠抵扣")
+ @TableField(exist = false)
+ private String discount;
+ @ApiModelProperty(value = "充电时长")
+ @TableField(exist = false)
+ private String chargingTime;
+ @ApiModelProperty(value = "充电后soc")
+ @TableField(exist = false)
+ private String endSoc;
+ @ApiModelProperty(value = "客户昵称")
+ @TableField(exist = false)
+ private String userName;
+ @ApiModelProperty(value = "手机号")
+ @TableField(exist = false)
+ private String phone;
+ @ApiModelProperty(value = "车牌号")
+ @TableField(exist = false)
+ private String licensePlate;
+ @ApiModelProperty(value = "车辆品牌")
+ @TableField(exist = false)
+ private String vehicleModel;
+
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrderRefund.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrderRefund.java
index f885a70..c95a809 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrderRefund.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/TChargingOrderRefund.java
@@ -21,7 +21,7 @@
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_charging_order_refund")
-@ApiModel(value="TChargingOrderRefund对象", description="")
+@ApiModel(value="TChargingOrderRefund对象1", description="")
public class TChargingOrderRefund implements Serializable {
private static final long serialVersionUID = 1L;
@@ -86,5 +86,17 @@
@TableField("pay_amount")
private BigDecimal payAmount;
+ @TableField(exist = false)
+ private Integer type;
+ @ApiModelProperty(value = "第三方支付流水号")
+ @TableField(exist = false)
+ private String serailNumber;
+ @ApiModelProperty(value = "支付金额")
+ @TableField(exist = false)
+ private BigDecimal paymentAmount;
+ @ApiModelProperty(value = "支付时间")
+ @TableField(exist = false)
+ private LocalDateTime payTime;
+
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillListVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillListVO.java
new file mode 100644
index 0000000..47c25c5
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillListVO.java
@@ -0,0 +1,37 @@
+package com.ruoyi.order.api.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.order.api.model.TChargingBill;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel(value = "ChargingBillListVO对象",description = "充电算帐单列表VO")
+public class ChargingBillListVO extends TChargingBill {
+ @ApiModelProperty(value = "账单周期")
+ private String billWeek;
+ @ApiModelProperty(value = "充电时间 秒")
+ private Integer chargingSecond;
+ @ApiModelProperty(value = "订单数量")
+ private Integer orderCount;
+ @ApiModelProperty(value = "站点名称")
+ private String siteName;
+ @ApiModelProperty(value = "实收金额")
+ private BigDecimal paymentAmount;
+ @ApiModelProperty(value = "总金额")
+ private BigDecimal orderAmount;
+ @ApiModelProperty(value = "累计电费")
+ private BigDecimal electrovalence;
+ @ApiModelProperty(value = "累计服务费")
+ private BigDecimal serviceCharge;
+ @ApiModelProperty(value = "平台手续费")
+ private BigDecimal commissionAmount;
+ @ApiModelProperty(value = "平台分佣")
+ private BigDecimal sharingAmount;
+ @ApiModelProperty(value = "充电电流 度")
+ private BigDecimal chargingCapacity;
+}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java
index ab1c46f..9ea35ee 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/ChargingBillVO.java
@@ -1,11 +1,13 @@
package com.ruoyi.order.api.vo;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.model.TChargingOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
+import java.util.List;
@Data
@ApiModel(value = "ChargingBillVO对象",description = "充电算帐单")
@@ -23,11 +25,27 @@
@ApiModelProperty(value = "订单数量")
private Integer orderCount;
@ApiModelProperty(value = "平台手续费")
- private String commissionAmount;
+ private BigDecimal commissionAmount;
@ApiModelProperty(value = "三方平台分佣")
- private String sharingAmount;
+ private BigDecimal sharingAmount;
@ApiModelProperty(value = "优惠抵扣")
- private String discount;
+ private BigDecimal discount;
+ @ApiModelProperty(value = "账单分类 1全站 2各个站点 前端忽略")
+ private String category;
+ @ApiModelProperty(value = "账单类型 月结 前端忽略")
+ private String type;
+ @ApiModelProperty(value = "站点名称 前端忽略")
+ private String siteName;
+ @ApiModelProperty(value = "账单周期 前端忽略")
+ private String billWeek;
+ @ApiModelProperty(value = "账单生成日期 前端忽略")
+ private String createTime;
+ @ApiModelProperty(value = "账单编号 前端忽略")
+ private String code;
+ @ApiModelProperty(value = "充电时长 前端忽略")
+ private String chargingTime;
@ApiModelProperty(value = "列表数据")
- private PageInfo<ChargingOrderListVO> list;
+ private PageInfo<ChargingBillListVO> list;
+ @ApiModelProperty(value = "导出Excel数据 前端忽略")
+ private List<TChargingOrder> exportList;
}
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
index d49f395..1db4d7c 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -82,8 +82,6 @@
@Resource
private ChargingOrderClient chargingOrderClient;
-
-
/**
* 小程序扫一扫
* @param number
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java
index 2a28707..e326bf4 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java
@@ -326,6 +326,12 @@
byId.setAuditStatus(3);
byId.setTwoRemark(steategyPassDto.getRemark());
byId.setTwoAuditTime(LocalDateTime.now());
+
+ //如果parentId不为空,则将parentId对应的siteId改为现在的,并且将parenId对应的数据删除
+
+
+ //将site表对应的模板id修改为新的这个
+
}
}else {
byId.setAuditStatus(4);
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
index 8e85f92..ca22e94 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
@@ -1,10 +1,18 @@
package com.ruoyi.chargingPile.controller;
+import java.math.BigDecimal;
+import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.model.TChargingOrder;
+import com.ruoyi.order.api.vo.ChargingBillListVO;
+import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.enums.WriteDirectionEnum;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
+import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -24,18 +32,23 @@
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.order.api.feignClient.ChargingOrderClient;
+import com.ruoyi.order.api.model.ChargingListQuery;
+import com.ruoyi.order.api.vo.ChargingBillVO;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.CharEncoding;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -55,6 +68,8 @@
private final TApplyChargingPileService applyChargingPileService;
private final TokenService tokenService;
private final RedisService redisService;
+ @Resource
+ private ChargingOrderClient chargingOrderClient;
@Autowired
public TApplyChargingPileController(TApplyChargingPileService applyChargingPileService, TokenService tokenService, RedisService redisService) {
@@ -217,6 +232,87 @@
return R.ok();
}
+ @ApiOperation(value = "下载-已出账", tags = {"管理后台-充电算账单"})
+ @GetMapping("/downloadBill")
+ public R downloadBill(String uid,HttpServletResponse response)
+ {
+ ChargingListQuery chargingListQuery = new ChargingListQuery();
+ chargingListQuery.setUid(uid);
+ chargingListQuery.setPageCurr(1);
+ chargingListQuery.setPageSize(99999);
+ ChargingBillVO data = chargingOrderClient.chargingBillListR(chargingListQuery).getData();
+
+ List<ChargingBillVO> chargingBillVOS = new ArrayList<>();
+ chargingBillVOS.add(data);
+ try {
+ response.setCharacterEncoding(Constants.UTF8);
+ response.setContentType("application/vnd.ms-excel");
+ response.setHeader("Access-Control-Expose-Headers", "Content-disposition");
+ response.setHeader("Content-Disposition", "attachment;filename=" +
+ URLEncoder.encode("月账单-"+data.getCategory()+"-"+data.getBillWeek()+"-"+data.getSiteName(), CharEncoding.UTF_8) + ".xlsx");
+ } catch (UnsupportedEncodingException e) {
+ return R.fail("excel导出失败!");
+ }
+ try {
+ // excel模板封装
+ ExcelWriterBuilder excelWriterBuilder = EasyExcelFactory.write(response.getOutputStream());
+ InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/" +"充电算帐单已出账" + ".xlsx");
+ // 自动释放资源
+ try (ExcelWriter excelWriter = excelWriterBuilder.withTemplate(stream).build()) {
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
+ excelWriter.fill(new FillWrapper("data1", chargingBillVOS), fillConfig, writeSheet);
+ excelWriter.fill(new FillWrapper("data2", data.getExportList()), fillConfig, writeSheet);
+ excelWriter.finish();
+ } catch (Exception e) {
+ return R.fail("excel导出失败!");
+ }
+ } catch (IOException e) {
+ return R.fail("excel导出失败!");
+ }
+ return R.ok();
+ }
+ @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"})
+ @GetMapping("/download")
+ public R download(String uid,HttpServletResponse response)
+ {
+ ChargingListQuery chargingListQuery = new ChargingListQuery();
+ chargingListQuery.setUid(uid);
+ chargingListQuery.setPageCurr(1);
+ chargingListQuery.setPageSize(99999);
+ ChargingBillVO data = chargingOrderClient.chargingBillListR(chargingListQuery).getData();
+
+ List<ChargingBillVO> chargingBillVOS = new ArrayList<>();
+ chargingBillVOS.add(data);
+ try {
+ response.setCharacterEncoding(Constants.UTF8);
+ response.setContentType("application/vnd.ms-excel");
+ response.setHeader("Access-Control-Expose-Headers", "Content-disposition");
+ response.setHeader("Content-Disposition", "attachment;filename=" +
+ URLEncoder.encode("月账单-"+data.getCategory()+data.getBillWeek()+data.getSiteName(), CharEncoding.UTF_8) + ".xlsx");
+ } catch (UnsupportedEncodingException e) {
+ return R.fail("excel导出失败!");
+ }
+ try {
+ // excel模板封装
+ ExcelWriterBuilder excelWriterBuilder = EasyExcelFactory.write(response.getOutputStream());
+ InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/" +"充电算帐单已出账" + ".xlsx");
+ // 自动释放资源
+ try (ExcelWriter excelWriter = excelWriterBuilder.withTemplate(stream).build()) {
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
+ excelWriter.fill(new FillWrapper("data1", chargingBillVOS), fillConfig, writeSheet);
+ excelWriter.fill(new FillWrapper("data2", data.getExportList()), fillConfig, writeSheet);
+ excelWriter.finish();
+ } catch (Exception e) {
+ return R.fail("excel导出失败!");
+ }
+ } catch (IOException e) {
+ return R.fail("excel导出失败!");
+ }
+ return R.ok();
+ }
+
public static boolean isImageUrl(JSONObject jsonObject) {
String url = jsonObject.getString("url");
Pattern pattern = Pattern.compile(
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
index 6449504..ad1d1f3 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
@@ -49,6 +49,14 @@
return R.ok(page);
}
+ @ApiOperation(tags = {"后台-订单管理-停车记录"},value = "详情")
+ @GetMapping(value = "/detail")
+ public R<TParkingRecord> detail(Long id) {
+
+ return R.ok(parkingRecordService.getById(id));
+
+ }
+
@ApiOperation(tags = {"后台-订单管理-停车记录"},value = "出场")
@GetMapping(value = "/out")
public R out(Long id) {
diff --git "a/ruoyi-service/ruoyi-chargingPile/src/main/resources/template/\345\205\205\347\224\265\347\256\227\345\270\220\345\215\225\345\267\262\345\207\272\350\264\246.xlsx" "b/ruoyi-service/ruoyi-chargingPile/src/main/resources/template/\345\205\205\347\224\265\347\256\227\345\270\220\345\215\225\345\267\262\345\207\272\350\264\246.xlsx"
new file mode 100644
index 0000000..bccbcd0
--- /dev/null
+++ "b/ruoyi-service/ruoyi-chargingPile/src/main/resources/template/\345\205\205\347\224\265\347\256\227\345\270\220\345\215\225\345\267\262\345\207\272\350\264\246.xlsx"
Binary files differ
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/CallBackController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/CallBackController.java
new file mode 100644
index 0000000..e47e282
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/CallBackController.java
@@ -0,0 +1,50 @@
+package com.ruoyi.order.controller;
+
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.order.service.TVipOrderService;
+import com.ruoyi.payment.api.vo.AliQueryOrder;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+
+
+@RestController
+@RequestMapping("/callBack")
+public class CallBackController {
+
+ @Resource
+ private TVipOrderService tVipOrderService;
+
+ @ResponseBody
+ @PostMapping(value = "/ali/all")
+ public void chargingOrderALICallback(@RequestBody AliQueryOrder aliQueryOrder, HttpServletResponse response) {
+ try {
+ String out_trade_no = aliQueryOrder.getOutTradeNo();
+ String transaction_id = aliQueryOrder.getTradeNo();
+ String attach = aliQueryOrder.getPassbackParams();
+ String substring = out_trade_no.substring(0, 2);
+ switch (substring){
+ //购物订单
+ case "GW":
+
+ break;
+ case "HY":
+ tVipOrderService.payBack(out_trade_no);
+ break;
+ }
+
+// AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(2, out_trade_no, transaction_id, attach);
+// if (ajaxResult.isSuccess()) {
+// PrintWriter writer = response.getWriter();
+// writer.println("success");
+// writer.flush();
+// writer.close();
+// }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
index cfed3a4..d219870 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
@@ -1,29 +1,50 @@
package com.ruoyi.order.controller;
-import com.ruoyi.account.api.feignClient.AppUserCarClient;
-import com.ruoyi.account.api.feignClient.AppUserClient;
-import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
-import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
-import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.chargingPile.api.feignClient.SiteClient;
+import com.ruoyi.chargingPile.api.model.Site;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.DateUtils;
+import com.ruoyi.common.core.utils.WebUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.redis.service.RedisService;
-import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.order.api.model.TChargingBill;
+import com.ruoyi.order.api.model.TChargingOrder;
+import com.ruoyi.order.api.query.TOrderInvoiceQuery;
+import com.ruoyi.order.api.vo.ChargingBillListVO;
import com.ruoyi.order.api.vo.ChargingBillVO;
-import com.ruoyi.order.api.vo.ChargingOrderTimeVO;
-import com.ruoyi.order.dto.ChargingBillQuery;
-import com.ruoyi.order.dto.ChargingListQuery;
+import com.ruoyi.order.api.model.ChargingListQuery;
+import com.ruoyi.order.api.vo.TOrderInvoiceVO;
+import com.ruoyi.order.export.*;
import com.ruoyi.order.service.*;
-import com.ruoyi.order.vo.ChargingOrderListInfoVO;
-import com.ruoyi.payment.api.feignClient.AliPaymentClient;
-import com.ruoyi.payment.api.feignClient.WxPaymentClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* <p>
@@ -39,53 +60,279 @@
public class ChargingBillController {
@Resource
- private TChargingOrderService chargingOrderService;
- @Autowired
- private TokenService tokenService;
- @Autowired
- private TOrderEvaluateService orderEvaluateService;
-
- @Resource
- private WxPaymentClient wxPaymentClient;
-
- @Resource
- private RedisService redisService;
-
- @Resource
- private AliPaymentClient aliPaymentClient;
- @Resource
- private TShoppingOrderService shoppingOrderService;
-
- @Resource
- private AppUserClient appUserClient;
-
- @Resource
- private TVipOrderService vipOrderService;
- @Resource
- private ParkingLotClient parkingLotClient;
- @Resource
- private TChargingOrderRefundService chargingOrderRefundService;
-
- @Resource
- private TShoppingOrderRefundService shoppingOrderRefundService;
- @Resource
- private TVipOrderRefundService vipOrderRefundService;
+ private TChargingBillService chargingBillService;
@Resource
private SiteClient siteClient;
@Resource
- private ChargingPileClient chargingPileClient;
- @Resource
- private ChargingGunClient chargingGunClient;
- @Resource
- private AppUserCarClient appUserCarClient;
- @Resource
- private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService;
- @ResponseBody
- @PostMapping(value = "/chargingList")
- @ApiOperation(value = "充电算帐单列表查询", tags = {"管理后台-充电算账单"})
- public AjaxResult<ChargingBillVO> chargingList(@RequestBody ChargingListQuery dto) {
+ private TChargingOrderService chargingOrderService;
- return AjaxResult.success(null);
+
+ @PostMapping(value = "/chargingBillList")
+ @ApiOperation(value = "充电算帐单列表查询", tags = {"管理后台-充电算账单"})
+ public AjaxResult<ChargingBillVO> chargingBillList(@RequestBody ChargingListQuery dto) {
+ ChargingBillVO res = chargingBillService.chargingBillList(dto);
+ return AjaxResult.success(res);
+ }
+ @PostMapping(value = "/chargingBillListR")
+ public R<ChargingBillVO> chargingBillListR(@RequestBody ChargingListQuery dto) {
+ ChargingBillVO res = chargingBillService.chargingBillList(dto);
+ return R.ok(res);
+ }
+ @GetMapping(value = "/chargingBillListExport")
+ public R<ChargingBillVO> chargingBillListExport(String uid) {
+ return R.ok(null);
+ }
+ @ApiOperation(value = "导出", tags = {"管理后台-充电算账单"})
+ @PostMapping("/export")
+ public void export(@RequestBody ChargingListQuery dto)
+ {
+ ChargingBillVO res = chargingBillService.chargingBillList(dto);
+ List<ChargingBillListVO> list = res.getList().getRecords();
+ List<TChargingBillExport> tChargingBillExports = new ArrayList<>();
+ for (ChargingBillListVO orderInvoiceVO : list) {
+ TChargingBillExport tChargingBillExport = new TChargingBillExport();
+ tChargingBillExport.setCode(orderInvoiceVO.getCode());
+ tChargingBillExport.setBillType("月账单");
+ tChargingBillExport.setType(orderInvoiceVO.getType().toString());
+ tChargingBillExport.setBillWeek(orderInvoiceVO.getBillWeek());
+ tChargingBillExport.setSiteName(orderInvoiceVO.getSiteName());
+ tChargingBillExport.setPaymentAmount(orderInvoiceVO.getPaymentAmount());
+ tChargingBillExport.setElectrovalence(orderInvoiceVO.getElectrovalence());
+ tChargingBillExport.setServiceCharge(orderInvoiceVO.getServiceCharge());
+ tChargingBillExport.setChargingCapacity(orderInvoiceVO.getChargingCapacity());
+ Integer chargingSecond = orderInvoiceVO.getChargingSecond();
+ // 根据秒数 转换为xx小时xx分钟xx秒 如果小时为0不展示 如果分钟为0则不展示
+ // 计算小时、分钟和秒
+ int hours = chargingSecond / 60 / 60;
+ int minutes = chargingSecond /60 % 60;
+ int seconds = 0; // 如果没有秒数,则默认是0
+ // 构造结果字符串
+ StringBuilder result = new StringBuilder();
+ if (hours > 0) {
+ result.append(hours).append("小时");
+ }
+ if (minutes > 0) {
+ result.append(minutes).append("分钟");
+ }
+ if (seconds > 0 || result.length() == 0) { // 如果秒数大于0,或者小时和分钟都为0,则显示秒数
+ result.append(seconds).append("秒");
+ }
+ tChargingBillExport.setChargingTime(result.toString());
+ tChargingBillExport.setOrderCount(orderInvoiceVO.getOrderCount());
+ tChargingBillExport.setBillTime(orderInvoiceVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+ tChargingBillExports.add(tChargingBillExport);
+ }
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChargingBillExport.class, tChargingBillExports);
+ HttpServletResponse response = WebUtils.response();
+ response.setContentType("application/vnd.ms-excel");
+ response.setCharacterEncoding("utf-8");
+ ServletOutputStream outputStream = null;
+ try {
+ String fileName = URLEncoder.encode("月账单-"+res.getCategory()+"-"+res.getBillWeek()+"-"+res.getSiteName()+".xls", "utf-8");
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+ response.setHeader("Pragma", "no-cache");
+ response.setHeader("Cache-Control", "no-cache");
+ outputStream = response.getOutputStream();
+ workbook.write(outputStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"})
+ @GetMapping("/download")
+ public void download(String uid)
+ {
+ List<ChargingBillExport> chargingBillExports = new ArrayList<>();
+ List<ChargingBillRefundExport> chargingBillRefundExports = new ArrayList<>();
+ List<ChargingBillPayExport> chargingBillPayExports = new ArrayList<>();
+ TChargingBill byId = chargingBillService.getById(uid);
+ ChargingBillExport chargingBillExport = new ChargingBillExport();
+ chargingBillExport.setCode(byId.getCode());
+ // todo 确认商户类型
+ chargingBillExport.setAccountType("商户类型");
+ chargingBillExport.setType(byId.getType().toString());
+ chargingBillExport.setBillType("月结");
+ LocalDateTime billTime = byId.getBillTime();
+ // 将billTime 减去一个月 转化为yyyy-MM格式字符串
+ billTime = billTime.minusMonths(1);
+ chargingBillExport.setBillWeek(DateUtils.parseDateToStr("yyyy-MM",DateUtils.toDate(billTime)));
+
+ chargingBillExport.setBillTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(billTime)));
+ chargingBillExport.setState("未出账");
+ List<Site> data = siteClient.getSiteByIds(Arrays.asList(byId.getSiteId())).getData();
+ if (!data.isEmpty()){
+ chargingBillExport.setSiteName(data.get(0).getName());
+ }
+ // 根据账单的出账时间 查询上个月的充电订单
+ LocalDateTime localDate = byId.getBillTime().minusMonths(1);
+ // 账单周期
+ // 获取 LocalDate 对象
+ LocalDate date = localDate.toLocalDate();
+ // 获取该月份的第一天
+ LocalDate firstDayOfMonth = date.withDayOfMonth(1);
+ // 获取该月份的最后一天
+ LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
+ QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
+ .between("create_time", firstDayOfMonth, lastDayOfMonth)
+ .eq("status", 5)
+ .eq("recharge_payment_status", 2);
+ if (byId.getType() == 2) {
+ eq.eq("site_id", byId.getSiteId());
+ }
+ BigDecimal paymentAmount = new BigDecimal("0");
+ BigDecimal refundAmount = new BigDecimal("0");
+ BigDecimal income = new BigDecimal("0");
+
+ List<TChargingOrder> tChargingOrders = chargingOrderService.list(eq);
+ // 累加支付金额
+ int i =1;
+ for (TChargingOrder tChargingOrder : tChargingOrders) {
+ // 账单信息
+ paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
+ if (tChargingOrder.getRefundStatus()!=null && tChargingOrder.getRefundStatus()==2){
+ refundAmount = refundAmount.add(tChargingOrder.getRefundAmount());
+ }
+ // 退款信息
+ ChargingBillRefundExport chargingBillRefundExport = new ChargingBillRefundExport();
+ ChargingBillPayExport chargingBillPayExport = new ChargingBillPayExport();
+
+ chargingBillRefundExport.setId(i+"");
+ switch (tChargingOrder.getRechargePaymentType()){
+ case 1:
+ chargingBillRefundExport.setPlatform("微信");
+ chargingBillRefundExport.setPlatformPay("微信小程序支付");
+ chargingBillPayExport.setPlatform("微信");
+ chargingBillPayExport.setPlatformPay("微信小程序支付");
+ break;
+ case 2:
+ chargingBillRefundExport.setPlatform("支付宝");
+ chargingBillRefundExport.setPlatformPay("支付宝小程序支付");
+ chargingBillPayExport.setPlatform("支付宝");
+ chargingBillPayExport.setPlatformPay("支付宝小程序支付");
+
+ }
+ chargingBillRefundExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber());
+ chargingBillRefundExport.setCode(tChargingOrder.getCode());
+ chargingBillRefundExport.setPayTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime())));
+ if (tChargingOrder.getRefundTime()!=null){
+ chargingBillRefundExport.setRefundTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getRefundTime())));
+ }
+ chargingBillRefundExport.setRefundMoney(tChargingOrder.getRefundAmount().toString());
+ chargingBillRefundExport.setRefundRemark(tChargingOrder.getRefundReason());
+ chargingBillRefundExport.setRefundCode(tChargingOrder.getRefundCode());
+ chargingBillRefundExport.setRefundSerialNumber(tChargingOrder.getRefundSerialNumber());
+ chargingBillRefundExports.add(chargingBillRefundExport);
+ // 支付信息
+ chargingBillPayExport.setId(i+"");
+ chargingBillPayExport.setRechargeSerialNumber(tChargingOrder.getRechargeSerialNumber());
+ chargingBillPayExport.setCode(tChargingOrder.getCode());
+ chargingBillPayExport.setPayTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getPayTime())));
+ chargingBillPayExport.setPaymentAmount(tChargingOrder.getPaymentAmount().toString());
+ chargingBillPayExport.setTotal("");
+ chargingBillPayExports.add(chargingBillPayExport);
+ i++;
+ }
+ chargingBillExport.setPaymentAmount(paymentAmount);
+ chargingBillExport.setRefundAmount(refundAmount);
+ chargingBillExport.setIncome(paymentAmount.subtract(refundAmount));
+ chargingBillExports.add(chargingBillExport);
+
+ // 导出
+ List<Map<String, Object>> sheetsList = new ArrayList<>();
+ AtomicInteger atomicInteger = new AtomicInteger();
+
+ for (int i1 = 0; i1 < 3; i1++) {
+ String sheetName="";
+ switch (i1){
+ case 1:
+ sheetName= "账单信息";
+ Map<String, Object> exportMap = Maps.newHashMap();
+ ExportParams exportParams = new ExportParams(null, sheetName, ExcelType.HSSF);
+ // 以下3个参数为API中写死的参数名 分别是sheet配置/导出类(注解定义)/数据集
+ exportMap.put("title", exportParams);
+ exportMap.put("entity", ChargingBillExport.class);
+ exportMap.put("data", chargingBillExports);
+ // 加入多sheet配置列表
+ sheetsList.add(exportMap);
+ break;
+ case 2:
+ sheetName= "退款订单";
+ Map<String, Object> exportMap1 = Maps.newHashMap();
+ ExportParams exportParams1 = new ExportParams(null, sheetName, ExcelType.HSSF);
+ // 以下3个参数为API中写死的参数名 分别是sheet配置/导出类(注解定义)/数据集
+ exportMap1.put("title", exportParams1);
+ exportMap1.put("entity", ChargingBillRefundExport.class);
+ exportMap1.put("data", chargingBillRefundExports);
+ // 加入多sheet配置列表
+ sheetsList.add(exportMap1);
+ break;
+ case 3:
+ sheetName= "支付记录";
+ Map<String, Object> exportMap2 = Maps.newHashMap();
+ ExportParams exportParams2 = new ExportParams(null, sheetName, ExcelType.HSSF);
+ // 以下3个参数为API中写死的参数名 分别是sheet配置/导出类(注解定义)/数据集
+ exportMap2.put("title", exportParams2);
+ exportMap2.put("entity", ChargingBillPayExport.class);
+ exportMap2.put("data", chargingBillPayExports);
+ // 加入多sheet配置列表
+ sheetsList.add(exportMap2);
+ break;
+ }
+ }
+ if (!chargingBillRefundExports.isEmpty()){
+ ChargingBillRefundExport chargingBillRefundExport = chargingBillRefundExports.get(0);
+ chargingBillRefundExport.setTotal(refundAmount.toString());
+ }
+ if (!chargingBillPayExports.isEmpty()){
+ ChargingBillPayExport chargingBillPayExport = chargingBillPayExports.get(0);
+ chargingBillPayExport.setTotal(refundAmount.toString());
+ }
+ String type="";
+ String type1="";
+ switch (byId.getType()){
+ case 1:
+ type = "全站账单";
+ type1 = "全站";
+ break;
+ case 2:
+ type = "各个站点账单";
+ List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(byId.getSiteId())).getData();
+ if (!data1.isEmpty()){
+ type1 = data.get(0).getName();
+ }
+ break;
+ }
+ String s = DateUtils.parseDateToStr("yyyy-MM", DateUtils.toDate(billTime));
+
+ Workbook workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
+ HttpServletResponse response = WebUtils.response();
+ response.setContentType("application/vnd.ms-excel");
+ response.setCharacterEncoding("utf-8");
+ ServletOutputStream outputStream = null;
+ try {
+ String fileName = URLEncoder.encode("账户结算账单-月账单-"+type+"-"+s+"-"+type1+".xls", "utf-8");
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+ response.setHeader("Pragma", "no-cache");
+ response.setHeader("Cache-Control", "no-cache");
+ outputStream = response.getOutputStream();
+ workbook.write(outputStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java
index 0b3a52f..950f938 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/FinancialSettlementController.java
@@ -12,7 +12,7 @@
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.vo.ChargingOrderListInfoVO;
import com.ruoyi.order.api.vo.ChargingOrderTimeVO;
-import com.ruoyi.order.dto.ChargingListQuery;
+import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.service.*;
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
import com.ruoyi.payment.api.feignClient.WxPaymentClient;
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
index 285fcf8..309caee 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -145,7 +145,7 @@
}
@ResponseBody
@PostMapping(value = "/pay/order/refund")
- @ApiOperation(value = "列表", tags = {"管理后台-支付订单-订单信息"})
+ @ApiOperation(value = "退款", tags = {"管理后台-支付订单-订单信息"})
public R refund(@RequestBody PayOrderRefundDto payOrderQueryDto) {
return chargingOrderService.payRefund(payOrderQueryDto);
}
@@ -258,8 +258,15 @@
@ResponseBody
@PostMapping(value = "/pay/order/refund/list")
- @ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-退款订单"})
+ @ApiOperation(value = "列表", tags = {"管理后台-支付订单-退款订单"})
public R<PageInfo<TChargingOrderRefund>> refundList(@RequestBody ChargingRefundDto chargingRefundDto) {
+ return chargingOrderService.getRefundList(chargingRefundDto);
+
+ }
+ @ResponseBody
+ @PostMapping(value = "/pay/order/refund/list1")
+ @ApiOperation(value = "列表1", tags = {"管理后台-支付订单-退款订单"})
+ public R<PageInfo<TChargingOrderRefund>> refundList1(@RequestBody ChargingRefundDto chargingRefundDto) {
return chargingOrderService.getRefundList(chargingRefundDto);
}
@@ -376,7 +383,10 @@
.eq(TChargingOrder::getDelFlag, 0).eq(TChargingOrder::getStatus, 3));
return R.ok(one);
}
-
+
+
+
+
@ResponseBody
@GetMapping(value = "/getMyChargingOrderList")
@ApiOperation(value = "获取充电记录列表", tags = {"小程序-充电记录"})
@@ -785,8 +795,8 @@
return resultList;
}
-
-
+
+
/**
* 硬件充电结束后的处理逻辑
* @param code
@@ -795,7 +805,7 @@
public void endCharge(@RequestParam("code") String code){
chargingOrderService.endCharge(code, 2);
}
-
+
/**
* 硬件异常结束充电后的处理逻辑
* @param code
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java
index 7beaf25..1ad49f2 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java
@@ -2,6 +2,7 @@
import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TExchangeOrder;
@@ -51,9 +52,9 @@
}
@PostMapping("/addVipOrder")
@ApiOperation(value = "添加会员订单", tags = {"管理后台-会员订单"})
- public AjaxResult addVipOrder(@RequestBody TVipOrder dto) {
+ public R<Long> addVipOrder(@RequestBody TVipOrder dto) {
vipOrderService.saveOrUpdate(dto);
- return AjaxResult.success();
+ return R.ok(dto.getId());
}
@GetMapping("/deleteVipOrder")
@ApiOperation(value = "批量删除会员订单", tags = {"管理后台-会员订单"})
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillDetailExport.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillDetailExport.java
new file mode 100644
index 0000000..4887c44
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillDetailExport.java
@@ -0,0 +1,62 @@
+package com.ruoyi.order.export;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@ApiModel(value = "导出充电算帐单明细")
+public class ChargingBillDetailExport implements Serializable {
+ @Excel(name = "序号",width = 30)
+ private String id;
+ @Excel(name = "订单编号",width = 30)
+ private String code;
+ @Excel(name = "电站名称",width = 30)
+ private String siteName;
+ @Excel(name = "终端名称",width = 30)
+ private String terminalName;
+ @Excel(name = "终端编号",width = 30)
+ private String terminalCode;
+ @Excel(name = "收款方式(直接修改成订单分类)",width = 30,replace = {"线上订单_1","线下订单_2"})
+ private String type;
+ @Excel(name = "支付方式(预付/先充后付)",width = 30)
+ private String billType;
+ @Excel(name = "充电启动方式(对应订单类型)",width = 30)
+ private String billWeek;
+ @Excel(name = "订单创建时间(支付订单)",width = 30)
+ private String orderAmount;
+ @Excel(name = "充电开始时间(充电桩订单)",width = 30)
+ private BigDecimal discount;
+ @Excel(name = "充电结束时间(充电桩订单)",width = 30)
+ private BigDecimal discount1;
+ @Excel(name = "订单状态",width = 30,replace = {"未知_0","等待中_1","启动中_2","充电中_3","停止_4","已结束_5"})
+ private BigDecimal d;
+ @Excel(name = "判定结束原因",width = 30)
+ private BigDecimal electrovalence1;
+ @Excel(name = "充电电费(元)",width = 30)
+ private BigDecimal electrovalence;
+ @Excel(name = "充电服务费(元)",width = 30)
+ private BigDecimal serviceCharge;
+ @Excel(name = "充电费用(元)",width = 30)
+ private BigDecimal serviceCharge1;
+ @Excel(name = "优惠券抵扣",width = 30)
+ private BigDecimal chargingCapacity;
+ @Excel(name = "充电电量(度)",width = 30)
+ private BigDecimal chargingCapacity1;
+ @Excel(name = "充电时长(从充电桩订单中获取)",width = 30)
+ private String chargingTime;
+ @Excel(name = "充电后soc",width = 30)
+ private Integer orderCount;
+ @Excel(name = "客户昵称",width = 30)
+ private Integer orderCount1;
+ @Excel(name = "手机号",width = 30)
+ private Integer orderCount2;
+ @Excel(name = "车牌号",width = 30)
+ private Integer orderCount3;
+ @Excel(name = "汽车类型",width = 30)
+ private Integer orderCount4;
+
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillExport.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillExport.java
new file mode 100644
index 0000000..3c826b2
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillExport.java
@@ -0,0 +1,41 @@
+package com.ruoyi.order.export;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@ApiModel(value = "导出充电算帐单-导出")
+public class ChargingBillExport implements Serializable {
+
+ @Excel(name = "账单编号",width = 30)
+ private String code;
+ @Excel(name = "账户类型",width = 30)
+ private String accountType;
+ @Excel(name = "账单分类",width = 30,replace = {"全站账单_1","各个站点账单_2"})
+ private String type;
+ @Excel(name = "账单类型",width = 30)
+ private String billType;
+ @Excel(name = "账单周期",width = 30 )
+ private String billWeek;
+ @Excel(name = "账单生成日期",width = 30)
+ private String billTime;
+ @Excel(name = "状态",width = 30)
+ private String state;
+ @Excel(name = "站点名称",width = 30)
+ private String siteName;
+ @Excel(name = "支付金额",width = 30)
+ private BigDecimal paymentAmount;
+ @Excel(name = "退款金额",width = 30)
+ private BigDecimal refundAmount;
+ @Excel(name = "入账金额",width = 30)
+ private BigDecimal income;
+
+
+
+
+
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillPayExport.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillPayExport.java
new file mode 100644
index 0000000..b580bd7
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillPayExport.java
@@ -0,0 +1,28 @@
+package com.ruoyi.order.export;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@ApiModel(value = "导出充电算帐单支付-导出")
+public class ChargingBillPayExport implements Serializable {
+ @Excel(name = "序号",width = 30)
+ private String id;
+ @Excel(name = "支付平台",width = 30)
+ private String platform;
+ @Excel(name = "支付方式名称",width = 30)
+ private String platformPay;
+ @Excel(name = "支付平台流水号",width = 30)
+ private String rechargeSerialNumber;
+ @Excel(name = "平台订单号",width = 30)
+ private String code;
+ @Excel(name = "支付时间",width = 30)
+ private String payTime;
+ @Excel(name = "支付金额",width = 30)
+ private String paymentAmount;
+ @Excel(name = "合计",width = 30)
+ private String total;
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillRefundExport.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillRefundExport.java
new file mode 100644
index 0000000..18116d3
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/ChargingBillRefundExport.java
@@ -0,0 +1,37 @@
+package com.ruoyi.order.export;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@ApiModel(value = "导出充电算帐单退款-导出")
+public class ChargingBillRefundExport implements Serializable {
+ @Excel(name = "序号",width = 30)
+ private String id;
+ @Excel(name = "支付平台",width = 30)
+ private String platform;
+ @Excel(name = "支付方式名称",width = 30)
+ private String platformPay;
+ @Excel(name = "源(支付平台流水号)",width = 30)
+ private String rechargeSerialNumber;
+ @Excel(name = "源(平台支付订单号)",width = 30)
+ private String code;
+ @Excel(name = "支付时间",width = 30)
+ private String payTime;
+ @Excel(name = "退款时间",width = 30)
+ private String refundTime;
+ @Excel(name = "退款金额",width = 30)
+ private String refundMoney;
+ @Excel(name = "退款描述",width = 30)
+ private String refundRemark;
+ @Excel(name = "平台退款编号",width = 30)
+ private String refundCode;
+ @Excel(name = "支付平台退款流水号",width = 30)
+ private String refundSerialNumber;
+ @Excel(name = "合计",width = 30)
+ private String total;
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/TChargingBillExport.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/TChargingBillExport.java
new file mode 100644
index 0000000..39e61c9
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/export/TChargingBillExport.java
@@ -0,0 +1,39 @@
+package com.ruoyi.order.export;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.models.auth.In;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@ApiModel(value = "充电算帐单列表-导出")
+public class TChargingBillExport implements Serializable {
+
+ @Excel(name = "账单编号",width = 30)
+ private String code;
+ @Excel(name = "账单类型",width = 30)
+ private String billType;
+ @Excel(name = "账单分类",width = 30,replace = {"全站账单_1","各个站点账单_2"})
+ private String type;
+ @Excel(name = "账单周期",width = 30 )
+ private String billWeek;
+ @Excel(name = "站点名称",width = 30)
+ private String siteName;
+ @Excel(name = "总金额",width = 30)
+ private BigDecimal paymentAmount;
+ @Excel(name = "总电费",width = 30)
+ private BigDecimal electrovalence;
+ @Excel(name = "总服务费",width = 30)
+ private BigDecimal serviceCharge;
+ @Excel(name = "总电量",width = 30)
+ private BigDecimal chargingCapacity;
+ @Excel(name = "充电时长",width = 30)
+ private String chargingTime;
+ @Excel(name = "充电订单数量",width = 30)
+ private Integer orderCount;
+ @Excel(name = "账单生成日期",width = 30)
+ private String billTime;
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingBillMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingBillMapper.java
new file mode 100644
index 0000000..c93a20a
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingBillMapper.java
@@ -0,0 +1,30 @@
+package com.ruoyi.order.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.model.TChargingBill;
+import com.ruoyi.order.api.vo.ChargingBillListVO;
+import com.ruoyi.order.api.model.ChargingListQuery;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author xiaochen
+ * @since 2024-08-07
+ */
+@Mapper
+public interface TChargingBillMapper extends BaseMapper<TChargingBill> {
+
+ List<ChargingBillListVO> chargingBillList(
+ @Param("pageInfo") PageInfo<ChargingBillListVO> pageInfo,
+ @Param("req") ChargingListQuery dto,
+ @Param("startTime1")String startTime1,
+ @Param("startTime2")String startTime2);
+
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
index d9bad70..44e1416 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
@@ -4,6 +4,7 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.model.TChargingOrderRefund;
import com.ruoyi.order.api.query.ChargingOrderQuery;
@@ -76,7 +77,7 @@
List<Map<String, BigDecimal>> getYearData(List<Long> chargingOrderIds);
- List<ChargingOrderListVO> chargingList(@Param("pageInfo")PageInfo<ChargingOrderListVO> pageInfo, @Param("req")ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
+ List<ChargingOrderListVO> chargingList(@Param("pageInfo")PageInfo<ChargingOrderListVO> pageInfo, @Param("req") ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
List<ChargingOrderListVO> chargingList1( @Param("req")ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingBillService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingBillService.java
new file mode 100644
index 0000000..b1e6a58
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingBillService.java
@@ -0,0 +1,20 @@
+package com.ruoyi.order.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.order.api.model.TChargingBill;
+import com.ruoyi.order.api.vo.ChargingBillVO;
+import com.ruoyi.order.api.model.ChargingListQuery;
+
+/**
+ * <p>
+ * 服务类
+ * </p>
+ *
+ * @author xiaochen
+ * @since 2024-08-07
+ */
+public interface TChargingBillService extends IService<TChargingBill> {
+
+ ChargingBillVO chargingBillList(ChargingListQuery dto);
+
+}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
index 980c6e3..f7da0dc 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
@@ -5,8 +5,8 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.model.ChargingListQuery;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.model.TChargingOrderRefund;
import com.ruoyi.order.api.query.ChargingOrderQuery;
@@ -142,15 +142,15 @@
* @param query
*/
void chargeMonitoring(UploadRealTimeMonitoringDataQuery query);
-
-
+
+
/**
* 自动结束充电后的处理逻辑
* @param code
*/
void endCharge(String code, Integer endMode);
-
-
+
+
/**
* 异常结束充电处理逻辑
* @param orderCode
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TVipOrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TVipOrderService.java
index 88ab8e6..1434169 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TVipOrderService.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TVipOrderService.java
@@ -25,4 +25,6 @@
List<SixVipDto> sixBefore(LocalDate sixBefore);
BigDecimal getSumAmout(LocalDate sixBefore);
+
+ void payBack(String outTradeNo);
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
new file mode 100644
index 0000000..e1cf6a0
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
@@ -0,0 +1,327 @@
+package com.ruoyi.order.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.account.api.feignClient.AppUserCarClient;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.TAppUser;
+import com.ruoyi.account.api.model.TAppUserCar;
+import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
+import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
+import com.ruoyi.chargingPile.api.feignClient.SiteClient;
+import com.ruoyi.chargingPile.api.model.Site;
+import com.ruoyi.chargingPile.api.model.TChargingGun;
+import com.ruoyi.chargingPile.api.model.TChargingPile;
+import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient;
+import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
+import com.ruoyi.order.api.model.TChargingOrder;
+import com.ruoyi.order.api.vo.ChargingBillListVO;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.model.TChargingBill;
+import com.ruoyi.order.api.vo.ChargingBillVO;
+import com.ruoyi.order.api.model.ChargingListQuery;
+import com.ruoyi.order.mapper.TChargingBillMapper;
+import com.ruoyi.order.mapper.TChargingOrderMapper;
+import com.ruoyi.order.service.TChargingBillService;
+import org.omg.CORBA.PRIVATE_MEMBER;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.temporal.TemporalAdjusters;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author xiaochen
+ * @since 2024-08-07
+ */
+@Service
+public class TChargingBillServiceImpl extends ServiceImpl<TChargingBillMapper, TChargingBill> implements TChargingBillService {
+
+ @Resource
+ private TChargingOrderMapper chargingOrderList;
+ @Resource
+ private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient;
+ @Resource
+ private SiteClient siteClient;
+ @Resource
+ private ChargingPileClient chargingPileClient;
+ @Resource
+ private ChargingGunClient chargingGunClient;
+ @Resource
+ private AppUserClient appUserClient;
+ @Resource
+ private AppUserCarClient appUserCarClient;
+ @Override
+ public ChargingBillVO chargingBillList(ChargingListQuery dto) {
+ ChargingBillVO chargingBillVO = new ChargingBillVO();
+ String startTime1 = null;
+ String startTime2 = null;
+ if (StringUtils.hasLength(dto.getStartTime())){
+ String[] split = dto.getStartTime().split(" - ");
+ startTime1 = split[0];
+ startTime2 = split[1];
+ }
+ PageInfo<ChargingBillListVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
+ List<ChargingBillListVO> list = this.baseMapper.chargingBillList(pageInfo,dto,startTime1,startTime2);
+ BigDecimal paymentAmountTotal = new BigDecimal("0");
+ BigDecimal orderAmountTotal = new BigDecimal("0");
+ BigDecimal electrovalenceTotal = new BigDecimal("0");
+ BigDecimal serviceChargeTotal = new BigDecimal("0");
+ BigDecimal commissionAmountTotal = new BigDecimal("0");
+ BigDecimal sharingAmountTotal = new BigDecimal("0");
+ BigDecimal chargingCapacityTotal = new BigDecimal("0");
+ BigDecimal discountTotal = new BigDecimal("0");
+ int orderCount = 0;
+ for (ChargingBillListVO chargingBillListVO : list) {
+ String temp = "";
+ String temp1 = "";
+ switch (chargingBillListVO.getType()){
+ case 1:
+ temp = "全站账单";
+ temp1 = "全站";
+ break;
+ case 2:
+ temp = "各个站点账单";
+ temp1 = siteClient.getSiteByIds(Arrays.asList(chargingBillListVO.getSiteId())).getData().get(0).getName();
+ break;
+ }
+ chargingBillVO.setCategory(temp);
+ chargingBillVO.setSiteName(temp1);
+
+ chargingBillVO.setType("月账单");
+ chargingBillVO.setCode(chargingBillListVO.getCode());
+
+ LocalDateTime billTime = chargingBillListVO.getBillTime();
+ // 将其转化为yyyy-MM格式字符串
+ chargingBillVO.setCreateTime(billTime.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+ // 将billTime减去一个月 转化为yyyy-MM格式字符串
+ chargingBillVO.setBillWeek(billTime.minusMonths(1).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
+
+ chargingBillListVO.setUid(chargingBillListVO.getId().toString());
+ // 根据账单的出账时间 查询上个月的充电订单
+ LocalDateTime localDate = chargingBillListVO.getBillTime().minusMonths(1);
+ // 账单周期
+ chargingBillListVO.setBillWeek(localDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM")));
+ // 获取 LocalDate 对象
+ LocalDate date = localDate.toLocalDate();
+ // 获取该月份的第一天
+ LocalDate firstDayOfMonth = date.withDayOfMonth(1);
+ // 获取该月份的最后一天
+ LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
+ QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
+ .between("create_time", firstDayOfMonth, lastDayOfMonth)
+ .eq("status", 5)
+ .eq("recharge_payment_status", 2);
+ if (chargingBillListVO.getType() == 2) {
+ eq.eq("site_id", chargingBillListVO.getSiteId());
+ }
+ List<TChargingOrder> tChargingOrders = chargingOrderList.selectList(eq);
+ int chargingSecond = 0;
+ BigDecimal paymentAmount = new BigDecimal("0");
+ BigDecimal orderAmount = new BigDecimal("0");
+ BigDecimal electrovalence = new BigDecimal("0");
+ BigDecimal serviceCharge = new BigDecimal("0");
+ BigDecimal commissionAmount = new BigDecimal("0");
+ BigDecimal sharingAmount = new BigDecimal("0");
+ BigDecimal chargingCapacity = new BigDecimal("0");
+ orderCount+=tChargingOrders.size();
+ chargingBillVO.setCategory("");
+ chargingBillVO.setExportList(tChargingOrders);
+ for (TChargingOrder tChargingOrder : tChargingOrders) {
+ List<Site> data = siteClient.getSiteByIds(Arrays.asList(tChargingOrder.getSiteId())).getData();
+ if (!data.isEmpty()){
+ chargingBillVO.setSiteName(data.get(0).getName());
+ }
+ TChargingPile data1 = chargingPileClient.getChargingPileById(tChargingOrder.getChargingPileId()).getData();
+ TChargingGun data2 = chargingGunClient.getChargingGunById(tChargingOrder.getChargingGunId()).getData();
+ if (data1!=null && data2!=null){
+ tChargingOrder.setTerminalName(data1.getName()+data2.getName());
+ tChargingOrder.setTerminalCode(data2.getCode());
+ }
+ tChargingOrder.setOrderClassification1("线上订单");
+ tChargingOrder.setRechargePaymentType1("预付");
+ tChargingOrder.setChargingType("充电桩接口充电服务");
+ switch (tChargingOrder.getStatus()){
+ case 1:
+ tChargingOrder.setStatus1("等待中");
+ break;
+ case 2:
+ tChargingOrder.setStatus1("启动中");
+ break;
+ case 3:
+ tChargingOrder.setStatus1("充电中");
+ break;
+ case 4:
+ tChargingOrder.setStatus1("停止中");
+ break;
+ case 5:
+ tChargingOrder.setStatus1("已结束");
+ break;
+ case 0:
+ tChargingOrder.setStatus1("未知");
+ break;
+ }
+ if (tChargingOrder.getEndMode()!=null){
+ switch (tChargingOrder.getEndMode()){
+ case 1:
+ tChargingOrder.setEndMode1("主动终止");
+ break;
+ case 2:
+ tChargingOrder.setEndMode1("满电终止");
+ break;
+ case 3:
+ tChargingOrder.setEndMode1("费用不足终止");
+ break;
+ case 0:
+ tChargingOrder.setEndMode1("异常终止");
+ break;
+ }
+ }
+ BigDecimal add = tChargingOrder.getElectrovalence().add(tChargingOrder.getServiceCharge());
+ tChargingOrder.setTotalAmount(add.toString());
+ tChargingOrder.setDiscount(tChargingOrder.getCouponDiscountAmount().toString());
+ UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(tChargingOrder.getCode()).getData();
+ if (data5!=null){
+ if (data5.getTime_remaining()!=null){
+ chargingSecond+=data5.getTime_remaining()*60;
+ }
+ }
+ Integer cumulativeChargingTime = data5.getCumulative_charging_time();
+ // 将其转化为xx小时xx分钟xx秒显示 如果是0小时则不展示小时 如果是0分钟则不展示分钟
+ if (cumulativeChargingTime!=null){
+ // 计算小时、分钟和秒
+ int hours = cumulativeChargingTime / 60;
+ int minutes = cumulativeChargingTime % 60;
+ int seconds = 0; // 如果没有秒数,则默认是0
+ StringBuilder result = new StringBuilder();
+ if (hours > 0) {
+ result.append(hours).append("小时");
+ }
+ if (minutes > 0) {
+ result.append(minutes).append("分钟");
+ }
+ if (seconds > 0 || result.length() == 0) { // 如果秒数大于0,或者小时和分钟都为0,则显示秒数
+ result.append(seconds).append("秒");
+ }
+ tChargingOrder.setChargingTime(result.toString());
+ }
+ tChargingOrder.setEndSoc(data5.getSoc().toString());
+ TAppUser data3 = appUserClient.getUserById(tChargingOrder.getAppUserId()).getData();
+ if (tChargingOrder.getAppUserCarId()!=null){
+ List<TAppUserCar> data4 = appUserCarClient.getCarByIds(Arrays.asList(tChargingOrder.getAppUserCarId())).getData();
+ if (!data4.isEmpty()){
+ tChargingOrder.setLicensePlate(data4.get(0).getLicensePlate());
+ tChargingOrder.setVehicleModel(data4.get(0).getVehicleModel());
+ }
+ }
+ if (data3!=null)tChargingOrder.setUserName(data3.getName());
+ // 累加实收金额 支付金额减去退款金额
+ if (tChargingOrder.getRefundAmount()!=null && tChargingOrder.getPaymentAmount()!=null){
+ paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
+ paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount()).subtract(tChargingOrder.getRefundAmount());
+
+ }else if (tChargingOrder.getPaymentAmount()!=null){
+ paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
+ paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount());
+ }
+ // 累加订单金额
+ if (tChargingOrder.getOrderAmount()!=null){
+ orderAmount = orderAmount.add(tChargingOrder.getOrderAmount());
+ orderAmountTotal = orderAmountTotal.add(tChargingOrder.getOrderAmount());
+ }
+ // 累加累计电费
+ if (tChargingOrder.getElectrovalence()!=null){
+ electrovalence = electrovalence.add(tChargingOrder.getElectrovalence());
+ electrovalenceTotal = electrovalenceTotal.add(tChargingOrder.getElectrovalence());
+ }
+ // 累加累计服务费
+ if (tChargingOrder.getServiceCharge()!=null){
+ serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
+ serviceChargeTotal = serviceChargeTotal.add(tChargingOrder.getServiceCharge());
+ }
+ // 累加平台手续费
+ if (tChargingOrder.getCommissionAmount()!=null){
+ commissionAmount = commissionAmount.add(tChargingOrder.getCommissionAmount());
+ commissionAmountTotal = commissionAmountTotal.add(tChargingOrder.getCommissionAmount());
+ }
+ // 累加平台分佣
+ if (tChargingOrder.getSharingAmount()!=null){
+ sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
+ sharingAmountTotal = sharingAmountTotal.add(tChargingOrder.getSharingAmount());
+ }
+ // 累加充电度数
+ if (tChargingOrder.getChargingCapacity()!=null){
+ chargingCapacity = chargingCapacity.add(tChargingOrder.getChargingCapacity());
+ chargingCapacityTotal = chargingCapacityTotal.add(tChargingOrder.getChargingCapacity());
+ }
+ // 累加优惠金额
+ if (tChargingOrder.getCouponDiscountAmount()!=null){
+ discountTotal = discountTotal.add(tChargingOrder.getCouponDiscountAmount());
+ }
+ if (tChargingOrder.getVipDiscountAmount()!=null){
+ discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount());
+ }
+ }
+ // 将chargingSecond 这是以秒为单位存放的总秒数 将其转化为xx小时xx分钟xx秒
+ int hours = chargingSecond / 3600;
+ int minutes = (chargingSecond % 3600) / 60;
+ int seconds = chargingSecond % 60;
+ // 格式化为字符串
+ String timeString = String.format("%d小时%d分钟%d秒", hours, minutes, seconds);
+ chargingBillVO.setChargingTime(timeString);
+
+ chargingBillListVO.setPaymentAmount(paymentAmount);
+ chargingBillListVO.setOrderAmount(orderAmount);
+ chargingBillListVO.setElectrovalence(electrovalence);
+ chargingBillListVO.setServiceCharge(serviceCharge);
+ chargingBillListVO.setCommissionAmount(commissionAmount);
+ chargingBillListVO.setSharingAmount(sharingAmount);
+ chargingBillListVO.setChargingCapacity(chargingCapacity);
+ switch (chargingBillListVO.getType()){
+ case 1:
+ chargingBillListVO.setSiteName("全站");
+ break;
+ case 2:
+ Site site = siteClient.getSiteByIds(Arrays.asList(chargingBillListVO.getSiteId())).getData().get(0);
+ if (site!=null){
+ chargingBillListVO.setSiteName(site.getName());
+ }
+ break;
+ }
+ // 订单数
+ chargingBillListVO.setOrderCount(tChargingOrders.size());
+ // 充电时间秒
+ chargingBillListVO.setChargingSecond(chargingSecond);
+ }
+ chargingBillVO.setChargingCapacity(chargingCapacityTotal);
+ chargingBillVO.setPaymentAmount(paymentAmountTotal);
+ chargingBillVO.setOrderAmount(orderAmountTotal);
+ chargingBillVO.setElectrovalence(electrovalenceTotal);
+ chargingBillVO.setServiceCharge(serviceChargeTotal);
+ chargingBillVO.setOrderCount(orderCount);
+ chargingBillVO.setCommissionAmount(commissionAmountTotal);
+ chargingBillVO.setSharingAmount(sharingAmountTotal);
+ chargingBillVO.setDiscount(discountTotal);
+
+
+ pageInfo.setRecords(list);
+ chargingBillVO.setList(pageInfo);
+ return chargingBillVO;
+ }
+
+ public static void main(String[] args) {
+ LocalDateTime now = LocalDateTime.now();
+ // 将时间转化为字符串 只保留年月日 格式为yyyy-MM-dd
+ String format = now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ }
+
+}
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 b99ebf0..928979b 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
@@ -4,7 +4,6 @@
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.*;
import com.ruoyi.account.api.model.*;
@@ -16,11 +15,9 @@
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
-import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.ChargingHandshakeClient;
import com.ruoyi.integration.api.feignClient.PlatformStartChargingReplyClient;
import com.ruoyi.integration.api.feignClient.SendMessageClient;
@@ -40,6 +37,10 @@
import com.ruoyi.order.api.vo.*;
import com.ruoyi.order.dto.*;
import com.ruoyi.order.mapper.TChargingOrderMapper;
+import com.ruoyi.order.service.TChargingOrderAccountingStrategyService;
+import com.ruoyi.order.service.TChargingOrderRefundService;
+import com.ruoyi.order.service.TChargingOrderService;
+import com.ruoyi.order.service.TOrderEvaluateService;
import com.ruoyi.order.service.*;
import com.ruoyi.other.api.domain.TCoupon;
import com.ruoyi.other.api.domain.TGoods;
@@ -54,7 +55,6 @@
import com.ruoyi.payment.api.model.RefundResp;
import com.ruoyi.payment.api.model.WxPaymentRefundModel;
import com.ruoyi.payment.api.vo.*;
-import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.ApiModelProperty;
@@ -74,7 +74,6 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
-import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
@@ -91,7 +90,7 @@
public class TChargingOrderServiceImpl extends ServiceImpl<TChargingOrderMapper, TChargingOrder> implements TChargingOrderService {
private Logger log = LoggerFactory.getLogger(TChargingOrderServiceImpl.class);
-
+
@Resource
private ChargingGunClient chargingGunClient;
@@ -141,45 +140,45 @@
@Resource
private TOrderEvaluateService orderEvaluateService;
-
+
@Resource
private AccountingStrategyDetailClient accountingStrategyDetailClient;
-
+
@Resource
private AccountingStrategyDetailOrderClient accountingStrategyDetailOrderClient;
-
+
@Resource
private AccountingStrategyClient accountingStrategyClient;
-
+
@Resource
private PlatformStartChargingReplyClient platformStartChargingReplyClient;
-
+
@Resource
private TChargingOrderRefundService chargingOrderRefundService;
-
+
@Resource
private PlatformStopChargingReplyClient platformStopChargingReplyClient;
-
+
@Resource
private AccountingStrategyOrderService accountingStrategyOrderService;
-
+
@Resource
private AccountingStrategyDetailOrderService accountingStrategyDetailOrderService;
-
+
@Resource
private InviteUserClient inviteUserClient;
-
+
@Resource
private AppUserIntegralChangeClient appUserIntegralChangeClient;
-
+
@Resource
private IntegralRuleClient integralRuleClient;
-
+
//计数器
private Map<String, Integer> counter_map = new HashMap<>();
-
-
-
+
+
+
/**
* 获取小程序充电记录列表数据
@@ -438,9 +437,10 @@
chargingOrder.setVipDiscountAmount(discountAmount);
}
}
+
}
this.save(chargingOrder);
-
+
//添加订单的计费策略
TAccountingStrategy accountingStrategy = accountingStrategyClient.getAccountingStrategyById(tChargingGun.getAccountingStrategyId()).getData();
List<TAccountingStrategyDetail> strategyDetailList = accountingStrategyDetailClient.getListByAccountingStrategyId(tChargingGun.getAccountingStrategyId()).getData();
@@ -456,7 +456,7 @@
list1.add(accountingStrategyDetailOrder);
}
accountingStrategyDetailOrderService.saveBatch(list1);
-
+
//会员优惠折扣将其计入增加充电时长(增加总充电金额)
//如果充电总金额未使用完,则需要退回费用=(原金额/总金额)*(总金额-实际充电金额)
if(1 == addChargingOrder.getPaymentType()){
@@ -504,7 +504,7 @@
chargingOrder.setRechargePaymentStatus(2);
chargingOrder.setRechargeSerialNumber(transaction_id);
chargingOrder.setStatus(2);
-
+
//添加安全检测数据到缓存中,每步安全检测完成后需要更新缓存数据
PreChargeCheck preChargeCheck = new PreChargeCheck();
preChargeCheck.setElectronicLockLock(false);
@@ -526,7 +526,7 @@
//计算电费金额和服务费
BigDecimal serviceCharge = strategyDetail.getServiceCharge().multiply(degrees);
BigDecimal electrovalence = strategyDetail.getElectrovalence().multiply(degrees);
-
+
//再处理会员折扣
BigDecimal discount = BigDecimal.ZERO;
TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData();
@@ -544,8 +544,8 @@
electrovalence = electrovalence.add(discount);
chargingOrder.setChargeAmount(electrovalence);
this.updateById(chargingOrder);
-
-
+
+
TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData();
//调用远程启动充电消息
PlatformStartCharging platformStartCharging = new PlatformStartCharging();
@@ -662,11 +662,11 @@
}
}
}
-
+
}
}
-
-
+
+
/**
* 启动失败后微信退款的回调处理
* @param out_refund_no
@@ -685,10 +685,10 @@
}
return AjaxResult.success();
}
-
-
-
-
+
+
+
+
/**
* 获取充电中的详情
* @param id
@@ -751,7 +751,7 @@
chargingOrder.setStatus(4);
chargingOrder.setEndMode(1);
this.updateById(chargingOrder);
-
+
//异步线程处理停机
ExecutorService cachedThreadPool = Executors.newFixedThreadPool(1);
cachedThreadPool.execute(()->{
@@ -776,7 +776,7 @@
}
continue;
}
-
+
if(0 == reply.getStop_result()){
String failure_cause = "";
switch (reply.getFailure_cause()){
@@ -796,14 +796,14 @@
log.error("停机失败:订单号:{},失败原因:{}", chargingOrder.getCode(), failure_cause);
throw new RuntimeException(failure_cause);
}
-
+
//计算费用,处理退款
endCharge(chargingOrder);
break;
}
});
-
-
+
+
//处理推荐奖励(被推荐首单奖励)
TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData();
long count = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId())
@@ -838,15 +838,15 @@
appUserIntegralChange.setCurrentIntegral(appUser1.getPoints() + num1);
appUserIntegralChange.setCreateTime(LocalDateTime.now());
appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange);
-
+
appUser1.setPoints(appUser1.getPoints() + num1);
appUserClient.updateAppUser(appUser1);
}
-
+
return AjaxResult.success();
}
-
-
+
+
/**
* 手动结束后的费用计算和退款逻辑
*/
@@ -873,14 +873,14 @@
orderAmount = orderAmount.divide(chargingOrder.getVipDiscount().divide(new BigDecimal(10)));
chargingOrder.setOrderAmount(total);
}
-
+
if(chargingOrder.getEndMode() == 2){
chargingOrder.setEndMode(refundAmount.compareTo(BigDecimal.ZERO) > 0 ? 2 : 3);
}
chargingOrder.setStatus(5);
chargingOrder.setPaymentAmount(payAmount);
this.updateById(chargingOrder);
-
+
//计算优惠券
if(null != chargingOrder.getAppCouponId()){
//判断实际充电金额是否满足优惠券使用条件,如果不满足则不适用优惠券。
@@ -916,7 +916,7 @@
}
}
}
-
+
if(null != chargingOrder.getVipDiscount()){
BigDecimal subtract = orderAmount.subtract(total);
chargingOrder.setVipDiscountAmount(subtract);
@@ -972,9 +972,9 @@
}
}
}
-
+
}
-
+
}
@@ -1323,10 +1323,10 @@
return chargingOrderTimeVO;
}
- @Override
- public R payRefund(PayOrderRefundDto payOrderQueryDto) {
- return null;
- }
+// @Override
+// public R payRefund(PayOrderRefundDto payOrderQueryDto) {
+// return null;
+// }
@Override
public ChargingOrderListInfoVO chargingInfo(String uid) {
@@ -1378,6 +1378,7 @@
chargingOrderListInfoVO.setList1(list);
return chargingOrderListInfoVO;
}
+
/**
* 处理充电订单实时监控数据相关的业务逻辑
@@ -1463,7 +1464,7 @@
chargingOrderAccountingStrategyService.save(chargingOrderAccountingStrategy1);
}
}
-
+
List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>()
.eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId()));
BigDecimal t = BigDecimal.ZERO;
@@ -1477,8 +1478,8 @@
this.updateById(chargingOrder);
}
}
-
-
+
+
/**
* 自动结束充电后的处理逻辑
* @param orderCode
@@ -1494,10 +1495,10 @@
chargingOrder.setStatus(5);
chargingOrder.setEndMode(endMode);
this.updateById(chargingOrder);
-
+
//计算费用,处理退款
endCharge(chargingOrder);
-
+
//处理推荐奖励(被推荐首单奖励)
TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData();
long count = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId())
@@ -1532,12 +1533,12 @@
appUserIntegralChange.setCurrentIntegral(appUser1.getPoints() + num1);
appUserIntegralChange.setCreateTime(LocalDateTime.now());
appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange);
-
+
appUser1.setPoints(appUser1.getPoints() + num1);
appUserClient.updateAppUser(appUser1);
}
}
-
+
/**
* 异常结束充电处理逻辑
* @param orderCode
@@ -1546,6 +1547,71 @@
public void excelEndCharge(String orderCode) {
endCharge(orderCode, 0);
}
+
+
+
+ @Override
+ public R payRefund(PayOrderRefundDto payOrderQueryDto) {
+ if (payOrderQueryDto.getType()==1){
+ TChargingOrder tChargingOrder = this.baseMapper.selectById(payOrderQueryDto.getOrderId());
+ TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund();
+ chargingOrderRefund.setChargingOrderId(tChargingOrder.getId());
+ chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount());
+ chargingOrderRefund.setRefundStatus(1);
+ chargingOrderRefund.setPayType(tChargingOrder.getRechargePaymentType());
+ chargingOrderRefund.setRefundTime(LocalDateTime.now());
+ chargingOrderRefund.setCode(tChargingOrder.getCode());
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+ chargingOrderRefund.setRefundCode("GDF" + sdf.format(new Date()) + (Math.random() * 1000));
+ chargingOrderRefund.setRefundTitle("后台退款");
+ chargingOrderRefund.setRefundContent("后台退款");
+ chargingOrderRefund.setRefundReason("后台退款");
+ chargingOrderRefund.setRefundRemark("后台退款");
+ chargingOrderRefund.setRefundTotalAmount(tChargingOrder.getRefundAmount().add(payOrderQueryDto.getRefundAmount()));
+ chargingOrderRefund.setPayAmount(tChargingOrder.getPaymentAmount());
+
+ if(1 == tChargingOrder.getRechargePaymentType()){
+ WxPaymentRefundModel model = new WxPaymentRefundModel();
+ model.setOut_trade_no(tChargingOrder.getCode());
+ model.setOut_refund_no(chargingOrderRefund.getRefundCode());
+ model.setTransaction_id(tChargingOrder.getRechargeSerialNumber());
+ model.setReason("取消订单");
+ model.setNotify_url("http://127.0.0.1:9000/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.setCurrency("CNY");
+ model.setAmount(amount);
+ R<String> orderR = wxPaymentClient.refundOrderR(model);
+ if(200 == orderR.getCode()){
+ chargingOrderRefundService.save(chargingOrderRefund);
+ }
+ }
+
+ if(2 == tChargingOrder.getRechargePaymentType()){
+ RefundReq dto = new RefundReq();
+ dto.setOutTradeNo(tChargingOrder.getCode());
+ dto.setOutRequestNo(tChargingOrder.getCode());
+ dto.setRefundAmount(payOrderQueryDto.getRefundAmount().toString());
+ dto.setRefundReason("取消订单");
+ RefundResp resp = aliPaymentClient.refund(dto).getData();
+ if(null != resp){
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE");
+ chargingOrderRefundService.save(chargingOrderRefund);
+
+ }
+ }
+
+
+
+
+
+ }
+
+
+
+ return null;
+ }
/**
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java
index c96a21f..53d4fb7 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java
@@ -1,6 +1,8 @@
package com.ruoyi.order.service.impl;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.api.dto.GiveVipDto;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TShoppingOrder;
import com.ruoyi.order.api.model.TVipOrder;
@@ -65,4 +67,18 @@
public BigDecimal getSumAmout(LocalDate sixBefore) {
return this.baseMapper.getSumAmout(sixBefore);
}
+
+ @Override
+ public void payBack(String outTradeNo) {
+ //将vip订单改为已完成
+ TVipOrder tVipOrder = this.baseMapper.selectOne(Wrappers.lambdaQuery(TVipOrder.class).eq(TVipOrder::getCode, outTradeNo));
+ tVipOrder.setPaymentStatus(2);
+ this.baseMapper.updateById(tVipOrder);
+ //赠送会员
+ GiveVipDto giveVipDto = new GiveVipDto();
+ giveVipDto.setUserIds(tVipOrder.getAppUserId().toString());
+ giveVipDto.setVipId(tVipOrder.getVipId());
+ giveVipDto.setType(tVipOrder.getVipType());
+// vipClient.giveVip(giveVipDto);
+ }
}
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingBillMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingBillMapper.xml
new file mode 100644
index 0000000..9300228
--- /dev/null
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingBillMapper.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.order.mapper.TChargingBillMapper">
+
+
+ <select id="chargingBillList" resultType="com.ruoyi.order.api.vo.ChargingBillListVO">
+ select t1.* from t_charging_bill t1
+ where 1=1
+ <if test="req.type != null ">
+ and t1.type = #{req.type}
+ </if>
+ <if test="req.state != null ">
+ and t1.status = #{req.state}
+ </if>
+ <if test="startTime1 != null and startTime1!=''">
+ and (t1.bill_time between #{startTime1} and #{startTime2}
+ </if>
+ <if test="req.uid != null and req.uid!=''">
+ and t1.id = #{req.uid}
+ </if>
+ </select>
+</mapper>
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
index ff1c3a2..a320601 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -195,44 +195,59 @@
</select>
<select id="getRefundList" resultType="com.ruoyi.order.api.model.TChargingOrderRefund">
- select * from (SELECT id,
- `code`,
- refund_code,
- refund_title,
- refund_reason,
- refund_amount,
- refund_total_amount,
- refund_time,
- pay_type,
- pay_amount,
- refund_remark
- FROM t_charging_order_refund
- UNION ALL
- SELECT id,
- `code`,
- refund_code,
- refund_title,
- refund_reason,
- refund_amount,
- refund_total_amount,
- refund_time,
- pay_type,
- pay_amount,
- refund_remark
- FROM t_shopping_order_refund
- UNION ALL
- SELECT id,
- `code`,
- refund_code,
- refund_title,
- refund_reason,
- refund_amount,
- refund_total_amount,
- refund_time,
- pay_type,
- pay_amount,
- refund_remark
- FROM t_vip_order_refund) o
+ select * from (SELECT re.id,
+ re.`code`,
+ re.refund_code,
+ re.refund_title,
+ re.refund_reason,
+ re.refund_amount,
+ re.refund_total_amount,
+ re.refund_time,
+ re.pay_type,
+ re.pay_amount,
+ re.refund_remark,
+ co.recharge_serial_number as serail_number,
+ co.payment_amount,
+ co.pay_time
+ FROM t_charging_order_refund re
+ LEFT JOIN t_charging_order co ON re.charging_order_id = co.id
+ UNION ALL
+ SELECT re.id,
+ re.`code`,
+ re.refund_code,
+ re.refund_title,
+ re.refund_reason,
+ re.refund_amount,
+ re.refund_total_amount,
+ re.refund_time,
+ re.pay_type,
+ re.pay_amount,
+ re.refund_remark,
+ so.serial_number,
+ so.payment_amount,
+ so.pay_time
+ FROM t_shopping_order_refund re
+ LEFT JOIN t_shopping_order so on re.shopping_order_id = so.id
+ UNION ALL
+ SELECT vr.id,
+ vr.`code`,
+ vr.refund_code,
+ vr.refund_title,
+ vr.refund_reason,
+ vr.refund_amount,
+ vr.refund_total_amount,
+ vr.refund_time,
+ vr.pay_type,
+ vr.pay_amount,
+ vr.refund_remark,
+ vo.serial_number,
+ vo.payment_amount,
+ vo.pay_time
+ FROM t_vip_order_refund vr
+ LEFT JOIN t_vip_order vo on vr.vip_order_id = vo.id
+
+
+ ) o
<where>
<if test="data.code != null and data.code != ''">
AND o.code LIKE CONCAT('%',#{data.code},'%')
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
index cefe4a4..9a1207d 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
@@ -8,6 +8,7 @@
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.other.api.domain.TCoupon;
import com.ruoyi.other.api.domain.TIntegralRule;
import com.ruoyi.other.api.domain.TUserTag;
@@ -47,6 +48,8 @@
private TVipService vipService;
@Resource
private TCouponService couponService;
+ @Resource
+ private TokenService tokenService;
@PostMapping("/saveVip")
@ApiOperation(tags = {"管理后台-会员管理"},value = "会员添加")
public AjaxResult saveVip(@RequestBody TVip dto) {
@@ -204,5 +207,52 @@
return R.ok(vipInfoDtos);
}
+
+ @ApiOperation(value = "购买会员", tags = {"小程序-个人中心"})
+ @GetMapping("/vipInfo/pay")
+ public R vipInfoPay(@RequestParam("vipId")Integer vipId,@RequestParam(name = "1月2季3年",value = "buyType") Integer buyType,
+ @RequestParam(name = "1微信2支付宝",value = "payType") Integer payType
+ ) {
+
+ TVip byId = vipService.getById(vipId);
+ BigDecimal payMoney = BigDecimal.ZERO;
+ BigDecimal discountMoney = BigDecimal.ZERO;
+ BigDecimal discount = BigDecimal.ZERO;
+ LocalDateTime now = LocalDateTime.now();
+ switch (buyType){
+ case 1:
+ if (byId.getMonthlyCardDiscountStart()!=null&&(now.isAfter(byId.getMonthlyCardDiscountStart())&&now.isBefore(byId.getMonthlyCardDiscountEnd()))){
+ payMoney = byId.getMonthlyCard().multiply(byId.getMonthlyCardDiscount());
+ discountMoney = byId.getMonthlyCard().subtract(payMoney);
+ discount = byId.getMonthlyCardDiscount();
+ }else {
+ payMoney = byId.getMonthlyCard();
+ }
+ break;
+ case 2:
+ if (byId.getSeasonCardDiscountStart()!=null&&(now.isAfter(byId.getSeasonCardDiscountStart())&&now.isBefore(byId.getSeasonCardDiscountEnd()))){
+ payMoney = byId.getSeasonCard().multiply(byId.getSeasonCardDiscount());
+ discountMoney = byId.getSeasonCard().subtract(payMoney);
+ discount = byId.getSeasonCardDiscount();
+ }else {
+ payMoney = byId.getSeasonCard();
+ }
+ break;
+ case 3:
+ if (byId.getAnnualCardDiscountStart()!=null&&(now.isAfter(byId.getAnnualCardDiscountStart())&&now.isBefore(byId.getAnnualCardDiscountEnd()))){
+ payMoney = byId.getAnnualCard().multiply(byId.getAnnualCardDiscount());
+ discountMoney = byId.getAnnualCard().subtract(payMoney);
+ discount = byId.getAnnualCardDiscount();
+ }else {
+ payMoney = byId.getAnnualCard();
+ }
+ break;
+ }
+
+ Long userId = tokenService.getLoginUserApplet().getUserId();
+
+ return R.ok(vipService.vipInfoPay(byId,payMoney,payType,discountMoney,discount,buyType,userId));
+ }
+
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TVipService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TVipService.java
index 27af66e..522dd5a 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TVipService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TVipService.java
@@ -4,6 +4,8 @@
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.other.api.domain.TVip;
+import java.math.BigDecimal;
+
/**
* <p>
* 服务类
@@ -17,4 +19,5 @@
PageInfo<TVip> pageList(Integer pageCurr,Integer pageSize);
+ Object vipInfoPay(TVip byId, BigDecimal payMoney, Integer payType,BigDecimal discountMoney,BigDecimal discount,Integer buyType, Long userId);
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java
index d15b333..369b371 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TVipServiceImpl.java
@@ -1,19 +1,33 @@
package com.ruoyi.other.service.impl;
+import java.time.LocalDateTime;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.TAppUser;
+import com.ruoyi.common.core.utils.OrderCodeUtil;
+import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.feignClient.OrderClient;
+import com.ruoyi.order.api.model.TVipOrder;
import com.ruoyi.other.api.domain.TCoupon;
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.mapper.TCouponMapper;
import com.ruoyi.other.mapper.TVipMapper;
import com.ruoyi.other.service.TVipService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.payment.api.feignClient.AliPaymentClient;
+import com.ruoyi.payment.api.feignClient.WxPaymentClient;
+import com.ruoyi.payment.api.vo.AliPaymentReq;
+import com.ruoyi.payment.api.vo.AliPaymentResp;
+import com.ruoyi.payment.api.vo.PaymentOrder;
import org.apache.poi.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -29,6 +43,17 @@
@Autowired
private TCouponMapper tCouponMapper;
+ @Resource
+ private OrderClient orderClient;
+ @Resource
+ private AppUserClient appUserClient;
+
+ @Resource
+ private WxPaymentClient wxPaymentClient;
+ @Resource
+ private AliPaymentClient aliPaymentClient;
+
+
@Override
public PageInfo<TVip> pageList(Integer pageCurr,Integer pageSize) {
PageInfo<TVip> pageInfo = new PageInfo<>(pageCurr,pageSize);
@@ -54,4 +79,51 @@
pageInfo.setRecords(list);
return pageInfo;
}
+
+ @Override
+ public Object vipInfoPay(TVip byId, BigDecimal payMoney, Integer payType,BigDecimal discountMoney,BigDecimal discount,Integer buyType, Long userId) {
+ TAppUser user = appUserClient.getUserById(userId).getData();
+
+ //生成会员购买订单
+
+ TVipOrder shopOrder = new TVipOrder();
+ shopOrder.setCode(OrderCodeUtil.getOrderCode("HY"));
+ shopOrder.setAppUserId(userId);
+ shopOrder.setType(1);
+ shopOrder.setVipId(byId.getId());
+ shopOrder.setVipType(buyType);
+ shopOrder.setOrderAmount(payMoney.add(discountMoney));
+ shopOrder.setDiscount(discount);
+ shopOrder.setDiscountAmount(discountMoney);
+ shopOrder.setPaymentAmount(payMoney);
+ shopOrder.setPaymentStatus(1);
+ shopOrder.setPaymentType(payType);
+ shopOrder.setPayTime(LocalDateTime.now());
+ orderClient.addVipOrder(shopOrder).getData();
+
+
+ if (payType==1){
+ //调起支付
+ PaymentOrder paymentOrder = new PaymentOrder();
+ paymentOrder.setCode(shopOrder.getCode());
+ paymentOrder.setAmount(shopOrder.getPaymentAmount());
+ paymentOrder.setOpenId(user.getWxOpenid());
+ paymentOrder.setDescription("购买会员");
+ return wxPaymentClient.orderPay(paymentOrder);
+ }else {
+ AliPaymentReq req = new AliPaymentReq();
+ req.setOutTradeNo(shopOrder.getCode());
+ req.setTotalAmount(shopOrder.getPaymentAmount().toString());
+ req.setSubject("充电充值");
+ req.setBuyerOpenId(user.getAliOpenid());
+ req.setBody("充电充值");
+ AliPaymentResp data = aliPaymentClient.payment(req).getData();
+ if(null != data){
+ data.setNotifyUrl(data.getNotifyUrl() + "/callBack/ali/all");
+ return AjaxResult.success(data);
+ }
+ }
+
+ return null;
+ }
}
diff --git a/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/AliPayController.java b/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/AliPayController.java
index ea2bb50..171369c 100644
--- a/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/AliPayController.java
+++ b/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/AliPayController.java
@@ -1,6 +1,7 @@
package com.ruoyi.payment.controller;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.payment.ali.config.AliProperties;
import com.ruoyi.payment.ali.v2.AppletPayUtil;
import com.ruoyi.payment.api.model.*;
@@ -11,6 +12,8 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
/**
* @author zhibing.pu
@@ -83,6 +86,27 @@
public R<RefundResp> refund(@RequestBody RefundReq dto){
return R.ok(appletPayUtil.refund(dto));
}
+
+
+ @ResponseBody
+ @PostMapping(value = "/allCallBack")
+ public void chargingOrderALICallback(@RequestBody AliQueryOrder aliQueryOrder, HttpServletResponse response) {
+ try {
+ String out_trade_no = aliQueryOrder.getOutTradeNo();
+ String transaction_id = aliQueryOrder.getTradeNo();
+ String attach = aliQueryOrder.getPassbackParams();
+// AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(2, out_trade_no, transaction_id, attach);
+// if (ajaxResult.isSuccess()) {
+// PrintWriter writer = response.getWriter();
+// writer.println("success");
+// writer.flush();
+// writer.close();
+// }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
diff --git a/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/WxPayController.java b/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/WxPayController.java
index a937505..3ed6053 100644
--- a/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/WxPayController.java
+++ b/ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/WxPayController.java
@@ -114,12 +114,14 @@
log.info("支付回调:{}", params);
String outRefundNo = (String) params.get("out_refund_no");
String out_trade_no = params.get("out_trade_no").toString();
- String substring = outRefundNo.substring(0, 2);
+ String substring = out_trade_no.substring(0, 2);
switch (substring){
//购物订单
case "GW":
break;
+ case "HY":
+ break;
}
return R.ok(params);
--
Gitblit v1.7.1