Selaa lähdekoodia

feat: 企业权限判断

zhangxinlei1996 2 vuotta sitten
vanhempi
commit
5ba157d9ab
1 muutettua tiedostoa jossa 40 lisäystä ja 51 poistoa
  1. 40 51
      service/power.go

+ 40 - 51
service/power.go

@@ -219,55 +219,45 @@ func (this *PowerService) Power(userid string, baseUserId, accountId, entId, pos
 							}
 						}
 					}
-					//获取用户是什么版本权益
-					//用于判断是否含有企业主体的超级订阅、大会员服务
-					epowerData := this.Conn.Mysql.SelectBySql(`SELECT c.product_type FROM entniche_user a INNER JOIN entniche_power b 
-		 									INNER JOIN entniche_wait_empower c 
-		 									ON a.id =b.ent_user_id  AND c.id = b.wait_empower_id WHERE a.phone =? AND b.ent_id=? AND c.end_time >?`, phone, entId, time.Now().Format(date.Date_Full_Layout))
 
-					if epowerData != nil && len(*epowerData) > 0 {
-						for _, v := range *epowerData {
-							product_type := common.ObjToString(v["product_type"])
-							if strings.Contains(product_type, entity.ProductType_vip) {
-								oBuyset := common.ObjToMap((*o_entniche)["o_buyset"])
-								//upgrade := common.Int64All((*oBuyset)["upgrade"])
-								areacount := common.Int64All((*oBuyset)["areacount"])
-								buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
-								newcitys, _ := (*oBuyset)["newcitys"].([]interface{})
-								newcitysArr := common.InterfaceArrToint64Arr(newcitys)
-								status := common.Int64All((*eudata)["i_vip_status"])
-								starttime := common.Int64All((*eudata)["l_vip_starttime"])
-								endtime := common.Int64All((*eudata)["l_vip_endtime"])
-								vip = &entity.Vip{
-									Status:          status,
-									StartTime:       starttime,
-									EndTime:         endtime,
-									Upgrade:         1, //企业版默认是升级版
-									Areacount:       areacount,
-									Buyerclasscount: buyerclasscount,
-									MaxKeyLength:    300,
-									PowerType:       2,
-									HasKey:          haskey,
-									NewCitys:        newcitysArr,
-								}
-							} else if strings.Contains(product_type, entity.ProductType_member) {
-								member.PowerType = 2
-								status := common.Int64All((*eudata)["i_member_status"])
-								starttime := common.Int64All((*eudata)["l_member_starttime"])
-								endtime := common.Int64All((*eudata)["l_member_endtime"])
-								member = &entity.Member{
-									Status:     status,
-									StartTime:  starttime,
-									EndTime:    endtime,
-									MemberName: level_map[status],
-									PowerType:  2,
-									HasKey:     haskey,
-								}
-								//是否试用
-								if this.Conn.MgoJy.Count("member", map[string]interface{}{"userid": positionId}) > 0 {
-									member.Used = true
-								}
-							}
+					if common.Int64All((*eudata)["i_vip_status"]) > 0 {
+						oBuyset := common.ObjToMap((*o_entniche)["o_buyset"])
+						areacount := common.Int64All((*oBuyset)["areacount"])
+						buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
+						newcitys, _ := (*oBuyset)["newcitys"].([]interface{})
+						newcitysArr := common.InterfaceArrToint64Arr(newcitys)
+						status := common.Int64All((*eudata)["i_vip_status"])
+						starttime := common.Int64All((*eudata)["l_vip_starttime"])
+						endtime := common.Int64All((*eudata)["l_vip_endtime"])
+						vip = &entity.Vip{
+							Status:          status,
+							StartTime:       starttime,
+							EndTime:         endtime,
+							Upgrade:         1, //企业版默认是升级版
+							Areacount:       areacount,
+							Buyerclasscount: buyerclasscount,
+							MaxKeyLength:    300,
+							PowerType:       2,
+							HasKey:          haskey,
+							NewCitys:        newcitysArr,
+						}
+					}
+					if common.Int64All((*eudata)["i_member_status"]) > 0 {
+						member.PowerType = 2
+						status := common.Int64All((*eudata)["i_member_status"])
+						starttime := common.Int64All((*eudata)["l_member_starttime"])
+						endtime := common.Int64All((*eudata)["l_member_endtime"])
+						member = &entity.Member{
+							Status:     status,
+							StartTime:  starttime,
+							EndTime:    endtime,
+							MemberName: level_map[status],
+							PowerType:  2,
+							HasKey:     haskey,
+						}
+						//是否试用
+						if this.Conn.MgoJy.Count("member", map[string]interface{}{"userid": positionId}) > 0 {
+							member.Used = true
 						}
 					}
 				}
@@ -353,10 +343,9 @@ func (this *PowerService) Power(userid string, baseUserId, accountId, entId, pos
 							}
 						}
 					}
-
-					//广东移动DICT 用户
-					ent.PrivateGD = this.Conn.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) > 0
 				}
+				//广东移动DICT 用户
+				ent.PrivateGD = this.Conn.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) > 0
 			}
 			if vip.Status <= 0 && member.Status <= 0 && entniche.Status <= 0 {
 				free.IsFree = true