|
@@ -15,7 +15,7 @@ import (
|
|
|
var (
|
|
|
INDEX_1 = "transaction_info"
|
|
|
sql_2_0 = `SELECT buyer, buyer_id, agency, agency_id, property_form FROM information.transaction_info WHERE project_id = ?`
|
|
|
- sql_2_1 = `SELECT project_id, project_name, zbtime FROM information.transaction_info WHERE buyer_id = ? AND has(winner_id, ?) ORDER BY zbtime DESC`
|
|
|
+ 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": "%s"}}],"must_not": {"term": {"property_form": "%s"}}}},"aggs": {"winner_count": {"terms": {"field": "winner","size": 1000,"order": {"_count": "desc"}},"aggs": {"amount_all": {"sum": {"field": "bidamount"}}}}},"size": 1}`
|
|
@@ -44,12 +44,13 @@ type ProjectTmp struct {
|
|
|
PropertyForm []string `ch:"property_form"`
|
|
|
}
|
|
|
|
|
|
-func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2, size_3, size_4 int64) {
|
|
|
+func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2, size_3, size_4 int64, bid string) {
|
|
|
pTmp := ProjectTmp{}
|
|
|
err := T.ClickhouseConn.QueryRow(context.TODO(), sql_2_0, req.Pid).ScanStruct(&pTmp)
|
|
|
if err != nil {
|
|
|
- return nil, 0, 0, 0, 0
|
|
|
+ return nil, 0, 0, 0, 0, ""
|
|
|
}
|
|
|
+ bid = pTmp.BuyerId
|
|
|
propertyForm := ""
|
|
|
m1 := T.CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": req.EntAccountId}, "probusfor", "")
|
|
|
if m1 != nil && len(*m1) > 0 {
|
|
@@ -62,7 +63,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
|
|
|
if (req.ChannelType == "0" || req.ChannelType == "1") && r1 != nil && len(r1) > 0 {
|
|
|
size_1 = int64(len(r1))
|
|
|
for _, m := range r1 {
|
|
|
- near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
|
|
|
+ near, zbtime := LastTimeCoop(bid, common.ObjToString(m["name"]), "adiffb")
|
|
|
tmp := ResultData{
|
|
|
SourceType: "adiffb",
|
|
|
EntName: common.ObjToString(m["name"]),
|
|
@@ -77,7 +78,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
|
|
|
if req.ChannelType == "0" || req.ChannelType == "3" && r2 != nil && len(r2) > 0 {
|
|
|
size_3 = int64(len(r2))
|
|
|
for _, m := range r2 {
|
|
|
- near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
|
|
|
+ near, zbtime := LastTimeCoop(bid, common.ObjToString(m["name"]), "agency")
|
|
|
tmp := ResultData{
|
|
|
SourceType: "agency",
|
|
|
EntName: common.ObjToString(m["name"]),
|
|
@@ -94,7 +95,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
|
|
|
if req.ChannelType == "0" || req.ChannelType == "4" {
|
|
|
// 中间人可介绍业主
|
|
|
var r3 []map[string]interface{}
|
|
|
- r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, req.PositionId, r3)
|
|
|
+ r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", bid)}, req.PositionId, r3)
|
|
|
if r3 != nil && len(r3) > 0 {
|
|
|
for _, m := range r3 {
|
|
|
size_4 = int64(len(r3))
|
|
@@ -111,7 +112,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
|
|
|
if req.ChannelType == "0" || req.ChannelType == "2" {
|
|
|
// 关联单位
|
|
|
var r4 []map[string]interface{}
|
|
|
- r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, r4)
|
|
|
+ r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", bid)}, r4)
|
|
|
if r4 != nil && len(r4) > 0 {
|
|
|
size_2 = int64(len(r4))
|
|
|
for _, m := range r4 {
|