优化合同个管理和产品管理相关功能

This commit is contained in:
2026-09-12 23:29:45 +08:00
parent 2b1874943f
commit 4455b95e37
92 changed files with 5367 additions and 3144 deletions
+42 -21
View File
@@ -20,16 +20,19 @@ type BackendCrmProductController struct {
}
type crmProductPayload struct {
ProductNo string `json:"product_no"`
ProductName string `json:"product_name"`
Category string `json:"category"`
Unit string `json:"unit"`
Spec string `json:"spec"`
Price float64 `json:"price"`
CostPrice float64 `json:"cost_price"`
TaxRate float64 `json:"tax_rate"`
Status int8 `json:"status"`
Remark string `json:"remark"`
ProductNo string `json:"product_no"`
ProductName string `json:"product_name"`
Category string `json:"category"`
Unit string `json:"unit"`
Spec string `json:"spec"`
Price float64 `json:"price"`
CostPrice float64 `json:"cost_price"`
TaxRate float64 `json:"tax_rate"`
LineType string `json:"line_type"`
DevUnitPrice float64 `json:"dev_unit_price"`
DevTree json.RawMessage `json:"dev_tree"`
Status int8 `json:"status"`
Remark string `json:"remark"`
}
// crmProductItem 项目产品清单中的单行(也用于项目生成时写入产品管理)。
@@ -139,6 +142,10 @@ func (c *BackendCrmProductController) Create() {
if status != 0 && status != 1 {
status = 1
}
lineType := strings.TrimSpace(p.LineType)
if lineType != "dev" {
lineType = "product"
}
now := time.Now()
row := models.TenantCrmProduct{
TenantID: pipelineTenantID(claims),
@@ -150,6 +157,9 @@ func (c *BackendCrmProductController) Create() {
Price: p.Price,
CostPrice: p.CostPrice,
TaxRate: p.TaxRate,
LineType: lineType,
DevUnitPrice: p.DevUnitPrice,
DevTree: string(p.DevTree),
Status: status,
Remark: p.Remark,
CreateUserID: pipelineUID(claims),
@@ -198,21 +208,28 @@ func (c *BackendCrmProductController) Update() {
if status != 0 && status != 1 {
status = row.Status
}
lineType := strings.TrimSpace(p.LineType)
if lineType != "dev" {
lineType = "product"
}
now := time.Now()
_, err = models.Orm.QueryTable(new(models.TenantCrmProduct)).
Filter("id", id).Filter("tenant_id", tenantID).
Update(orm.Params{
"product_no": strings.TrimSpace(p.ProductNo),
"product_name": strings.TrimSpace(p.ProductName),
"category": strings.TrimSpace(p.Category),
"unit": strings.TrimSpace(p.Unit),
"spec": strings.TrimSpace(p.Spec),
"price": p.Price,
"cost_price": p.CostPrice,
"tax_rate": p.TaxRate,
"status": status,
"remark": p.Remark,
"update_time": now,
"product_no": strings.TrimSpace(p.ProductNo),
"product_name": strings.TrimSpace(p.ProductName),
"category": strings.TrimSpace(p.Category),
"unit": strings.TrimSpace(p.Unit),
"spec": strings.TrimSpace(p.Spec),
"price": p.Price,
"cost_price": p.CostPrice,
"tax_rate": p.TaxRate,
"line_type": lineType,
"dev_unit_price": p.DevUnitPrice,
"dev_tree": p.DevTree,
"status": status,
"remark": p.Remark,
"update_time": now,
})
if err != nil {
pipelineErr(&c.Controller, 500, 500, "更新失败: "+err.Error())
@@ -371,6 +388,10 @@ func SyncContractProducts(tenantID, uid string, raw json.RawMessage) (json.RawMe
}
now := time.Now()
for _, it := range items {
// 软件开发行(line_type=dev)不走产品管理建档,仅保留模块树
if fmt.Sprintf("%v", it["line_type"]) == "dev" {
continue
}
name := strings.TrimSpace(fmt.Sprintf("%v", it["name"]))
if name == "" {
continue