Forráskód Böngészése

商机管理导出

WH01243 2 éve
szülő
commit
4ed8bdfde8

+ 3 - 3
src/entnichePc.json

@@ -1,4 +1,4 @@
 {
-	"entnichePcUser": [14595,442,1686,1685,1711,674],
-	"hideEntnicheMenu": [1711,442]
-}
+  "entnichePcUser": [14776,14781,14766,14659,14682,14680,14677,2090,14668,14667,14665,14663,14660,14648,14650,14652,14645,14643,14640,14631,14628,14636,14560,14559,14543,2109,2108,2107,1947,1927,2044,700,14544,377,14563,14564],
+  "hideEntnicheMenu": [2109]
+}

+ 40 - 36
src/jfw/modules/common/src/qfw/util/jy/entnichepush.go

@@ -14,6 +14,7 @@ import (
 	"qfw/util/redis"
 	"strings"
 	"time"
+	util2 "util"
 
 	"go.mongodb.org/mongo-driver/bson/primitive"
 )
@@ -219,15 +220,15 @@ func (e *entnichePush) GetCache(code, key string) ([]*SubPushList, error) {
 	return p, nil
 }
 
-func (e *entnichePush) NewDatas(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, PushMysql *mysql.Mysql, entId, userId int, pageNum int, selectTime, area, buyerclass string, isEnt bool, url string) (hasNextPage bool, result []map[string]interface{}, allCount int) {
+func (e *entnichePush) NewDatas(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, PushMysql *mysql.Mysql, entId, userId int, pageNum int, selectTime, area, buyerclass string, isEnt bool, url string, pageSize int) (hasNextPage bool, result []map[string]interface{}, allCount int) {
 	if pageNum < 1 {
 		pageNum = 1
 	}
-	result, allCount = e.newGetDatasFromMysql(Mgo_bidding, bidding, bidding_back, PushMysql, entId, userId, pageNum, pageSizes, selectTime, area, buyerclass, true, isEnt, url)
+	result, allCount = e.newGetDatasFromMysql(Mgo_bidding, bidding, bidding_back, PushMysql, entId, userId, pageNum, pageSize, selectTime, area, buyerclass, true, isEnt, url)
 	if result == nil {
 		result = []map[string]interface{}{}
 	}
-	hasNextPage = len(result) >= pageSizes
+	hasNextPage = len(result) >= pageSize
 	return
 }
 
@@ -313,61 +314,64 @@ func (e *entnichePush) newGetDatasFromMysql(Mgo_bidding mg.MongodbSim, bidding,
 func (e *entnichePush) newGetExportDatasFromMysql(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, PushMysql *mysql.Mysql, entId, userId int, pageNum, myPageSize int, selectTime, area, buyerclass string, isLimit bool, isEnt bool, maxCount int, url string) (result []map[string]interface{}, counts, secondCount int) {
 	findSQL := ""
 	countSQL := ""
+	querys := []string{}
 	if isEnt {
-		findSQL = "select id,date,infoid,buyerclass,isvisit,matchkeys,type,1 as isvip from pushentniche where entid=" + fmt.Sprint(entId)
-		countSQL = "select count(1) from pushentniche where entid=" + fmt.Sprint(entId)
+		querys = []string{fmt.Sprintf("a.entid='%s'", entId)}
 	} else {
-		findSQL = "select id,date,infoid,buyerclass,isvisit,matchkeys,type,1 as isvip from pushentniche where entid=" + fmt.Sprint(entId) + " and userid=" + fmt.Sprint(userId)
-		countSQL = "select count(1) from pushentniche where entid=" + fmt.Sprint(entId) + " and userid=" + fmt.Sprint(userId)
+		querys = []string{fmt.Sprintf("a.userid='%s'", fmt.Sprint(userId))}
+
 	}
-	findStr := ""
 	if selectTime != "" {
 		times := strings.Split(selectTime, "_")
 		startTime := times[0][0:10]
 		endTime := times[1][0:10]
-		findStr += " and date < " + endTime + " and date >= " + startTime
+		//findStr += " and date < " + endTime + " and date >= " + startTime
+		querys = append(querys, fmt.Sprintf("a.date>=%d and date<=%d", startTime, endTime))
 	}
 	if area != "" {
 		var _area = ""
+		city := []string{}
 		for _, v := range strings.Split(area, ",") {
-			if v == "全部" {
-				continue
-			}
-			if _area != "" {
-				_area += ","
+			if util2.PushMapping.City[v] != "" {
+				city = append(city, fmt.Sprint(util2.PushMapping.City[v]))
+			} else {
+				city = append(city, "-1")
 			}
-			_area += fmt.Sprint(PushMapping.City[v])
 		}
-		if strings.Contains(_area, ",") {
-			findStr += " and city in (" + _area + ")"
-		} else if len(strings.Split(_area, ",")) == 1 {
-			_area += ",9999" //多个in操作 比直接=查询更快
-			findStr += " and city in (" + _area + ")"
+		if len(city) == 1 {
+			city = append(city, "9999")
+		}
+		if len(city) > 0 {
+			_area = fmt.Sprintf("b.city_code in (%s)", strings.Join(city, ","))
+		}
+		if _area != "" {
+			_area = "( " + _area + " )"
+		}
+		if _area != "" {
+			querys = append(querys, _area)
 		}
 	}
 	if buyerclass != "" {
-		findStr += " and buyerclass in ("
-		var _buyerclass = ""
+		buyerclassArr := []string{}
 		for _, v := range strings.Split(buyerclass, ",") {
-			if v == "全部" {
-				continue
+			if util2.PushMapping.Buyerclass[v] != "" {
+				buyerclassArr = append(buyerclassArr, fmt.Sprint(util2.PushMapping.Buyerclass[v]))
 			}
-			if _buyerclass != "" {
-				_buyerclass += ","
-			}
-			_buyerclass += fmt.Sprint(PushMapping.Buyerclass[v])
 		}
-		findStr += _buyerclass + ")"
-	}
-	countSQL = countSQL + findStr
-	start := (pageNum - 1) * myPageSize
-	findStr += " order by id desc"
-	if isLimit {
-		findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(myPageSize)
+		if len(buyerclassArr) == 1 {
+			buyerclassArr = append(buyerclassArr, "9999")
+		}
+		if len(buyerclassArr) > 0 {
+			querys = append(querys, fmt.Sprintf("b.buyerclass_code in (%s)", strings.Join(buyerclassArr, ",")))
+		}
 	}
-	findSQL = findSQL + findStr
+	searchSql := fmt.Sprintf(" from %s  a LEFT JOIN %s b ON a.infoid = b.infoid LEFT JOIN %s t on t.infoid = b.infoid and t.labelcode=2  where %s"+
+		" order by a.id desc", util2.PushEntniche, util2.Baseinfo, util2.BidTags, strings.Join(querys, " and "))
+	countSQL = fmt.Sprintf("select count(a.id)" + searchSql)
 	count := PushMysql.CountBySql(countSQL)
 	counts = int(count)
+	findSQL = "select a.id"
+	findSQL += searchSql
 	list := &[]map[string]interface{}{}
 	log.Println("counts ", counts)
 	if counts > 0 {