更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -15,7 +15,6 @@ import (
|
||||
"server/pkg/identity"
|
||||
)
|
||||
|
||||
// BackendCrmBusinessController CRM 商机管理
|
||||
type BackendCrmBusinessController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -42,7 +41,6 @@ type businessPayload struct {
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// List GET /backend/crm/business/list
|
||||
func (c *BackendCrmBusinessController) List() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -66,7 +64,6 @@ func (c *BackendCrmBusinessController) 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().
|
||||
@@ -92,7 +89,6 @@ func (c *BackendCrmBusinessController) List() {
|
||||
total, _ := qs.Count()
|
||||
var list []models.TenantCrmBusiness
|
||||
if total > 0 {
|
||||
// 未转化的排前面,已转化的(locked=1)沉到列表下方
|
||||
_, _ = qs.OrderBy("locked", "-id").Offset((page - 1) * pageSize).Limit(pageSize).All(&list)
|
||||
}
|
||||
attachClueName(tenantID, list)
|
||||
@@ -101,7 +97,6 @@ func (c *BackendCrmBusinessController) List() {
|
||||
})
|
||||
}
|
||||
|
||||
// Detail GET /backend/crm/business/:id
|
||||
func (c *BackendCrmBusinessController) Detail() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -128,7 +123,6 @@ func (c *BackendCrmBusinessController) Detail() {
|
||||
pipelineOk(&c.Controller, biz)
|
||||
}
|
||||
|
||||
// Create POST /backend/crm/business
|
||||
func (c *BackendCrmBusinessController) Create() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -201,7 +195,6 @@ func (c *BackendCrmBusinessController) Create() {
|
||||
CreateTime: now,
|
||||
UpdateTime: now,
|
||||
}
|
||||
// 唯一性校验:同租户内不允许重复创建同名商机(重复数据请联系管理员转移跟进)
|
||||
if crmNameDuplicated(new(models.TenantCrmBusiness), tenantID, "business_name", biz.BusinessName) {
|
||||
pipelineErr(&c.Controller, 409, 409, "该商机名称已存在(可能由其他同事创建),如需继续跟进请联系管理员转移")
|
||||
return
|
||||
@@ -215,7 +208,6 @@ func (c *BackendCrmBusinessController) Create() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": id})
|
||||
}
|
||||
|
||||
// Update PUT /backend/crm/business/:id
|
||||
func (c *BackendCrmBusinessController) Update() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -242,7 +234,6 @@ func (c *BackendCrmBusinessController) Update() {
|
||||
pipelineErr(&c.Controller, 404, 404, "商机未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, biz.OwnerUserID, biz.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该商机数据")
|
||||
return
|
||||
@@ -303,9 +294,6 @@ func (c *BackendCrmBusinessController) Update() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": biz.ID})
|
||||
}
|
||||
|
||||
// ChangeStage POST /backend/crm/business/:id/stage
|
||||
// 商机阶段流转:1初步接洽 2需求确认 3方案报价 4商务谈判 5赢单 6输单。
|
||||
// 仅更新阶段字段,不触碰其他业务字段;已转化并锁定的商机不允许再流转。
|
||||
func (c *BackendCrmBusinessController) ChangeStage() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -339,7 +327,6 @@ func (c *BackendCrmBusinessController) ChangeStage() {
|
||||
pipelineErr(&c.Controller, 404, 404, "商机未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, biz.OwnerUserID, biz.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该商机数据")
|
||||
return
|
||||
@@ -352,7 +339,6 @@ func (c *BackendCrmBusinessController) ChangeStage() {
|
||||
pipelineErr(&c.Controller, 400, 400, "商机已废弃,请先恢复为「跟进中」再流转阶段")
|
||||
return
|
||||
}
|
||||
// 阶段未变化:直接幂等返回,不写日志
|
||||
if strings.TrimSpace(biz.Stage) == stage {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": biz.ID, "stage": biz.Stage})
|
||||
return
|
||||
@@ -368,9 +354,6 @@ func (c *BackendCrmBusinessController) ChangeStage() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": biz.ID, "stage": stage})
|
||||
}
|
||||
|
||||
// ChangeStatus POST /backend/crm/business/:id/status
|
||||
// 商机状态流转:1跟进中 / 3已废弃。
|
||||
// 「已转化项目(2)」不走本接口,须用「转项目」完成(会锁定商机)。
|
||||
func (c *BackendCrmBusinessController) ChangeStatus() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -403,7 +386,6 @@ func (c *BackendCrmBusinessController) ChangeStatus() {
|
||||
pipelineErr(&c.Controller, 404, 404, "商机未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, biz.OwnerUserID, biz.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该商机数据")
|
||||
return
|
||||
@@ -412,7 +394,6 @@ func (c *BackendCrmBusinessController) ChangeStatus() {
|
||||
pipelineErr(&c.Controller, 400, 400, "商机已转化并锁定,不能流转状态")
|
||||
return
|
||||
}
|
||||
// 状态未变化:直接幂等返回,不写日志
|
||||
if biz.Status == p.Status {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": biz.ID, "status": biz.Status})
|
||||
return
|
||||
@@ -428,7 +409,6 @@ func (c *BackendCrmBusinessController) ChangeStatus() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": biz.ID, "status": p.Status})
|
||||
}
|
||||
|
||||
// businessStatusName 商机状态文案(用于操作日志):1跟进中 / 2已转化项目 / 3已废弃
|
||||
func businessStatusName(s int8) string {
|
||||
switch s {
|
||||
case 2:
|
||||
@@ -440,7 +420,6 @@ func businessStatusName(s int8) string {
|
||||
}
|
||||
}
|
||||
|
||||
// businessStageName 商机阶段文案(用于操作日志):1初步接洽 … 5赢单 / 6输单
|
||||
func businessStageName(s string) string {
|
||||
switch strings.TrimSpace(s) {
|
||||
case "2":
|
||||
@@ -458,7 +437,6 @@ func businessStageName(s string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// validBusinessStage 商机阶段取值校验(1~6)
|
||||
func validBusinessStage(s string) bool {
|
||||
switch s {
|
||||
case "1", "2", "3", "4", "5", "6":
|
||||
@@ -467,7 +445,6 @@ func validBusinessStage(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Delete DELETE /backend/crm/business/:id
|
||||
func (c *BackendCrmBusinessController) Delete() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -488,7 +465,6 @@ func (c *BackendCrmBusinessController) Delete() {
|
||||
pipelineErr(&c.Controller, 404, 404, "商机未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, biz.OwnerUserID, biz.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该商机数据")
|
||||
return
|
||||
@@ -512,7 +488,6 @@ func (c *BackendCrmBusinessController) Delete() {
|
||||
pipelineOk(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Convert POST /backend/crm/business/:id/convert 商机转项目
|
||||
func (c *BackendCrmBusinessController) Convert() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
@@ -547,7 +522,6 @@ func (c *BackendCrmBusinessController) Convert() {
|
||||
pipelineErr(&c.Controller, 404, 404, "商机未找到")
|
||||
return
|
||||
}
|
||||
// 数据范围校验:非管理员仅能操作本人(负责人或创建人)的数据
|
||||
if !canAccessCrmRecord(claims, biz.OwnerUserID, biz.CreateUserID) {
|
||||
pipelineErr(&c.Controller, 403, 403, "无权操作该商机数据")
|
||||
return
|
||||
@@ -575,8 +549,6 @@ func (c *BackendCrmBusinessController) Convert() {
|
||||
TenantID: tenantID,
|
||||
ProjectName: projectName,
|
||||
ProjectNo: strings.TrimSpace(p.ProjectNo),
|
||||
// 商机转化默认按「单一项目」创建:金额与对接人先落到上游侧,
|
||||
// 后续可在项目中选择「上下游项目」并补充下游供应商 / 金额 / 对接人
|
||||
ProjectType: 1,
|
||||
BusinessID: &bizIDVal,
|
||||
CustomerID: biz.CustomerID,
|
||||
@@ -585,7 +557,7 @@ func (c *BackendCrmBusinessController) Convert() {
|
||||
OwnerUserName: biz.OwnerUserName,
|
||||
Industry: biz.Industry,
|
||||
UpstreamAmount: amount,
|
||||
Amount: amount, // 兼容旧字段
|
||||
Amount: amount,
|
||||
Status: 1,
|
||||
StartDate: parsePipelineDate(p.StartDate),
|
||||
EndDate: parsePipelineDate(p.EndDate),
|
||||
@@ -606,7 +578,6 @@ func (c *BackendCrmBusinessController) Convert() {
|
||||
return
|
||||
}
|
||||
|
||||
// 锁定商机
|
||||
biz.Status = 2
|
||||
biz.Locked = 1
|
||||
pid := uint64(projID)
|
||||
@@ -618,7 +589,6 @@ func (c *BackendCrmBusinessController) Convert() {
|
||||
crmWriteLog(tenantID, 2, biz.ID, "convert", "商机转化为项目:"+projectName, claims)
|
||||
crmWriteLog(tenantID, 3, uint64(projID), "create", "由商机「"+biz.BusinessName+"」转化生成", claims)
|
||||
|
||||
// 生成项目时,把「商机 + 来源线索」过程库中的联系人去重同步到正式公司联系人库
|
||||
if biz.CustomerID != nil && *biz.CustomerID > 0 {
|
||||
var contacts []models.TenantCrmEntityContact
|
||||
var bizContacts []models.TenantCrmEntityContact
|
||||
|
||||
Reference in new issue
Block a user