|
@@ -32,7 +32,7 @@ func (n *Network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
|
|
itype = 5
|
|
itype = 5
|
|
}
|
|
}
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
- var getValues = func(cid int64) []interface{} {
|
|
|
|
|
|
+ var saveIntroduce = func(tx *sql.Tx, cid int64) int64 {
|
|
values := []interface{}{}
|
|
values := []interface{}{}
|
|
if in.Introduce_owner_id != "" {
|
|
if in.Introduce_owner_id != "" {
|
|
for k, v := range strings.Split(in.Introduce_owner_id, ",") {
|
|
for k, v := range strings.Split(in.Introduce_owner_id, ",") {
|
|
@@ -41,20 +41,20 @@ func (n *Network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
|
|
}
|
|
}
|
|
if in.Introduce_project_id != "" {
|
|
if in.Introduce_project_id != "" {
|
|
for k, v := range strings.Split(in.Introduce_project_id, ",") {
|
|
for k, v := range strings.Split(in.Introduce_project_id, ",") {
|
|
- values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_project_name, ",")[k], 1, nowFormat)
|
|
|
|
|
|
+ values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_project_name, ",")[k], 2, nowFormat)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return values
|
|
|
|
|
|
+ var r3 int64
|
|
|
|
+ if len(values) > 0 {
|
|
|
|
+ _, r3 = CrmMysql.InsertBatchByTx(tx, "connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "relate_id", "relate_name", "itype", "create_time"}, values)
|
|
|
|
+ }
|
|
|
|
+ return r3
|
|
}
|
|
}
|
|
if in.Id > 0 {
|
|
if in.Id > 0 {
|
|
if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
|
|
if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
|
|
- r1 := CrmMysql.UpdateOrDeleteBySqlByTx(`update connection set company_name=?,company_id=?,contact_person=?,contact_phone=?,update_time=? where id=? and position_id=?`, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, nowFormat, in.Id, in.PositionId)
|
|
|
|
- r2 := CrmMysql.UpdateOrDeleteBySqlByTx(`delete from connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
|
|
|
|
- var r3 int64
|
|
|
|
- if len(values) > 0 {
|
|
|
|
- _, r3 = CrmMysql.InsertBatchByTx(tx, "connection_introduce", []string{"connection_id", "relate_id", "relate_name", "itype", "create_time"}, getValues(r1))
|
|
|
|
- }
|
|
|
|
- return r1 > 0 && r2 >= 0 && r3 >= 0
|
|
|
|
|
|
+ r1 := CrmMysql.UpdateOrDeleteBySqlByTx(tx, `update connection set company_name=?,company_id=?,contact_person=?,contact_phone=?,update_time=? where id=? and position_id=?`, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, nowFormat, in.Id, in.PositionId)
|
|
|
|
+ r2 := CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
|
|
|
|
+ return r1 > 0 && r2 >= 0 && saveIntroduce(tx, in.Id) >= 0
|
|
}) {
|
|
}) {
|
|
reply.Data = map[string]interface{}{
|
|
reply.Data = map[string]interface{}{
|
|
"status": 1,
|
|
"status": 1,
|
|
@@ -67,12 +67,8 @@ func (n *Network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
|
|
} else {
|
|
} else {
|
|
id := 0
|
|
id := 0
|
|
if CrmMysql.ExecTx("新增人脉", func(tx *sql.Tx) bool {
|
|
if CrmMysql.ExecTx("新增人脉", func(tx *sql.Tx) bool {
|
|
- _, r1 := CrmMysql.InsertBatchByTx(tx, "connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_id", "position_id", "contact_name", "contact_phone", "status", "create_time", "update_time"}, []interface{}{in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, itype, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
|
|
|
|
- var r2 int64
|
|
|
|
- if len(values) > 0 {
|
|
|
|
- _, r2 = CrmMysql.InsertBatchByTx(tx, "connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "relate_id", "relate_name", "itype", "create_time"}, values)
|
|
|
|
- }
|
|
|
|
- return r1 > 0 && r2 >= 0
|
|
|
|
|
|
+ _, r1 := CrmMysql.InsertBatchByTx(tx, "connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_id", "contact_person", "contact_phone", "status", "create_time", "update_time"}, []interface{}{in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, itype, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
|
|
|
|
+ return r1 > 0 && saveIntroduce(tx, r1) >= 0
|
|
}) {
|
|
}) {
|
|
reply.Data = map[string]interface{}{
|
|
reply.Data = map[string]interface{}{
|
|
"status": 1,
|
|
"status": 1,
|