This commit is contained in:
2026-04-30 19:50:31 +08:00
parent 612643e568
commit 2b3ee849f1
2 changed files with 28 additions and 11 deletions
+7
View File
@@ -0,0 +1,7 @@
# 2026-04-30 工作记录
## 修复编译错误:TabCustomer 无 PrimaryPhone 字段
- **问题**: `apiWarehouse.go:1177``c.PrimaryPhone undefined`
- **原因**: `TabCustomer` 结构体没有 `PrimaryPhone` 字段,电话存储在独立的 `TabCustomerPhone` 表(`is_primary=true` 标记主号码)
- **修复**: 改为从 `TabCustomerPhone` 表查询主号码,拼接格式 `+{Prefix} {Phone}`,文件:`routers/apiWarehouse.go`
+11 -1
View File
@@ -1169,12 +1169,22 @@ func ApiWarehouse(r *gin.RouterGroup) {
for _, b := range customerBinds { for _, b := range customerBinds {
var c TabCustomer var c TabCustomer
if models.DB.Where("id = ?", b.CustomerID).First(&c).Error == nil { if models.DB.Where("id = ?", b.CustomerID).First(&c).Error == nil {
// 查询主电话号码
var primaryPhone TabCustomerPhone
primaryPhoneStr := ""
if models.DB.Where("customer_id = ? AND is_primary = ?", c.ID, true).First(&primaryPhone).Error == nil {
if primaryPhone.Prefix != "" {
primaryPhoneStr = "+" + primaryPhone.Prefix + " " + primaryPhone.Phone
} else {
primaryPhoneStr = primaryPhone.Phone
}
}
customers = append(customers, CustomerInfo{ customers = append(customers, CustomerInfo{
ID: c.ID, ID: c.ID,
FirstName: c.FirstName, FirstName: c.FirstName,
LastName: c.LastName, LastName: c.LastName,
Title: c.Title, Title: c.Title,
PrimaryPhone: c.PrimaryPhone, PrimaryPhone: primaryPhoneStr,
}) })
} }
} }