|
@@ -1,7 +1,9 @@
|
|
|
package portrait
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"jy/src/jfw/modules/bigmember/src/config"
|
|
|
"jy/src/jfw/modules/bigmember/src/entity"
|
|
@@ -259,37 +261,61 @@ func (this *EntPortrait) WinnerMiniPortrait() {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- entId := util.DecodeId(this.GetString("entId"))
|
|
|
- rData, err := cepm.WinnerMiniPortraitData(entId) //项目个数,项目金额、合作金额
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- // 处理字段 bidamountCount companyName cooperate projectCount timeFrame
|
|
|
- rData["bidamountCount"] = rData["bidamount_count"]
|
|
|
- rData["cooperate"] = rData["buyer_count"]
|
|
|
- rData["projectCount"] = rData["project_count"]
|
|
|
- rData["winnerId"] = this.GetString("entId")
|
|
|
- rData["timeFrame"] = cepm.FormatTimeframe()
|
|
|
- delete(rData, "bidamount_count")
|
|
|
- delete(rData, "buyer_count")
|
|
|
- delete(rData, "project_count")
|
|
|
- //公司状态
|
|
|
- if entInfo, err := cepm.GetEntInfo(entId); err == nil {
|
|
|
- rData["status"] = entInfo["status"]
|
|
|
- rData["type"] = entInfo["type"]
|
|
|
- rData["companyName"] = entInfo["entName"]
|
|
|
- entName := qutil.ObjToString(entInfo["entName"])
|
|
|
- if entName != "" {
|
|
|
- if contactList, err := cepm.GetContacts(entName, ContactEntTypeWinner); err == nil {
|
|
|
- rData["contactCount"] = GetContactCount(contactList)
|
|
|
- } else {
|
|
|
- rData["contactCount"] = 0
|
|
|
+ var (
|
|
|
+ rData = map[string]interface{}{}
|
|
|
+ entId = util.DecodeId(this.GetString("entId"))
|
|
|
+ cacheKey = fmt.Sprintf("winner_mini_portrait_%s", entId)
|
|
|
+ errRids error
|
|
|
+ res = &[]byte{}
|
|
|
+ )
|
|
|
+ if config.Config.MiniPortraitCacheTime > 0 {
|
|
|
+ res, errRids = redis.GetBytes("limitation", cacheKey)
|
|
|
+ }
|
|
|
+ if config.Config.MiniPortraitCacheTime == 0 || errRids != nil || res == nil || len(*res) == 0 {
|
|
|
+ rData, err = cepm.WinnerMiniPortraitData(entId) //项目个数,项目金额、合作金额
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 处理字段 bidamountCount companyName cooperate projectCount timeFrame
|
|
|
+ rData["bidamountCount"] = rData["bidamount_count"]
|
|
|
+ rData["cooperate"] = rData["buyer_count"]
|
|
|
+ rData["projectCount"] = rData["project_count"]
|
|
|
+ rData["winnerId"] = this.GetString("entId")
|
|
|
+ rData["timeFrame"] = cepm.FormatTimeframe()
|
|
|
+ delete(rData, "bidamount_count")
|
|
|
+ delete(rData, "buyer_count")
|
|
|
+ delete(rData, "project_count")
|
|
|
+ //公司状态
|
|
|
+ if entInfo, err := cepm.GetEntInfo(entId); err == nil {
|
|
|
+ rData["status"] = entInfo["status"]
|
|
|
+ rData["type"] = entInfo["type"]
|
|
|
+ rData["companyName"] = entInfo["entName"]
|
|
|
+ entName := qutil.ObjToString(entInfo["entName"])
|
|
|
+ if entName != "" {
|
|
|
+ if contactList, err := cepm.GetContacts(entName, ContactEntTypeWinner); err == nil {
|
|
|
+ rData["contactCount"] = GetContactCount(contactList)
|
|
|
+ } else {
|
|
|
+ rData["contactCount"] = 0
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //项目动态数量
|
|
|
+ rData["biddingCount"] = cepm.GetWinnerNewCount(entId)
|
|
|
+ if config.Config.MiniPortraitCacheTime > 0 {
|
|
|
+ rb, bErr := json.Marshal(rData)
|
|
|
+ if bErr == nil {
|
|
|
+ bErr = redis.PutBytes("limitation", cacheKey, &rb, config.Config.MiniPortraitCacheTime)
|
|
|
+ }
|
|
|
+ if bErr != nil {
|
|
|
+ log.Println("save winner mini cache err :", bErr.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ err := json.Unmarshal(*res, &rData)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("get winner mini cache err :", err.Error())
|
|
|
+ }
|
|
|
}
|
|
|
- //项目动态数量
|
|
|
- rData["biddingCount"] = cepm.GetWinnerNewCount(entId)
|
|
|
-
|
|
|
return rData, nil
|
|
|
}()
|
|
|
if errMsg != nil {
|
|
@@ -485,26 +511,52 @@ func (this *EntPortrait) BuyerMiniPortrait() {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- entName := this.GetString("buyer")
|
|
|
- //所在地(省、市)、采购单位类型、采购项目数量、采购规模、合作客户数量
|
|
|
- rData, err := cepm.BuyerMiniPortraitData(entName)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- // 处理字段 bidamountCount companyName cooperate projectCount timeFrame
|
|
|
- rData["bidamountCount"] = rData["bidamount_count"]
|
|
|
- rData["companyName"] = entName
|
|
|
- rData["cooperate"] = rData["winner_count"]
|
|
|
- rData["projectCount"] = rData["project_count"]
|
|
|
- rData["timeFrame"] = cepm.FormatTimeframe()
|
|
|
- delete(rData, "bidamount_count")
|
|
|
- delete(rData, "winner_count")
|
|
|
- delete(rData, "project_count")
|
|
|
- //招标动态数量
|
|
|
- rData["biddingCount"] = cepm.GetBuyerNewCount(entName)
|
|
|
- //采购联系人数量
|
|
|
- if contactList, err := cepm.GetContacts(entName, ContactEntTypeBuyer); err == nil {
|
|
|
- rData["contactCount"] = GetContactCount(contactList)
|
|
|
+ var (
|
|
|
+ rData = map[string]interface{}{}
|
|
|
+ entName = this.GetString("buyer")
|
|
|
+ cacheKey = fmt.Sprintf("buyer_mini_portrait_%s", entName)
|
|
|
+ errRids error
|
|
|
+ res = &[]byte{}
|
|
|
+ )
|
|
|
+ if config.Config.MiniPortraitCacheTime > 0 {
|
|
|
+ res, errRids = redis.GetBytes("limitation", cacheKey)
|
|
|
+ }
|
|
|
+ if config.Config.MiniPortraitCacheTime == 0 || errRids != nil || res == nil || len(*res) == 0 {
|
|
|
+ //所在地(省、市)、采购单位类型、采购项目数量、采购规模、合作客户数量
|
|
|
+ rData, err = cepm.BuyerMiniPortraitData(entName)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 处理字段 bidamountCount companyName cooperate projectCount timeFrame
|
|
|
+ rData["bidamountCount"] = rData["bidamount_count"]
|
|
|
+ rData["companyName"] = entName
|
|
|
+ rData["cooperate"] = rData["winner_count"]
|
|
|
+ rData["projectCount"] = rData["project_count"]
|
|
|
+ rData["timeFrame"] = cepm.FormatTimeframe()
|
|
|
+ delete(rData, "bidamount_count")
|
|
|
+ delete(rData, "winner_count")
|
|
|
+ delete(rData, "project_count")
|
|
|
+ //招标动态数量
|
|
|
+ rData["biddingCount"] = cepm.GetBuyerNewCount(entName)
|
|
|
+ //采购联系人数量
|
|
|
+ if contactList, err := cepm.GetContacts(entName, ContactEntTypeBuyer); err == nil {
|
|
|
+ rData["contactCount"] = GetContactCount(contactList)
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if config.Config.MiniPortraitCacheTime > 0 {
|
|
|
+ rb, bErr := json.Marshal(rData)
|
|
|
+ if bErr == nil {
|
|
|
+ bErr = redis.PutBytes("limitation", cacheKey, &rb, config.Config.MiniPortraitCacheTime)
|
|
|
+ }
|
|
|
+ if bErr != nil {
|
|
|
+ log.Println("save winner mini cache err :", bErr.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ err := json.Unmarshal(*res, &rData)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("get winner mini cache err :", err.Error())
|
|
|
+ }
|
|
|
}
|
|
|
return rData, nil
|
|
|
}()
|