|
@@ -24,18 +24,27 @@ type SubVipPortrait struct {
|
|
|
subVipNewMsgSelects xweb.Mapper `xweb:"/portrait/subVipPortrait/selects"` //最新招标信息可筛选项
|
|
|
portraitUsage xweb.Mapper `xweb:"/portrait/subVipPortrait/usage"` //超级订阅升级版画像浏览详情
|
|
|
portraitRecord xweb.Mapper `xweb:"/portrait/subVipPortrait/record"` //超级订阅升级版画像浏览记录
|
|
|
+
|
|
|
+ buyerContacts xweb.Mapper `xweb:"/subVipPortrait/buyer/contacts"` //采购项目联系方式
|
|
|
+ buyerSelects xweb.Mapper `xweb:"/subVipPortrait/buyer/selects"` //采购单位画像可筛选项
|
|
|
+ buyerNewMsg xweb.Mapper `xweb:"/subVipPortrait/buyer/getNewMsg"` //最新项目动态[筛选]
|
|
|
+ buyerPortrait xweb.Mapper `xweb:"/subVipPortrait/buyer/getData"` //采购单位画像数据[筛选]
|
|
|
}
|
|
|
|
|
|
//SubVipEntDetail 超级订阅升级版查询基本信息
|
|
|
func (this *SubVipPortrait) SubVipEntDetail() {
|
|
|
userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
- cepm, _, err := entity.CreateSubVipPortraitManager(userId, "entDetail")
|
|
|
+ entId := util.DecodeId(this.GetString("entId"))
|
|
|
+ if entId == "" {
|
|
|
+ return nil, fmt.Errorf("参数异常")
|
|
|
+ }
|
|
|
+ cepm, err := entity.CreateSubVipPortraitManager(userId, "entDetail", entId, true)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- entId := this.GetString("entId")
|
|
|
- entInfo, err := cepm.GetEntInfo(util.DecodeId(entId))
|
|
|
+
|
|
|
+ entInfo, err := cepm.GetEntInfo(entId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -51,16 +60,12 @@ func (this *SubVipPortrait) SubVipEntDetail() {
|
|
|
func (this *SubVipPortrait) SubVipWinnerNewMsg() {
|
|
|
userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
- cepm, bigMsg, err := entity.CreateSubVipPortraitManager(userId, "entNewMsg")
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
entId := util.DecodeId(this.GetString("entId"))
|
|
|
if entId == "" {
|
|
|
return nil, fmt.Errorf("参数异常")
|
|
|
}
|
|
|
- //校验超级订阅画像浏览次数
|
|
|
- if err = bigMsg.SubVipPortraitTimesCheck(db.Mysql, entId); err != nil {
|
|
|
+ cepm, err := entity.CreateSubVipPortraitManager(userId, "entNewMsg", entId, true)
|
|
|
+ if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
@@ -101,16 +106,12 @@ func (this *SubVipPortrait) SubVipNewMsgSelects() {
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
entId := util.DecodeId(this.GetString("entId"))
|
|
|
if entId == "" {
|
|
|
- return nil, fmt.Errorf("企业参数异常")
|
|
|
+ return nil, fmt.Errorf("参数异常")
|
|
|
}
|
|
|
- _, bigMsg, err := entity.CreateSubVipPortraitManager(userId, "entNewMsg")
|
|
|
+ _, err := entity.CreateSubVipPortraitManager(userId, "entNewMsg", entId, true)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- //校验超级订阅画像浏览次数
|
|
|
- if err = bigMsg.SubVipPortraitTimesCheck(db.Mysql, entId); err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
pwp := &entity.PortraitScreen{Ent: entId}
|
|
|
return pwp.GetProjectSelectItems(true)
|
|
|
}()
|
|
@@ -124,16 +125,12 @@ func (this *SubVipPortrait) SubVipNewMsgSelects() {
|
|
|
func (this *SubVipPortrait) SubVipPortrait() {
|
|
|
userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
- cepm, bigMsg, err := entity.CreateSubVipPortraitManager(userId, "entPortrait")
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
entId := util.DecodeId(this.GetString("entId"))
|
|
|
if entId == "" {
|
|
|
return nil, fmt.Errorf("参数异常")
|
|
|
}
|
|
|
- //校验超级订阅画像浏览次数
|
|
|
- if err = bigMsg.SubVipPortraitTimesCheck(db.Mysql, entId); err != nil {
|
|
|
+ cepm, err := entity.CreateSubVipPortraitManager(userId, "entPortrait", entId, true)
|
|
|
+ if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
rData, err := cepm.WinnerPortraitData(&entity.PortraitScreen{
|
|
@@ -163,7 +160,7 @@ func (this *SubVipPortrait) PortraitUsage() {
|
|
|
return nil, fmt.Errorf("非法请求")
|
|
|
}
|
|
|
entId := util.DecodeId(this.GetString("entId"))
|
|
|
- total, usage, isUsed := bigMsg.SubVipPortraitUsage(db.Mysql, entId)
|
|
|
+ total, usage, isUsed := bigMsg.SubVipPortraitUsage(db.Mysql, entId, this.GetString("p_type") != "1")
|
|
|
returnMap := map[string]interface{}{
|
|
|
"total": total,
|
|
|
"usage": usage,
|
|
@@ -198,33 +195,27 @@ func (this *SubVipPortrait) PortraitRecord() {
|
|
|
if bigMsg.VipStatus <= 0 && bigMsg.Vip_BuySet.Upgrade != 1 {
|
|
|
return nil, fmt.Errorf("非法请求")
|
|
|
}
|
|
|
+ isWinner := this.GetString("p_type") != "1"
|
|
|
//获取画像企业id
|
|
|
- recordList, total := bigMsg.GetPortraitRecord(db.Mysql, year, month, pageNum, pageSize, pageNum == 0)
|
|
|
- //followCheckMap, entDetailMap := func() (follcheck map[string]bool, entMsg map[string]map[string]interface{}) {
|
|
|
- // var swg sync.WaitGroup
|
|
|
- // swg.Add(2)
|
|
|
- // //补全关注状态
|
|
|
- // go func() {
|
|
|
- // follcheck = getEntListFollow(userId, recordList)
|
|
|
- // swg.Done()
|
|
|
- // }()
|
|
|
- // //补全企业信息
|
|
|
- // go func() {
|
|
|
- // entMsg = gitEntListMsg(recordList)
|
|
|
- // swg.Done()
|
|
|
- // }()
|
|
|
- // swg.Wait()
|
|
|
- // return
|
|
|
- //}()
|
|
|
- entDetailMap := gitEntListMsg(recordList)
|
|
|
+ recordList, total := bigMsg.GetPortraitRecord(db.Mysql, year, month, pageNum, pageSize, pageNum == 0, isWinner)
|
|
|
var infoList []map[string]interface{}
|
|
|
- for _, eid := range recordList {
|
|
|
- if entDetail, ok := entDetailMap[eid]; ok && entDetail != nil {
|
|
|
- entDetail["id"] = util.EncodeId(eid)
|
|
|
- //entDetail["followed"] = followCheckMap[eid]
|
|
|
- infoList = append(infoList, entDetail)
|
|
|
+ if isWinner { //企业画像
|
|
|
+ entDetailMap := getEntListMsg(recordList)
|
|
|
+ for _, eid := range recordList {
|
|
|
+ if entDetail, ok := entDetailMap[eid]; ok && entDetail != nil {
|
|
|
+ entDetail["id"] = util.EncodeId(eid)
|
|
|
+ infoList = append(infoList, entDetail)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { //采购单位画像
|
|
|
+ buyerDetailMap := getBuyerListMsg(recordList)
|
|
|
+ for _, buyerName := range recordList {
|
|
|
+ if buyerDetail, ok := buyerDetailMap[buyerName]; ok && buyerDetail != nil {
|
|
|
+ infoList = append(infoList, buyerDetail)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
returnMap := map[string]interface{}{
|
|
|
"list": infoList,
|
|
|
}
|
|
@@ -239,28 +230,152 @@ func (this *SubVipPortrait) PortraitRecord() {
|
|
|
this.ServeJson(NewResult(rData, errMsg))
|
|
|
}
|
|
|
|
|
|
-func getEntListFollow(userId string, ids []string) (followMap map[string]bool) {
|
|
|
- followMap = make(map[string]bool)
|
|
|
- followed, _ := db.Mgo.Find("follow_entinfo_bigvip", map[string]interface{}{
|
|
|
- "s_userid": userId,
|
|
|
- "s_id": map[string]interface{}{"$in": ids},
|
|
|
- }, nil, `{"s_id":1}`, false, -1, -1)
|
|
|
- if followed == nil || len(*followed) == 0 {
|
|
|
- return
|
|
|
+//BuyerSelects 超级订阅筛选画像
|
|
|
+func (this *SubVipPortrait) BuyerSelects() {
|
|
|
+ userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+ buyer := this.GetString("buyer")
|
|
|
+ if buyer == "" {
|
|
|
+ return nil, fmt.Errorf("参数异常")
|
|
|
+ }
|
|
|
+ _, err := entity.CreateSubVipPortraitManager(userId, "buyerPortrait", buyer, false)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ pwp := &entity.PortraitScreen{Ent: buyer}
|
|
|
+ return pwp.GetProjectSelectItems(false)
|
|
|
+ }()
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("%s BuyerSelects 获取采购的单位画像可筛选条件出错:%s\n", userId, errMsg.Error())
|
|
|
}
|
|
|
+ this.ServeJson(NewResult(rData, errMsg))
|
|
|
+}
|
|
|
|
|
|
- for _, row := range *followed {
|
|
|
- if entId, _ := row["id"].(string); entId != "" {
|
|
|
- followMap[entId] = true
|
|
|
+//BuyerNewMsg 超级订阅采购单位画像动态
|
|
|
+func (this *SubVipPortrait) BuyerNewMsg() {
|
|
|
+ userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+ buyer := this.GetString("buyer")
|
|
|
+ if buyer == "" {
|
|
|
+ return nil, fmt.Errorf("参数异常")
|
|
|
+ }
|
|
|
+ pageNum, _ := this.GetInteger("pageNum")
|
|
|
+ pageSize, _ := this.GetInteger("pageSize")
|
|
|
+ cepm, err := entity.CreateSubVipPortraitManager(userId, "buyerPortrait", buyer, false)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ //免费用户仅可查看三条记录
|
|
|
+ rData, total, err := cepm.GetBuyerNewMsg(&entity.PortraitProjectScreen{
|
|
|
+ Screen: &entity.PortraitScreen{
|
|
|
+ Ent: buyer,
|
|
|
+ Match: this.GetString("match"),
|
|
|
+ ExactMatch: this.GetString("exactMatch") == "1",
|
|
|
+ MatchRange: this.GetString("matchRange"),
|
|
|
+ Area: this.GetString("area"),
|
|
|
+ ScopeClass: this.GetString("scopeClass"),
|
|
|
+ TimeRange: this.GetString("timeRange"),
|
|
|
+ HasPower: true,
|
|
|
+ },
|
|
|
+ PageNum: pageNum,
|
|
|
+ PageSize: pageSize,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return map[string]interface{}{
|
|
|
+ "list": rData,
|
|
|
+ "count": total,
|
|
|
+ }, nil
|
|
|
+ }()
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("%s BuyerNewMsg获取采购单位最新招标信息出错:%s\n", userId, errMsg.Error())
|
|
|
+ }
|
|
|
+ this.ServeJson(NewResult(rData, errMsg))
|
|
|
+}
|
|
|
+
|
|
|
+//BuyerContacts 超级订阅采购单位联系人
|
|
|
+func (this *SubVipPortrait) BuyerContacts() {
|
|
|
+ userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+ buyerName := this.GetString("buyer")
|
|
|
+ if buyerName == "" {
|
|
|
+ return nil, fmt.Errorf("企业参数异常")
|
|
|
+ }
|
|
|
+ cepm, err := entity.CreateSubVipPortraitManager(userId, "buyerPortrait", buyerName, false)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ rData, err := cepm.GetBuyerContactsMsg(buyerName)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return map[string]interface{}{
|
|
|
+ "list": rData,
|
|
|
+ }, nil
|
|
|
+ }()
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("%s BuyerContacts获取历史项目联系方式出错:%s\n", userId, errMsg.Error())
|
|
|
+ }
|
|
|
+ this.ServeJson(NewResult(rData, errMsg))
|
|
|
+}
|
|
|
+
|
|
|
+//BuyerPortrait 超级订阅采购单位画像-数据
|
|
|
+func (this *SubVipPortrait) BuyerPortrait() {
|
|
|
+ userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+ buyerName := this.GetString("buyer")
|
|
|
+ if buyerName == "" {
|
|
|
+ return nil, fmt.Errorf("参数异常")
|
|
|
+ }
|
|
|
+ cepm, err := entity.CreateSubVipPortraitManager(userId, "buyerPortrait", buyerName, false)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ flag := this.GetString("flag") //分段请求标识
|
|
|
+ rData, err := cepm.BuyerPortraitData(&entity.PortraitScreen{
|
|
|
+ Ent: buyerName,
|
|
|
+ Match: this.GetString("match"),
|
|
|
+ ExactMatch: this.GetString("exactMatch") == "1",
|
|
|
+ MatchRange: this.GetString("matchRange"),
|
|
|
+ Area: this.GetString("area"),
|
|
|
+ ScopeClass: this.GetString("scopeClass"),
|
|
|
+ TimeRange: this.GetString("timeRange"),
|
|
|
+ HasPower: true,
|
|
|
+ }, flag)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return rData, nil
|
|
|
+ }()
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("%s BuyerPortrait获取采购单位画像标信息出错:%s\n", userId, errMsg.Error())
|
|
|
+ }
|
|
|
+ this.ServeJson(NewResult(rData, errMsg))
|
|
|
+}
|
|
|
+
|
|
|
+//getEntListMsg 获取企业基本信息
|
|
|
+func getEntListMsg(ids []string) (dMap map[string]map[string]interface{}) {
|
|
|
+ dMap = make(map[string]map[string]interface{})
|
|
|
+ rData := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"id":["%s"]}}]}},"_source":["_id","company_name","company_status","legal_person","capital","company_address","company_shortname","company_phone","establish_date"],"size":%d}`, strings.Join(ids, `","`), len(ids)))
|
|
|
+ if rData == nil || len(*rData) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, data := range *rData {
|
|
|
+ if id, ok := data["_id"].(string); ok && id != "" {
|
|
|
+ if dateTimestamp := qutil.Int64All(data["establish_date"]); dateTimestamp > 0 {
|
|
|
+ data["establish_date"] = time.Unix(dateTimestamp, 0).Format(qutil.Date_Short_Layout)
|
|
|
+ }
|
|
|
+ dMap[id] = data
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func gitEntListMsg(ids []string) (detail map[string]map[string]interface{}) {
|
|
|
- detail = make(map[string]map[string]interface{})
|
|
|
- ids_str := `"` + strings.Join(ids, `","`) + `"`
|
|
|
- rData := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"id":[%s]}}]}},"_source":["_id","company_name","company_status","legal_person","capital","company_address","company_shortname","company_phone","establish_date"],"size":%d}`, ids_str, len(ids)))
|
|
|
+//getBuyerListMsg 获取采购单位基本信息
|
|
|
+func getBuyerListMsg(buyerNames []string) (dMap map[string]map[string]interface{}) {
|
|
|
+ dMap = make(map[string]map[string]interface{})
|
|
|
+ rData := elastic.Get("buyer", "buyer", fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"buyer_name":["%s"]}}]}},"size":%d,"_source":["buyer_name","city","province","buyerclass"]}`, strings.Join(buyerNames, `","`), len(buyerNames)))
|
|
|
if rData == nil || len(*rData) == 0 {
|
|
|
return
|
|
|
}
|
|
@@ -269,7 +384,15 @@ func gitEntListMsg(ids []string) (detail map[string]map[string]interface{}) {
|
|
|
if dateTimestamp := qutil.Int64All(data["establish_date"]); dateTimestamp > 0 {
|
|
|
data["establish_date"] = time.Unix(dateTimestamp, 0).Format(qutil.Date_Short_Layout)
|
|
|
}
|
|
|
- detail[id] = data
|
|
|
+ dMap[id] = data
|
|
|
+ }
|
|
|
+ if buyerName, _ := data["buyer_name"].(string); buyerName != "" {
|
|
|
+ dMap[buyerName] = map[string]interface{}{
|
|
|
+ "name": buyerName,
|
|
|
+ "city": data["city"],
|
|
|
+ "province": data["province"],
|
|
|
+ "buyerclass": data["buyerclass"],
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return
|