业务更名为撞车并切换crash路由

用户可见文案与页面/API路径改为撞车与crash,保留mohong表与权限码兼容;移动端入口去掉租/撞图标。
This commit is contained in:
yml2213
2026-07-16 21:19:35 +08:00
parent 8b637cf499
commit a4189db4ca
38 changed files with 232 additions and 179 deletions
@@ -169,6 +169,22 @@ func (r *Repository) EnsureSupportConversation(ctx context.Context, userID uint6
_ = tx.Model(&existing).Update("support_scene", SupportSceneGeneral).Error
}
}
// 兼容旧摸大红场景码 mohong → crash
if existing.ID == 0 && scene == SupportSceneCrash {
err = tx.Table("chat_conversations AS c").
Select("c.*").
Joins("JOIN chat_participants AS cp ON cp.conversation_id = c.id").
Where(
"c.type = ? AND c.support_scene = ? AND cp.participant_type = ? AND cp.participant_id = ?",
ConversationTypeGeneralSupport, SupportSceneMohong, "user", userID,
).
Order("c.id ASC").
Limit(1).
Find(&existing).Error
if err != nil {
return err
}
}
if existing.ID > 0 {
conversationID = existing.ID
return nil
+1 -1
View File
@@ -35,7 +35,7 @@ type ConversationDTO struct {
// EnsureSupportRequest 创建/复用客服会话。
type EnsureSupportRequest struct {
// Scene 业务场景:general(默认)/ mohong(摸大红
// Scene 业务场景:general(默认)/ crash(撞车,兼容旧值 mohong
Scene string `json:"scene"`
}
@@ -11,18 +11,20 @@ import (
// 客服入口业务场景(与前端 POST /chats/support 的 scene 对齐)。
const (
SupportSceneGeneral = "general"
SupportSceneMohong = "mohong"
SupportSceneCrash = "crash"
// SupportSceneMohong 兼容旧 scene 值,与 crash 同一客服分组。
SupportSceneMohong = "mohong"
)
// resolveSupportScene 规范化场景并返回标题、客服分组 code、欢迎语。
// groupCode 为空时表示不走分组,使用默认客服选取逻辑。
func resolveSupportScene(raw string) (scene, title, groupCode, welcome string) {
switch strings.ToLower(strings.TrimSpace(raw)) {
case SupportSceneMohong:
return SupportSceneMohong,
"摸大红客服",
supportgroup.GroupCodeMohong,
"您好,这里是摸大红客服。请直接描述问题,可将订单信息复制后发送。"
case SupportSceneCrash, SupportSceneMohong:
return SupportSceneCrash,
"撞车客服",
supportgroup.GroupCodeMohong, // 分组 code 仍为 mohong,后台可改显示名
"您好,这里是撞车客服。请直接描述问题,可将订单信息复制后发送。"
default:
// 未知场景回落平台客服,避免随意 scene 绕开分配策略
return SupportSceneGeneral,
+1 -1
View File
@@ -70,7 +70,7 @@ func (h *Handler) writeObject(c *gin.Context, publicOnly bool) {
!strings.HasPrefix(key, "avatar/") &&
!strings.HasPrefix(key, "payment-cert/") &&
!strings.HasPrefix(key, "announcement/") &&
!strings.HasPrefix(key, "mohong/") {
!strings.HasPrefix(key, "mohong/") && !strings.HasPrefix(key, "crash/") {
response.Error(c, http.StatusNotFound, "not_found", "文件不存在或暂不可访问")
return
}
+2 -2
View File
@@ -106,7 +106,7 @@ func normalizeContentType(contentType string, data []byte) string {
func fileURLForScene(scene string, key string) string {
fileURL := "/api/files/object?key=" + url.QueryEscape(key)
if scene == "home-banner" || scene == "avatar" || scene == "payment-cert" || scene == "announcement" || scene == "mohong" {
if scene == "home-banner" || scene == "avatar" || scene == "payment-cert" || scene == "announcement" || scene == "mohong" || scene == "crash" {
fileURL = "/api/public/files/object?key=" + url.QueryEscape(key)
}
return fileURL
@@ -115,7 +115,7 @@ func fileURLForScene(scene string, key string) string {
func normalizeScene(scene string) string {
scene = strings.TrimSpace(strings.ToLower(scene))
switch scene {
case "listing", "handoff", "dispute", "realname", "avatar", "home-banner", "chat", "payment-cert", "announcement", "qrcode", "mohong":
case "listing", "handoff", "dispute", "realname", "avatar", "home-banner", "chat", "payment-cert", "announcement", "qrcode", "mohong", "crash":
return scene
default:
return "misc"
+3 -3
View File
@@ -14,7 +14,7 @@ const (
configKeyDefaultQrcodeURL = "mohong.default_qrcode_url"
configKeyOrderCopyTemplate = "mohong.order_copy_template"
defaultOrderCopyTemplate = "【摸大红订单】\n订单号:{{order_no}}\n下单时间:{{created_at}}\n商品明细:\n{{items}}\n数量合计:{{quantity}}\n金额:{{amount}}\n下单人:{{buyer_name}}{{buyer_phone}}"
defaultOrderCopyTemplate = "【撞车订单】\n订单号:{{order_no}}\n下单时间:{{created_at}}\n商品明细:\n{{items}}\n数量合计:{{quantity}}\n金额:{{amount}}\n下单人:{{buyer_name}}{{buyer_phone}}"
)
func (r *Repository) GetConfig(ctx context.Context) (*ConfigDTO, error) {
@@ -42,12 +42,12 @@ func (r *Repository) UpdateConfig(ctx context.Context, req UpdateConfigRequest)
}
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
if req.DefaultQrcodeURL != nil {
if err := upsertConfig(tx, configKeyDefaultQrcodeURL, strings.TrimSpace(*req.DefaultQrcodeURL), "摸大红全局默认固定二维码图片URL"); err != nil {
if err := upsertConfig(tx, configKeyDefaultQrcodeURL, strings.TrimSpace(*req.DefaultQrcodeURL), "撞车全局默认固定二维码图片URL"); err != nil {
return err
}
}
if req.OrderCopyTemplate != nil {
if err := upsertConfig(tx, configKeyOrderCopyTemplate, strings.TrimSpace(*req.OrderCopyTemplate), "摸大红订单一键复制文案模板"); err != nil {
if err := upsertConfig(tx, configKeyOrderCopyTemplate, strings.TrimSpace(*req.OrderCopyTemplate), "撞车订单一键复制文案模板"); err != nil {
return err
}
}
@@ -111,7 +111,7 @@ func (r *Repository) CreateOrder(ctx context.Context, userID uint64, req CreateO
if err := notification.Append(tx, notification.Entry{
UserID: userID,
Type: "order",
Title: "摸大红订单已创建",
Title: "撞车订单已创建",
Content: "订单已创建,请在有效时间内完成支付。",
BizType: "mohong_order",
BizID: &orderID,
@@ -311,8 +311,8 @@ func (r *Repository) AdminCompleteOrder(ctx context.Context, orderID uint64, rem
return r.AdminFindOrder(ctx, orderID)
}
// ConfirmPaidFromChannelTx 支付成功后推进摸大红订单:固化二维码快照与可复制文案。
// 返回值固定为 0,兼容支付模块会话通知签名(摸大红无订单群)。
// ConfirmPaidFromChannelTx 支付成功后推进撞车订单:固化二维码快照与可复制文案。
// 返回值固定为 0,兼容支付模块会话通知签名(撞车无订单群)。
func (r *Repository) ConfirmPaidFromChannelTx(tx *gorm.DB, orderID uint64) (uint64, error) {
var order model.MohongOrder
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&order, orderID).Error; err != nil {
@@ -348,7 +348,7 @@ func (r *Repository) ConfirmPaidFromChannelTx(tx *gorm.DB, orderID uint64) (uint
if err := notification.Append(tx, notification.Entry{
UserID: order.UserID,
Type: "order",
Title: "摸大红订单支付成功",
Title: "撞车订单支付成功",
Content: "支付已完成,请在订单详情扫码联系客服,并复制订单信息发送。",
BizType: "mohong_order",
BizID: &orderIDCopy,
@@ -358,7 +358,7 @@ func (r *Repository) ConfirmPaidFromChannelTx(tx *gorm.DB, orderID uint64) (uint
return 0, nil
}
// NotifyNewConversation 兼容支付模块接口;摸大红不创建会话,空实现。
// NotifyNewConversation 兼容支付模块接口;撞车不创建会话,空实现。
func (r *Repository) NotifyNewConversation(conversationID uint64) {}
func (r *Repository) cancelPendingOrderTx(tx *gorm.DB, order *model.MohongOrder, reason string) error {
@@ -2,7 +2,7 @@ package mohong
import "gorm.io/gorm"
// Repository 摸大红数据访问。
// Repository 撞车数据访问。
type Repository struct {
db *gorm.DB
}
@@ -13,7 +13,7 @@ import (
const bizTypeMohongPay = "mohong_pay"
// StartMohong 发起摸大红订单支付。
// StartMohong 发起撞车订单支付。
func (r *Repository) StartMohong(ctx context.Context, userID uint64, orderID uint64, req StartPaymentRequest, clientIP string) (*PaymentDTO, error) {
req.PayWay = normalizePayWay(req.PayWay)
defaultConfig, err := r.defaultRuntimeConfig(ctx, req.PayWay)
@@ -73,7 +73,7 @@ func (r *Repository) StartMohong(ctx context.Context, userID uint64, orderID uin
NotifyURL: runtimeConfig.NotifyURL,
JumpURL: runtimeConfig.JumpURL,
ClientIP: clientIP,
Body: "摸大红订单 " + orderRow.OrderNo,
Body: "撞车订单 " + orderRow.OrderNo,
Attach: orderRow.OrderNo,
})
if err != nil {
@@ -202,7 +202,7 @@ func newMohongPayment(row model.MohongOrder, req StartPaymentRequest, runtimeCon
return payment, nil
}
// QueryMohong 查询摸大红订单支付状态。
// QueryMohong 查询撞车订单支付状态。
func (r *Repository) QueryMohong(ctx context.Context, userID uint64, orderID uint64) (*PaymentDTO, error) {
var payment model.PaymentOrder
if err := r.db.WithContext(ctx).
@@ -13,7 +13,7 @@ import (
"gorm.io/gorm"
)
// MohongOrderConfirmer 摸大红订单支付确认接口,避免 payment 与 mohong 循环依赖。
// MohongOrderConfirmer 撞车订单支付确认接口,避免 payment 与 mohong 循环依赖。
type MohongOrderConfirmer interface {
ConfirmPaidFromChannelTx(tx *gorm.DB, orderID uint64) (uint64, error)
NotifyNewConversation(conversationID uint64)
@@ -89,7 +89,7 @@ func WithLogger(logger *zap.Logger) RepositoryOption {
}
}
// WithMohongRepo 注入摸大红订单确认器。
// WithMohongRepo 注入撞车订单确认器。
func WithMohongRepo(repo MohongOrderConfirmer) RepositoryOption {
return func(r *Repository) {
r.mohongRepo = repo