Explorar o código

Merge branch 'release' into dev4.7.0

lianbingjie %!s(int64=3) %!d(string=hai) anos
pai
achega
165b65175a

+ 1 - 12
src/jfw/modules/app/src/app/front/front.go

@@ -551,17 +551,6 @@ func (s *Front) ShowRedSpotOnMenu() {
 				s_phone = s_m_phone
 			}
 			isNew := false
-			/* if s_phone != "" {
-			    ent := public.Mysql.SelectBySql("select id,isNew,phone,createtime from entniche_info where phone=? and status=1 ", s_phone)
-			    if ent != nil && len(*ent) != 0 {
-
-			        for _, val := range *ent {
-			            if util.IntAll(val["isNew"]) == 1 {
-			                isNew = true
-			            }
-			        }
-			    }
-			}*/
 			res := public.Mysql.SelectBySql(`SELECT isNew,i.name,i.phone,i.status,i.auth_status,u.power FROM entniche_user u LEFT JOIN entniche_info i
 			ON u.ent_id=i.id
 			where u.phone=? `, s_phone)
@@ -578,7 +567,7 @@ func (s *Front) ShowRedSpotOnMenu() {
 					}
 				}
 			}
-			if jy.SwitchService.IsMember(s.Session(), mongodb) {
+			if jy.SwitchService.IsMember(s.Session(), mongodb, public.Mysql) {
 				subscribe = util.IntAll((*user)["i_member_apppushunread"])
 			} else if isNew {
 				subscribe = 0

+ 2 - 2
src/jfw/modules/app/src/app/front/vipsubscribe.go

@@ -109,7 +109,7 @@ func (s *Subscribepay) ToSetPage() {
 			s.SetSession(jy.SwitchService.SessionKey, jy.SwitchService.Member)
 		}
 	}
-	vSwitch = jy.SwitchService.Get(s.Session(), public.MQFW) //v:vip m:member
+	vSwitch = jy.SwitchService.GetEntniche(s.Session(), public.MQFW, public.Mysql) //v:vip m:member
 	bigBaseMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW)
 	if (vSwitch == "" || vSwitch == "v") && bigBaseMsg.VipStatus <= 0 && !bigBaseMsg.IsUpgrade {
 		s.Redirect("/jyapp/wxkeyset/keyset/index")
@@ -243,7 +243,7 @@ func (s *Subscribepay) ToSetKeyWordPage() {
 			s.SetSession(jy.SwitchService.SessionKey, jy.SwitchService.Member)
 		}
 	}
