Browse Source

feat:xiugai

wangchuanjin 1 year ago
parent
commit
871a85c1d3
2 changed files with 33 additions and 29 deletions
  1. 18 14
      api/internal/service/network.go
  2. 15 15
      api/internal/service/network_test.go

+ 18 - 14
api/internal/service/network.go

@@ -60,19 +60,25 @@ 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 == "" {
+		} else if in.Introduce_owner_id == "" || in.Introduce_project_id == "" {
 			return false
 		}
 		values := []interface{}{}
-		if in.Introduce_owner_id != "" {
-			for k, v := range strings.Split(in.Introduce_owner_id, ",") {
-				values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_owner_name, ",")[k], 1, nowFormat)
-			}
+		ioi := strings.Split(in.Introduce_owner_id, ",")
+		ion := strings.Split(in.Introduce_owner_name, ",")
+		if len(ioi) != len(ion) {
+			return false
 		}
-		if 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], 2, nowFormat)
-			}
+		for k, v := range ioi {
+			values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, ion[k], 1, nowFormat)
+		}
+		ipi := strings.Split(in.Introduce_project_id, ",")
+		ipn := strings.Split(in.Introduce_project_name, ",")
+		if len(ipi) != len(ipn) {
+			return false
+		}
+		for k, v := range ipi {
+			values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, ipn[k], 2, nowFormat)
 		}
 		var r2 int64
 		if isUpdate {
@@ -478,9 +484,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 						}
 					}
 				}
-				if middleman_project[company_id] != nil {
-					expect_amount = middleman_project[company_id].ProjectAmount
-				}
 			case 5:
 				itype = "招标代理机构"
 				jump_type = "agency"
@@ -496,7 +499,7 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 			}
 			if buyer_count < in.Buyercount_start {
 				continue
-			} else if buyer_count > in.Buyercount_end {
+			} else if in.Buyercount_end > 0 && buyer_count > in.Buyercount_end {
 				continue
 			} else if in.Monitor == 1 && monitor_count <= 0 {
 				continue
@@ -504,11 +507,12 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				continue
 			} else if monitor_count < in.Monitorcount_start {
 				continue
-			} else if monitor_count > in.Monitorcount_end {
+			} else if in.Monitorcount_end > 0 && monitor_count > in.Monitorcount_end {
 				continue
 			} else if in.Project_matchme == 1 && project_count == 0 {
 				continue
 			}
+
 			export_url := ""
 			if len(export_id) > 0 {
 				export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(strings.Join(export_id, ","))

+ 15 - 15
api/internal/service/network_test.go

@@ -5,6 +5,8 @@ import (
 	"log"
 	"testing"
 
+	. "app.yhyue.com/moapp/jybase/common"
+
 	"app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/mysql"
 	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
@@ -33,19 +35,17 @@ func initDb() {
 	es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
 }
 func TestAddOrUpdate(t *testing.T) {
+	defer Catch()
 	initDb()
 	res1 := Network.AddOrUpdate(&types.AddOrUpdateReq{
-		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,
+		PositionId:           943,
+		Company_name:         "王传进的89",
+		Contact_person:       "王传进",
+		Contact_phone:        "15037870765",
+		Type:                 "middleman",
+		Introduce_owner_id:   "5aebc2c37a624e8bacc40c1802a57041",
+		Introduce_owner_name: "北京影业(北京)有限公司",
+		Introduce_project_id: "5aebc2c37a624e8bacc40c1802a57041,北京物业服务",
 	})
 	log.Println(res1)
 	return
@@ -99,10 +99,10 @@ func TestNetWorkList(t *testing.T) {
 	initDb()
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
 	res := Network.List(&types.NetWorkListReq{
-		PositionId:         943,
-		Order_amount:       1,
-		Monitorcount_start: 1,
-		Monitorcount_end:   1,
+		PositionId: 1205591239,
+		// Order_amount:       1,
+		// Monitorcount_start: 1,
+		// Monitorcount_end:   1,
 		//Monitor:      0,
 		//Project_matchme: 1,
 	})