Browse Source

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

wangshan 5 years ago
parent
commit
ab5836535c
26 changed files with 1223 additions and 424 deletions
  1. 19 0
      src/jfw/modules/app/src/app/front/entniche.go
  2. 6 0
      src/jfw/modules/app/src/app/front/login.go
  3. 22 17
      src/jfw/modules/app/src/app/front/me.go
  4. 31 21
      src/jfw/modules/app/src/app/front/swordfish.go
  5. BIN
      src/jfw/modules/app/src/web/staticres/jyapp/images/switch-line.png
  6. BIN
      src/jfw/modules/app/src/web/staticres/jyapp/images/switch-star.png
  7. BIN
      src/jfw/modules/app/src/web/staticres/jyapp/images/switch-text.png
  8. 9 0
      src/jfw/modules/app/src/web/staticres/jyapp/js/common.js
  9. 22 8
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_toMyOrder.html
  10. 2 2
      src/jfw/modules/app/src/web/templates/entniche/entniche_order_detail.html
  11. 307 0
      src/jfw/modules/app/src/web/templates/entniche/entniche_seniorset.html
  12. 469 160
      src/jfw/modules/app/src/web/templates/weixin/historypush.html
  13. 2 2
      src/jfw/modules/entniche/src/config.json
  14. 2 2
      src/jfw/modules/entniche/src/entity/department.go
  15. 23 17
      src/jfw/modules/entniche/src/entity/entity.go
  16. 1 3
      src/jfw/modules/entniche/src/filter/sessionfilter.go
  17. 22 12
      src/jfw/modules/entniche/src/service/buy/buy.go
  18. 3 3
      src/jfw/modules/entniche/src/service/distribute/distribute.go
  19. 56 11
      src/jfw/modules/entniche/src/service/ent/ent.go
  20. 1 1
      src/jfw/modules/entniche/src/service/service.go
  21. 64 13
      src/jfw/modules/entniche/src/service/subscribe/subscribe.go
  22. 6 1
      src/jfw/modules/entniche/src/util/util.go
  23. 24 12
      src/jfw/modules/subscribepay/src/entity/entniche.go
  24. 24 6
      src/jfw/modules/subscribepay/src/entity/subscribeVip.go
  25. 85 121
      src/jfw/modules/subscribepay/src/service/entniche.go
  26. 23 12
      src/jfw/modules/subscribepay/src/service/orderListDetails.go

+ 19 - 0
src/jfw/modules/app/src/app/front/entniche.go

@@ -0,0 +1,19 @@
+package front
+
+import (
+	"github.com/go-xweb/xweb"
+)
+
+type Entniche struct {
+	*xweb.Action
+	toSetEntPushSetPage xweb.Mapper `xweb:"/jyapp/entniche/toSetEntPushSetPage"` //订阅收费推送设置
+}
+
+func init() {
+	xweb.AddAction(&Entniche{})
+}
+
+//推送设置
+func (e *Entniche) ToSetEntPushSetPage() {
+	e.Render("/entniche/entniche_seniorset.html")
+}

+ 6 - 0
src/jfw/modules/app/src/app/front/login.go

@@ -860,6 +860,12 @@ func clearSession(s *httpsession.Session) {
 	//清除数据导出信息
 	s.Del("DataExportVerifyEmail_val")
 	s.Del("DataExportVerifyPhone_val")
+	//清除企业商机管理
+	s.Del("selectEntId")
+	s.Del("selectEntName")
+	s.Del("entId")
+	s.Del("entName")
+	s.Del("prevSelectEntId")
 }
 
 //生成签名,返回手机端

+ 22 - 17
src/jfw/modules/app/src/app/front/me.go

@@ -293,33 +293,42 @@ func (l *Me) MyInfo() {
 		"userType": "free",
 		"hasEnt":   false,
 	}
