consumer模块完成90%,前端完成supabase对接

This commit is contained in:
2026-02-04 17:21:15 +08:00
parent 8a535e3f38
commit 39aa1b6bec
1335 changed files with 191376 additions and 4 deletions

3
mall/types/analytics.uts Normal file
View File

@@ -0,0 +1,3 @@
// types/analytics.uts
export type AnalyticsTypesMigrated = true

View File

@@ -0,0 +1,5 @@
// types/analytics/common.uts
export type TimePeriod = { value: string; label: string }
export type ChartType = { value: string; label: string }
export type Metric = { key: string; label: string }

View File

@@ -0,0 +1,11 @@
// types/analytics/coupon.uts
export type CouponData = {
total_issued: number
issued_growth: number
total_used: number
usage_rate: number
gmv_increase: number
gmv_growth: number
roi: number
}

View File

@@ -0,0 +1,29 @@
// types/analytics/custom-report.uts
import type { Metric, TimePeriod, ChartType } from './common.uts'
export type CustomReport = {
id: string
name: string
description: string
metrics: Array<string>
charts: Array<string>
updated_at: string
period?: string
}
export type ReportForm = {
name: string
description: string
metrics: Array<string>
period: string
chartType: string
}
export type ReportFormErrors = {
name: string
description: string
metrics: string
period: string
chartType: string
}

View File

@@ -0,0 +1,7 @@
// types/analytics/dashboard.uts
export type TrendData = { x: Array<string>; gmv: Array<number>; orders: Array<number> }
export type SegmentItem = { name: string; value: number }
export type TrafficItem = { name: string; value: number }
export type TopProductItem = { id: string; rank: number; name: string; sales: number }
export type TopMerchantItem = { id: string; rank: number; name: string; sales: number; growth: number }

View File

@@ -0,0 +1,4 @@
// types/analytics/data-detail.uts
export type TableColumn = { key: string; label: string; type: string; sortable: boolean }
export type DrillDownItem = { id: string; label: string; value: string; type: string }

View File

@@ -0,0 +1,25 @@
// types/analytics/delivery.uts
/**
* Key Performance Indicators for the Delivery Analysis page.
*/
export type DeliveryData = {
avg_delivery_time: number;
time_growth: number;
total_fee: number;
avg_fee: number;
avg_orders_per_driver: number;
satisfaction_rate: number;
satisfaction_growth: number;
};
/**
* Represents a driver's ranking based on performance.
*/
export type DriverRank = {
id: string;
rank: number;
name: string;
orders: number;
rating: number
};

View File

@@ -0,0 +1,19 @@
// types/analytics/insight.uts
export type InsightDetail = {
id: string
report_id: string
type: string
impact: string
title: string
content: string
created_at: string
}
export type RelatedReport = {
id: string
title: string
type: string
period: string
generated_at: string
}

View File

@@ -0,0 +1,9 @@
// types/analytics/market.uts
export type MarketTrendsResponse = {
trendRows: any
categoryRows: any
seasonalRows: any
priceRows: any
competitionRows: any
}

View File

@@ -0,0 +1,14 @@
// types/analytics/product.uts
export type ProductData = {
total_products: number
product_growth: number
hot_products: number
turnover_rate: number
turnover_growth: number
avg_stock: number
stock_growth: number
}
export type ProductRank = { id: string; rank: number; name: string; sales: number; growth: number }
export type ProductTrendRow = { date: string; gmv: number; qty: number; orders: number }

View File

@@ -0,0 +1,38 @@
// types/analytics/profile.uts
export type ReportStatus = 'pending' | 'ready' | 'failed' | 'scheduled' | 'shared' | string
export type RecentReport = {
id: string
title: string
description: string
status: ReportStatus
created_at: string
}
export type OverviewData = {
totalSales: string
salesGrowth: number
totalUsers: string
userGrowth: number
totalOrders: string
orderGrowth: number
conversionRate: number
conversionGrowth: number
}
export type ReportCounts = {
total: number
pending: number
scheduled: number
shared: number
}
export type TodayInsights = {
hotProduct: string
peakTraffic: string
conversionAnomaly: string
mobileRatio: number
}
export type TrendDatum = { label: string; sales: number; orders: number }

