123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>service: Go Coverage Report</title>
- <style>
- body {
- background: black;
- color: rgb(80, 80, 80);
- }
- body, pre, #legend span {
- font-family: Menlo, monospace;
- font-weight: bold;
- }
- #topbar {
- background: black;
- position: fixed;
- top: 0; left: 0; right: 0;
- height: 42px;
- border-bottom: 1px solid rgb(80, 80, 80);
- }
- #content {
- margin-top: 50px;
- }
- #nav, #legend {
- float: left;
- margin-left: 10px;
- }
- #legend {
- margin-top: 12px;
- }
- #nav {
- margin-top: 10px;
- }
- #legend span {
- margin: 0 5px;
- }
- .cov0 { color: rgb(192, 0, 0) }
- .cov1 { color: rgb(128, 128, 128) }
- .cov2 { color: rgb(116, 140, 131) }
- .cov3 { color: rgb(104, 152, 134) }
- .cov4 { color: rgb(92, 164, 137) }
- .cov5 { color: rgb(80, 176, 140) }
- .cov6 { color: rgb(68, 188, 143) }
- .cov7 { color: rgb(56, 200, 146) }
- .cov8 { color: rgb(44, 212, 149) }
- .cov9 { color: rgb(32, 224, 152) }
- .cov10 { color: rgb(20, 236, 155) }
- </style>
- </head>
- <body>
- <div id="topbar">
- <div id="nav">
- <select id="files">
-
- <option value="file0">bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/service/power.go (64.9%)</option>
-
- </select>
- </div>
- <div id="legend">
- <span>not tracked</span>
-
- <span class="cov0">not covered</span>
- <span class="cov8">covered</span>
-
- </div>
- </div>
- <div id="content">
-
- <pre class="file" id="file0" style="display: none">package service
- import (
- "fmt"
- "log"
- "strings"
- "time"
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/date"
- "app.yhyue.com/moapp/jybase/redis"
- "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/entity"
- )
- //权益
- type PowerService struct {
- *entity.Conn
- }
- //
- func NewPower(conn *entity.Conn) *PowerService <span class="cov8" title="1">{
- return &PowerService{
- conn,
- }
- }</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">{
- 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)
- 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, //最大关键词数量限制
- }
- 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)
- 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">{
- serviceid := common.Int64All(item["s_serviceid"])
- memberServiceMap[serviceid] = true
- member.MemberPowerList = append(member.MemberPowerList, serviceid)
- if serviceid == 14 </span><span class="cov0" title="0">{ //项目数量
- pCount = common.IntAll(item["i_frequency"])
- }</span> else<span class="cov0" title="0"> if serviceid == 4 || serviceid == 12 || serviceid == 13 </span><span class="cov0" title="0">{ //企业情报监控 企业中标动态
- tEcount := common.IntAll(item["i_frequency"])
- if tEcount > eCount </span><span class="cov0" title="0">{
- eCount = tEcount
- }</span>
- } else<span class="cov0" title="0"> if serviceid == 17 || serviceid == 18 </span><span class="cov0" title="0">{ //每日数据包
- dailyNum = common.IntAll(item["i_frequency"])
- }</span> else<span class="cov0" title="0"> if serviceid == 7 </span><span class="cov0" title="0">{ //潜在客户 关注客户
- customers = common.IntAll(item["i_frequency"])
- }</span>
- }
- <span class="cov0" title="0">member.EntNum = int64(eCount)
- member.ProNum = int64(pCount)
- member.DailyNum = int64(dailyNum)
- 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="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">{
- 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"])
- 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.EntRoleId = common.Int64All(v["role_id"])
- ent.EntAuthStatus = common.Int64All(v["auth_status"])
- ent.EntAuthReason = common.ObjToString(v["auth_reason"])
- ent.DeptSubscribe = common.Int64All(v["dept_subscribe"])
- //判断企业是否购买企业版相关
- eweData := this.Conn.Mysql.SelectBySql(`select * from entniche_wait_empower where ent_id=? and end_time>?`, entId, time.Now().Format(date.Date_Full_Layout))
- if eweData != nil && len(*eweData) > 0 </span><span class="cov0" title="0">{
- for _, v := range *eweData </span><span class="cov0" title="0">{
- product_type := common.ObjToString(v["product_type"])
- if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
- ent.BuyMember = 1
- }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
- ent.BuyVip = 1
- }</span>
- }
- }
- //企业管理员
- <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">{
- 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">{
- 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">{
- 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="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>
- }
- <span class="cov0" title="0">return nil</span>
- }
- //免费用户体验会员功能权限
- //免费用户在企业画像/采购单位画像/附件下载留资 留资成功后用户才有功能使用次数
- func FreeExperience(userId string) (int, int, int) <span class="cov8" title="1">{
- 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>
- </pre>
-
- </div>
- </body>
- <script>
- (function() {
- var files = document.getElementById('files');
- var visible;
- files.addEventListener('change', onChange, false);
- function select(part) {
- if (visible)
- visible.style.display = 'none';
- visible = document.getElementById(part);
- if (!visible)
- return;
- files.value = part;
- visible.style.display = 'block';
- location.hash = part;
- }
- function onChange() {
- select(files.value);
- window.scrollTo(0, 0);
- }
- if (location.hash != "") {
- select(location.hash.substr(1));
- }
- if (!visible) {
- select("file0");
- }
- })();
- </script>
- </html>
|