Răsfoiți Sursa

Merge remote-tracking branch 'origin/feature/v1.0.4' into dev_v1.0.4_wh

WH01243 1 an în urmă
părinte
comite
58bd221eee

+ 2 - 0
api/internal/logic/coophistorylistlogic.go

@@ -5,6 +5,7 @@ import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
 	"context"
+	"fmt"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -24,6 +25,7 @@ func NewCoopHistoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
 }
 
 func (l *CoopHistoryListLogic) CoopHistoryList(req *types.CoopHistoryReq) (resp *types.Reply, err error) {
+	logx.Info(fmt.Sprintf("%+v", req))
 	resp = &types.Reply{}
 	result, size1, size2, size3, size4 := service.GetPrList(req)
 	resp.Data = map[string]interface{}{

+ 11 - 2
api/internal/logic/ignoreactionlogic.go

@@ -2,8 +2,10 @@ package logic
 
 import (
 	"app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jypkg/ent/util"
 	T "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"context"
+	"fmt"
 	"time"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
@@ -27,11 +29,18 @@ func NewIgnoreActionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Igno
 }
 
 func (l *IgnoreActionLogic) IgnoreAction(req *types.IgnoreReq) (resp *types.Reply, err error) {
+	logx.Info(fmt.Sprintf("%+v", req))
 	resp = &types.Reply{}
+	rid := ""
+	if req.Source == "2" {
+		rid = util.DecodeId(req.RelateId)
+	} else {
+		rid = req.RelateId
+	}
 	query := map[string]interface{}{
 		"position_id": req.PositionId,
 		"itype":       req.Source,
-		"relate_id":   req.RelateId,
+		"relate_id":   rid,
 	}
 	info := T.CrmMysql.FindOne("connection_status", query, "id", "")
 	if info != nil && len(*info) > 0 {
@@ -39,7 +48,7 @@ func (l *IgnoreActionLogic) IgnoreAction(req *types.IgnoreReq) (resp *types.Repl
 			"is_ignore": req.Action,
 		}
 		if req.Action == "1" {
-			update["is_handle"] = 1
+			update["is_handle"] = 0
 		}
 		b := T.CrmMysql.Update("connection_status", query, update)
 		if !b {

+ 6 - 4
api/internal/logic/infodetaillogic.go

@@ -40,16 +40,18 @@ type Infomation struct {
 }
 
 func (l *InfoDetailLogic) InfoDetail(req *types.InfoDetailReq) (resp *types.Reply, err error) {
+	logx.Info(fmt.Sprintf("%+v", req))
 	resp = &types.Reply{}
 	sql := `SELECT title, summary, content, basis, area, city, datajson_id FROM information.information WHERE id = ?`
 	info := Infomation{}
-	err = T.ClickhouseConn.QueryRow(context.TODO(), sql, req.InfoId).ScanStruct(&info)
-	if err == nil {
-		info.DataJsonId = encrypt.CommonEncodeArticle("content", info.DataJsonId)
+	row := T.ClickhouseConn.QueryRow(context.TODO(), sql, req.InfoId)
+	err1 := row.ScanStruct(&info)
+	if err1 == nil {
+		info.DataJsonId = encrypt.EncodeArticleId2ByCheck(info.DataJsonId)
 		binfo, b := T.MgoBidding.FindById("bidding", info.DataJsonId, map[string]interface{}{"title": 1, "projectname": 1})
 		if b && binfo != nil && len(*binfo) > 0 {
 			info.ProjectName = common.ObjToString((*binfo)["projectname"])
-			info.Href = fmt.Sprintf("/article/content/%s.html", encrypt.CommonEncodeArticle("content", info.DataJsonId))
+			info.Href = fmt.Sprintf("/article/content/%s.html", encrypt.EncodeArticleId2ByCheck(info.DataJsonId))
 		}
 		resp.Data = info
 	} else {

+ 2 - 0
api/internal/logic/projecthistorylogic.go

@@ -3,6 +3,7 @@ package logic
 import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
+	"fmt"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
@@ -25,6 +26,7 @@ func NewProjectHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Pr
 }
 
 func (l *ProjectHistoryLogic) ProjectHistory(req *types.PrjectHistoryReq) (resp *types.Reply, err error) {
+	logx.Info(fmt.Sprintf("%+v", req))
 	resp = &types.Reply{}
 	if req.BuyerId != "" && req.WinnerId != "" {
 		data := service.GetData3(req.BuyerId, req.WinnerId)

+ 2 - 0
api/internal/logic/projectlistlogic.go

@@ -3,6 +3,7 @@ package logic
 import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
+	"fmt"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
@@ -25,6 +26,7 @@ func NewProjectListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Proje
 }
 
 func (l *ProjectListLogic) ProjectList(req *types.ProjectListReq) (resp *types.Reply, err error) {
+	logx.Info(fmt.Sprintf("%+v", req))
 	resp = &types.Reply{}
 	list, hasNextPage, count := service.GetProjectList(req)
 	resp.Data = map[string]interface{}{

+ 2 - 0
api/internal/logic/prpnameasslogic.go

@@ -5,6 +5,7 @@ import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
 	"context"
+	"fmt"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -28,6 +29,7 @@ func NewPrPnameAssLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PrPnam
 }
 
 func (l *PrPnameAssLogic) PrPnameAss(req *types.PnameAssReq) (resp *types.Reply, err error) {
+	logx.Info(fmt.Sprintf("%+v", req))
 	resp = &types.Reply{}
 	if req.ProjectName != "" {
 		esq := `{"query": {"bool": {"must": [{"match": {"project_name.pname": "` + req.ProjectName + `" }}]}}}`

+ 14 - 14
api/internal/service/CoopHistoryService.go

@@ -9,6 +9,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/zeromicro/go-zero/core/logx"
+	"strings"
 	"time"
 )
 
@@ -18,7 +19,7 @@ var (
 	sql_2_1   = `SELECT project_id, project_name, zbtime FROM information.transaction_info WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC`
 	sql_2_2   = `select DISTINCT  b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person   from  connection_introduce a  INNER JOIN connection b on  a.position_id= ? and a.connection_id=b.id  and   a.relate_Id = ? and  a.itype =1  and  b.itype=4 and  b.status=1 `
 	sql_2_3   = `select a.a_id as a_id, a.b_id as b_id, a.a_name as a_name, a.b_name as b_name, a.code as code, c.legal_person as c_person, d.legal_person d_person from crm.ent_map_code a left join ent_info c on (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201') and a.a_id = c.id left join ent_info d on (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201') and a.b_id = d.id where (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201')`
-	es_query  = `{"query": {"bool": {"must": [{"term": {"buyer_id": "%s"}}],"must_not": {"term": {"property_form": "%s"}}}},"aggs": {"winner_count": {"terms": {"field": "winner","size": 1000,"order": {"_count": "desc"}},"aggs": {"amount_all": {"sum": {"field": "project_money"}},"ent_id": {"terms": {"field": "winner_id"}}}}},"size": 1}`
+	es_query  = `{"query": {"bool": {"must": [{"term": {"buyer_id": "%s"}}],"must_not": {"terms": {"property_form": ["%s"]}}}},"aggs": {"winner_count": {"terms": {"field": "winner","size": 1000,"order": {"_count": "desc"}},"aggs": {"amount_all": {"sum": {"field": "project_money"}},"ent_id": {"terms": {"field": "winner_id"}}}}},"size": 1}`
 	es_query1 = `{"query": {"bool": {"must": [{"term": {"buyer_id": "%s"}}]}},"aggs": {"agency_count": {"terms": {"field": "agency","size": 1000,"order": {"_count": "desc"}},"aggs": {"amount_all": {"sum": {"field": "project_money"}},"ent_id": {"terms": {"field": "agency_id"}}}}},"size": 1}`
 )
 
@@ -55,11 +56,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 	if err != nil {
 		return nil, 0, 0, 0, 0
 	}
-	propertyForm := ""
-	m1 := T.CrmMysql.FindOne("config_tenant", map[string]interface{}{"entAccountId": req.EntAccountId}, "probusfor", "")
-	if m1 != nil && len(*m1) > 0 {
-		propertyForm = common.ObjToString((*m1)["probusfor"])
-	}
+	propertyForm := T.NetworkCom.GetMyProbusfor(req.EntAccountId)
 	// firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构 sup_sub: 上下级
 	// 1、同甲异业数据/ 3、招标代理机构渠道
 	if req.ChannelType == "0" || req.ChannelType == "1" || req.ChannelType == "3" {
@@ -141,7 +138,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 	return
 }
 
-func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{}) {
+func GetData(propertyForm []string, bid string) (result1, result2 []map[string]interface{}) {
 	type AggStruct struct {
 		Buckets []struct {
 			Key        string `json:"key,omitempty"`
@@ -159,10 +156,10 @@ func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{
 	}
 	m1 := make(map[string]interface{}) //采购单位-中标单位
 	m2 := make(map[string]interface{}) //采购单位-代理机构
-	if propertyForm != "" {
+	if len(propertyForm) > 0 {
 		//同甲异态 中标企业
-		aggs, count, res := elastic.GetAggs(INDEX_1, INDEX_1, fmt.Sprintf(es_query, bid, propertyForm))
-		logx.Info("es聚合查询结果:", aggs, count, res)
+		aggs, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, fmt.Sprintf(es_query, bid, strings.Join(propertyForm, "\",\"")))
+		logx.Info("es聚合查询结果:", fmt.Sprintf(es_query, bid, strings.Join(propertyForm, "\",\"")))
 		var m1Buckets = AggStruct{}
 		if aggs != nil && aggs["winner_count"] != nil {
 			bs, err := aggs["winner_count"].MarshalJSON()
@@ -177,7 +174,7 @@ func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{
 					if len(m1Buckets.Buckets) > 0 {
 						for _, v := range m1Buckets.Buckets {
 							if v.Key != "" {
-								m1[v.Key] = map[string]interface{}{"name": v.Key, "amount": v.Amount_all.Value, "count": v.Doc_count}
+								m1[v.Key] = map[string]interface{}{"name": v.Key, "amount": v.Amount_all.Value, "count": v.Doc_count, "nameId": v.EntId.Buckets[0].Key}
 							}
 						}
 					}
@@ -188,14 +185,14 @@ func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{
 			v1 := v.(map[string]interface{})
 			tmp := make(map[string]interface{})
 			tmp["name"] = k
+			tmp["nameId"] = v1["nameId"]
 			tmp["coop_size"] = v1["count"]
 			tmp["coop_amount"] = v1["amount"]
 			result1 = append(result1, tmp)
 		}
 	}
 	//代理机构
-	aggs1, count1, res1 := elastic.GetAggs("bidding", "bidding", fmt.Sprintf(es_query1, "中国计量大学"))
-	logx.Info("es聚合查询结果:", aggs1, count1, res1)
+	aggs1, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, fmt.Sprintf(es_query1, bid))
 	var m2Buckets = AggStruct{}
 	if aggs1 != nil && aggs1["agency_count"] != nil {
 		bs, err := aggs1["agency_count"].MarshalJSON()
@@ -209,7 +206,9 @@ func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{
 				logx.Info(err)
 				if len(m2Buckets.Buckets) > 0 {
 					for _, v := range m2Buckets.Buckets {
-						m2[v.Key] = map[string]interface{}{"name": v.Key, "amount": v.Amount_all.Value, "count": v.Doc_count}
+						if v.Key != "" {
+							m2[v.Key] = map[string]interface{}{"name": v.Key, "amount": v.Amount_all.Value, "count": v.Doc_count, "nameId": v.EntId.Buckets[0].Key}
+						}
 					}
 				}
 			}
@@ -219,6 +218,7 @@ func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{
 		v1 := v.(map[string]interface{})
 		tmp := make(map[string]interface{})
 		tmp["name"] = k
+		tmp["nameId"] = v1["nameId"]
 		tmp["coop_size"] = v1["count"]
 		tmp["coop_amount"] = v1["amount"]
 		result2 = append(result2, tmp)

+ 66 - 21
api/internal/service/network.go

@@ -441,11 +441,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 					pType += ","
 				}
 				pType += vv.Type
-			}
-			if myChildIds == "" {
 				myChildIds = tempId
-			}
-			if myChildTypes == "" {
 				myChildTypes = vv.Type
 			}
 			cm := map[string]interface{}{
@@ -484,45 +480,68 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 	if in.Current_page <= 0 {
 		in.Current_page = 1
 	}
+	dbPaging := in.Buyercount_start == 0 && in.Buyercount_end == 0 && in.Monitor == 0 && in.Monitorcount_start == 0 && in.Monitorcount_end == 0 && in.Project_matchme == 0 && in.Order_amount == 0
 	sqlAppendArgs := []interface{}{}
 	sqlAppend1 := ""
-	if in.Type != "" {
+	if dbPaging && in.Type != "" {
 		sqlAppend1 += ` and a.itype=?`
 		sqlAppendArgs = append(sqlAppendArgs, n.TypeStrConvert(in.Type))
 	}
+	comSqlAppend := ""
+	comSqlArgs := []interface{}{}
 	if in.Starttime != "" {
-		sqlAppend1 += ` and a.create_time>=?`
-		sqlAppendArgs = append(sqlAppendArgs, in.Starttime+" 00:00:00")
+		comSqlAppend += ` and a.create_time>=?`
+		comSqlArgs = append(comSqlArgs, in.Starttime+" 00:00:00")
 	}
 	if in.Endtime != "" {
-		sqlAppend1 += ` and a.create_time<=?`
+		comSqlAppend += ` and a.create_time<=?`
 		if in.Starttime == in.Endtime {
 			in.Endtime += " 23:59:59"
 		} else {
 			in.Endtime += " 00:00:00"
 		}
-		sqlAppendArgs = append(sqlAppendArgs, in.Endtime)
+		comSqlArgs = append(comSqlArgs, in.Endtime)
 	}
 	if in.Name != "" {
-		sqlAppend1 += ` and a.company_name like ?`
-		sqlAppendArgs = append(sqlAppendArgs, "%"+in.Name+"%")
+		comSqlAppend += ` and a.company_name like ?`
+		comSqlArgs = append(comSqlArgs, "%"+in.Name+"%")
 	}
+	sqlAppend1 += comSqlAppend
+	sqlAppendArgs = append(sqlAppendArgs, comSqlArgs...)
 	var count int64
 	start := (in.Current_page - 1) * in.Page_size
 	end := start + in.Page_size
-	dbPaging := in.Buyercount_start == 0 && in.Buyercount_end == 0 && in.Monitor == 0 && in.Monitorcount_start == 0 && in.Monitorcount_end == 0 && in.Project_matchme == 0 && in.Order_amount == 0
 	args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
 	args = append(args, sqlAppendArgs...)
 	sqlAppend2 := ""
+	firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
 	if dbPaging {
 		newArgs := []interface{}{in.PositionId}
 		newArgs = append(newArgs, sqlAppendArgs...)
 		count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend1, newArgs...)
 		sqlAppend2 = ` limit ?,?`
 		args = append(args, start, end)
+		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...)
+		if items != nil {
+			for _, v := range *items {
+				switch Int64All(v["itype"]) {
+				case 1:
+					firstparty_count = IntAll(v["sum"])
+				case 2:
+					supplier_count = IntAll(v["sum"])
+				case 3:
+					adiffb_count = IntAll(v["sum"])
+				case 4:
+					middleman_count = IntAll(v["sum"])
+				case 5:
+					agency_count = IntAll(v["sum"])
+				}
+			}
+		}
 	}
 	//
-	firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
 	list := []*map[string]interface{}{}
 	isTjProject := true
 	probusfors := []string{}
@@ -550,7 +569,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 					}
 					jump_id += vv.CompanyId
 				}
-				firstparty_count++
 				if aio.Firstparty[v.Company_id] != nil {
 					buyer_count = aio.Firstparty[v.Company_id].BuyerCount
 					project_count = aio.Firstparty[v.Company_id].ProjectCount
@@ -562,7 +580,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				itype = "供应商"
 				jump_type = "supplier"
 				jump_id = v.Company_id
-				supplier_count++
 				if aio.Supplier[v.Company_id] != nil {
 					buyer_count = aio.Supplier[v.Company_id].BuyerCount
 					project_count = aio.Supplier[v.Company_id].ProjectCount
@@ -574,7 +591,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				itype = "同甲异业渠道"
 				jump_type = "adiffb"
 				jump_id = v.Company_id
-				adiffb_count++
 				if aio.Adiffb[v.Company_id] != nil {
 					buyer_count = aio.Adiffb[v.Company_id].BuyerCount
 					project_count = aio.Adiffb[v.Company_id].ProjectCount
@@ -586,7 +602,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				itype = "中间人"
 				jump_type = "middleman"
 				jump_id = fmt.Sprint(v.Id)
-				middleman_count++
 				buyer_count = v.Buyer_count
 				if v.Relate_buyer_id != "" {
 					for _, v := range strings.Split(v.Relate_buyer_id, ",") {
@@ -611,7 +626,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				itype = "招标代理机构"
 				jump_type = "agency"
 				jump_id = v.Company_id
-				agency_count++
 				if aio.Agency[v.Company_id] != nil {
 					buyer_count = aio.Agency[v.Company_id].BuyerCount
 					project_count = aio.Agency[v.Company_id].ProjectCount
@@ -635,9 +649,38 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 			} else if in.Project_matchme == 1 && project_count == 0 {
 				continue
 			}
+			if !dbPaging {
+				switch v.Itype {
+				case 1:
+					firstparty_count++
+				case 2:
+					supplier_count++
+				case 3:
+					adiffb_count++
+				case 4:
+					middleman_count++
+				case 5:
+					agency_count++
+				}
+				if in.Type != "" && n.TypeStrConvert(in.Type) != v.Itype {
+					continue
+				}
+			}
 			export_url := ""
 			if len(export_id) > 0 {
-				export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(strings.Join(export_id, ","))
+				exportIdRepeat := map[string]bool{}
+				exportId := ""
+				for _, v := range export_id {
+					if exportIdRepeat[v] {
+						continue
+					}
+					exportIdRepeat[v] = true
+					if exportId != "" {
+						exportId += ","
+					}
+					exportId += v
+				}
+				export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(exportId)
 			}
 			url := ""
 			if v.Qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
@@ -654,12 +697,13 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				"person":        v.Person,
 				"phone":         v.Phone,
 				"buyer_count":   buyer_count,
-				"monitor_count": 0,
+				"monitor_count": monitor_count,
 				"expect_amount": RetainDecimal(expect_amount/10000, 2),
 				"project_count": project_count,
 				"create_time":   v.Create_time,
 				"export_url":    export_url,
 				"url":           url,
+				"id":            v.Id,
 			})
 		}
 	}
@@ -809,6 +853,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
 			}
 			result[k].ProjectCount += vm[vv.CompanyId].ProjectCount
 			result[k].ProjectAmount += vm[vv.CompanyId].ProjectAmount
+			result[k].ExportId = append(result[k].ExportId, vm[vv.CompanyId].ExportId...)
 		}
 	}
 	return result
@@ -952,7 +997,7 @@ func (n *network) Introduce_Middleman(values []string, entMonitor map[string]boo
 }
 
 //
-func (n *network) TypeStrConvert(itype string) int {
+func (n *network) TypeStrConvert(itype string) int64 {
 	//firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
 	switch itype {
 	case "firstparty":

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

@@ -35,7 +35,7 @@ func initDb() {
 	es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
 	log.Println("ccccccc")
 	Mgo = MongodbSim{
-		MongodbAddr: "192.168.3.206:27080",
+		MongodbAddr: "192.168.3.149:27180",
 		Size:        2,
 		DbName:      "qfw",
 	}
@@ -106,20 +106,23 @@ func TestNetWorkList(t *testing.T) {
 	initDb()
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
 	res := Network.List(&types.NetWorkListReq{
-		PositionId:   1205591997,
+		EntAccountId: 64,
+		UserId:       "1205591997",
+		//PositionId: 1205591997,
+		PositionId: 1205592003,
+		//PositionId:   935,
 		Current_page: 1,
 		Page_size:    10,
 		//PositionId: 935,
-		//PositionId: 1205591998,
 		//Order_amount: -1,
 		// Monitorcount_start: 1,
 		// Monitorcount_end:   1,
 		//Monitor:      0,
-		//Project_matchme: 1,
+		Project_matchme: 1,
 		//Starttime: "2024-04-23",
 		//Endtime:   "2024-04-23",
-		//Type: "middleman",
-		//Name: "三亚市",
+		Type: "supplier",
+		//Name: "四川",
 	})
 	for k, v := range res.Data.(map[string]interface{}) {
 		if k == "list" {
@@ -136,9 +139,10 @@ func TestAllProject(t *testing.T) {
 	res := Network.AllProject(&types.AllprojectReq{
 		EntAccountId: 64,
 		//PositionId:   935,
-		PositionId: 1205591997,
-		//Id:         "wcj_11111111a",
-		//Type:       "firstparty",
+		PositionId: 1205591997, //刘苗
+		//PositionId: 1205592003,//刘亚丽
+		Id:   "87028422487e44e68c5531bc2c6f9528",
+		Type: "firstparty",
 	})
 	b, _ := json.Marshal(res.Data)
 	log.Println(string(b))

+ 1 - 5
api/internal/service/owner.go

@@ -1081,11 +1081,7 @@ func (t *OwnerService) CandidateChannel() ([]*ResultData, int, int, int, int) {
 	}
 	a1, a2, a3, a4 := 0, 0, 0, 0
 	if len(*dataMap) > 0 && dataMap != nil {
-		propertyForm := ""
-		m1 := CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": t.EntAccountId}, "probusfor", "")
-		if m1 != nil && len(*m1) > 0 {
-			propertyForm = common.ObjToString((*m1)["probusfor"])
-		}
+		propertyForm := NetworkCom.GetMyProbusfor(t.EntAccountId)
 		for buyerId := range *dataMap {
 			r1, r2 := GetData(propertyForm, buyerId)
 			if r1 != nil && len(r1) > 0 {

+ 47 - 39
api/internal/service/plistService.go

@@ -9,6 +9,7 @@ import (
 	"context"
 	"fmt"
 	"github.com/shopspring/decimal"
+	"strconv"
 	"strings"
 )
 
@@ -53,11 +54,15 @@ type ProjectEntry struct {
 	SourceType    string          `json:"SourceType"` // firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
 	Person        string          `json:"Person"`
 	Num           int             `json:"Num"`
-	FocusId       string          `json:"FocusId"`
+	FocusId       string          `json:"FocusId"` // 监控主键
+	IsFocus       int             `json:"IsFocus"`
 }
 
 func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasNextPage bool, total int) {
 	buyerM := BuyerList(req.PartyA, req.Supplier, req.Heterotophy, req.Intermediary, req.Agency, req.PositionId)
+	if len(*buyerM) <= 0 {
+		return []*ProjectEntry{}, false, 0
+	}
 	mmp := MonitorStatus(req.UserId) // 项目监控
 	var buyerArr []string
 	for b := range *buyerM {
@@ -77,8 +82,6 @@ func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasN
 	for rows.Next() {
 		project := ProjectEntry{}
 		_ = rows.ScanStruct(&project)
-		//project.ProjectId = encrypt.CommonEncodeArticle("content", project.ProjectId)
-		//project.ProjectId = util.EncodeId(project.ProjectId)
 		resultList = append(resultList, &project)
 	}
 
@@ -86,21 +89,24 @@ func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasN
 	if !isSqlPage {
 		total = len(resultList)
 		if total > req.PageSize {
+			hasNextPage = true
 			start := (req.PageNum - 1) * req.PageSize
-			end := start + req.PageSize
-			if req.PageNum > 1 {
-				resultList = resultList[start:end]
-			} else {
-				resultList = resultList[:req.PageSize]
+			end := req.PageNum * req.PageSize
+			if end > total {
+				end = total
+				hasNextPage = false
 			}
+			resultList = resultList[start:end]
+		} else {
+			hasNextPage = false
 		}
 	} else {
 		total = int(T.NetworkCom.Count(countSql))
-	}
-	if total > req.PageSize {
-		hasNextPage = true
-	} else {
-		hasNextPage = false
+		if total > req.PageSize {
+			hasNextPage = true
+		} else {
+			hasNextPage = false
+		}
 	}
 	moreInfo(req, resultList) //  补充信息
 
@@ -222,22 +228,25 @@ func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr []string) (cou
 // @Date 2024/4/18
 func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales, mmp map[string]interface{}, isSqlPage bool) []*ProjectEntry {
 	var newList []*ProjectEntry
-	f := make(map[string]int, 3)
-	if strings.Contains(req.SaleStatus, "1") {
+	f := make(map[string]int, 1)
+	if req.SaleStatus == "1" {
 		f["is_handle"] = 0
-	} else if strings.Contains(req.SaleStatus, "2") {
+	} else if req.SaleStatus == "2" {
 		f["is_ignore"] = 1
-	} else if strings.Contains(req.SaleStatus, "3") {
+	} else if req.SaleStatus == "3" {
 		f["is_create"] = 1
 	}
 	for _, m := range resultList {
+		// 处理/忽略/销售机会
 		if m1, ok := preSales[m.ProjectId].(map[string]interface{}); ok {
+			m.IsIgnore = common.IntAll(m1["is_handle"])
 			m.IsIgnore = common.IntAll(m1["is_ignore"])
 			m.IsCreate = common.IntAll(m1["is_create"])
 		}
+		// 监控
 		for _, s := range strings.Split(m.InfoId, ",") {
 			if mmp[s] != nil {
-				m.IsHandle = 1
+				m.IsFocus = 1
 				m.FocusId = common.ObjToString(mmp[s])
 				break
 			}
@@ -246,13 +255,10 @@ func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales,
 			for k, v := range f {
 				if k == "is_handle" && m.IsHandle == v {
 					newList = append(newList, m)
-					break
 				} else if k == "is_ignore" && m.IsIgnore == v {
 					newList = append(newList, m)
-					break
 				} else if k == "is_create" && m.IsCreate == v {
 					newList = append(newList, m)
-					break
 				}
 			}
 		}
@@ -278,24 +284,26 @@ func moreInfo(req *types.ProjectListReq, list []*ProjectEntry) (result []*Projec
 		}
 	}
 	countMap := make(map[string]int)
-	str1, arr1 := common.WhArgs(buyerIds)
-	info1, err := T.ClickhouseConn.Query(context.TODO(), fmt.Sprintf(sql_1, str1), arr1...)
-	if err == nil {
-		for info1.Next() {
-			var buyerId string
-			var count uint64
-			_ = info1.Scan(&buyerId, &count)
-			countMap[buyerId] = int(count)
-		}
-	}
-	info2 := T.CrmMysql.SelectBySql(fmt.Sprintf(sql_3, str1), arr1...)
 	connMap := make(map[string]int)
-	if info2 != nil && len(*info2) > 0 {
-		for _, m := range *info2 {
-			if req.PositionId == common.Int64All(m["position_id"]) {
-				connMap[common.ObjToString(m["company_id"])] = 1 // 我的人脉
-			} else {
-				connMap[common.ObjToString(m["company_id"])] = 2
+	if buyerIds != nil && len(buyerIds) > 0 {
+		str1, arr1 := common.WhArgs(buyerIds)
+		info1, err := T.ClickhouseConn.Query(context.TODO(), fmt.Sprintf(sql_1, str1), arr1...)
+		if err == nil {
+			for info1.Next() {
+				var buyerId string
+				var count uint64
+				_ = info1.Scan(&buyerId, &count)
+				countMap[buyerId] = int(count)
+			}
+		}
+		info2 := T.CrmMysql.SelectBySql(fmt.Sprintf(sql_3, str1), arr1...)
+		if info2 != nil && len(*info2) > 0 {
+			for _, m := range *info2 {
+				if req.PositionId == common.Int64All(m["position_id"]) {
+					connMap[common.ObjToString(m["company_id"])] = 1 // 我的人脉
+				} else {
+					connMap[common.ObjToString(m["company_id"])] = 2
+				}
 			}
 		}
 	}
@@ -378,7 +386,7 @@ func MonitorStatus(uid string) map[string]interface{} {
 	m1 := make(map[string]interface{})
 	info := T.BaseMysql.SelectBySql(sql_4, uid)
 	for _, m := range *info {
-		m1[common.ObjToString(m["s_id"])] = util.EncodeId(common.ObjToString(m["id"]))
+		m1[common.ObjToString(m["s_id"])] = util.EncodeId(strconv.Itoa(common.IntAll(m["id"])))
 	}
 	return m1
 }