-	if l.GetSession("entId") != nil {
+	if l.GetSession("selectEntId") != l.GetSession("prevSelectEntId") {
+		r["reLoad"] = true
+		l.SetSession("prevSelectEntId", l.GetSession("selectEntId"))
+	} else {
+		r["reLoad"] = false
+	}
+	userId, _ := l.GetSession("userId").(string)
+	if l.GetSession("selectEntId") != nil {
 		r["userType"] = "ent"
 		r["hasEnt"] = true
-		r["entName"] = l.GetSession("entName")
+		r["entName"] = l.GetSession("selectEntName")
+		user, ok := mongodb.FindById("user", userId, `{"i_entniche_first":1}`)
+		if ok && user != nil {
+			r["entFirst"] = qutil.IntAll((*user)["i_entniche_first"]) == 0
+		}
 	} else {
-		userId, _ := l.GetSession("userId").(string)
-		user, ok := mongodb.FindById("user", userId, `{"s_phone":1,"o_jy":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1}`)
+		user, ok := mongodb.FindById("user", userId, `{"s_phone":1,"o_jy":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1,"i_vip_subtips":1,"i_entniche_first":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"]
+				_endtime := qutil.Int64All((*user)["l_vip_endtime"])
+				now_unix := time.Now().Unix()
 				//是否到期
-				if qutil.Int64All(_endtime)-time.Now().Unix() < threeRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
+				if _endtime-now_unix < threeRemind && _endtime-now_unix >= twoRemind {
 					isExpire = 3 //即将到期
-				} else if qutil.Int64All(_endtime)-time.Now().Unix() < twoRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
+				} else if _endtime-now_unix < twoRemind && _endtime-now_unix >= oneRemind {
 					isExpire = 2 //即将到期
-				} else if qutil.Int64All(_endtime)-time.Now().Unix() < oneRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= 0 {
+				} else if _endtime-now_unix < oneRemind && _endtime-now_unix >= 0 {
 					isExpire = 1 //即将到期
 				}
 				isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 2000
@@ -329,11 +338,6 @@ func (l *Me) MyInfo() {
 					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 {
@@ -342,12 +346,13 @@ func (l *Me) MyInfo() {
 				}
 			}
 			r["isExpire"] = isExpire
-			r["isOnTail"] = isOnTail
+			r["vipStatus"] = qutil.IntAll((*user)["i_vip_status"])
 			r["isPassCount"] = isPassCount
 			r["haskey"] = hasKeyFlag
+			r["entFirst"] = qutil.IntAll((*user)["i_entniche_first"]) == 0
 			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) 
+			LEFT JOIN entniche_user b on (a.id=b.ent_id) 
 			where a.phone=? or b.phone=?`, phone, phone) > 0 {
 				r["hasEnt"] = true
 			}

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

@@ -673,7 +673,13 @@ func (f *Front) HasPushHistory() {
 		pageNum = 1
 	}
 	area := f.GetString("area")
-	hasNextPage, list := jy.SubscribePush.Datas(public.MQFW, public.PushMysql, userId, pageNum, formatTime, area)
+	var hasNextPage bool
+	list := []*jy.SubPushList{}
+	if selectEntId := f.GetSession("selectEntId"); selectEntId != nil {
+
+	} else {
+		hasNextPage, list = jy.SubscribePush.Datas(public.MQFW, public.PushMysql, userId, pageNum, formatTime, area)
+	}
 	if len(list) > 0 {
 		go updateUserApppushunread(userId)
 		//formatTime
@@ -699,24 +705,22 @@ func (f *Front) HasPushHistory() {
 
 //历史推送
 func (f *Front) Historypush() error {
-	userId := util.ObjToString(f.GetSession("userId"))
+	userId, _ := f.GetSession("userId").(string)
 	if userId != "" {
-		selectTime := f.GetString("selectTime")
-		f.T["selectTime"] = selectTime
-		isExprie := 1
+		f.T["selectTime"] = f.GetString("selectTime")
+		vipSubtips := 1
 		// 打开推送
-		data, ok := mongodb.FindById("user", userId, nil)
+		data, ok := mongodb.FindById("user", userId, `{"i_vip_subtips":1}`)
 		if ok && data != nil && len(*data) > 0 {
 			//VIP服务到期
-			vipSubtips := (*data)["i_vip_subtips"]
-			if vipSubtips == 0 {
+			i_vip_subtips := (*data)["i_vip_subtips"]
+			if i_vip_subtips == 0 {
 				if mongodb.UpdateById("user", userId, bson.M{"$set": bson.M{"i_vip_subtips": 1}}) {
-					isExprie = 0
+					vipSubtips = 0
 				}
 			}
 		}
-		f.T["vipSubtips"] = isExprie
-		f.T["isVip"] = util.IntAll((*data)["i_vip_status"]) > 0
+		f.T["vipSubtips"] = vipSubtips
 	}
 	return f.Render("/weixin/historypush.html", &f.T)
 }
@@ -733,17 +737,23 @@ func (f *Front) HistorypushPaging() error {
 	}
 	area := f.GetString("area")
 	userId, _ := f.GetSession("userId").(string)
-	if userId != "" {
-		if pageNum == 1 {
-			go updateUserApppushunread(userId)
-		}
-		//		_, firstPushTime := public.HistoryPush.UserInfo(userId)
-		hasNextPage, list := jy.SubscribePush.Datas(public.MQFW, public.PushMysql, userId, pageNum, formatTime, area)
-		f.ServeJson(map[string]interface{}{
-			"hasNextPage": hasNextPage,
-			"data":        list,
-		})
+	if userId == "" {
+		return nil
 	}
+	if pageNum == 1 {
+		go updateUserApppushunread(userId)
+	}
+	var hasNextPage bool
+	list := []*jy.SubPushList{}
+	if selectEntId := f.GetSession("selectEntId"); selectEntId != nil {
+
+	} else {
+		hasNextPage, list = jy.SubscribePush.Datas(public.MQFW, public.PushMysql, userId, pageNum, formatTime, area)
+	}
+	f.ServeJson(map[string]interface{}{
+		"hasNextPage": hasNextPage,
+		"data":        list,
+	})
 	return nil
 }
 

BIN
src/jfw/modules/app/src/web/staticres/jyapp/images/switch-line.png


BIN
src/jfw/modules/app/src/web/staticres/jyapp/images/switch-star.png


BIN
src/jfw/modules/app/src/web/staticres/jyapp/images/switch-text.png


+ 9 - 0
src/jfw/modules/app/src/web/staticres/jyapp/js/common.js

@@ -78,6 +78,15 @@ $(function(){
 			sendChannelSign();
 		}catch(e){}
 	}
+	setInterval(function(){
+		if(localStorage.chooseTab != undefined){
+			try{
+				JyObj.hiddenBottom("1");
+				JyObj.chooseTab(parseInt(localStorage.chooseTab));
+				localStorage.removeItem("chooseTab");
+			}catch(e){}
+		}
+	},1000);
 });
 var EasyAlert = {
 	timeout: null,

+ 22 - 8
src/jfw/modules/app/src/web/templates/dataExport/dataExport_toMyOrder.html

@@ -548,7 +548,7 @@
 				if (isVipOrder=="true"){
 					window.location.href="/jyapp/vipsubscribe/toOrderDetailPage?orderCode="+eid;
 				}else if(isent=="true"){
-					window.location.href="/jyapp/front/myorder/toEntnicheDetail?orderCode="+eid;
+					window.location.href="/jyapp/front/myorder/toEntnicheDetail?order_code="+eid;
 				}else if(courseOrder=="true"){
 					window.location.href="/jyapp/course/orderDetail?code="+vid;
 				}else{
@@ -589,10 +589,10 @@
 				var orderCode = $(e).parent(".card-footer").prev(".card-content").find("a").attr("eid");
 				if (pattern==1){
 					//再次购买
-					window.location.href="http://192.168.20.216:5500/page/buy_production/renew_production.html?orderCode="+orderCode;   
+					window.location.href="/page_entniche/page/buy_production/buy_production.html";   
 				}else if (pattern==2){
 					//续费
-					window.location.href="";
+					window.location.href="/page_entniche/page/buy_production/renew_production.html?ordercode="+orderCode;
 				}
 			}
 			
@@ -722,13 +722,19 @@
 			                                   					 var self = $(obj).parent(".card-footer").prev(".card-content").prev(".card-header").children(".notpay");
 			                                   					 self.css("color","black");
 																 var isVipOrder =$(obj).parent(".card-footer").prev(".card-content").children(".media").attr("isvipOrder");
+																 var isEntOrder =$(obj).parent(".card-footer").prev(".card-content").children(".media").attr("isent");
 			                                   					 var courseOrder =$(obj).parent(".card-footer").prev(".card-content").children(".media").attr("courseOrder");
 			                                   					 var courseId = $(obj).parent(".card-footer").prev(".card-content").find("a").attr("eid");
 			                                   					 //vip订单取消了没有再次购买
 			                                   					if (isVipOrder!="true"){
 																	 if(courseOrder !== "true"){
-																		 self.text("已取消");
-																		 $(obj).parent(".card-footer").html('<a  onclick="onceMore(this)" class="btn cancle">再次购买</a>')
+																		if (isEntOrder=="true"){
+																			self.text("已取消");
+																			$(obj).parent(".card-footer").html('<a  onclick="renewalOrBuyAgain_ent(1,this)" class="btn cancle">再次购买</a>')
+																		}else{
+																			self.text("已取消");
+																			$(obj).parent(".card-footer").html('<a  onclick="onceMore(this)" class="btn cancle">再次购买</a>')
+																		}
 																	 }else{
 																		 $(obj).parent(".card-footer").html(`<a href="/swordfish/course/detail/${courseId}" class="btn cancle">再次购买</a>`)
 																		 self.children().remove()
@@ -815,11 +821,15 @@
 				$('input:radio[name="way"]').click(function() {
 					var checkValue = $('input:radio[name="way"]:checked').val();
 					var order_code_vip=$(".order_code_vip").text();
+					var order_code_ent=$(".order_code_ent").text();
 		        	if(checkValue=="微信支付"){
 		        		localStorage.setItem($(".param_id").text(),"wx");
 						if(order_code_vip){
 		        			localStorage.setItem(order_code_vip,"wx");
 						}
+						if(order_code_ent){
+		        			localStorage.setItem(order_code_ent,"wx");
+						}
 		        		$("#wx").prop("checked",true);
 						$("#zfb").prop("checked",false);
 		            	pay_way="wx_app";
@@ -828,6 +838,9 @@
 		        		if(order_code_vip){
 		        			localStorage.setItem(order_code_vip,"ali");
 						}
+						if(order_code_ent){
+		        			localStorage.setItem(order_code_ent,"wx");
+						}
 		        		$("#wx").prop("checked",false);
 						$("#zfb").prop("checked",true);
 		        		pay_way="ali_app";
@@ -1002,7 +1015,7 @@
 										sessionStorage.reloadHomePage = true;
 										sessionStorage.reloadSubPage = true;
 									}catch(e){}	
-									window.location.href="http://192.168.20.216:5500/page/buy_production/pay_success.html?orderCode="+order_entcode;
+									window.location.href="/page_entniche/page/buy_production/pay_success.html?ordercode="+order_entcode;
 									clearInterval(interval_ent);
 								})
 							}
@@ -2120,11 +2133,11 @@
 						iconHtml=""
 						if((i_ent_status==false)&&(obj.lastbuy_code_ent!=undefined)){
 							iconHtml+='<div class="card-footer">'
-									+'<a  onclick="renewalOrBuyAgain_ent(2,this)" class="btn cancle">再次购买</a>'
+									+'<a  onclick="renewalOrBuyAgain_ent(1,this)" class="btn cancle">再次购买</a>'
 								+'</div>'
 						}else if((i_ent_status==true)&&(obj.lastbuy_code_ent!=undefined)){
 							iconHtml+='<div class="card-footer">'
-									+'<a  onclick="renewalOrBuyAgain_ent(1,this)" class="btn cancle">续费</a>'
+									+'<a  onclick="renewalOrBuyAgain_ent(2,this)" class="btn cancle">续费</a>'
 								+'</div>'
 						}
 					}else if(order_status_ent==-2){
@@ -2134,6 +2147,7 @@
 						orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id_ent +",this)\"></a>";
 						iconHtml="";
 						iconHtml+='<div class="card-footer">'
+								+'<a  onclick="renewalOrBuyAgain_ent(1,this)" class="btn cancle">再次购买</a>'
 								+'</div>'
 					}
 					//

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

@@ -426,7 +426,7 @@ body .loading_ p span {
 	$(function(){
 		$(".loading_").hide();
 		var pay_way="";
-    	var orderCode=decodeURIComponent(getParam("orderCode"));
+    	var orderCode=decodeURIComponent(getParam("order_code"));
 		$.post("/subscribepay/orderListDetails/entnicheDetails",{"order_code":orderCode},function(r){
 				console.log(r.data)
 				if (r.data){
@@ -670,7 +670,7 @@ body .loading_ p span {
 							sessionStorage.reloadHomePage = true;
 							sessionStorage.reloadSubPage = true;
 						}catch(e){}	
-						window.location.href="http://192.168.20.216:5500/page/buy_production/pay_success.html?orderCode="+order_entcode;
+						window.location.href="/page_entniche/page/buy_production/pay_success.html?ordercode="+order_entcode;
 					}
 				})
 			},3000)

+ 307 - 0
src/jfw/modules/app/src/web/templates/entniche/entniche_seniorset.html

@@ -0,0 +1,307 @@
+<html>
+<head>
+	{{include "/common/meta.html"}}
+	<title>推送设置</title>
+	<link href="{{Msg "seo" "cdn"}}/jyapp/mobiscroll/mobiscroll.min.css" rel="stylesheet">
+	<link href="{{Msg "seo" "cdn"}}/jyapp/css/common.css?v={{Msg "seo" "version"}}" rel="stylesheet">
+	<link href="{{Msg "seo" "cdn"}}/jyapp/css/wxkeyset.css?v={{Msg "seo" "version"}}" rel="stylesheet">
+	<script src="{{Msg "seo" "cdn"}}/jyapp/js/jquery.js"></script>
+	<script src="{{Msg "seo" "cdn"}}/jyapp/js/fastclick.js?v={{Msg "seo" "version"}}"></script>
+	<script src="{{Msg "seo" "cdn"}}/jyapp/js/common.js?v={{Msg "seo" "version"}}"></script>
+	<script src="{{Msg "seo" "cdn"}}/jyapp/mobiscroll/mobiscroll.min.js"></script>
+	<script src="{{Msg "seo" "cdn"}}/jyapp/js/rem.js"></script>
+	<style>
+		#pushway ul>li:nth-child(n+2) {
+			/*padding: 8px 0px;*/
+		}
+		#matchType ul>li:nth-child(n+2) {
+			line-height: normal;
+			padding: 14px 0px;
+			color: #1d1d1d;
+		}
+		#matchType ul>li:nth-child(2) {
+			padding-top: 16px;
+			line-height: 55px;
+		}
+		#matchType ul>li>span {
+			display: block;
+			margin-top: 6px;
+			font-size: 14px;
+			color: #686868;
+		}
+	</style>
+    <script>
+		var keepOneTipWayMsg = "请保留一种推送方式,<br>剑鱼标讯还要推送信息给您";
+		var emailSetModal = null;
+		var clickDelayed = false;
+		setTimeout(function(){
+			clickDelayed = true;
+		},500);
+		$(function(){
+			new FastClick(document.body);
+			emailSetModal = new EasyPopup("emailSetModal");
+			$(window).bind("pageshow", function(event){
+				if(event.originalEvent.persisted){
+					window.location.reload(true);
+				}
+			});
+			//获取推送设置
+             $.post("/entniche/subscribe/pushset/get",{},function(r){
+					console.log(r)
+					if (r.data!=null){
+						//推送时间
+						if (r.data.ratemode!=undefined){
+	                        $("#pushfrequency li").eq(parseInt(r.data.ratemode)).addClass("checked");
+	                    }else{
+							$("#pushfrequency li").eq(1).addClass("checked");
+	                    }
+						//推送方式
+						if (r.data.mailpush==0&&r.data.apppush==0){
+							$("#wxtip").addClass("on");
+							$("#wxtip .turn-off").hide();
+		                    $("#wxtip .turn-on").show();
+		                    $("#emailtip .turn-on").hide();
+							$("#emailtip .turn-off").show();
+						}
+						if(r.data.apppush==1){
+							$("#wxtip").addClass("on");
+							$("#wxtip .turn-off").hide();
+		                    $("#wxtip .turn-on").show();
+						}else{
+							$("#wxtip .turn-on").hide();
+							$("#wxtip .turn-off").show();
+						}
+						if(r.data.mailpush==1){
+							$("#emailtip").addClass("on");
+							$("#emailtip .turn-off").hide();
+		                    $("#emailtip .turn-on").show();
+						}else{
+							$("#emailtip .turn-on").hide();
+							$("#emailtip .turn-off").show();
+						}
+						//关键词匹配方式
+						 if (r.data.matchway!=undefined){
+	                        $("#matchType li").eq(r.data.matchway).addClass("checked");
+	                    }else{
+	                        $("#matchType li").eq(1).addClass("checked");
+	                    }
+					}else{
+							//
+							$("#pushfrequency li").eq(1).addClass("checked");
+							
+							$("#wxtip").addClass("on");
+							$("#wxtip .turn-off").hide();
+		                    $("#wxtip .turn-on").show();
+							$("#emailtip .turn-off").show();
+		                    $("#emailtip .turn-on").hide();
+							
+	                        $("#matchType li").eq(1).addClass("checked");
+					}
+            })
+			////////////////////////////////
+			$(".modal-dialog").css("margin-top",$(window).height()*0.25);
+			//推送结果预览
+			$("#resultpreview").click(function(){
+				if(!clickDelayed){
+					return;
+				}
+				window.location.href = "/jyapp/vipsubscribe/toVIPViewPage";
+			});
+			
+			//app提醒
+			$("#wxtip>img").click(function(){
+				var parentLi = $(this).parent();
+				if($(this).hasClass("turn-on")){
+					if(!$("#emailtip").hasClass("on")){
+						EasyAlert.show(keepOneTipWayMsg);
+						return;
+					}
+					parentLi.removeClass("on");
+					parentLi.children(".turn-off").show();
+					parentLi.children(".turn-on").hide();
+				}else{
+					parentLi.addClass("on");
+					parentLi.children(".turn-on").show();
+					parentLi.children(".turn-off").hide();
+				}
+				saveData();
+			});
+			//邮件提醒
+			$("#emailtip>img").click(function(){
+				var parentLi = $(this).parent();
+				if($(this).hasClass("turn-on")){
+					if(!$("#wxtip").hasClass("on")){
+						EasyAlert.show(keepOneTipWayMsg);
+						return;
+					}
+					parentLi.removeClass("on");
+					parentLi.children(".turn-off").show();
+					parentLi.children(".turn-on").hide();
+				}else{
+					emailtipOn();
+				}
+				saveData();
+			});
+			$(".complate").click(function(){
+				if(!clickDelayed){
+					return;
+				}
+				window.history.go(-1);
+			});
+			//
+			sessionStorage.setItem('index_read_cache','6');
+		});
+		//
+		function emailtipOn(){
+			$("#emailtip").addClass("on");
+			$("#emailtip").children(".turn-on").show();
+			$("#emailtip").children(".turn-off").hide();
+		}
+		function saveData(){
+			var param = {
+				"ratemode": 1,
+				"apppush":0,
+				"mailpush":0,
+				"matchway":1,
+			};
+			if($("#matchType li:eq(2)").hasClass("checked")){
+				param["matchway"] = 2;
+			}
+			$("#pushfrequency li").each(function(){
+				if ($(this).hasClass("checked")){
+					param["ratemode"] = $(this).attr("dataid");
+				}
+			})
+			//
+			if($("#wxtip").hasClass("on")){
+				param["apppush"] = 1;
+			}
+			if($("#emailtip").hasClass("on")){
+				param["mailpush"] = 1;
+			}
+			$.post("/entniche/subscribe/pushset/update",param,function(r){
+				if(r.data.status!=1){
+					EasyAlert.show("设置失败")
+				}
+			});
+		}
+		//
+		function docheck(n,th){
+			if(parseInt(n)<5){
+				$("#pushfrequency li").each(function(){
+					var linum = $(this).attr("dataid");
+					$(this).removeClass("checked");
+					if(linum==n){
+						$(this).addClass("checked");
+					}
+				})
+			}else {
+				$("#matchType li").each(function(){
+					var linum = $(this).attr("dataid");
+					$(this).removeClass("checked");
+					if(linum==n){
+						$(this).addClass("checked");
+					}
+				})
+			}
+			saveData();
+		}
+	</script>
+</head>
+<body class="seniorsetpage">
+	<div class="app-layout-header">
+		<span class="app-back jyapp-icon jyapp-icon-zuojiantou"></span>
+		推送设置
+	</div>
+	
+	<div class="app-layout-content-b">
+		<div class="header">
+			推送设置<span class="complate">完成</span>
+		</div>
+	
+		<div class="content" style="margin-top:0px;">
+			<div id="pushfrequency">
+				<ul class="navchoose">
+					<li><img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/pushfrequency.png">推送时间</li>
+					<li onclick="docheck('1',this)" dataid="1">
+						实时推送
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/checked.png" class="checked-img">
+						<span>8点-20点实时推送</span>
+					</li>
+					<li onclick="docheck('2',this)" dataid="2">
+						每日推送
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/checked.png" class="checked-img">
+						<span>上午9点推送一次</span>
+					</li>
+					<li onclick="docheck('3',this)" dataid="3">
+						每周推送
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/checked.png" class="checked-img">
+						<span>每周五上午9点推送一次</span>
+					</li>
+					<li onclick="docheck('4',this)" dataid="4">
+						每月推送
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/checked.png" class="checked-img">
+						<span>每月28日上午9点推送一次</span>
+					</li>
+				</ul>
+			</div>
+			<div id="pushway">
+				<ul class="navchoose">
+					<li><img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/pushway.png">推送方式</li>
+					<li id="wxtip">
+						APP提醒
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/turn-on.png" class="turn-on">
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/turn-off.png" class="turn-off">
+					</li>
+					<li id="emailtip">
+						邮件提醒
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/turn-on.png" class="turn-on">
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/turn-off.png" class="turn-off">
+						<div class="emailset">
+							<span></span>
+							<img src="{{Msg "seo" "cdn"}}/jyapp/images/wx/editemail.png">
+						</div>
+					</li>
+				</ul>
+			</div>
+			<div id="matchType">
+				<ul class="navchoose">
+					<li><img src="{{Msg "seo" "cdn"}}/jyapp/vipsubscribe/image/matchType.png">关键词匹配方式</li>
+					<li onclick="docheck('5',this)" dataid="5">
+						按标题匹配
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/checked.png" class="checked-img">
+					</li>
+					<li onclick="docheck('6',this)" dataid="6">
+						按全文匹配
+						<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/checked.png" class="checked-img">
+						<span>会产生无效信息,请根据需要选择</span>
+					</li>
+				</ul>
+			</div>
+			<!--2.9.0暂无 推送结果预览-->
+			<div class="onenavbar" id="resultpreview" style="display:none">	 
+				<img src="{{Msg "seo" "cdn"}}/jyapp/images/wxkeyset/resultpreview.png" class="img-left">
+				推送结果预览
+				<img src="{{Msg "seo" "cdn"}}/jyapp/wxswordfish/images/right.png" class="img-right">
+			</div>
+		</div>
+		<div class="easypopup" id="emailSetModal">
+			<div class="easypopup-edit">
+				<div class="easypopup-header">设置邮件地址</div>
+				<div class="easypopup-content">
+					<input type="text" id="email" placeholder="邮件地址" class="form-control"/>
+					<div class="error hide">您输入的邮箱不正确,请重新输入</div>
+				</div>
+				<div class="easypopup-footer">
+					<span onclick="emailSetModal.hide();">取消</span>
+					<span id="sure">确定</span>
+				</div>
+			</div>
+		</div>
+		<div class="easyalert easyalert-icon" id="setSuccess">
+			<img src='{{Msg "seo" "cdn"}}/jyapp/images/set-right.png' style='width: 49px;margin-bottom: 15px;margin-top: 25px;'><br>设置成功
+		</div>
+	</div>
+	{{include "/common/baiducc.html"}}
+</body>
+</html>

+ 469 - 160
src/jfw/modules/app/src/web/templates/weixin/historypush.html

@@ -53,7 +53,7 @@
         if (getUrlParam("f") == "push") {
             removeSessionStorage();
             if (history) {
-                history.replaceState(null, null, "/jyapp/swordfish/historypush");
+              history.replaceState(null, null, "/jyapp/swordfish/historypush");
             }
         }
         $(function () {
@@ -79,8 +79,6 @@
             }
         });
 
