Browse Source

Merge branch 'dev/v4.8.26_fuwencai' of http://192.168.3.207:8080/qmx/jy into dev/v4.8.26_fuwencai

wangshan 2 years ago
parent
commit
00f84f2672

+ 2 - 1
src/jfw/modules/bigmember/src/config.json

@@ -181,5 +181,6 @@
     "listPage": "https://databi-web.jydev.jianyu360.com/nzj/app/nzj.app/nzj_claim.spg"
   },
   "contextOldVipLimit": 1664553600,
-  "potentialCount": 1000
+  "potentialCount": 1000,
+  "newDataTime": 1685606275
 }

+ 1 - 0
src/jfw/modules/bigmember/src/config/config.go

@@ -67,6 +67,7 @@ type config struct {
 	} `json:"claim"`
 	ContextOldVipLimit int64 `json:"contextOldVipLimit"` //超级订阅部分用户:--- 超前项目权限
 	PotentialCount     int   `json:"potentialCount"`     //潜在客户 潜在竞争对手数据量
+	NewDataTime        int64 `json:"newDataTime"`        // 用于周边月报区分是否为新数据 、配置为p350发版的时间
 }
 
 type CustomerInfo struct {

+ 150 - 0
src/jfw/modules/bigmember/src/entity/report.go

@@ -0,0 +1,150 @@
+package entity
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"fmt"
+	"jy/src/jfw/modules/bigmember/src/db"
+	"strings"
+)
+
+const (
+	TableMemberReportProject = "member_report_project" // 大会员周报月报-项目明细表
+)
+
+type ReportProjectInfoParam struct {
+	Items      []string            `json:"items"`      // 订阅关键词组
+	Area       map[string][]string `json:"area"`       // 省份城市
+	Industry   []string            `json:"industry"`   // 行业
+	Buyerclass []string            `json:"buyerclass"` // 采购单位类型
+	Buyer      string              `json:"buyer"`      // 采购单位
+	Winner     string              `json:"winner"`     // 中标单位
+	Sort       int                 `json:"sort"`       // 排序默认0:成交时间倒序;1:项目金额倒序
+	Start      int                 `json:"start"`      // 开始时间
+	End        int                 `json:"end"`        // 结束时间
+	PageSize   int                 `json:"pageSize"`   // 默认每页10条
+	PageNum    int                 `json:"pageNum"`    // 默认当前第一页
+}
+
+// GetReportProjectInfo 周报/月报查询项目明细
+func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data []map[string]interface{}, total int64) {
+	data = []map[string]interface{}{}
+	// 处理查询条件
+	q := ""
+	values := []interface{}{positionId, param.Start, param.End} // 用于最后sql查询传的值
+	qstr := []string{}                                          // 用于后边拼接查询条件
+	if param.Items != nil && len(param.Items) > 0 {
+		tmpArr := []string{}
+		for i := 0; i < len(param.Items); i++ {
+			tmpArr = append(tmpArr, "find_in_set(?,items)")
+			values = append(values, param.Items[i])
+		} // 关键词组
+		qstr = append(qstr, fmt.Sprintf("(%s)", strings.Join(tmpArr, " or ")))
+	}
+	// 省份
+	if param.Area != nil && len(param.Area) > 0 {
+		area, city := []interface{}{}, []interface{}{} // 存值
+		areaS, cityS := []string{}, []string{}         // 存占位符
+		for k, v := range param.Area {
+			if len(v) == 0 { // 省份
+				area = append(area, k)
+				areaS = append(areaS, "?")
+			} else { // 城市
+				for i := 0; i < len(v); i++ {
+					city = append(city, v[i])
+					cityS = append(cityS, "?")
+				}
+			}
+		}
+		area_ := []string{}
+		if len(areaS) > 0 {
+			area_ = append(area_, fmt.Sprintf("area in (%s)", strings.Join(areaS, ","))) // 处理省份语句
+			values = append(values, area...)
+		}
+		if len(cityS) > 0 {
+			area_ = append(area_, fmt.Sprintf("city in (%s)", strings.Join(cityS, ","))) // 处理省份语句
+			values = append(values, city...)
+		}
+		qstr = append(qstr, fmt.Sprintf("(%s)", strings.Join(area_, " or ")))
+	}
+	//  行业
+	if param.Industry != nil && len(param.Industry) > 0 {
+		tmpArr := []string{}
+		for i := 0; i < len(param.Industry); i++ {
+			tmpArr = append(tmpArr, "?")
+			values = append(values, param.Industry[i])
+		}
+		qstr = append(qstr, fmt.Sprintf("subscopeclass in (%s)", strings.Join(tmpArr, ",")))
+	}
+	// 采购单位类型
+	if param.Buyerclass != nil && len(param.Buyerclass) > 0 {
+		tmpArr := []string{}
+		for i := 0; i < len(param.Buyerclass); i++ {
+			tmpArr = append(tmpArr, "?")
+			values = append(values, param.Buyerclass[i])
+		}
+		qstr = append(qstr, fmt.Sprintf("buyerclass in (%s)", strings.Join(tmpArr, ",")))
+	}
+	// 采购单位
+	if param.Buyer != "" {
+		qstr = append(qstr, "buyer like ?")
+		values = append(values, fmt.Sprintf("%%%s%%", param.Buyer))
+	}
+	// 中标单位
+	if param.Winner != "" {
+		qstr = append(qstr, "winner like ?")
+		values = append(values, fmt.Sprintf("%%%s%%", param.Winner))
+	}
+	if len(qstr) > 0 {
+		q = " and "
+	}
+	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)
+	total = db.Base.CountBySql(CountQuery, values...)
+	if total == 0 {
+		return data, 0
+	}
+	orderby := "last_time desc"
+	if param.Sort == 1 {
+		orderby = " (if(bidamount >0,bidamount,budget)) 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)
+	rs := db.Base.SelectBySql(query, values...)
+	if rs != nil && len(*rs) > 0 {
+		data = *rs
+	}
+	return data, total
+}
+
+// ReportProjectInfoFormat 周报/月报 项目明细 格式化数据
+func ReportProjectInfoFormat(data []map[string]interface{}) []map[string]interface{} {
+	rs := []map[string]interface{}{}
+	for i := 0; i < len(data); i++ {
+		tmp := map[string]interface{}{}
+		tmpWinner := common.ObjToString(data[i]["winner"])
+		tmpWinnerId := common.ObjToString(data[i]["winner_id"])
+		// 中标id 加密
+		splitWinnerId := strings.Split(tmpWinnerId, ",")
+		winIdArr := []string{}
+		for j := 0; j < len(splitWinnerId); j++ {
+			if splitWinnerId[j] != "" {
+				splitWinnerId[j] = encrypt.EncodeArticleId2ByCheck(splitWinnerId[j])
+			}
+			winIdArr = append(winIdArr, splitWinnerId[j])
+		}
+		tmp["winnerId"] = winIdArr
+		tmp["winner"] = strings.Split(tmpWinner, ",")
+		tmp["name"] = common.ObjToString(data[i]["name"])
+		tmp["area"] = data[i]["area"]
+		tmp["city"] = data[i]["city"]
+		tmp["bidStatus"] = data[i]["bidstatus"]
+		tmp["buyerClass"] = data[i]["buyerclass"]
+		tmp["bidAmount"] = data[i]["bidamount"]
+		tmp["budget"] = data[i]["budget"]
+		tmp["buyer"] = data[i]["buyer"]
+		tmp["lastTime"] = data[i]["last_time"]
+		rs = append(rs, tmp)
+	}
+	return rs
+}

