Browse Source

会员详情,查询钱包信息

owen 1 year ago
parent
commit
675f3df5cb
3 changed files with 83 additions and 23 deletions
  1. 22 0
      src/api/pay/wallet/index.ts
  2. 31 18
      src/utils/constants.ts
  3. 30 5
      src/views/member/user/detail/UserAccountInfo.vue

+ 22 - 0
src/api/pay/wallet/index.ts

@@ -0,0 +1,22 @@
+import request from '@/config/axios'
+
+/** 用户钱包查询参数 */
+export interface PayWalletUserReqVO {
+  userId: number
+  userType: number
+}
+/** 钱包 VO */
+export interface WalletVO {
+  id: number
+  userId: number
+  userType: number
+  balance: number
+  totalExpense: number
+  totalRecharge: number
+  freezePrice: number
+}
+
+/** 查询用户钱包详情 */
+export const getUserWallet = async (params: PayWalletUserReqVO) => {
+  return await request.get<WalletVO>({ url: `/pay/wallet/user-wallet`, params })
+}

+ 31 - 18
src/utils/constants.ts

@@ -4,12 +4,20 @@
  * 枚举类
  */
 
+// ========== COMMON 模块 ==========
 // 全局通用状态枚举
 export const CommonStatusEnum = {
   ENABLE: 0, // 开启
   DISABLE: 1 // 禁用
 }
 
+// 全局用户类型枚举
+export const UserTypeEnum = {
+  MEMBER: 1, // 会员
+  ADMIN: 2 // 管理员
+}
+
+// ========== SYSTEM 模块 ==========
 /**
  * 菜单的类型枚举
  */
@@ -38,6 +46,25 @@ export const SystemDataScopeEnum = {
   DEPT_SELF: 5 // 仅本人数据权限
 }
 
+/**
+ * 用户的社交平台的类型枚举
+ */
+export const SystemUserSocialTypeEnum = {
+  DINGTALK: {
+    title: '钉钉',
+    type: 20,
+    source: 'dingtalk',
+    img: 'https://s1.ax1x.com/2022/05/22/OzMDRs.png'
+  },
+  WECHAT_ENTERPRISE: {
+    title: '企业微信',
+    type: 30,
+    source: 'wechat_enterprise',
+    img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png'
+  }
+}
+
+// ========== INFRA 模块 ==========
 /**
  * 代码生成模板类型
  */
@@ -65,24 +92,7 @@ export const InfraApiErrorLogProcessStatusEnum = {
   IGNORE: 2 // 已忽略
 }
 
-/**
- * 用户的社交平台的类型枚举
- */
-export const SystemUserSocialTypeEnum = {
-  DINGTALK: {
-    title: '钉钉',
-    type: 20,
-    source: 'dingtalk',
-    img: 'https://s1.ax1x.com/2022/05/22/OzMDRs.png'
-  },
-  WECHAT_ENTERPRISE: {
-    title: '企业微信',
-    type: 30,
-    source: 'wechat_enterprise',
-    img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png'
-  }
-}
-
+// ========== PAY 模块 ==========
 /**
  * 支付渠道枚举
  */
@@ -177,6 +187,7 @@ export const PayOrderStatusEnum = {
   }
 }
 
+// ========== MALL - 商品模块 ==========
 /**
  * 商品 SPU 状态
  */
@@ -195,6 +206,7 @@ export const ProductSpuStatusEnum = {
   }
 }
 
+// ========== MALL - 营销模块 ==========
 /**
  * 优惠劵模板的有限期类型的枚举
  */
@@ -273,6 +285,7 @@ export const PromotionDiscountTypeEnum = {
   }
 }
 
+// ========== MALL - 交易模块 ==========
 /**
  * 分销关系绑定模式枚举
  */

+ 30 - 5
src/views/member/user/detail/UserAccountInfo.vue

@@ -24,31 +24,56 @@
       </template>
       {{ user.totalPoint || 0 }}
     </el-descriptions-item>
-    <!-- TODO @疯狂:从 wallet 读取下对应字段 -->
     <el-descriptions-item>
       <template #label>
         <descriptions-item-label label=" 当前余额 " icon="svg-icon:member_balance" />
       </template>
-      {{ 0 }}
+      {{ wallet.balance || 0 }}
     </el-descriptions-item>
     <el-descriptions-item>
       <template #label>
         <descriptions-item-label label=" 支出金额 " icon="svg-icon:member_expenditure_balance" />
       </template>
-      {{ 0 }}
+      {{ wallet.totalExpense || 0 }}
     </el-descriptions-item>
     <el-descriptions-item>
       <template #label>
         <descriptions-item-label label=" 充值金额 " icon="svg-icon:member_recharge_balance" />
       </template>
-      {{ 0 }}
+      {{ wallet.totalRecharge || 0 }}
     </el-descriptions-item>
   </el-descriptions>
 </template>
 <script setup lang="ts">
 import { DescriptionsItemLabel } from '@/components/Descriptions'
 import * as UserApi from '@/api/member/user'
-const { user } = defineProps<{ user: UserApi.UserVO }>()
+import * as WalletApi from '@/api/pay/wallet'
+import { UserTypeEnum } from '@/utils/constants'
+
+const props = defineProps<{ user: UserApi.UserVO }>() // 用户信息
+const WALLET_INIT_DATA = {
+  balance: 0,
+  totalExpense: 0,
+  totalRecharge: 0
+} as WalletApi.WalletVO // 钱包初始化数据
+const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
+
+/** 查询用户钱包信息 */
+const getUserWallet = async () => {
+  if (!props.user.id) {
+    wallet.value = WALLET_INIT_DATA
+    return
+  }
+  const params = { userId: props.user.id, userType: UserTypeEnum.MEMBER }
+  wallet.value = (await WalletApi.getUserWallet(params)) || WALLET_INIT_DATA
+}
+
+/** 监听用户编号变化 */
+watch(
+  () => props.user.id,
+  () => getUserWallet(),
+  { immediate: true }
+)
 </script>
 <style scoped lang="scss">
 .cell-item {