更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -15,12 +15,10 @@ import (
|
||||
"server/pkg/identity"
|
||||
)
|
||||
|
||||
// BackendCrmClueController CRM 线索管理
|
||||
type BackendCrmClueController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// cluePayload 线索新增/编辑请求体
|
||||
type cluePayload struct {
|
||||
ClueName string `json:"clue_name"`
|
||||
CustomerName string `json:"customer_name"`
|
||||
@@ -28,10 +26,9 @@ type cluePayload struct {
|
||||
OwnerUserID string `json:"owner_user_id"`
|
||||
OwnerUserName string `json:"owner_user_name"`
|
||||
Industry string `json:"industry"`
|
||||
Amount float64 `json:"amount"` // 预计金额
|
||||
Amount float64 `json:"amount"`
|
||||
NextContactTime string `json:"next_contact_time"`
|
||||
ClueLevel string `json:"clue_level"`
|
||||
// 线索状态:1跟进中 / 2已转化 / 3已废弃(编辑时可调整;新增固定为跟进中)
|
||||
Status string `json:"status"`
|
||||
ContactPerson string `json:"contact_person"`
|
||||
ContactPosition string `json:"contact_position"`
|
||||
@@ -42,7 +39,6 @@ type cluePayload struct {
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// List GET /backend/crm/clue/list
|
||||
func (c *BackendCrmClueController) List() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -67,7 +63,6 @@ func (c *BackendCrmClueController) List() {
|
||||
|
||||
tenantID := pipelineTenantID(claims)
|
||||
cond := orm.NewCondition().And("tenant_id", tenantID).And("delete_time__isnull", true)
|
||||
// 数据范围:平台/租户管理员可见全部,其他用户仅本人(负责人或创建人)
|
||||
cond = crmApplyOwnerScope(cond, claims)
|
||||
if keyword != "" {
|
||||
kw := orm.NewCondition().
|
||||
@@ -94,8 +89,6 @@ func (c *BackendCrmClueController) List() {
|
||||
total, _ := qs.Count()
|
||||
var list []models.TenantCrmClue
|
||||
if total > 0 {
|
||||
// 列表排列:按 id 倒序,最新创建的线索排在最前。
|
||||
// 排序在数据库侧完成,翻页后整体顺序保持一致。
|
||||
_, _ = qs.OrderBy("-id").Offset((page - 1) * pageSize).Limit(pageSize).All(&list)
|
||||
}
|
||||
pipelineOk(&c.Controller, map[string]interface{}{
|
||||
@@ -103,7 +96,6 @@ func (c *BackendCrmClueController) List() {
|
||||
})
|
||||
}
|
||||
|
||||
// Detail GET /backend/crm/clue/:id
|
||||
func (c *BackendCrmClueController) Detail() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -124,7 +116,6 @@ func (c *BackendCrmClueController) Detail() {
|
||||
pipelineErr(&c.Controller, 404, 404, "线索未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, clue.OwnerUserID, clue.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该线索数据")
|
||||
return
|
||||
@@ -132,7 +123,6 @@ func (c *BackendCrmClueController) Detail() {
|
||||
pipelineOk(&c.Controller, clue)
|
||||
}
|
||||
|
||||
// Create POST /backend/crm/clue
|
||||
func (c *BackendCrmClueController) Create() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -193,7 +183,6 @@ func (c *BackendCrmClueController) Create() {
|
||||
CreateTime: now,
|
||||
UpdateTime: now,
|
||||
}
|
||||
// 唯一性校验:同租户内不允许重复创建同名线索(重复数据请联系管理员转移跟进)
|
||||
if crmNameDuplicated(new(models.TenantCrmClue), clue.TenantID, "clue_name", clue.ClueName) {
|
||||
pipelineErr(&c.Controller, 409, 409, "该线索名称已存在(可能由其他同事创建),如需继续跟进请联系管理员转移")
|
||||
return
|
||||
@@ -207,7 +196,6 @@ func (c *BackendCrmClueController) Create() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": id})
|
||||
}
|
||||
|
||||
// Update PUT /backend/crm/clue/:id
|
||||
func (c *BackendCrmClueController) Update() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -235,7 +223,6 @@ func (c *BackendCrmClueController) Update() {
|
||||
pipelineErr(&c.Controller, 404, 404, "线索未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, clue.OwnerUserID, clue.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该线索数据")
|
||||
return
|
||||
@@ -271,9 +258,6 @@ func (c *BackendCrmClueController) Update() {
|
||||
clue.ContactQQ = strings.TrimSpace(p.ContactQQ)
|
||||
clue.Address = strings.TrimSpace(p.Address)
|
||||
clue.Remark = p.Remark
|
||||
// 线索状态:编辑时可直接管理(1跟进中 / 2已转化 / 3已废弃)。
|
||||
// 标为「已转化」时与转化流程保持一致:同时锁定(locked=1),列表中沉底且不能再编辑 / 转化;
|
||||
// 改回跟进中 / 已废弃则解除锁定(历史数据同样兜底)。
|
||||
prevStatus := clue.Status
|
||||
if s := strings.TrimSpace(p.Status); s != "" {
|
||||
if v, err := strconv.Atoi(s); err == nil && v >= 1 && v <= 3 {
|
||||
@@ -334,7 +318,6 @@ func (c *BackendCrmClueController) ChangeStatus() {
|
||||
pipelineErr(&c.Controller, 404, 404, "线索未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, clue.OwnerUserID, clue.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该线索数据")
|
||||
return
|
||||
@@ -343,7 +326,6 @@ func (c *BackendCrmClueController) ChangeStatus() {
|
||||
pipelineErr(&c.Controller, 400, 400, "线索已转化并锁定,不能流转状态")
|
||||
return
|
||||
}
|
||||
// 状态未变化:直接幂等返回,不写日志
|
||||
if clue.Status == p.Status {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": clue.ID, "status": clue.Status})
|
||||
return
|
||||
@@ -359,7 +341,6 @@ func (c *BackendCrmClueController) ChangeStatus() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": clue.ID, "status": p.Status})
|
||||
}
|
||||
|
||||
// clueStatusName 线索状态文案(用于操作日志):1跟进中 / 2已转化 / 3已废弃
|
||||
func clueStatusName(s int8) string {
|
||||
switch s {
|
||||
case 2:
|
||||
@@ -371,7 +352,6 @@ func clueStatusName(s int8) string {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete DELETE /backend/crm/clue/:id
|
||||
func (c *BackendCrmClueController) Delete() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -392,7 +372,6 @@ func (c *BackendCrmClueController) Delete() {
|
||||
pipelineErr(&c.Controller, 404, 404, "线索未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, clue.OwnerUserID, clue.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该线索数据")
|
||||
return
|
||||
@@ -416,8 +395,6 @@ func (c *BackendCrmClueController) Delete() {
|
||||
pipelineOk(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Convert POST /backend/crm/clue/:id/convert
|
||||
// 线索转商机:把线索的客户名称落地为正式客户(或关联已有客户),再创建商机并锁定线索。
|
||||
func (c *BackendCrmClueController) Convert() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -439,7 +416,7 @@ func (c *BackendCrmClueController) Convert() {
|
||||
NextContactTime string `json:"next_contact_time"`
|
||||
Level string `json:"level"`
|
||||
Remark string `json:"remark"`
|
||||
CustomerMode string `json:"customer_mode"` // create=新建客户(默认) / existing=关联已有客户
|
||||
CustomerMode string `json:"customer_mode"`
|
||||
CustomerID uint64 `json:"customer_id"`
|
||||
Customer struct {
|
||||
CustomerName string `json:"customer_name"`
|
||||
@@ -466,7 +443,6 @@ func (c *BackendCrmClueController) Convert() {
|
||||
pipelineErr(&c.Controller, 404, 404, "线索未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, clue.OwnerUserID, clue.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该线索数据")
|
||||
return
|
||||
@@ -480,7 +456,6 @@ func (c *BackendCrmClueController) Convert() {
|
||||
return
|
||||
}
|
||||
|
||||
// 1. 处理客户:新建正式客户 或 关联已有客户
|
||||
customerName := strings.TrimSpace(p.Customer.CustomerName)
|
||||
if customerName == "" {
|
||||
customerName = clue.CustomerName
|
||||
@@ -534,7 +509,6 @@ func (c *BackendCrmClueController) Convert() {
|
||||
crmWriteLog(tenantID, 1, clue.ID, "convert-customer", "线索转化生成正式客户:"+customerName, claims)
|
||||
}
|
||||
|
||||
// 2. 创建商机
|
||||
businessName := strings.TrimSpace(p.BusinessName)
|
||||
if businessName == "" {
|
||||
businessName = clue.ClueName
|
||||
@@ -588,7 +562,6 @@ func (c *BackendCrmClueController) Convert() {
|
||||
return
|
||||
}
|
||||
|
||||
// 3. 锁定线索
|
||||
clue.Status = 2
|
||||
clue.Locked = 1
|
||||
bid := uint64(bizID)
|
||||
@@ -605,7 +578,6 @@ func (c *BackendCrmClueController) Convert() {
|
||||
})
|
||||
}
|
||||
|
||||
// firstNonEmpty 返回第一个非空字符串。
|
||||
func firstNonEmpty(vals ...string) string {
|
||||
for _, v := range vals {
|
||||
if strings.TrimSpace(v) != "" {
|
||||
|
||||
Reference in new issue
Block a user