Ver Fonte

Merge remote-tracking branch 'origin/dev' into dev

zuy há 2 anos atrás
pai
commit
d4d12df357

+ 1 - 1
admin-web/src/views/admin/index.vue

@@ -217,7 +217,7 @@ const initLineChart = (dataList: Array<any>) => {
     },
     grid: {top: 70, right: 0, bottom: 30, left: 50},
     tooltip: {trigger: 'axis'},
-    legend: {data: ['充电量', /*'总金额','电费',*/'服务费',], right: 0},
+    legend: {data: ['充电量', /*'总金额','电费',*/'实付服务费',], right: 0},
     xAxis: {
       data: xAxis,
       // data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],

+ 15 - 13
admin-web/src/views/admin/invoice/index.vue

@@ -126,10 +126,10 @@
                   <h4 class="pd5">关联订单明细</h4>
                   <el-table :data="row.orderDetails" width="400" border>
                     <el-table-column label="充电订单" prop="startChargeSeq"/>
-                    <el-table-column label="总金额(元)" prop="totalMoney">
+                    <el-table-column label="订单总金额" prop="totalMoney">
                       <template #default="{row}">{{ u.fmt.fmtMoney(row.totalMoney) }}</template>
                     </el-table-column>
-                    <el-table-column label="总电量(Kwh)" prop="totalPower"/>
+                    <el-table-column label="总电量/度" prop="totalPower"/>
                     <el-table-column label="电费" prop="elecMoney">
                       <template #default="{row}">{{ u.fmt.fmtMoney(row.elecMoney) }}</template>
                     </el-table-column>
@@ -224,18 +224,20 @@ const state = reactive({
     loading: false,
     columns: [
       {type: 'expand', prop: 'expand', width: 30, fixed: 'left'},
-      {label: '用户手机号', prop: 'mobilePhone', align: 'center', fixed: 'left', width: 150},
-      {label: '申请号', prop: 'applyId', align: 'center', fixed: 'left', width: 220},
+      {label: '用户手机号', prop: 'mobilePhone', align: 'center', fixed: 'left', width: 120},
+      {label: '发票ID', prop: 'id', align: 'center', fixed: 'left', width: 110},
+      {label: '发票申请单号', prop: 'applyId', align: 'center', fixed: 'left', width: 130},
       {label: '发票状态', prop: 'status', align: 'center', fixed: 'left', width: 100},
-      {label: '发票金额(元)', prop: 'invoiceAmount', resizable: true, width: 150},
-      {label: '订单总金额(元)', prop: 'totalMoney', resizable: true, width: 150},
-      {label: '总服务费(元)', prop: 'serviceMoney', resizable: true, width: 140},
-      {label: '开票人', prop: 'biller', resizable: true, width: 130},
-      {label: '公司税号', prop: 'taxId', resizable: true, width: 130},
-      {label: '接收发票邮箱', prop: 'email', resizable: true, width: 130},
-      {label: '电话', prop: 'phone', resizable: true, width: 130},
-      {label: '发票类型', prop: 'invoiceType', resizable: true, width: 130},
-      {label: '发票抬头名称', prop: 'invoiceTitle', resizable: true, width: 130},
+      {label: '发票金额', prop: 'invoiceAmount', resizable: true, width: 90},
+      {label: '订单总额', prop: 'totalMoney', resizable: true, width: 90},
+      {label: '总服务费', prop: 'serviceMoney', resizable: true, width: 90},
+      {label: '服务费优惠', prop: 'serviceMoneyDiscount', resizable: true, width: 105},
+      {label: '开票人', prop: 'biller', resizable: true, width: 80},
+      {label: '公司税号', prop: 'taxId', resizable: true, width: 110},
+      {label: '接收发票邮箱', prop: 'email', resizable: true, width: 120},
+      {label: '电话', prop: 'phone', resizable: true, width: 90},
+      {label: '发票类型', prop: 'invoiceType', resizable: true, width: 90},
+      {label: '发票抬头', prop: 'invoiceTitle', resizable: true, width: 110},
       /*
 
             {label: '公司地址', prop: 'address', resizable: true, width: 130},

+ 14 - 14
admin-web/src/views/admin/ordering/index.vue

@@ -275,27 +275,27 @@ const state = reactive({
     data: [] as Array<any>,
     loading: false,
     columns: [
-      {label: '站点', prop: 'stationId', width: 150,align:'center', resizable: true, fixed: 'left'},
-      {label: '用户手机号', prop: 'mobilePhone', width: 130, resizable: true, fixed: 'left'},
+      {label: '站点ID/名称', prop: 'stationId', width: 130,align:'center', resizable: true, fixed: 'left'},
+      {label: '用户手机号', prop: 'mobilePhone', width: 120, resizable: true, fixed: 'left'},
       // {label: '站点ID',  prop: 'stationId',width:100, resizable: true, fixed: 'left'},
       // {label: '站点', prop: 'stationName', width: 150, resizable: true, fixed: 'left'},
       {label: '充电订单号', prop: 'startChargeSeq', width: 170, resizable: true, fixed: 'left'},
       {label: '充电设备接口编码', prop: 'connectorId', width: 160, resizable: true},
-      {label: '充电开始时间', prop: 'startTime', sortable: 'custom', width: 160, resizable: true},
+      {label: '充电开始/结束时间', prop: 'startTime', sortable: 'custom', width: 175, resizable: true},
       // {label: '充电结束时间', prop: 'endTime', sortable: 'custom', width: 160, resizable: true},
-      {label: '充电量(度)', prop: 'totalPower', width: 120, resizable: true},
-      {label: '订单总金额(元)', prop: 'totalMoney', width: 150, resizable: true},
-      {label: '服务费优惠(元)', prop: 'serviceMoneyDiscount', width: 150, resizable: true},
-      {label: '实付金额(元)', prop: 'payAmount', width: 150, resizable: true},
-      {label: '总电费(元)', prop: 'elecMoney', width: 140, resizable: true},
-      {label: '总服务费(元)', prop: 'serviceMoney', width: 150, resizable: true},
-      {label: '实付服务费(元)', prop: 'payServiceAmount', width: 150, resizable: true},
+      {label: '充电量/度', prop: 'totalPower', width: 95, resizable: true},
+      {label: '订单总金额', prop: 'totalMoney', width: 105, resizable: true},
+      {label: '服务费优惠', prop: 'serviceMoneyDiscount', width: 105, resizable: true},
+      {label: '实付金额', prop: 'payAmount', width: 90, resizable: true},
+      {label: '总电费', prop: 'elecMoney', width: 80, resizable: true},
+      {label: '总服务费', prop: 'serviceMoney', width: 90, resizable: true},
+      {label: '实付服务费', prop: 'payServiceAmount', width: 105, resizable: true},
       // {label: '时段数:0~32', prop: 'sumPeriod', width:150, resizable: true},
       // {label: '充电明细信息', prop: 'chargeDetail', width:150, resizable: true},
-      {label: '订单状态', prop: 'orderStatus', width: 120, resizable: true},
-      {label: '充电状态', prop: 'chargeStatus', width: 120, resizable: true},
-      {label: '充电停止原因', prop: 'stopReason', width: 150, resizable: true},
-      {label: '发票状态', prop: 'invoiceStatus', width: 120, resizable: true},
+      {label: '订单状态', prop: 'orderStatus', width: 90, resizable: true},
+      {label: '充电状态', prop: 'chargeStatus', width: 90, resizable: true},
+      {label: '充电停止原因', prop: 'stopReason', width: 120, resizable: true},
+      {label: '发票状态', prop: 'invoiceStatus', width: 90, resizable: true},
       // {label: '创建时间', prop: 'createTime', sortable: 'custom', width:150, resizable: true},
       // {label: '更新时间', prop: 'updateTime', sortable: 'custom',width:150,  resizable: true},
       // {

+ 8 - 0
admin/src/main/java/com/kym/admin/controller/StatController.java

@@ -50,4 +50,12 @@ public class StatController {
 
     // TODO: 2023-12-01 站点平均单度电费数据 日/月/整体维度
 
+    // 站点详细数据统计
+    @GetMapping("/stationStatDetail")
+    R<?> stationStatDetail(@ModelAttribute StatQueryParam params){
+        var res = chargeOrderService.stationStatDetail(params);
+        return R.success(res);
+    }
+
+
 }

+ 4 - 2
entity/src/main/java/com/kym/entity/admin/queryParams/StatQueryParam.java

@@ -4,6 +4,7 @@ import com.kym.entity.common.PageParams;
 import lombok.Data;
 
 import java.time.LocalDate;
+import java.util.List;
 
 /**
  * @author skyline
@@ -13,10 +14,11 @@ import java.time.LocalDate;
 @Data
 public class StatQueryParam extends PageParams {
 
-    private static final String TYPE_DAY = "day";
-    private static final String TYPE_MONTH = "month";
+    public static final String TYPE_DAY = "day";
+    public static final String TYPE_MONTH = "month";
 
     private String stationId;
+    private List<String> stationIds;
     private String type;
 
 

+ 5 - 0
entity/src/main/java/com/kym/entity/miniapp/OrderRechargeRights.java

@@ -33,6 +33,11 @@ public class OrderRechargeRights extends BaseEntity {
      */
     private Long activityId;
 
+    /**
+     * 用户充值权益id
+     */
+    private Long userRightsId;
+
     /**
      * 用户id
      */

+ 1 - 1
miniapp/src/main/java/com/kym/miniapp/aspect/AppLogAspect.java

@@ -86,7 +86,7 @@ public class AppLogAspect {
         //设置IP地址
         appLog.setIp(IPUtils.getIpAddr(request));
         //用户名、公司id、后台用户id
-        if (!apiLog.value().contains("推送") && apiLog.value().contains("拉取")) {
+        if (!apiLog.value().contains("推送") && !apiLog.value().contains("拉取")) {
             appLog.setUserId(StpUtil.getSession().getLong("userId"));
             appLog.setCompanyId(StpUtil.getSession().getLong("companyId"));
             appLog.setUsername(StpUtil.getSession().getString("username"));

+ 8 - 0
miniapp/src/main/java/com/kym/miniapp/jobs/StartChargeDelayJob.java

@@ -90,6 +90,14 @@ public class StartChargeDelayJob implements DelayService<DelayChargeOrder> {
                         log.error("预约充电队列take异常", e);
                     } else {
                         log.info("预约启动充电失败,订单号:{}", threadLocal.get(), e);
+                        // 启动失败将订单状态修改为充电状态已结束,订单状态已确认,结束原因:预约启动失败
+                        chargeOrderService.lambdaUpdate()
+                                .eq(ChargeOrder::getStartChargeSeq, threadLocal.get())
+                                .set(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_已结束)
+                                .set(ChargeOrder::getOrderStatus, ChargeOrder.ORDER_STATUS_失败)
+                                .set(ChargeOrder::getStopReason, "预约启动充电失败")
+                                .update();
+
                     }
                 } finally {
                     threadLocal.remove();

+ 6 - 1
service/src/main/java/com/kym/service/admin/impl/StationServiceImpl.java

@@ -80,7 +80,12 @@ public class StationServiceImpl extends MPJBaseServiceImpl<StationMapper, Statio
             station.getEquipmentInfos().forEach(enEquipmentInfo ->
                     enEquipmentInfo.setShortId(KymCache.INSTANCE.getShortIdByEquipmentIdOrConnectorId(enEquipmentInfo.getEquipmentId()))
                             .setParkingNo(KymCache.INSTANCE.getParkNoByEquipmentIdOrConnectorId(enEquipmentInfo.getEquipmentId())));
-            station.setPictures(stations.stream().filter(item -> item.getStationId().equals(station.getStationId())).toList().get(0).getPictures());
+            var res = stations.stream().filter(item -> item.getStationId().equals(station.getStationId())).toList();
+            if (!res.isEmpty()) {
+                station.setPictures(res.get(0).getPictures());
+            } else {
+                station.setPictures(null);
+            }
         });
 
         stationList.forEach(vo -> vo.setEquipmentInfos(vo.getEquipmentInfos().stream().sorted(Comparator.comparing(EnEquipmentInfo::getShortId)).toList()));

+ 1 - 0
service/src/main/java/com/kym/service/enplus/impl/EnNotifyServiceImpl.java

@@ -315,6 +315,7 @@ public class EnNotifyServiceImpl implements EnNotifyService {
 
                 // 用户充值权益
                 var userRechargeRights = userRechargeRightsService.lambdaQuery()
+                        .eq(UserRechargeRights::getId, orderRechargeRights.getUserRightsId())
                         .eq(UserRechargeRights::getUserId, chargeOrder.getUserId())
                         .eq(UserRechargeRights::getRightsId, orderRechargeRights.getRightsId())
                         .one();

+ 2 - 0
service/src/main/java/com/kym/service/miniapp/ChargeOrderService.java

@@ -41,4 +41,6 @@ public interface ChargeOrderService extends MPJBaseService<ChargeOrder> {
     void exportCustomChargeOrders(CustomChargeOrdersQueryParam params, HttpServletResponse response);
 
     PageBean<ChargeOrderVo> listUserChargeOrders(OrderQueryParams params);
+
+    Map stationStatDetail(StatQueryParam params);
 }

+ 38 - 3
service/src/main/java/com/kym/service/miniapp/impl/ChargeOrderServiceImpl.java

@@ -9,6 +9,8 @@ import com.github.pagehelper.PageHelper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.kym.common.utils.CommUtil;
 import com.kym.entity.admin.RechargeRights;
+import com.kym.entity.admin.StationStatDay;
+import com.kym.entity.admin.StationStatMonth;
 import com.kym.entity.admin.queryParams.CustomChargeOrdersQueryParam;
 import com.kym.entity.admin.queryParams.StatQueryParam;
 import com.kym.entity.admin.vo.CustomOrderVo;
@@ -21,6 +23,8 @@ import com.kym.entity.miniapp.vo.ChargeOrderVo;
 import com.kym.mapper.miniapp.ChargeOrderMapper;
 import com.kym.service.admin.ExportService;
 import com.kym.service.admin.RechargeRightsService;
+import com.kym.service.admin.StationStatDayService;
+import com.kym.service.admin.StationStatMonthService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.miniapp.ChargeOrderService;
 import com.kym.service.miniapp.OrderRechargeRightsService;
@@ -56,10 +60,15 @@ public class ChargeOrderServiceImpl extends MPJBaseServiceImpl<ChargeOrderMapper
     private final OrderRechargeRightsService orderRechargeRightsService;
     private final RechargeRightsService rechargeRightsService;
 
-    public ChargeOrderServiceImpl(ExportService exportService, OrderRechargeRightsService orderRechargeRightsService, RechargeRightsService rechargeRightsService) {
+    private final StationStatDayService stationStatDayService;
+    private final StationStatMonthService stationStatMonthService;
+
+    public ChargeOrderServiceImpl(ExportService exportService, OrderRechargeRightsService orderRechargeRightsService, RechargeRightsService rechargeRightsService, StationStatDayService stationStatDayService, StationStatMonthService stationStatMonthService) {
         this.exportService = exportService;
         this.orderRechargeRightsService = orderRechargeRightsService;
         this.rechargeRightsService = rechargeRightsService;
+        this.stationStatDayService = stationStatDayService;
+        this.stationStatMonthService = stationStatMonthService;
     }
 
 
@@ -67,7 +76,7 @@ public class ChargeOrderServiceImpl extends MPJBaseServiceImpl<ChargeOrderMapper
     public ChargeOrder getChargingOrderByUserId(Long userId) {
         return lambdaQuery()
                 .eq(ChargeOrder::getUserId, userId)
-                .in(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_预约中, ChargeOrder.CHARGE_STATUS_启动中, ChargeOrder.CHARGE_STATUS_充电中)
+                .in(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_预约中, ChargeOrder.CHARGE_STATUS_启动中, ChargeOrder.CHARGE_STATUS_充电中, ChargeOrder.CHARGE_STATUS_停止中)
                 .one();
     }
 
@@ -208,11 +217,37 @@ public class ChargeOrderServiceImpl extends MPJBaseServiceImpl<ChargeOrderMapper
         var map = Map.of(
                 "totalPower", BigDecimal.valueOf(res.stream().mapToDouble(StationStatVo::getTotalPower).sum()).setScale(2, RoundingMode.HALF_UP).doubleValue(),
                 "serviceMoney", res.stream().mapToInt(StationStatVo::getServiceMoney).sum(),
-                "payServiceAmount",res.stream().mapToInt(StationStatVo::getPayServiceAmount).sum()
+                "payServiceAmount", res.stream().mapToInt(StationStatVo::getPayServiceAmount).sum()
         );
         return new PageBean<>(res).setExtraData(map);
     }
 
+    /**
+     * 站点统计详情
+     *
+     * @param params
+     * @return
+     */
+    @Override
+    @DS("db-admin")
+    public Map<String, ?> stationStatDetail(StatQueryParam params) {
+        if (params.getType().equals(StatQueryParam.TYPE_DAY)) {
+            return stationStatDayService.lambdaQuery()
+                    .in(StationStatDay::getStationId, params.getStationIds())
+                    .ge(StationStatDay::getStatDay, params.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                    .le(StationStatDay::getStatDay, params.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                    .orderByAsc(StationStatDay::getStatDay)
+                    .list().stream().collect(Collectors.groupingBy(StationStatDay::getStationId, Collectors.toList()));
+        } else {
+            return stationStatMonthService.lambdaQuery()
+                    .in(StationStatMonth::getStationId, params.getStationIds())
+                    .ge(StationStatMonth::getStatMonth, params.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM")))
+                    .le(StationStatMonth::getStatMonth, params.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM")))
+                    .orderByAsc(StationStatMonth::getStatMonth)
+                    .list().stream().collect(Collectors.groupingBy(StationStatMonth::getStationId, Collectors.toList()));
+        }
+    }
+
     /**
      * 充电站当日统计
      *

+ 19 - 3
service/src/main/java/com/kym/service/miniapp/impl/ChargeServiceImpl.java

@@ -202,7 +202,11 @@ public class ChargeServiceImpl implements ChargeService {
         var account = checkCharge(userId, connectorId, isBooking, startTime);
 
         // 是否有之前预约充电创建的订单记录,有则直接用,没有则创建
-        ChargeOrder order = chargeOrderService.lambdaQuery().eq(ChargeOrder::getConnectorId, connectorId).in(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_已取消, ChargeOrder.CHARGE_STATUS_预约中).one();
+        ChargeOrder order = chargeOrderService.lambdaQuery()
+                .eq(ChargeOrder::getUserId, userId)
+                .eq(ChargeOrder::getConnectorId, connectorId)
+                .in(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_已取消, ChargeOrder.CHARGE_STATUS_预约中)
+                .one();
 
         if (order == null) {
             // 充电订单号/设备认证号
@@ -223,7 +227,12 @@ public class ChargeServiceImpl implements ChargeService {
             if (!CommUtil.isEmptyOrNull(userRechargeRightsId)) {
                 var userRechargeRights = userRechargeRightsService.lambdaQuery().eq(UserRechargeRights::getUserId, userId).eq(UserRechargeRights::getId, userRechargeRightsId).one();
                 if (userRechargeRights != null) {
-                    var orderRechargeRights = new OrderRechargeRights().setUserId(userId).setStartChargeSeq(startChargeSeq).setActivityId(userRechargeRights.getActivityId()).setRightsId(userRechargeRights.getRightsId()).setDiscount(userRechargeRights.getDiscount());
+                    var orderRechargeRights = new OrderRechargeRights()
+                            .setUserId(userId).setStartChargeSeq(startChargeSeq)
+                            .setActivityId(userRechargeRights.getActivityId())
+                            .setRightsId(userRechargeRights.getRightsId())
+                            .setUserRightsId(userRechargeRights.getId())
+                            .setDiscount(userRechargeRights.getDiscount());
                     orderRechargeRightsService.save(orderRechargeRights);
                 }
             }
@@ -237,7 +246,14 @@ public class ChargeServiceImpl implements ChargeService {
             if (!CommUtil.isEmptyOrNull(endTime)) {
                 order.setEndTime(endTime);
             }
-            chargeOrderService.lambdaUpdate().set(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_预约中).set(ChargeOrder::getIsBooking, order.getIsBooking()).set(ChargeOrder::getStartTime, startTime).set(!CommUtil.isEmptyOrNull(endTime), ChargeOrder::getEndTime, endTime).eq(ChargeOrder::getStartChargeSeq, order.getStartChargeSeq()).update();
+            chargeOrderService.lambdaUpdate()
+                    .set(ChargeOrder::getChargeStatus, ChargeOrder.CHARGE_STATUS_预约中)
+                    .set(ChargeOrder::getIsBooking, order.getIsBooking())
+                    .set(ChargeOrder::getStartTime, startTime)
+                    .set(!CommUtil.isEmptyOrNull(endTime), ChargeOrder::getEndTime, endTime)
+                    .eq(ChargeOrder::getUserId, userId)
+                    .eq(ChargeOrder::getStartChargeSeq, order.getStartChargeSeq())
+                    .update();
 
             var delayChargeOrder = new DelayChargeOrder();
             BeanUtils.copyProperties(order, delayChargeOrder);

+ 1 - 1
service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -528,7 +528,7 @@ public class WxPayServiceImpl implements WxPayService {
         refundLog.setCurrency(refund.getAmount().getCurrency());
         refundLog.setAdminUserId(StpUtil.getLoginIdAsLong());
         refundLog.setAdminUsername(StpUtil.getSession().getString("username"));
-        refundLog.setStatus(RefundLog.STATUS_退款已申请);
+        refundLog.setStatus(RefundLog.STATUS_退款处理中);
         refundLogService.updateById(refundLog);
 
     }