-        var words = ""
-        var isInTSguide = false;//订阅向导
         var firstTime = {{.T.selectTime}};
         var userId = "";
         var selectCity = "";
@@ -102,6 +100,7 @@
         }
 
         function initpage() {
+            var thisClass=this;
             FastClick.attach(document.body);
             $("#openmailpush").click(function () {
                 setSessionStorage();
@@ -110,36 +109,20 @@
             $(".listcontent").scroll(function () {
                 scrollTop = $(this).scrollTop();
             });
+            this.isCanSwitch=true;
             this.InitPersonal=function(r){
               $("#sub_manager").click(tokeyset);
               $(".tab_left .area").hide();
               $(".vip_banner").show();
               if (r.isPassCount) {
-                  $(".open_remind").show();
+                $(".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';
-                  }
+              if (r.isExpire < 0 && r.vipStatus == -1) {
+                if (localStorage.getItem("nv_vip_" + userId) == null) {
+                  $(".nv_renew_toast").show();
+                }
               }
+              thisClass.LoadDatas(r);
             }
             this.InitVip=function(r){
               $("#sub_manager").click(tosetpage);
@@ -152,7 +135,7 @@
                         weuiDialog();
                     }
                 }
-                if (r.isOnTail != 1) {
+                if (r.vipStatus != 1) {
                     if (r.isExpire > 1) {
                         $(".renew_toast .isExpire").text(r.isExpire);
                         $(".renew_toast").show();
@@ -173,30 +156,212 @@
                 }
                 $.post("/subscribepay/report/tip?t=" + new Date().getTime(), null, function (r) {
                     if (r.unread > 0) {
-                        $(".vip_report>a").show();
+                      $(".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);
-                        });
+                      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";
+                  setSessionStorage();
+                  window.location.href = "/vipreport/page/subreport.html";
                 });
+                thisClass.LoadDatas(r);
+            }
+            this.InitEnt=function(r){
+              if(r.reLoad){
+                removeSessionStorage();
+              }
+              $(".tab_left .area").show();
+              $.post("/entniche/ent/entinfo?t="+new Date().getTime(),null,function(rr){
+                $("#sub_manager").click(function(){
+                  setSessionStorage();
+                  if(rr.data.admin_system){
+                    window.location.href='/page_entniche/page/sub_management/sub_management_system.html';
+                  }else if(rr.data.admin_department){
+                    window.location.href='/page_entniche/page/sub_management/sub_management_department.html';
+                  }else{
+                    window.location.href='/page_entniche/page/subsetting/sub_entrance.html';
+                  }
+                });
+                if(rr.data.admin_system && rr.data.ent_model==0){
+                  thisClass.EntSelectModel(r.entFirst);
+                  $("#loading").hide();
+                  return;
+                }else if(rr.data.admin_system && r.entFirst){
+                  thisClass.EntAdminFirst(true);
+                  $("#loading").hide();
+                  return;
+                }else if(rr.data.admin_department && r.entFirst){
+                  $(".ent-first,.ent-first-dept").show();
+                  $("#loading").hide();
+                  return;
+                }
+                thisClass.LoadDatas(r);
+              });
+            }
+            this.EntAdminFirst=function(entFirst){
+              $(".ent-first,.ent-first-admin").show();
+              if(!entFirst){
+                return;
+              }
+              $(".switch-mask").show();
+              $(".switch-mask .switch-mask-gotit").click(function(e){
+                $.post("/entniche/ent/gotit",null,function(r){
+                  if (r.error_code == 0 && r.data.status == 1) {
+                    $(".switch-mask").hide();
+                  }
+                })
+                e.stopPropagation();
+              });
+              $(".switch-mask").click(function(e){
+                e.stopPropagation();
+              });
+            }
+            this.EntSelectModel=function(entFirst){
+              thisClass.isCanSwitch=false;
+              $("#sub_manager").hide();
+              $(".ent-model").show();
+              $(".ent-model-item").click(function(){
+                $(".ent-model-item").removeClass("ent-model-active");
+                $(this).addClass("ent-model-active");
+                $(this).find(".ent-model-checkbox").prop("checked",true);
+              });
+              $(".ent-model-button").click(function(){
+                $.post("/entniche/ent/setmodel",{model:$(".ent-model-active").index()+1},function(r){
+                  if (r.error_code == 0 && r.data.status == 1) {
+                    thisClass.isCanSwitch=true;
+                    $("#sub_manager").show();
+                    $(".ent-model").hide();
+                    thisClass.EntAdminFirst(entFirst);
+                  }
+                });
+              });
+            }
+            this.LoadDatas=function(r){
+              $(".app-content").css("display","flex");
+              if(r.reLoad){
+                removeSessionStorage();
+              }
+              if (sessionStorage && sessionStorage.historypushScrollTop && sessionStorage.historypushDataCache) {
+                  if (sessionStorage.closeAdvert == "true") {
+                      closeAdvert = true;
+                  }
+                  pageIndex = sessionStorage.historypushPageIndexCache;
+                  hasNextPage = sessionStorage.historypushHasNextPage == "true" ? true : false;
+                  scrollTop = sessionStorage.historypushScrollTop;
+                  dataCache = JSON.parse(sessionStorage.historypushDataCache);
+                  userId = sessionStorage.userId;
+                  firstTime = sessionStorage.getItem(userId + "_searchTime");
+                  selectCity = sessionStorage.getItem(userId + "_selectCity");
+                  $("#list>*").remove();
+                  firstPage = dataCache;
+                  if (dataCache.length == 0) {
+                      hasNoData();
+                  } else {
+                      structureHtml(dataCache, true);
+                  }
+                  //appendList($(listCache),$(tableCache));
+                  $(".listcontent").scrollTop(scrollTop);
+                  removeSessionStorage();
+                  showPage();
+              } else {
+                  userId = sessionStorage.userId;
+                  if (window.location.href.indexOf("selectTime") < 0 && sessionStorage.getItem(userId + "_searchTime") != null && sessionStorage.getItem(userId + "_searchTime") != "") {
+                      firstTime = sessionStorage.getItem(userId + "_searchTime");
+                  }
+                  if (sessionStorage.getItem(userId + "_selectCity") != null && sessionStorage.getItem(userId + "_selectCity") != "") {
+                      selectCity = sessionStorage.getItem(userId + "_selectCity");
+                  }
+                  $.ajax({
+                      type: 'post',
+                      url: '/jyapp/front/hasPushHistory?t=' + new Date().getTime(),
+                      data: {"selectTime": firstTime, "pageNum": 1, "area": selectCity},
+                      async: false,
+                      dataType: 'json',
+                      success: function (data) {
+                        firstPage = data.data;
+                        if (r.userType=="" && !firstPage.length > 0 && !r.haskey) {
+                          (function() { 
+                            if (sessionStorage && (sessionStorage.keysetindexToHistory == "1" || sessionStorage.keysetindexToHistory == "2" || sessionStorage.keysetindexToHistory == "3")) {
+                              sessionStorage.removeItem("keysetindexToHistory");
+                              return
+                            }
+                            if (firstTime != "") {
+                              return
+                            }
+                            history.pushState({}, "", "");
+                            window.location.href = '/jyapp/wxkeyset/keyset/index';
+                          })();
+                        }
+                        pageIndex = 2;
+                        lasttime = data.thistime;
+                        hasNextPage = data.hasNextPage;
+                        userId = data.userId;
+                        sessionStorage.userId = userId;
+                        sessionStorage.setItem(userId + "_searchTime", firstTime);
+                        showPage();
+                      },
+                      error: function (xhr, type) {
+                          hasNoData();
+                      }
+                  });
+                  if (firstPage.length == 0) {
+                      //sessionStorage.removeItem("search_starttime");
+                      sessionStorage.removeItem(sessionStorage.userId + "_searchTime");
+                      hasNoData();
+                      return;
+                  }
+                  $(".findnull_").hide();
+                  dataCache = dataCache.concat(firstPage);
+                  structureHtml(firstPage, true);
+                  setTimeout(function () {
+                      $(".listcontent").scrollTop(0);
+                      //$("#list").css("visibility","visible");
+                  }, 300);
+              }
+              if (hasNextPage) {
+                  setTimeout(function () {
+                      wxflag = $('.listcontent').dropload({
+                          scrollArea: $(".listcontent"),
+                          loadUpFn: function (me) {
+                              //loadDatas(me,-1);
+                              reloadFirstPage(me);//下拉刷新更新订阅词
+                          },
+                          loadDownFn: function (me) {
+                              loadDatas(me, lasttime);
+                          }
+                      });
+                  }, 1000);
+              } else {
+                  setTimeout(function () {
+                      wxflag = $('.listcontent').dropload({
+                          scrollArea: $(".listcontent"),
+                          loadUpFn: function (me) {
+                              loadDatas(me, -1);
+                          },
+                          loadDownFn: function (me) {
+                              loadDatas(me, lasttime);
+                          }
+                      });
+                      noMoreData(wxflag);
+                  }, 1000);
+              }
             }
-            var thisClass = this;
+            //
             $.post("/jyapp/myinfo?t="+new Date().getTime(),null,function(r){
               if(r.hasEnt){
                 if(r.userType=="vip"){
@@ -206,24 +371,17 @@
                 }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';
-                      }
-                    });
-                  });
+                  thisClass.InitEnt(r);
                 }else{
                   $(".switch").addClass("switch-personal");
                   $(".switch>span").text("标讯订阅(个人版)");
                   thisClass.InitPersonal(r);
                 }
                 $(".switch").click(function(){
+                  if(!thisClass.isCanSwitch){
+                    return;
+                  }
+                  setSessionStorage();
                   window.location.href='/page_entniche/page/sub_mode/switch_mode.html';
                 });
               }else{
@@ -240,98 +398,6 @@
                 }
               }
             });