View File

@@ -0,0 +1,46 @@
// types/analytics/report-detail.uts
export type ReportType = {
id: string;
title: string;
type: string;
period: string;
generated_at: string;
description: string;
};
export type MetricType = {
key: string;
label: string;
value: number;
format: string;
icon: string;
color: string;
change: number;
};
export type ChartTabType = {
key: string;
label: string;
};
export type ChartLegendType = {
key: string;
label: string;
color: string;
};
export type TableColumnType = {
key: string;
title: string;
width: string;
type: string;
};
export type InsightType = {
id: string;
type: string;
title: string;
content: string;
impact: string;
};

View File

@@ -0,0 +1,22 @@
// types/analytics/sales.uts
// Re-exporting shared types from dashboard for semantic clarity in the sales context.
import type { TrendData, TopProductItem, TopMerchantItem } from './dashboard.uts'
export type SalesTrendData = TrendData
export type ProductRank = TopProductItem
export type MerchantRank = TopMerchantItem
/**
* Key Performance Indicators for the Sales Report page.
*/
export type SalesData = {
gmv: number
gmv_growth: number
orders: number
order_growth: number
conversion_rate: number
conversion_growth: number
avg_order_amount: number
avg_order_growth: number
}

View File

@@ -0,0 +1,25 @@
// types/analytics/user.uts
/**
* Key Performance Indicators for the User Analysis page.
*/
export type UserData = {
total_users: number;
user_growth: number;
new_users: number;
new_user_growth: number;
active_users: number;
active_growth: number;
ordering_users: number;
ordering_growth: number;
paid_users: number;
paid_growth: number;
new_user_conversion_rate: number;
repurchase_rate: number;
repurchase_growth: number;
}
/**
* Represents a single step in a conversion funnel.
*/
export type FunnelStep = { step: string; value: number };

15
mall/types/charts.uts Normal file
View File

@@ -0,0 +1,15 @@
/**
* 用户趋势数据结构
*/
export interface UserTrend {
date: string; // 日期, 例如 "01-03"
count: number; // 用户数
}
/**
* 购买用户统计数据结构
*/
export interface PurchaseUserStat {
label: string; // 分级标签: "未消费用户", "消费一次用户", "留存客户", "回流客户"
value: number; // 用户数量
}

View File

