|
@@ -55,7 +55,7 @@
|
|
|
<div id="nav">
|
|
|
<select id="files">
|
|
|
|
|
|
- <option value="file0">bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/service/power.go (64.9%)</option>
|
|
|
+ <option value="file0">bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/service/power.go (6.1%)</option>
|
|
|
|
|
|
</select>
|
|
|
</div>
|
|
@@ -72,8 +72,10 @@
|
|
|
<pre class="file" id="file0" style="display: none">package service
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"log"
|
|
|
+ "math/rand"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
@@ -95,79 +97,237 @@ func NewPower(conn *entity.Conn) *PowerService <span class="cov8" title="1">{
|
|
|
}
|
|
|
}</span>
|
|
|
|
|
|
-//权益相关 userid用户mongodbid baseUserId
|
|
|
-func (this *PowerService) Power(userid string, baseUserId, accountId, entId int64) *entity.Power <span class="cov8" title="1">{
|
|
|
- //获取权益
|
|
|
- //大会员状态
|
|
|
- data, ok := this.Conn.MgoJy.FindById("user", userid, `{"l_vip_starttime":1,"l_vip_endtime":1,"s_phone":1,"s_m_phone":1,i_member_status":1,"i_member_give":1,"s_member_mainid":1,"i_member_sub_status":1,"i_member_trial":1,"i_vip_status":1,"o_vipjy":1,"o_jy":1,"l_registedate":1,"s_myemail":1,"base_user_id":1}`)
|
|
|
- if ok && *data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
|
+var level_map = map[int64]string{
|
|
|
+ 1: "专家版",
|
|
|
+ 2: "智慧版",
|
|
|
+ 3: "商机版",
|
|
|
+ 4: "试用版",
|
|
|
+ 5: "自定义",
|
|
|
+ 6: "商机版2.0",
|
|
|
+ 7: "专家版2.0",
|
|
|
+}
|
|
|
|
|
|
- ent := &entity.Ent{}
|
|
|
- entniche := &entity.Entniche{}
|
|
|
- vip := &entity.Vip{}
|
|
|
- member := &entity.Member{}
|
|
|
- registeDate := common.Int64All((*data)["l_registedate"]) //注册时间
|
|
|
- //VIP
|
|
|
- vipStatus := common.Int64All((*data)["i_vip_status"])
|
|
|
- vipStartTime := common.Int64All((*data)["l_vip_starttime"])
|
|
|
- vipEndTime := common.Int64All((*data)["l_vip_endtime"])
|
|
|
- ovipjy := common.ObjToMap((*data)["o_vipjy"])
|
|
|
- oBuyset := common.ObjToMap((*ovipjy)["o_buyset"])
|
|
|
- upgrade := common.Int64All((*oBuyset)["oBuyset"])
|
|
|
- areacount := common.Int64All((*oBuyset)["areacount"])
|
|
|
- buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
|
|
|
- vip = &entity.Vip{
|
|
|
- Status: vipStatus,
|
|
|
- StartTime: vipStartTime,
|
|
|
- EndTime: vipEndTime,
|
|
|
- Upgrade: upgrade,
|
|
|
- Areacount: areacount,
|
|
|
- Buyerclasscount: buyerclasscount,
|
|
|
- MaxKeyLength: 300,
|
|
|
- PowerType: common.Int64All(common.If(vipStatus > 0, 1, 0)),
|
|
|
- //TODO 附件下载次数
|
|
|
- }
|
|
|
- //免费相关
|
|
|
- free := &entity.Free{}
|
|
|
- o_jy, _ := (*data)["o_jy"].(map[string]interface{})
|
|
|
- a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
- free.FreeHasKey = len(a_key) > 0
|
|
|
- //免费用户可查看企业画像次数//免费用户可查看采购单位画像次数//免费用户可以进行附件下载次数
|
|
|
- freeEntPort, freeBuyerPort, freeFile := FreeExperience(userid)
|
|
|
- free.FreeEntPort, free.FreeBuyerPort, free.FreeFile = int64(freeEntPort), int64(freeBuyerPort), int64(freeFile)
|
|
|
- //
|
|
|
- //子账号被启用
|
|
|
- i_member_sub_status := common.IntAllDef((*data)["i_member_sub_status"], 0)
|
|
|
+/*
|
|
|
+ 权益相关
|
|
|
+ userid //mongodb用户id
|
|
|
+ baseUserId //base_user用户id
|
|
|
+ accountId //账户id
|
|
|
+ entId =5; //企业id
|
|
|
+ positionType //职位类型 0个人 1企业
|
|
|
+ positionId //职位id
|
|
|
+ 切换到企业身份后,session中userId存的是企业雇员的职位id,个人身份,userId还是原来mgo库里的_id
|
|
|
+*/
|
|
|
+func (this *PowerService) Power(userid string, baseUserId, accountId, entId, positionType, positionId int64) *entity.Power <span class="cov8" title="1">{
|
|
|
+ ent := &entity.Ent{}
|
|
|
+ entniche := &entity.Entniche{}
|
|
|
+ vip := &entity.Vip{}
|
|
|
+ member := &entity.Member{}
|
|
|
+ free := &entity.Free{}
|
|
|
+ userPower := entity.Power{}
|
|
|
+ if bytes, err := redis.GetBytes("newother", GetRedisName(positionId)); err == nil && bytes != nil </span><span class="cov8" title="1">{
|
|
|
+ if err := json.Unmarshal(*bytes, &userPower); err == nil </span><span class="cov8" title="1">{
|
|
|
+ return &userPower
|
|
|
+ }</span>
|
|
|
+ }
|
|
|
+ <span class="cov0" title="0">log.Println("##########", redis.Get("newother", "zxl"))
|
|
|
+
|
|
|
+ //获取用户本身的注册时间和邮箱、这个与个人、企业无关
|
|
|
+ mgoUserFields := map[string]interface{}{
|
|
|
+ "s_myemail": 1,
|
|
|
+ "l_registedate": 1,
|
|
|
+ "s_phone": 1,
|
|
|
+ "s_m_phone": 1,
|
|
|
+ "base_user_id": 1,
|
|
|
+ }
|
|
|
+ //大会员权益表查询条件
|
|
|
+ bigmemberServiceUserQuery := map[string]interface{}{"s_userid": userid, "i_status": 0}
|
|
|
+ //个人身份 取user表中权益
|
|
|
+ if positionType == 0 </span><span class="cov0" title="0">{
|
|
|
+ mgoUserFields["i_vip_status"] = 1
|
|
|
+ mgoUserFields["l_vip_starttime"] = 1
|
|
|
+ mgoUserFields["l_vip_endtime"] = 1
|
|
|
+ mgoUserFields["o_vipjy"] = 1
|
|
|
+ mgoUserFields["i_member_status"] = 1
|
|
|
+ mgoUserFields["i_member_give"] = 1
|
|
|
+ mgoUserFields["s_member_mainid"] = 1
|
|
|
+ mgoUserFields["i_member_sub_status"] = 1
|
|
|
+ mgoUserFields["i_member_trial"] = 1
|
|
|
+ mgoUserFields["o_member_jy"] = 1
|
|
|
+ mgoUserFields["o_jy"] = 1
|
|
|
+ mgoUserFields["i_ts_guide"] = 1
|
|
|
+ mgoUserFields["i_member_apppushunread"] = 1
|
|
|
+ mgoUserFields["i_entniche_apppushunread"] = 1
|
|
|
+ mgoUserFields["i_apppushunread"] = 1
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
+ bigmemberServiceUserQuery["s_userid"] = positionId
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">data, ok := this.Conn.MgoJy.FindById("user", userid, mgoUserFields)
|
|
|
+ if ok && data != nil && len(*data) > 0 </span><span class="cov0" title="0">{
|
|
|
+ //基本信息
|
|
|
+ registeDate := common.Int64All((*data)["l_registedate"]) //注册时间
|
|
|
+ phone, _ := common.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string) //
|
|
|
+ mail := common.ObjToString((*data)["s_myemail"])
|
|
|
+ i_ts_guide := common.Int64All((*data)["i_ts_guide"])
|
|
|
+ i_member_apppushunread := common.Int64All((*data)["i_member_apppushunread"])
|
|
|
+ i_entniche_apppushunread := common.Int64All((*data)["i_entniche_apppushunread"])
|
|
|
+ i_apppushunread := common.Int64All((*data)["i_apppushunread"])
|
|
|
+ free.Mail = mail
|
|
|
+ free.Registedate = registeDate
|
|
|
+ free.Phone = phone
|
|
|
+ free.TsGuide = i_ts_guide
|
|
|
+ free.Apppushunread = i_apppushunread
|
|
|
+ free.EntnicheApppushunread = i_entniche_apppushunread
|
|
|
+ free.MemberApppushunread = i_member_apppushunread
|
|
|
+ //个人权益
|
|
|
+ if positionType == 0 </span><span class="cov0" title="0">{
|
|
|
+ o_jy, _ := (*data)["o_jy"].(map[string]interface{})
|
|
|
+ a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
+ free.FreeHasKey = len(a_key) > 0
|
|
|
+ if common.IntAll((o_jy)["i_newfree"]) > 0 || entity.IsNewFreeTimeCell < registeDate </span><span class="cov0" title="0">{
|
|
|
+ //IsNewFreeTimeCell dev3.6.4版本之前发了个紧急版本处理老用户订阅问题,i_newfree字段必须用户选择地区才能生成,不能作为判断是否是新用户得唯一标识,在此版本添加了常量:IsNewFreeTimeCell作为判断标准;--ws
|
|
|
+ free.IsUpgrade = true //新免费用户
|
|
|
+ }</span>
|
|
|
+ //超级订阅
|
|
|
+ <span class="cov0" title="0">vipStatus := common.Int64All((*data)["i_vip_status"])
|
|
|
+ vipStartTime := common.Int64All((*data)["l_vip_starttime"])
|
|
|
+ vipEndTime := common.Int64All((*data)["l_vip_endtime"])
|
|
|
+ ovipjy := common.ObjToMap((*data)["o_vipjy"])
|
|
|
+ oBuyset := common.ObjToMap((*ovipjy)["o_buyset"])
|
|
|
+ upgrade := common.Int64All((*oBuyset)["upgrade"])
|
|
|
+ areacount := common.Int64All((*oBuyset)["areacount"])
|
|
|
+ buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
|
|
|
+ vip = &entity.Vip{
|
|
|
+ Status: vipStatus,
|
|
|
+ StartTime: vipStartTime,
|
|
|
+ EndTime: vipEndTime,
|
|
|
+ Upgrade: upgrade,
|
|
|
+ Areacount: areacount,
|
|
|
+ Buyerclasscount: buyerclasscount,
|
|
|
+ MaxKeyLength: 300,
|
|
|
+ PowerType: common.Int64All(common.If(vipStatus > 0, 1, 0)),
|
|
|
+ //TODO 附件下载次数
|
|
|
+ }
|
|
|
+ if (*ovipjy)["a_items"] != nil </span><span class="cov0" title="0">{
|
|
|
+ a_items := common.ObjArrToMapArr((*ovipjy)["a_items"].([]interface{}))
|
|
|
+ vip.HasKey = HasKey(a_items)
|
|
|
+ }</span>
|
|
|
+ //个人member
|
|
|
+ <span class="cov0" title="0">i_member_sub_status := common.IntAllDef((*data)["i_member_sub_status"], 0)
|
|
|
|
|
|
- memberStatus := common.Int64All((*data)["i_member_status"])
|
|
|
- memberStarttime := common.Int64All((*data)["i_member_starttime"])
|
|
|
- memberEndtime := common.Int64All((*data)["i_member_endtime"])
|
|
|
- member = &entity.Member{
|
|
|
- Status: memberStatus,
|
|
|
- StartTime: memberStarttime,
|
|
|
- EndTime: memberEndtime,
|
|
|
- MaxKeyLength: 300, //最大关键词数量限制
|
|
|
+ memberStatus := common.Int64All((*data)["i_member_status"])
|
|
|
+ memberStarttime := common.Int64All((*data)["i_member_starttime"])
|
|
|
+ memberEndtime := common.Int64All((*data)["i_member_endtime"])
|
|
|
+ member = &entity.Member{
|
|
|
+ Status: memberStatus,
|
|
|
+ StartTime: memberStarttime,
|
|
|
+ EndTime: memberEndtime,
|
|
|
+ MaxKeyLength: 300, //最大关键词数量限制
|
|
|
+ PowerType: common.Int64All(common.If(memberStatus > 0, 1, 0)),
|
|
|
+ }
|
|
|
+ omemberjy := common.ObjToMap((*data)["o_member_jy"])
|
|
|
+ if (*omemberjy)["a_items"] != nil </span><span class="cov0" title="0">{
|
|
|
+ if arr, ok := (*omemberjy)["a_items"].([]interface{}); ok </span><span class="cov0" title="0">{
|
|
|
+ a_items := common.ObjArrToMapArr(arr)
|
|
|
+ member.HasKey = HasKey(a_items)
|
|
|
+ }</span>
|
|
|
+ }
|
|
|
+ <span class="cov0" title="0">if memberStatus > 0 </span><span class="cov0" title="0">{
|
|
|
+ member.MemberPower = 1 //是否分配了大会员;0:否 1:是
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">if (*data)["s_member_mainid"] != nil && common.ObjToString((*data)["s_member_mainid"]) != "" && i_member_sub_status > 0 </span><span class="cov0" title="0">{
|
|
|
+ member.Pid = common.ObjToString((*data)["s_member_mainid"])
|
|
|
+ member.IsSubCount = 1
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">if (member.Pid != "" && common.IntAllDef((*data)["i_member_sub_status"], 0) == 1) || this.Conn.MgoJy.Count("member", map[string]interface{}{"userid": userid}) > 0 </span><span class="cov0" title="0">{
|
|
|
+ member.Used = true
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">if (*data)["i_member_trial"] != nil </span><span class="cov0" title="0">{
|
|
|
+ member.IsMemberTrial = 1
|
|
|
+ }</span>
|
|
|
+ //获取大会员版本名称
|
|
|
+ <span class="cov0" title="0">member.MemberName = level_map[memberStatus]</span>
|
|
|
+ } else<span class="cov0" title="0"> if positionType == 1 </span><span class="cov0" title="0">{
|
|
|
+ entnicheUserId := this.GetEntnicheUserId(entId, phone)
|
|
|
+ //免费
|
|
|
+ fdata, ok := this.Conn.MgoJy.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_ent": entId,
|
|
|
+ "i_userid": entnicheUserId,
|
|
|
+ "i_type": 2, //0:商机管理 1:超级订阅/大会员 2:免费
|
|
|
+ })
|
|
|
+ o_jy, _ := (*fdata)["o_entniche"].(map[string]interface{})
|
|
|
+ a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
+ free.FreeHasKey = len(a_key) > 0
|
|
|
+ if common.IntAll((o_jy)["i_newfree"]) > 0 || entity.IsNewFreeTimeCell < registeDate </span><span class="cov0" title="0">{ //IsNewFreeTimeCell dev3.6.4版本之前发了个紧急版本处理老用户订阅问题,i_newfree字段必须用户选择地区才能生成,不能作为判断是否是新用户得唯一标识,在此版本添加了常量:IsNewFreeTimeCell作为判断标准;--ws
|
|
|
+ free.IsUpgrade = true //新免费用户
|
|
|
+ }</span>
|
|
|
+ //企业
|
|
|
+ <span class="cov0" title="0">edata, ok := this.Conn.MgoJy.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_ent": entId,
|
|
|
+ "i_userid": entnicheUserId,
|
|
|
+ "i_type": 1, //0:商机管理 1:超级订阅/大会员
|
|
|
+ "l_endtime": map[string]interface{}{
|
|
|
+ "$gt": time.Now().Unix(),
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if ok && edata != nil && len(*edata) > 0 </span><span class="cov0" title="0">{
|
|
|
+ haskey := false
|
|
|
+ status := common.Int64All((*edata)["i_status"])
|
|
|
+ starttime := common.Int64All((*edata)["l_starttime"])
|
|
|
+ endtime := common.Int64All((*edata)["l_endtime"])
|
|
|
+ o_entniche := common.ObjToMap((*edata)["o_entniche"])
|
|
|
+ if (*o_entniche)["a_items"] != nil </span><span class="cov0" title="0">{
|
|
|
+ if arr, ok := (*o_entniche)["a_items"].([]interface{}); ok </span><span class="cov0" title="0">{
|
|
|
+ a_items := common.ObjArrToMapArr(arr)
|
|
|
+ haskey = HasKey(a_items)
|
|
|
+ }</span>
|
|
|
+ }
|
|
|
+ //获取用户是什么版本权益
|
|
|
+ //用于判断是否含有企业主体的超级订阅、大会员服务
|
|
|
+ <span class="cov0" title="0">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 </span><span class="cov0" title="0">{
|
|
|
+ for _, v := range *epowerData </span><span class="cov0" title="0">{
|
|
|
+ product_type := common.ObjToString(v["product_type"])
|
|
|
+ if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
|
|
|
+ oBuyset := common.ObjToMap((*o_entniche)["o_buyset"])
|
|
|
+ upgrade := common.Int64All((*oBuyset)["oBuyset"])
|
|
|
+ areacount := common.Int64All((*oBuyset)["areacount"])
|
|
|
+ buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
|
|
|
+ vip = &entity.Vip{
|
|
|
+ Status: status,
|
|
|
+ StartTime: starttime,
|
|
|
+ EndTime: endtime,
|
|
|
+ Upgrade: upgrade,
|
|
|
+ Areacount: areacount,
|
|
|
+ Buyerclasscount: buyerclasscount,
|
|
|
+ MaxKeyLength: 300,
|
|
|
+ PowerType: 2,
|
|
|
+ HasKey: haskey,
|
|
|
+ }
|
|
|
+ }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
|
|
|
+ member.PowerType = 2
|
|
|
+ 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 </span><span class="cov0" title="0">{
|
|
|
+ member.Used = true
|
|
|
+ }</span>
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if memberStatus > 0 </span><span class="cov0" title="0">{
|
|
|
- member.MemberPower = 1 //是否分配了大会员;0:否 1:是
|
|
|
- }</span>
|
|
|
- <span class="cov8" title="1">if (*data)["s_member_mainid"] != nil && common.ObjToString((*data)["s_member_mainid"]) != "" && i_member_sub_status > 0 </span><span class="cov0" title="0">{
|
|
|
- member.Pid = common.ObjToString((*data)["s_member_mainid"])
|
|
|
- member.IsSubCount = 1
|
|
|
- }</span>
|
|
|
- <span class="cov8" title="1">if (member.Pid != "" && common.IntAllDef((*data)["i_member_sub_status"], 0) == 1) || this.Conn.MgoJy.Count("member", map[string]interface{}{"userid": userid}) > 0 </span><span class="cov8" title="1">{
|
|
|
- member.Used = true
|
|
|
- }</span>
|
|
|
- <span class="cov8" title="1">if (*data)["i_member_trial"] != nil </span><span class="cov0" title="0">{
|
|
|
- member.IsMemberTrial = 1
|
|
|
- }</span>
|
|
|
- //获取大会员版本名称 //TODO 自定义有问题
|
|
|
- <span class="cov8" title="1">if combo := this.Conn.Mysql.SelectBySql(`select s_name from bigmember_combo where id=?`, memberStatus); combo != nil && len(*combo) > 0 </span><span class="cov0" title="0">{
|
|
|
- member.MemberName = common.ObjToString((*combo)[0]["s_name"])
|
|
|
- }</span>
|
|
|
- <span class="cov8" title="1">memberServiceMap := map[int64]bool{}
|
|
|
- //获取大会员相关操作
|
|
|
- serviceList := this.Conn.Mysql.Find("bigmember_service_user", map[string]interface{}{"s_userid": userid, "i_status": 0}, "DISTINCT(s_serviceid),i_frequency", "", -1, -1)
|
|
|
+ //大会员相关权益数量
|
|
|
+ <span class="cov0" title="0">memberServiceMap := map[int64]bool{}
|
|
|
+ serviceList := this.Conn.Mysql.Find("bigmember_service_user", bigmemberServiceUserQuery, "DISTINCT(s_serviceid),i_frequency", "", -1, -1)
|
|
|
if serviceList != nil && len(*serviceList) != 0 </span><span class="cov0" title="0">{
|
|
|
pCount, eCount, dailyNum, customers := 0, 0, 0, 10
|
|
|
for _, item := range *serviceList </span><span class="cov0" title="0">{
|
|
@@ -193,44 +353,22 @@ func (this *PowerService) Power(userid string, baseUserId, accountId, entId int6
|
|
|
member.Customers = int64(customers)</span>
|
|
|
}
|
|
|
//
|
|
|
- <span class="cov8" title="1">phone, _ := common.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string)
|
|
|
- if phone != "" </span><span class="cov8" title="1">{
|
|
|
- //用于判断是否含有企业主体的超级订阅、大会员服务
|
|
|
- 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 c.end_time >?`, phone, time.Now().Format(date.Date_Full_Layout))
|
|
|
- if epowerData != nil && len(*epowerData) > 0 </span><span class="cov0" title="0">{
|
|
|
- for _, v := range *epowerData </span><span class="cov0" title="0">{
|
|
|
- product_type := common.ObjToString(v["product_type"])
|
|
|
- if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
|
|
|
- vip.PowerType = 2
|
|
|
- }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
|
|
|
- member.PowerType = 2
|
|
|
- }</span>
|
|
|
- }
|
|
|
- }
|
|
|
- //免费用户画像和附件下载权限
|
|
|
- <span class="cov8" title="1">o_jy := common.ObjToMap((*data)["o_jy"])
|
|
|
- //IsNewFreeTimeCell dev3.6.4版本之前发了个紧急版本处理老用户订阅问题,i_newfree字段必须用户选择地区才能生成,不能作为判断是否是新用户得唯一标识,在此版本添加了常量:IsNewFreeTimeCell作为判断标准;--ws
|
|
|
- if common.IntAll((*o_jy)["i_newfree"]) > 0 || entity.IsNewFreeTimeCell < registeDate </span><span class="cov0" title="0">{
|
|
|
- free.IsUpgrade = true //新免费用户
|
|
|
- }</span>
|
|
|
+ <span class="cov0" title="0">if phone != "" </span><span class="cov0" title="0">{
|
|
|
//查询是否是商机管理付费用户
|
|
|
- <span class="cov8" title="1">res := this.Conn.Mysql.SelectBySql(`SELECT i. STATUS AS status, i.isNew, i.power_source, r.role_id, u.power, i.name,i.id,i.startdate,i.enddate,i.auth_status,i.auth_reason,i.dept_subscribe FROM (entniche_user u LEFT JOIN entniche_user_role r ON r.user_id = u.id ) LEFT JOIN entniche_info i ON u.ent_id = i.id WHERE u.phone = ? and i.id = ? ORDER BY i. STATUS DESC, i.auth_status DESC`, phone, entId)
|
|
|
- if res != nil && len(*res) > 0 </span><span class="cov8" title="1">{
|
|
|
- for _, v := range *res </span><span class="cov8" title="1">{
|
|
|
+ res := this.Conn.Mysql.SelectBySql(`SELECT i. STATUS AS status, i.isNew, i.power_source, r.role_id, u.power, i.name,i.id,i.startdate,i.enddate,i.auth_status,i.auth_reason,i.dept_subscribe FROM (entniche_user u LEFT JOIN entniche_user_role r ON r.user_id = u.id ) LEFT JOIN entniche_info i ON u.ent_id = i.id WHERE u.phone = ? and i.id = ? ORDER BY i. STATUS DESC, i.auth_status DESC`, phone, entId)
|
|
|
+ if res != nil && len(*res) > 0 </span><span class="cov0" title="0">{
|
|
|
+ for _, v := range *res </span><span class="cov0" title="0">{
|
|
|
if common.IntAll(v["id"]) == 0 </span><span class="cov0" title="0">{
|
|
|
continue</span>
|
|
|
}
|
|
|
- <span class="cov8" title="1">entniche.IsNew = common.Int64All(v["isNew"])
|
|
|
+ <span class="cov0" title="0">entniche.IsNew = common.Int64All(v["isNew"])
|
|
|
entniche.Status = common.Int64All(v["status"])
|
|
|
entniche.IsEntPower = common.Int64All(v["power"])
|
|
|
entniche.PowerSource = common.Int64All(v["power_source"])
|
|
|
entniche.StartTime = common.Int64All(v["startdate"])
|
|
|
entniche.EndTime = common.Int64All(v["enddate"])
|
|
|
-
|
|
|
//
|
|
|
- ent.Name = common.ObjToString((*res)[0]["name"])
|
|
|
+ ent.Name = common.ObjToString(v["name"])
|
|
|
ent.EntRoleId = common.Int64All(v["role_id"])
|
|
|
ent.EntAuthStatus = common.Int64All(v["auth_status"])
|
|
|
ent.EntAuthReason = common.ObjToString(v["auth_reason"])
|
|
@@ -248,48 +386,99 @@ func (this *PowerService) Power(userid string, baseUserId, accountId, entId int6
|
|
|
}
|
|
|
}
|
|
|
//企业管理员
|
|
|
- <span class="cov8" title="1">if ent.EntRoleId == 1 && ((ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 && entniche.PowerSource == 0)) </span><span class="cov8" title="1">{
|
|
|
+ <span class="cov0" title="0">if ent.EntRoleId == 1 && ((ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 && entniche.PowerSource == 0)) </span><span class="cov0" title="0">{
|
|
|
ent.EntSubscribeManager = 1
|
|
|
}</span>
|
|
|
//部门管理员
|
|
|
- <span class="cov8" title="1">if ent.EntRoleId == 2 && entniche.Status == 1 && entniche.PowerSource == 0 && ent.DeptSubscribe == 1 </span><span class="cov0" title="0">{
|
|
|
+ <span class="cov0" title="0">if ent.EntRoleId == 2 && entniche.Status == 1 && entniche.PowerSource == 0 && ent.DeptSubscribe == 1 </span><span class="cov0" title="0">{
|
|
|
ent.EntSubscribeManager = 1
|
|
|
}</span>
|
|
|
//
|
|
|
- <span class="cov8" title="1">if ent.EntRoleId == 1 || ent.EntRoleId == 2 </span><span class="cov8" title="1">{
|
|
|
- if (ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 && entniche.PowerSource == 0) </span><span class="cov8" title="1">{
|
|
|
+ <span class="cov0" title="0">if ent.EntRoleId == 1 || ent.EntRoleId == 2 </span><span class="cov0" title="0">{
|
|
|
+ if (ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 && entniche.PowerSource == 0) </span><span class="cov0" title="0">{
|
|
|
ent.EntSubscribe = 1
|
|
|
}</span>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//广东移动DICT 用户
|
|
|
- <span class="cov8" title="1">ent.PrivateGD = this.Conn.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) > 0</span>
|
|
|
+ <span class="cov0" title="0">ent.PrivateGD = this.Conn.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) > 0</span>
|
|
|
}
|
|
|
}
|
|
|
- <span class="cov8" title="1">log.Println("vip:", vip)
|
|
|
- log.Println("member:", member)
|
|
|
- log.Println("free:", free)
|
|
|
- log.Println("ent:", ent)
|
|
|
- log.Println("entniche:", entniche)
|
|
|
- return &entity.Power{
|
|
|
- Vip: vip,
|
|
|
- Member: member,
|
|
|
- Free: free,
|
|
|
- Ent: ent,
|
|
|
- Entniche: entniche,
|
|
|
+ <span class="cov0" title="0">if vip.Status <= 0 && member.Status <= 0 && entniche.Status <= 0 </span><span class="cov0" title="0">{
|
|
|
+ free.IsFree = true
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
+ free.IsFree = false
|
|
|
}</span>
|
|
|
}
|
|
|
- <span class="cov0" title="0">return nil</span>
|
|
|
+ <span class="cov0" title="0">userPower = entity.Power{
|
|
|
+ Vip: vip,
|
|
|
+ Member: member,
|
|
|
+ Free: free,
|
|
|
+ Ent: ent,
|
|
|
+ Entniche: entniche,
|
|
|
+ }
|
|
|
+ //存储缓存
|
|
|
+ go func() </span><span class="cov0" title="0">{
|
|
|
+ if bytes, err := json.Marshal(userPower); err == nil && bytes != nil </span><span class="cov0" title="0">{
|
|
|
+ oneDayMore := 60*60*24 + rand.Intn(60*60)
|
|
|
+ _ = redis.PutBytes("newother", GetRedisName(positionId), &bytes, oneDayMore)
|
|
|
+ }</span>
|
|
|
+ }()
|
|
|
+ <span class="cov0" title="0">return &userPower</span>
|
|
|
}
|
|
|
|
|
|
//免费用户体验会员功能权限
|
|
|
//免费用户在企业画像/采购单位画像/附件下载留资 留资成功后用户才有功能使用次数
|
|
|
-func FreeExperience(userId string) (int, int, int) <span class="cov8" title="1">{
|
|
|
+func FreeExperience(userId string) (int, int, int) <span class="cov0" title="0">{
|
|
|
return redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheEntPortKey, userId)),
|
|
|
redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheBuyerPortKey, userId)),
|
|
|
redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheFileKey, userId))
|
|
|
}</span>
|
|
|
+
|
|
|
+/*
|
|
|
+判断是企业或个人
|
|
|
+1.企业
|
|
|
+ entniche_rule
|
|
|
+ 查询 vip/member free ent entniche
|
|
|
+2.个人
|
|
|
+ 查询vip member free
|
|
|
+*/
|
|
|
+
|
|
|
+func (this *PowerService) GetEntnicheUserId(entId int64, phone string) int64 <span class="cov0" title="0">{
|
|
|
+ data := this.Conn.Mysql.SelectBySql(`select id from entniche_user where phone =? and ent_id =?`, phone, entId)
|
|
|
+ if data != nil && len(*data) > 0 </span><span class="cov0" title="0">{
|
|
|
+ return common.Int64All((*data)[0]["id"])
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">return -1</span>
|
|
|
+}
|
|
|
+
|
|
|
+//是否有关键词
|
|
|
+func HasKey(a_items []map[string]interface{}) bool <span class="cov0" title="0">{
|
|
|
+ for _, v := range a_items </span><span class="cov0" title="0">{
|
|
|
+ akey, _ := v["a_key"].([]interface{})
|
|
|
+ if len(akey) > 0 </span><span class="cov0" title="0">{
|
|
|
+ return true
|
|
|
+ }</span>
|
|
|
+ }
|
|
|
+ <span class="cov0" title="0">return false</span>
|
|
|
+}
|
|
|
+
|
|
|
+//获取redis key
|
|
|
+func GetRedisName(positionId int64) string <span class="cov8" title="1">{
|
|
|
+ if positionId == 0 </span><span class="cov0" title="0">{
|
|
|
+ return ""
|
|
|
+ }</span>
|
|
|
+ <span class="cov8" title="1">return fmt.Sprintf("user_power_info_%v", positionId)</span>
|
|
|
+}
|
|
|
+
|
|
|
+//清除redis缓存
|
|
|
+func (this *PowerService) DelRedisPower(positionId int64) bool <span class="cov0" title="0">{
|
|
|
+ if positionId == 0 </span><span class="cov0" title="0">{
|
|
|
+ return false
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">return redis.Del("newother", GetRedisName(positionId))</span>
|
|
|
+}
|
|
|
</pre>
|
|
|
|
|
|
</div>
|