瀏覽代碼

feat: add name_pinyin_abbr columns for CRM product and customer.

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 3 月之前
父節點
當前提交
e7b3fbb21b
共有 3 個文件被更改,包括 40 次插入 和 170 次删除
  1. 2 0
      backend/app/models/crm_models.py
  2. 37 0
      docs/sql/migrations/2026-08-07-crm-name-pinyin-abbr.sql
  3. 1 170
      docs/sql/shanxia2.0.sql

+ 2 - 0
backend/app/models/crm_models.py

@@ -48,6 +48,7 @@ class CrmProduct(Base):
     id = Column(String(64), primary_key=True, comment="主键ID")
     product_no = Column(String(50), nullable=False, comment="产品编号")
     product_name = Column(String(200), nullable=False, comment="产品名称")
+    name_pinyin_abbr = Column(String(100), nullable=True, comment="产品名称拼音首字母(小写)")
     category_id = Column(String(64), nullable=True, comment="分类ID")
     category_name = Column(String(100), nullable=True, comment="分类名称(冗余)")
     model = Column(String(100), nullable=True, comment="规格型号")
@@ -157,6 +158,7 @@ class CrmCustomer(Base):
     # 业务字段
     customer_no = Column(String(50), nullable=False, comment="客户编号(唯一)")
     customer_name = Column(String(200), nullable=False, comment="客户名称")
+    name_pinyin_abbr = Column(String(100), nullable=True, comment="客户名称拼音首字母(小写)")
     short_name = Column(String(100), nullable=True, comment="客户简称")
     customer_type = Column(String(20), nullable=True, default="company", comment="客户类型(字典 crm_customer_type)")
     mobile = Column(String(20), nullable=True, comment="手机号")

+ 37 - 0
docs/sql/migrations/2026-08-07-crm-name-pinyin-abbr.sql

@@ -0,0 +1,37 @@
+-- 产品/客户名称拼音首字母(小写)
+-- 若列已存在会报 Duplicate column;可忽略或先查 information_schema。
+-- 建议仅执行一次。
+
+-- crm_product.name_pinyin_abbr
+SET @col_exists := (
+  SELECT COUNT(*)
+  FROM information_schema.COLUMNS
+  WHERE TABLE_SCHEMA = DATABASE()
+    AND TABLE_NAME = 'crm_product'
+    AND COLUMN_NAME = 'name_pinyin_abbr'
+);
+SET @sql := IF(
+  @col_exists = 0,
+  'ALTER TABLE `crm_product` ADD COLUMN `name_pinyin_abbr` varchar(100) DEFAULT NULL COMMENT ''产品名称拼音首字母(小写)'' AFTER `product_name`',
+  'SELECT ''crm_product.name_pinyin_abbr already exists, skip'''
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+-- crm_customer.name_pinyin_abbr
+SET @col_exists := (
+  SELECT COUNT(*)
+  FROM information_schema.COLUMNS
+  WHERE TABLE_SCHEMA = DATABASE()
+    AND TABLE_NAME = 'crm_customer'
+    AND COLUMN_NAME = 'name_pinyin_abbr'
+);
+SET @sql := IF(
+  @col_exists = 0,
+  'ALTER TABLE `crm_customer` ADD COLUMN `name_pinyin_abbr` varchar(100) DEFAULT NULL COMMENT ''客户名称拼音首字母(小写)'' AFTER `customer_name`',
+  'SELECT ''crm_customer.name_pinyin_abbr already exists, skip'''
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;

File diff suppressed because it is too large
+ 1 - 170
docs/sql/shanxia2.0.sql


Some files were not shown because too many files changed in this diff