Browse Source

Merge branch 'dev_v4.8.92_wh' of qmx/jy into master

王浩 1 year ago
parent
commit
f2f15645fb

+ 41 - 7
src/jfw/modules/bigmember/src/entity/report.go

@@ -9,7 +9,9 @@ import (
 )
 
 const (
-	TableMemberReportProject = "member_report_project" // 大会员周报月报-项目明细表
+	TableMemberReportProject    = "member_report_project" // 大会员周报月报-项目明细表
+	From                        = "yyszsyy"
+	TableMemberReportProjectYys = "member_report_project_yys" // 大会员周报月报-项目明细表
 )
 
 type ReportProjectInfoParam struct {
@@ -24,6 +26,7 @@ type ReportProjectInfoParam struct {
 	End        int                 `json:"end"`        // 结束时间
 	PageSize   int                 `json:"pageSize"`   // 默认每页10条
 	PageNum    int                 `json:"pageNum"`    // 默认当前第一页
+	From       string              `json:"from"`       // 来源
 }
 
 // GetReportProjectInfo 周报/月报查询项目明细
@@ -103,7 +106,11 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
 	}
 	q += strings.Join(qstr, " and ")
 	// 查询数量
-	CountQuery := fmt.Sprintf("select count(1) from %s where position_id=? and start_time>=? and end_time<=? %s ", TableMemberReportProject, q)
+	table := TableMemberReportProject
+	if param.From == From {
+		table = TableMemberReportProjectYys
+	}
+	CountQuery := fmt.Sprintf("select count(1) from %s where position_id=? and start_time>=? and end_time<=? %s ", table, q)
 	total = db.Base.CountBySql(CountQuery, values...)
 	if total == 0 {
 		return data, 0
@@ -112,7 +119,7 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
 	if param.Sort == 1 {
 		orderby = " (if(bidamount >0,bidamount,budget)) desc,id desc"
 	}
-	query := fmt.Sprintf("select * from %s where position_id=? and start_time>=? and end_time<=? %s  order by  %s   limit %d,%d", TableMemberReportProject, q, orderby, (param.PageNum-1)*param.PageSize, param.PageSize)
+	query := fmt.Sprintf("select * from %s where position_id=? and start_time>=? and end_time<=? %s  order by  %s   limit %d,%d", table, q, orderby, (param.PageNum-1)*param.PageSize, param.PageSize)
 	rs := db.Base.SelectBySql(query, values...)
 	if rs != nil && len(*rs) > 0 {
 		data = *rs
@@ -143,8 +150,10 @@ func ReportProjectInfoFormat(data []map[string]interface{}) []map[string]interfa
 		tmp["area"] = data[i]["area"]
 		tmp["bidStatus"] = data[i]["bidstatus"]
 		tmp["buyerClass"] = data[i]["buyerclass"]
+		tmp["subscopeclass"] = data[i]["subscopeclass"]
 		tmp["bidAmount"] = data[i]["bidamount"]
 		tmp["budget"] = data[i]["budget"]
+		tmp["item"] = data[i]["items"]
 		tmp["buyer"] = data[i]["buyer"]
 		tmp["lastTime"] = data[i]["last_time"]
 		rs = append(rs, tmp)
@@ -153,8 +162,12 @@ func ReportProjectInfoFormat(data []map[string]interface{}) []map[string]interfa
 }
 
 // ReportGetArea 周报月报获取当前订阅地区
-func ReportGetArea(positionId, start, end int64) map[string]interface{} {
-	q := "SELECT area,group_concat(distinct(city)) as city from " + TableMemberReportProject + " where position_id =? and start_time >=? and end_time<=? and area!='全国' group by area;"
+func ReportGetArea(positionId, start, end int64, from string) map[string]interface{} {
+	table := TableMemberReportProject
+	if from == From {
+		table = TableMemberReportProjectYys
+	}
+	q := "SELECT area,group_concat(distinct(city)) as city from " + table + " where position_id =? and start_time >=? and end_time<=? and area!='全国' group by area;"
 	rs := db.Base.SelectBySql(q, positionId, start, end)
 	areaMap := map[string]interface{}{}
 	if rs != nil && len(*rs) > 0 {
@@ -177,9 +190,13 @@ func ReportGetArea(positionId, start, end int64) map[string]interface{} {
 }
 
 // ReportGetBuyerClass 周报月报获取当前采购单位类型
-func ReportGetBuyerClass(positionId, start, end int64) []string {
+func ReportGetBuyerClass(positionId, start, end int64, from string) []string {
 	buyerClass := []string{}
-	q := "select distinct(buyerclass) from " + TableMemberReportProject + " where position_id =? and start_time >=? and end_time<=?  order by buyerclass "
+	table := TableMemberReportProject
+	if from == From {
+		table = TableMemberReportProjectYys
+	}
+	q := "select distinct(buyerclass) from " + table + " where position_id =? and start_time >=? and end_time<=?  order by buyerclass "
 	rs := db.Base.SelectBySql(q, positionId, start, end)
 	if rs != nil && len(*rs) > 0 {
 		for i := 0; i < len(*rs); i++ {
@@ -189,6 +206,23 @@ func ReportGetBuyerClass(positionId, start, end int64) []string {
 	return buyerClass
 }
 
+// ReportGetIndustry 周报月报获取当前行业
+func ReportGetIndustry(positionId, start, end int64, from string) []string {
+	subscopeclass := []string{}
+	table := TableMemberReportProject
+	if from == From {
+		table = TableMemberReportProjectYys
+	}
+	q := "select distinct(subscopeclass) from " + table + " where position_id =? and start_time >=? and end_time<=?  order by subscopeclass "
+	rs := db.Base.SelectBySql(q, positionId, start, end)
+	if rs != nil && len(*rs) > 0 {
+		for i := 0; i < len(*rs); i++ {
+			subscopeclass = append(subscopeclass, common.ObjToString((*rs)[i]["subscopeclass"]))
+		}
+	}
+	return subscopeclass
+}
+
 // GetMainPositionId 根据用户id获取主账号的职位id
 func GetMainPositionId(mgoUserId string) (positionId int64) {
 	// 1. 查主账号的base_user_id

+ 72 - 40
src/jfw/modules/bigmember/src/service/report/report.go

@@ -3,6 +3,7 @@ package report
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/modules/bigmember/src/config"
 	. "jy/src/jfw/modules/bigmember/src/db"
 	"jy/src/jfw/modules/bigmember/src/entity"
@@ -57,8 +58,10 @@ func (s BarCharts) Swap(i, j int) {
 const (
 	oneday                                       = 86400
 	pushspace_experience_member_statistic        = "pushspace_experience_member_statistic"
-	pushspace_experience_member_statistic_winner = "pushspace_experience_member_statistic_winner"
+	From                                         = "yyszsyy"
 	pushspace_member_statistic                   = "pushspace_member_statistic"
+	pushspace_member_statistic_yys               = "pushspace_member_statistic_yys"
+	pushspace_experience_member_statistic_winner = "pushspace_experience_member_statistic_winner"
 	pushspace_member_statistic_winner            = "pushspace_member_statistic_winner"
 	C_User                                       = "user"
 	C_Entniche_Rule                              = "entniche_rule"
@@ -69,8 +72,9 @@ func (r *Report) Index() {
 		return
 	}
 	ym := r.GetString("ym")
+	from := r.GetString("from")
 	result := M{}
-	userId, qk, qv := getQuery(r.Session())
+	userId, qk, qv := getQuery(r.Session(), from)
 	if qk == "" || qv == nil {
 		return
 	}
@@ -95,7 +99,11 @@ func (r *Report) Index() {
 		R.InvalidReqParam(r.ResponseWriter, r.Request, "ym")
 		return
 	}
-	list, ok := Mgo.Find(pushspace_member_statistic, query, `{"startdate":-1}`, `{"startdate":1,"enddate":1,"pushcount":1,"pushtime":1,"unread":1}`, false, -1, -1)
+	table := pushspace_member_statistic
+	if from == From {
+		table = pushspace_member_statistic_yys
+	}
+	list, ok := Mgo.Find(table, query, `{"startdate":-1}`, `{"startdate":1,"enddate":1,"pushcount":1,"pushtime":1,"unread":1}`, false, -1, -1)
 	array := []map[string]interface{}{}
 	if ok && list != nil {
 		for _, v := range *list {
@@ -110,34 +118,38 @@ func (r *Report) Index() {
 	}
 	result["list"] = array
 	result["subscribe"] = false
-	o_mb := &map[string]interface{}{}
-	user := config.Compatible.Select(userId, `{"o_member_jy":1,"i_member_status":1,"s_member_mainid":1,"i_member_sub_status":1}`)
-	if user != nil {
-		if s_member_mainid := qutil.ObjToString((*user)["s_member_mainid"]); s_member_mainid != "" && qutil.IntAll((*user)["i_member_sub_status"]) == 1 && qutil.IntAll((*user)["i_member_status"]) > 0 {
-			user, ok = Mgo.FindById("user", s_member_mainid, `{"o_member_jy":1}`)
+	if from != From {
+		o_mb := &map[string]interface{}{}
+		user := config.Compatible.Select(userId, `{"o_member_jy":1,"i_member_status":1,"s_member_mainid":1,"i_member_sub_status":1}`)
+		if user != nil {
+			if s_member_mainid := qutil.ObjToString((*user)["s_member_mainid"]); s_member_mainid != "" && qutil.IntAll((*user)["i_member_sub_status"]) == 1 && qutil.IntAll((*user)["i_member_status"]) > 0 {
+				user, ok = Mgo.FindById("user", s_member_mainid, `{"o_member_jy":1}`)
+			}
 		}
-	}
-	if ok && o_mb != nil {
-		o_member_jy, _ := (*o_mb)["o_member_jy"].(map[string]interface{})
-		if o_member_jy["a_infotype"] != nil || o_member_jy["o_area"] != nil || o_member_jy["a_buyerclass"] != nil {
-			result["subscribe"] = true
-		} else {
-			a_items, _ := o_member_jy["a_items"].([]interface{})
-		L:
-			for _, a_item := range a_items {
-				itemMap, _ := a_item.(map[string]interface{})
-				a_keys, _ := itemMap["a_key"].([]interface{})
-				for _, a_key := range a_keys {
-					keyMap, _ := a_key.(map[string]interface{})
-					keys, _ := keyMap["key"].([]interface{})
-					for _, key := range keys {
-						if strings.TrimSpace(qutil.ObjToString(key)) != "" {
-							result["subscribe"] = true
-							break L
+		if ok && o_mb != nil {
+			o_member_jy, _ := (*o_mb)["o_member_jy"].(map[string]interface{})
+			if o_member_jy["a_infotype"] != nil || o_member_jy["o_area"] != nil || o_member_jy["a_buyerclass"] != nil {
+				result["subscribe"] = true
+			} else {
+				a_items, _ := o_member_jy["a_items"].([]interface{})
+			L:
+				for _, a_item := range a_items {
+					itemMap, _ := a_item.(map[string]interface{})
+					a_keys, _ := itemMap["a_key"].([]interface{})
+					for _, a_key := range a_keys {
+						keyMap, _ := a_key.(map[string]interface{})
+						keys, _ := keyMap["key"].([]interface{})
+						for _, key := range keys {
+							if strings.TrimSpace(qutil.ObjToString(key)) != "" {
+								result["subscribe"] = true
+								break L
+							}
 						}
 					}
 				}
 			}
+		} else {
+			result["subscribe"] = true
 		}
 	}
 	r.ServeJson(Result{
@@ -150,12 +162,13 @@ func (r *Report) Detail() {
 	}
 	start, _ := r.GetInt("start")
 	end, _ := r.GetInt("end")
+	from := r.GetString("from")
 	var m M
-	userId, qk, qv := getQuery(r.Session())
+	userId, qk, qv := getQuery(r.Session(), from)
 	if qk == "" || qv == nil {
 		return
 	}
-	coll, coll_winner := getColl(r.Header("referer"), r.GetString("type"))
+	coll, coll_winner := getColl(r.Header("referer"), r.GetString("type"), from)
 	// userId, _, _ = MainUserId(userId, "", 0)
 	if end-start == 518400 { //周
 		m = weekResult(qk, qv, start, end, coll, coll_winner)
@@ -184,10 +197,13 @@ func (r *Report) Detail() {
 		positionId = mainPositionId
 	}
 	// 省份
-	m["area"] = entity.ReportGetArea(positionId, start, end)
+	m["area"] = entity.ReportGetArea(positionId, start, end, from)
 	// 采购单位类型
-	m["buyerClass"] = entity.ReportGetBuyerClass(positionId, start, end)
+	m["buyerClass"] = entity.ReportGetBuyerClass(positionId, start, end, from)
 	m["isNewData"] = isNewData
+	if from == From {
+		m["industry"] = entity.ReportGetIndustry(positionId, start, end, from)
+	}
 	r.ServeJson(Result{
 		Data: m,
 	})
@@ -252,7 +268,7 @@ func weekResult(qk string, qv interface{}, start, end int64, coll, coll_winner s
 			"$lte": end,
 		},
 		"type": 2,
-	}, `{"startdate":1}`, `{"startdate":1,"type":1,"item":1,"bidamount":1,"budget":1,"zhao_matchitem":1,"zhong_matchitem":1,"follow_project":1,"follow_ent":1,"nextweek_bidopen":1,"project_amount":1}`, false, 0, 2)
+	}, `{"startdate":1}`, `{"startdate":1,"type":1,"item":1,"industry":1,bidamount":1,"budget":1,"zhao_matchitem":1,"zhong_matchitem":1,"follow_project":1,"follow_ent":1,"nextweek_bidopen":1,"project_amount":1}`, false, 0, 2)
 	result := M{}
 	prevWeek := map[string]interface{}{}
 	if ok && list != nil {
@@ -263,6 +279,8 @@ func weekResult(qk string, qv interface{}, start, end int64, coll, coll_winner s
 			}
 			//订阅关键词组
 			result["item"] = v["item"]
+			//行业
+			result["industry"] = v["industry"]
 			//本周新增招标项目数量
 			result["zhao_matchitem"] = v["zhao_matchitem"]
 			//本周新增开标项目数量
@@ -298,7 +316,7 @@ func monthResult(userId, qk string, qv interface{}, start, end int64, coll, coll
 		"enddate": map[string]interface{}{
 			"$lte": end,
 		},
-	}, `{"startdate":1}`, `{"startdate":1,"item":1,"project_matchitem_count":1,"project_matchitem_bidamount":1,"project_count":1,"project_bidamount_count":1,"project_area_count":1,"project_area_bidamount":1,"project_buyerclass_count":1,"project_buyerclass_bidamount":1,"project_buyerclass_average_bidamount":1,"winner_area":1,"buyer":1,"winner":1,"project_bidamount":1,"winner_capital_array":1,"winner_project":1}`, false, -1, -1)
+	}, `{"startdate":1}`, `{"startdate":1,"item":1,"industry":1,project_matchitem_count":1,"project_matchitem_bidamount":1,"project_count":1,"project_bidamount_count":1,"project_area_count":1,"project_area_bidamount":1,"project_buyerclass_count":1,"project_buyerclass_bidamount":1,"project_buyerclass_average_bidamount":1,"winner_area":1,"buyer":1,"winner":1,"project_bidamount":1,"winner_capital_array":1,"winner_project":1}`, false, -1, -1)
 	if ok && sixDatas != nil {
 		project_count := &BarCharts{
 			Keys: map[int64]bool{},
@@ -315,6 +333,8 @@ func monthResult(userId, qk string, qv interface{}, start, end int64, coll, coll
 			} else if startdate == start { //本月
 				//订阅关键词组
 				result["item"] = v["item"]
+				//行业
+				result["industry"] = v["industry"]
 				//本月项目规模
 				result["project_matchitem_count"] = v["project_matchitem_count"]
 				//本月项目规模
@@ -514,7 +534,7 @@ func getGrowthRate(v1, v2 float64) float64 {
 }
 
 func (r *Report) Tip() {
-	_, qk, qv := getQuery(r.Session())
+	_, qk, qv := getQuery(r.Session(), "")
 	if qk == "" || qv == nil {
 		return
 	}
@@ -535,7 +555,7 @@ func (r *Report) Tip() {
 	r.ServeJson(result)
 }
 func (r *Report) Tipover() {
-	_, qk, qv := getQuery(r.Session())
+	_, qk, qv := getQuery(r.Session(), "")
 	if qk == "" || qv == nil {
 		return
 	}
@@ -553,7 +573,7 @@ func tipover(qk string, qv interface{}, coll string) bool {
 	}, false, true)
 }
 func (r *Report) Openpushmsg() error {
-	userId, qk, qv := getQuery(r.Session())
+	userId, qk, qv := getQuery(r.Session(), "")
 	pushcount, _ := r.GetInteger("pushcount")
 	positionType := qutil.Int64All(r.GetSession("positionType"))
 	start, _ := r.GetInt("start")
@@ -582,12 +602,17 @@ func (r *Report) Openpushmsg() error {
 }
 
 func (r *Report) Starttime() {
-	_, qk, qv := getQuery(r.Session())
+	from := r.GetString("from")
+	_, qk, qv := getQuery(r.Session(), from)
 	if qk == "" || qv == nil {
 		return
 	}
+	table := pushspace_member_statistic
+	if from == From {
+		table = pushspace_member_statistic_yys
+	}
 	week_start, month_start := 0, 0
-	week_list, _ := Mgo.Find(pushspace_member_statistic, map[string]interface{}{
+	week_list, _ := Mgo.Find(table, map[string]interface{}{
 		qk:     qv,
 		"type": 2,
 	}, `{"enddate":1}`, `{"enddate":1,"dateym":1}`, false, 0, 1)
@@ -598,7 +623,7 @@ func (r *Report) Starttime() {
 		}
 	}
 	//
-	month_list, _ := Mgo.Find(pushspace_member_statistic, map[string]interface{}{
+	month_list, _ := Mgo.Find(table, map[string]interface{}{
 		qk:     qv,
 		"type": 3,
 	}, `{"enddate":1}`, `{"enddate":1,"dateym":1}`, false, 0, 1)
@@ -616,10 +641,14 @@ func (r *Report) Starttime() {
 	})
 }
 
-func getColl(referer, t string) (string, string) {
+func getColl(referer, t, from string) (string, string) {
 	if t == "free" || strings.Contains(referer, "t=wx_experience") || strings.Contains(referer, "t=app_experience") {
+
 		return pushspace_experience_member_statistic, pushspace_experience_member_statistic_winner
 	} else {
+		if from == From {
+			return pushspace_member_statistic_yys, pushspace_member_statistic_winner
+		}
 		return pushspace_member_statistic, pushspace_member_statistic_winner
 	}
 }
@@ -633,9 +662,12 @@ func isFree(userId string, positionType int64, session *httpsession.Session) boo
 	return false
 }
 
-func getQuery(sess *httpsession.Session) (string, string, interface{}) {
+func getQuery(sess *httpsession.Session, from string) (string, string, interface{}) {
 	sessMap := sess.GetMultiple()
 	userId := qutil.ObjToString(sessMap["userId"])
+	if from == From {
+		return userId, "userid", gconv.String(sessMap["positionId"])
+	}
 	if qutil.IntAll(sessMap["positionType"]) == 1 {
 		return userId, "ent_userid", qutil.IntAll(sessMap["entUserId"])
 	} else {