-            //
-            if (sessionStorage && sessionStorage.historypushScrollTop && sessionStorage.historypushDataCache) {
-                if (sessionStorage.closeAdvert == "true") {
-                    closeAdvert = true;
-                }
-                pageIndex = sessionStorage.historypushPageIndexCache;
-                hasNextPage = sessionStorage.historypushHasNextPage == "true" ? true : false;
-                scrollTop = sessionStorage.historypushScrollTop;
-                dataCache = JSON.parse(sessionStorage.historypushDataCache);
-                userId = sessionStorage.userId;
-                firstTime = sessionStorage.getItem(userId + "_searchTime");
-                selectCity = sessionStorage.getItem(userId + "_selectCity");
-                $("#list>*").remove();
-                firstPage = dataCache;
-                if (dataCache.length == 0) {
-                    hasNoData();
-                } else {
-                    structureHtml(dataCache, true);
-                }
-                //appendList($(listCache),$(tableCache));
-                $(".listcontent").scrollTop(scrollTop);
-                removeSessionStorage();
-                showPage();
-            } else {
-                userId = sessionStorage.userId;
-                if (window.location.href.indexOf("selectTime") < 0 && sessionStorage.getItem(userId + "_searchTime") != null && sessionStorage.getItem(userId + "_searchTime") != "") {
-                    firstTime = sessionStorage.getItem(userId + "_searchTime");
-                }
-                if (sessionStorage.getItem(userId + "_selectCity") != null && sessionStorage.getItem(userId + "_selectCity") != "") {
-                    selectCity = sessionStorage.getItem(userId + "_selectCity");
-                }
-                $.ajax({
-                    type: 'post',
-                    url: '/jyapp/front/hasPushHistory?t=' + new Date().getTime(),
-                    data: {"selectTime": firstTime, "pageNum": 1, "area": selectCity},
-                    async: false,
-                    dataType: 'json',
-                    success: function (data) {
-                        pageIndex = 2;
-                        lasttime = data.thistime;
-                        firstPage = data.data;
-                        hasNextPage = data.hasNextPage;
-                        userId = data.userId;
-                        sessionStorage.userId = userId;
-                        sessionStorage.setItem(userId + "_searchTime", firstTime);
-                        showPage();
-                    },
-                    error: function (xhr, type) {
-                        hasNoData();
-                    }
-                });
-                if (firstPage.length == 0) {
-                    //sessionStorage.removeItem("search_starttime");
-                    sessionStorage.removeItem(sessionStorage.userId + "_searchTime");
-                    hasNoData();
-                    return;
-                }
-                $(".findnull_").hide();
-                dataCache = dataCache.concat(firstPage);
-                structureHtml(firstPage, true);
-                setTimeout(function () {
-                    $(".listcontent").scrollTop(0);
-                    //$("#list").css("visibility","visible");
-                }, 300);
-            }
-            if (hasNextPage) {
-                setTimeout(function () {
-                    wxflag = $('.listcontent').dropload({
-                        scrollArea: $(".listcontent"),
-                        loadUpFn: function (me) {
-                            //loadDatas(me,-1);
-                            reloadFirstPage(me);//下拉刷新更新订阅词
-                        },
-                        loadDownFn: function (me) {
-                            loadDatas(me, lasttime);
-                        }
-                    });
-                }, 1000);
-            } else {
-                setTimeout(function () {
-                    wxflag = $('.listcontent').dropload({
-                        scrollArea: $(".listcontent"),
-                        loadUpFn: function (me) {
-                            loadDatas(me, -1);
-                        },
-                        loadDownFn: function (me) {
-                            loadDatas(me, lasttime);
-                        }
-                    });
-                    noMoreData(wxflag);
-                }, 1000);
-            }
         }
 
         //页面渲染处理
@@ -342,7 +408,6 @@
                 date = formatDate(firstTime / 1000, "1");
                 $('#showDatePicker .time_result').html(_formatDate).addClass('current');
             }
-            $(".tab_left .time").show();
             //地区渲染
             mapData();
         }
@@ -452,8 +517,8 @@
                 //标题(需要高亮)
                 var title = obj.title;
                 var mWords = "";
-                var _words = words;
-                if (obj.matchkeys != undefined && obj.matchkeys != null && obj.matchkeys != "") {
+                var _words = "";
+                if (obj.matchkeys != undefined && obj.matchkeys != null) {
                     _words = obj.matchkeys;
                 }
                 if (_words != null && _words.length > 0) {
@@ -646,7 +711,6 @@
                 sessionStorage.historypushDataCache = JSON.stringify(dataCache);
                 sessionStorage.historypushPageIndexCache = pageIndex;
                 sessionStorage.historypushHasNextPage = hasNextPage;
-                sessionStorage.historypushCount = count;
             }
         }
 
@@ -655,7 +719,6 @@
             sessionStorage.removeItem("historypushPageIndexCache");
             sessionStorage.removeItem("historypushScrollTop");
             sessionStorage.removeItem("historypushHasNextPage");
-            sessionStorage.removeItem("historypushCount");
             sessionStorage.removeItem("closeAdvert");
         }
 
@@ -691,7 +754,6 @@
                     lasttime = data.thistime;
                     firstPage = data.data;
                     hasNextPage = data.hasNextPage;
-                    words = data.keys;
                     userId = data.userId;
                     ajaxFlag = true;
                     if (time == undefined || time == "") {
@@ -710,18 +772,17 @@
                     hasNoData();
                 }
             });
+            dataCache = firstPage;
             if (firstPage.length == 0) {
                 if ($(".findnull").css("display") == "block") {
                     $(".findnull").css("display", "none");
                 }
-                dataCache = firstPage;
                 hasNoData();
                 return;
             } else {
                 $(".findnull_").css("display", "none");
             }
             //$("#list").css("visibility","hidden");
-            dataCache = firstPage;
             $("#list").html("");
             count = 0;
             structureHtml(firstPage, true);
@@ -975,7 +1036,7 @@
         }
 
         .app-content {
-            display: flex;
+            display: none;
             justify-content: space-between;
             flex-direction: column;
             overflow: hidden;
@@ -1016,6 +1077,9 @@
           display: flex;
           padding: 0px 10px;
         }
