diff --git a/src/api/ab98/balanceLog.ts b/src/api/ab98/balanceLog.ts new file mode 100644 index 0000000..c0a9f49 --- /dev/null +++ b/src/api/ab98/balanceLog.ts @@ -0,0 +1,144 @@ +import { http } from "@/utils/http"; + +export interface UserBalanceLog { + /** 主键ID */ + logId: number; + /** 用户余额ID */ + userBalanceId: number; + /** 变更类型(1-消费,2-审批归还,3-系统调整) */ + changeType: number; + /** 变更金额(分) */ + changeAmount: number; + /** 变更前已用余额(分) */ + useBalanceBefore: number; + /** 变更后已用余额(分) */ + useBalanceAfter: number; + /** 关联订单ID */ + orderId?: number; + /** 关联审批ID */ + approvalId?: number; + /** 关联订单商品ID */ + orderGoodsId?: number; + /** 创建者ID */ + creatorId: number; + /** 创建时间 */ + createTime: string; + /** 更新者ID */ + updaterId: number; + /** 更新时间 */ + updateTime: string; + /** 删除标志 */ + deleted: boolean; +} + +export interface UserBalanceLogListParams { + pageNum?: number; + pageSize?: number; + userBalanceId?: number; + changeType?: number; + orderId?: number; + approvalId?: number; + orderGoodsId?: number; + creatorId?: number; +} + +// 新增用户余额变更日志请求参数 +export interface AddUserBalanceLogCommand { + /** 用户余额ID */ + userBalanceId: number; + /** 变更类型(1-消费,2-审批归还,3-系统调整) */ + changeType: number; + /** 变更金额(分) */ + changeAmount: number; + /** 变更前已用余额(分) */ + useBalanceBefore: number; + /** 变更后已用余额(分) */ + useBalanceAfter: number; + /** 关联订单ID */ + orderId?: number; + /** 关联审批ID */ + approvalId?: number; + /** 关联订单商品ID */ + orderGoodsId?: number; +} + +// 修改用户余额变更日志请求参数 +export interface UpdateUserBalanceLogCommand extends AddUserBalanceLogCommand { + /** 主键ID */ + logId: number; +} + +// 根据用户余额ID查询参数 +export interface QueryByUserBalanceIdParams { + userBalanceId: number; +} + +// 根据订单ID查询参数 +export interface QueryByOrderIdParams { + orderId: number; +} + +// 根据审批ID查询参数 +export interface QueryByApprovalIdParams { + approvalId: number; +} + +// 根据订单商品ID查询参数 +export interface QueryByOrderGoodsIdParams { + orderGoodsId: number; +} + +// 根据变更类型查询参数 +export interface QueryByChangeTypeParams { + changeType: number; +} + +// 批量删除参数 +export interface BatchDeleteParams { + ids: number[]; +} + +// 用户余额变更日志相关API +export const getUserBalanceLogListApi = (params: UserBalanceLogListParams) => { + return http.request>>("get", "/ab98/balance-log", { params }); +}; + +export const getUserBalanceLogDetailApi = (id: number) => { + return http.request>("get", `/ab98/balance-log/${id}`); +}; + +export const getUserBalanceLogByUserBalanceIdApi = (userBalanceId: number) => { + return http.request>("get", `/ab98/balance-log/byUserBalanceId/${userBalanceId}`); +}; + +export const getUserBalanceLogByOrderIdApi = (orderId: number) => { + return http.request>("get", `/ab98/balance-log/byOrderId/${orderId}`); +}; + +export const getUserBalanceLogByApprovalIdApi = (approvalId: number) => { + return http.request>("get", `/ab98/balance-log/byApprovalId/${approvalId}`); +}; + +export const getUserBalanceLogByOrderGoodsIdApi = (orderGoodsId: number) => { + return http.request>("get", `/ab98/balance-log/byOrderGoodsId/${orderGoodsId}`); +}; + +export const getUserBalanceLogByChangeTypeApi = (changeType: number) => { + return http.request>("get", `/ab98/balance-log/byChangeType/${changeType}`); +}; + +export const addUserBalanceLogApi = (data: AddUserBalanceLogCommand) => { + return http.request>("post", "/ab98/balance-log", { data }); +}; + +export const updateUserBalanceLogApi = (id: number, data: UpdateUserBalanceLogCommand) => { + return http.request>("put", `/ab98/balance-log/${id}`, { data }); +}; + +export const deleteUserBalanceLogApi = (id: number) => { + return http.request>("delete", `/ab98/balance-log/${id}`); +}; + +export const batchDeleteUserBalanceLogApi = (ids: number[]) => { + return http.request>("delete", `/ab98/balance-log/batch/${ids.join(',')}`); +}; \ No newline at end of file diff --git a/src/views/user/ab98/detail.vue b/src/views/user/ab98/detail.vue index d1f2eeb..8835ae0 100644 --- a/src/views/user/ab98/detail.vue +++ b/src/views/user/ab98/detail.vue @@ -11,6 +11,7 @@ import { PureTableBar } from "@/components/RePureTableBar"; import { useWxStore } from "@/store/modules/wx"; import { formatFenToYuan } from "@/utils/currency"; import BalanceEditModal from "./BalanceEditModal.vue"; +import { getUserBalanceLogListApi, type UserBalanceLog, type UserBalanceLogListParams } from "@/api/ab98/balanceLog"; defineOptions({ name: "Ab98UserDetail" @@ -48,6 +49,15 @@ const pagination = ref({ const orderLoading = ref(false); const activeTab = ref('basic'); +// 借呗记录 +const balanceLogRecords = ref([]); +const balanceLogPagination = ref({ + pageSize: 10, + currentPage: 1, + total: 0 +}); +const balanceLogLoading = ref(false); + const openid = computed(() => { if (userType.value === 'ab98') { return (userInfo.value as Ab98UserDetailDTO).wxUserList?.[0]?.openid || ''; @@ -80,9 +90,34 @@ async function fetchOrders() { } } +async function fetchBalanceLogs() { + try { + if (userType.value !== 'ab98') return; + const userBalanceId = (userInfo.value as Ab98UserDetailDTO).userBalanceEntity?.userBalanceId; + if (!userBalanceId) { + balanceLogRecords.value = []; + return; + } + + balanceLogLoading.value = true; + const params: UserBalanceLogListParams = { + pageSize: balanceLogPagination.value.pageSize, + pageNum: balanceLogPagination.value.currentPage, + userBalanceId + }; + const { data } = await getUserBalanceLogListApi(params); + balanceLogRecords.value = data.rows; + balanceLogPagination.value.total = data.total; + } finally { + balanceLogLoading.value = false; + } +} + watch(activeTab, (newVal) => { if (newVal === 'orders') { fetchOrders(); + } else if (newVal === 'balanceLog') { + fetchBalanceLogs(); } }); @@ -203,14 +238,16 @@ async function handleShowAddTagDialog() {
@@ -236,6 +274,7 @@ async function handleShowAddTagDialog() { +
@@ -245,13 +284,16 @@ async function handleShowAddTagDialog() { {{ (userInfo as Ab98UserDetailDTO).ab98UserId }} {{ openid }} {{ userInfo.createTime }} - {{ formatFenToYuan((userInfo as Ab98UserDetailDTO).balanceLimit) }} + {{ formatFenToYuan((userInfo as + Ab98UserDetailDTO).balanceLimit) }} 修改 - {{ formatFenToYuan((userInfo as Ab98UserDetailDTO).balance) }} - {{ formatFenToYuan((userInfo as Ab98UserDetailDTO).useBalance) }} + {{ formatFenToYuan((userInfo as Ab98UserDetailDTO).balance) + }} + {{ formatFenToYuan((userInfo as Ab98UserDetailDTO).useBalance) + }}
@@ -270,8 +312,10 @@ async function handleShowAddTagDialog() { {{ (userInfo as WxUserDTO).wxUserId }} {{ openid }} {{ userInfo.createTime }} - {{ formatFenToYuan((userInfo as WxUserDTO).wxBalance) }} - {{ (userInfo as WxUserDTO).remark || '无' }} + {{ formatFenToYuan((userInfo as WxUserDTO).wxBalance) + }} + {{ (userInfo as WxUserDTO).remark || '无' + }} @@ -279,61 +323,93 @@ async function handleShowAddTagDialog() {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
@@ -349,7 +425,8 @@ async function handleShowAddTagDialog() { 确定 - +
@@ -468,5 +545,9 @@ async function handleShowAddTagDialog() { color: #303133; } } + + .el-pagination { + margin-top: 10px; + } } \ No newline at end of file