wangchuanjin 1 سال پیش
والد
کامیت
4555392423
2فایلهای تغییر یافته به همراه11 افزوده شده و 3 حذف شده
  1. 2 3
      api/internal/service/network.go
  2. 9 0
      api/internal/service/network_test.go

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

@@ -60,6 +60,8 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 	var saveIntroduce = func(tx *sql.Tx, cid int64, isUpdate bool) bool {
 		if in.Type != "middleman" {
 			return true
+		} else if in.Introduce_owner_id == "" && in.Introduce_project_id == "" {
+			return false
 		}
 		values := []interface{}{}
 		if in.Introduce_owner_id != "" {
@@ -72,9 +74,6 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 				values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_project_name, ",")[k], 2, nowFormat)
 			}
 		}
-		if len(values) == 0 {
-			return false
-		}
 		var r2 int64
 		if isUpdate {
 			r2 = CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from crm.connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)

+ 9 - 0
api/internal/service/network_test.go

@@ -34,6 +34,15 @@ 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",
+	})
+	log.Println(res1)
+	return
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
 	for _, v := range []string{"firstparty", "supplier", "adiffb", "middleman", "agency"} {
 		text := ""