feat: MBTI头像与用户规则链路升级,三端页面与接口同步

Made-with: Cursor
This commit is contained in:
卡若
2026-03-24 01:22:50 +08:00
parent fa3da12b16
commit 1d56d0336c
71 changed files with 3848 additions and 1621 deletions

View File

@@ -4,26 +4,31 @@ import "time"
// Order 对应表 ordersJSON 输出与现网接口 1:1小写驼峰
type Order struct {
ID string `gorm:"column:id;primaryKey;size:50" json:"id"`
OrderSN string `gorm:"column:order_sn;uniqueIndex;size:50" json:"orderSn"`
UserID string `gorm:"column:user_id;size:50" json:"userId"`
OpenID string `gorm:"column:open_id;size:100" json:"openId"`
ProductType string `gorm:"column:product_type;size:50" json:"productType"`
ProductID *string `gorm:"column:product_id;size:50" json:"productId,omitempty"`
Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"`
Description *string `gorm:"column:description;size:200" json:"description,omitempty"`
Status *string `gorm:"column:status;size:20" json:"status,omitempty"`
TransactionID *string `gorm:"column:transaction_id;size:100" json:"transactionId,omitempty"`
PayTime *time.Time `gorm:"column:pay_time" json:"payTime,omitempty"`
ReferralCode *string `gorm:"column:referral_code;size:255" json:"referralCode,omitempty"`
ReferrerID *string `gorm:"column:referrer_id;size:255" json:"referrerId,omitempty"`
RefundReason *string `gorm:"column:refund_reason;size:500" json:"refundReason,omitempty"`
PaymentMethod *string `gorm:"column:payment_method;size:20" json:"paymentMethod,omitempty"`
ID string `gorm:"column:id;primaryKey;size:50" json:"id"`
OrderSN string `gorm:"column:order_sn;uniqueIndex;size:50" json:"orderSn"`
UserID string `gorm:"column:user_id;size:50" json:"userId"`
OpenID string `gorm:"column:open_id;size:100" json:"openId"`
ProductType string `gorm:"column:product_type;size:50" json:"productType"`
ProductID *string `gorm:"column:product_id;size:50" json:"productId,omitempty"`
Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"`
Description *string `gorm:"column:description;size:200" json:"description,omitempty"`
Status *string `gorm:"column:status;size:20" json:"status,omitempty"`
TransactionID *string `gorm:"column:transaction_id;size:100" json:"transactionId,omitempty"`
PayTime *time.Time `gorm:"column:pay_time" json:"payTime,omitempty"`
ReferralCode *string `gorm:"column:referral_code;size:255" json:"referralCode,omitempty"`
ReferrerID *string `gorm:"column:referrer_id;size:255" json:"referrerId,omitempty"`
RefundReason *string `gorm:"column:refund_reason;size:500" json:"refundReason,omitempty"`
PaymentMethod *string `gorm:"column:payment_method;size:20" json:"paymentMethod,omitempty"`
// 代付:关联代付请求、实际付款人
GiftPayRequestID *string `gorm:"column:gift_pay_request_id;size:50" json:"giftPayRequestId,omitempty"`
PayerUserID *string `gorm:"column:payer_user_id;size:50" json:"payerUserId,omitempty"`
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
// 飞书 webhook 推送状态paid 后实时推送;失败可补偿重推)
WebhookPushStatus string `gorm:"column:webhook_push_status;size:20;default:''" json:"webhookPushStatus,omitempty"`
WebhookPushedAt *time.Time `gorm:"column:webhook_pushed_at" json:"webhookPushedAt,omitempty"`
WebhookPushAttempts int `gorm:"column:webhook_push_attempts;default:0" json:"webhookPushAttempts,omitempty"`
WebhookPushError *string `gorm:"column:webhook_push_error;size:500" json:"webhookPushError,omitempty"`
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
}
func (Order) TableName() string { return "orders" }

View File

@@ -62,6 +62,8 @@ type User struct {
// 以下为接口返回时从订单/绑定表实时计算的字段,不入库
PurchasedSectionCount int `gorm:"-" json:"purchasedSectionCount,omitempty"`
WalletBalance *float64 `gorm:"-" json:"walletBalance,omitempty"`
RFMScore *float64 `gorm:"-" json:"rfmScore,omitempty"`
RFMLevel *string `gorm:"-" json:"rfmLevel,omitempty"`
}
func (User) TableName() string { return "users" }

View File

@@ -1,17 +1,40 @@
package model
import "time"
import (
"database/sql/driver"
"time"
)
// UserRule 用户旅程触达规则(各节点弹窗标题/说明,由管理端配置
// RuleJSON 存储 JSON 数组/对象的列user_rules 的 trigger_conditions 等
type RuleJSON []byte
func (r RuleJSON) Value() (driver.Value, error) { return []byte(r), nil }
func (r *RuleJSON) Scan(value interface{}) error {
if value == nil {
*r = nil
return nil
}
b, ok := value.([]byte)
if !ok {
return nil
}
*r = append((*r)[0:0], b...)
return nil
}
// UserRule 用户旅程触达规则(结构化触发条件 + 推送动作,由管理端配置)
type UserRule struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
Title string `gorm:"column:title;size:200;not null" json:"title"`
Description string `gorm:"column:description;type:text" json:"description"`
Trigger string `gorm:"column:trigger;size:100" json:"trigger"`
Sort int `gorm:"column:sort;default:0" json:"sort"`
Enabled bool `gorm:"column:enabled;default:true" json:"enabled"`
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
ID uint `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
Title string `gorm:"column:title;size:200;not null" json:"title"`
Description string `gorm:"column:description;type:text" json:"description"`
Trigger string `gorm:"column:trigger;size:100" json:"trigger"`
TriggerConditions RuleJSON `gorm:"column:trigger_conditions;type:json" json:"triggerConditions,omitempty"`
ActionType string `gorm:"column:action_type;size:50;default:'popup'" json:"actionType,omitempty"`
ActionConfig RuleJSON `gorm:"column:action_config;type:json" json:"actionConfig,omitempty"`
Sort int `gorm:"column:sort;default:0" json:"sort"`
Enabled bool `gorm:"column:enabled;default:true" json:"enabled"`
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
}
func (UserRule) TableName() string { return "user_rules" }