客户基本信息支持快速编辑,新增微信与QQ字段
工作台侧栏可点击编辑手机/邮箱/微信/QQ;客户资料同步展示,自动识别仅在主字段为空时回填。
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -52,6 +52,8 @@ type Customer struct {
|
||||
Name string `gorm:"size:50;not null" json:"name"`
|
||||
Phone string `gorm:"size:20" json:"phone"`
|
||||
Email string `gorm:"size:100" json:"email"`
|
||||
Wechat string `gorm:"size:50" json:"wechat"` // 微信号,默认可空
|
||||
QQ string `gorm:"size:20;column:qq" json:"qq"`
|
||||
Tags string `gorm:"type:text" json:"tags"`
|
||||
Source string `gorm:"size:30" json:"source"`
|
||||
Status string `gorm:"size:20;default:online" json:"status"`
|
||||
|
||||
Reference in New Issue
Block a user