客户基本信息支持快速编辑,新增微信与QQ字段

工作台侧栏可点击编辑手机/邮箱/微信/QQ;客户资料同步展示,自动识别仅在主字段为空时回填。
This commit is contained in:
yml2213
2026-07-19 00:23:21 +08:00
parent 6070cf47dc
commit cbc76f3258
6 changed files with 191 additions and 17 deletions
@@ -137,6 +137,14 @@ func mergeCustomerContacts(tenantID, customerID uint, contacts []extractedContac
updates["email"] = c.Value
customer.Email = c.Value
}
if c.Kind == "wechat" && strings.TrimSpace(customer.Wechat) == "" && updates["wechat"] == nil {
updates["wechat"] = c.Value
customer.Wechat = c.Value
}
if c.Kind == "qq" && strings.TrimSpace(customer.QQ) == "" && updates["qq"] == nil {
updates["qq"] = c.Value
customer.QQ = c.Value
}
}
if len(updates) > 0 {
model.DB.Model(&model.Customer{}).Where("id = ?", customerID).Updates(updates)
+13 -1
View File
@@ -2,6 +2,7 @@ package handler
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
"kefu-cloud/server/internal/middleware"
@@ -135,12 +136,23 @@ func (h *CustomerHandler) Update(c *gin.Context) {
return
}
allowed := map[string]bool{"name": true, "phone": true, "email": true, "tags": true, "source": true, "status": true}
allowed := map[string]bool{
"name": true, "phone": true, "email": true, "wechat": true, "qq": true,
"tags": true, "source": true, "status": true,
}
for key := range updates {
if !allowed[key] {
delete(updates, key)
}
}
// 字符串字段统一 trim
for _, k := range []string{"name", "phone", "email", "wechat", "qq", "source", "status"} {
if v, ok := updates[k]; ok {
if s, ok := v.(string); ok {
updates[k] = strings.TrimSpace(s)
}
}
}
if len(updates) == 0 {
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "没有可更新字段"})
return