|
@@ -24,6 +24,7 @@ import (
|
|
|
|
|
|
type BaseInfo struct {
|
|
|
Id string //信息id
|
|
|
+ FirstType string //详情页类型
|
|
|
PageType string //详情页类型
|
|
|
UserInfo util.SessUserInfo //用户信息
|
|
|
Sess *httpsession.Session //
|
|
@@ -33,12 +34,13 @@ type BaseInfo struct {
|
|
|
FromUserId string //分享者用户id
|
|
|
}
|
|
|
|
|
|
-func NewBaseInfo(id, pageType string, ui util.SessUserInfo, fromUserId string, sess *httpsession.Session, r *http.Request) *BaseInfo {
|
|
|
+func (s *SDao) NewBaseInfo(ui util.SessUserInfo, sess *httpsession.Session, r *http.Request) *BaseInfo {
|
|
|
return &BaseInfo{
|
|
|
- Id: id,
|
|
|
- PageType: pageType,
|
|
|
+ Id: s.Id,
|
|
|
+ FirstType: s.FirstType,
|
|
|
+ PageType: s.PageType,
|
|
|
UserInfo: ui,
|
|
|
- FromUserId: fromUserId,
|
|
|
+ FromUserId: s.UserId,
|
|
|
Sess: sess,
|
|
|
R: r,
|
|
|
IsMobile: consts.MobileReg.MatchString(r.UserAgent()),
|
|
@@ -65,14 +67,21 @@ func (b *BaseInfo) BidBaseInfo() (bi *BidInfo, err error) {
|
|
|
Topnet: false,
|
|
|
BindPhone: false,
|
|
|
}
|
|
|
+ advancedBool := true //是否有权限获取进阶信息
|
|
|
resResp := config.Middleground.ResourceCenter.Haspowers(b.UserInfo.AccountId, b.UserInfo.EntAccountId, b.UserInfo.EntId, b.UserInfo.EntUserId)
|
|
|
if resResp != nil && len(resResp.Powers) > 0 {
|
|
|
for _, pv := range resResp.Powers {
|
|
|
switch strings.TrimSpace(pv) {
|
|
|
case "bi_yx_topnet": //拓普
|
|
|
bi.Topnet = true
|
|
|
- case "ygzc_cgxx":
|
|
|
- bi.Purchase = true //阳光采购
|
|
|
+ case "ygzc_cgxx": //阳光采购
|
|
|
+ bi.Purchase = true
|
|
|
+ advancedBool = false
|
|
|
+ case "bi_sj_yyszs": //运营商专版
|
|
|
+ bi.Operator = true
|
|
|
+ if b.PageType == "yyszb" {
|
|
|
+ advancedBool = false
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -95,6 +104,7 @@ func (b *BaseInfo) BidBaseInfo() (bi *BidInfo, err error) {
|
|
|
isEntService = userPower.Data.Ent.PowerSource > 0 && userPower.Data.Entniche.IsEntPower > 0 //商机管理服务
|
|
|
pageTypeCheck = consts.PageTypeCheck
|
|
|
isPay = isVip || isMember || isEntniche
|
|
|
+ routeKey = fmt.Sprintf("%s%s", b.FirstType, b.PageType)
|
|
|
)
|
|
|
|
|
|
//企业级商机管理权限判断
|
|
@@ -116,10 +126,10 @@ func (b *BaseInfo) BidBaseInfo() (bi *BidInfo, err error) {
|
|
|
}
|
|
|
//redis 缓存数据
|
|
|
var detailKey = func() string {
|
|
|
- if bi.Topnet {
|
|
|
+ if bi.Topnet || bi.Purchase || bi.Operator {
|
|
|
bi.CanRead = true
|
|
|
return "pay" //可以看全部
|
|
|
- } else if (isVip && isOldVip) || isMember || isEntniche || pageTypeCheck[b.PageType] || privateData || bi.Purchase {
|
|
|
+ } else if (isVip && isOldVip) || isMember || isEntniche || pageTypeCheck[b.PageType] || privateData {
|
|
|
bi.CanRead = true
|
|
|
return "pay" //可以看全部
|
|
|
} else if isVip && !isOldVip {
|
|
@@ -134,15 +144,15 @@ func (b *BaseInfo) BidBaseInfo() (bi *BidInfo, err error) {
|
|
|
}()
|
|
|
//数据获取及简单处理
|
|
|
var GetBidInfo = func() (subtype string, obj map[string]interface{}, err error) {
|
|
|
- detailCacheKey := fmt.Sprintf(consts.CacheKey, detailKey, b.PageType, b.Id, common.If(b.IsMobile, "mobile", "pc"))
|
|
|
+ detailCacheKey := fmt.Sprintf(consts.CacheKey, detailKey, routeKey, b.Id, common.If(b.IsMobile, "mobile", "pc"))
|
|
|
//如果缓存没有数据 查看 是否有权限
|
|
|
res, errRids := redis.GetBytes(consts.RedisLimitation, detailCacheKey)
|
|
|
if errRids != nil || res == nil || len(*res) == 0 {
|
|
|
- obj = GetBiddingData(b.Id)
|
|
|
+ obj = b.GetBiddingData()
|
|
|
} else {
|
|
|
err = json.Unmarshal(*res, &obj)
|
|
|
if err != nil || obj == nil {
|
|
|
- obj = GetBiddingData(b.Id)
|
|
|
+ obj = b.GetBiddingData()
|
|
|
}
|
|
|
}
|
|
|
if obj != nil && len(obj) > 0 {
|
|
@@ -223,9 +233,9 @@ func (b *BaseInfo) BidBaseInfo() (bi *BidInfo, err error) {
|
|
|
return nil
|
|
|
}
|
|
|
err = BidInfoFormat()
|
|
|
- if bi.CanRead && bi.BaseInfo.InfoAttribute == "" && err == nil {
|
|
|
+ if bi.CanRead && advancedBool && err == nil {
|
|
|
//token
|
|
|
- token := fmt.Sprintf("%s#%s#%s#%s#%s", b.Id, b.PageType, fmt.Sprintf("%d", time.Now().Unix()), b.UserInfo.UserId, common.If(bi.CanRead, detailKey, "").(string))
|
|
|
+ token := fmt.Sprintf("%s#%s#%s#%s#%s#%s", b.Id, b.FirstType, b.PageType, fmt.Sprintf("%d", time.Now().Unix()), b.UserInfo.UserId, common.If(bi.CanRead, detailKey, "").(string))
|
|
|
bi.Token = encrypt.SE.EncodeString(token)
|
|
|
//存缓存
|
|
|
redis.Put(consts.RedisLimitation, fmt.Sprintf(consts.CacheAdvanceKey, bi.Token), bi, common.If(isPay, consts.DetailRedisByPayTimeOut, consts.DetailRedisByFreeTimeOut).(int))
|
|
@@ -243,7 +253,7 @@ func (b *BaseInfo) MinBidBaseInfo() (bi *BidInfo, err error) {
|
|
|
detailCacheKey := fmt.Sprintf(consts.MinCacheKey, b.Id, common.If(b.IsMobile, "mobile", "pc"))
|
|
|
//数据获取及简单处理
|
|
|
var bidInfo = func() {
|
|
|
- obj := GetBiddingData(b.Id)
|
|
|
+ obj := b.GetBiddingData()
|
|
|
if len(obj) == 0 {
|
|
|
err = fmt.Errorf("未查到当前招标信息")
|
|
|
log.Println("--未查到数据--:", b.Id)
|
|
@@ -302,11 +312,102 @@ func (b *BaseInfo) MinBidBaseInfo() (bi *BidInfo, err error) {
|
|
|
}
|
|
|
|
|
|
// GetBid 获取活动用户的id
|
|
|
-func GetBid(auId string) (bid string) {
|
|
|
+func GetBid(auId string) (s *SDao) {
|
|
|
+ s = &SDao{}
|
|
|
rs := db.BaseMysql.SelectBySql(fmt.Sprintf("select bidding_id from %s where au_id=?", consts.TableActivateBidding), auId)
|
|
|
if rs == nil || len(*rs) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- bid = common.InterfaceToStr((*rs)[0]["bidding_id"])
|
|
|
+ s.Id = common.InterfaceToStr((*rs)[0]["bidding_id"])
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+var (
|
|
|
+ customerField = []string{
|
|
|
+ "projectId", "toptype", "subtype", "title", "area", "city",
|
|
|
+ "district", "publishtime", "projectcode", "projectname",
|
|
|
+ "buyer", "buyerclass", "budget", "buyerperson", "buyertel",
|
|
|
+ "s_winner", "bidamount", "winnerperson", "winnertel",
|
|
|
+ "agency", "agencyperson", "agencytel", "href", "detail",
|
|
|
+ "docstarttime", "docendtime", "bidstarttime", "bidendtime",
|
|
|
+ "bidopentime", "isCompetitors", "pici", "industry",
|
|
|
+ "region", "expurasingtime", "bid",
|
|
|
+ }
|
|
|
+ biddingField = []string{
|
|
|
+ "s_subscopeclass", "purchasing", "site", "infoattribute",
|
|
|
+ "signendtime", "buyerhint", "entidlist", "winnerorder",
|
|
|
+ "winner", "infoformat", "isValidFile", "projectinfo",
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+// 详情页数据
|
|
|
+func (b *BaseInfo) GetBiddingData() (obj map[string]interface{}) {
|
|
|
+ isCustomer := consts.FirstTypeCheck[b.PageType]
|
|
|
+ fields := biddingField
|
|
|
+ bId := b.Id
|
|
|
+ obj = make(map[string]interface{})
|
|
|
+ if isCustomer {
|
|
|
+ entId := common.Int64All(b.Sess.Get("entId"))
|
|
|
+ cds := db.BaseMysql.SelectBySql(`SELECT * FROM bi_service.customer_data cd WHERE cd.infoid = ? AND cd.eid = ? ORDER BY cd.id DESC `, bId, entId)
|
|
|
+ if cds == nil || len(*cds) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ cd := (*cds)[0]
|
|
|
+ for _, v := range customerField {
|
|
|
+ switch v {
|
|
|
+ case "detail": //详情页
|
|
|
+ details := db.BaseMysql.SelectBySql(`SELECT cdyg.details FROM bi_service.customer_data_yys_gl cdyg WHERE cdyg.info_id = ? ORDER BY cdyg.id DESC `, bId)
|
|
|
+ if details != nil && len(*details) > 0 {
|
|
|
+ obj[v] = (*details)[0]["details"]
|
|
|
+ }
|
|
|
+ case "industry": //行业
|
|
|
+ if cd[v] == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ code := common.IntAll(cd[v])
|
|
|
+ scopeClass := db.BaseMysql.SelectBySql(`SELECT dyad.name FRoM bi_service.d_yys_analyze_dimensions dyad WHERE dyad.code = ?`, code)
|
|
|
+ if scopeClass != nil && len(*scopeClass) > 0 {
|
|
|
+ obj["s_subscopeclass"] = (*scopeClass)[0]["name"] //用户自定义的行业
|
|
|
+ }
|
|
|
+ case "isCompetitors": //是否竞品网站
|
|
|
+ if common.InterfaceToStr(cd[v]) == "是" {
|
|
|
+ obj["href"] = b.R.URL
|
|
|
+ }
|
|
|
+ case "bid": //标讯bidding的id
|
|
|
+ bId = common.InterfaceToStr(cd[v])
|
|
|
+ //uuid
|
|
|
+ if len([]rune(bId)) > 24 || bId == "" {
|
|
|
+ bId = ""
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ obj[v] = bId
|
|
|
+ default:
|
|
|
+ if cd[v] == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ obj[v] = cd[v]
|
|
|
+ }
|
|
|
+ fields = append(fields, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len([]rune(bId)) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ cObj, ok := db.Mgo_Bidding.FindById(db.DbConf.Mongodb.Bidding.Collection, bId, nil)
|
|
|
+ if ok && (cObj == nil || *cObj == nil || len(*cObj) == 0) {
|
|
|
+ cObj, ok = db.Mgo_Bidding.FindById(db.DbConf.Mongodb.Bidding.Collection_change, bId, nil)
|
|
|
+ }
|
|
|
+ if cObj == nil || len(*cObj) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !isCustomer {
|
|
|
+ obj = *cObj
|
|
|
+ } else {
|
|
|
+ for _, v := range fields {
|
|
|
+ if (*cObj)[v] != nil && obj[v] == nil {
|
|
|
+ obj[v] = (*cObj)[v]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return
|
|
|
}
|