|
@@ -9,7 +9,7 @@ import (
|
|
|
)
|
|
|
|
|
|
//CanAdd 是否允许多人针对一个创建
|
|
|
-func CanAdd(entId int64, key string, employInfoId, employCustomId int64) (status int64, error_msg string) {
|
|
|
+func CanAdd(entId int64, key string, employInfoId, employCustomId, positionId int64) (status int64, error_msg string) {
|
|
|
accountData := cm.BaseMysql.SelectBySql(`select * from base_service.base_account where ent_id =? and person_id =0 and type =1 limit 1`, entId)
|
|
|
if accountData == nil || len(*accountData) <= 0 {
|
|
|
return 1, ""
|
|
@@ -17,32 +17,46 @@ func CanAdd(entId int64, key string, employInfoId, employCustomId int64) (status
|
|
|
accountId := (*accountData)[0]["id"]
|
|
|
//
|
|
|
tenantData := cm.BaseMysql.SelectBySql(`select * from crm.config_tenant where account_id =?`, accountId)
|
|
|
- if tenantData == nil || len(*tenantData) <= 0 {
|
|
|
- return 1, ""
|
|
|
- }
|
|
|
+
|
|
|
//不允许
|
|
|
- if gconv.Int((*tenantData)[0][key]) == 0 {
|
|
|
+ if tenantData == nil || gconv.Int((*tenantData)[0][key]) == 0 {
|
|
|
//判断是否已经创建
|
|
|
if strings.Contains(key, "clue") {
|
|
|
- d := cm.BaseMysql.SelectBySql(`select create_person from crm.sale_clue where employ_info_id =? and ent_id =?`, employInfoId, entId)
|
|
|
+ d := cm.BaseMysql.SelectBySql(`select create_person,position_id from crm.sale_clue where employ_info_id =? and ent_id =?`, employInfoId, entId)
|
|
|
if d != nil && len(*d) > 0 {
|
|
|
+ position_id := gconv.Int64((*d)[0]["position_id"])
|
|
|
+ if positionId == position_id {
|
|
|
+ return 1, ""
|
|
|
+ }
|
|
|
return -1, fmt.Sprintf("%v已经基于该咨询创建了线索", (*d)[0]["create_person"])
|
|
|
}
|
|
|
|
|
|
} else if strings.Contains(key, "chance") {
|
|
|
- d := cm.BaseMysql.SelectBySql(`select create_person from crm.sale_chance where employ_info_id =? and ent_id =?`, employInfoId, entId)
|
|
|
+ d := cm.BaseMysql.SelectBySql(`select create_person,position_id from crm.sale_chance where employ_info_id =? and ent_id =?`, employInfoId, entId)
|
|
|
if d != nil && len(*d) > 0 {
|
|
|
+ position_id := gconv.Int64((*d)[0]["position_id"])
|
|
|
+ if positionId == position_id {
|
|
|
+ return 1, ""
|
|
|
+ }
|
|
|
return -1, fmt.Sprintf("%v已经基于该咨询创建了机会", (*d)[0]["create_person"])
|
|
|
}
|
|
|
} else if strings.Contains(key, "custom") {
|
|
|
if employInfoId > 0 {
|
|
|
- d := cm.BaseMysql.SelectBySql(`select create_person from crm.custom where employ_info_id =? and ent_id =?`, employInfoId, entId)
|
|
|
+ d := cm.BaseMysql.SelectBySql(`select create_person,position_id from crm.custom where employ_info_id =? and ent_id =?`, employInfoId, entId)
|
|
|
if d != nil && len(*d) > 0 {
|
|
|
+ position_id := gconv.Int64((*d)[0]["position_id"])
|
|
|
+ if positionId == position_id {
|
|
|
+ return 1, ""
|
|
|
+ }
|
|
|
return -1, fmt.Sprintf("%v已经基于该咨询创建了客户", (*d)[0]["create_person"])
|
|
|
}
|
|
|
} else if employCustomId > 0 {
|
|
|
- d := cm.BaseMysql.SelectBySql(`select create_person from crm.custom where employ_custom_id =? and ent_id =?`, employCustomId, entId)
|
|
|
+ d := cm.BaseMysql.SelectBySql(`select create_person,position_id from crm.custom where employ_custom_id =? and ent_id =?`, employCustomId, entId)
|
|
|
if d != nil && len(*d) > 0 {
|
|
|
+ position_id := gconv.Int64((*d)[0]["position_id"])
|
|
|
+ if positionId == position_id {
|
|
|
+ return 1, ""
|
|
|
+ }
|
|
|
return -1, fmt.Sprintf("%v已经基于该候选客户创建了客户", (*d)[0]["create_person"])
|
|
|
}
|
|
|
}
|