Bläddra i källkod

洗车订单列表

skyline 1 år sedan
förälder
incheckning
272b08ecde

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

@@ -90,10 +90,10 @@
                     border
                     :data="row.detail"
                     stripe="stripe">
-                  <el-table-column width="120" label="项目" prop="name"></el-table-column>
-                  <el-table-column width="120" label="时长" prop="seconds"></el-table-column>
-                  <el-table-column width="120" label="单价" prop="price"></el-table-column>
-                  <el-table-column width="120" label="费用" prop="amount"></el-table-column>
+                  <el-table-column width="120" label="服务项目" prop="name"></el-table-column>
+                  <el-table-column width="120" label="服务时长" prop="seconds"></el-table-column>
+                  <el-table-column width="120" label="服务单价" prop="price"></el-table-column>
+                  <el-table-column width="120" label="小计金额" prop="amount"></el-table-column>
                 </el-table>
               </div>
             </template>
@@ -178,35 +178,39 @@ const state = reactive({
   exportConfig: {},
   columns: [
     {type: 'expand', width: 60, align: 'center', fixed: 'left'},
-    {width: 260, label: '订单号', prop: 'orderId', query: true, type: 'text', resizable: true, fixed: 'left'},
-    {width: 260, label: '用户', prop: 'userId', query: true, type: 'text', resizable: true},
-    {width: 160, label: '消费总额', prop: 'amount', query: false, resizable: true},
-    {width: 160, label: '应收金额', prop: 'amountReceivable', query: false, type: '', resizable: true},
-    {width: 160, label: '实收金额', prop: 'amountReceived', query: false, type: 'text', resizable: true},
-    {width: 160, label: '卡内余额', prop: 'cardBalance', query: false, type: 'text', resizable: true},
-    {
-      width: 160, label: '卡过期时间',
-      prop: 'cardExpired',
-      query: false,
-      sortable: 'custom',
-      type: 'datetime',
-      resizable: true,
-      conf: {format: (val: any) => u.fmt.fmtDateTime(val)}
-    },
-    {width: 160, label: '卡内码', prop: 'cardId', query: false, type: 'text', resizable: true},
-    {width: 160, label: '卡串号', prop: 'cardSn', query: false, type: 'text', resizable: true},
-    {width: 160, label: '卡类型', prop: 'cardType', query: false, type: '', resizable: true},
+    {width: 220, label: '订单号', prop: 'orderId', query: true, type: 'text', resizable: true, fixed: 'left'},
+    {width: 120, label: '用户手机号', prop: 'mobilePhone', query: true, type: 'text', fixed: 'left'},
+    {width: 140, label: '站点名称', prop: 'stationName', query: false, type: 'text', resizable: true},
+    {width: 100, label: '设备编号', prop: 'shortId', query: false, type: 'text', resizable: true},
+    {width: 160, label: '开始时间', prop: 'startTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDate(val)}},
+    {width: 160, label: '结束时间', prop: 'endTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDateTime(val)}},
+    {width: 100, label: '消费总额', prop: 'amount', query: false, resizable: true},
+    {width: 100, label: '应收金额', prop: 'amountReceivable', query: false, type: '', resizable: true},
+    {width: 100, label: '实收金额', prop: 'amountReceived', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '卡内余额', prop: 'cardBalance', query: false, type: 'text', resizable: true},
+    // {
+    //   width: 160, label: '卡过期时间',
+    //   prop: 'cardExpired',
+    //   query: false,
+    //   sortable: 'custom',
+    //   type: 'datetime',
+    //   resizable: true,
+    //   conf: {format: (val: any) => u.fmt.fmtDateTime(val)}
+    // },
+    // {width: 160, label: '卡内码', prop: 'cardId', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '卡串号', prop: 'cardSn', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '卡类型', prop: 'cardType', query: false, type: '', resizable: true},
     {
-      width: 160, label: '关机方式',
+      width: 120, label: '关机方式',
       prop: 'closeType',
-      query: true,
+      query: false,
       type: 'dict',
       conf: {dict: 'Order.closeType'},
       resizable: true
     },
-    {width: 160, label: '投币的累计金额', prop: 'coinMoney', query: false, type: 'text', resizable: true},
-    {width: 160, label: '投币的次数', prop: 'coinNum', query: false, type: 'text', resizable: true},
-    {width: 160, label: '开单时间', prop: 'createTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDateTime(val)}},
+    // {width: 160, label: '投币的累计金额', prop: 'coinMoney', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '投币的次数', prop: 'coinNum', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '开单时间', prop: 'createTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDateTime(val)}},
     // {
     //   width:160,label: '费用明细',
     //   prop: 'detail',
@@ -215,30 +219,26 @@ const state = reactive({
     //   resizable: true
     // },
 
-    {width: 160, label: '设备名称', prop: 'deviceName', query: false, type: 'text', resizable: true},
-    {width: 160, label: '优惠金额', prop: 'discountAmount', query: false, type: '', resizable: true},
-    {width: 160, label: '优惠金额', prop: 'discountMoney', query: false, type: '', resizable: true},
-    {width: 160, label: '优惠方式', prop: 'discountType', query: false, type: 'dict', conf: {dict: 'Activity.discountType'}, resizable: true},
-    {width: 160, label: '结束时间', prop: 'endTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDateTime(val)}},
-    {
-      width: 160, label: '设备空闲关机倒计时剩余时间',
-      prop: 'idleRemainTime',
-      query: true,
-      type: 'text',
-      resizable: true
-    },
-    {width: 160, label: '发票状态', prop: 'invoiceStatus', query: false, type: 'dict', conf: {dict: 'Invoice.status'}, resizable: true},
-    {width: 160, label: '会员折扣比例', prop: 'memberDiscount', query: false, type: 'text', resizable: true},
-    {width: 160, label: '开机方式', prop: 'openType', query: false, type: 'dict', conf: {dict: 'Order.openType'}, resizable: true},
-    {width: 160, label: '订单操作剩余操作时间(单位秒)', prop: 'operationRemainTime', query: false, type: 'text', resizable: true},
-    {width: 160, label: '本机订单号', prop: 'orderIdLocal', query: false, type: 'text', resizable: true},
-    {width: 160, label: '订单状态', prop: 'orderStatus', query: false, type: 'dict', conf: {dict: 'Order.status'}, resizable: true},
-    {width: 160, label: '支付状态', prop: 'payStatus', query: true, type: 'dict', conf: {dict: 'Order.pay'}, resizable: true},
-    {width: 160, label: '本次开机的预付金额', prop: 'prepayMoney', query: true, type: '', resizable: true},
-    {width: 160, label: '产品key', prop: 'productKey', query: false, type: 'text', resizable: true},
-    {width: 160, label: '开始时间', prop: 'startTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDate(val)}},
-    {width: 160, label: '站点ID', prop: 'stationId', query: true, type: 'text', resizable: true},
-    {label: '停机原因', prop: 'stopReason', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '优惠金额', prop: 'discountAmount', query: false, type: '', resizable: true},
+    // {width: 160, label: '优惠方式', prop: 'discountType', query: false, type: 'dict', conf: {dict: 'Activity.discountType'}, resizable: true},
+    // {
+    //   width: 160, label: '设备空闲关机倒计时剩余时间',
+    //   prop: 'idleRemainTime',
+    //   query: true,
+    //   type: 'text',
+    //   resizable: true
+    // },
+    // {width: 160, label: '会员折扣比例', prop: 'memberDiscount', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '开机方式', prop: 'openType', query: false, type: 'dict', conf: {dict: 'Order.openType'}, resizable: true},
+    // {width: 160, label: '订单操作剩余操作时间(单位秒)', prop: 'operationRemainTime', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '本机订单号', prop: 'orderIdLocal', query: false, type: 'text', resizable: true},
+    {width: 100, label: '订单状态', prop: 'orderStatus', query: false, type: 'dict', conf: {dict: 'Order.status'}, resizable: true},
+    {width: 100, label: '支付状态', prop: 'payStatus', query: true, type: 'dict', conf: {dict: 'Order.pay'}, resizable: true},
+    {width: 100, label: '发票状态', prop: 'invoiceStatus', query: false, type: 'dict', conf: {dict: 'Invoice.status'}, resizable: true},
+    // {width: 160, label: '本次开机的预付金额', prop: 'prepayMoney', query: true, type: '', resizable: true},
+    // {width: 160, label: '产品key', prop: 'productKey', query: false, type: 'text', resizable: true},
+    // {width: 160, label: '站点ID', prop: 'stationId', query: true, type: 'text', resizable: true},
+    // {label: '停机原因', prop: 'stopReason', query: false, type: 'text', resizable: true},
     {
       width: 160,
       label: '更新时间',
@@ -365,4 +365,4 @@ const handleRowDelete = (row: any) => {
 // defineExpose({
 //     loadData,
 // });
-</script>
+</script>

+ 1 - 1
car-wash-entity/pom.xml

@@ -35,7 +35,7 @@
         <dependency>
             <groupId>com.github.yulichang</groupId>
             <artifactId>mybatis-plus-join-boot-starter</artifactId>
-            <version>1.4.13</version>
+            <version>1.5.2</version>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 5 - 0
car-wash-entity/src/main/java/com/kym/entity/miniapp/WashOrder.java

@@ -55,6 +55,11 @@ public class WashOrder extends BaseEntity {
      */
     private String deviceName;
 
+    /**
+     * 设备编号
+     */
+    private String shortId;
+
     /**
      * 开机方式:button维护按钮,network网络命令,coin投币,card刷卡
      */

+ 4 - 1
car-wash-entity/src/main/java/com/kym/entity/miniapp/queryParams/WashOrderQueryParams.java

@@ -10,8 +10,11 @@ import lombok.Data;
  */
 @Data
 public class WashOrderQueryParams extends PageParams {
+    private String userId;
+    private String mobilePhone;
     private String orderId;
     private String stationId;
     private String shortId;
-    private String userId;
+    private Integer payStatus;
+    private Integer orderStatus;
 }

+ 13 - 0
car-wash-entity/src/main/java/com/kym/entity/miniapp/vo/WashOrderVo.java

@@ -20,8 +20,12 @@ public class WashOrderVo extends BaseEntity {
 
     private Long userId;
 
+    private String mobilePhone;
+
     private String stationId;
 
+    private String stationName;
+
     /**
      * 产品key
      */
@@ -32,6 +36,15 @@ public class WashOrderVo extends BaseEntity {
      */
     private String deviceName;
 
+    /**
+     * 设备编号
+     */
+    private String shortId;
+
+    /**
+     * 关机方式:button维护按钮,network网络命令,no_balance超过预设金额,idle_timeout设备空闲超时,operation_timeout操作超时,card刷卡。注意:为空表示还没有关机,正在使用
+     */
+    private String closeType;
 
     /**
      * 订单号,和开机命令的order_id相同,如果使用按钮快速开机,order_id是空字符串

+ 9 - 2
car-wash-service/src/main/java/com/kym/service/cache/KymCache.java

@@ -4,6 +4,8 @@ import cn.hutool.extra.spring.SpringUtil;
 import com.kym.common.exception.BusinessException;
 import com.kym.common.utils.CommUtil;
 import com.kym.entity.common.RedisKeys;
+import com.kym.entity.miniapp.WashStation;
+import com.kym.service.miniapp.WashStationService;
 import org.springframework.boot.context.event.ApplicationStartedEvent;
 import org.springframework.context.ApplicationListener;
 import org.springframework.data.redis.core.StringRedisTemplate;
@@ -13,6 +15,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
 
 /**
  * @author skyline
@@ -84,7 +87,7 @@ public enum KymCache {
         return KymCacheInjector.redisTemplate.opsForValue().get(RedisKeys.CONNECTOR_ID_TO_STATION_ID + connectorId);
     }
 
-    public void putStationId2Name(Map<String, String> map) {
+    public static void putStationId2Name(Map<String, String> map) {
         map.forEach((k, v) -> KymCacheInjector.redisTemplate.opsForValue().set(RedisKeys.STATION_ID_TO_NAME + k, v));
     }
 
@@ -204,14 +207,18 @@ public enum KymCache {
 
         private static final StringRedisTemplate redisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
 
+        private final WashStationService washStationService;
 
-        private KymCacheInjector() {
+
+        private KymCacheInjector(WashStationService washStationService) {
+            this.washStationService = washStationService;
         }
 
         @Override
         public void onApplicationEvent(ApplicationStartedEvent event) {
             // 将数据库数据缓存到redis
 
+            putStationId2Name(washStationService.list().stream().collect(Collectors.toMap(WashStation::getStationId, WashStation::getStationName)));
         }
     }
 }

+ 22 - 13
car-wash-service/src/main/java/com/kym/service/miniapp/impl/WashOrderServiceImpl.java

@@ -2,6 +2,8 @@ package com.kym.service.miniapp.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
 import com.github.pagehelper.PageHelper;
+import com.github.yulichang.toolkit.JoinWrappers;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.kym.common.exception.BusinessException;
 import com.kym.common.utils.CommUtil;
 import com.kym.common.utils.OrderUtils;
@@ -15,6 +17,7 @@ import com.kym.entity.miniapp.queryParams.WashOrderQueryParams;
 import com.kym.entity.miniapp.vo.WashOrderVo;
 import com.kym.mapper.miniapp.WashOrderMapper;
 import com.kym.service.awoara.AwoaraService;
+import com.kym.service.cache.KymCache;
 import com.kym.service.miniapp.AccountService;
 import com.kym.service.miniapp.WashOrderService;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
@@ -22,6 +25,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * <p>
@@ -83,6 +87,7 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
                 .setStationId(params.getStationId())
                 .setProductKey(params.getProductKey())
                 .setDeviceName(params.getDeviceName())
+                .setShortId(KymCache.INSTANCE.getShortIdByProductKeyAndDeviceName(params.getProductKey(), params.getDeviceName()))
                 .setOpenType(WashOrder.START_CLOSE_TYPE_网络)
                 .setOrderId(orderId)
                 .setOrderIdLocal(createOrder.getOrder_id_local())
@@ -155,19 +160,23 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
 
     //region 管理后台
     @Override
-    public PageBean<WashOrderVo> list(WashOrderQueryParams query) {
-        PageHelper.startPage(query.getPageNum(), query.getPageSize());
-        var res = lambdaQuery()
-                .eq(CommUtil.isNotEmptyAndNull(query.getStationId()), WashOrder::getStationId, query.getStationId())
-                .like(CommUtil.isNotEmptyAndNull(query.getOrderId()), WashOrder::getOrderId, query.getOrderId())
-                .orderByDesc(WashOrder::getId)
-                .list();
-        var voList = res.stream().map(order -> {
-            var vo = new WashOrderVo();
-            BeanUtils.copyProperties(order, vo);
-            return vo;
-        }).toList();
-        return new PageBean<>(voList);
+    public PageBean<WashOrderVo> list(WashOrderQueryParams params) {
+        PageHelper.startPage(params.getPageNum(), params.getPageSize());
+        MPJLambdaWrapper<WashOrder> wrapper = JoinWrappers.lambda(WashOrder.class)
+                .selectAsClass(WashOrder.class, WashOrderVo.class)
+                .selectAs(User::getMobilePhone, WashOrderVo::getMobilePhone)
+                .leftJoin(User.class, User::getId,WashOrder::getUserId)
+                .eq(CommUtil.isNotEmptyAndNull(params.getUserId()), WashOrder::getUserId, params.getUserId())
+                .eq(CommUtil.isNotEmptyAndNull(params.getMobilePhone()), User::getMobilePhone, params.getMobilePhone())
+                .eq(CommUtil.isNotEmptyAndNull(params.getOrderStatus()), WashOrder::getOrderStatus, params.getOrderStatus())
+                .eq(CommUtil.isNotEmptyAndNull(params.getPayStatus()), WashOrder::getPayStatus, params.getPayStatus())
+                .orderByDesc(WashOrder::getId);
+        //连表查询 返回自定义ResultType
+        List<WashOrderVo> list = selectJoinList(WashOrderVo.class, wrapper);
+        list.forEach(item -> {
+            item.setStationName(KymCache.INSTANCE.getStationNameById(item.getStationId()));
+        });
+        return new PageBean<>(list);
     }
 
     @Override