+        .app-layout-header>ul>li:nth-child(2)>img{
+          position: absolute;
+        }
         .app-layout-header>ul>li:last-child{
           font-size: 15px;
           align-self: center;
@@ -1029,6 +1093,7 @@
           padding: 0px 10px;
           border-radius: 24px;
           display: flex;
+          position: relative;
         }
         .app-layout-header .switch>span{
           max-width: 2.5rem;
@@ -1093,7 +1158,194 @@
         }
         .tab_right{
           position: relative;
-          
+        }
+        .switch-mask{
+          display: none;
+        }
+        .switch-mask-main{
+          position: absolute;
+          top: -5px;
+          left: -5px;
+          right: -5px;
+          bottom: -5px;
+          border-radius: 100px;
+          box-shadow: 0 0 0 2000px rgba(0,0,0,.7);
+        }
+        .switch-mask-star-1{
+          position: absolute;
+          top: -16px;
+          left: -20px;
+          width: 10px;
+          z-index: 1;
+        }
+        .switch-mask-star-2{
+          position: absolute;
+          top: -7px;
+          left: -12px;
+          width: 5px;
+          z-index: 1;
+        }
+        .switch-mask-border{
+          position: absolute;
+          top: -9px;
+          left: -9px;
+          right: -9px;
+          bottom: -9px;
+          border-radius: 100px;
+          z-index: 1px;
+          border: 1px dashed rgba(255, 255, 255, 0.5);
+          z-index: 1;
+        }
+        .switch-mask .switch-mask-text{
+          position: absolute;
+          top: 70px;
+          left: 50%;
+          margin-left: 20px;
+        }
+        .switch-mask .switch-mask-line{
+          position: absolute;
+          left: 50%;
+          top: 35px;
+          margin-left: -9px;
+        }
+        .switch-mask .switch-mask-gotit{
+          position: absolute;
+          top: 130px;
+          left: 50%;
+          margin-left: 20px;
+          line-height: 32px;
+          width: 90px;
+          border-radius: 100px;
+          color: #fff;
+          font-size: 15px;
+          border: 1px solid #FFFFFF;
+        }
+        .switch-mask-prevent{
+          position: fixed;
+          top: 0px;
+          bottom:0px;
+          right: 0px;
+          left: 0px;
+        }
+        .ent-model{
+          color: #171826;
+          padding-left: 0.32rem;
+          padding-right: 0.32rem;
+          display: none;
+        }
+        .ent-model>div:first-child{
+          padding: .32rem 0;
+        }
+        .ent-model-item{
+          display: flex;
+          align-items: center;
+          justify-content: space-between;
+          margin-bottom: .24rem;
+          padding: 0 .4rem;
+          height: 2.4rem;
+          background-color: #F5F6F7;
+          border-radius: .16rem;
+        }
+        .ent-model-active {
+          background-color: #2ABED1 !important;
+        }
+        .ent-model>div:nth-child(2){
+          color: #9B9CA3;
+          font-size: .24rem;
+          line-height: .36rem;
+        }
+        .ent-model>div:nth-child(2)>p{
+          margin-bottom: .16rem;
+          font-size: .26rem;
+          line-height: .4rem;
+        }
+        .ent-model>div:nth-child(2)>div>span{
+          margin-bottom: .16rem;
+          font-size: .26rem;
+          line-height: .4rem;
+        }
+        .ent-model>div:last-child{
+          display: flex;
+          flex-direction: column;
+          align-items: center;
+          justify-content: center;
+          background-color: #fff;
+          box-shadow: 0px -2px 8px rgba(54, 147, 179, 0.051);
+          margin-top: .5rem;
+        }
+        .ent-model>div:last-child>div:first-child{
+          margin: .24rem 0;
+          color: #2ABED1;
+          font-size: .28rem;
+          font-weight: 700;
+        }
+        .ent-model>div:last-child>div:last-child{
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+          width: 100%;
+          padding: 0.16rem 0.32rem 0.24rem;
+          background-color: #fff;
+        }
+        .ent-model-button{
+          flex: 1;
+          width: 100%;
+          height: 0.92rem;
+          font-size: 0.32rem;
+          border-radius: 0.16rem;
+          color: #fff;
+          background-color: #2cb7ca;
+        }
+        .ent-model-active{
+          color: #fff;
+        }
+        .ent-model-left{
+          margin-right: .1rem;
+        }
+        .ent-model-left>div:first-child{
+          margin-bottom: .1rem;
+          font-size: .4rem;
+          font-weight: 700;
+        }
+        .ent-model-left>div:last-child{
+          font-size: .28rem;
+        }
+        .ent-model-checkbox:checked {
+          border: 0;
+          background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHBSURBVHgBzZiPcYIwFIeDE7hB6QR1gzqCG2g3cAPtBLqBdoK6Ae0EXCd4bmA3+PW9JlxTJEJCgnx37xQSku9IyL9MeQIg558FxxPHnGNqQvjmOJv45DhlWXZWKWCRFUcBf0p5VsWCC5tzEPpDvcT44SnHDvGRMqe+Mjn0q04FQffFzjKE9FCrFHQzEYZDWuFf801qThuOXA3HzNR5DfRnfS/mlUdmCZEa9u3YnHkAfZQ/EyOzGkjmyPHWcD+HPUYh7SdesbXqOzakF1VijvRs7dfB1wdHvgdJXCMtdZnljbxryfCOccgIh1v9h6CbM3Qa8ZX5rVMyXtoKhB7Bfd5kiIxwUTcSCbW5hq/38JdZwAPVkk4NUlt0l5nB3QJOobYHqKNUbxmYJqMuGaWCWoX23HeMICOUrlHTxbKh4n0kGeEUMjA2LxdUlMXdOnTq2CSQEfKqsAL+7CLLlK4O6lUI9C4itM/YrMRlnAs0w4u6H6+Nd9FtaojN3qkJPYkOsXqsILTtYjGmjeKAUmVnmVrzpehTUqbfYUNNTMYoQn8I1oawN0YspMMX8DgXypQn+DvSe1Z6IJWwj/QkPji+VMCR3g//T7SIqLP6vQAAAABJRU5ErkJggg==) no-repeat center center;
+          background-size: 100% 100%;
+        }
+        .ent-model-checkbox {
+          width: 0.4rem;
+          height: 0.4rem;
+          border: 1px solid #ddd;
+          border-radius: 50%;
+          margin-right: 0.2rem;
+          -webkit-appearance: none;
+          background: #fff;
+        }
+        .ent-first{
+          padding: 30% .5rem 0px .5rem;
+          display: none;
+        }
+        .ent-first>div:first-child{
+          font-size: 18px;
+          text-align: center;
+          color: #171826;
+          margin-bottom: 20px;
+        }
+        .ent-first-admin{
+          display: none;
+        }
+        .ent-first-admin>span{
+          font-size: 13px;
+          color: #5F5E64;
+          display: block;
+          margin-bottom: 5px;
+        }
+        .ent-first-dept{
+          display: none;
+          text-align: center;
         }
     </style>
 </head>
@@ -1108,7 +1360,22 @@
 <div class="app-layout-header">
   <ul>
     <li>订阅</li>
-    <li><div class="switch"><span></div></span></li>
+    <li>
+      <div class="switch">
+        <div class="switch-mask">
+          <a class="switch-mask-prevent"></a>
+          <img src="/jyapp/images/switch-star.png" class="switch-mask-star-1">
+          <img src="/jyapp/images/switch-star.png" class="switch-mask-star-2">
+          <a class="switch-mask-border"></a>
+          <div class="switch-mask-main">
+            <img src="/jyapp/images/switch-line.png" class="switch-mask-line">
+            <img src="/jyapp/images/switch-text.png" class="switch-mask-text">
+            <a class="switch-mask-gotit">知道了</a>
+          </div>
+        </div>
+        <span></span>
+      </div>
+    </li>
     <li id="sub_manager">订阅管理</li>
   </ul>
 </div>
@@ -1128,7 +1395,7 @@
             <!-- 筛选条件 -->
             <div class="filter_tab">
                 <div class="tab_left">
-                    <div class="time" style="display: none;">
+                    <div class="time">
                         <p class="time_box" id="showDatePicker">
                             <span class="time_result jymobile-tab-triangle">时间</span>
                         </p>
@@ -1224,6 +1491,48 @@
             </div>
         </div>
     </div>
+    <div class="ent-model">
+      <div>
+          <div class="ent-model-item ent-model-active">
+              <div class="ent-model-left">
+                  <div>统一订阅模式</div>
+                  <div>企业或部门统一订阅,统一分发给下属员工</div>
+              </div>
+              <input type="radio" class="ent-model-checkbox" checked=true>
+          </div>
+          <div class="ent-model-item">
+              <div class="ent-model-left">
+                  <div>个人订阅模式</div>
+                  <div>员工个人自行订阅</div>
+              </div>
+              <input type="radio" class="ent-model-checkbox">
+          </div>
+      </div>
+      <div>
+          <p>剑鱼标讯-企业商机管理欢迎您的使用,首次使用,请完成以下操作:</p>
+          <div>
+              <p>1.选择订阅模式;</p>
+              <p>2.进入企业框架,添加部门和员工;</p>
+              <p>3.进入订阅管理,设置标讯订阅条件和分发规则。</p>
+          </div>
+      </div>
+      <div>
+          <!--<div>附加说明</div>-->
+          <div>
+              <button class="ent-model-button">确认</button>
+          </div>
+      </div>
+    </div>
+    <div class="ent-first">
+      <div>剑鱼标讯-企业商机管理欢迎您的使用<br>请继续完成以下操作:</div>
+      <div class="ent-first-admin">
+        <span>1.进入企业框架,添加部门和员工;</span>
+        <span>2.进入订阅管理,设置标讯订阅条件和分发规则。</span>
+      </div>
+      <div class="ent-first-dept">
+        <span>进入订阅管理,设置标讯订阅条件和分发规则。</span>
+      </div>
+    </div>
 </div>
 <div class="vip_report_tip">
     <div class="weui-mask weui-animate-fade-in"></div>

+ 2 - 2
src/jfw/modules/entniche/src/config.json

