瀏覽代碼

Merge branch 'dev2.9.0' of http://39.105.157.10:10080/qmx/jy into dev2.9.0

wangshan 5 年之前
父節點
當前提交
a9c5a7047d
共有 29 個文件被更改,包括 715 次插入276 次删除
  1. 2 1
      src/jfw/modules/app/src/app/front/laboratory.go
  2. 42 1
      src/jfw/modules/app/src/app/front/me.go
  3. 0 31
      src/jfw/modules/app/src/app/front/swordfish.go
  4. 28 13
      src/jfw/modules/app/src/web/templates/entniche/entniche_order_detail.html
  5. 117 120
      src/jfw/modules/app/src/web/templates/weixin/historypush.html
  6. 7 6
      src/jfw/modules/entniche/src/config.json
  7. 1 0
      src/jfw/modules/entniche/src/config/config.go
  8. 2 1
      src/jfw/modules/entniche/src/service/person/person.go
  9. 12 2
      src/jfw/modules/entniche/src/service/service.go
  10. 334 54
      src/jfw/modules/entniche/src/service/subscribe/subscribe.go
  11. 0 2
      src/jfw/modules/entniche/src/util/constant.go
  12. 9 1
      src/jfw/modules/pushsubscribe/src/match/config.json
  13. 8 0
      src/jfw/modules/pushsubscribe/src/match/config/config.go
  14. 23 1
      src/jfw/modules/pushsubscribe/src/match/job/matchjob.go
  15. 12 8
      src/jfw/modules/pushsubscribe/src/match/job/timetask.go
  16. 2 9
      src/jfw/modules/pushsubscribe/src/match/main.go
  17. 34 0
      src/jfw/modules/pushsubscribe/src/match/util/db.go
  18. 1 0
      src/jfw/modules/pushsubscribe/src/public/entity.go
  19. 20 16
      src/jfw/modules/pushsubscribe/src/public/util.go
  20. 2 1
      src/jfw/modules/pushsubscribe/src/push/config.json
  21. 2 3
      src/jfw/modules/pushsubscribe/src/push/config/config.go
  22. 5 1
      src/jfw/modules/pushsubscribe/src/push/job/pushjob.go
  23. 二進制
      src/jfw/modules/pushsubscribe/src/push/push
  24. 5 1
      src/jfw/modules/pushsubscribe/src/push/util/rpccall.go
  25. 0 0
      src/jfw/modules/subscribepay/src/dataexport.json
  26. 32 1
      src/jfw/modules/subscribepay/src/entity/dataexport.go
  27. 0 1
      src/jfw/modules/subscribepay/src/entity/entniche.go
  28. 12 1
      src/jfw/modules/subscribepay/src/service/entniche.go
  29. 3 1
      src/jfw/modules/subscribepay/src/service/orderListDetails.go

+ 2 - 1
src/jfw/modules/app/src/app/front/laboratory.go