+ 50 - 9
src/jfw/modules/bigmember/src/service/report/report.go

@@ -1,9 +1,11 @@
 package report
 
 import (
+	"encoding/json"
 	"fmt"
 	"jy/src/jfw/modules/bigmember/src/config"
 	. "jy/src/jfw/modules/bigmember/src/db"
+	"jy/src/jfw/modules/bigmember/src/entity"
 	"sort"
 	"strings"
 	"time"
@@ -25,6 +27,8 @@ type Report struct {
 	tipover     xweb.Mapper `xweb:"/report/tipover"`
 	openpushmsg xweb.Mapper `xweb:"/report/openpushmsg"`
 	starttime   xweb.Mapper `xweb:"/report/starttime"`
+	projectInfo xweb.Mapper `xweb:"/report/projectInfo"` // 周边月报项目明细
+
 }
 
 type BarChart struct {
@@ -170,12 +174,53 @@ func (r *Report) Detail() {
 			"unread": 0,
 		},
 	}, false, true)
+	isNewData := true
+	if end < config.Config.NewDataTime {
+		isNewData = false
+	}
+	m["isNewData"] = isNewData
+	r.ServeJson(Result{
+		Data: m,
+	})
+}
+
+// ProjectInfo 项目明细
+func (r *Report) ProjectInfo() {
+	//参数接收
+	body := xweb.FilterXSS(string(r.Body()))
+	param := entity.ReportProjectInfoParam{}
+	//接收参数
+	err := json.Unmarshal([]byte(body), &param)
+	if err != nil {
+		R.InvalidReqParam(r.ResponseWriter, r.Request)
+		return
+	}
+	start := param.Start
+	end := param.End
+	if end-start == 518400 { //周
+	} else if 518400 < end-start && end-start <= 2592000 { //月
+	} else {
+		R.InvalidReqParam(r.ResponseWriter, r.Request, "start", "end")
+		return
+	}
+	// 取positionId
+	positionId := qutil.Int64All(r.GetSession("positionId"))
+	if param.PageSize == 0 {
+		param.PageSize = 10
+	}
+	if param.PageNum == 0 {
+		param.PageNum = 1
+	}
+	m := map[string]interface{}{}
+	list, total := entity.GetReportProjectInfo(&param, positionId)
+	m["list"] = entity.ReportProjectInfoFormat(list)
+	m["total"] = total
 	r.ServeJson(Result{
 		Data: m,
 	})
 }
 
