新增:优惠券、积分明细
This commit is contained in:
113
src/api/shop/shopGoodsReview/model/index.ts
Normal file
113
src/api/shop/shopGoodsReview/model/index.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
|
||||
/**
|
||||
* 商品评价
|
||||
*/
|
||||
export interface ShopGoodsReview {
|
||||
// 评价ID
|
||||
reviewId?: number;
|
||||
// 商品ID
|
||||
goodsId?: number;
|
||||
// 订单ID
|
||||
orderId?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 用户昵称
|
||||
nickname?: string;
|
||||
// 用户头像
|
||||
avatar?: string;
|
||||
// 评价内容
|
||||
content?: string;
|
||||
// 评分 1-5星
|
||||
rating?: number;
|
||||
// 评价图片,JSON数组格式
|
||||
images?: string;
|
||||
// 是否匿名评价
|
||||
isAnonymous?: boolean;
|
||||
// 商家回复
|
||||
reply?: string;
|
||||
// 商家回复时间
|
||||
replyTime?: string;
|
||||
// 评价状态 0待审核 1已通过 2已拒绝
|
||||
status?: number;
|
||||
// 是否置顶
|
||||
isTop?: boolean;
|
||||
// 点赞数
|
||||
likeCount?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 更新时间
|
||||
updateTime?: string;
|
||||
// 商品信息
|
||||
goodsName?: string;
|
||||
goodsImage?: string;
|
||||
goodsPrice?: string;
|
||||
// SKU信息
|
||||
skuId?: number;
|
||||
specInfo?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评价统计
|
||||
*/
|
||||
export interface ReviewStats {
|
||||
// 总评价数
|
||||
totalCount: number;
|
||||
// 好评数
|
||||
goodCount: number;
|
||||
// 中评数
|
||||
mediumCount: number;
|
||||
// 差评数
|
||||
badCount: number;
|
||||
// 好评率
|
||||
goodRate: number;
|
||||
// 平均评分
|
||||
avgRating: number;
|
||||
// 各星级统计
|
||||
ratingStats: {
|
||||
[key: number]: number; // 星级 -> 数量
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 评价查询参数
|
||||
*/
|
||||
export interface ShopGoodsReviewParam extends PageParam {
|
||||
// 商品ID
|
||||
goodsId?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 订单ID
|
||||
orderId?: number;
|
||||
// 评分筛选
|
||||
rating?: number;
|
||||
// 状态筛选
|
||||
status?: number;
|
||||
// 是否有图片
|
||||
hasImages?: boolean;
|
||||
// 排序方式 time:时间 rating:评分 like:点赞数
|
||||
sortBy?: string;
|
||||
// 排序方向 asc:升序 desc:降序
|
||||
sortOrder?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交评价请求
|
||||
*/
|
||||
export interface SubmitReviewRequest {
|
||||
// 商品ID
|
||||
goodsId: number;
|
||||
// 订单ID
|
||||
orderId: number;
|
||||
// 评价内容
|
||||
content: string;
|
||||
// 评分
|
||||
rating: number;
|
||||
// 评价图片
|
||||
images?: string[];
|
||||
// 是否匿名
|
||||
isAnonymous?: boolean;
|
||||
// SKU信息
|
||||
skuId?: number;
|
||||
specInfo?: string;
|
||||
}
|
||||
102
src/api/user/balance-log/index.ts
Normal file
102
src/api/user/balance-log/index.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { UserBalanceLog, UserBalanceLogParam } from './model';
|
||||
import {SERVER_API_URL} from "@/utils/server";
|
||||
|
||||
/**
|
||||
* 分页查询余额明细
|
||||
*/
|
||||
export async function pageUserBalanceLog(params: UserBalanceLogParam) {
|
||||
const res = await request.get<ApiResult<PageResult<UserBalanceLog>>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log/page',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询余额明细列表
|
||||
*/
|
||||
export async function listUserBalanceLog(params?: UserBalanceLogParam) {
|
||||
const res = await request.get<ApiResult<UserBalanceLog[]>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log',
|
||||
params
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询余额明细
|
||||
*/
|
||||
export async function getUserBalanceLog(id: number) {
|
||||
const res = await request.get<ApiResult<UserBalanceLog>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log/' + id
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加余额明细
|
||||
*/
|
||||
export async function addUserBalanceLog(data: UserBalanceLog) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改余额明细
|
||||
*/
|
||||
export async function updateUserBalanceLog(data: UserBalanceLog) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除余额明细
|
||||
*/
|
||||
export async function removeUserBalanceLog(id?: number) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log/' + id
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除余额明细
|
||||
*/
|
||||
export async function removeUserBalanceLogs(data: (number | undefined)[]) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/sys/user-balance-log/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
31
src/api/user/balance-log/model/index.ts
Normal file
31
src/api/user/balance-log/model/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
|
||||
/**
|
||||
* 余额明细
|
||||
*/
|
||||
export interface UserBalanceLog {
|
||||
logId?: number;
|
||||
userId?: number;
|
||||
scene?: number;
|
||||
money?: string;
|
||||
describe?: string;
|
||||
remark?: string;
|
||||
sortNumber?: number;
|
||||
comments?: string;
|
||||
status?: number;
|
||||
deleted?: number;
|
||||
tenantId?: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户搜索条件
|
||||
*/
|
||||
export interface UserBalanceLogParam extends PageParam {
|
||||
logId?: number;
|
||||
userId?: number;
|
||||
scene?: number;
|
||||
createTimeStart?: string;
|
||||
createTimeEnd?: string;
|
||||
}
|
||||
78
src/api/user/coupon/index.ts
Normal file
78
src/api/user/coupon/index.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { UserCoupon, UserCouponParam } from './model';
|
||||
import {SERVER_API_URL} from "@/utils/server";
|
||||
|
||||
/**
|
||||
* 分页查询用户优惠券
|
||||
*/
|
||||
export async function pageUserCoupon(params: UserCouponParam) {
|
||||
const res = await request.get<ApiResult<PageResult<UserCoupon>>>(
|
||||
SERVER_API_URL + '/sys/user-coupon/page',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户优惠券列表
|
||||
*/
|
||||
export async function listUserCoupon(params?: UserCouponParam) {
|
||||
const res = await request.get<ApiResult<UserCoupon[]>>(
|
||||
SERVER_API_URL + '/sys/user-coupon',
|
||||
params
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户优惠券统计
|
||||
*/
|
||||
export async function getUserCouponCount(userId: number) {
|
||||
const res = await request.get<ApiResult<{
|
||||
total: number;
|
||||
unused: number;
|
||||
used: number;
|
||||
expired: number;
|
||||
}>>(
|
||||
SERVER_API_URL + '/sys/user-coupon/count',
|
||||
{ userId }
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询用户优惠券
|
||||
*/
|
||||
export async function getUserCoupon(id: number) {
|
||||
const res = await request.get<ApiResult<UserCoupon>>(
|
||||
SERVER_API_URL + '/sys/user-coupon/' + id
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*/
|
||||
export async function useCoupon(couponId: number, orderId: number) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/sys/user-coupon/use',
|
||||
{ couponId, orderId }
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
45
src/api/user/coupon/model/index.ts
Normal file
45
src/api/user/coupon/model/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
|
||||
/**
|
||||
* 用户优惠券
|
||||
*/
|
||||
export interface UserCoupon {
|
||||
// 优惠券ID
|
||||
couponId?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 优惠券名称
|
||||
name?: string;
|
||||
// 优惠券类型 1-满减券 2-折扣券 3-免费券
|
||||
type?: number;
|
||||
// 优惠券金额/折扣
|
||||
value?: string;
|
||||
// 使用门槛金额
|
||||
minAmount?: string;
|
||||
// 有效期开始时间
|
||||
startTime?: string;
|
||||
// 有效期结束时间
|
||||
endTime?: string;
|
||||
// 使用状态 0-未使用 1-已使用 2-已过期
|
||||
status?: number;
|
||||
// 使用时间
|
||||
useTime?: string;
|
||||
// 关联订单ID
|
||||
orderId?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 更新时间
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户优惠券搜索条件
|
||||
*/
|
||||
export interface UserCouponParam extends PageParam {
|
||||
userId?: number;
|
||||
type?: number;
|
||||
status?: number;
|
||||
name?: string;
|
||||
}
|
||||
73
src/api/user/points/index.ts
Normal file
73
src/api/user/points/index.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { UserPointsLog, UserPointsLogParam, UserPointsStats } from './model';
|
||||
import {SERVER_API_URL} from "@/utils/server";
|
||||
|
||||
/**
|
||||
* 分页查询用户积分记录
|
||||
*/
|
||||
export async function pageUserPointsLog(params: UserPointsLogParam) {
|
||||
const res = await request.get<ApiResult<PageResult<UserPointsLog>>>(
|
||||
SERVER_API_URL + '/sys/user-points-log/page',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户积分记录列表
|
||||
*/
|
||||
export async function listUserPointsLog(params?: UserPointsLogParam) {
|
||||
const res = await request.get<ApiResult<UserPointsLog[]>>(
|
||||
SERVER_API_URL + '/sys/user-points-log',
|
||||
params
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户积分统计
|
||||
*/
|
||||
export async function getUserPointsStats(userId: number) {
|
||||
const res = await request.get<ApiResult<UserPointsStats>>(
|
||||
SERVER_API_URL + '/sys/user-points-log/stats',
|
||||
{ userId }
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询积分记录
|
||||
*/
|
||||
export async function getUserPointsLog(id: number) {
|
||||
const res = await request.get<ApiResult<UserPointsLog>>(
|
||||
SERVER_API_URL + '/sys/user-points-log/' + id
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用积分
|
||||
*/
|
||||
export async function usePoints(userId: number, points: number, reason: string, orderId?: number) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/sys/user-points-log/use',
|
||||
{ userId, points, reason, orderId }
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
49
src/api/user/points/model/index.ts
Normal file
49
src/api/user/points/model/index.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
|
||||
/**
|
||||
* 用户积分记录
|
||||
*/
|
||||
export interface UserPointsLog {
|
||||
// 积分记录ID
|
||||
logId?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 积分变动类型 1-获得 2-消费 3-过期 4-管理员调整
|
||||
type?: number;
|
||||
// 积分变动数量
|
||||
points?: number;
|
||||
// 变动原因
|
||||
reason?: string;
|
||||
// 关联订单ID
|
||||
orderId?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 更新时间
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户积分统计
|
||||
*/
|
||||
export interface UserPointsStats {
|
||||
// 当前积分
|
||||
currentPoints?: number;
|
||||
// 累计获得积分
|
||||
totalEarned?: number;
|
||||
// 累计消费积分
|
||||
totalUsed?: number;
|
||||
// 即将过期积分
|
||||
expiringSoon?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户积分搜索条件
|
||||
*/
|
||||
export interface UserPointsLogParam extends PageParam {
|
||||
userId?: number;
|
||||
type?: number;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user