Prechádzať zdrojové kódy

feat: 订单列表新增新用户订单标记,注册当天的订单打上「新用户」标签

skyline 2 týždňov pred
rodič
commit
b33eeb42af

+ 13 - 0
admin-h5/src/pages/order/list.vue

@@ -70,6 +70,7 @@
             <text class="info-label">用户手机号</text>
             <view class="info-value-row">
               <text class="info-value">{{ order.mobilePhone || '匿名用户' }}</text>
+              <text v-if="order.newUser" class="new-user-tag">新用户</text>
               <AppIcon v-if="order.mobilePhone" name="copy" :size="28" color="#C6171E" class="copy-icon" @click.stop="copyText(order.mobilePhone)" />
             </view>
           </view>
@@ -557,6 +558,18 @@ const onPullDownRefresh = () => {
   gap: 8rpx;
 }
 
+/* 新用户订单标签 */
+.new-user-tag {
+  font-size: 20rpx;
+  color: #C6171E;
+  background-color: rgba(198, 23, 30, 0.1);
+  border-radius: 200rpx;
+  padding: 2rpx 16rpx;
+  font-weight: 500;
+  white-space: nowrap;
+  flex-shrink: 0;
+}
+
 /* 金额信息 */
 .order-amount-info {
   display: flex;

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

@@ -28,6 +28,11 @@
   margin-left: 20px;
 }
 
+.new-user-tag {
+  margin-left: 6px;
+  flex-shrink: 0;
+}
+
 .el-table {
   &:deep(.el-table__body-wrapper) {
     width: 100% !important;
@@ -120,6 +125,19 @@
                 </div>
               </div>
             </template>
+            <template v-else-if="field.prop==='mobilePhone'">
+              <div class="flex-align-items-center">
+                <span>{{ row.mobilePhone }}</span>
+                <el-tag
+                    v-if="row.newUser"
+                    class="new-user-tag"
+                    type="success"
+                    size="small"
+                    effect="light">
+                  新用户
+                </el-tag>
+              </div>
+            </template>
             <template v-else-if="field.prop==='discountType'">
               <ext-d-label type="Activity.discountType" :model-value="row[field.prop]"></ext-d-label>
             </template>
@@ -230,7 +248,7 @@ const state = reactive({
     {label: '消费站点', prop: 'stationId', width: 140, query: true, type: 'select', resizable: true, conf: {url: 'washStation/list', valueKey: 'stationId', labelKey: 'stationName'}},
     {label: '归属站点', prop: 'userStationId', width: 140, query: true, type: 'select', resizable: true, conf: {url: 'washStation/list', valueKey: 'stationId', labelKey: 'stationName'}},
     {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: 150, label: '用户手机号', prop: 'mobilePhone', query: true, type: 'text', fixed: 'left'},
     {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)}},

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

@@ -1,6 +1,7 @@
 package com.kym.entity.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.kym.entity.BaseEntity;
 import com.kym.entity.awoara.Detail;
 import lombok.Data;
@@ -165,4 +166,15 @@ public class WashOrderVo extends BaseEntity {
      * 是否跨店:0-否,1-是
      */
     private Boolean isCross;
+
+    /**
+     * 是否新用户订单:订单日期与用户注册日期为同一天
+     */
+    private Boolean newUser;
+
+    /**
+     * 用户注册时间,仅用于判定新用户订单,不返回前端
+     */
+    @JsonIgnore
+    private LocalDateTime userCreateTime;
 }

+ 15 - 0
car-wash-service/src/main/java/com/kym/service/impl/WashOrderServiceImpl.java

@@ -377,6 +377,7 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
         MPJLambdaWrapper<WashOrder> wrapper = JoinWrappers.lambda(WashOrder.class)
                 .selectAsClass(WashOrder.class, WashOrderVo.class)
                 .selectAs(User::getMobilePhone, WashOrderVo::getMobilePhone)
+                .selectAs(User::getCreateTime, WashOrderVo::getUserCreateTime)
                 .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())
@@ -389,10 +390,24 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
             item.setStationName(KymCache.INSTANCE.getStationNameById(item.getStationId()));
             item.setUserStationId(KymCache.INSTANCE.getUserStationId(item.getUserId()));
             item.setUserStationName(KymCache.INSTANCE.getStationNameById(item.getUserStationId()));
+            item.setNewUser(isNewUserOrder(item));
         });
         return new PageBean<>(list);
     }
 
+    /**
+     * 是否新用户订单:订单开始时间(为空时取订单创建时间)与用户注册时间为同一天
+     *
+     * @param vo 订单视图对象
+     * @return 是否新用户订单
+     */
+    private boolean isNewUserOrder(WashOrderVo vo) {
+        LocalDateTime orderTime = vo.getStartTime() != null ? vo.getStartTime() : vo.getCreateTime();
+        LocalDateTime registerTime = vo.getUserCreateTime();
+        return orderTime != null && registerTime != null
+                && orderTime.toLocalDate().isEqual(registerTime.toLocalDate());
+    }
+
     /**
      * 获取订单详情
      * 根据订单号查询,而不是主键ID