فهرست منبع

加入积分明细

yjwang 20 ساعت پیش
والد
کامیت
5705242301

+ 9 - 0
src/api/hisStore/userIntegralLogs.js

@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+// 按订单 ID 查询积分明细列表
+export function getIntegralLogsByOrderId(orderId) {
+  return request({
+    url: '/store/userIntegralLogs/getByOrderId/' + orderId,
+    method: 'get'
+  })
+}

+ 77 - 0
src/views/hisStore/components/productAfterSalesOrder.vue

@@ -213,6 +213,35 @@
             </template>
           </el-table-column>
         </el-table>
+
+        <div style="margin-top: 20px">
+          <span class="font-small">积分明细</span>
+        </div>
+        <el-table
+          border
+          :data="integralLogs"
+          size="small"
+          style="width: 100%;margin-top: 20px"
+          empty-text="该订单暂无积分变动记录">
+          <el-table-column label="类型" align="center" min-width="160">
+            <template slot-scope="scope">
+              <el-tag size="mini" :type="scope.row.integral >= 0 ? 'success' : 'danger'">
+                {{ formatLogType(scope.row.logType) }}
+              </el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column label="积分变动" align="center" width="120">
+            <template slot-scope="scope">
+              <span :style="{ color: scope.row.integral >= 0 ? '#67C23A' : '#F56C6C', fontWeight: 'bold' }">
+                {{ scope.row.integral >= 0 ? '+' + scope.row.integral : scope.row.integral }}
+              </span>
+            </template>
+          </el-table-column>
+          <el-table-column label="变动后余额" align="center" prop="balance" width="120" />
+          <el-table-column label="业务订单ID" align="center" prop="businessId" width="140" />
+          <el-table-column label="时间" align="center" prop="createTime" width="160" />
+          <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
+        </el-table>
       </el-card>
 
     </div>
@@ -262,6 +291,7 @@
 <script>
 import {getStoreAfterSales,cancel,refund,audit,updateStoreAfterSales } from "@/api/hisStore/storeAfterSales";
 import { getOrderPromotionDetail } from "@/api/hisStore/storePromotion";
+import { getIntegralLogsByOrderId } from "@/api/hisStore/userIntegralLogs";
 
 import productOrder from "./productOrder";
 export default {
@@ -296,6 +326,10 @@ export default {
       },
       order:null,
       orderPromotion: null,
+      // 积分明细列表
+      integralLogs: [],
+      // 积分日志类型字典(字典 + 本地兜底,与 FsUserIntegralLogTypeEnum 对齐)
+      integralLogTypeOptions: [],
       user:null,
       serviceTypeOptions:[],
       salesStatusOptions:[],
@@ -342,6 +376,10 @@ export default {
      this.getDicts("store_after_sales_service_type").then((response) => {
         this.serviceTypeOptions = response.data;
     });
+    // 加载积分日志类型字典(合并本地兜底,确保所有已知 logType 都有中文名称)
+    this.getDicts("sys_integral_log_type").then((response) => {
+      this.integralLogTypeOptions = this.mergeLogTypeOptions(response.data || []);
+    });
   },
   methods: {
     formatPromotionDiscount(amount) {
@@ -433,6 +471,9 @@ export default {
             this.order=response.order;
             if (this.order && this.order.id) {
               this.loadOrderPromotion(this.order.id);
+              this.loadIntegralLogs(this.order.id);
+            } else {
+              this.integralLogs = [];
             }
         });
      },
@@ -442,6 +483,42 @@ export default {
        }).catch(() => {
          this.orderPromotion = null;
        });
+     },
+     // 加载积分明细
+     loadIntegralLogs(orderId) {
+       getIntegralLogsByOrderId(orderId).then(response => {
+         this.integralLogs = response.data || [];
+       }).catch(() => {
+         this.integralLogs = [];
+       });
+     },
+     /** 合并字典与本地兜底类型,确保所有已知 logType 都有对应名称 */
+     mergeLogTypeOptions(dictOptions) {
+       const localMap = {
+         1: '签到获得积分', 2: '消费获得积分', 3: '分享获得积分', 4: '退款扣除积分',
+         5: '购买积分商品', 6: '平台取消售后', 7: '积分过期', 8: '螳螂同步积分',
+         9: '购买课程小节扣除', 10: '观看课程获取积分', 11: '新用户完善就诊人获得积分',
+         12: '新用户填写收货地址获取积分', 13: '浏览商品获得积分', 14: '浏览视频获得积分',
+         15: '首次下单疗法获得积分', 16: '点播看课获得积分', 17: '点播答题获得积分',
+         18: '邀请新用户获取积分', 19: '填写邀请码获取积分', 20: '首次完成手机号绑定注册',
+         21: '首次完成专家咨询', 22: '首次完成积分商城下单', 23: '管理员添加',
+         24: '付费课程订阅', 25: '下单使用积分抵扣', 26: '取消订单退回积分', 27: '退款订单退回积分'
+       };
+       const result = [...dictOptions];
+       const existValues = new Set(dictOptions.map(o => Number(o.dictValue)));
+       Object.keys(localMap).forEach(key => {
+         const val = Number(key);
+         if (!existValues.has(val)) {
+           result.push({ dictValue: String(val), dictLabel: localMap[val] });
+         }
+       });
+       return result;
+     },
+     /** 将 logType 数值转换为中文名称 */
+     formatLogType(logType) {
+       if (logType == null) return '-';
+       const item = this.integralLogTypeOptions.find(o => Number(o.dictValue) === Number(logType));
+       return item ? item.dictLabel : ('类型' + logType);
      }
   }
 };