@@ -18,6 +18,7 @@ func init() {
 
 //剑鱼标讯实验室首页
 func (l *Lab) Index() error {
-	return l.Render("/weixin/treasure_box.html")
+	//return l.Render("/weixin/treasure_box.html")
 	//return l.Render("/weixin/jylab/lab-index.html")
+	return l.Redirect("/page_entniche/page/treasure_box.html")
 }

+ 42 - 1
src/jfw/modules/app/src/app/front/me.go

@@ -299,11 +299,52 @@ func (l *Me) MyInfo() {
 		r["entName"] = l.GetSession("entName")
 	} else {
 		userId, _ := l.GetSession("userId").(string)
-		user, ok := mongodb.FindById("user", userId, `{"s_phone":1,"i_vip_status":1}`)
+		user, ok := mongodb.FindById("user", userId, `{"s_phone":1,"o_jy":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1}`)
 		if ok && user != nil {
+			isExpire := 0
+			isOnTail := 0
+			isPassCount := false
+			hasKeyFlag := false
+			tedayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
 			if qutil.IntAll((*user)["i_vip_status"]) > 0 {
 				r["userType"] = "vip"
+				isOnTail = qutil.IntAll((*user)["i_vip_status"])
+				//
+				var threeRemind = int64(3 * 24 * 60 * 60)
+				var twoRemind = int64(2 * 24 * 60 * 60)
+				var oneRemind = int64(1 * 24 * 60 * 60)
+				_endtime := (*user)["l_vip_endtime"]
+				//是否到期
+				if qutil.Int64All(_endtime)-time.Now().Unix() < threeRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
+					isExpire = 3 //即将到期
+				} else if qutil.Int64All(_endtime)-time.Now().Unix() < twoRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
+					isExpire = 2 //即将到期
+				} else if qutil.Int64All(_endtime)-time.Now().Unix() < oneRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= 0 {
+					isExpire = 1 //即将到期
+				}
+				isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 2000
+				o_vipjy, _ := (*user)["o_vipjy"].(map[string]interface{})
+				if o_vipjy["a_items"] != nil {
+					a_itmes := qutil.ObjArrToMapArr(o_vipjy["a_items"].([]interface{}))
+					hasKeyFlag = len(a_itmes) > 0
+				}
+			} else {
+				if (*user)["i_vip_status"] == nil {
+					isExpire = 0
+				} else {
+					isOnTail = qutil.IntAll((*user)["i_vip_status"])
+				}
+				isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 50
+				o_jy, _ := (*user)["o_jy"].(map[string]interface{})
+				if o_jy != nil || len(o_jy) == 0 {
+					a_key, _ := o_jy["a_key"].([]interface{})
+					hasKeyFlag = len(a_key) > 0
+				}
 			}
+			r["isExpire"] = isExpire
+			r["isOnTail"] = isOnTail
+			r["isPassCount"] = isPassCount
+			r["haskey"] = hasKeyFlag
 			phone, _ := (*user)["s_phone"].(string)
 			if public.Mysql.CountBySql(`SELECT count(DISTINCT a.id) as count from entniche_info a 
 			INNER JOIN entniche_user b on (a.id=b.ent_id) 

+ 0 - 31
src/jfw/modules/app/src/app/front/swordfish.go

@@ -640,11 +640,6 @@ func (f *Front) HasPushHistory() {
 	user, _ := jy.SubscribePush.UserInfo(public.MQFW, userId)
 	hasKeyFlag := false
 	isVipFlag := false
-	isPassCount := false
-	isExpire := 0
-	tedayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
-	isOnTail := 0
-
 	var o_jy map[string]interface{}
 	var keys []string
 	if user != nil {
@@ -659,10 +654,6 @@ func (f *Front) HasPushHistory() {
 			}
 		}
 		if util.IntAll((*user)["i_vip_status"]) == 1 || util.IntAll((*user)["i_vip_status"]) == 2 {
-			//
-			var threeRemind = int64(3 * 24 * 60 * 60)
-			var twoRemind = int64(2 * 24 * 60 * 60)
-			var oneRemind = int64(1 * 24 * 60 * 60)
 			var o_vipjy map[string]interface{}
 			o_vipjy, _ = (*user)["o_vipjy"].(map[string]interface{})
 			if o_vipjy["a_items"] != nil {
@@ -670,28 +661,11 @@ func (f *Front) HasPushHistory() {
 				hasKeyFlag = len(a_itmes) > 0
 			}
 			isVipFlag = true
-			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 2000
-			isOnTail = util.IntAll((*user)["i_vip_status"])
-			_endtime := (*user)["l_vip_endtime"]
-			//是否到期
-			if util.Int64All(_endtime)-time.Now().Unix() < threeRemind && util.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
-				isExpire = 3 //即将到期
-			} else if util.Int64All(_endtime)-time.Now().Unix() < twoRemind && util.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
-				isExpire = 2 //即将到期
-			} else if util.Int64All(_endtime)-time.Now().Unix() < oneRemind && util.Int64All(_endtime)-time.Now().Unix() >= 0 {
-				isExpire = 1 //即将到期
-			}
 		} else {
-			if (*user)["i_vip_status"] == nil {
-				isExpire = 0
-			} else {
-				isOnTail = util.IntAll((*user)["i_vip_status"])
-			}
 			if o_jy != nil || len(o_jy) == 0 {
 				a_key, _ := o_jy["a_key"].([]interface{})
 				hasKeyFlag = len(a_key) > 0
 			}
-			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 50
 		}
 	}
 	pageNum, _ := f.GetInteger("pageNum")
@@ -715,14 +689,9 @@ func (f *Front) HasPushHistory() {
 	}
 	//
 	f.ServeJson(map[string]interface{}{
-		"haskey":      hasKeyFlag,
 		"data":        list,
 		"hasNextPage": hasNextPage,
 		"isInTSguide": isInTSguide(userId),
-		"isVipSub":    isVipFlag,
-		"isPassCount": isPassCount,
-		"isExpire":    isExpire,
-		"isOnTail":    isOnTail,
 		"userId":      util.EncodeArticleId(userId),
 		"keys":        keys,
 	})

+ 28 - 13
src/jfw/modules/app/src/web/templates/entniche/entniche_order_detail.html

@@ -481,19 +481,34 @@ body .loading_ p span {
 					//发票
 					if (order_status==1){
 						$(".order_status").text("已完成");
-						$(".invoicing").css("display","");
-					 	$(".invoicing").on("click",function(){
-			            	var nowTimestamp= (new Date()).valueOf();
-			            	$.post("/subscribepay/orderListDetails/emailOperation?v="+nowTimestamp,{},function(r){
-								if (r.success){
-									//没有绑定邮箱
-									weuiDialog();
-								}else{
-									//绑定了邮箱
-									window.location.href="/jyapp/front/myOrder/getOrderCode/"+orderCode;
-								}
-							})
-			            });
+						if(data.applybill_status==0){ 
+							$(".invoicing").css("display","");
+						 	$(".invoicing").on("click",function(){
+				            	var nowTimestamp= (new Date()).valueOf();
+				            	$.post("/subscribepay/orderListDetails/emailOperation?v="+nowTimestamp,{},function(r){
+									if (r.success){
+										//没有绑定邮箱
+										weuiDialog();
+									}else{
+										//绑定了邮箱
+										window.location.href="/jyapp/front/myOrder/getOrderCode/"+orderCode;
+									}
+								})
+				            });
+						}else{
+							//已支付已申请发票
+						    $("#invoicing").css("display","none");
+							switch (data.applybill_type){
+								case 0:
+								$(".person").css("display","");
+								break;
+								case 1:
+								$(".unit").css("display","");
+								$(".company_name").html(data.applybill_company);
+								$(".taxpayer_number").html(data.applybill_taxnum);
+								break;
+							}
+						}
 					}
 					if(order_status==0){
 						var payway_ent = data.pay_way;

+ 117 - 120
src/jfw/modules/app/src/web/templates/weixin/historypush.html

@@ -81,12 +81,7 @@
 
         var words = ""
         var isInTSguide = false;//订阅向导
-        var isVipSub = false;//是不是VIP
         var firstTime = {{.T.selectTime}};
-        var isPassCount = false; //提示信息
-        var haskey = false;//是否有关键词
-        var isOnTail = false;//是否在试用
-        var isExpire = 0;//到期天数3 2 1
         var userId = "";
         var selectCity = "";
 
@@ -115,30 +110,133 @@
             $(".listcontent").scroll(function () {
                 scrollTop = $(this).scrollTop();
             });
+            this.InitPersonal=function(r){
+              $("#sub_manager").click(tokeyset);
+              $(".tab_left .area").hide();
+              $(".vip_banner").show();
+              if (r.isPassCount) {
+                  $(".open_remind").show();
+              }
+              if (r.isExpire < 0 && r.isOnTail == -1) {
+                  if (localStorage.getItem("nv_vip_" + userId) == null) {
+                      $(".nv_renew_toast").show();
+                  }
+              }
+              if (!firstPage.length > 0 && !r.haskey) {
+                  if (sessionStorage && (sessionStorage.keysetindexToHistory == "1" || sessionStorage.keysetindexToHistory == "2" || sessionStorage.keysetindexToHistory == "3")) {
+                    sessionStorage.removeItem("keysetindexToHistory");
+                    return
+                  }
+                  if (firstTime != "") {
+                    return
+                  }
+                  history.pushState({}, "", "");
+                  if (isInTSguide) {
+                      if (localStorage) {
+                        localStorage.removeItem("tsGuide_status");
+                      }
+                      window.location.href = '/jyapp/tenderSubscribe/guide';
+                  } else {
+                      window.location.href = '/jyapp/wxkeyset/keyset/index';
+                  }
+              }
+            }
+            this.InitVip=function(r){
+              $("#sub_manager").click(tosetpage);
+              $(".vip_report").show();
+              $(".tab_left .area").show();
+              if (!r.haskey) {
+                    $(".set_keyword").show();
+                    if (r.isPassCount && (localStorage.isPassCount == null || localStorage.isPassCount != date.split("-")[2])) {
+                        localStorage.isPassCount = date.split("-")[2]
+                        weuiDialog();
+                    }
+                }
+                if (r.isOnTail != 1) {
+                    if (r.isExpire > 1) {
+                        $(".renew_toast .isExpire").text(r.isExpire);
+                        $(".renew_toast").show();
+                    } else if (r.isExpire > 0) {
+                        $(".renew_toast").find(".other").hide();
+                        $(".renew_toast").find(".today").show();
+                        $(".renew_toast").show();
+                    }
+                } else {
+                    if (r.isExpire > 1) {
+                        $("._renew_toast .isExpire").text(r.isExpire);
+                        $("._renew_toast").show();
+                    } else if (r.isExpire > 0) {
+                        $("._renew_toast").find(".other").hide();
+                        $("._renew_toast").find(".today").show();
+                        $("._renew_toast").show();
+                    }
+                }
+                $.post("/subscribepay/report/tip?t=" + new Date().getTime(), null, function (r) {
+                    if (r.unread > 0) {
+                        $(".vip_report>a").show();
+                    }
+                    if (r.tip) {
+                        if (r.tip.type == 2) {
+                            $(".vip_report_tip .weekly>span").text("周");
+                        } else {
+                            $(".vip_report_tip .weekly>span").text("月");
+                        }
+                        $(".vip_report_tip .term").text(new Date(Number(r.tip.startdate + "000")).Format("yyyy年M月d日") + "-" + new Date(Number(r.tip.enddate + "000")).Format("yyyy年M月d日"));
+                        $('.vip_report_tip').fadeIn();
+                        $('.vip_report_todetail').on('click', function () {
+                            updateReportStatus(1, r.tip.startdate, r.tip.enddate, r.tip.pushcount);
+                        });
+                        $('.weui-dialog img.vip_report_tip_close').click(function () {
+                            $('.vip_report_tip').fadeOut();
+                            updateReportStatus(0);
+                        });
+                    }
+                });
+                $(".vip_report").click(function () {
+                    window.location.href = "/vipreport/page/subreport.html";
+                });
+            }
+            var thisClass = this;
             $.post("/jyapp/myinfo?t="+new Date().getTime(),null,function(r){
               if(r.hasEnt){
                 if(r.userType=="vip"){
                   $(".switch").addClass("switch-vip");
                   $(".switch>span").text("VIP订阅");
+                  thisClass.InitVip(r);
                 }else if (r.userType=="ent"){
                   $(".switch").addClass("switch-ent");
                   $(".switch>span").text(r.entName);
+                  $(".switch").click(function(){
+                    window.location.href='/page_entniche/page/sub_mode/switch_mode.html';
+                  });
+                  $("#sub_manager").click(function(){
+                    $.post("/entniche/ent/entinfo",null,function(r){
+                      if(r.data.admin_system){
+                        window.location.href='/page/sub_management/sub_management_system.html';
+                      }else if(r.data.admin_department){
+                        window.location.href='/page/sub_management/sub_management_department.html';
+                      }
+                    });
+                  });
                 }else{
                   $(".switch").addClass("switch-personal");
                   $(".switch>span").text("标讯订阅(个人版)");
+                  thisClass.InitPersonal(r);
                 }
                 $(".switch").click(function(){
-                  window.location.href='';
+                  window.location.href='/page_entniche/page/sub_mode/switch_mode.html';
                 });
               }else{
                 if(r.userType=="vip"){
                   $(".switch").addClass("only-vip");
                   $(".switch>span").text("VIP订阅");
-                  $(".switch").click(tosetpage);  
+                  $(".switch").click(tosetpage);
+                  thisClass.InitVip(r);
                 }else{
                   $(".switch").addClass("only-personal");
                   $(".switch>span").text("¥5.8 开通VIP");
                   $(".switch").click(tointroducepage);
+                  thisClass.InitPersonal(r);
                 }
               }
             });
@@ -151,14 +249,6 @@
                 hasNextPage = sessionStorage.historypushHasNextPage == "true" ? true : false;
                 scrollTop = sessionStorage.historypushScrollTop;
                 dataCache = JSON.parse(sessionStorage.historypushDataCache);
-                isVipSub = sessionStorage.isVipSub == "true" ? true : false;
-                ;
-                isPassCount = sessionStorage.isPassCount == "true" ? true : false;
-                ;
-                haskey = sessionStorage.haskey == "true" ? true : false;
-                ;
-                isOnTail = sessionStorage.isOnTail;
-                isExpire = sessionStorage.isExpire;
                 userId = sessionStorage.userId;
                 firstTime = sessionStorage.getItem(userId + "_searchTime");
                 selectCity = sessionStorage.getItem(userId + "_selectCity");
@@ -192,18 +282,8 @@
                         lasttime = data.thistime;
                         firstPage = data.data;
                         hasNextPage = data.hasNextPage;
-                        isVipSub = data.isVipSub;
-                        sessionStorage.isVipSub = isVipSub;
                         userId = data.userId;
                         sessionStorage.userId = userId;
-                        isPassCount = data.isPassCount;
-                        sessionStorage.isPassCount = isPassCount;
-                        haskey = data.haskey;
-                        sessionStorage.haskey = haskey;
-                        isOnTail = data.isOnTail;
-                        sessionStorage.isOnTail = isOnTail;
-                        isExpire = data.isExpire;
-                        sessionStorage.isExpire = isExpire;
                         sessionStorage.setItem(userId + "_searchTime", firstTime);
                         showPage();
                     },
@@ -265,96 +345,6 @@
             $(".tab_left .time").show();
             //地区渲染
             mapData();
-            //
-            if (!isVipSub) {
-                $("#sub_manager").click(function(){
-                  setSessionStorage();
-                  window.location.href = '/jyapp/wxkeyset/keyset/index';
-                });
-                $(".tab_left .area").hide();
-                $(".vip_banner").show();
-                //$(".listcontent").css("margin-top","2rem");
-                if (isPassCount) {
-                    $(".open_remind").show();
-                }
-                if (parseInt(isExpire) < 0 && parseInt(isOnTail) == -1) {
-                    if (localStorage.getItem("nv_vip_" + userId) == null) {
-                        $(".nv_renew_toast").show();
-                    }
-                }
-                if (!firstPage.length > 0 && !haskey) {
-                    if (sessionStorage && (sessionStorage.keysetindexToHistory == "1" || sessionStorage.keysetindexToHistory == "2" || sessionStorage.keysetindexToHistory == "3")) {
-                        sessionStorage.removeItem("keysetindexToHistory");
-                        return
-                    }
-                    if (firstTime != "") {
-                        return
-                    }
-                    history.pushState({}, "", "");
-                    if (isInTSguide) {
-                        if (localStorage) {
-                            localStorage.removeItem("tsGuide_status");
-                        }
-                        window.location.href = '/jyapp/tenderSubscribe/guide';
-                    } else {
-                        window.location.href = '/jyapp/wxkeyset/keyset/index';
-                    }
-                }
-            } else {
-                if (!haskey) {
-                    $(".set_keyword").show();
-                    if (isPassCount && (localStorage.isPassCount == null || localStorage.isPassCount != date.split("-")[2])) {
-                        localStorage.isPassCount = date.split("-")[2]
-                        weuiDialog();
-                    }
-                }
-                if (parseInt(isOnTail) != 1) {
-                    if (parseInt(isExpire) > 1) {
-                        $(".renew_toast .isExpire").text(parseInt(isExpire));
-                        $(".renew_toast").show();
-                    } else if (parseInt(isExpire) > 0) {
-                        $(".renew_toast").find(".other").hide();
-                        $(".renew_toast").find(".today").show();
-                        $(".renew_toast").show();
-                    }
-                } else {
-                    if (parseInt(isExpire) > 1) {
-                        $("._renew_toast .isExpire").text(parseInt(isExpire));
-                        $("._renew_toast").show();
-                    } else if (parseInt(isExpire) > 0) {
-                        $("._renew_toast").find(".other").hide();
-                        $("._renew_toast").find(".today").show();
-                        $("._renew_toast").show();
-                    }
-                }
-                $("#sub_manager").click(tosetpage);
-                $(".vip_report").show();
-                $(".tab_left .area").show();
-                $.post("/subscribepay/report/tip?t=" + new Date().getTime(), null, function (r) {
-                    if (r.unread > 0) {
-                        $(".vip_report>a").show();
-                    }
-                    if (r.tip) {
-                        if (r.tip.type == 2) {
-                            $(".vip_report_tip .weekly>span").text("周");
-                        } else {
-                            $(".vip_report_tip .weekly>span").text("月");
-                        }
-                        $(".vip_report_tip .term").text(new Date(Number(r.tip.startdate + "000")).Format("yyyy年M月d日") + "-" + new Date(Number(r.tip.enddate + "000")).Format("yyyy年M月d日"));
-                        $('.vip_report_tip').fadeIn();
-                        $('.vip_report_todetail').on('click', function () {
-                            updateReportStatus(1, r.tip.startdate, r.tip.enddate, r.tip.pushcount);
-                        });
-                        $('.weui-dialog img.vip_report_tip_close').click(function () {
-                            $('.vip_report_tip').fadeOut();
-                            updateReportStatus(0);
-                        });
-                    }
-                });
-                $(".vip_report").click(function () {
-                    window.location.href = "/vipreport/page/subreport.html";
-                });
-            }
         }
 
         //下拉刷新
@@ -767,6 +757,12 @@
             }
         }
 
+        //免费用户关键词设置
+        function tokeyset() {
+          setSessionStorage();
+          window.location.href = '/jyapp/wxkeyset/keyset/index';
+        }
+
         //介绍页
         function tointroducepage() {
             setSessionStorage();
@@ -1023,10 +1019,11 @@
         .app-layout-header>ul>li:last-child{
           font-size: 15px;
           align-self: center;
-        }
-        .app-layout-header>ul>li:last-child>img{
-          width:14px;
-          margin-right: 5px;
+          padding-left: 19px;
+          background-image: url("/jyapp/images/sub_manager.png");
+          background-size: 14px;
+          background-repeat: no-repeat;
+          background-position: left center;
         }
         .app-layout-header .switch{
           padding: 0px 10px;
@@ -1112,7 +1109,7 @@
   <ul>
     <li>订阅</li>
     <li><div class="switch"><span></div></span></li>
-    <li id="sub_manager"><img src="/jyapp/images/sub_manager.png">订阅管理</li>
+    <li id="sub_manager">订阅管理</li>
   </ul>
 </div>
 <div class="app-layout-content-b">

+ 7 - 6
src/jfw/modules/entniche/src/config.json

@@ -1,17 +1,18 @@
 {
 	"webPort": "811",
 	"mongodb":{
-		"address":"192.168.3.128:27080",
+		"address":"127.0.0.1:27080",
 		"size":5,
 		"dbName":"qfw"
 	},
-    "redisAddrs": "other=192.168.3.128:1712,session=192.168.3.128:1712",
+    "redisAddrs": "other=127.0.0.1:1712,session=127.0.0.1:1712",
     "mysql": {
         "dbName": "jianyu",
-        "address": "192.168.3.11:3366",
+        "address": "127.0.0.1:3366",
         "userName": "root",
         "passWord": "Topnet123",
-		"maxOpenConns":500,
-		"maxIdleConns":200
-    }
+		"maxOpenConns":2,
+		"maxIdleConns":2
+    },
+    "userInEntLimit":5
 }

+ 1 - 0
src/jfw/modules/entniche/src/config/config.go

@@ -28,6 +28,7 @@ type config struct {
 		MaxOpenConns int
 		MaxIdleConns int
 	}
+	UserInEntLimit int64
 }
 type timeTaskConfig struct {
 	CheckIsExpire string //定时更新用户状态

+ 2 - 1
src/jfw/modules/entniche/src/service/person/person.go

@@ -2,6 +2,7 @@
 package person
 
 import (
+	. "config"
 	"database/sql"
 	. "entity"
 	"fmt"
@@ -92,7 +93,7 @@ func (a *Action) Add() {
 	status, user_id := func() (int, int64) {
 		if VarUser.AddIsExists(entId, phone) {
 			return -1, 0
-		} else if VarEntInfo.IsQuota(entId) {
+		} else if Mysql.CountBySql(`SELECT count(1) as count from entniche_user where phone=?`, phone) >= Config.UserInEntLimit {
 			return -2, 0
 		}
 		var user_id int64

+ 12 - 2
src/jfw/modules/entniche/src/service/service.go

@@ -11,8 +11,9 @@ import (
 
 type Action struct {
 	*xweb.Action
-	move xweb.Mapper `xweb:"/move"`   //人员或者部门移动
-	del  xweb.Mapper `xweb:"/delete"` //人员或者部门删除
+	move       xweb.Mapper `xweb:"/move"`       //人员或者部门移动
+	del        xweb.Mapper `xweb:"/delete"`     //人员或者部门删除
+	whetherbuy xweb.Mapper `xweb:"/whetherbuy"` //是否购买过
 }
 
 func (a *Action) Move() {
@@ -57,3 +58,12 @@ func (a *Action) Del() {
 	}
 	a.ServeJson(Result{Data: M{"status": status}})
 }
+func (a *Action) Whetherbuy() {
+	userId, _ := a.GetSession("userId").(string)
+	phone := VarCurrentUser.Phone(userId)
+	status := 0
+	if Mysql.CountBySql("select count(1) as count from entniche_user where phone=?", phone) > 0 {
+		status = 1
+	}
+	a.ServeJson(Result{Data: M{"status": status}})
+}

+ 334 - 54
src/jfw/modules/entniche/src/service/subscribe/subscribe.go

@@ -8,6 +8,7 @@ import (
 	qutil "qfw/util"
 	"reflect"
 	"strings"
+	"time"
 	"util"
 
 	"github.com/go-xweb/xweb"
@@ -41,8 +42,21 @@ func (ac *Action) Subscribe_index() error {
 		"model":  entInfo.Ent.Model,
 		"subdis": entInfo.Dept.Subdis,
 	}
+	var o_entniche *map[string]interface{}
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	if model == 1 {
+		o_entniche, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	} else if model == 2 {
+		o_entniche, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
 	//
-	o_entniche, _ := util.MQFW.FindById("user", userId, `{"o_entniche":1}`)
+	//	o_entniche, _ := util.MQFW.FindById("user", userId, `{"o_entniche":1}`)
 	delete(*o_entniche, "_id")
 	if len(*o_entniche) > 0 {
 		entniche := (*o_entniche)["o_entniche"].(map[string]interface{})
@@ -79,8 +93,23 @@ func (ac *Action) Subscribe_index() error {
 //区域
 func (ac *Action) Get_area() error {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
-	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.o_area":1}`)
-	if !ok || len(*res) == 0 || res == nil {
+	//res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.o_area":1}`)
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	var res *map[string]interface{}
+	switch model {
+	case 1:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	case 2:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
+	if len(*res) == 0 || res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return nil
 	}
@@ -91,8 +120,7 @@ func (ac *Action) Get_area() error {
 	log.Println("查看o_area:", data)
 	areacount := 0
 	newcitys := []string{}
-	for k, v := range *data {
-		log.Println(k, "---", v)
+	for _, v := range *data {
 		if len(v.([]interface{})) == 0 {
 			areacount++
 		} else {
@@ -115,7 +143,6 @@ func (ac *Action) Get_area() error {
 
 //区域
 func (ac *Action) Update_area() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	status := 0
 	getarea := ac.Body()
 	area := map[string]interface{}{}
@@ -127,14 +154,12 @@ func (ac *Action) Update_area() {
 			return
 		}
 		log.Println("修改地区:", area)
-		bl := util.MQFW.UpdateById("user", userId, bson.M{
-			"$set": bson.M{"o_entniche.o_area": area},
-		})
+		bl := ac.updateEntnicheRule("o_area", area)
+
 		if bl {
 			status = 1
 		}
 	}
-
 	ac.ServeJson(Result{Data: M{"status": status}})
 	return
 }
@@ -143,8 +168,23 @@ func (ac *Action) Update_area() {
 func (ac *Action) Get_buyerclass() {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
 	data := []string{}
-	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_buyerclass":1}`)
-	if !ok || len(*res) == 0 || res == nil {
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_buyerclass":1}`)
+	var res *map[string]interface{}
+	switch model {
+	case 1:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	case 2:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
+	if len(*res) == 0 || res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
@@ -163,7 +203,6 @@ func (ac *Action) Get_buyerclass() {
 
 //行业
 func (ac *Action) Update_buyerclass() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	status := 0
 	buyerclass_map := map[string]interface{}{}
 	buyerclass := []string{}
@@ -180,9 +219,7 @@ func (ac *Action) Update_buyerclass() {
 			buyerclass = qutil.ObjArrToStringArr(v.([]interface{}))
 		}
 		log.Println("修改行业:", buyerclass)
-		bl := util.MQFW.UpdateById("user", userId, bson.M{
-			"$set": bson.M{"o_entniche.a_buyerclass": buyerclass},
-		})
+		bl := ac.updateEntnicheRule("a_buyerclass", buyerclass)
 		if bl {
 			status = 1
 		}
@@ -195,8 +232,23 @@ func (ac *Action) Update_buyerclass() {
 func (ac *Action) Get_infotype() {
 	data := []string{}
 	userId := qutil.ObjToString(ac.GetSession("userId"))
-	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_infotype":1}`)
-	if !ok || len(*res) == 0 || res == nil {
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_infotype":1}`)
+	var res *map[string]interface{}
+	switch model {
+	case 1:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	case 2:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
+	if len(*res) == 0 || res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
@@ -215,7 +267,6 @@ func (ac *Action) Get_infotype() {
 
 //信息类型
 func (ac *Action) Update_infotype() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	status := 0
 	infotype_map := map[string]interface{}{}
 	infotype := []string{}
@@ -231,9 +282,7 @@ func (ac *Action) Update_infotype() {
 			infotype = qutil.ObjArrToStringArr(v.([]interface{}))
 		}
 		log.Println("修改信息类型:", infotype)
-		bl := util.MQFW.UpdateById("user", userId, bson.M{
-			"$set": bson.M{"o_entniche.a_infotype": infotype},
-		})
+		bl := ac.updateEntnicheRule("a_infotype", infotype)
 		if bl {
 			status = 1
 		}
@@ -244,17 +293,37 @@ func (ac *Action) Update_infotype() {
 
 //关键词
 func (ac *Action) Get_key() {
-	//data:=[]string{}
 	data := []map[string]interface{}{}
 	status := 0 //显示快速导入关键词按钮 --0    不显示--1
 	userId := qutil.ObjToString(ac.GetSession("userId"))
-	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_items":1,"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1,"o_entniche.i_ent_fastimport":1}`)
+	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_items":1,"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1,"o_entniche.i_ent_fastimport":1}`)
+	res, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1}`)
 	if !ok || len(*res) == 0 || res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
 	delete(*res, "_id")
-	o_entniche := qutil.ObjToMap((*res)["o_entniche"])
+	//查看是否使用过快速导入
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	var res_ *map[string]interface{}
+	switch model {
+	case 1:
+		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	case 2:
+		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
+	if len(*res_) == 0 || res_ == nil {
+		ac.ServeJson(Result{Error_code: util.Error_code})
+		return
+	}
+	o_entniche := qutil.ObjToMap((*res_)["o_entniche"])
 	i_ent_fastimport := qutil.IntAll((*o_entniche)["i_ent_fastimport"])
 	if i_ent_fastimport == 1 {
 		status = 1
@@ -328,10 +397,30 @@ func (ac *Action) Update_key() {
 				ac.ServeJson(Result{Data: M{"status": status}})
 				return
 			}
+			//分类名有分发规则
+			distribute_items := []string{}
+			list_items, _ := util.MQFW.Find(util.Entniche_distribute, map[string]interface{}{
+				"s_userid": userId,
+			}, nil, nil, false, -1, -1)
+			if len(*list_items) > 0 {
+				for _, n := range *list_items {
+					if len(n["a_items"].([]interface{})) > 0 {
+						for _, y := range n["a_items"].([]interface{}) {
+							distribute_items = append(distribute_items, qutil.ObjToString(y))
+						}
+					}
+				}
+			}
+			isEqual := isEqualValue(new_item, deleteRepeat(distribute_items)) //查看分发规则库中是否有规则
+			if isEqual {
+				status = -2
+				ac.ServeJson(Result{Data: M{"status": status}})
+				return
+			}
 		}
-		bl := util.MQFW.UpdateById("user", userId, bson.M{
-			"$set": bson.M{"o_entniche.a_items": keywords["a_items"]},
-		})
+
+		ac.updateEntnicheRule("a_items", keywords["a_items"])
+		bl := true
 		if bl {
 			status = 1
 		}
@@ -350,7 +439,7 @@ func (ac *Action) Get_fastimport() {
 	unclassified := "未分类"
 	a_items_ent := []map[string]interface{}{}
 	newOne := map[string]interface{}{}
-	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_items":1,"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1,"o_entniche.i_ent_fastimport":1}`)
+	res, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1}`)
 	if !ok || len(*res) == 0 || res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
@@ -361,8 +450,28 @@ func (ac *Action) Get_fastimport() {
 	a := map[string]int{}  //分类 位置
 	b := map[string]bool{} //关键词
 	ent_hebing := []interface{}{}
+	//从entniche_rule中获取o_entniche
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	var res_ *map[string]interface{}
+	switch model {
+	case 1:
+		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	case 2:
+		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
+	if len(*res_) == 0 || res_ == nil {
+		ac.ServeJson(Result{Error_code: util.Error_code})
+		return
+	}
 	//ent设置的关键词
-	o_entniche := *qutil.ObjToMap((*res)["o_entniche"])
+	o_entniche := *qutil.ObjToMap((*res_)["o_entniche"])
 	i_ent_fastimport := o_entniche["i_ent_fastimport"]
 	//是否进行过快速导入
 	if i_ent_fastimport == 1 {
@@ -502,10 +611,33 @@ func (ac *Action) Get_fastimport() {
 		}
 	}
 	if canFastImport == 0 {
-		ok := util.MQFW.UpdateById("user", userId, bson.M{
-			"$set": bson.M{"o_entniche.a_items": a_items_ent, "o_entniche.i_ent_fastimport": 1},
-		})
-		if ok {
+		//		ok := util.MQFW.UpdateById("user", userId, bson.M{
+		//			"$set": bson.M{"o_entniche.a_items": a_items_ent, "o_entniche.i_ent_fastimport": 1},
+		//		})
+		bl := false
+		if model == 1 {
+			bl = util.MQFW.Update("entniche_rule", bson.M{
+				"i_deptid": entInfo.Dept.Id,
+				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			}, bson.M{
+				"$set": bson.M{
+					"o_entniche.a_items":          a_items_ent,
+					"o_entniche.i_ent_fastimport": 1,
+				},
+			}, false, false)
+		} else if model == 2 {
+			bl = util.MQFW.Update("entniche_rule", bson.M{
+				"s_userid": userId,
+				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			}, bson.M{
+				"$set": bson.M{
+					"o_entniche.a_items":          a_items_ent,
+					"o_entniche.i_ent_fastimport": 1,
+				},
+			}, false, false)
+		}
+
+		if bl {
 			status = 1
 		}
 	}
@@ -514,13 +646,10 @@ func (ac *Action) Get_fastimport() {
 
 //修改项目匹配设置
 func (ac *Action) Update_projectmatch() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	status := 0
 	projectmatch, _ := ac.GetInteger("projectmatch")
 	log.Println("修改项目匹配设置为:", projectmatch)
-	bl := util.MQFW.UpdateById("user", userId, bson.M{
-		"$set": bson.M{"o_entniche.i_projectmatch": projectmatch},
-	})
+	bl := ac.updateEntnicheRule("i_projectmatch", projectmatch)
 	if bl {
 		status = 1
 	}
@@ -532,8 +661,23 @@ func (ac *Action) Update_projectmatch() {
 func (ac *Action) Get_pushset() {
 	data := map[string]interface{}{}
 	userId := qutil.ObjToString(ac.GetSession("userId"))
-	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.i_ratemode":1,"o_entniche.i_apppush":1,"o_entniche.i_mailpush":1,"o_entniche.i_matchway":1}`)
-	if !ok || len(*res) == 0 || res == nil {
+	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.i_ratemode":1,"o_entniche.i_apppush":1,"o_entniche.i_mailpush":1,"o_entniche.i_matchway":1}`)
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	var res *map[string]interface{}
+	switch model {
+	case 1:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	case 2:
+		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+	}
+	if len(*res) == 0 || res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
@@ -551,19 +695,84 @@ func (ac *Action) Get_pushset() {
 
 //推送设置
 func (ac *Action) Update_pushset() {
+	bl := false
+	rules := map[string]interface{}{}
 	userId := qutil.ObjToString(ac.GetSession("userId"))
-	log.Println(userId)
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	dept_id := entInfo.Dept.Id
 	status := 0
 	ratemode, _ := ac.GetInteger("ratemode")
 	apppush, _ := ac.GetInteger("apppush")
 	mailpush, _ := ac.GetInteger("mailpush")
 	matchway, _ := ac.GetInteger("matchway")
-	bl := util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{
-		`o_entniche.i_ratemode`: ratemode,
-		`o_entniche.i_apppush`:  apppush,
-		`o_entniche.i_mailpush`: mailpush,
-		`o_entniche.i_matchway`: matchway,
-	}})
+	switch model {
+	case 1:
+		rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": dept_id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+		if len(*rule) > 0 {
+			bl = util.MQFW.Update("entniche_rule", bson.M{
+				"i_deptid": entInfo.Dept.Id,
+				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			}, bson.M{
+				"$set": bson.M{
+					`o_entniche.i_ratemode`: ratemode,
+					`o_entniche.i_apppush`:  apppush,
+					`o_entniche.i_mailpush`: mailpush,
+					`o_entniche.i_matchway`: matchway,
+				},
+			}, false, false)
+		} else {
+			rules["s_userid"] = userId
+			rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
+			rules["l_createtime"] = time.Now().Unix()
+			rules["o_entniche"] = bson.M{
+				`o_entniche.i_ratemode`: ratemode,
+				`o_entniche.i_apppush`:  apppush,
+				`o_entniche.i_mailpush`: mailpush,
+				`o_entniche.i_matchway`: matchway,
+			} //entniche_rule
+			rules["i_deptid"] = dept_id
+
+			if util.MQFW.Save("entniche_rule", rules) != "" {
+				bl = true
+			}
+		}
+	case 2:
+		rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+		if len(*rule) > 0 {
+			bl = util.MQFW.Update("entniche_rule", bson.M{
+				"s_userid": userId,
+				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			}, bson.M{
+				"$set": bson.M{
+					`o_entniche.i_ratemode`: ratemode,
+					`o_entniche.i_apppush`:  apppush,
+					`o_entniche.i_mailpush`: mailpush,
+					`o_entniche.i_matchway`: matchway,
+				},
+			}, false, false)
+		} else {
+			rules["s_userid"] = userId
+			rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
+			rules["l_createtime"] = time.Now().Unix()
+			rules["o_entniche"] = bson.M{
+				`o_entniche.i_ratemode`: ratemode,
+				`o_entniche.i_apppush`:  apppush,
+				`o_entniche.i_mailpush`: mailpush,
+				`o_entniche.i_matchway`: matchway,
+			} //entniche_rule
+			rules["i_deptid"] = dept_id
+			if util.MQFW.Save("entniche_rule", rules) != "" {
+				bl = true
+			}
+		}
+	}
 	if bl {
 		status = 1
 	}
@@ -600,21 +809,34 @@ func isRepeat(slice1 []string) bool {
 	return false
 }
 
-//两个数组合并去重
-func removalRepeat(slice1, slice2 []interface{}) []interface{} {
+//去重
+func deleteRepeat(slice []string) []string {
+	m := make(map[string]int)
+	slice_repeat := []string{}
+	for _, v := range slice {
+		m[v]++
+	}
+	for x, _ := range m {
+		slice_repeat = append(slice_repeat, qutil.ObjToString(x))
+	}
+	return slice_repeat
+}
+
+//两个数组是否有相等的值
+func isEqualValue(slice1, slice2 []string) bool {
 	m := make(map[interface{}]int)
-	slice := []interface{}{}
 	for _, v := range slice1 {
 		m[v]++
 	}
 	for _, v := range slice2 {
-		//m[v]++
 		m[v]++
 	}
-	for x, _ := range m {
-		slice = append(slice, x)
+	for _, y := range m {
+		if y > 1 {
+			return true
+		}
 	}
-	return slice
+	return false
 }
 
 //判断数组是否包含
@@ -626,3 +848,61 @@ func IsContain(slice []string, s string) bool {
 	}
 	return false
 }
+
+//修改或新增 entniche_rule 表的 entinfo 信息   parameter_name参数名  parameter参数
+func (ac *Action) updateEntnicheRule(parameter_name string, parameter interface{}) bool {
+	bl := false
+	rules := map[string]interface{}{}
+	userId := qutil.ObjToString(ac.GetSession("userId"))
+	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
+	switch model {
+	case 1:
+		rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"i_deptid": entInfo.Dept.Id,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+		if len(*rule) > 0 {
+			bl = util.MQFW.Update("entniche_rule", bson.M{
+				"i_deptid": entInfo.Dept.Id,
+				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			}, bson.M{
+				"$set": bson.M{"o_entniche." + parameter_name: parameter},
+			}, false, false)
+		} else {
+			rules["s_userid"] = userId
+			rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
+			rules["l_createtime"] = time.Now().Unix()
+			rules["o_entniche"] = bson.M{parameter_name: parameter} //entniche_rule
+			rules["i_deptid"] = entInfo.Dept.Id
+
+			if util.MQFW.Save("entniche_rule", rules) != "" {
+				bl = true
+			}
+		}
+	case 2:
+		rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
+			"s_userid": userId,
+			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+		})
+		if len(*rule) > 0 {
+			bl = util.MQFW.Update("entniche_rule", bson.M{
+				"s_userid": userId,
+				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			}, bson.M{
+				"$set": bson.M{"o_entniche." + parameter_name: parameter},
+			}, false, false)
+		} else {
+			rules["s_userid"] = userId
+			rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
+			rules["l_createtime"] = time.Now().Unix()
+			rules["o_entniche"] = bson.M{parameter_name: parameter} //entniche_rule
+			rules["i_deptid"] = entInfo.Dept.Id
+
+			if util.MQFW.Save("entniche_rule", rules) != "" {
+				bl = true
+			}
+		}
+	}
+	return bl
+}

+ 0 - 2
src/jfw/modules/entniche/src/util/constant.go

@@ -12,9 +12,7 @@ const (
 	Entniche_department_parent = "entniche_department_parent"
 	Entniche_info              = "entniche_info"
 	Entniche_log               = "entniche_log"
-	Entniche_power             = "entniche_power"
 	Entniche_role              = "entniche_role"
-	Entniche_role_power        = "entniche_role_power"
 	Entniche_user              = "entniche_user"
 	Entniche_user_role         = "entniche_user_role"
 	Entniche_user_rule         = "entniche_user_rule"

+ 9 - 1
src/jfw/modules/pushsubscribe/src/match/config.json

@@ -15,5 +15,13 @@
 	"notMatchHour":[19,20,21,23,0,1,2,4,5],
 	"userBatch":10,
 	"pcHelperSleep":-1,
-	"pcHelper":"127.0.0.1:8082"
+	"pcHelper":"127.0.0.1:8082",
+	"mysql":{
+        "dbName":"jianyu",
+        "address":"127.0.0.1:3366",
+        "userName":"root",
+        "passWord":"Topnet123",
+		"maxOpenConns": 2,
+		"maxIdleConns": 2
+    }
 }

+ 8 - 0
src/jfw/modules/pushsubscribe/src/match/config/config.go

@@ -22,6 +22,14 @@ type config struct {
 	UserBatch        int      `json:"userBatch"`
 	PcHelper         string   `json:"pcHelper"`
 	PcHelperSleep    int      `json:"pcHelperSleep"`
+	Mysql            struct {
+		DbName       string
+		Address      string
+		UserName     string
+		PassWord     string
+		MaxOpenConns int
+		MaxIdleConns int
+	} `json:"mysql"`
 }
 
 type taskConfig struct {

+ 23 - 1
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	. "match/config"
 	. "match/matcher"
+	. "match/util"
 	. "public"
 	"qfw/util"
 	"qfw/util/elastic"
@@ -20,7 +21,6 @@ import (
 )
 
 const (
-	DbName       = "qfw"
 	DB           = "bidding"
 	MaxId        = `{"query":{"filtered":{"filter":{"bool":{"must":{"range":{"id":{"gt":"%s"}}}}}}},"_source":["_id","comeintime"],"sort":{"id":"desc"},"from":0,"size":1}`
 	ProjectQuery = `{"query":{"filtered":{"filter":{"term":{"list.infoid":"%s"}}}},"_source":["_id","list.infoid"],"sort":{"id":"desc"},"from":0,"size":1}`
@@ -236,6 +236,10 @@ func (m *MatchJob) OnceUserBatch(batchIndex int, lastUserId *string) (int, *VipU
 			originalKeys := []string{}                   //原始关键词
 			////////////////
 			for _, vs := range allKeySet {
+				if vs == nil {
+					logger.Error(user.Id, "关键词设置异常")
+					continue
+				}
 				var vs_keys []string
 				for _, vs_v := range [][]string{vs.Keys, vs.AppendKeys} {
 					for _, vs_vv := range vs_v {
@@ -701,3 +705,21 @@ func (m *MatchJob) ToRelationProject(projectUser *map[*UserInfo]*[]string, myMat
 	}
 	logger.Info("关联项目结束。。。", index)
 }
+
+func (m *MatchJob) LoadEntPersonal() map[string]map[int]bool {
+	user_ent_personal := map[string]map[int]bool{}
+	list := Mysql.SelectBySql("SELECT b.entid,b.phone from entniche_info a INNER JOIN entniche_user b on (a.model=2 and a.id=b.ent_id)")
+	if list == nil {
+		return
+	}
+	for _, v := range *list {
+		phone, _ := v["phone"].(string)
+		entId := util.IntAll(v["entid"])
+		if user_ent_personal[phone] == nil {
+
+			user_ent_personal[phone] = map[int]bool{}
+		}
+		user_ent_personal[phone][entId] = true
+	}
+	return user_ent_personal
+}

+ 12 - 8
src/jfw/modules/pushsubscribe/src/match/job/timetask.go

@@ -19,18 +19,20 @@ var Task = &timeTask{
 type MatchTimeTask struct {
 }
 
-func (m *MatchTimeTask) Execute() {
+func (m *MatchTimeTask) Execute(flag bool) {
 	hour := time.Now().Hour()
 	//23点到1点之间,不执行定时任务
 	//订阅付费有每天0点的定时任务删除pushspace_temp表的数据,会有冲突
 	isRun := true
-	if hour == 0 {
-		isRun = false
-	}
-	for _, v := range Config.NotMatchHour {
-		if v == hour {
+	if flag {
+		if hour == 0 {
 			isRun = false
-			break
+		}
+		for _, v := range Config.NotMatchHour {
+			if v == hour {
+				isRun = false
+				break
+			}
 		}
 	}
 	if isRun {
@@ -39,5 +41,7 @@ func (m *MatchTimeTask) Execute() {
 	}
 	t := time.Duration(Config.MatchDuration) * time.Minute
 	logger.Info("start match job after", t)
-	time.AfterFunc(t, m.Execute)
+	time.AfterFunc(t, func() {
+		m.Execute(true)
+	})
 }

+ 2 - 9
src/jfw/modules/pushsubscribe/src/match/main.go

@@ -4,28 +4,21 @@ package main
 import (
 	"flag"
 	"log"
-	. "match/config"
 	"match/job"
-	"qfw/util/elastic"
-	"qfw/util/mongodb"
-	"qfw/util/redis"
 
 	"github.com/donnie4w/go-logger/logger"
 )
 
 func main() {
-	modle := flag.Int("m", 0, "默认:0;1 匹配数据")
+	modle := flag.Int("m", 0, "默认:0;1 非定时任务匹配数据")
 	flag.Parse()
 	logger.SetConsole(false)
 	logger.SetRollingDaily("./logs", "match.log")
-	mongodb.InitMongodbPool(Config.MgoSize, Config.MgoAddr, job.DbName)
-	redis.InitRedis(Config.RedisServers)
-	elastic.InitElasticSize(Config.ElasticSearch, Config.ElasticPoolSize)
 	log.Println("订阅推送-匹配数据程序启动。。。")
 	if *modle == 1 {
 		job.Jobs.Match.Execute()
 	} else {
-		go job.Task.Match.Execute()
+		go job.Task.Match.Execute(false)
 		<-chan bool(nil)
 	}
 }

+ 34 - 0
src/jfw/modules/pushsubscribe/src/match/util/db.go

@@ -0,0 +1,34 @@
+package util
+
+import (
+	"log"
+	. "match/config"
+	"qfw/util/elastic"
+	"qfw/util/mongodb"
+	"qfw/util/mysql"
+	"qfw/util/redis"
+)
+
+var (
+	Mysql  *mysql.Mysql
+	DbName = "qfw"
+)
+
+func init() {
+	mongodb.InitMongodbPool(Config.MgoSize, Config.MgoAddr, DbName)
+	log.Println("mongodb初始化完成!")
+	redis.InitRedis(Config.RedisServers)
+	log.Println("redis初始化完成!")
+	elastic.InitElasticSize(Config.ElasticSearch, Config.ElasticPoolSize)
+	log.Println("elastic初始化完成!")
+	Mysql = &mysql.Mysql{
+		DBName:       Config.Mysql.DbName,
+		Address:      Config.Mysql.Address,
+		UserName:     Config.Mysql.UserName,
+		PassWord:     Config.Mysql.PassWord,
+		MaxOpenConns: Config.Mysql.MaxOpenConns,
+		MaxIdleConns: Config.Mysql.MaxIdleConns,
+	}
+	Mysql.Init()
+	log.Println("mysql初始化完成!")
+}

+ 1 - 0
src/jfw/modules/pushsubscribe/src/public/entity.go

@@ -33,6 +33,7 @@ type UserInfo struct {
 	CreateTime    int64
 	O_jy          *O_jy
 	O_vipjy       *O_vipjy
+	O_entniche    *O_vipjy
 }
 
 type O_jy struct {

+ 20 - 16
src/jfw/modules/pushsubscribe/src/public/util.go

@@ -12,22 +12,26 @@ import (
 )
 
 const (
-	BulkSize            = 20
-	BigBulkSize         = 100
-	OneDaySecond        = 86400
-	SevenDay            = 604800
-	User                = "user"
-	Bidding             = "bidding"
-	Projectset          = "projectset"
-	Pushspace_project   = "pushspace_project"
-	Pushspace_statistic = "pushspace_statistic"
-	Pushspace_temp      = "pushspace_temp"
-	Pushspace_vip       = "pushspace_vip"
-	Pushspace_vip_fail  = "pushspace_vip_fail"
-	Pushspace_fail      = "pushspace_fail"
-	Pushspace           = "pushspace"
-	Pushcache_1         = "pushcache_1"
-	Pushcache_2_a       = "pushcache_2_a"
+	BulkSize                         = 20
+	BigBulkSize                      = 100
+	OneDaySecond                     = 86400
+	SevenDay                         = 604800
+	User                             = "user"
+	Bidding                          = "bidding"
+	Projectset                       = "projectset"
+	Pushspace_project                = "pushspace_project"
+	Pushspace_statistic              = "pushspace_statistic"
+	Pushspace_temp                   = "pushspace_temp"
+	Pushspace_vip                    = "pushspace_vip"
+	Pushspace_vip_fail               = "pushspace_vip_fail"
+	Pushspace_fail                   = "pushspace_fail"
+	Pushcache_entniche_personal      = "pushcache_entniche_personal"
+	Pushcache_entniche_personal_temp = "pushcache_entniche_personal_temp"
+	Pushcache_entniche_unified       = "pushcache_entniche_unified"
+	Pushcache_entniche_unified_temp  = "pushcache_entniche_unified_temp"
+	Pushspace                        = "pushspace"
+	Pushcache_1                      = "pushcache_1"
+	Pushcache_2_a                    = "pushcache_2_a"
 )
 
 var (

+ 2 - 1
src/jfw/modules/pushsubscribe/src/push/config.json

@@ -51,7 +51,8 @@
 	"testids":["5d81c5a525ef8723ac0036f9"],
 	"weixinRpcServer":"127.0.0.1:8083",
 	"wxColor":"#2cb7ca",
-	"wxGroup":"招标信息",
+	"wxType":"标讯订阅",
+	"vipWxType":"VIP订阅",
 	"wxTitle":"根据你订阅的关键词“%s”,剑鱼标讯为你推送以下信息。如果不想继续收到此类信息,可进入招标订阅的设置页面取消订阅。",
 	"vipWxTitle":"根据你当前订阅,剑鱼标讯为你推送以下信息。如果不想继续收到此类信息,可进入招标订阅的设置页面取消订阅。",
 	"wxDetailColor":"#686868",

+ 2 - 3
src/jfw/modules/pushsubscribe/src/push/config/config.go

@@ -28,8 +28,9 @@ type config struct {
 	TestIds                 []string       `json:"testIds"`
 	WeixinRpcServer         string         `json:"weixinRpcServer"`
 	WxColor                 string         `json:"wxColor"`
-	WxGroup                 string         `json:"wxGroup"`
 	WxTitle                 string         `json:"wxTitle"`
+	WxType                  string         `json:"wxType"`
+	VipWxType               string         `json:"vipWxType"`
 	VipWxTitle              string         `json:"vipWxTitle"`
 	WxDetailColor           string         `json:"wxDetailColor"`
 	AppPushServiceRpc       string         `json:"appPushServiceRpc"`
@@ -91,7 +92,6 @@ var (
 	Gmails         []*mail.GmailAuth
 	Config         *config
 	ProjectTask    *projectTask
-	WxGroupLen     int
 	FastigiumStart int
 	FastigiumEnd   int
 )
@@ -104,7 +104,6 @@ func init() {
 		FastigiumStart = util.IntAll(fastigiumTimes[0])
 		FastigiumEnd = util.IntAll(fastigiumTimes[1])
 	}
-	WxGroupLen = len([]rune(Config.WxGroup))
 	Gmails = make([]*mail.GmailAuth, len(Config.Mails))
 	for k, v := range Config.Mails {
 		Gmails[k] = &mail.GmailAuth{

+ 5 - 1
src/jfw/modules/pushsubscribe/src/push/job/pushjob.go

@@ -186,7 +186,11 @@ func (p *PushJob) doPush(pusher Pusher, taskType int, pushWay *putil.PushWay, u
 				wxTitle = fmt.Sprintf(Config.WxTitle, wxTitleKeys)
 			}
 			TitleLen := len([]rune(wxTitle))
-			reLen := 200 - TitleLen - 10 - WxGroupLen - len([]rune(tip))
+			TypeLen := len([]rune(Config.WxType))
+			if IsVipUser(u.VipStatus) {
+				TypeLen = len([]rune(Config.VipWxType))
+			}
+			reLen := 200 - TitleLen - 10 - TypeLen - len([]rune(tip))
 			wxTplTitle := ""
 			bshow := false
 			for n := 1; n < len(pushParam.TitleArray)+1; n++ {

二進制
src/jfw/modules/pushsubscribe/src/push/push


+ 5 - 1
src/jfw/modules/pushsubscribe/src/push/util/rpccall.go

@@ -31,11 +31,15 @@ func SendWeixin(k *UserInfo, remark, title string, pushDate int64) bool {
 	if Config.WxSleep > 0 {
 		time.Sleep(time.Duration(Config.WxSleep) * time.Millisecond)
 	}
+	wxTplType := Config.WxType
+	if IsVipUser(k.VipStatus) {
+		wxTplType = Config.VipWxType
+	}
 	p := &qrpc.NotifyMsg{
 		Openid:      k.S_m_openid,
 		Title:       title,
 		Remark:      remark,
-		Detail:      Config.WxGroup,
+		Detail:      wxTplType,
 		Date:        "",
 		Service:     util.NowFormat(util.Date_Short_Layout),
 		Color:       Config.WxColor,

File diff suppressed because it is too large
+ 0 - 0
src/jfw/modules/subscribepay/src/dataexport.json


+ 32 - 1
src/jfw/modules/subscribepay/src/entity/dataexport.go

@@ -10,6 +10,7 @@ import (
 	qutil "qfw/util"
 	"qfw/util/mail"
 	"regexp"
+	"strconv"
 	"strings"
 	"sync"
 	"time"
@@ -43,6 +44,7 @@ type DataexportConfig struct {
 	Font                             Font              `json:"font"`
 	Mail_invoice_finance_content     string            `json:"mail_invoice_finance_content"`     //to北京财务订单内容
 	Mail_vip_invoice_finance_content string            `json:"mail_vip_invoice_finance_content"` //vip订单 to北京财务申请发票内容
+	Mail_ent_invoice_finance_content string            `json:"mail_ent_invoice_finance_content"` //企业商机管理 to北京财务申请发票内容
 	Mail_order_finance_content       string            `json:"mail_order_finance_content"`       //to北京财务申请发票内容
 	Finance_emails                   []string          `json:"finance_emails"`
 	Qmxdomain                        string            `json:"qmxdomain"`
@@ -451,7 +453,6 @@ func SendMailToBJFinance(order *map[string]interface{}, pay_time, transaction_id
 
 				// 订阅周期 有效日期
 				if vip_endtime != "" && vip_starttime != "" {
-					log.Println(vip_endtime, "---", vip_starttime)
 					year := 0
 					month := 0
 					//订阅周期
@@ -523,6 +524,36 @@ func SendMailToBJFinance(order *map[string]interface{}, pay_time, transaction_id
 			}
 			mail_title = "电子发票申请-[剑鱼标讯]VIP订阅(" + order_code + ")"
 			mailcontent = fmt.Sprintf(ExConf.Mail_vip_invoice_finance_content, bill_title, company_flag, bill_company, taxnum_flag, bill_taxnum, user_email, order_code, create_time, payment_number, pay_time, pay_way, product_type, pay_money, display_a, subscription_area, industry, subscription_cycle, display_b, subscription_area, industry, subscription_cycle, display_c, subscription_area, industry, subscription_cycle, effective_date)
+		} else if product_type == "企业商机管理导出" {
+			//邮箱
+			user_email := ""
+			user_id := qutil.ObjToString((*order)["user_id"])
+			res, _ := util.MQFW.FindOne("user", bson.M{"_id": bson.ObjectIdHex(user_id)})
+			if len(*res) > 0 {
+				if qutil.ObjToString((*res)["s_myemail"]) != "" {
+					user_email = qutil.ObjToString((*res)["s_myemail"])
+				}
+			}
+			filter := qutil.ObjToString((*order)["filter"])
+			ent_filter := map[string]interface{}{}
+			err := json.Unmarshal([]byte(filter), &ent_filter)
+			entname, personnum, cycle := "", "", ""
+			if err == nil && ent_filter != nil {
+				entname = qutil.ObjToString(ent_filter["entname"])
+				personnum = strconv.Itoa(qutil.IntAll(ent_filter["personnum"])) + "人"
+				cycle = strconv.Itoa(qutil.IntAll(ent_filter["cycle"])) + "年"
+			}
+			display_a, display_b := "", ""
+			vip_type := qutil.Int64All((*order)["vip_type"]) //判断 续费
+			if vip_type == 1 {                               //续费
+				display_a = "none"
+			} else {
+				display_b = "none"
+			}
+			product_type = "企业商机管理"
+			payment_number := getPayTransactionId(qutil.ObjToString((*order)["pay_way"]), qutil.ObjToString((*order)["out_trade_no"]))
+			mail_title = "电子发票申请-[剑鱼标讯]企业商机管理(" + order_code + ")"
+			mailcontent = fmt.Sprintf(ExConf.Mail_ent_invoice_finance_content, bill_title, company_flag, bill_company, taxnum_flag, bill_taxnum, user_email, order_code, create_time, payment_number, pay_time, pay_way, product_type, pay_money, entname, personnum, display_a, cycle, display_b, cycle)
 		}
 	}
 	//发送邮件

+ 0 - 1
src/jfw/modules/subscribepay/src/entity/entniche.go

@@ -35,7 +35,6 @@ func (e *entnicheStruct) PayCallBack(param *CallBackParam) bool {
 			phone, _ := filter["phone"].(string)
 			industry, _ := filter["industry"].(string)
 			enddate := time.Date(now.Year()+cycle, now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
-			var filter_id int64
 			ent := util.Mysql.FindOne("entniche_info", map[string]interface{}{
 				"name":  entname,
 				"phone": phone,

+ 12 - 1
src/jfw/modules/subscribepay/src/service/entniche.go

@@ -67,7 +67,10 @@ func (e *Entniche) Buy() {
 		if util.Mysql.Count("entniche_info", map[string]interface{}{"name": entname, "phone": phone, "status": 1}) > 0 {
 			return -2, ""
 		}
-		order_money := int(config.EntnicheConfig.Discount * price * float64(cycle) * 100)
+		order_money := int(config.EntnicheConfig.Discount * price * float64(cycle) * float64(personnum) * 100)
+		if order_money < 1 {
+			order_money = 1
+		}
 		code := pay.GetOrderCode(userId)
 		if util.Mysql.ExecTx("企业商机管理创建订单", func(tx *sql.Tx) bool {
 			filter, _ := json.Marshal(map[string]interface{}{
@@ -103,6 +106,14 @@ func (e *Entniche) Buy() {
 			isadmin = 1
 		}
 	}
+	log.Println(map[string]interface{}{
+		"error_code": 0,
+		"data": map[string]interface{}{
+			"status":    status,
+			"ordercode": ordercode,
+			"isadmin":   isadmin,
+		},
+	})
 	e.ServeJson(map[string]interface{}{
 		"error_code": 0,
 		"data": map[string]interface{}{

+ 3 - 1
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -478,7 +478,7 @@ func (o *OrderListDetails) GetEntnicheDetails() {
 		if order_code != "" {
 			data = *util.Mysql.FindOne(tableName_order, map[string]interface{}{
 				"order_code": order_code,
-			}, "order_code,order_status,create_time,pay_time,pay_way,prepay_id,product_type,pay_money,order_money,filter,applybill_type,applybill_taxnum,applybill_company", "")
+			}, "order_code,order_status,create_time,pay_time,pay_way,out_trade_no,prepay_id,product_type,pay_money,order_money,filter,applybill_type,applybill_taxnum,applybill_company,applybill_status", "")
 
 			if data != nil {
 				//filter
@@ -500,6 +500,7 @@ func (o *OrderListDetails) GetEntnicheDetails() {
 				} else {
 					data["order_countdown"] = qutil.IntAll(order_countdown)
 				}
+				data["prepay_id"] = getPayTransactionId(qutil.ObjToString(data["pay_way"]), qutil.ObjToString(data["out_trade_no"]))
 			}
 		}
 	}
@@ -656,6 +657,7 @@ func isEmail(value string) bool {
 
 //获取支付单号
 func getPayTransactionId(payWay, tradeNo string) (transaction_id string) {
+	log.Println(payWay, tradeNo)
 	if payWay == "" || tradeNo == "" {
 		return
 	}

Some files were not shown because too many files changed in this diff