wangchuanjin 1 vuosi sitten
vanhempi
commit
6bbfb7f1a5
2 muutettua tiedostoa jossa 13 lisäystä ja 7 poistoa
  1. 2 2
      api/internal/service/network.go
  2. 11 5
      api/internal/service/network_test.go

+ 2 - 2
api/internal/service/network.go

@@ -85,7 +85,7 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 	if in.Id > 0 {
 		if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
 			if in.Company_id != "" {
-				count := CrmMysql.CountBySql(`select count(1) as count from crm.connection where position_id=? and company_id=? and itype=? and id<>?`, in.PositionId, in.Company_id, itype, in.Id)
+				count := CrmMysql.CountBySql(`select count(1) as count from crm.connection where position_id=? and company_id=? and itype=? and id<>? and status=1`, in.PositionId, in.Company_id, itype, in.Id)
 				if count == -1 {
 					return false
 				} else if count > 0 {
@@ -104,7 +104,7 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 		}
 	} else {
 		if in.Company_id != "" {
-			count := CrmMysql.CountBySql(`select count(1) as count from crm.connection where position_id=? and company_id=? and itype=?`, in.PositionId, in.Company_id, itype)
+			count := CrmMysql.CountBySql(`select count(1) as count from crm.connection where position_id=? and company_id=? and itype=? and status=1`, in.PositionId, in.Company_id, itype)
 			if count == -1 {
 				return reply
 			} else if count > 0 {

+ 11 - 5
api/internal/service/network_test.go

@@ -35,11 +35,17 @@ func initDb() {
 func TestAddOrUpdate(t *testing.T) {
 	initDb()
 	res1 := Network.AddOrUpdate(&types.AddOrUpdateReq{
-		PositionId:     943,
-		Company_name:   "王传进的89",
-		Contact_person: "王传进",
-		Contact_phone:  "15037870765",
-		Type:           "middleman",
+		PositionId:             943,
+		Company_id:             "77777",
+		Company_name:           "王传进的89",
+		Contact_person:         "王传进",
+		Contact_phone:          "15037870765",
+		Type:                   "middleman",
+		Introduce_owner_id:     "5aebc2c37a624e8bacc40c1802a57041",
+		Introduce_owner_name:   "北京影业(北京)有限公司",
+		Introduce_project_id:   "5aebc2c37a624e8bacc40c1802a57041",
+		Introduce_project_name: "北京物业服务",
+		Id:                     21,
 	})
 	log.Println(res1)
 	return