-	vSwitch = jy.SwitchService.Get(s.Session(), public.MQFW) //v:vip m:member
+	vSwitch = jy.SwitchService.GetEntniche(s.Session(), public.MQFW, public.Mysql) //v:vip m:member
 	bigBaseMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW)
 	//如果没有首次使用
 	if vSwitch == "m" && bigBaseMsg.Status > 0 && !bigBaseMsg.Used {

+ 51 - 24
src/jfw/modules/app/src/web/staticres/jyapp/js/historypush.js

@@ -83,12 +83,17 @@ var vm = new Vue({
       // iconbm: '/jyapp/big-member/image/icon-putonghy.png'
       showPopover: false,
       protype: 'vip', // 关键词接口动态修改
-      entinfo: {}
+      entinfo: {},
+      isEntniche: false,// 是否是商机管理
+      address: '' // 商机管理订阅管理跳转地址
     }
   },
   computed: {
     selectedMoreCancelDisabled: function () {
       return !(this.buyerclass || this.key || this.subtype)
+    },
+    selectedMoreProduct: function () {
+      return !!(this.rootInfo.vipStatus > 0 && this.rootInfo.memberStatus > 0) || !!(this.rootInfo.vipStatus > 0 && this.isEntniche) || !!(this.rootInfo.memberStatus > 0 && this.isEntniche)
     }
   },
   created () {
@@ -100,7 +105,7 @@ var vm = new Vue({
       }
     });
     this.getHasWeekMonthData()
-    this.getUserRoot()
+    this.getEntniche()
     this.subPageMove()
     if(firstTime) {
       firstTime = firstTime / 1000 +'_'+ firstTime / 1000;
@@ -173,25 +178,25 @@ var vm = new Vue({
     SwitchPro: function() {
       // 超级订阅和大会员
       // this.rootInfo.memberStatus = 0
-      if(this.rootInfo.vipStatus > 0 && this.rootInfo.memberStatus > 0) {
+      if(this.selectedMoreProduct) {
         this.bigSubShow = true
-        if(this.rootInfo.memberStatus == 1) {
+        if(this.rootInfo.memberStatus == 1 || this.rootInfo.memberStatus == 7) {
           this.iconbm = '/jyapp/big-member/image/icon-gaojihy.png'
         } else if(this.rootInfo.memberStatus == 2) {
           this.iconbm = '/jyapp/big-member/image/icon-biaozhunhy.png'
-        } else if(this.rootInfo.memberStatus == 3) {
+        } else if(this.rootInfo.memberStatus == 3 || this.rootInfo.memberStatus == 6) {
           this.iconbm = '/jyapp/big-member/image/icon-putonghy.png'
         } else {
           this.iconbm = '/jyapp/big-member/image/icon-gaojihy.png'
         }
       } else if(this.rootInfo.vipStatus > 0) {
         // 仅超级订阅
-        if(!this.rootInfo.memberStatus || this.rootInfo.memberStatus <=0) {
+        if((!this.rootInfo.memberStatus || this.rootInfo.memberStatus <=0) && !this.isEntniche) {
           tosetpage()
         }
       } else if(this.rootInfo.memberStatus > 0) {
         // 仅大会员
-        if(!this.rootInfo.vipStatus || this.rootInfo.vipStatus == 0) {
+        if((!this.rootInfo.vipStatus || this.rootInfo.vipStatus == 0) && !this.isEntniche) {
           location.href = '/jyapp/big/page/main_root?type=subscribe'
         }
       }
@@ -206,6 +211,7 @@ var vm = new Vue({
         // this.ajaxUrl = '/publicapply/subscribe/historyPush?t=' + new Date().getTime()
         this.RemoveClass('big')
         this.getBmStatus(this.rootInfo)
+        initpage()
       } else if(data == 'vip') {
         productType = 1
         historyVt = 'v'
@@ -215,15 +221,17 @@ var vm = new Vue({
         $(".switch").addClass('only-vip')
         $(".switch .user_pro").text("超级订阅")
         $(".switch_right").addClass('right_zh')
+        $('.user_pro').css('color', '#D69E55')
         $(".switch .switch_icon").addClass('icon_vip')
         this.selectPro = 1
+        initpage()
         // this.ajaxUrl = '/publicapply/subscribe/historyPush?t=' + new Date().getTime()
       } else if(data == 'ent') {
         productType = 3
         historyVt = 's'
         this.switchVip('s')
         sessionStorage.setItem('switch-product', 'entniche')
-        this.RemoveClass('vip')
+        this.RemoveClass('ent')
         $(".switch").addClass('only-vip')
         $(".switch .user_pro").text("商机管理")
         $(".switch_right").addClass('right_zj')
@@ -250,6 +258,11 @@ var vm = new Vue({
         $(".switch .switch_icon").removeClass('icon_zh')
         $(".switch .switch_icon").removeClass('icon_sj')
       } else {
+        if(data == 'ent') {
+          $(".switch .switch_icon").removeClass('icon_zj')
+          $(".switch .switch_icon").removeClass('icon_zh')
+          $(".switch .switch_icon").removeClass('icon_sj')
+        }
         $(".switch").removeClass('switch_zh')
         $(".switch_right").removeClass('right_zh')
         $(".switch .switch_icon").removeClass('icon_zh')
@@ -417,6 +430,20 @@ var vm = new Vue({
         }
       })
     },
+    // 判断是否是新版商机管理
+    getEntniche: function () {
+      var _this = this
+      $.ajax({
+          url: '/entnicheNew/buy/whetherbuy',
+          type: 'POST',
+          success:function(res){
+              if (res.data) {
+                _this.isEntniche = res.data.isNew
+              }
+          }
+      })
+      _this.getUserRoot()
+  },
     // 会员切换
     switchVip: function(name) {
       let _this = this
@@ -429,6 +456,7 @@ var vm = new Vue({
       $.ajax({
         url: '/publicapply/subscribe/vipSwitch',
         type: 'POST',
+        async: false,
         data: param,
         success: function(res) {
           if(res.error_code == 0) {
@@ -473,19 +501,21 @@ var vm = new Vue({
               productType = 3
               historyVt = 's'
               sessionStorage.setItem('switch-product', 'entniche')
-              _this.RemoveClass('vip')
+              _this.RemoveClass('ent')
               $(".switch").addClass('only-vip')
               $(".switch .user_pro").text("商机管理")
               $(".switch_right").addClass('right_zj')
               $('.user_pro').css('color', '#171826')
               $(".switch .switch_icon").addClass('icon_ent')
+              $(".switch").show()
               _this.protype = 'entniche'
               _this.selectPro = 3
+              $('.vip_report').hide()
               _this.getEntInfo()
             }
             if(switchProduct == 'bigmember' && _this.rootInfo.isSubCount) {
             	$('#sub_manager').hide();
-				$('.vip_report').addClass('vip_report_only');
+				      $('.vip_report').addClass('vip_report_only');
             } else {
                 $('#sub_manager').show()
                 $('.vip_report').removeClass('vip_report_only');
@@ -507,16 +537,15 @@ var vm = new Vue({
           console.log(res)
           if(res.error_code === 0) {
             _this.entinfo = res.data
-            let address = ''
             if(res.data.admin_department || res.data.admin_system) {
-              address = '/page_entniche_new/page/sub_management/sub_management_system.html'
+              _this.address = '/page_entniche_new/page/sub_management/sub_management_system.html'
             } else {
-              address = '/page_entniche_new/page/subsetting/sub_entrance.html'
+              _this.address = '/page_entniche_new/page/subsetting/sub_entrance.html'
             }
             $("#sub_manager").click(function() {
               setSessionStorage();
               sessionStorage.setItem(_this.sessStorageKey, JSON.stringify(_this.$data))
-              location.href = address
+              location.href = _this.address
             })
           }
         }
@@ -575,7 +604,6 @@ var vm = new Vue({
                   $('.vip_report').show()
                 }
                 if(res.data.vipStatus > 0 && res.data.memberStatus > 0) {
-
                   if(switchProduct) {
                     if(switchProduct == 'bigmember') {
                       _this.getBmStatus(res.data)
@@ -583,7 +611,6 @@ var vm = new Vue({
                       $(".switch").addClass('only-vip')
                       $(".switch .user_pro").text("超级订阅")
                       $(".switch .switch_icon").addClass('icon_vip')
-                      $(".switch").show()
                       $(".switch_right").addClass('right_zh')
                       _this.selectPro = 1
                     }
@@ -599,24 +626,20 @@ var vm = new Vue({
                 } else if(res.data.vipStatus > 0) {
                   // 仅超级订阅
                   $(".switch").show()
-                  if(!res.data.memberStatus || res.data.memberStatus <=0) {
-                    $('.switch_right').hide()
+                  if((!res.data.memberStatus || res.data.memberStatus <=0) && !_this.isEntniche) {
                     $(".switch").addClass('only-vip')
                     $(".switch .user_pro").text("超级订阅")
                     $(".switch .switch_icon").addClass('icon_vip')
-                    $(".switch_right").hide()
                     _this.selectPro = 1
                   }
                 } else if(res.data.memberStatus > 0) {
                   // 仅大会员
-                  if(!res.data.vipStatus || res.data.vipStatus == 0) {
+                  if((!res.data.vipStatus || res.data.vipStatus == 0) && !_this.isEntniche) {
                     _this.getBmStatus(res.data)
-                    $(".switch_right").hide()
                   }
-                } else if(res.data.entniche) {
+                } else if(_this.isEntniche) {
                   // 仅商机管理
                   if(!res.data.vipStatus || res.data.vipStatus == 0 && res.data.memberStatus <= 0) {
-                    $(".switch_right").hide()
                     $(".switch .switch_icon").addClass('icon_zj')
                     _this.selectPro = 3
                   }
@@ -634,18 +657,22 @@ var vm = new Vue({
         $(".switch").addClass('switch_zj')
         $(".switch_right").addClass('right_zj')
         $(".switch .switch_icon").addClass('icon_zj')
+        $('.user_pro').css('color', '#171826')
       } else if(res.memberStatus == 2 ) {
         $(".switch").addClass('switch_zh')
         $(".switch_right").addClass('right_zh')
         $(".switch .switch_icon").addClass('icon_zh')
+        $('.user_pro').css('color', '#d69e55')
       } else if(res.memberStatus == 3 || res.memberStatus == 6) {
         $(".switch").addClass('switch_sj')
         $(".switch_right").addClass('right_sj')
         $(".switch .switch_icon").addClass('icon_sj')
+        $('.user_pro').css('color', '#2abed1')
       } else {
         $(".switch").addClass('switch_zj')
         $(".switch_right").addClass('right_zj')
         $(".switch .switch_icon").addClass('icon_zj')
+        $('.user_pro').css('color', '#171826')
       }
       $(".switch .user_pro").text("大会员")
       $(".switch").show()
@@ -795,7 +822,7 @@ var vm = new Vue({
         this.subscopeclass = ''
         $('.industryText').html('行业')
         this.setTimer.industrytimer = new Date().getTime()
-
+        this.selectIndustryList = []
         this.setToggle()
         this.doSearch()
       } else if(data.name === 'cateItem'){

+ 20 - 9
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyWord.js

@@ -136,16 +136,27 @@ var vm = new Vue({
       var vSwitch = utils.getParam('vSwitch')
       if (vSwitch) {
         this.vSwitch = vSwitch
+        this.ajaxSwitchFun(vSwitch)
       } else {
-        $.ajax({
-          type: 'POST',
-          url: '/publicapply/subscribe/vipSwitch',
-          async: false,
-          success: function (res) {
-            this.vSwitch = res.data.vt || 'f'
-          }.bind(this)
-        })
+        this.ajaxSwitchFun()
+      }
+    },
+    ajaxSwitchFun: function (n) {
+      let dataS = ''
+      if(n) {
+        dataS = n
       }
+      $.ajax({
+        type: 'POST',
+        url: '/publicapply/subscribe/vipSwitch',
+        async: false,
+        data: {
+          vt: dataS
+        },
+        success: function (res) {
+          this.vSwitch = res.data.vt || 'f'
+        }.bind(this)
+      })
     },
     getKeywordsGroupList: function (needLoading) {
       var _this = this
@@ -604,7 +615,7 @@ var vm = new Vue({
 
       this.savePageState()
       var queryString = this.qsStringify(query)
-      location.href = '/jyapp/vipsubscribe/toSetinfoPage' + '?' + queryString
+      location.href = '/jyapp/vipsubscribe/toSetinfoPage' + '?' + queryString + '&vSwitch=' + this.vSwitch
     },
     toBuyVIPService: function () {
       this.savePageState()

+ 6 - 8
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyword-manage.js

@@ -25,7 +25,7 @@ var vm = new Vue({
       var url = '/subscribepay/afterPay/getUserInfo'
       if (this.vSwitch === 'm') {
         url = '/bigmember/use/info'
-      } else {
+      } else if(this.vSwitch === 's') {
         url = '/entnicheNew/subscribe/key/get'
       }
       return url
@@ -147,13 +147,11 @@ var vm = new Vue({
               }
             }
 
-            if (kList.length) {
-              // 整理数据
-              var groupList = _this.addInfoToKeyItem(kList)
-              var groupNameList = _this.getGroupNameList(groupList)
-              _this.keywordsGroupList = groupList
-              _this.groupNameList = groupNameList
-            }
+            // 整理数据
+            var groupList = _this.addInfoToKeyItem(kList)
+            var groupNameList = _this.getGroupNameList(groupList)
+            _this.keywordsGroupList = groupList
+            _this.groupNameList = groupNameList
           }
         },
         error: function () {

+ 2 - 2
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_index_new.js

@@ -9,7 +9,7 @@ var subNode = new Vue({
       linkObj: {
         area: '/jyapp/vipsubscribe/toChangeArea?header=save',
         industry: '/jyapp/vipsubscribe/toChangeIndustry?header=save',
-        keyword: '/jyapp/vipsubscribe/toSetKeyWordPage',
+        keyword: '/jyapp/vipsubscribe/toSetKeyWordPage?vSwitch=v',
         infotype: '/jyapp/vipsubscribe/toSetInfoTypePage',
         resultview: '/jyapp/vipsubscribe/toVIPViewPage?vSwitch=v',
         pushsetting: '/jyapp/big/page/push_setting_detail?header=超级订阅推送设置&type=super_subscribe',
@@ -99,7 +99,7 @@ var subNode = new Vue({
             this.linkObj = {
               area: '/jyapp/big/page/set_area?callback=setting_save',
               industry: '/jyapp/big/page/set_cate?header=采购单位类型&callback=setting_save',
-              keyword: '/jyapp/vipsubscribe/toSetKeyWordPage',
+              keyword: '/jyapp/vipsubscribe/toSetKeyWordPage?vSwitch=m',
               infotype: '/jyapp/big/page/set_infotype?callback=setting_save',
               resultview: '/jyapp/big/page/bigvip_viewpage',
               pushsetting: '/jyapp/big/page/push_setting_detail?header=大会员推送设置&type=member_subscribe'

+ 40 - 22
src/jfw/modules/app/src/web/templates/weixin/historypush.html

@@ -178,6 +178,13 @@
             color: #2ABED1;
             display: contents;
         }
+        .product-switch{
+          display: block;
+          height: auto;
+        }
+        .typeswitch{
+          height: 1.08rem;
+        }
     </style>
 </head>
 <body class="p13" id="viperSuper" style="background: #fff;overflow: hidden;">
@@ -214,7 +221,7 @@
       <div class="switch" @click="SwitchPro" data-need-bind-phone id="app-historypush-vipSub-btn" style="display:none;">
         <span class="switch_icon"></span>
         <span class="user_pro"></span>
-        <span class="switch_right"></span>
+        <span class="switch_right" v-show="selectedMoreProduct"></span>
       </div>
     </li>
     <li>
@@ -250,8 +257,8 @@
 		</div>
 	</div>
 </div>
-<van-popup v-model="bigSubShow" class="product-switch" position="top" get-container="body" :style="{ height: '242px' }">
-    <div class="typeswitch entniche" @click="proClick('ent')">
+<van-popup v-model="bigSubShow" class="product-switch" position="top" get-container="body">
+    <div class="typeswitch entniche" v-if="isEntniche" @click="proClick('ent')">
       <div class="type-left">
           <img class="icon-bm" src="/jyapp/images/shangjigl.png" alt="">
           <span class="bm-text">商机管理</span>
@@ -260,7 +267,7 @@
           <span class="icon-blue-duihao" v-if="selectPro == 3"></span>
       </div>
     </div>
-    <div class="typeswitch bigmember" @click="proClick('big')">
+    <div class="typeswitch bigmember" v-if="rootInfo.memberStatus > 0" @click="proClick('big')">
         <div class="type-left">
             <img :src="iconbm" class="icon-bm" alt="">
             <span class="bm-text">大会员</span>
@@ -269,7 +276,7 @@
             <span class="icon-blue-duihao" v-if="selectPro == 2"></span>
         </div>
     </div>
-    <div class="typeswitch vipproduct" @click="proClick('vip')">
+    <div class="typeswitch vipproduct" v-if="rootInfo.vipStatus > 0" @click="proClick('vip')">
         <div class="type-left">
             <img class="icon-bm" src="/jyapp/vipsubscribe/image/vip-icon.png" alt="">
             <span class="bm-text">超级订阅</span>
@@ -882,7 +889,7 @@
                 location.href = '/jyapp/vipsubscribe/toSubVipSetPage'
             } else {
                 if(vm.rootInfo.memberStatus > 0) {
-                    location.href = '/jyapp/vipsubscribe/toSubVipSetPage'
+                    location.href = '/jyapp/vipsubscribe/toSubVipSetPage?vSwitch=m'
                 } else {
                     tokeyset()
                 }
@@ -913,16 +920,30 @@
             setSessionStorage();
             console.log(vm.rootInfo, 'vmrootInfo')
             sessionStorage.setItem(vm.sessStorageKey, JSON.stringify(vm.$data))
-            let thisType = sessionStorage.getItem('userIsNew')
-            if (window.userNewType || thisType) {
-                location.href = '/jyapp/vipsubscribe/toSubVipSetPage'
+            if(historyVt == 's') {
+              if(vm.entinfo.admin_department || vm.entinfo.admin_system) {
+                location.href = '/page_entniche_new/page/sub_management/sub_management_system.html'
+              } else {
+                location.href = '/page_entniche_new/page/subsetting/sub_entrance.html'
+              }
+              return
+            } else if(historyVt == 'm') {
+              location.href = '/jyapp/vipsubscribe/toSubVipSetPage?vSwitch=m'
+            } else if(historyVt == 'v') {
+              location.href = '/jyapp/vipsubscribe/toSubVipSetPage?vSwitch=v'
             } else {
-                if(vm.selectPro == 1) {
-                    location.href = '/jyapp/vipsubscribe/toSubVipSetPage'
-                } else {
-                    tosetpage()
-                }
+              tosetpage()
             }
+            // let thisType = sessionStorage.getItem('userIsNew')
+            // if (window.userNewType || thisType) {
+            //     location.href = '/jyapp/vipsubscribe/toSubVipSetPage'
+            // } else {
+            //     if(vm.selectPro == 1) {
+            //         location.href = '/jyapp/vipsubscribe/toSubVipSetPage'
+            //     } else {
+            //         tosetpage()
+            //     }
+            // }
 
         });
         if(productType == 0) {
@@ -1179,7 +1200,7 @@
       //
       $.post("/publicapply/myinfo?t="+new Date().getTime(),null,function(r){
         myInfo = r
-        if(r.userType=="vip"){
+        if(r.vipStatus > 0){
             // $(".switch").addClass("only-vip");
             // $(".switch").text("超级订阅").show();
             // $(".switch").click(tosetpage);
@@ -1190,12 +1211,14 @@
               if(myInfo.userType == 'entniche') {
                 $('.header_header').hide()
                 $(".switch").addClass('switch_zj')
-                $(".switch_right").hide()
+                // $(".switch_right").hide()
                 $(".switch .switch_icon").addClass('icon_ent')
                 $(".switch .user_pro").text("商机管理").css('margin-right','.08rem')
                 $(".switch").show()
                 thisClass.InitPersonal(r);
-                $(".switch").click(toEntNichePage);
+                if(historyVt === 's') {
+                  $(".switch").click(toEntNichePage);
+                }
                 extend(1)
                 return
               }
@@ -1228,11 +1251,6 @@
                 vm.RemoveClass('vip')
                 vm.RemoveClass('big')
             } else {
-                $(".switch").addClass('switch_zj')
-                $(".switch_right").addClass('right_zj')
-                $(".switch .switch_icon").addClass('icon_zj')
-                $(".switch .user_pro").text("大会员")
-                $(".switch").show()
                 thisClass.InitPersonal(r);
                 extend(1)
             }

+ 688 - 679
src/jfw/modules/common/src/qfw/util/jy/subscribepush.go

@@ -1,787 +1,796 @@
 package jy
 
 import (
-	"encoding/json"
-	"fmt"
-	"log"
-	mg "mongodb"
-	. "qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/mysql"
-	"qfw/util/redis"
-	"strconv"
-	"strings"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
+    "encoding/json"
+    "fmt"
+    "log"
+    mg "mongodb"
+    . "qfw/util"
+    "qfw/util/elastic"
+    "qfw/util/mysql"
+    "qfw/util/redis"
+    "strconv"
+    "strings"
+    "time"
+
+    "go.mongodb.org/mongo-driver/bson/primitive"
 )
 
 const (
-	threeDay  = 172800
-	halfOfDay = 43200
+    threeDay  = 172800
+    halfOfDay = 43200
 )
 
 type SubPushList struct {
-	Id              string      `json:"_id"`
-	Title           string      `json:"title"`
-	Area            string      `json:"area"`
-	Buyerclass      string      `json:"buyerclass"`
-	Type            string      `json:"type"`
-	S_subscopeclass string      `json:"s_subscopeclass"`
-	Publishtime     int64       `json:"publishtime"`
-	Ca_index        int64       `json:"ca_index"`
-	Ca_date         int64       `json:"ca_date"`
-	Ca_isvisit      int         `json:"ca_isvisit"`
-	Ca_isvip        int         `json:"ca_isvip"`
-	Ca_type         int         `json:"ca_type"`
-	Matchkeys       []string    `json:"matchkeys"`
-	Budget          interface{} `json:"budget"`
-	Bidamount       interface{} `json:"bidamount"`
-	Collection      int         `json:"collection"`
-	Buyer           string      `json:"buyer"`
-	ProjectName     string      `json:"projectName"`
-	S_winner        string      `json:"s_winner"`
-	Bidopentime     int64       `json:"bidopentime"`
+    Id              string      `json:"_id"`
+    Title           string      `json:"title"`
+    Area            string      `json:"area"`
+    Buyerclass      string      `json:"buyerclass"`
+    Type            string      `json:"type"`
+    S_subscopeclass string      `json:"s_subscopeclass"`
+    Publishtime     int64       `json:"publishtime"`
+    Ca_index        int64       `json:"ca_index"`
+    Ca_date         int64       `json:"ca_date"`
+    Ca_isvisit      int         `json:"ca_isvisit"`
+    Ca_isvip        int         `json:"ca_isvip"`
+    Ca_type         int         `json:"ca_type"`
+    Matchkeys       []string    `json:"matchkeys"`
+    Budget          interface{} `json:"budget"`
+    Bidamount       interface{} `json:"bidamount"`
+    Collection      int         `json:"collection"`
+    Buyer           string      `json:"buyer"`
+    ProjectName     string      `json:"projectName"`
+    S_winner        string      `json:"s_winner"`
+    Bidopentime     int64       `json:"bidopentime"`
 }
 
 const (
-	pageSize            = 50
-	pageSizes           = 10
-	AllSubPushCacheSize = 250
-	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner"],"from":0,"size":%d}`
-	mongodb_fields      = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"s_winner":1,"bidopentime":1,"buyer":1,"projectname":1}`
-	querys              = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","title","detail","area","city","publishtime","projectname","buyer","buyerclass","s_winner","bidamount","subtype","toptype","href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel"]}`
-
-	MemberFlag   = "m"
-	SubVipFlag   = "v"
-	EntnicheFlag = "s"
-	SubFreeFlag  = ""
+    pageSize            = 50
+    pageSizes           = 10
+    AllSubPushCacheSize = 250
+    query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner"],"from":0,"size":%d}`
+    mongodb_fields      = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"s_winner":1,"bidopentime":1,"buyer":1,"projectname":1}`
+    querys              = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","title","detail","area","city","publishtime","projectname","buyer","buyerclass","s_winner","bidamount","subtype","toptype","href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel"]}`
+
+    MemberFlag   = "m"
+    SubVipFlag   = "v"
+    EntnicheFlag = "s"
+    SubFreeFlag  = ""
 )
 
 var aboutDbMsg map[string]*AboutDbMsg = map[string]*AboutDbMsg{
-	SubFreeFlag:  &AboutDbMsg{"pushsubscribe", "subpush"},
-	SubVipFlag:   &AboutDbMsg{"pushsubscribe", "subpush"},
-	MemberFlag:   &AboutDbMsg{"pushmember", "memberpush"},
-	EntnicheFlag: &AboutDbMsg{"pushentniche", "pushentniche"},
+    SubFreeFlag:  &AboutDbMsg{"pushsubscribe", "subpush"},
+    SubVipFlag:   &AboutDbMsg{"pushsubscribe", "subpush"},
+    MemberFlag:   &AboutDbMsg{"pushmember", "memberpush"},
+    EntnicheFlag: &AboutDbMsg{"pushentniche", "pushentniche"},
 }
 
 type AboutDbMsg struct {
-	MysqlTable   string
-	RedisKeyFlag string
+    MysqlTable   string
+    RedisKeyFlag string
 }
 
 type SubPush struct {
-	Date  string
-	Datas []*SubPushList
-	Count int64
+    Date  string
+    Datas []*SubPushList
+    Count int64
 }
 
 type PushCa struct {
-	Date   int64
-	InfoId string
-	Visit  int
-	Index  int64
-	Keys   []string
-	Type   int
-	Isvip  int
+    Date   int64
+    InfoId string
+    Visit  int
+    Index  int64
+    Keys   []string
+    Type   int
+    Isvip  int
 }
 
 //查询参数
 type SubPushQueryParam struct {
-	Mgo_bidding   mg.MongodbSim //
-	Bidding       string        //
-	Bidding_back  string        //
-	PushMysql     *mysql.Mysql  //
-	UserId        string        //用户id
-	PageNum       int           //页面
-	PageSize      int           //每页数量
-	SelectTime    string        //时间
-	Area          string        //区域
-	City          string        //城市
-	Buyerclass    string        //采购单位行业
-	Subtype       string        //信息类型 二级分类
-	Subscopeclass string        //信息行业
-	Key           string        //订阅词
-	Export        bool          //导出
-	EntId         int
+    Mgo_bidding   mg.MongodbSim //
+    Bidding       string        //
+    Bidding_back  string        //
+    PushMysql     *mysql.Mysql  //
+    UserId        string        //用户id
+    PageNum       int           //页面
+    PageSize      int           //每页数量
+    SelectTime    string        //时间
+    Area          string        //区域
+    City          string        //城市
+    Buyerclass    string        //采购单位行业
+    Subtype       string        //信息类型 二级分类
+    Subscopeclass string        //信息行业
+    Key           string        //订阅词
+    Export        bool          //导出
+    EntId         int
 }
 
 func (spqp *SubPushQueryParam) IsEmpty() bool {
-	return spqp.SelectTime == "" && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == ""
+    return spqp.SelectTime == "" && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == ""
 }
 
 type subscribePush struct {
-	ModuleFlag string
+    ModuleFlag string
 }
 
 func NewSubscribePush(module ...string) *subscribePush {
-	m := ""
-	if len(module) > 0 {
-		m = module[0]
-	}
-	return &subscribePush{m}
+    m := ""
+    if len(module) > 0 {
+        m = module[0]
+    }
+    return &subscribePush{m}
 }
 
 //从pushcache_2_a中取
 func (h *subscribePush) GetTodayCache(userId string) (*SubPush, error) {
-	pc_a, err := redis.GetNewBytes("pushcache_2_b", h.todayKey(userId))
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p *SubPush
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
+    pc_a, err := redis.GetNewBytes("pushcache_2_b", h.todayKey(userId))
+    if err != nil {
+        return nil, err
+    }
+    if pc_a == nil {
+        return nil, nil
+    }
+    var p *SubPush
+    if err := json.Unmarshal(*pc_a, &p); err != nil {
+        return nil, err
+    }
+    return p, nil
 }
 
 //往pushcache_2_a中放
 func (h *subscribePush) PutTodayCache(userId string, pc_a *SubPush) {
-	redis.Put("pushcache_2_b", h.todayKey(userId), pc_a, threeDay)
+    redis.Put("pushcache_2_b", h.todayKey(userId), pc_a, threeDay)
 }
 
 //获取redis key
 func (s *subscribePush) todayKey(userId string) string {
-	return fmt.Sprintf("%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId)
+    return fmt.Sprintf("%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId)
 }
 func (s *subscribePush) allKey(userId string) string {
-	return fmt.Sprintf("all_%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId)
+    log.Println(fmt.Sprintf("all_%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId))
+    return fmt.Sprintf("all_%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId)
 }
 
 //历史推送记录中单条信息格式化
 func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}) *SubPushList {
-	area := ObjToString((*info)["area"])
-	if area == "A" {
-		area = "全国"
-	}
-	industry := ObjToString((*info)["s_subscopeclass"])
-	scs := strings.Split(industry, ",")
-	if len(scs) > 0 {
-		industry = scs[0]
-		if industry != "" {
-			iss := strings.Split(industry, "_")
-			if len(iss) > 0 {
-				industry = iss[0]
-			}
-		}
-	}
-	infotype := ObjToString((*info)["subtype"])
-	if infotype == "" {
-		infotype = ObjToString((*info)["toptype"])
-	}
-	if infotype == "" {
-		infotype = ObjToString((*info)["type"])
-		if infotype == "tender" {
-			infotype = "招标"
-		} else if infotype == "bid" {
-			infotype = "中标"
-		}
-	}
-	_id := p.InfoId
-	if _id == "" {
-		_id = ObjToString((*info)["_id"])
-	}
-	return &SubPushList{
-		Id:              EncodeArticleId2ByCheck(_id),
-		Title:           ObjToString((*info)["title"]),
-		Area:            area,
-		Buyerclass:      ObjToString((*info)["buyerclass"]),
-		Type:            infotype,
-		S_subscopeclass: industry,
-		Publishtime:     Int64All((*info)["publishtime"]),
-		Ca_index:        p.Index,
-		Ca_date:         p.Date,
-		Ca_isvisit:      p.Visit,
-		Ca_isvip:        p.Isvip,
-		Ca_type:         p.Type,
-		Matchkeys:       p.Keys,
-		Budget:          (*info)["budget"],
-		Bidamount:       (*info)["bidamount"],
-		Buyer:           ObjToString((*info)["buyer"]),
-		ProjectName:     ObjToString((*info)["projectname"]),
-		S_winner:        ObjToString((*info)["s_winner"]),
-		Bidopentime:     Int64All((*info)["bidopentime"]),
-	}
+    area := ObjToString((*info)["area"])
+    if area == "A" {
+        area = "全国"
+    }
+    industry := ObjToString((*info)["s_subscopeclass"])
+    scs := strings.Split(industry, ",")
+    if len(scs) > 0 {
+        industry = scs[0]
+        if industry != "" {
+            iss := strings.Split(industry, "_")
+            if len(iss) > 0 {
+                industry = iss[0]
+            }
+        }
+    }
+    infotype := ObjToString((*info)["subtype"])
+    if infotype == "" {
+        infotype = ObjToString((*info)["toptype"])
+    }
+    if infotype == "" {
+        infotype = ObjToString((*info)["type"])
+        if infotype == "tender" {
+            infotype = "招标"
+        } else if infotype == "bid" {
+            infotype = "中标"
+        }
+    }
+    _id := p.InfoId
+    if _id == "" {
+        _id = ObjToString((*info)["_id"])
+    }
+    return &SubPushList{
+        Id:              EncodeArticleId2ByCheck(_id),
+        Title:           ObjToString((*info)["title"]),
+        Area:            area,
+        Buyerclass:      ObjToString((*info)["buyerclass"]),
+        Type:            infotype,
+        S_subscopeclass: industry,
+        Publishtime:     Int64All((*info)["publishtime"]),
+        Ca_index:        p.Index,
+        Ca_date:         p.Date,
+        Ca_isvisit:      p.Visit,
+        Ca_isvip:        p.Isvip,
+        Ca_type:         p.Type,
+        Matchkeys:       p.Keys,
+        Budget:          (*info)["budget"],
+        Bidamount:       (*info)["bidamount"],
+        Buyer:           ObjToString((*info)["buyer"]),
+        ProjectName:     ObjToString((*info)["projectname"]),
+        S_winner:        ObjToString((*info)["s_winner"]),
+        Bidopentime:     Int64All((*info)["bidopentime"]),
+    }
 }
 
 func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total int64, result []*SubPushList) {
-	log.Println(spqp.UserId, s.ModuleFlag, "subscribePush query param:", "SelectTime", spqp.SelectTime, "Area", spqp.Area, "City", spqp.City, "Subtype", spqp.Subtype, "Subscopeclass", spqp.Subscopeclass, "Buyerclass", spqp.Buyerclass, "Key", spqp.Key, "PageNum", spqp.PageNum)
-	if spqp.UserId == "" {
-		return
-	}
-	if spqp.PageNum < 1 {
-		spqp.PageNum = 1
-	}
-	if spqp.PageSize < 1 || spqp.PageSize > pageSize {
-		if !spqp.Export {
-			spqp.PageSize = pageSize
-		} else { //数据导出查询20000条限制
-			if spqp.PageSize < 1 || spqp.PageSize > 20000 {
-				spqp.PageSize = 20000
-			}
-		}
-	}
-	starttime, endtime := int64(0), int64(0)
-	st, et := "", ""
-	now := time.Now()
-	if spqp.SelectTime == "today" { //今天
-		starttime = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
-	} else if spqp.SelectTime == "yesterday" { //昨天
-		starttime = time.Date(now.Year(), now.Month(), now.Day()-1, 0, 0, 0, 0, time.Local).Unix()
-		endtime = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
-	} else if spqp.SelectTime == "lately-7" { //最近7天
-		starttime = time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix()
-	} else if spqp.SelectTime == "lately-30" { //最近30天
-		starttime = time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix()
-	} else if spqp.SelectTime == "lastyear" { //去年
-		starttime = time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Unix()
-		endtime = time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Unix()
-	} else if len(strings.Split(spqp.SelectTime, "_")) == 2 {
-		st = strings.Split(spqp.SelectTime, "_")[0]
-		starttime, _ = strconv.ParseInt(st, 0, 64)
-		et = strings.Split(spqp.SelectTime, "_")[1]
-		endtime, _ = strconv.ParseInt(et, 0, 64)
-		if endtime > 0 {
-			etTime := time.Unix(endtime, 0)
-			endtime = time.Date(etTime.Year(), etTime.Month(), etTime.Day(), 23, 59, 59, 0, time.Local).Unix()
-		}
-	}
-	nowFormat := NowFormat(Date_Short_Layout)
-	start := (spqp.PageNum - 1) * spqp.PageSize
-	end := start + spqp.PageSize
-	//时间是今天,没有别的过滤条件
-	if nowFormat == FormatDateByInt64(&starttime, Date_Short_Layout) && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == "" {
-		subPush, err := s.GetTodayCache(spqp.UserId)
-		if err != nil {
-			log.Println(spqp.UserId, "GetTodayCache Error", err)
-		}
-		if err != nil || subPush == nil || subPush.Date != nowFormat || len(subPush.Datas) == 0 {
-			list, countSearch := s.getDatasFromMysql(spqp, starttime, endtime, spqp.PageSize, false)
-			subPush = &SubPush{
-				Date:  nowFormat,
-				Datas: list,
-				Count: countSearch,
-			}
-			s.PutTodayCache(spqp.UserId, subPush)
-		}
-		length := len(subPush.Datas)
-		if end > length {
-			end = length
-		}
-		if start < length {
-			result = subPush.Datas[start:end]
-		}
-		total = int64(length)
-	} else if spqp.IsEmpty() && (spqp.PageNum-1)*spqp.PageSize <= 250 { //全部,没有过滤条件 之前缓存5页*50条=250
-		allCache, err := s.GetAllCache(spqp.UserId)
-		if err != nil {
-			log.Println(spqp.UserId, "GetAllCache Error", err)
-		}
-		if err != nil || allCache == nil || allCache.Date != nowFormat || len(allCache.Datas) == 0 {
-			spqp.PageNum = 1
-			list, countSearch := s.getDatasFromMysql(spqp, starttime, endtime, AllSubPushCacheSize, true)
-			allCache = &SubPush{
-				Date:  nowFormat,
-				Datas: list,
-				Count: countSearch,
-			}
-			s.PutAllCache(spqp.UserId, allCache)
-		}
-		length := len(allCache.Datas)
-		if end > length {
-			end = length
-		}
-		if start < length {
-			result = allCache.Datas[start:end]
-		}
-		total = allCache.Count
-	} else {
-		result, total = s.getDatasFromMysql(spqp, starttime, endtime, spqp.PageSize, true)
-	}
-	if result == nil {
-		result = []*SubPushList{}
-	}
-	hasNextPage = len(result) >= spqp.PageSize
-	return
+    log.Println(spqp.UserId, s.ModuleFlag, "subscribePush query param:", "SelectTime", spqp.SelectTime, "Area", spqp.Area, "City", spqp.City, "Subtype", spqp.Subtype, "Subscopeclass", spqp.Subscopeclass, "Buyerclass", spqp.Buyerclass, "Key", spqp.Key, "PageNum", spqp.PageNum)
+    if spqp.UserId == "" {
+        return
+    }
+    if spqp.PageNum < 1 {
+        spqp.PageNum = 1
+    }
+    if spqp.PageSize < 1 || spqp.PageSize > pageSize {
+        if !spqp.Export {
+            spqp.PageSize = pageSize
+        } else { //数据导出查询20000条限制
+            if spqp.PageSize < 1 || spqp.PageSize > 20000 {
+                spqp.PageSize = 20000
+            }
+        }
+    }
+    starttime, endtime := int64(0), int64(0)
+    st, et := "", ""
+    now := time.Now()
+    log.Println(4444)
+    if spqp.SelectTime == "today" { //今天
+        starttime = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+    } else if spqp.SelectTime == "yesterday" { //昨天
+        starttime = time.Date(now.Year(), now.Month(), now.Day()-1, 0, 0, 0, 0, time.Local).Unix()
+        endtime = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+    } else if spqp.SelectTime == "lately-7" { //最近7天
+        starttime = time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix()
+    } else if spqp.SelectTime == "lately-30" { //最近30天
+        starttime = time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix()
+    } else if spqp.SelectTime == "lastyear" { //去年
+        starttime = time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Unix()
+        endtime = time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Unix()
+    } else if len(strings.Split(spqp.SelectTime, "_")) == 2 {
+        st = strings.Split(spqp.SelectTime, "_")[0]
+        starttime, _ = strconv.ParseInt(st, 0, 64)
+        et = strings.Split(spqp.SelectTime, "_")[1]
+        endtime, _ = strconv.ParseInt(et, 0, 64)
+        if endtime > 0 {
+            etTime := time.Unix(endtime, 0)
+            endtime = time.Date(etTime.Year(), etTime.Month(), etTime.Day(), 23, 59, 59, 0, time.Local).Unix()
+        }
+    }
+    log.Println(2222)
+    nowFormat := NowFormat(Date_Short_Layout)
+    start := (spqp.PageNum - 1) * spqp.PageSize
+    end := start + spqp.PageSize
+    //时间是今天,没有别的过滤条件
+    if nowFormat == FormatDateByInt64(&starttime, Date_Short_Layout) && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == "" {
+
+        log.Println("a1")
+        subPush, err := s.GetTodayCache(spqp.UserId)
+        if err != nil {
+            log.Println(spqp.UserId, "GetTodayCache Error", err)
+        }
+        if err != nil || subPush == nil || subPush.Date != nowFormat || len(subPush.Datas) == 0 {
+            list, countSearch := s.getDatasFromMysql(spqp, starttime, endtime, spqp.PageSize, false)
+            subPush = &SubPush{
+                Date:  nowFormat,
+                Datas: list,
+                Count: countSearch,
+            }
+            s.PutTodayCache(spqp.UserId, subPush)
+        }
+        length := len(subPush.Datas)
+        if end > length {
+            end = length
+        }
+        if start < length {
+            result = subPush.Datas[start:end]
+        }
+        total = int64(length)
+    } else if spqp.IsEmpty() && (spqp.PageNum-1)*spqp.PageSize <= 250 { //全部,没有过滤条件 之前缓存5页*50条=250
+        log.Println("a2")
+        allCache, err := s.GetAllCache(spqp.UserId)
+        if err != nil {
+            log.Println(spqp.UserId, "GetAllCache Error", err)
+        }
+        if err != nil || allCache == nil || allCache.Date != nowFormat || len(allCache.Datas) == 0 {
+            log.Println("a3")
+            spqp.PageNum = 1
+            log.Println(1111)
+            list, countSearch := s.getDatasFromMysql(spqp, starttime, endtime, AllSubPushCacheSize, true)
+            allCache = &SubPush{
+                Date:  nowFormat,
+                Datas: list,
+                Count: countSearch,
+            }
+            s.PutAllCache(spqp.UserId, allCache)
+        }
+        length := len(allCache.Datas)
+        if end > length {
+            end = length
+        }
+        if start < length {
+            result = allCache.Datas[start:end]
+        }
+        total = allCache.Count
+    } else {
+        log.Println("a4")
+        result, total = s.getDatasFromMysql(spqp, starttime, endtime, spqp.PageSize, true)
+    }
+    if result == nil {
+        result = []*SubPushList{}
+    }
+    hasNextPage = len(result) >= spqp.PageSize
+    return
 }
 func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, endtime int64, size int, isLimit bool) (result []*SubPushList, count int64) {
-	querys := []string{fmt.Sprintf("userid='%s'", spqp.UserId)}
-	//时间
-	if starttime > 0 && endtime > 0 {
-		querys = append(querys, fmt.Sprintf("date>=%d and date<=%d", starttime, endtime))
-	} else if starttime > 0 && endtime == 0 {
-		querys = append(querys, fmt.Sprintf("date>=%d", starttime))
-	} else if starttime == 0 && endtime > 0 {
-		querys = append(querys, fmt.Sprintf("date<=%d", endtime))
-	}
-	if spqp.Area != "" || spqp.City != "" {
-		var sqlAreaCity = ""
-		//城市
-		city := []string{}
-		for _, v := range strings.Split(spqp.City, ",") {
-			if PushMapping.City[v] > 0 {
-				city = append(city, fmt.Sprint(PushMapping.City[v]))
-			} else {
-				city = append(city, "-1")
-			}
-		}
-		if len(city) == 1 {
-			city = append(city, "9999")
-		}
-		if len(city) > 0 {
-			sqlAreaCity = fmt.Sprintf("city in (%s)", strings.Join(city, ","))
-		}
-		//区域
-		var sqlArea = ""
-		area := []string{}
-		for _, v := range strings.Split(spqp.Area, ",") {
-			if PushMapping.Area[v] > 0 {
-				area = append(area, fmt.Sprint(PushMapping.Area[v]))
-			} else {
-				area = append(area, "-1")
-			}
-		}
-		if len(area) == 1 {
-			area = append(area, "9999")
-		}
-		if len(area) > 0 {
-			sqlArea = fmt.Sprintf("area in (%s)", strings.Join(area, ","))
-		}
-		if sqlAreaCity != "" && sqlArea != "" {
-			sqlAreaCity = "( " + sqlAreaCity + " or " + sqlArea + " )"
-		} else if sqlAreaCity == "" && sqlArea != "" {
-			sqlAreaCity = sqlArea
-		}
-		if sqlAreaCity != "" {
-			querys = append(querys, sqlAreaCity)
-		}
-	}
-	//采购单位行业
-	if spqp.Buyerclass != "" {
-		buyerclass := []string{}
-		for _, v := range strings.Split(spqp.Buyerclass, ",") {
-			buyerclass = append(buyerclass, fmt.Sprint(PushMapping.Buyerclass[v]))
-		}
-		if len(buyerclass) == 1 {
-			buyerclass = append(buyerclass, "9999")
-		}
-		if len(buyerclass) > 0 {
-			querys = append(querys, fmt.Sprintf("buyerclass in (%s)", strings.Join(buyerclass, ",")))
-		}
-	}
-	//信息类型
-	if spqp.Subtype != "" {
-		subtype := []string{}
-		for _, v := range strings.Split(spqp.Subtype, ",") {
-			subtype = append(subtype, fmt.Sprint(PushMapping.Subtype[v]))
-		}
-		if len(subtype) == 1 {
-			subtype = append(subtype, "9999")
-		}
-		if len(subtype) > 0 {
-			querys = append(querys, fmt.Sprintf("subtype in (%s)", strings.Join(subtype, ",")))
-		}
-	}
-	//信息行业
-	if spqp.Subscopeclass != "" {
-		find_in_set := []string{}
-		for _, v := range strings.Split(spqp.Subscopeclass, ",") {
-			find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%d',subscopeclass)", PushMapping.Subscopeclass[v]))
-		}
-		if len(find_in_set) == 1 {
-			querys = append(querys, find_in_set[0])
-		} else if len(find_in_set) > 1 {
-			querys = append(querys, fmt.Sprintf("(%s)", strings.Join(find_in_set, " or ")))
-		}
-	}
-	//关键词
-	if spqp.Key != "" {
-		find_in_set := []string{}
-		for _, v := range strings.Split(spqp.Key, ",") {
-			find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(matchkeys,'+',','),' ',','))", v))
-		}
-		if len(find_in_set) == 1 {
-			querys = append(querys, find_in_set[0])
-		} else if len(find_in_set) > 1 {
-			querys = append(querys, fmt.Sprintf("(%s)", strings.Join(find_in_set, " or ")))
-		}
-	}
-	searchSql := fmt.Sprintf(" from %s where %s order by id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "))
-	fmt.Println("searchSql", searchSql)
-	//查询总数
-	count = spqp.PushMysql.CountBySql(fmt.Sprintf("select count(id)" + searchSql))
-
-	findSql := "select id,date,infoid,isvisit,matchkeys,type"
-	if s.ModuleFlag != MemberFlag {
-		if s.ModuleFlag == EntnicheFlag {
-
-		} else {
-			findSql += ",isvip"
-		}
-
-	}
-
-	findSql += searchSql
-	if isLimit {
-		findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
-	}
-
-	log.Println(spqp.UserId, "subscribePush query sql:", findSql)
-	list := spqp.PushMysql.SelectBySql(findSql)
-	if list != nil && len(*list) > 0 {
-		pushCas := s.GetJyPushs(*list)
-		result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
-	} else {
-		result = []*SubPushList{}
-	}
-	return
+    querys := []string{fmt.Sprintf("userid='%s'", spqp.UserId)}
+    //时间
+    if starttime > 0 && endtime > 0 {
+        querys = append(querys, fmt.Sprintf("date>=%d and date<=%d", starttime, endtime))
+    } else if starttime > 0 && endtime == 0 {
+        querys = append(querys, fmt.Sprintf("date>=%d", starttime))
+    } else if starttime == 0 && endtime > 0 {
+        querys = append(querys, fmt.Sprintf("date<=%d", endtime))
+    }
+    if spqp.Area != "" || spqp.City != "" {
+        var sqlAreaCity = ""
+        //城市
+        city := []string{}
+        for _, v := range strings.Split(spqp.City, ",") {
+            if PushMapping.City[v] > 0 {
+                city = append(city, fmt.Sprint(PushMapping.City[v]))
+            } else {
+                city = append(city, "-1")
+            }
+        }
+        if len(city) == 1 {
+            city = append(city, "9999")
+        }
+        if len(city) > 0 {
+            sqlAreaCity = fmt.Sprintf("city in (%s)", strings.Join(city, ","))
+        }
+        //区域
+        var sqlArea = ""
+        area := []string{}
+        for _, v := range strings.Split(spqp.Area, ",") {
+            if PushMapping.Area[v] > 0 {
+                area = append(area, fmt.Sprint(PushMapping.Area[v]))
+            } else {
+                area = append(area, "-1")
+            }
+        }
+        if len(area) == 1 {
+            area = append(area, "9999")
+        }
+        if len(area) > 0 {
+            sqlArea = fmt.Sprintf("area in (%s)", strings.Join(area, ","))
+        }
+        if sqlAreaCity != "" && sqlArea != "" {
+            sqlAreaCity = "( " + sqlAreaCity + " or " + sqlArea + " )"
+        } else if sqlAreaCity == "" && sqlArea != "" {
+            sqlAreaCity = sqlArea
+        }
+        if sqlAreaCity != "" {
+            querys = append(querys, sqlAreaCity)
+        }
+    }
+    //采购单位行业
+    if spqp.Buyerclass != "" {
+        buyerclass := []string{}
+        for _, v := range strings.Split(spqp.Buyerclass, ",") {
+            buyerclass = append(buyerclass, fmt.Sprint(PushMapping.Buyerclass[v]))
+        }
+        if len(buyerclass) == 1 {
+            buyerclass = append(buyerclass, "9999")
+        }
+        if len(buyerclass) > 0 {
+            querys = append(querys, fmt.Sprintf("buyerclass in (%s)", strings.Join(buyerclass, ",")))
+        }
+    }
+    //信息类型
+    if spqp.Subtype != "" {
+        subtype := []string{}
+        for _, v := range strings.Split(spqp.Subtype, ",") {
+            subtype = append(subtype, fmt.Sprint(PushMapping.Subtype[v]))
+        }
+        if len(subtype) == 1 {
+            subtype = append(subtype, "9999")
+        }
+        if len(subtype) > 0 {
+            querys = append(querys, fmt.Sprintf("subtype in (%s)", strings.Join(subtype, ",")))
+        }
+    }
+    //信息行业
+    if spqp.Subscopeclass != "" {
+        find_in_set := []string{}
+        for _, v := range strings.Split(spqp.Subscopeclass, ",") {
+            find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%d',subscopeclass)", PushMapping.Subscopeclass[v]))
+        }
+        if len(find_in_set) == 1 {
+            querys = append(querys, find_in_set[0])
+        } else if len(find_in_set) > 1 {
+            querys = append(querys, fmt.Sprintf("(%s)", strings.Join(find_in_set, " or ")))
+        }
+    }
+    //关键词
+    if spqp.Key != "" {
+        find_in_set := []string{}
+        for _, v := range strings.Split(spqp.Key, ",") {
+            find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(matchkeys,'+',','),' ',','))", v))
+        }
+        if len(find_in_set) == 1 {
+            querys = append(querys, find_in_set[0])
+        } else if len(find_in_set) > 1 {
+            querys = append(querys, fmt.Sprintf("(%s)", strings.Join(find_in_set, " or ")))
+        }
+    }
+    searchSql := fmt.Sprintf(" from %s where %s order by id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, strings.Join(querys, " and "))
+    fmt.Println("searchSql", searchSql)
+    //查询总数
+    count = spqp.PushMysql.CountBySql(fmt.Sprintf("select count(id)" + searchSql))
+
+    findSql := "select id,date,infoid,isvisit,matchkeys,type"
+    if s.ModuleFlag != MemberFlag {
+        if s.ModuleFlag == EntnicheFlag {
+
+        } else {
+            findSql += ",isvip"
+        }
+
+    }
+
+    findSql += searchSql
+    if isLimit {
+        findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
+    }
+
+    log.Println(spqp.UserId, "subscribePush query sql:", findSql)
+    list := spqp.PushMysql.SelectBySql(findSql)
+    if list != nil && len(*list) > 0 {
+        pushCas := s.GetJyPushs(*list)
+        result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
+    } else {
+        result = []*SubPushList{}
+    }
+    return
 }
 
 //获取历史推送
 func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*PushCa) {
-	pushCas = []*PushCa{}
-	for _, v := range datas {
-		keys := []string{}
-		if matchkeys := ObjToString(v["matchkeys"]); matchkeys != "" {
-			keys = strings.Split(matchkeys, " ")
-		}
-		pushCas = append(pushCas, &PushCa{
-			Date:   Int64All(v["date"]),
-			InfoId: ObjToString(v["infoid"]),
-			Visit:  IntAll(v["isvisit"]),
-			Index:  Int64All(v["id"]),
-			Keys:   keys,
-			Type:   IntAll(v["type"]),
-			Isvip:  IntAll(v["isvip"]),
-		})
-	}
-	return
+    pushCas = []*PushCa{}
+    for _, v := range datas {
+        keys := []string{}
+        if matchkeys := ObjToString(v["matchkeys"]); matchkeys != "" {
+            keys = strings.Split(matchkeys, " ")
+        }
+        pushCas = append(pushCas, &PushCa{
+            Date:   Int64All(v["date"]),
+            InfoId: ObjToString(v["infoid"]),
+            Visit:  IntAll(v["isvisit"]),
+            Index:  Int64All(v["id"]),
+            Keys:   keys,
+            Type:   IntAll(v["type"]),
+            Isvip:  IntAll(v["isvip"]),
+        })
+    }
+    return
 }
 
 //根据id取内容
 func (s *subscribePush) GetInfoByIds(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, pushCas []*PushCa) []*SubPushList {
-	array := make([]*SubPushList, len(pushCas))
-	if len(pushCas) == 0 {
-		return array
-	}
-	m := map[string]bool{}
-	ids := []string{}
-	for _, v := range pushCas {
-		if m[v.InfoId] {
-			continue
-		}
-		m[v.InfoId] = true
-		ids = append(ids, v.InfoId)
-	}
-	infos := map[string]map[string]interface{}{}
-	//redis
-
-	es_ids := []string{}
-	for _, v := range ids {
-		info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
-		if info_i != nil {
-			info_m, _ := info_i.(map[string]interface{})
-			info_m["_id"] = v
-			infos[v] = info_m
-		} else {
-			es_ids = append(es_ids, v)
-		}
-	}
-	//	log.Println(es_ids)
-	//elasticsearch
-	if len(es_ids) > 0 {
-		list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
-		if list != nil {
-			for _, v := range *list {
-				_id := ObjToString(v["_id"])
-				infos[_id] = v
-			}
-		}
-	}
-	//mongodb bidding
-	mgo_ids := []primitive.ObjectID{}
-	for _, v := range es_ids {
-		if infos[v] == nil {
-			_id, _ := primitive.ObjectIDFromHex(v)
-			mgo_ids = append(mgo_ids, _id)
-		}
-	}
-	if len(mgo_ids) > 0 {
-		list, ok := Mgo_bidding.Find(bidding, map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
-		if ok && *list != nil {
-			for _, v := range *list {
-				_id := mg.BsonIdToSId(v["_id"])
-				v["_id"] = _id
-				infos[_id] = v
-			}
-		}
-	}
-	//mongodb bidding_back
-	mgo_back_ids := []primitive.ObjectID{}
-	for _, v := range mgo_ids {
-		if infos[mg.BsonIdToSId(v)] == nil {
-			mgo_back_ids = append(mgo_back_ids, v)
-		}
-	}
-	if len(mgo_back_ids) > 0 {
-		list, ok := Mgo_bidding.Find(bidding_back, map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
-		if ok && *list != nil {
-			for _, v := range *list {
-				_id := mg.BsonIdToSId(v["_id"])
-				v["_id"] = _id
-				infos[_id] = v
-			}
-		}
-	}
-	//
-	for k, v := range pushCas {
-		info := infos[v.InfoId]
-		if info == nil {
-			info = map[string]interface{}{}
-		}
-		array[k] = s.InfoFormat(v, &info)
-	}
-	return array
+    array := make([]*SubPushList, len(pushCas))
+    if len(pushCas) == 0 {
+        return array
+    }
+    m := map[string]bool{}
+    ids := []string{}
+    for _, v := range pushCas {
+        if m[v.InfoId] {
+            continue
+        }
+        m[v.InfoId] = true
+        ids = append(ids, v.InfoId)
+    }
+    infos := map[string]map[string]interface{}{}
+    //redis
+
+    es_ids := []string{}
+    for _, v := range ids {
+        info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
+        if info_i != nil {
+            info_m, _ := info_i.(map[string]interface{})
+            info_m["_id"] = v
+            infos[v] = info_m
+        } else {
+            es_ids = append(es_ids, v)
+        }
+    }
+    //	log.Println(es_ids)
+    //elasticsearch
+    if len(es_ids) > 0 {
+        list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
+        if list != nil {
+            for _, v := range *list {
+                _id := ObjToString(v["_id"])
+                infos[_id] = v
+            }
+        }
+    }
+    //mongodb bidding
+    mgo_ids := []primitive.ObjectID{}
+    for _, v := range es_ids {
+        if infos[v] == nil {
+            _id, _ := primitive.ObjectIDFromHex(v)
+            mgo_ids = append(mgo_ids, _id)
+        }
+    }
+    if len(mgo_ids) > 0 {
+        list, ok := Mgo_bidding.Find(bidding, map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
+        if ok && *list != nil {
+            for _, v := range *list {
+                _id := mg.BsonIdToSId(v["_id"])
+                v["_id"] = _id
+                infos[_id] = v
+            }
+        }
+    }
+    //mongodb bidding_back
+    mgo_back_ids := []primitive.ObjectID{}
+    for _, v := range mgo_ids {
+        if infos[mg.BsonIdToSId(v)] == nil {
+            mgo_back_ids = append(mgo_back_ids, v)
+        }
+    }
+    if len(mgo_back_ids) > 0 {
+        list, ok := Mgo_bidding.Find(bidding_back, map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
+        if ok && *list != nil {
+            for _, v := range *list {
+                _id := mg.BsonIdToSId(v["_id"])
+                v["_id"] = _id
+                infos[_id] = v
+            }
+        }
+    }
+    //
+    for k, v := range pushCas {
+        info := infos[v.InfoId]
+        if info == nil {
+            info = map[string]interface{}{}
+        }
+        array[k] = s.InfoFormat(v, &info)
+    }
+    return array
 }
 
 //保存最近7天的数据到历史记录
 func (s *subscribePush) MakeHistoryDatas(MQFW mg.MongodbSim, PushMysql *mysql.Mysql, userId string, PushView func(userid, allquery, field string, pageNum, pageSize int) (keys []interface{}, list *[]map[string]interface{})) (bool, []*SubPushList) {
-	log.Println("匹配最近7天数据", userId)
-	field := `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount"`
-	allquery := `{"range":{"publishtime":{"gt":%s}}}`
-	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
-	//allquery = ``
-	keys, list := PushView(userId, allquery, field, 1, 50)
-	if list == nil || len(*list) == 0 {
-		return true, nil
-	}
-	matchkeys := []string{}
-	for _, v := range keys {
-		matchkeys = append(matchkeys, strings.Join(ObjArrToStringArr(v.([]interface{})), "+"))
-	}
-	publishTitle := map[string]bool{}
-	now := time.Now().Unix()
-	var array []*SubPushList
-	for i := len(*list) - 1; i >= 0; i-- {
-		v := (*list)[i]
-		var myInsert = make(map[string]interface{})
-		title := strings.Replace(v["title"].(string), "\n", "", -1)
-		area_check := ObjToString(v["area"])
-		if area_check == "A" {
-			area_check = "全国"
-		}
-		if publishTitle[area_check+title] {
-			continue
-		} else {
-			publishTitle[area_check+title] = true
-		}
-		myInsert["userid"] = userId
-		_id := ObjToString(v["_id"])
-		myInsert["infoid"] = _id
-		redisKey := fmt.Sprintf("pushinfo_%s_%s", userId, _id)
-		if isExists, _ := redis.Exists("pushcache_2_a", redisKey); isExists {
-			continue
-		}
-		myInsert["date"] = now
-		myInsert["matchkeys"] = strings.Join(matchkeys, " ")
-		if area_check != "" {
-			if area_check == "全国" {
-				myInsert["area"] = 0
-			} else if area_mapping, ok := PushMapping.Area[area_check]; ok {
-				myInsert["area"] = area_mapping
-			}
-		}
-		if city_check := ObjToString(v["city"]); city_check != "" {
-			if city_mapping, ok := PushMapping.City[city_check]; ok {
-				myInsert["city"] = city_mapping
-			}
-		}
-		if subtype := ObjToString(v["subtype"]); subtype != "" {
-			if subtype_mapping, ok := PushMapping.Subtype[subtype]; ok {
-				myInsert["subtype"] = subtype_mapping
-			}
-		}
-		if toptype := ObjToString(v["toptype"]); toptype != "" {
-			if toptype_mapping, ok := PushMapping.Toptype[toptype]; ok {
-				myInsert["toptype"] = toptype_mapping
-			}
-		}
-		if buyerclass := ObjToString(v["buyerclass"]); buyerclass != "" {
-			if buyerclass_mapping, ok := PushMapping.Buyerclass[buyerclass]; ok {
-				myInsert["buyerclass"] = buyerclass_mapping
-			}
-		}
-		if s_subscopeclass := ObjToString(v["s_subscopeclass"]); s_subscopeclass != "" {
-			subscopeclass := []string{}
-			for _, v := range strings.Split(s_subscopeclass, ",") {
-				if subscopeclass_mapping, ok := PushMapping.Subscopeclass[v]; ok {
-					subscopeclass = append(subscopeclass, fmt.Sprint(subscopeclass_mapping))
-				}
-			}
-			if len(subscopeclass) > 0 {
-				myInsert["subscopeclass"] = strings.Join(subscopeclass, ",")
-			}
-		}
-		id := PushMysql.Insert("pushsubscribe", myInsert)
-		if id > 0 {
-			redis.Put("pushcache_2_a", redisKey, 1, 86400)
-		} else {
-			continue
-		}
-		array = append(array, s.InfoFormat(&PushCa{
-			InfoId: _id,
-			Date:   now,
-			Index:  id,
-			Keys:   matchkeys,
-		}, &v))
-	}
-	var resultList []*SubPushList
-	for i := len(array) - 1; i >= 0; i-- {
-		resultList = append(resultList, array[i])
-	}
-	return true, resultList
+    log.Println("匹配最近7天数据", userId)
+    field := `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount"`
+    allquery := `{"range":{"publishtime":{"gt":%s}}}`
+    allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
+    //allquery = ``
+    keys, list := PushView(userId, allquery, field, 1, 50)
+    if list == nil || len(*list) == 0 {
+        return true, nil
+    }
+    matchkeys := []string{}
+    for _, v := range keys {
+        matchkeys = append(matchkeys, strings.Join(ObjArrToStringArr(v.([]interface{})), "+"))
+    }
+    publishTitle := map[string]bool{}
+    now := time.Now().Unix()
+    var array []*SubPushList
+    for i := len(*list) - 1; i >= 0; i-- {
+        v := (*list)[i]
+        var myInsert = make(map[string]interface{})
+        title := strings.Replace(v["title"].(string), "\n", "", -1)
+        area_check := ObjToString(v["area"])
+        if area_check == "A" {
+            area_check = "全国"
+        }
+        if publishTitle[area_check+title] {
+            continue
+        } else {
+            publishTitle[area_check+title] = true
+        }
+        myInsert["userid"] = userId
+        _id := ObjToString(v["_id"])
+        myInsert["infoid"] = _id
+        redisKey := fmt.Sprintf("pushinfo_%s_%s", userId, _id)
+        if isExists, _ := redis.Exists("pushcache_2_a", redisKey); isExists {
+            continue
+        }
+        myInsert["date"] = now
+        myInsert["matchkeys"] = strings.Join(matchkeys, " ")
+        if area_check != "" {
+            if area_check == "全国" {
+                myInsert["area"] = 0
+            } else if area_mapping, ok := PushMapping.Area[area_check]; ok {
+                myInsert["area"] = area_mapping
+            }
+        }
+        if city_check := ObjToString(v["city"]); city_check != "" {
+            if city_mapping, ok := PushMapping.City[city_check]; ok {
+                myInsert["city"] = city_mapping
+            }
+        }
+        if subtype := ObjToString(v["subtype"]); subtype != "" {
+            if subtype_mapping, ok := PushMapping.Subtype[subtype]; ok {
+                myInsert["subtype"] = subtype_mapping
+            }
+        }
+        if toptype := ObjToString(v["toptype"]); toptype != "" {
+            if toptype_mapping, ok := PushMapping.Toptype[toptype]; ok {
+                myInsert["toptype"] = toptype_mapping
+            }
+        }
+        if buyerclass := ObjToString(v["buyerclass"]); buyerclass != "" {
+            if buyerclass_mapping, ok := PushMapping.Buyerclass[buyerclass]; ok {
+                myInsert["buyerclass"] = buyerclass_mapping
+            }
+        }
+        if s_subscopeclass := ObjToString(v["s_subscopeclass"]); s_subscopeclass != "" {
+            subscopeclass := []string{}
+            for _, v := range strings.Split(s_subscopeclass, ",") {
+                if subscopeclass_mapping, ok := PushMapping.Subscopeclass[v]; ok {
+                    subscopeclass = append(subscopeclass, fmt.Sprint(subscopeclass_mapping))
+                }
+            }
+            if len(subscopeclass) > 0 {
+                myInsert["subscopeclass"] = strings.Join(subscopeclass, ",")
+            }
+        }
+        id := PushMysql.Insert("pushsubscribe", myInsert)
+        if id > 0 {
+            redis.Put("pushcache_2_a", redisKey, 1, 86400)
+        } else {
+            continue
+        }
+        array = append(array, s.InfoFormat(&PushCa{
+            InfoId: _id,
+            Date:   now,
+            Index:  id,
+            Keys:   matchkeys,
+        }, &v))
+    }
+    var resultList []*SubPushList
+    for i := len(array) - 1; i >= 0; i-- {
+        resultList = append(resultList, array[i])
+    }
+    return true, resultList
 }
 
 //获取用户信息
 func (s *subscribePush) UserInfo(MQFW mg.MongodbSim, userId string) (*map[string]interface{}, int64) {
-	user, ok := MQFW.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1,"o_jy":1,"l_firstpushtime":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1,"i_member_status":1,"o_member_jy":1}`)
-	if !ok || user == nil {
-		return nil, 0
-	}
-	return user, Int64All((*user)["l_firstpushtime"])
+    user, ok := MQFW.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1,"o_jy":1,"l_firstpushtime":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1,"i_member_status":1,"o_member_jy":1}`)
+    if !ok || user == nil {
+        return nil, 0
+    }
+    return user, Int64All((*user)["l_firstpushtime"])
 }
 func (s *subscribePush) Visit(PushMysql *mysql.Mysql, userId string, id int) {
-	if userId == "" {
-		return
-	}
-	PushMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), userId, id)
-	todaySubPush, err := s.GetTodayCache(userId)
-	if err == nil && todaySubPush != nil {
-		for _, v := range todaySubPush.Datas {
-			if v.Ca_index == Int64All(id) {
-				v.Ca_isvisit = 1
-				break
-			}
-		}
-		s.PutTodayCache(userId, todaySubPush)
-	}
-	//
-	allSubPush, err := s.GetAllCache(userId)
-	if err == nil && allSubPush != nil {
-		for _, v := range allSubPush.Datas {
-			if v.Ca_index == Int64All(id) {
-				v.Ca_isvisit = 1
-				break
-			}
-		}
-		s.PutAllCache(userId, allSubPush)
-	}
+    if userId == "" {
+        return
+    }
+    PushMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), userId, id)
+    todaySubPush, err := s.GetTodayCache(userId)
+    if err == nil && todaySubPush != nil {
+        for _, v := range todaySubPush.Datas {
+            if v.Ca_index == Int64All(id) {
+                v.Ca_isvisit = 1
+                break
+            }
+        }
+        s.PutTodayCache(userId, todaySubPush)
+    }
+    //
+    allSubPush, err := s.GetAllCache(userId)
+    if err == nil && allSubPush != nil {
+        for _, v := range allSubPush.Datas {
+            if v.Ca_index == Int64All(id) {
+                v.Ca_isvisit = 1
+                break
+            }
+        }
+        s.PutAllCache(userId, allSubPush)
+    }
 }
 
 //查看全部列表缓存
 func (s *subscribePush) PutAllCache(userId string, datas *SubPush) {
-	redis.Put("pushcache_2_a", s.allKey(userId), datas, threeDay)
+    redis.Put("pushcache_2_a", s.allKey(userId), datas, threeDay)
 }
 
 func (s *subscribePush) GetAllCache(userId string) (*SubPush, error) {
-	return s.GetCache("pushcache_2_a", s.allKey(userId))
+    return s.GetCache("pushcache_2_a", s.allKey(userId))
 }
 
 func (s *subscribePush) GetCache(code, key string) (*SubPush, error) {
-	pc_a, err := redis.GetNewBytes(code, key)
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p *SubPush
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
+    pc_a, err := redis.GetNewBytes(code, key)
+    if err != nil {
+        return nil, err
+    }
+    if pc_a == nil {
+        return nil, nil
+    }
+    var p *SubPush
+    if err := json.Unmarshal(*pc_a, &p); err != nil {
+        return nil, err
+    }
+    return p, nil
 }
 
 //是否收藏
 func (s *subscribePush) MakeCollection(userId string, m *mysql.Mysql, list []*SubPushList) {
-	if list == nil || len(list) == 0 {
-		return
-	}
-	param := []interface{}{userId}
-	wh := []string{}
-	for _, v := range list {
-		array := DecodeArticleId2ByCheck(v.Id)
-		if len(array) == 1 && array[0] != "" {
-			param = append(param, array[0])
-			wh = append(wh, "?")
-		}
-	}
-	if len(wh) > 0 {
-		result := m.SelectBySql(`select bid from bdcollection where userid=? and bid in (`+strings.Join(wh, ",")+`)`, param...)
-		bid_map := map[string]bool{}
-		if result != nil {
-			for _, v := range *result {
-				bid_map[EncodeArticleId2ByCheck(ObjToString(v["bid"]))] = true
-			}
-		}
-		for _, v := range list {
-			if bid_map[v.Id] {
-				v.Collection = 1
-			}
-		}
-	}
+    if list == nil || len(list) == 0 {
+        return
+    }
+    param := []interface{}{userId}
+    wh := []string{}
+    for _, v := range list {
+        array := DecodeArticleId2ByCheck(v.Id)
+        if len(array) == 1 && array[0] != "" {
+            param = append(param, array[0])
+            wh = append(wh, "?")
+        }
+    }
+    if len(wh) > 0 {
+        result := m.SelectBySql(`select bid from bdcollection where userid=? and bid in (`+strings.Join(wh, ",")+`)`, param...)
+        bid_map := map[string]bool{}
+        if result != nil {
+            for _, v := range *result {
+                bid_map[EncodeArticleId2ByCheck(ObjToString(v["bid"]))] = true
+            }
+        }
+        for _, v := range list {
+            if bid_map[v.Id] {
+                v.Collection = 1
+            }
+        }
+    }
 }
 
 //仅移动端首页使用,历史推送7天信息
 func (s *subscribePush) sevenDayKey(userId string) string {
-	return fmt.Sprintf("7day_subpush_%s", userId)
+    return fmt.Sprintf("7day_subpush_%s", userId)
 }
 
 func (s *subscribePush) PutSevenDayCache(userId string, datas []*SubPushList) {
-	redis.Put("pushcache_2_a", s.sevenDayKey(userId), SubPush{Datas: datas}, 7*24*60*60)
+    redis.Put("pushcache_2_a", s.sevenDayKey(userId), SubPush{Datas: datas}, 7*24*60*60)
 }
 
 //从pushcache_2_a中取
 func (s *subscribePush) GetSevenDayCache(userId string) ([]*SubPushList, error) {
-	allPush, _ := s.GetCache("pushcache_2_a", s.sevenDayKey(userId))
-	if allPush != nil && allPush.Datas != nil && len(allPush.Datas) > 0 {
-		return allPush.Datas, nil
-	}
-	return nil, nil
+    allPush, _ := s.GetCache("pushcache_2_a", s.sevenDayKey(userId))
+    if allPush != nil && allPush.Datas != nil && len(allPush.Datas) > 0 {
+        return allPush.Datas, nil
+    }
+    return nil, nil
 }
 
 //历史推送记录中单条信息格式化
 func InfoFormats(info map[string]interface{}, tmp map[string]interface{}) map[string]interface{} {
-	area := ObjToString(info["area"])
-	if area == "A" {
-		area = "全国"
-	}
-	industry := ObjToString(info["s_subscopeclass"])
-	scs := strings.Split(industry, ",")
-	if len(scs) > 0 {
-		industry = scs[0]
-		if industry != "" {
-			iss := strings.Split(industry, "_")
-			if len(iss) > 0 {
-				industry = iss[0]
-			}
-		}
-	}
-	infotype := ObjToString(info["subtype"])
-	if infotype == "" {
-		infotype = ObjToString(info["toptype"])
-	}
-	if infotype == "" {
-		infotype = ObjToString(info["type"])
-		if infotype == "tender" {
-			infotype = "招标"
-		} else if infotype == "bid" {
-			infotype = "中标"
-		}
-	}
-	info["type"] = infotype
-	return info
+    area := ObjToString(info["area"])
+    if area == "A" {
+        area = "全国"
+    }
+    industry := ObjToString(info["s_subscopeclass"])
+    scs := strings.Split(industry, ",")
+    if len(scs) > 0 {
+        industry = scs[0]
+        if industry != "" {
+            iss := strings.Split(industry, "_")
+            if len(iss) > 0 {
+                industry = iss[0]
+            }
+        }
+    }
+    infotype := ObjToString(info["subtype"])
+    if infotype == "" {
+        infotype = ObjToString(info["toptype"])
+    }
+    if infotype == "" {
+        infotype = ObjToString(info["type"])
+        if infotype == "tender" {
+            infotype = "招标"
+        } else if infotype == "bid" {
+            infotype = "中标"
+        }
+    }
+    info["type"] = infotype
+    return info
 }

+ 80 - 77
src/jfw/modules/common/src/qfw/util/jy/switchService.go

@@ -1,28 +1,28 @@
 package jy
 
 import (
-	"fmt"
-	"github.com/go-xweb/httpsession"
-	. "mongodb"
-	"qfw/util"
-	"qfw/util/mysql"
+    "fmt"
+    "github.com/go-xweb/httpsession"
+    . "mongodb"
+    "qfw/util"
+    "qfw/util/mysql"
 )
 
 var SwitchService = &switchService{
-	SessionKey: "vSwitch",
-	Member:     "m",
-	Vip:        "v",
-	Free:       "",
-	Entniche:   "s",
+    SessionKey: "vSwitch",
+    Member:     "m",
+    Vip:        "v",
+    Free:       "",
+    Entniche:   "s",
 }
 
 //切换超级订阅、大会员服务
 type switchService struct {
-	SessionKey string
-	Member     string
-	Vip        string
-	Free       string
-	Entniche   string
+    SessionKey string
+    Member     string
+    Vip        string
+    Free       string
+    Entniche   string
 }
 
 /* 获取当前所选的服务类型
@@ -31,80 +31,83 @@ type switchService struct {
  * @return string 服务类型
  */
 func (s *switchService) Get(session *httpsession.Session, m MongodbSim) string {
-	userId, _ := session.Get("userId").(string)
-	v, _ := session.Get(s.SessionKey).(string)
-	u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1}`)
-	if ok && u != nil {
-		if i_vip_status := util.IntAll((*u)["i_vip_status"]); v == s.Vip && i_vip_status > 0 {
-			return s.Vip
-		} else if i_member_status := util.IntAll((*u)["i_member_status"]); v == s.Member && i_member_status > 0 {
-			return s.Member
-		} else if i_vip_status > 0 {
-			session.Set(s.SessionKey, s.Vip)
-			return s.Vip
-		} else if i_member_status > 0 {
-			session.Set(s.SessionKey, s.Member)
-			return s.Member
-		}
-	}
-	session.Del(s.SessionKey)
-	return s.Free
+    userId, _ := session.Get("userId").(string)
+    v, _ := session.Get(s.SessionKey).(string)
+    u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1}`)
+    if ok && u != nil {
+        if i_vip_status := util.IntAll((*u)["i_vip_status"]); v == s.Vip && i_vip_status > 0 {
+            return s.Vip
+        } else if i_member_status := util.IntAll((*u)["i_member_status"]); v == s.Member && i_member_status > 0 {
+            return s.Member
+        } else if i_vip_status > 0 {
+            session.Set(s.SessionKey, s.Vip)
+            return s.Vip
+        } else if i_member_status > 0 {
+            session.Set(s.SessionKey, s.Member)
+            return s.Member
+        }
+    }
+    session.Del(s.SessionKey)
+    return s.Free
 }
 
 func (s *switchService) GetEntniche(session *httpsession.Session, m MongodbSim, sql *mysql.Mysql) string {
-	userId, _ := session.Get("userId").(string)
-	v, _ := session.Get(s.SessionKey).(string)
-	u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1,"s_phone":1,"s_m_phone":1}`)
-	entniche := false
-	phone:=""
-	if s_phone, _ := (*u)["s_phone"].(string); s_phone != "" {
-		phone = s_phone
-	} else if s_m_phone, _ := (*u)["s_m_phone"].(string); s_m_phone != "" {
-		phone = s_m_phone
-	}
-	if phone != "" {
-		//已购买企业未过期
-		if entInfo := sql.SelectBySql(`SELECT status,isNew FROM entniche_info WHERE id  IN (SELECT ent_id FROM entniche_user where phone = ? and power =1)`, phone); len((*entInfo)) > 0 {
-			for _, v := range (*entInfo) {
-				if util.IntAll(v["status"]) == 1 && util.IntAll(v["isNew"]) == 1{
-					entniche = true
-					break
-				}
-			}
-		}
-	}
-	if ok && u != nil {
-		if i_vip_status := util.IntAll((*u)["i_vip_status"]); v == s.Vip && i_vip_status > 0 {
-			return s.Vip
-		} else if i_member_status := util.IntAll((*u)["i_member_status"]); v == s.Member && i_member_status > 0 {
-			return s.Member
-		} else if i_vip_status > 0 {
-			session.Set(s.SessionKey, s.Vip)
-			return s.Vip
-		} else if entniche {
-			fmt.Println("1231212",entniche)
-			session.Set(s.SessionKey, s.Entniche)
-			return s.Entniche
-		} else if i_member_status > 0 {
-			session.Set(s.SessionKey, s.Member)
-			return s.Member
-		}
-	}
-	session.Del(s.SessionKey)
-	return s.Free
+    userId, _ := session.Get("userId").(string)
+    v, _ := session.Get(s.SessionKey).(string)
+    u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1,"s_phone":1,"s_m_phone":1}`)
+    entniche := false
+    phone := ""
+    if s_phone, _ := (*u)["s_phone"].(string); s_phone != "" {
+        phone = s_phone
+    } else if s_m_phone, _ := (*u)["s_m_phone"].(string); s_m_phone != "" {
+        phone = s_m_phone
+    }
+    if phone != "" {
+        //已购买企业未过期
+        if entInfo := sql.SelectBySql(`SELECT status,isNew FROM entniche_info WHERE id  IN (SELECT ent_id FROM entniche_user where phone = ? and power =1)`, phone); len((*entInfo)) > 0 {
+            for _, v := range (*entInfo) {
+                if util.IntAll(v["status"]) == 1 && util.IntAll(v["isNew"]) == 1 {
+                    entniche = true
+                    break
+                }
+            }
+        }
+    }
+    if ok && u != nil {
+        if i_member_status := util.IntAll((*u)["i_member_status"]); v == s.Member && i_member_status > 0 {
+            return s.Member
+        } else if v == s.Entniche && entniche {
+            session.Set(s.SessionKey, s.Entniche)
+            return s.Entniche
+        } else if i_vip_status := util.IntAll((*u)["i_vip_status"]); v == s.Vip && i_vip_status > 0 {
+            return s.Vip
+        } else if i_member_status > 0 {
+            session.Set(s.SessionKey, s.Member)
+            return s.Member
+        } else if entniche {
+            fmt.Println("1231212", entniche)
+            session.Set(s.SessionKey, s.Entniche)
+            return s.Entniche
+        } else if i_vip_status > 0 {
+            session.Set(s.SessionKey, s.Vip)
+            return s.Vip
+        }
+    }
+    session.Del(s.SessionKey)
+    return s.Free
 }
 
 //所选服务是否是大会员
-func (s *switchService) IsMember(session *httpsession.Session, m MongodbSim) bool {
-	return s.Get(session, m) == s.Member
+func (s *switchService) IsMember(session *httpsession.Session, m MongodbSim,sql *mysql.Mysql) bool {
+    return s.GetEntniche(session, m,sql) == s.Member
 }
 
 //所选服务是否是超级订阅
 func (s *switchService) IsVip(session *httpsession.Session, m MongodbSim) bool {
-	return s.Get(session, m) == s.Vip
+    return s.Get(session, m) == s.Vip
 }
 
 //所选服务是否是免费
 func (s *switchService) IsFree(session *httpsession.Session, m MongodbSim) bool {
-	return s.Get(session, m) == s.Free
+    return s.Get(session, m) == s.Free
 }

+ 176 - 8
src/jfw/modules/publicapply/src/me/me.go

@@ -2,10 +2,11 @@ package me
 
 import (
 	"db"
-	"qfw/util"
+	qutil "qfw/util"
 	"qfw/util/jy"
 	"qfw/util/redis"
 	"time"
+	"util"
 
 	"github.com/go-xweb/xweb"
 )
@@ -20,6 +21,11 @@ func init() {
 	xweb.AddAction(&Me{})
 }
 
+const (
+	Role_admin_system     = 1 //系统管理员
+	Role_admin_department = 2 //部门管理员
+)
+
 //
 func (m *Me) MyInfo() {
 	r := map[string]interface{}{
@@ -31,13 +37,13 @@ func (m *Me) MyInfo() {
 		isExpire := -1
 		isPassCount := false
 		tedayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
-		if util.IntAll((*user)["i_vip_status"]) > 0 {
+		if qutil.IntAll((*user)["i_vip_status"]) > 0 {
 			r["userType"] = "vip"
 			//
 			var threeRemind = int64(3 * 24 * 60 * 60)
 			var twoRemind = int64(2 * 24 * 60 * 60)
 			var oneRemind = int64(1 * 24 * 60 * 60)
-			_endtime := util.Int64All((*user)["l_vip_endtime"])
+			_endtime := qutil.Int64All((*user)["l_vip_endtime"])
 			now_unix := time.Now().Unix()
 			//是否到期
 			if _endtime-now_unix < threeRemind && _endtime-now_unix >= twoRemind {
@@ -62,26 +68,78 @@ func (m *Me) MyInfo() {
 			//已购买企业未过期
 			if entInfo := db.Mysql.SelectBySql(`SELECT status,isNew FROM entniche_info WHERE id  IN (SELECT ent_id FROM entniche_user where phone = ? and power =1)`, phone); len((*entInfo)) > 0 {
 				for _, v := range *entInfo {
-					if util.IntAll(v["status"]) == 1 && util.IntAll(v["isNew"]) == 1 {
+					if qutil.IntAll(v["status"]) == 1 && qutil.IntAll(v["isNew"]) == 1 {
 						isEnt = true
 						break
 					}
 				}
 			}
 		}
+		o_entniche := &map[string]interface{}{}
+		data := []string{}
 		if isEnt {
 			r["userType"] = "entniche"
+			entId := qutil.IntAll(m.GetSession("entId"))
+			entUserId := qutil.IntAll(m.GetSession("entUserId"))
+			entInfo := GetEntInfo(entId, entUserId)
+			if entId != 0 && entUserId != 0 {
+				model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+				var res_ *map[string]interface{}
+				switch model {
+				case 1:
+					res_, _ = db.Mgo.FindOne("entniche_rule", map[string]interface{}{
+						"i_deptid": entInfo.Dept.Id,
+						"i_entid":  entId,
+					})
+				case 2:
+					res_, _ = db.Mgo.FindOne("entniche_rule", map[string]interface{}{
+						"i_userid": entUserId,
+						"i_entid":  entId,
+					})
+				}
+				if res_ != nil {
+					o_entniche = qutil.ObjToMap((*res_)["o_entniche"])
+				}
+				if (*o_entniche)["a_items"] != nil {
+					a_items := qutil.ObjArrToMapArr((*o_entniche)["a_items"].([]interface{}))
+					for _, v := range a_items {
+						if v["a_key"] != nil {
+							a_key_arr := qutil.ObjArrToMapArr(v["a_key"].([]interface{}))
+							for kk, vv := range a_key_arr {
+								if vv["notkey"] == nil {
+									a_key_arr[kk]["notkey"] = []string{}
+								}
+								if vv["appendkey"] == nil {
+									a_key_arr[kk]["appendkey"] = []string{}
+								}
+								for kkk, vvv := range vv {
+									if vvv == nil && kkk == "notkey" {
+										a_key_arr[kk][kkk] = []string{}
+									}
+									if vvv == nil && kkk == "appendkey" {
+										a_key_arr[kk][kkk] = []string{}
+									}
+								}
+							}
+							v["a_key"] = a_key_arr
+						}
+					}
+					data = qutil.ObjArrToStringArr(qutil.MapArrToObjArr(a_items))
+				}
+
+			}
+
 		}
 		r["isExpire"] = isExpire
-		r["vipStatus"] = util.IntAll((*user)["i_vip_status"])
+		r["vipStatus"] = qutil.IntAll((*user)["i_vip_status"])
 		r["isPassCount"] = isPassCount
-		r["haskey"], _ = GetKeySet(jy.SwitchService.Get(m.Session(), db.Mgo), user)
+		r["haskey"], _ = GetKeySet(jy.SwitchService.GetEntniche(m.Session(), db.Mgo, db.Mysql), user, data)
 	}
 	m.ServeJson(r)
 }
 
 //是否有订阅词
-func GetKeySet(t string, u *map[string]interface{}) (bool, []string) {
+func GetKeySet(t string, u *map[string]interface{}, data []string) (bool, []string) {
 	var industry_ = []string{}
 	if u != nil {
 		if t == jy.SwitchService.Free {
@@ -94,10 +152,17 @@ func GetKeySet(t string, u *map[string]interface{}) (bool, []string) {
 				obj, _ = (*u)["o_vipjy"].(map[string]interface{})
 			} else if t == jy.SwitchService.Member {
 				obj, _ = (*u)["o_member_jy"].(map[string]interface{})
+			} else if t == jy.SwitchService.Entniche {
+				if len(data) > 0 {
+					return true, data
+				} else {
+					return false, data
+				}
+
 			}
 			if obj != nil {
 				if buyerclassObj, ok := obj["a_buyerclass"].([]interface{}); ok {
-					industry_ = util.ObjArrToStringArr(buyerclassObj)
+					industry_ = qutil.ObjArrToStringArr(buyerclassObj)
 				}
 				itmes, _ := obj["a_items"].([]interface{})
 				for _, v := range itmes {
@@ -112,3 +177,106 @@ func GetKeySet(t string, u *map[string]interface{}) (bool, []string) {
 	}
 	return false, industry_
 }
+
+type CurrentUser struct {
+	Role_admin_department bool        //是否是部门管理员
+	Role_admin_system     bool        //是否是系统管理员
+	Ent                   *EntInfo    //企业信息
+	Dept                  *Department //部门信息
+	BondPhone             string      //手机号
+	NickName              string      //昵称
+	HeadImageUrl          string      //头像
+	PersonalAuth          int         //个人认证
+	PersonalAuthReason    string      //个人认证不通过原因
+	User_power            int         //是否分配权限
+	User_name             string      //用户姓名
+}
+type EntInfo struct {
+	Id                    int    //企业id
+	Name                  string //企业名
+	Phone                 string //手机号
+	Model                 int    //1-统一订阅,2-个人订阅
+	Status                int    //0:未生效,1:已生效,-1:已到期
+	Quota                 int    //限额人数
+	Startdate             int    //开始时间
+	Enddate               int    //结束时间
+	Createtime            string //创建时间
+	Mail                  string //邮箱
+	Marketarea            string
+	Industryclass         string //行业分类
+	Admin                 string //管理员姓名-只有商机洞察中有,可能没什么用
+	Code                  string //统一社会信用代码
+	License               string //营业执照
+	Legal_name            string //法人姓名
+	Legal_idcard          string //身份证号
+	Legal_idcard_front    string //身份证前面
+	Legal_idcard_after    string //身份证后面
+	Auth_status           int    //-1-未通过 0-未认证 1-已认证
+	Auth_reason           string //审核不通过的原因说明
+	Auth_time             string //提交时间
+	Audit_time            string //审核时间
+	User_id               int
+	Auth_type             int    //认证类型 1-事业单位  其他:企业
+	Legal_mancard         string //法人证
+	IsNew                 int    //1新商机管理0老商机管理
+	Power_virtual_account int    //是否有添加虚拟账号权限
+	Virtual_account_rule  string //虚拟账号的手机号规则
+}
+type Department struct {
+	Id         int
+	Name       string //部门名
+	Pid        int    //上级部门id
+	Pname      string //上级部门名称
+	Nodiff     int    //全员无差别接收 0:关闭 1:打开
+	Subdis     int    //订阅分发 0:关闭 1:打开
+	Aid        int    //管理员id
+	Aname      string //管理员姓名
+	Rname      string //角色名
+	User_count int    //该部门下员工的总数
+	Dept_count int    //该部门下子部门总数
+	Ent_id     int    //公司id
+}
+
+//当前登录用户的信息
+func GetEntInfo(entId, entUserId int) *CurrentUser {
+	currentUser := &CurrentUser{
+		Ent:  &EntInfo{},
+		Dept: &Department{},
+	}
+	currentUser.Ent = &EntInfo{Id: entId}
+	user := db.Mysql.SelectBySql(`SELECT a.name as user_name from entniche_user a INNER JOIN entniche_user_role b on (a.id=b.user_id) where a.id=? and b.role_id=? limit 1`, entUserId, Role_admin_system)
+	if user != nil && len(*user) > 0 {
+		currentUser.Role_admin_system = true
+		currentUser.User_name, _ = (*user)[0]["user_name"].(string)
+		currentUser.User_power = 1
+		r := db.Mysql.SelectBySql(`SELECT id,name,subdis,nodiff from entniche_department where ent_id=? and pid=0 limit 1`, entId)
+		if r != nil && len(*r) == 1 {
+			department := util.JsonUnmarshal((*r)[0], &Department{}).(*Department)
+			if department != nil {
+				department.Pid = department.Id
+				currentUser.Dept = department
+			}
+		}
+	} else {
+		//角色、权限
+		r := db.Mysql.SelectBySql(`SELECT a.name as user_name,a.power as user_power,b.role_id,d.id as dept_id,d.name as dept_name,d.subdis as dept_subdis,d.nodiff as dept_nodiff,e.id as dept_pid from entniche_user a 
+			LEFT JOIN entniche_user_role b on (b.user_id=?) 
+			INNER JOIN entniche_department_user c on (a.id=? and a.id=c.user_id) 
+			INNER JOIN entniche_department d on (c.dept_id=d.id) 
+			INNER JOIN entniche_department e on (e.ent_id=? and e.pid=0) 
+			order by a.id desc limit 1`, entUserId, entUserId, entId)
+		if r != nil && len(*r) == 1 {
+			currentUser.User_name, _ = (*r)[0]["user_name"].(string)
+			currentUser.User_power = qutil.IntAll((*r)[0]["user_power"])
+			if qutil.IntAll((*r)[0]["role_id"]) == Role_admin_department {
+				currentUser.Role_admin_department = true
+			}
+			currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
+			currentUser.Dept.Pid = qutil.IntAll((*r)[0]["dept_pid"])
+			currentUser.Dept.Name = qutil.ObjToString((*r)[0]["dept_name"])
+			currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
+			currentUser.Dept.Nodiff = qutil.IntAll((*r)[0]["dept_nodiff"])
+		}
+	}
+	return currentUser
+}

+ 4 - 3
src/jfw/modules/publicapply/src/subscribePush/service/pushList.go

@@ -31,7 +31,8 @@ type SubscribePush struct {
 //VipSwitch 大会员、超级订阅、商机管理切换
 func (sp *SubscribePush) VipSwitch() {
 	userId, _ := sp.GetSession("userId").(string)
-	//entUserId := util.IntAll(sp.GetSession("entUserId"))
+	v, _ := sp.Session().Get("vSwitch").(string)
+	log.Println(v)
 	rData, errMsg := func() (interface{}, error) {
 		if userId == "" {
 			return nil, fmt.Errorf("未登录")
@@ -92,7 +93,7 @@ func (sp *SubscribePush) HasPushHistory() {
 	entId := util.IntAll(sp.GetSession("entId"))
 	go entity.HistoryPush.UpdateUserPushUnread(userId, vipType)
 	user, _ := jy.NewSubscribePush().UserInfo(db.Mgo, userId)
-	hasKeyFlag, industry_ := me.GetKeySet(vipType, user)
+	hasKeyFlag, industry_ := me.GetKeySet(vipType, user, []string{})
 	var isVipFlag, isPassCount, isread, otherFlag bool = false, false, false, false
 	isExpire, isOnTail := -1, 0
 	todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
@@ -242,7 +243,7 @@ func (sp *SubscribePush) HistoryPaging() {
 	jy.NewSubscribePush().MakeCollection(userId, db.Mysql, list)
 	//是否有关键词
 	user, _ := jy.NewSubscribePush(vipType).UserInfo(db.Mgo, userId)
-	hasKeyFlag, _ := me.GetKeySet(vipType, user)
+	hasKeyFlag, _ := me.GetKeySet(vipType, user, []string{})
 	//仅表格第一页展示全部字段
 	if !(sp.GetString("format") == "table" && pageNum == 1 && PageSize <= 20) && len(list) > 0 {
 		for i := 0; i < len(list); i++ {

+ 14 - 0
src/jfw/modules/publicapply/src/util/util.go

@@ -254,3 +254,17 @@ func ConvertWeekday(weekday string) int {
 	}
 	return _weekday
 }
+
+//map转结构体
+func JsonUnmarshal(m interface{}, s interface{}) interface{} {
+	var b []byte
+	if v, ok := m.(string); ok {
+		b = []byte(v)
+	} else if v, ok := m.([]byte); ok {
+		b = v
+	} else {
+		b, _ = json.Marshal(m)
+	}
+	json.Unmarshal(b, &s)
+	return s
+}

+ 6 - 2
src/web/staticres/common-module/collection/js/industry-mobile.js

@@ -245,13 +245,17 @@ var industryComponent = {
         this.canClick = bool
       } else {
         indArr.forEach(function(sum) {
-          newindArr.push(sum.split('_')[1])
+          // newindArr.push(sum.split('_')[1])
+          newindArr.push({
+            key:sum.split('_')[0],
+            value:sum.split('_')[1]
+          })
         })
         // console.log(newindArr)
         this.tablist.forEach(function(item){
           item[Object.keys(item)[0]].forEach(function(data) {
             newindArr.forEach(function(sum) {
-              if(data.name == sum) {
+              if(data.name == sum.value && Object.keys(item)[0] == sum.key) {
                 data.type = true
                 bool = false
               }