Browse Source

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

wcj 5 years ago
parent
commit
a33b4732b2

+ 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;

+ 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
+}

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)
 		}
 	}
 	//发送邮件

+ 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