فهرست منبع

feat:区域权益校验修改

duxin 2 سال پیش
والد
کامیت
2225fb23e9
2فایلهای تغییر یافته به همراه43 افزوده شده و 15 حذف شده
  1. 25 10
      jyBXSubscribe/rpc/model/distributor.go
  2. 18 5
      jyBXSubscribe/rpc/model/entity.go

+ 25 - 10
jyBXSubscribe/rpc/model/distributor.go

@@ -70,7 +70,13 @@ func Distributor(region []string, entId, entUserId int) []*User {
 			}
 			//非商机管理企业或商机管理区域不满足 判断是否分配大会员或超级订阅
 			//user表 判断区域是否符合
-			if status := powerUser[common.InterfaceToStr(v.Id)]; status != 0 && v.Phone != "" {
+			var _n namePower
+			_n.entUserId = common.InterfaceToStr(v.Id)
+			_n.power = 1
+			n1 := powerUser[_n]
+			_n.power = 2
+			n2 := powerUser[_n]
+			if (n1 != 0 || n2 != 0) && v.Phone != "" {
 				//查询user表订阅区域
 				data, ok := IC.Mgo.FindOne("user", map[string]interface{}{
 					"$or": []map[string]interface{}{{"s_phone": v.Phone}, {"s_m_phone": v.Phone}},
@@ -81,23 +87,32 @@ func Distributor(region []string, entId, entUserId int) []*User {
 					i_vip_status, _ := (*data)["i_vip_status"].(int)
 					o_member_jy, _ := (*data)["o_member_jy"].(map[string]interface{})
 					o_vipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
-					if status == 1 && i_vip_status > 0 {
-						o_area, _ = o_vipjy["o_area"].(map[string]interface{})
-					} else if status == 2 && i_member_status > 0 {
+					if n2 != 0 && i_member_status > 0 { //有大会员权益 校验区域
 						o_area, _ = o_member_jy["o_area"].(map[string]interface{})
-					} else {
-						continue
+						if regionCheck(o_area, regions) {
+							ss = append(ss, v)
+							continue
+						}
 					}
-
-					if regionCheck(o_area, regions) {
-						ss = append(ss, v)
+					if n1 != 0 && i_vip_status > 0 { //有超级订阅权益 校验区域
+						o_area, _ = o_vipjy["o_area"].(map[string]interface{})
+						if regionCheck(o_area, regions) {
+							ss = append(ss, v)
+							continue
+						}
 					}
 				}
 			}
 		}
 	} else {
 		for _, v := range users {
-			if (isEnt && v.Power == 1) || powerUser[common.InterfaceToStr(v.Id)] != 0 {
+			var _n namePower
+			_n.entUserId = common.InterfaceToStr(v.Id)
+			_n.power = 1
+			n1 := powerUser[_n]
+			_n.power = 2
+			n2 := powerUser[_n]
+			if (isEnt && v.Power == 1) || n1 != 0 || n2 != 0 {
 				ss = append(ss, v)
 			}
 		}

+ 18 - 5
jyBXSubscribe/rpc/model/entity.go

@@ -2,6 +2,7 @@ package model
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/date"
 	"encoding/json"
 	IC "jyBXSubscribe/rpc/init"
 	"strings"
@@ -46,6 +47,11 @@ type Department struct {
 	Ent_id     int    //公司id
 }
 
+type namePower struct {
+	entUserId string
+	power     int //1 超级订阅权益 2大会员权益
+}
+
 const (
 	//角色
 	Role_admin_system     = 1 //系统管理员
@@ -133,17 +139,24 @@ func GetEntUsers(entId int) *[]*User {
 }
 
 // 获取企业下分配权益的用户
-func GetEntPowerUsers(entId int) map[string]int {
-	r := IC.MainMysql.SelectBySql(`select a.ent_user_id,b.product_type from entniche_power a  LEFT JOIN entniche_wait_empower b ON (a.wait_empower_id = b.id) where a.ent_id=? and a.status != -1`, entId)
+func GetEntPowerUsers(entId int) map[namePower]int {
+	nowFormat := date.NowFormat(date.Date_Short_Layout)
+	r := IC.MainMysql.SelectBySql(`select a.ent_user_id,b.product_type from entniche_power a  LEFT JOIN entniche_wait_empower b ON (a.wait_empower_id = b.id) where a.ent_id=? and a.status = 1 and b.start_time <=? and b.end_time>=? `, entId, nowFormat, nowFormat)
 	if r == nil {
 		return nil
 	}
-	data := make(map[string]int)
+	data := make(map[namePower]int)
 	for _, v := range *r {
 		if strings.Contains(common.InterfaceToStr(v["product_type"]), "VIP") {
-			data[common.InterfaceToStr(v["ent_user_id"])] = 1
+			var _n namePower
+			_n.entUserId = common.InterfaceToStr(v["ent_user_id"])
+			_n.power = 1
+			data[_n] = 1
 		} else if strings.Contains(common.InterfaceToStr(v["product_type"]), "大会员") {
-			data[common.InterfaceToStr(v["ent_user_id"])] = 2
+			var _n namePower
+			_n.entUserId = common.InterfaceToStr(v["ent_user_id"])
+			_n.power = 2
+			data[_n] = 2
 		}
 	}
 	return data