@@ -1,8 +1,8 @@
 {
-	"webPort": "811",
+	"webPort": "812",
 	"mongodb":{
 		"address":"127.0.0.1:27080",
-		"size":5,
+		"size":2,
 		"dbName":"qfw"
 	},
     "redisAddrs": "other=127.0.0.1:1712,session=127.0.0.1:1712",

+ 2 - 2
src/jfw/modules/entniche/src/entity/department.go

@@ -109,12 +109,12 @@ func (d *Department) GetChildrens(ent_id, dept_id int) *[]*Department {
 
 //新增的时候,判断部门是否存在
 func (d *Department) AddIsExists(name string, ent_id int) bool {
-	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=?`, name, ent_id) > 0
+	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=? and pid<>0`, name, ent_id) > 0
 }
 
 //修改的时候,判断部门是否存在
 func (d *Department) UpdateIsExists(name string, ent_id, dept_id int) bool {
-	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=? and id<>?`, name, ent_id, dept_id) > 0
+	return Mysql.CountBySql(`select count(1) from entniche_department where name=? and ent_id=? and id<>? and pid<>0`, name, ent_id, dept_id) > 0
 }
 
 //删除部门

+ 23 - 17
src/jfw/modules/entniche/src/entity/entity.go

@@ -86,26 +86,32 @@ func (c *CurrentUser) EntInfo(userId string, entId int) *CurrentUser {
 	if phone == "" {
 		return currentUser
 	}
-	//角色、权限
-	r := Mysql.SelectBySql(`SELECT b.role_id,c.dept_id,d.name as dept_name,d.subdis as dept_subdis from entniche_user a 
-		LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
-		LEFT JOIN entniche_department_user c on (a.id=c.user_id) 
-		LEFT JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
-		where a.ent_id=? and a.phone=? order by a.id desc`, entId, entId, phone)
-	if r == nil || len(*r) == 0 {
-		return currentUser
-	}
-	role_id := qutil.IntAll((*r)[0]["role_id"])
-	if role_id == Role_admin_department {
-		currentUser.Role_admin_department = true
-	}
-	currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
-	currentUser.Dept.Name = (*r)[0]["dept_name"].(string)
-	currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
-	//
 	currentUser.Ent = VarEntInfo.GetById(entId)
 	if currentUser.Ent.Phone == phone {
 		currentUser.Role_admin_system = true
+		r := Mysql.SelectBySql(`SELECT id,name,subdis from entniche_department where ent_id=? and pid=0`, entId)
+		if r != nil && len(*r) > 0 {
+			department := JsonUnmarshal((*r)[0], &Department{}).(*Department)
+			if department != nil {
+				currentUser.Dept = department
+			}
+		}
+	} else {
+		//角色、权限
+		r := Mysql.SelectBySql(`SELECT b.role_id,c.dept_id,d.name as dept_name,d.subdis as dept_subdis from entniche_user a 
+			LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
+			LEFT JOIN entniche_department_user c on (a.id=c.user_id) 
+			LEFT JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
+			where a.ent_id=? and a.phone=? order by a.id desc`, entId, entId, phone)
+		if r != nil && len(*r) > 0 {
+			role_id := qutil.IntAll((*r)[0]["role_id"])
+			if role_id == Role_admin_department {
+				currentUser.Role_admin_department = true
+			}
+			currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
+			currentUser.Dept.Name = (*r)[0]["dept_name"].(string)
+			currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
+		}
 	}
 	return currentUser
 }

+ 1 - 3
src/jfw/modules/entniche/src/filter/sessionfilter.go

@@ -17,9 +17,7 @@ type sessionfilter struct {
 //继承过滤器方法
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	session := l.App.SessionManager.Session(req, w)
-	session.Set("userId", "5d6e142a25ef871f08a72662")
-	session.Set("entId", 4)
-	session.Set("entName", "王公子测试企业")
+	//session.Set("userId", "5d6e142a25ef871f08a72662")
 	if session.Get("userId") == nil {
 		content, _ := json.MarshalIndent(map[string]interface{}{
 			"error_code": Error_code_1001,

+ 22 - 12
src/jfw/modules/entniche/src/service/buy/buy.go

@@ -43,14 +43,14 @@ func (a *Action) SendIdentCode() {
 
 //是否支付成功
 func (a *Action) IsPaySuccess() {
-	if !R.CheckReqParam(a.Action, "code") {
+	if !R.CheckReqParam(a.Action, "ordercode") {
 		return
 	}
-	code := a.GetString("code")
+	ordercode := a.GetString("ordercode")
 	userId, _ := a.GetSession("userId").(string)
-	if code != "" || userId != "" {
+	if ordercode != "" || userId != "" {
 		data := Mysql.FindOne(Dataexport_order, map[string]interface{}{
-			"order_code": code,
+			"order_code": ordercode,
 			"user_id":    userId,
 		}, "order_status,pay_time,pay_way,pay_money,filter_id,filter", "")
 		if data != nil && util.IntAll((*data)["order_status"]) == 1 {
@@ -58,16 +58,26 @@ func (a *Action) IsPaySuccess() {
 			if strings.Contains(util.ObjToString((*data)["pay_way"]), "ali") {
 				pay_way = "支付宝"
 			}
-			a.SetSession("entId", util.IntAll((*data)["filter_id"]))
-			filter := map[string]interface{}{}
-			JsonUnmarshal((*data)["filter"], &filter)
-			a.SetSession("entName", util.ObjToString(filter["entname"]))
+			isadmin := 0
+			filter := JsonUnmarshal(util.ObjToString((*data)["filter"]), map[string]interface{}{}).(map[string]interface{})
+			if filter != nil {
+				if phone := VarCurrentUser.Phone(userId); phone != "" && phone == util.ObjToString(filter["phone"]) {
+					isadmin = 1
+					filter_id := util.IntAll((*data)["filter_id"])
+					entname, _ := filter["entname"].(string)
+					a.SetSession("selectEntId", filter_id)
+					a.SetSession("selectEntName", entname)
+					a.SetSession("entId", filter_id)
+					a.SetSession("entName", entname)
+				}
+			}
 			a.ServeJson(Result{
 				Data: M{
 					"status":   1,
 					"paytime":  util.ObjToString((*data)["pay_time"]),
 					"paymoney": util.Float64All((*data)["pay_money"]) / 100,
 					"payway":   pay_way,
+					"isadmin":  isadmin,
 				},
 			})
 		}
@@ -76,15 +86,15 @@ func (a *Action) IsPaySuccess() {
 }
 
 func (a *Action) GetOrderInfo() {
-	code := a.GetString("code") //订单编号
-	id := a.GetString("id")     //企业id
+	ordercode := a.GetString("ordercode") //订单编号
+	id := a.GetString("id")               //企业id
 	userId, _ := a.GetSession("userId").(string)
 	data := map[string]interface{}{}
 	res := map[string]interface{}{}
 	if userId != "" {
-		if code != "" {
+		if ordercode != "" {
 			res = *Mysql.FindOne(Dataexport_order, map[string]interface{}{
-				"order_code": code,
+				"order_code": ordercode,
 				"user_id":    userId,
 			}, "filter", "")
 		} else if id != "" {

+ 3 - 3
src/jfw/modules/entniche/src/service/distribute/distribute.go

@@ -31,13 +31,13 @@ type Action struct {
 func (ac *Action) Distribute_list() {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
-
+	userinfo := VarCurrentUser.EntInfo(userId, ent_id)
 	queryMap := map[string]interface{}{
-		"s_userid": userId,
+		"i_deptid": userinfo.Dept.Id,
+		"i_entid":  ent_id,
 		"i_status": 0, //0未删除 1已删除
 	}
 	list := []map[string]interface{}{}
-	userinfo := VarCurrentUser.EntInfo(userId, ent_id)
 	res, _ := util.MQFW.Find(util.Entniche_distribute, queryMap, nil, `{"_id":1,"o_area":1,"a_buyerclass":1}`, false, -1, -1)
 	data := *util.Mysql.SelectBySql(`select a.nodiff,a.subdis from  entniche_department a INNER JOIN entniche_department_parent b where (a.ent_id=? and (a.id=? or b.pid=?)and a.id=b.id)`, ent_id, userinfo.Dept.Id, userinfo.Dept.Id)
 	var nodiff int64

+ 56 - 11
src/jfw/modules/entniche/src/service/ent/ent.go

@@ -15,20 +15,23 @@ type Action struct {
 	entinfo   xweb.Mapper `xweb:"/ent/entinfo"`   //企业信息
 	setmodel  xweb.Mapper `xweb:"/ent/setmodel"`  //订阅模式
 	selectent xweb.Mapper `xweb:"/ent/selectent"` //选择企业
+	framework xweb.Mapper `xweb:"/ent/framework"` //进入企业架构
+	gotit     xweb.Mapper `xweb:"/ent/gotit"`     //知道了
 }
 
 //当前登录用户的所在的企业
 func (a *Action) Myents() {
 	userId, _ := a.GetSession("userId").(string)
-	entId := qutil.IntAll(a.GetSession("entId"))
+	entId := qutil.IntAll(a.GetSession("selectEntId"))
 	phone := VarCurrentUser.Phone(userId)
 	if phone == "" {
 		R.NoPermissionReq(a.Action)
 		return
 	}
 	ents := []M{}
-	list := Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate from entniche_info a 
-				INNER JOIN entniche_user b on (a.id=b.ent_id) 
+	list := Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate,c.id as dept_id from entniche_info a 
+				LEFT JOIN entniche_user b on (a.id=b.ent_id) 
+				LEFT JOIN entniche_department c on (a.id=c.ent_id and c.pid=0) 
 				where a.phone=? or b.phone=? 
 				order by convert(a.name using gbk) COLLATE gbk_chinese_ci asc`, phone, phone)
 	if list != nil {
@@ -40,6 +43,7 @@ func (a *Action) Myents() {
 			ents = append(ents, M{
 				"name":         v["name"],
 				"id":           v["id"],
+				"dept_id":      v["dept_id"],
 				"startdate":    v["startdate"],
 				"enddate":      v["enddate"],
 				"admin_system": admin_system,
@@ -92,7 +96,7 @@ func (a *Action) Setmodel() {
 		R.InvalidReqParam(a.Action, "model")
 		return
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
+	entId := qutil.IntAll(a.GetSession("selectEntId"))
 	status := 0
 	if Mysql.UpdateOrDeleteBySql("update entniche_info set model=? where id=?", model, entId) > -1 {
 		status = 1
@@ -106,23 +110,64 @@ func (a *Action) Selectent() {
 		return
 	}
 	id, _ := a.GetInteger("id")
+	a.SetSession("prevSelectEntId", a.GetSession("selectEntId"))
 	if id == 0 {
+		a.DelSession("selectEntId")
+		a.DelSession("selectEntName")
 		a.DelSession("entId")
 		a.DelSession("entName")
 	} else {
 		userId, _ := a.GetSession("userId").(string)
-		phone := VarCurrentUser.Phone(userId)
-		if phone == "" {
-			R.NoPermissionReq(a.Action)
-			return
-		}
-		ent := Mysql.FindOne(Entniche_user, map[string]interface{}{"phone": phone, "ent_id": id}, "name", "")
+		ent := getSelectEnt(id, userId)
 		if ent == nil {
 			R.NoPermissionReq(a.Action)
 			return
 		}
+		a.SetSession("selectEntId", id)
+		a.SetSession("selectEntName", ent["name"])
 		a.SetSession("entId", id)
-		a.SetSession("entName", (*ent)["name"])
+		a.SetSession("entName", ent["name"])
+	}
+	a.ServeJson(Result{Data: M{"status": 1}})
+}
+
+//切换所在的企业
+func (a *Action) Framework() {
+	if !R.CheckReqParam(a.Action, "id") {
+		return
+	}
+	id, _ := a.GetInteger("id")
+	userId, _ := a.GetSession("userId").(string)
+	ent := getSelectEnt(id, userId)
+	if ent == nil {
+		R.NoPermissionReq(a.Action)
+		return
 	}
+	a.SetSession("entId", id)
+	a.SetSession("entName", ent["name"])
 	a.ServeJson(Result{Data: M{"status": 1}})
 }
+func getSelectEnt(id int, userId string) map[string]interface{} {
+	phone := VarCurrentUser.Phone(userId)
+	if phone == "" {
+		return nil
+	}
+	ents := Mysql.SelectBySql(`SELECT DISTINCT a.name from entniche_info a 
+			LEFT JOIN entniche_user b on (a.id=b.ent_id) where a.id=? and (a.phone=? or b.phone=?) limit 1`, id, phone, phone)
+	if ents == nil || len(*ents) == 0 {
+		return nil
+	}
+	return (*ents)[0]
+}
+func (a *Action) Gotit() {
+	userId, _ := a.GetSession("userId").(string)
+	status := 0
+	if MQFW.UpdateById("user", userId, map[string]interface{}{
+		"$set": map[string]interface{}{
+			"i_entniche_first": 1,
+		},
+	}) {
+		status = 1
+	}
+	a.ServeJson(Result{Data: M{"status": status}})
+}

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

@@ -62,7 +62,7 @@ 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 {
+	if Mysql.CountBySql("select count(1) as count from entniche_info where phone=?", phone) > 0 {
 		status = 1
 	}
 	a.ServeJson(Result{Data: M{"status": status}})

+ 64 - 13
src/jfw/modules/entniche/src/service/subscribe/subscribe.go

@@ -36,7 +36,8 @@ type Action struct {
 
 func (ac *Action) Subscribe_index() error {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entInfo := VarCurrentUser.EntInfo(userId, entId)
 	subscribe := map[string]interface{}{}
 	result := map[string]interface{}{
 		"model":  entInfo.Ent.Model,
@@ -47,12 +48,12 @@ func (ac *Action) Subscribe_index() error {
 	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")),
+			"i_entid":  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")),
+			"i_entid":  entId,
 		})
 	}
 	//
@@ -81,7 +82,11 @@ func (ac *Action) Subscribe_index() error {
 	}
 	result["subscribe"] = subscribe
 	//已设置的规则条数
-	count := util.MQFW.Count(util.Entniche_distribute, `{"s_userid":`+userId+`,"i_status":0}`)
+	count := util.MQFW.Count(util.Entniche_distribute, map[string]interface{}{
+		"i_status": 0,
+		"i_deptid": entInfo.Dept.Id,
+		"i_entid":  entId,
+	})
 	result["distribute"] = map[string]interface{}{
 		"count": count,
 	}
@@ -319,7 +324,7 @@ func (ac *Action) Get_key() {
 			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
 		})
 	}
-	if len(*res_) == 0 || res_ == nil {
+	if res_ == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
@@ -371,8 +376,12 @@ func (ac *Action) Get_key() {
 //关键词
 func (ac *Action) Update_key() {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entInfo := VarCurrentUser.EntInfo(userId, entId)
+	//userId = "5d6e142a25ef871f08a72662"
 	status := 0 //0:失败,1:成功,-1:分类名重复,-2:关联有分发规则,不能删除
 	keywords := map[string]interface{}{}
+	distribute_item_map := map[string]interface{}{} //用来计算规则顺序
 	getkeywords := ac.Body()
 	if len(getkeywords) > 0 {
 		err := json.Unmarshal(getkeywords, &keywords)
@@ -400,7 +409,9 @@ func (ac *Action) Update_key() {
 			//分类名有分发规则
 			distribute_items := []string{}
 			list_items, _ := util.MQFW.Find(util.Entniche_distribute, map[string]interface{}{
-				"s_userid": userId,
+				"i_deptid": entInfo.Dept.Id,
+				"i_entid":  entId,
+				"i_status": 0,
 			}, nil, nil, false, -1, -1)
 			if len(*list_items) > 0 {
 				for _, n := range *list_items {
@@ -409,13 +420,41 @@ func (ac *Action) Update_key() {
 							distribute_items = append(distribute_items, qutil.ObjToString(y))
 						}
 					}
+					id := qutil.BsonIdToSId(n["_id"])
+					distribute_item_map[id] = n["a_items"].([]interface{})
 				}
 			}
-			isEqual := isEqualValue(new_item, deleteRepeat(distribute_items)) //查看分发规则库中是否有规则
-			if isEqual {
-				status = -2
-				ac.ServeJson(Result{Data: M{"status": status}})
-				return
+			//isEqual := isEqualValue(new_item, deleteRepeat(distribute_items))
+			if keywords["delete_item"] != nil {
+				delete_item := qutil.ObjToString(keywords["delete_item"].(interface{})) //查看分发规则库中是否有被删除的规则
+				if delete_item != "" {
+					isEqual := IsContain(deleteRepeat(distribute_items), delete_item)
+					if isEqual {
+						status = -2
+						ac.ServeJson(Result{Data: M{"status": status}})
+						return
+					}
+				}
+			}
+
+			//修改了分类名更改规则中该分类名
+			if keywords["update_item"] != nil {
+				update_item := keywords["update_item"].(map[string]interface{})
+				log.Println(update_item["before"])
+				for x, y := range distribute_item_map {
+					dis_item := qutil.ObjArrToStringArr(y.([]interface{}))
+					if IsContain(dis_item, qutil.ObjToString(update_item["before"])) {
+						dis_item = ReplaceValues(dis_item, qutil.ObjToString(update_item["before"]), qutil.ObjToString(update_item["after"]))
+						if util.MQFW.UpdateById(util.Entniche_distribute, x, bson.M{
+							"$set": bson.M{"a_items": dis_item},
+						}) {
+							status = -1
+							ac.ServeJson(Result{Data: M{"status": status}})
+							return
+						}
+
+					}
+				}
 			}
 		}
 
@@ -466,7 +505,7 @@ func (ac *Action) Get_fastimport() {
 			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
 		})
 	}
-	if len(*res_) == 0 || res_ == nil {
+	if res_ == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
@@ -677,7 +716,7 @@ func (ac *Action) Get_pushset() {
 			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
 		})
 	}
-	if len(*res) == 0 || res == nil {
+	if res == nil {
 		ac.ServeJson(Result{Error_code: util.Error_code})
 		return
 	}
@@ -849,6 +888,18 @@ func IsContain(slice []string, s string) bool {
 	return false
 }
 
+//替换数组中某个值
+func ReplaceValues(slice []string, before, after string) []string {
+	var num int
+	for k, v := range slice {
+		if before == v {
+			num = k
+		}
+	}
+	slice[num] = after
+	return slice
+}
+
 //修改或新增 entniche_rule 表的 entinfo 信息   parameter_name参数名  parameter参数
 func (ac *Action) updateEntnicheRule(parameter_name string, parameter interface{}) bool {
 	bl := false

+ 6 - 1
src/jfw/modules/entniche/src/util/util.go

@@ -8,7 +8,12 @@ import (
 
 //map转结构体
 func JsonUnmarshal(m interface{}, s interface{}) interface{} {
-	b, _ := json.Marshal(m)
+	var b []byte
+	if v, ok := m.(string); ok {
+		b = []byte(v)
+	} else {
+		b, _ = json.Marshal(m)
+	}
 	json.Unmarshal(b, &s)
 	return s
 }

+ 24 - 12
src/jfw/modules/subscribepay/src/entity/entniche.go

@@ -1,6 +1,7 @@
 package entity
 
 import (
+	"database/sql"
 	"encoding/json"
 	"log"
 	qutil "qfw/util"
@@ -26,12 +27,13 @@ func (e *entnicheStruct) PayCallBack(param *CallBackParam) bool {
 		nowFormat := qutil.FormatDate(&now, qutil.Date_Full_Layout)
 		var filter_id int64
 		var filter map[string]interface{}
+		var entname string
 		if err := json.Unmarshal([]byte(qutil.ObjToString((*orderdata)["filter"])), &filter); err != nil {
 			log.Println("企业商机管理支付成功json.Unmarshal出错", err)
 		} else {
 			cycle := qutil.IntAll(filter["cycle"])
 			adminname, _ := filter["adminname"].(string)
-			entname, _ := filter["entname"].(string)
+			entname, _ = filter["entname"].(string)
 			phone, _ := filter["phone"].(string)
 			industry, _ := filter["industry"].(string)
 			enddate := time.Date(now.Year()+cycle, now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
@@ -56,16 +58,26 @@ func (e *entnicheStruct) PayCallBack(param *CallBackParam) bool {
 					})
 				}
 			} else {
-				filter_id = util.Mysql.Insert("entniche_info", map[string]interface{}{
-					"name":       entname,
-					"industry":   industry,
-					"phone":      phone,
-					"admin_name": adminname,
-					"quota":      qutil.IntAll(filter["personnum"]),
-					"status":     1,
-					"createtime": nowFormat,
-					"startdate":  now.Unix(),
-					"enddate":    enddate.Unix(),
+				util.Mysql.ExecTx("商机管理支付成功", func(tx *sql.Tx) bool {
+					filter_id = util.Mysql.InsertByTx(tx, "entniche_info", map[string]interface{}{
+						"name":       entname,
+						"industry":   industry,
+						"phone":      phone,
+						"admin_name": adminname,
+						"quota":      qutil.IntAll(filter["personnum"]),
+						"status":     1,
+						"createtime": nowFormat,
+						"startdate":  now.Unix(),
+						"enddate":    enddate.Unix(),
+					})
+					dept_id := util.Mysql.InsertByTx(tx, "entniche_department", map[string]interface{}{
+						"pid":        0,
+						"name":       entname,
+						"ent_id":     filter_id,
+						"createtime": nowFormat,
+						"timestamp":  nowFormat,
+					})
+					return filter_id > 0 && dept_id > 0
 				})
 			}
 		}
@@ -84,7 +96,7 @@ func (e *entnicheStruct) PayCallBack(param *CallBackParam) bool {
 		if update {
 			//取消其他订单
 			userid := qutil.ObjToString((*orderdata)["user_id"])
-			go PayCancel(userid, "企业商机管理")
+			go PayCancel(userid, "企业商机管理", entname)
 		}
 	}
 	return true

+ 24 - 6
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -142,7 +142,7 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 		//支付提醒
 		util.MsgRemind.PaySuccess(qutil.IntAll((*orderdata)["id"]), qutil.ObjToString((*orderdata)["order_code"]), qutil.ObjToString((*orderdata)["user_id"]), qutil.ObjToString((*orderdata)["prepay_time"]), qutil.IntAllDef((*orderdata)["vip_type"], -1))
 		//其他未支付vip订阅订单 变为已取消
-		go PayCancel(userid, "VIP订阅")
+		go PayCancel(userid, "VIP订阅", "")
 	}
 	return flag
 }
@@ -616,21 +616,39 @@ func getSetMealPrice(c, iCount, u int) int {
 	}
 }
 
-//支付成功后,将该订单以外的所有订单状态改为已取消状态 已取消:-2  先关闭订单再改状态
-func PayCancel(userId, product_type string) bool {
+//支付成功后,将该订单以外的所有订单状态改为已取消状态 已取消:-2  先关闭订单再改状态  --entname 企业商机管理订单会用到该参数 其他取消订单不需要
+func PayCancel(userId, product_type, entname string) bool {
 	queryMap := map[string]interface{}{
 		"user_id":      userId,
 		"order_status": 0,
 		"product_type": product_type,
 	}
 	i, order_len := 0, 0
-	order := util.Mysql.Find("dataexport_order", queryMap, "id,pay_way,out_trade_no,prepay_time,order_status", "create_time desc", -1, 0)
+	order := util.Mysql.Find("dataexport_order", queryMap, "id,filter,pay_way,out_trade_no,prepay_time,order_status", "create_time desc", -1, 0)
 	if order != nil {
-		order_len = len(*order)
 		//遍历未支付订单
 		for _, v := range *order {
 			//关闭未支付订单
-			flag := pay.CloseDataExportOrder(qutil.ObjToString(v["pay_way"]), qutil.ObjToString(v["out_trade_no"]), qutil.ObjToString(v["prepay_time"]))
+			if product_type == "企业商机管理" { //企业商机管理取消的订单 公司名重复才取消
+				var filter map[string]interface{}
+				if err := json.Unmarshal([]byte(qutil.ObjToString(v["filter"])), &filter); err != nil {
+					log.Println("企业商机管理取消订单json.Unmarshal出错", err)
+				} else {
+					filter_entname, _ := filter["entname"].(string)
+					if entname != filter_entname {
+						continue
+					}
+				}
+			}
+			order_len++
+			flag := false
+			if qutil.ObjToString(v["out_trade_no"]) != "" {
+				flag = pay.CloseDataExportOrder(qutil.ObjToString(v["pay_way"]), qutil.ObjToString(v["out_trade_no"]), qutil.ObjToString(v["prepay_time"]))
+			} else {
+				if product_type == "企业商机管理" {
+					flag = true
+				}
+			}
 			if flag {
 				//更改未支付订单状态 -2  逐个取消订单
 				bl := util.Mysql.Update("dataexport_order", bson.M{

+ 85 - 121
src/jfw/modules/subscribepay/src/service/entniche.go

@@ -2,7 +2,6 @@ package service
 
 import (
 	"config"
-	"database/sql"
 	"encoding/json"
 	"log"
 	"pay"
@@ -37,25 +36,8 @@ func (e *Entniche) Buy() {
 	phone, _ := e.GetSession("identCodeKey").(string)
 	userId, _ := e.GetSession("userId").(string)
 	status, ordercode := func() (int, string) {
-		if personnum < 5 || cycle < 1 {
-			return 0, ""
-		}
-		var price float64
-		for k, v := range config.EntnicheConfig.Price {
-			kk := strings.Split(k, "-")
-			if kk[0] != "" && kk[1] != "" {
-				if personnum >= qutil.IntAll(kk[0]) && personnum <= qutil.IntAll(kk[1]) {
-					price = v
-				}
-				break
-			} else if kk[0] != "" && kk[1] == "" {
-				if personnum >= qutil.IntAll(kk[0]) {
-					price = v
-				}
-				break
-			}
-		}
-		if price == 0 {
+		order_money := getOrderMoney(userId, personnum, cycle)
+		if order_money == -1 {
 			return 0, ""
 		}
 		//短信验证码校验
@@ -67,59 +49,37 @@ 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) * 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{}{
-				"cycle":     cycle,
-				"personnum": personnum,
-				"industry":  industry,
-				"entname":   entname,
-				"adminname": admin,
-				"phone":     phone,
-			})
-			order_id := util.Mysql.InsertByTx(tx, "dataexport_order", map[string]interface{}{
-				"order_money":  order_money,
-				"order_status": 0,
-				"filter":       string(filter),
-				"order_code":   code,
-				"product_type": "企业商机管理",
-				"create_time":  qutil.NowFormat(qutil.Date_Full_Layout),
-				"prepay_time":  qutil.NowFormat(qutil.Date_Full_Layout),
-				"user_id":      userId,
-				"pay_way":      "",
-			})
-			return order_id > 0
-		}) {
+		filter, _ := json.Marshal(map[string]interface{}{
+			"cycle":     cycle,
+			"personnum": personnum,
+			"industry":  industry,
+			"entname":   entname,
+			"adminname": admin,
+			"phone":     phone,
+		})
+		order_id := util.Mysql.Insert("dataexport_order", map[string]interface{}{
+			"order_money":  order_money,
+			"order_status": 0,
+			"filter":       string(filter),
+			"order_code":   code,
+			"product_type": "企业商机管理",
+			"create_time":  qutil.NowFormat(qutil.Date_Full_Layout),
+			"prepay_time":  qutil.NowFormat(qutil.Date_Full_Layout),
+			"user_id":      userId,
+			"pay_way":      "",
+		})
+		log.Println("商机管理购买订单", userId, order_id, code)
+		if order_id > 0 {
 			return 1, code
-		} else {
-			return 0, ""
 		}
+		return 0, ""
 	}()
-	isadmin := 0
-	if status == 1 {
-		user, ok := util.MQFW.FindById("user", userId, `{"s_phone":1}`)
-		if ok && user != nil && qutil.ObjToString((*user)["s_phone"]) == phone {
-			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{}{
 			"status":    status,
 			"ordercode": ordercode,
-			"isadmin":   isadmin,
 		},
 	})
 }
@@ -213,6 +173,7 @@ func (e *Entniche) BuyAgain() {
 	phone := e.GetString("phone")
 	userId, _ := e.GetSession("userId").(string)
 	renew, _ := e.GetInteger("renew") //1是续费 0再次购买
+	effective_cycle := 0
 	status, ordercode := func() (int, string) {
 		if renew == 1 {
 			ent := util.Mysql.FindOne("entniche_info", map[string]interface{}{
@@ -222,77 +183,80 @@ func (e *Entniche) BuyAgain() {
 			//计算周期
 			start_year := time.Unix(qutil.Int64All((*ent)["startdate"]), 0).Format("2006")
 			end_year := time.Unix(qutil.Int64All((*ent)["enddate"]), 0).Format("2006")
-			effective_cycle := qutil.IntAll(end_year) - qutil.IntAll(start_year) //生效周期
-			expect_cycle := effective_cycle + cycle                              //预计周期
+			effective_cycle = qutil.IntAll(end_year) - qutil.IntAll(start_year) //生效周期
+			expect_cycle := effective_cycle + cycle                             //预计周期
 			if effective_cycle > 3 || expect_cycle > 3 {
 				return -1, ""
 			}
 		}
-		if personnum < 5 || cycle < 1 {
-			return 0, ""
-		}
-		var price float64
-		for k, v := range config.EntnicheConfig.Price {
-			kk := strings.Split(k, "-")
-			if kk[0] != "" && kk[1] != "" {
-				if personnum >= qutil.IntAll(kk[0]) && personnum <= qutil.IntAll(kk[1]) {
-					price = v
-				}
-				break
-			} else if kk[0] != "" && kk[1] == "" {
-				if personnum >= qutil.IntAll(kk[0]) {
-					price = v
-				}
-				break
-			}
-		}
-		if price == 0 {
+		order_money := getOrderMoney(userId, personnum, cycle)
+		if order_money == -1 {
 			return 0, ""
 		}
-		order_money := int(config.EntnicheConfig.Discount * price * float64(cycle) * 100)
 		code := pay.GetOrderCode(userId)
-		if util.Mysql.ExecTx("企业商机管理创建订单", func(tx *sql.Tx) bool {
-			filter, _ := json.Marshal(map[string]interface{}{
-				"cycle":     cycle,
-				"personnum": personnum,
-				"industry":  industry,
-				"entname":   entname,
-				"adminname": admin,
-				"phone":     phone,
-			})
-			order_id := util.Mysql.InsertByTx(tx, "dataexport_order", map[string]interface{}{
-				"order_money":  order_money,
-				"order_status": 0,
-				"filter":       string(filter),
-				"order_code":   code,
-				"product_type": "企业商机管理",
-				"create_time":  qutil.NowFormat(qutil.Date_Full_Layout),
-				"prepay_time":  qutil.NowFormat(qutil.Date_Full_Layout),
-				"user_id":      userId,
-				"vip_type":     renew,
-				"pay_way":      "",
-			})
-			return order_id > 0
-		}) {
+		filter, _ := json.Marshal(map[string]interface{}{
+			"cycle":     cycle,
+			"personnum": personnum,
+			"industry":  industry,
+			"entname":   entname,
+			"adminname": admin,
+			"phone":     phone,
+		})
+		order_id := util.Mysql.Insert("dataexport_order", map[string]interface{}{
+			"order_money":  order_money,
+			"order_status": 0,
+			"filter":       string(filter),
+			"order_code":   code,
+			"product_type": "企业商机管理",
+			"create_time":  qutil.NowFormat(qutil.Date_Full_Layout),
+			"prepay_time":  qutil.NowFormat(qutil.Date_Full_Layout),
+			"user_id":      userId,
+			"vip_type":     renew,
+			"pay_way":      "",
+		})
+		if order_id > 0 {
 			return 1, code
-		} else {
-			return 0, ""
 		}
+		return 0, ""
 	}()
 
-	isadmin := 0
-	if status == 1 {
-		user, ok := util.MQFW.FindById("user", userId, `{"s_phone":1}`)
-		if ok && user != nil && qutil.ObjToString((*user)["s_phone"]) == phone {
-			isadmin = 1
-		}
-	}
 	e.ServeJson(map[string]interface{}{
 		"error_code": 0,
 		"data": map[string]interface{}{
-			"status":    status,
-			"ordercode": ordercode,
-			"isadmin":   isadmin,
+			"status":          status,
+			"ordercode":       ordercode,
+			"effective_cycle": effective_cycle,
 		},
 	})
 }
+
+func getOrderMoney(userId string, personnum, cycle int) int {
+	if personnum < 5 || cycle < 1 {
+		log.Println(userId, "商机管理订单personnum、cycle参数不合法", personnum, cycle)
+		return -1
+	}
+	var price float64
+	for k, v := range config.EntnicheConfig.Price {
+		kk := strings.Split(k, "-")
+		if kk[0] != "" && kk[1] != "" {
+			if personnum >= qutil.IntAll(kk[0]) && personnum <= qutil.IntAll(kk[1]) {
+				price = v
+				break
+			}
+		} else if kk[0] != "" && kk[1] == "" {
+			if personnum >= qutil.IntAll(kk[0]) {
+				price = v
+				break
+			}
+		}
+	}
+	if price == 0 {
+		log.Println(userId, "商机管理订单获取price错误")
+		return -1
+	}
+	order_money := int(config.EntnicheConfig.Discount * price * float64(cycle) * float64(personnum) * 100)
+	if order_money < 1 {
+		order_money = 1
+	}
+	return order_money
+}

+ 23 - 12
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -212,7 +212,6 @@ func (o *OrderListDetails) DeleteOrder() error {
 		} else {
 			queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
 		}
-		queryM["product_type"] = map[string]interface{}{"ne": "企业商机管理"}
 		haveNextPage, res, _ := o.Datas(queryM, pageNum, 10)
 		if len(res) > 0 {
 			res = res[0:1]
@@ -227,7 +226,7 @@ func (o *OrderListDetails) DeleteOrder() error {
 		//删除 取消前 先关闭订单
 		order := util.Mysql.FindOne(tableName_order, queryMap, "id,pay_way,out_trade_no,prepay_time,order_status", "")
 		if order != nil {
-			if qutil.IntAll((*order)["order_status"]) == 0 && qutil.ObjToString((*order)["pay_way"]) != "transferAccounts" { //未支付状态下 删除订单需要先关闭订单
+			if qutil.IntAll((*order)["order_status"]) == 0 && qutil.ObjToString((*order)["pay_way"]) != "transferAccounts" && qutil.ObjToString((*order)["out_trade_no"]) != "" { //未支付状态下 删除订单需要先关闭订单
 				flag = pay.CloseDataExportOrder(qutil.ObjToString((*order)["pay_way"]), qutil.ObjToString((*order)["out_trade_no"]), qutil.ObjToString((*order)["prepay_time"]))
 			} else {
 				flag = true
@@ -714,17 +713,29 @@ func FortyEightHoursCancel(order string, create_time_stamp, now_time_stamp int64
 func isEntExpire(userid string) bool {
 	u, ok := util.MQFW.FindById("user", userid, `{"s_phone":1}`)
 	if ok && u != nil && (*u)["s_phone"] != nil {
-		list := util.Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate from entniche_info a 
-				INNER JOIN entniche_user b on (a.id=b.ent_id) 
-				where a.phone=? or b.phone=? 
-				order by convert(a.name using gbk) COLLATE gbk_chinese_ci asc`, (*u)["s_phone"].(string), (*u)["s_phone"].(string))
-		if list != nil {
+		//		list := util.Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate from entniche_info a
+		//				INNER JOIN entniche_user b on (a.id=b.ent_id)
+		//				where a.phone=? or b.phone=?
+		//				order by convert(a.name using gbk) COLLATE gbk_chinese_ci asc`, (*u)["s_phone"].(string), (*u)["s_phone"].(string))
+		list := util.Mysql.SelectBySql(`select filter from dataexport_order where user_id=? and product_type=? and order_status=?`, userid, "企业商机管理", 1)
+		if len(*list) > 0 {
 			for _, v := range *list {
-				startdate := qutil.Int64All(v["startdate"])
-				enddate := qutil.Int64All(v["enddate"])
-				now := time.Now().Unix()
-				if now >= startdate && now < enddate {
-					return true
+				filterStr := qutil.ObjToString(v["filter"])
+				var filter map[string]interface{}
+				if err := json.Unmarshal([]byte(filterStr), &filter); err != nil {
+					log.Printf("%s 判断用户购买的企业商机管理是否到期 isEntExpire Unmarshal 出错 [%s]\n", userid, filterStr)
+					return false
+				}
+				date := util.Mysql.FindOne("entniche_info", bson.M{"name": qutil.ObjToString(filter["entname"])}, "startdate,enddate", "")
+				log.Println(date)
+				if date != nil {
+					startdate := qutil.Int64All((*date)["startdate"])
+					enddate := qutil.Int64All((*date)["enddate"])
+					log.Println(startdate)
+					now := time.Now().Unix()
+					if now >= startdate && now < enddate {
+						return true
+					}
 				}
 			}
 		}