+ 75 - 0
src/views/hisStore/components/productOrder.vue

@@ -305,6 +305,35 @@
             </template>
           </el-table-column>
         </el-table>
+
+        <div style="margin-top: 20px">
+          <span class="font-small">积分明细</span>
+        </div>
+        <el-table
+          border
+          :data="integralLogs"
+          size="small"
+          style="width: 100%;margin-top: 20px"
+          empty-text="该订单暂无积分变动记录">
+          <el-table-column label="类型" align="center" min-width="160">
+            <template slot-scope="scope">
+              <el-tag size="mini" :type="scope.row.integral >= 0 ? 'success' : 'danger'">
+                {{ formatLogType(scope.row.logType) }}
+              </el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column label="积分变动" align="center" width="120">
+            <template slot-scope="scope">
+              <span :style="{ color: scope.row.integral >= 0 ? '#67C23A' : '#F56C6C', fontWeight: 'bold' }">
+                {{ scope.row.integral >= 0 ? '+' + scope.row.integral : scope.row.integral }}
+              </span>
+            </template>
+          </el-table-column>
+          <el-table-column label="变动后余额" align="center" prop="balance" width="120" />
+          <el-table-column label="业务订单ID" align="center" prop="businessId" width="140" />
+          <el-table-column label="时间" align="center" prop="createTime" width="160" />
+          <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
+        </el-table>
       </el-card>
     </div>
     <el-dialog :title="edit.title" :visible.sync="edit.open" width="600px" append-to-body>
@@ -510,6 +539,7 @@ import ImageUpload from '@/components/ImageUpload'
 import Material from '@/components/Material'
 import {bindCustomer,getExpress, listStoreOrder, getStoreOrder, delStoreOrder, addStoreOrder, updateStoreOrder, exportStoreOrder,uploadCredentials, getStoreOrderAddress,getUserPhone} from "@/api/hisStore/storeOrder";
 import { getOrderPromotionDetail } from "@/api/hisStore/storePromotion";
+import { getIntegralLogsByOrderId } from "@/api/hisStore/userIntegralLogs";
 import {getCitys} from "@/api/hisStore/city";
 import customerDetails from '../../crm/components/customerDetails.vue';
 import addSms from '../../crm/components/addSms.vue';
@@ -619,6 +649,10 @@ export default {
       payments:[],
       auditLogs: [],
       orderPromotion: null,
+      // 积分明细列表
+      integralLogs: [],
+      // 积分日志类型字典(字典 + 本地兜底,与 FsUserIntegralLogTypeEnum 对齐)
+      integralLogTypeOptions: [],
     };
   },
   created() {
@@ -637,6 +671,10 @@ export default {
     this.getDicts("store_order_create_type").then((response) => {
       this.createTypeOptions = response.data;
     });
+    // 加载积分日志类型字典(合并本地兜底,确保所有已知 logType 都有中文名称)
+    this.getDicts("sys_integral_log_type").then((response) => {
+      this.integralLogTypeOptions = this.mergeLogTypeOptions(response.data || []);
+    });
     getTcmScheduleList().then(response => {
       this.scheduleOptions = response.data;
     });
@@ -889,6 +927,7 @@ export default {
             this.customerInfo=response.customer;
             this.auditLogs = response.auditLogs;
             this.loadOrderPromotion(orderId);
+            this.loadIntegralLogs(orderId);
         });
      },
      loadOrderPromotion(orderId) {
@@ -897,6 +936,42 @@ export default {
        }).catch(() => {
          this.orderPromotion = null;
        });
+     },
+     // 加载积分明细
+     loadIntegralLogs(orderId) {
+       getIntegralLogsByOrderId(orderId).then(response => {
+         this.integralLogs = response.data || [];
+       }).catch(() => {
+         this.integralLogs = [];
+       });
+     },
+     /** 合并字典与本地兜底类型,确保所有已知 logType 都有对应名称 */
+     mergeLogTypeOptions(dictOptions) {
+       const localMap = {
+         1: '签到获得积分', 2: '消费获得积分', 3: '分享获得积分', 4: '退款扣除积分',
+         5: '购买积分商品', 6: '平台取消售后', 7: '积分过期', 8: '螳螂同步积分',
+         9: '购买课程小节扣除', 10: '观看课程获取积分', 11: '新用户完善就诊人获得积分',
+         12: '新用户填写收货地址获取积分', 13: '浏览商品获得积分', 14: '浏览视频获得积分',
+         15: '首次下单疗法获得积分', 16: '点播看课获得积分', 17: '点播答题获得积分',
+         18: '邀请新用户获取积分', 19: '填写邀请码获取积分', 20: '首次完成手机号绑定注册',
+         21: '首次完成专家咨询', 22: '首次完成积分商城下单', 23: '管理员添加',
+         24: '付费课程订阅', 25: '下单使用积分抵扣', 26: '取消订单退回积分', 27: '退款订单退回积分'
+       };
+       const result = [...dictOptions];
+       const existValues = new Set(dictOptions.map(o => Number(o.dictValue)));
+       Object.keys(localMap).forEach(key => {
+         const val = Number(key);
+         if (!existValues.has(val)) {
+           result.push({ dictValue: String(val), dictLabel: localMap[val] });
+         }
+       });
+       return result;
+     },
+     /** 将 logType 数值转换为中文名称 */
+     formatLogType(logType) {
+       if (logType == null) return '-';
+       const item = this.integralLogTypeOptions.find(o => Number(o.dictValue) === Number(logType));
+       return item ? item.dictLabel : ('类型' + logType);
      }
   }
 };