@@ -0,0 +1,365 @@
// 电商商城系统类型定义 - UTS Android 兼容
// 用户类型
export type UserType = {
id: string
phone: string
email: string | null
nickname: string | null
avatar_url: string | null
gender: number
user_type: number
status: number
created_at: string
}
// 商城用户扩展信息类型
export type MallUserProfileType = {
id: string
user_id: string
user_type: number
status: number
real_name: string | null
id_card: string | null
credit_score: number
mall_role: string
verification_status: number
verification_data: UTSJSONObject | null
business_license: string | null
shop_category: string | null
service_areas: UTSJSONObject | null
emergency_contact: string | null
preferences: UTSJSONObject | null
created_at: string
updated_at: string
}
// 用户地址类型
export type UserAddressType = {
id: string
user_id: string
receiver_name: string
receiver_phone: string
province: string
city: string
district: string
address_detail: string
postal_code: string | null
is_default: boolean
label: string | null
coordinates: string | null
delivery_instructions: string | null
business_hours: string | null
status: number
created_at: string
updated_at: string
}
// 商家类型
export type MerchantType = {
id: string
user_id: string
shop_name: string
shop_logo: string | null
shop_banner: string | null
shop_description: string | null
contact_name: string
contact_phone: string
shop_status: number
rating: number
total_sales: number
created_at: string
}
// 商品类型
export type ProductType = {
id: string
merchant_id: string
category_id: string
name: string
description: string | null
images: Array<string>
price: number
original_price: number | null
stock: number
sales: number
status: number
created_at: string
}
// 商品SKU类型
export type ProductSkuType = {
id: string
product_id: string
sku_code: string
specifications: UTSJSONObject | null
price: number
stock: number
image_url: string | null
status: number
}
// 购物车类型
export type CartItemType = {
id: string
user_id: string
product_id: string
sku_id: string
quantity: number
selected: boolean
product: ProductType | null
sku: ProductSkuType | null
}
// 订单类型
export type OrderType = {
id: string
order_no: string
user_id: string
merchant_id: string
status: number
total_amount: number
discount_amount: number
delivery_fee: number
actual_amount: number
payment_method: number | null
payment_status: number
delivery_address: UTSJSONObject
created_at: string
}
// 订单商品类型
export type OrderItemType = {
id: string
order_id: string
product_id: string
sku_id: string
product_name: string
sku_specifications: UTSJSONObject | null
price: number
quantity: number
total_amount: number
}
// 配送员类型
export type DeliveryDriverType = {
id: string
user_id: string
real_name: string
id_card: string
driver_license: string | null
vehicle_type: number
vehicle_number: string | null
work_status: number
current_location: UTSJSONObject | null
service_areas: Array<string>
rating: number
total_orders: number
auth_status: number
created_at: string
updated_at: string
}
// 配送任务类型
export type DeliveryTaskType = {
id: string
order_id: string
driver_id: string | null
pickup_address: UTSJSONObject
delivery_address: UTSJSONObject
distance: number | null
estimated_time: number | null
delivery_fee: number
status: number
pickup_time: string | null
delivered_time: string | null
delivery_code: string | null
remark: string | null
created_at: string
updated_at: string
}
// 优惠券模板类型
export type CouponTemplateType = {
id: string
name: string
description: string | null
coupon_type: number
discount_type: number
discount_value: number
min_order_amount: number
max_discount_amount: number | null
total_quantity: number | null
per_user_limit: number
usage_limit: number
merchant_id: string | null
category_ids: Array<string>
product_ids: Array<string>
user_type_limit: number | null
start_time: string
end_time: string
status: number
created_at: string
}
// 用户优惠券类型
export type UserCouponType = {
id: string
user_id: string
template_id: string
coupon_code: string
status: number
used_at: string | null
order_id: string | null
received_at: string
expire_at: string
}
// 分页数据类型
export type PageDataType<T> = {
data: Array<T>
total: number
page: number
pageSize: number
hasMore: boolean
}
// API响应类型
export type ApiResponseType<T> = {
success: boolean
data: T | null
message: string
code: number
}
// 订单状态枚举
export const ORDER_STATUS = {
PENDING_PAYMENT: 1,
PAID: 2,
SHIPPED: 3,
DELIVERED: 4,
COMPLETED: 5,
CANCELLED: 6,
REFUNDING: 7,
REFUNDED: 8
} as const
// 优惠券类型枚举
export const COUPON_TYPE = {
DISCOUNT_AMOUNT: 1, // 满减券
DISCOUNT_PERCENT: 2, // 折扣券
FREE_SHIPPING: 3, // 免运费券
NEWBIE: 4, // 新人券
MEMBER: 5, // 会员券
CATEGORY: 6, // 品类券
MERCHANT: 7, // 商家券
LIMITED_TIME: 8 // 限时券
} as const
// 支付方式枚举
export const PAYMENT_METHOD = {
WECHAT: 1,
ALIPAY: 2,
UNIONPAY: 3,
BALANCE: 4
} as const
// 配送状态枚举
export const DELIVERY_STATUS = {
PENDING: 1,
ASSIGNED: 2,
PICKED_UP: 3,
IN_TRANSIT: 4,
DELIVERED: 5,
FAILED: 6
} as const
// 用户类型枚举
export const MALL_USER_TYPE = {
CONSUMER: 1, // 消费者
MERCHANT: 2, // 商家
DELIVERY: 3, // 配送员
SERVICE: 4, // 客服
ADMIN: 5 // 管理员
} as const
// 用户状态枚举
export const USER_STATUS = {
NORMAL: 1, // 正常
FROZEN: 2, // 冻结
CANCELLED: 3, // 注销
PENDING: 4 // 待审核
} as const
// 认证状态枚举
export const VERIFICATION_STATUS = {
UNVERIFIED: 0, // 未认证
VERIFIED: 1, // 已认证
FAILED: 2 // 认证失败
} as const
// 地址标签枚举
export const ADDRESS_LABEL = {
HOME: 'home', // 家
OFFICE: 'office', // 公司
SCHOOL: 'school', // 学校
OTHER: 'other' // 其他
} as const
// 收藏类型枚举
export const FAVORITE_TYPE = {
PRODUCT: 'product', // 商品
SHOP: 'shop' // 店铺
} as const
// =========================
// 订阅相关类型与枚举
// =========================
// 订阅周期枚举
export const SUBSCRIPTION_PERIOD = {
MONTHLY: 'monthly',
YEARLY: 'yearly'
} as const
// 订阅状态枚举
export const SUBSCRIPTION_STATUS = {
TRIAL: 'trial',
ACTIVE: 'active',
PAST_DUE: 'past_due',
CANCELED: 'canceled',
EXPIRED: 'expired'
} as const
// 软件订阅方案类型
export type SubscriptionPlanType = {
id: string
plan_code: string
name: string
description: string | null
features: UTSJSONObject | null // { featureKey: description }
price: number // 单位:元(或分,取决于后端;前端以显示为准)
currency: string | null // 'CNY' | 'USD' ...
billing_period: keyof typeof SUBSCRIPTION_PERIOD | string // 'monthly' | 'yearly'
trial_days: number | null
is_active: boolean
sort_order?: number | null
created_at?: string
updated_at?: string
}
// 用户订阅记录类型
export type UserSubscriptionType = {
id: string
user_id: string
plan_id: string
status: keyof typeof SUBSCRIPTION_STATUS | string
start_date: string
end_date: string | null
next_billing_date: string | null
auto_renew: boolean
cancel_at_period_end?: boolean | null
metadata?: UTSJSONObject | null
created_at?: string
updated_at?: string
}

