123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- package front
- import (
- "app.yhyue.com/moapp/jybase/common"
- util "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/encrypt"
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
- "app.yhyue.com/moapp/jybase/redis"
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
- "app.yhyue.com/moapp/jypkg/public"
- "context"
- "encoding/json"
- "fmt"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/gogf/gf/v2/util/gconv"
- "jy/src/jfw/config"
- "jy/src/jfw/jyutil"
- "jy/src/jfw/site/jySchool"
- "math/rand"
- "time"
- )
- type NewIndex struct {
- *xweb.Action
- newIndex xweb.Mapper `xweb:"/"` //首页改版
- entServerTransfer xweb.Mapper `xweb:"/front/entServerTransfer/(.*)"` //企业服务中转
- appDownload xweb.Mapper `xweb:"/front/appDownload"` //新app下载页面
- }
- var (
- entServerTransferMap map[string]map[bool]string
- BiddingTypeUrl = map[int]string{
- 1: "/list/stype/ZBYG.html",
- 2: "/list/stype/ZBJG.html",
- 3: "/list/stype/CGYX.html",
- 6: "/list/stype/XMFB.html",
- 13: "/list/rmxm/",
- 14: "/list/xxxm/",
- 15: "/list/gjxm/",
- 16: "/list/sjxm/",
- }
- )
- func init() {
- xweb.AddAction(&NewIndex{})
- entServerTransferMap = map[string]map[bool]string{
- "yxgl": map[bool]string{ //【营销管理】根据code判断是否有权限 bi_yx
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/succbi/crm_system/app/crm.app/sales_clues.spg", config.Sysconfig["webdomain"].(string)),
- false: "/swordfish/frontPage/digitalMarketing/free/index",
- },
- "yxt": map[bool]string{ //【医械通】根据code判断是否有权限 lyh_yl_yldy
- true: "/page_workDesktop/work-bench/app/big/medical/Credentials",
- false: "http://clpages.cn/yxtsjgwyxy",
- },
- "khgl": map[bool]string{ //【客户管理】根据code判断是否有权限 bi_yx
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/succbi/crm_system/app/crm.app/sales_clues.spg", config.Sysconfig["webdomain"].(string)),
- false: "/swordfish/frontPage/customanage/free/index",
- },
- "tbxmgl": map[bool]string{ //【投标项目管理】根据code判断是否有权限 cb_zy_code
- true: "/big/attend_bidding/mine",
- false: "/swordfish/frontPage/biddingProject/free/index",
- },
- "nzbg": map[bool]string{ //【年终报告】根据code判断是否有权限
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/succbi/nzbg/app/nzbg.app/nzbg_entrance_pc.spg", config.Sysconfig["webdomain"].(string)),
- false: "/swordfish/frontPage/AnnualReport/free/index",
- },
- }
- }
- // NewIndex 新版首页改版
- func (nIndex *NewIndex) NewIndex() error {
- sessVal := nIndex.Session().GetMultiple()
- userId := util.ObjToString(sessVal["userId"])
- nIndex.T["hasLogin"] = userId != ""
- nIndex.T["hotkey"] = hotKeyArrLoginEd
- nIndex.T["hotKeyArrUnLogin"] = hotKeyArrUnLogin
- if userId != "" {
- nickname, vipType := gconv.String(sessVal["userName"]), "注册用户"
- var endTime int64
- if nickname == "" {
- nickname = gconv.String(sessVal["s_nickname"])
- }
- if nickname == "" {
- nickname = gconv.String(sessVal["s_jyname"])
- }
- if nickname == "" {
- nickname = gconv.String(sessVal["phone"])
- }
- powerRes := config.Middleground.PowerCheckCenter.Check("10000", gconv.String(sessVal["mgoUserId"]), gconv.Int64(sessVal["base_user_id"]), gconv.Int64(sessVal["accountId"]), gconv.Int64(sessVal["entId"]), gconv.Int64(sessVal["positionType"]), gconv.Int64(sessVal["positionId"]))
- if powerRes.Vip.Status > 0 && powerRes.Vip.GetEndTime() > endTime {
- vipType, endTime = "超级订阅", powerRes.Vip.GetEndTime()
- }
- if powerRes.Member.Status > 0 && powerRes.Member.GetEndTime() > endTime {
- vipType, endTime = "大会员", powerRes.Member.GetEndTime()
- }
- if powerRes.Entniche.Status > 0 && powerRes.Entniche.GetEndTime() > endTime {
- vipType, endTime = "商机管理", powerRes.Entniche.GetEndTime()
- }
- if powerRes.Free.PpStatus > 0 && powerRes.Free.PpEndTime > endTime {
- vipType, endTime = "省份订阅包", powerRes.Free.GetPpEndTime()
- }
- nIndex.T["vipType"] = vipType
- nIndex.T["nickname"] = nickname
- if endTime > 0 {
- nIndex.T["vipEntTime"] = time.Unix(endTime, 0).Format("2006-01-02")
- }
- }
- //顶部菜单
- nIndex.T["topMenu"] = g.Cfg("index").MustGet(context.Background(), "topMenu").Maps()
- //招标公告
- nIndex.T["newbids"] = map[string]interface{}{
- "biddingList": NewIndexbids(nIndex.Session(), nIndex.Request),
- "more": fmt.Sprintf("%s", "/list/stype/ZBGG.html"),
- }
- //推荐标讯专区
- rangeInfoType := []int{1, 2, 3}
- //招标动态
- bidTrends := []map[string]interface{}{}
- for _, v := range rangeInfoType { //1招标预告 2 中标成交 3采购意向 4 拟建项目
- listData, types := GetRecommendBidZone(v, 5)
- bidTrends = append(bidTrends, map[string]interface{}{
- "listData": listData,
- "types": types,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[v]),
- })
- }
- //项目分包
- projectPage, typesName := GetIndexProjectList(6, 5)
- bidTrends = append(bidTrends, map[string]interface{}{
- "listData": projectPage,
- "types": typesName,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[6]),
- })
- nIndex.T["bidTrends"] = bidTrends
- //项目专区
- projectZoneType := []int{13, 14, 15, 16}
- projectZone := []map[string]interface{}{}
- for _, val := range projectZoneType {
- listData, types := GetIndexProjectList(val, 5)
- projectZone = append(projectZone, map[string]interface{}{
- "listData": listData,
- "types": types,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[val]),
- })
- }
- nIndex.T["projectZone"] = projectZone
- //中标喜报
- nIndex.T["winnerGlad"] = WinnerGladTidings()
- //热门行业 ////重点招标
- nIndex.T["hotIndustry"] = GetHotIndustry()
- //热门中标企业
- nIndex.T["hotWinner"] = NewHotEnt(true, 10)
- //热门采购单位
- nIndex.T["hotBuyers"] = NewHotEnt(false, 5)
- //供应商
- nIndex.T["supplyEnt"] = GetBidInfoPublishEnt()
- //招投标攻略
- nIndex.T["strategyList"] = GetStrategyList()
- //剑鱼课堂
- nIndex.T["jySchool"] = jyutil.Course(6, 3)
- //政府招标
- nIndex.T["governmentBidding"] = GovernmentTender(15)
- nIndex.T["importBidding"] = GetImportBidding()
- nIndex.T["biddingTrend"] = HomeBiddingTrends()
- nIndex.T["hotBuyerData"] = PurchasingData()
- nIndex.T["simpleTemplateData"] = map[string]interface{}{"XwebVer": nIndex.T["XwebVer"]}
- return nIndex.Render("/pc/newIndex.html", &nIndex.T)
- }
- func (nIndex *NewIndex) EntServerTransfer(code string) {
- toUrl := func() string {
- sessVal := nIndex.Session().GetMultiple()
- accountId := common.Int64All(sessVal["accountId"])
- if accountId <= 0 { //未登录
- return entServerTransferMap[code][false]
- }
- if code == "nzbg" {
- return entServerTransferMap[code][true]
- }
- entAccountId := common.Int64All(sessVal["entAccountId"])
- entId := common.Int64All(sessVal["entId"])
- entUserId := common.Int64All(sessVal["entUserId"])
- res := config.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
- powerPass := false
- switch code {
- case "yxgl", "khgl":
- for _, pCode := range res.Powers {
- if pCode == "bi_yx" {
- powerPass = true
- break
- }
- }
- case "yxt":
- for _, pCode := range res.Powers {
- if pCode == "lyh_yl_yldy" {
- powerPass = true
- break
- }
- }
- case "tbxmgl":
- for _, pCode := range res.Powers {
- if pCode == "cb_zy_code" {
- powerPass = true
- break
- }
- }
- }
- return entServerTransferMap[code][powerPass]
- }()
- _ = nIndex.Redirect(toUrl)
- }
- func (nIndex *NewIndex) AppDownload() {
- nIndex.T["includedInfo"] = GetIncludedInfo()
- nIndex.Render("/frontRouter/pc/AppDownload/free/index.html", &nIndex.T)
- }
- // 推荐标讯专区
- func GetRecommendBidZone(typ int, pageSize int) (list []map[string]interface{}, typs string) {
- if typ == 0 {
- typ = 1
- }
- rediskey := fmt.Sprintf("pcIndexRecommendBidZone_%d", typ)
- subtype := ""
- switch typ {
- case 1:
- //招标预告
- subtype = "预告"
- typs = "招标预告"
- case 2:
- //招标中标成交
- subtype = "中标,成交"
- typs = "中标成交"
- case 3:
- //采购意向
- subtype = "采购意向"
- typs = "采购意向"
- case 4:
- //拟建
- subtype = "拟建"
- typs = "拟建项目"
- }
- if l, ok := redis.Get("newother", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
- list = common.ObjArrToMapArr(l)
- } else {
- _, _, lists := bidsearch.GetPcBidSearchData("", "", "", "", subtype, "", "", "", "", "", "", "", "", 1, false, nil, bidSearch_field_1, "", false, false, "", pageSize, "")
- if lists != nil && len(*lists) >= 5 {
- *lists = (*lists)[0:5]
- for _, v := range *lists {
- v["_id"] = encrypt.CommonEncodeArticle("indexcontent", v["_id"].(string))
- delete(v, "toptype")
- delete(v, "s_subscopeclass")
- tmpdate := v["publishtime"]
- v["publish_time"] = time.Unix(common.Int64All(tmpdate.(float64)), 0).Format("2006-01-02")
- /*if v["budget"] != nil {
- v["budget"] = ConversionMoeny(v["budget"])
- } else if v["bidamount"] != nil {
- v["budget"] = ConversionMoeny(v["bidamount"])
- }*/
- }
- list = *lists
- redis.Put("other", rediskey, list, 2*60*60)
- }
- }
- return list, typs
- }
- // GetStrategyList 招投标攻略
- func GetStrategyList() (strategyList []map[string]interface{}) {
- if l, ok := redis.Get("newother", "pcIndexStrategyList").([]interface{}); ok && l != nil && len(l) > 0 {
- strategyList = common.ObjArrToMapArr(l)
- } else {
- for _, item := range jySchool.GuidelineColumn().SeedData {
- if res := jySchool.Guideline(item.Code, 15); res != nil && len(*res) > 0 {
- strategyList = append(strategyList, map[string]interface{}{
- "name": item.Name,
- "code": item.Code,
- "list": res,
- })
- }
- }
- }
- return strategyList
- }
- func GetIndexProjectList(typ, pageSize int) (data []map[string]interface{}, types string) {
- switch typ {
- case 6:
- types = "项目分包"
- case 13:
- types = "热门项目"
- case 14:
- types = "新兴项目"
- case 15:
- types = "国家级项目"
- case 16:
- types = "省级项目"
- }
- redidKey := fmt.Sprintf("pcIndexProjectZone_%d", typ)
- redisArr, _ := redis.Get("newother", redidKey).([]interface{})
- if len(redisArr) > 0 {
- data = common.ObjArrToMapArr(redisArr)
- return
- }
- res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT nbl.bid_id as bid_id,nbl.title as title,nbl.publish_time as publish_time FROM jyseo_test.new_bid_sign nbs LEFT JOIN jyseo_test.new_bidList nbl ON nbs.bid_id = nbl.bid_id WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT %d `, typ, pageSize))
- if err != nil || res.IsEmpty() {
- return nil, types
- }
- for _, v := range res.List() {
- v["_id"] = encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr(v["bid_id"]))
- v["publish_time"] = time.Unix(common.Int64All(v["publish_time"]), 0).Format("2006-01-02")
- data = append(data, v)
- }
- return data, types
- }
- // 优秀供应商
- func GetBidInfoPublishEnt() (res [][]map[string]interface{}) {
- if l, ok := redis.Get("newother", "pcIndexBidInfoGoodPublishEnt").([]interface{}); ok && l != nil && len(l) > 0 {
- for _, v := range l {
- res = append(res, common.ObjArrToMapArr(v.([]interface{})))
- }
- } else {
- data := public.Mysql.Find("entniche_info", map[string]interface{}{"auth_status": 1}, "id,name", "auth_time DESC", -1, -1)
- if data != nil && len(*data) > 0 {
- entData := []map[string]interface{}{}
- if len(*data) > 60 {
- r := rand.Intn(len(*data) - 60)
- entData = (*data)[r : r+60]
- } else {
- entData = *data
- }
- if len(entData) > 0 {
- once := []map[string]interface{}{}
- for _, val := range entData {
- if len(once) <= 15 {
- once = append(once, val)
- } else {
- res = append(res, once)
- once = []map[string]interface{}{}
- once = append(once, val)
- }
- }
- if len(once) > 0 {
- res = append(res, once)
- }
- }
- redis.Put("newother", "pcIndexBidInfoGoodPublishEnt", res, 3600*24*7)
- }
- }
- return res
- }
- func GetImportBidding() []*hotKeyWord {
- redisData := redis.Get(RedisNameNew, "pcIndexImportBidding")
- if redisData != nil {
- if d, err := json.Marshal(redisData); err == nil {
- var hotKW []*hotKeyWord
- json.Unmarshal(d, &hotKW)
- return hotKW
- }
- }
- randomNumber := rand.Intn(len(subjectMatter) - 30)
- res := subjectMatter[randomNumber : randomNumber+30]
- redis.Put(RedisNameNew, "pcIndexImportBidding", res, 3600*6)
- return res
- }
|