-//周报
+// 周报
 func weekResult(qk string, qv interface{}, start, end int64, coll, coll_winner string) M {
 	prevWeekStartDate := start - 7*oneday
 	list, ok := Mgo.Find(coll, map[string]interface{}{
@@ -219,7 +264,7 @@ func weekResult(qk string, qv interface{}, start, end int64, coll, coll_winner s
 	return result
 }
 
-//月报
+// 月报
 func monthResult(userId, qk string, qv interface{}, start, end int64, coll, coll_winner string) M {
 	result := M{}
 	//最近6个月
@@ -371,7 +416,7 @@ func monthResult(userId, qk string, qv interface{}, start, end int64, coll, coll
 	return result
 }
 
-//处理关键词分组环比增长率
+// 处理关键词分组环比增长率
 func matchitemGrowthRateHandle(earliest, curr map[string]interface{}, key1, key2 string) []interface{} {
 	e, _ := earliest[key1].([]interface{})
 	c, _ := curr[key1].([]interface{})
@@ -387,7 +432,7 @@ func matchitemGrowthRateHandle(earliest, curr map[string]interface{}, key1, key2
 	return c
 }
 
-//获取企业注册资本范围
+// 获取企业注册资本范围
 func getEntCapitalScopt(capital float64) string {
 	if 0 <= capital && capital < 100 {
 		return "0-100万"
@@ -412,7 +457,6 @@ func getEntCapitalScopt(capital float64) string {
 	}
 }
 
-//
 func formatMonths(start, end int64, bcs *BarCharts, pv interface{}) *BarCharts {
 	if len(bcs.List) == 0 {
 		return bcs
@@ -441,7 +485,7 @@ func formatMonths(start, end int64, bcs *BarCharts, pv interface{}) *BarCharts {
 	return bcs
 }
 
-//环比增长率
+// 环比增长率
 func getGrowthRate(v1, v2 float64) float64 {
 	if v2 == 0 {
 		return 0
@@ -449,7 +493,6 @@ func getGrowthRate(v1, v2 float64) float64 {
 	return qutil.RetainDecimal((v1-v2)/v2*100, 2)
 }
 
-//
 func (r *Report) Tip() {
 	_, qk, qv := getQuery(r.Session())
 	if qk == "" || qv == nil {
@@ -553,7 +596,6 @@ func (r *Report) Starttime() {
 	})
 }
 
-//
 func getColl(referer, t 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
@@ -571,7 +613,6 @@ func isFree(userId string, positionType int64, session *httpsession.Session) boo
 	return false
 }
 
-//
 func getQuery(sess *httpsession.Session) (string, string, interface{}) {
 	sessMap := sess.GetMultiple()
 	userId := qutil.ObjToString(sessMap["userId"])