470
mall/types/mall-types.uts Normal file
View File

@@ -0,0 +1,470 @@
// 电商商城系统类型定义 - UTS Android 兼容
// 用户类型
export type UserType = {
id: string
phone: string
email: string | null
nickname: string | null
avatar_url: string | null
gender: number
user_type: number
status: number
created_at: string
}
// 商城用户扩展信息类型
export type MallUserProfileType = {
id: string
user_id: string
user_type: number
status: number
real_name: string | null
id_card: string | null
credit_score: number
mall_role: string
verification_status: number
verification_data: UTSJSONObject | null
business_license: string | null
shop_category: string | null
service_areas: UTSJSONObject | null
emergency_contact: string | null
preferences: UTSJSONObject | null
created_at: string
updated_at: string
}
// 用户地址类型
export type UserAddressType = {
id: string
user_id: string
receiver_name: string
receiver_phone: string
province: string
city: string
district: string
address_detail: string
postal_code: string | null
is_default: boolean
label: string | null
coordinates: string | null
delivery_instructions: string | null
business_hours: string | null
status: number
created_at: string
updated_at: string
}
// 商家类型
export type MerchantType = {
id: string
user_id: string
shop_name: string
shop_logo: string | null
shop_banner: string | null
shop_description: string | null
contact_name: string
contact_phone: string
shop_status: number
rating: number
total_sales: number
created_at: string
}
// 商品类型
export type ProductType = {
id: string
merchant_id: string
category_id: string
name: string
description: string | null
images: Array<string>
price: number
original_price: number | null
stock: number
sales: number
status: number
created_at: string
// 药品相关字段
specification?: string | null // 规格说明
usage?: string | null // 用法用量
side_effects?: string | null // 副作用
precautions?: string | null // 注意事项
expiry_date?: string | null // 有效期
storage_conditions?: string | null // 储存条件
approval_number?: string | null // 批准文号
tags?: Array<string> | null // 商品标签
}
// 商品SKU类型
export type ProductSkuType = {
id: string
product_id: string
sku_code: string
specifications: UTSJSONObject | null
price: number
stock: number
image_url: string | null
status: number
}
// 购物车类型
export type CartItemType = {
id: string
user_id: string
product_id: string
sku_id: string
quantity: number
selected: boolean
product: ProductType | null
sku: ProductSkuType | null
}
// 订单类型
export type OrderType = {
id: string
order_no: string
user_id: string
merchant_id: string
status: number
total_amount: number
discount_amount: number
delivery_fee: number
actual_amount: number
payment_method: number | null
payment_status: number
delivery_address: UTSJSONObject
created_at: string
}
// 订单商品类型
export type OrderItemType = {
id: string
order_id: string
product_id: string
sku_id: string
product_name: string
sku_specifications: UTSJSONObject | null
price: number
quantity: number
total_amount: number
}
// 配送员类型
export type DeliveryDriverType = {
id: string
user_id: string
real_name: string
id_card: string
driver_license: string | null
vehicle_type: number
vehicle_number: string | null
work_status: number
current_location: UTSJSONObject | null
service_areas: Array<string>
rating: number
total_orders: number
auth_status: number
created_at: string
updated_at: string
}
// 配送任务类型
export type DeliveryTaskType = {
id: string
order_id: string
driver_id: string | null
pickup_address: UTSJSONObject
delivery_address: UTSJSONObject
distance: number | null
estimated_time: number | null
delivery_fee: number
status: number
pickup_time: string | null
delivered_time: string | null
delivery_code: string | null
remark: string | null
created_at: string
updated_at: string
}
// 优惠券模板类型
export type CouponTemplateType = {
id: string
name: string
description: string | null
coupon_type: number
discount_type: number
discount_value: number
min_order_amount: number
max_discount_amount: number | null
total_quantity: number | null
per_user_limit: number
usage_limit: number
merchant_id: string | null
category_ids: Array<string>
product_ids: Array<string>
user_type_limit: number | null
start_time: string
end_time: string
status: number
created_at: string
}
// 用户优惠券类型
export type UserCouponType = {
id: string
user_id: string
template_id: string
coupon_code: string
status: number
used_at: string | null
order_id: string | null
received_at: string
expire_at: string
}
// 分页数据类型
export type PageDataType<T> = {
data: Array<T>
total: number
page: number
pageSize: number
hasMore: boolean
}
// API响应类型
export type ApiResponseType<T> = {
success: boolean
data: T | null
message: string
code: number
}
// 订单状态枚举
export const ORDER_STATUS = {
PENDING_PAYMENT: 1,
PAID: 2,
SHIPPED: 3,
DELIVERED: 4,
COMPLETED: 5,
CANCELLED: 6,
REFUNDING: 7,
REFUNDED: 8
} as const
// 优惠券类型枚举
export const COUPON_TYPE = {
DISCOUNT_AMOUNT: 1, // 满减券
DISCOUNT_PERCENT: 2, // 折扣券
FREE_SHIPPING: 3, // 免运费券
NEWBIE: 4, // 新人券
MEMBER: 5, // 会员券
CATEGORY: 6, // 品类券
MERCHANT: 7, // 商家券
LIMITED_TIME: 8 // 限时券
} as const
// 支付方式枚举
export const PAYMENT_METHOD = {
WECHAT: 1,
ALIPAY: 2,
UNIONPAY: 3,
BALANCE: 4
} as const
// 配送状态枚举
export const DELIVERY_STATUS = {
PENDING: 1,
ASSIGNED: 2,
PICKED_UP: 3,
IN_TRANSIT: 4,
DELIVERED: 5,
FAILED: 6
} as const
// 用户类型枚举
export const MALL_USER_TYPE = {
CONSUMER: 1, // 消费者
MERCHANT: 2, // 商家
DELIVERY: 3, // 配送员
SERVICE: 4, // 客服
ADMIN: 5 // 管理员
} as const
// 用户状态枚举
export const USER_STATUS = {
NORMAL: 1, // 正常
FROZEN: 2, // 冻结
CANCELLED: 3, // 注销
PENDING: 4 // 待审核
} as const
// 认证状态枚举
export const VERIFICATION_STATUS = {
UNVERIFIED: 0, // 未认证
VERIFIED: 1, // 已认证
FAILED: 2 // 认证失败
} as const
// 地址标签枚举
export const ADDRESS_LABEL = {
HOME: 'home', // 家
OFFICE: 'office', // 公司
SCHOOL: 'school', // 学校
OTHER: 'other' // 其他
} as const
// 收藏类型枚举
export const FAVORITE_TYPE = {
PRODUCT: 'product', // 商品
SHOP: 'shop' // 店铺
} as const
// =========================
// 订阅相关类型与枚举
// =========================
// 订阅周期枚举
export const SUBSCRIPTION_PERIOD = {
MONTHLY: 'monthly',
YEARLY: 'yearly'
} as const
// 订阅状态枚举
export const SUBSCRIPTION_STATUS = {
TRIAL: 'trial',
ACTIVE: 'active',
PAST_DUE: 'past_due',
CANCELED: 'canceled',
EXPIRED: 'expired'
} as const
// 软件订阅方案类型
export type SubscriptionPlanType = {
id: string
plan_code: string
name: string
description: string | null
features: UTSJSONObject | null // { featureKey: description }
price: number // 单位:元(或分,取决于后端;前端以显示为准)
currency: string | null // 'CNY' | 'USD' ...
billing_period: keyof typeof SUBSCRIPTION_PERIOD | string // 'monthly' | 'yearly'
trial_days: number | null
is_active: boolean
sort_order?: number | null
created_at?: string
updated_at?: string
}
// 用户订阅记录类型
export type UserSubscriptionType = {
id: string
user_id: string
plan_id: string
status: keyof typeof SUBSCRIPTION_STATUS | string
start_date: string
end_date: string | null
next_billing_date: string | null
auto_renew: boolean
cancel_at_period_end?: boolean | null
metadata?: UTSJSONObject | null
created_at?: string
updated_at?: string
}
export interface Product {
id: string
name: string
description: string | null // 允许null
price: number
original_price: number | null // 允许null
images: string[]
// ... 其他属性
}
// types/mall-types.uts
export interface ProductType {
id: string
name: string
description: string
price: number
original_price: number
images: string[]
category_id: string
status: number
stock: number
sales: number
tags: string[]
created_at: string
updated_at: string
}
export interface CategoryType {
id: string
name: string
icon_url: string
parent_id: string | null
is_active: boolean
sort_order: number
}
export interface BannerType {
id: string
title: string
image_url: string
link_url: string
sort_order: number
status: number
}
export interface CouponTemplateType {
id: string
name: string
discount_value: number
min_order_amount: number
start_time: string
end_time: string
status: number
per_user_limit: number
}
export interface CartItemType {
id: string
user_id: string
product_id: string
quantity: number
created_at: string
}
// Mock 数据类型
export interface MockData {
banners: BannerType[]
categories: CategoryType[]
coupons: CouponTemplateType[]
products: ProductType[]
}
// 用户基础信息类型 (兼容 pages/user/types.uts)
export type UserProfile = {
id?: string;
username: string;
email: string;
gender?: string;
birthday?: string;
height_cm?: number;
weight_kg?: number;
bio?: string;
avatar_url?: string;
preferred_language?: string;
role?: string;
school_id?: string;
grade_id?: string;
class_id?: string;
created_at?: string;
updated_at?: string;
}
export type UserStats = {
trainings: number;
points: number;
streak: number;
}

8
mall/types/orders.uts Normal file
View File

@@ -0,0 +1,8 @@
/**
* 订单统计数据接口
*/
export interface OrderStat {
date: string; // 日期, 例如 "01-04"
totalAmount: number;// 订单金额
orderCount: number; // 订单数量
}