wangchuanjin 1 жил өмнө
parent
commit
09fb7b2956

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

@@ -4,6 +4,7 @@ import (
 	"context"
 	"database/sql"
 	"fmt"
+	"log"
 	"math"
 	"sort"
 	"strings"
@@ -533,7 +534,7 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 		args = append(args, start, in.Page_size)
 		itemArgs := []interface{}{in.PositionId}
 		itemArgs = append(itemArgs, comSqlArgs...)
-		items := CrmMysql.SelectBySql(`SELECT itype,SUM(1) AS sum FROM crm.connection WHERE position_id=?`+comSqlAppend+` GROUP BY itype`, itemArgs...)
+		items := CrmMysql.SelectBySql(`SELECT itype,SUM(1) AS sum FROM crm.connection a WHERE a.position_id=?`+comSqlAppend+` GROUP BY a.itype`, itemArgs...)
 		if items != nil {
 			for _, v := range *items {
 				switch Int64All(v["itype"]) {
@@ -856,6 +857,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
 		}
 		result[k].BuyerCount = int64(len(v))
 		for _, vv := range v {
+			log.Println(k, vv.CompanyName)
 			if entMonitor[vv.CompanyName] {
 				result[k].MonitorCount++
 			}

+ 36 - 40
api/internal/service/network_test.go

@@ -1,10 +1,13 @@
 package service
 
 import (
+	"context"
 	"encoding/json"
 	"log"
 	"testing"
 
+	"github.com/zeromicro/go-zero/zrpc"
+
 	. "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/es"
 	. "app.yhyue.com/moapp/jybase/mongodb"
@@ -12,38 +15,14 @@ import (
 	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"bp.jydev.jianyu360.cn/CRM/application/service"
+	"bp.jydev.jianyu360.cn/CRM/baseCenter/rpc/basecenter"
 )
 
-func initDb() {
-	CrmMysql = &mysql.Mysql{
-		Address:      "192.168.3.217:4000",
-		UserName:     "root",
-		PassWord:     "=PDT49#80Z!RVv52_z",
-		DBName:       "crm",
-		MaxOpenConns: 5,
-		MaxIdleConns: 5,
-	}
-	CrmMysql.Init()
-	ConnectClickhouse(&config.CHouseConfig{
-		Addr:         "192.168.3.207:19000",
-		UserName:     "jytop",
-		Password:     "pwdTopJy123",
-		DbName:       "information",
-		MaxIdleConns: 2,
-		MaxOpenConns: 2,
-	})
-	es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
-	log.Println("ccccccc")
-	Mgo = MongodbSim{
-		MongodbAddr: "192.168.3.149:27180",
-		Size:        2,
-		DbName:      "qfw",
-	}
-	Mgo.InitPool()
-}
+//go test -test.run=TestAddCustomService -fs=../../etc/crmapplication.yaml -lf=../../etc/logs.yaml -df=../../etc/db.yaml -pf=../../etc/push.yaml
+
 func TestAddOrUpdate(t *testing.T) {
 	defer Catch()
-	initDb()
 	res1 := Network.AddOrUpdate(&types.AddOrUpdateReq{
 		PositionId:           943,
 		Company_name:         "王传进的89",
@@ -89,7 +68,6 @@ func TestAddOrUpdate(t *testing.T) {
 }
 
 func TestAssociate(t *testing.T) {
-	initDb()
 	//log.Println(NetworkCom.GetEntTagSeat(2))
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
 	//
@@ -103,13 +81,12 @@ func TestAssociate(t *testing.T) {
 }
 
 func TestNetWorkList(t *testing.T) {
-	initDb()
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
 	res := Network.List(&types.NetWorkListReq{
 		EntAccountId: 64,
 		UserId:       "1205591997",
-		//PositionId: 1205591997,
-		PositionId: 1205592003,
+		PositionId:   1205591997,
+		//PositionId: 1205592003,
 		//PositionId:   935,
 		Current_page: 1,
 		Page_size:    10,
@@ -117,12 +94,12 @@ func TestNetWorkList(t *testing.T) {
 		//Order_amount: -1,
 		// Monitorcount_start: 1,
 		// Monitorcount_end:   1,
-		//Monitor:      0,
-		Project_matchme: 1,
+		//Monitor: 1,
+		//Project_matchme: 1,
 		//Starttime: "2024-04-23",
 		//Endtime:   "2024-04-23",
-		Type: "supplier",
-		//Name: "四川",
+		//Type: "middleman",
+		Name: "新疆",
 	})
 	for k, v := range res.Data.(map[string]interface{}) {
 		if k == "list" {
@@ -135,13 +112,12 @@ func TestNetWorkList(t *testing.T) {
 	}
 }
 func TestAllProject(t *testing.T) {
-	initDb()
 	res := Network.AllProject(&types.AllprojectReq{
 		EntAccountId: 64,
 		//PositionId:   935,
 		PositionId: 1205591997, //刘苗
 		//PositionId: 1205592003,//刘亚丽
-		Id:   "87028422487e44e68c5531bc2c6f9528",
+		Id:   "009c313ef8e740e59d57432aea777102",
 		Type: "firstparty",
 	})
 	b, _ := json.Marshal(res.Data)
@@ -149,9 +125,8 @@ func TestAllProject(t *testing.T) {
 }
 
 func TestOwner(t *testing.T) {
-	initDb()
 	ownerService := &OwnerService{
-		Intermediary: "wcj_11111111f",
+		Intermediary: "30154",
 		PositionId:   935,
 		PageIndex:    1,
 		PageSize:     100,
@@ -160,3 +135,24 @@ func TestOwner(t *testing.T) {
 	b, _ := json.Marshal(data)
 	log.Println(string(b))
 }
+
+func TestAddCustomService(t *testing.T) {
+	cs := &service.CustomService{
+		PositionId:           1205591997,
+		AppId:                "10000",
+		CustomType:           35,
+		Summary:              "1",
+		CustomAllName:        "1",
+		CustomAbbreviation:   "1",
+		CustomLevel:          1,
+		CustomIndustry:       11,
+		CustomDetailIndustry: 24,
+		Province:             "000000",
+		NextfollowUpTime:     1714406400,
+		Types:                1,
+		User:                 []int64{1205591997},
+		CreateName:           "刘苗苗",
+		OwnerId:              "875037a55d374627b1bc919c3cd84668",
+	}
+	cs.Add(context.Background())
+}

+ 1 - 1
service/custom.go

@@ -339,7 +339,7 @@ func SaveConnection(tx *sql.Tx, positionId int64, businessId, ownerId string, en
 		}
 		if cm.CrmMysql.Count(table, map[string]interface{}{
 			"position_id": positionId,
-			"relate_id":   sourceType,
+			"relate_id":   businessId,
 			"itype":       sourceType,
 		}) > 0 {
 			cm.CrmMysql.UpdateByTx(tx, table, map[string]interface{}{