coverage.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>service: Go Coverage Report</title>
  6. <style>
  7. body {
  8. background: black;
  9. color: rgb(80, 80, 80);
  10. }
  11. body, pre, #legend span {
  12. font-family: Menlo, monospace;
  13. font-weight: bold;
  14. }
  15. #topbar {
  16. background: black;
  17. position: fixed;
  18. top: 0; left: 0; right: 0;
  19. height: 42px;
  20. border-bottom: 1px solid rgb(80, 80, 80);
  21. }
  22. #content {
  23. margin-top: 50px;
  24. }
  25. #nav, #legend {
  26. float: left;
  27. margin-left: 10px;
  28. }
  29. #legend {
  30. margin-top: 12px;
  31. }
  32. #nav {
  33. margin-top: 10px;
  34. }
  35. #legend span {
  36. margin: 0 5px;
  37. }
  38. .cov0 { color: rgb(192, 0, 0) }
  39. .cov1 { color: rgb(128, 128, 128) }
  40. .cov2 { color: rgb(116, 140, 131) }
  41. .cov3 { color: rgb(104, 152, 134) }
  42. .cov4 { color: rgb(92, 164, 137) }
  43. .cov5 { color: rgb(80, 176, 140) }
  44. .cov6 { color: rgb(68, 188, 143) }
  45. .cov7 { color: rgb(56, 200, 146) }
  46. .cov8 { color: rgb(44, 212, 149) }
  47. .cov9 { color: rgb(32, 224, 152) }
  48. .cov10 { color: rgb(20, 236, 155) }
  49. </style>
  50. </head>
  51. <body>
  52. <div id="topbar">
  53. <div id="nav">
  54. <select id="files">
  55. <option value="file0">bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/service/power.go (64.9%)</option>
  56. </select>
  57. </div>
  58. <div id="legend">
  59. <span>not tracked</span>
  60. <span class="cov0">not covered</span>
  61. <span class="cov8">covered</span>
  62. </div>
  63. </div>
  64. <div id="content">
  65. <pre class="file" id="file0" style="display: none">package service
  66. import (
  67. "fmt"
  68. "log"
  69. "strings"
  70. "time"
  71. "app.yhyue.com/moapp/jybase/common"
  72. "app.yhyue.com/moapp/jybase/date"
  73. "app.yhyue.com/moapp/jybase/redis"
  74. "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/entity"
  75. )
  76. //权益
  77. type PowerService struct {
  78. *entity.Conn
  79. }
  80. //
  81. func NewPower(conn *entity.Conn) *PowerService <span class="cov8" title="1">{
  82. return &amp;PowerService{
  83. conn,
  84. }
  85. }</span>
  86. //权益相关 userid用户mongodbid baseUserId
  87. func (this *PowerService) Power(userid string, baseUserId, accountId, entId int64) *entity.Power <span class="cov8" title="1">{
  88. //获取权益
  89. //大会员状态
  90. 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}`)
  91. if ok &amp;&amp; *data != nil &amp;&amp; len(*data) &gt; 0 </span><span class="cov8" title="1">{
  92. ent := &amp;entity.Ent{}
  93. entniche := &amp;entity.Entniche{}
  94. vip := &amp;entity.Vip{}
  95. member := &amp;entity.Member{}
  96. registeDate := common.Int64All((*data)["l_registedate"]) //注册时间
  97. //VIP
  98. vipStatus := common.Int64All((*data)["i_vip_status"])
  99. vipStartTime := common.Int64All((*data)["l_vip_starttime"])
  100. vipEndTime := common.Int64All((*data)["l_vip_endtime"])
  101. ovipjy := common.ObjToMap((*data)["o_vipjy"])
  102. oBuyset := common.ObjToMap((*ovipjy)["o_buyset"])
  103. upgrade := common.Int64All((*oBuyset)["oBuyset"])
  104. areacount := common.Int64All((*oBuyset)["areacount"])
  105. buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
  106. vip = &amp;entity.Vip{
  107. Status: vipStatus,
  108. StartTime: vipStartTime,
  109. EndTime: vipEndTime,
  110. Upgrade: upgrade,
  111. Areacount: areacount,
  112. Buyerclasscount: buyerclasscount,
  113. MaxKeyLength: 300,
  114. PowerType: common.Int64All(common.If(vipStatus &gt; 0, 1, 0)),
  115. //TODO 附件下载次数
  116. }
  117. //免费相关
  118. free := &amp;entity.Free{}
  119. o_jy, _ := (*data)["o_jy"].(map[string]interface{})
  120. a_key, _ := o_jy["a_key"].([]interface{})
  121. free.FreeHasKey = len(a_key) &gt; 0
  122. //免费用户可查看企业画像次数//免费用户可查看采购单位画像次数//免费用户可以进行附件下载次数
  123. freeEntPort, freeBuyerPort, freeFile := FreeExperience(userid)
  124. free.FreeEntPort, free.FreeBuyerPort, free.FreeFile = int64(freeEntPort), int64(freeBuyerPort), int64(freeFile)
  125. //
  126. //子账号被启用
  127. i_member_sub_status := common.IntAllDef((*data)["i_member_sub_status"], 0)
  128. memberStatus := common.Int64All((*data)["i_member_status"])
  129. memberStarttime := common.Int64All((*data)["i_member_starttime"])
  130. memberEndtime := common.Int64All((*data)["i_member_endtime"])
  131. member = &amp;entity.Member{
  132. Status: memberStatus,
  133. StartTime: memberStarttime,
  134. EndTime: memberEndtime,
  135. MaxKeyLength: 300, //最大关键词数量限制
  136. }
  137. if memberStatus &gt; 0 </span><span class="cov0" title="0">{
  138. member.MemberPower = 1 //是否分配了大会员;0:否 1:是
  139. }</span>
  140. <span class="cov8" title="1">if (*data)["s_member_mainid"] != nil &amp;&amp; common.ObjToString((*data)["s_member_mainid"]) != "" &amp;&amp; i_member_sub_status &gt; 0 </span><span class="cov0" title="0">{
  141. member.Pid = common.ObjToString((*data)["s_member_mainid"])
  142. member.IsSubCount = 1
  143. }</span>
  144. <span class="cov8" title="1">if (member.Pid != "" &amp;&amp; common.IntAllDef((*data)["i_member_sub_status"], 0) == 1) || this.Conn.MgoJy.Count("member", map[string]interface{}{"userid": userid}) &gt; 0 </span><span class="cov8" title="1">{
  145. member.Used = true
  146. }</span>
  147. <span class="cov8" title="1">if (*data)["i_member_trial"] != nil </span><span class="cov0" title="0">{
  148. member.IsMemberTrial = 1
  149. }</span>
  150. //获取大会员版本名称 //TODO 自定义有问题
  151. <span class="cov8" title="1">if combo := this.Conn.Mysql.SelectBySql(`select s_name from bigmember_combo where id=?`, memberStatus); combo != nil &amp;&amp; len(*combo) &gt; 0 </span><span class="cov0" title="0">{
  152. member.MemberName = common.ObjToString((*combo)[0]["s_name"])
  153. }</span>
  154. <span class="cov8" title="1">memberServiceMap := map[int64]bool{}
  155. //获取大会员相关操作
  156. serviceList := this.Conn.Mysql.Find("bigmember_service_user", map[string]interface{}{"s_userid": userid, "i_status": 0}, "DISTINCT(s_serviceid),i_frequency", "", -1, -1)
  157. if serviceList != nil &amp;&amp; len(*serviceList) != 0 </span><span class="cov0" title="0">{
  158. pCount, eCount, dailyNum, customers := 0, 0, 0, 10
  159. for _, item := range *serviceList </span><span class="cov0" title="0">{
  160. serviceid := common.Int64All(item["s_serviceid"])
  161. memberServiceMap[serviceid] = true
  162. member.MemberPowerList = append(member.MemberPowerList, serviceid)
  163. if serviceid == 14 </span><span class="cov0" title="0">{ //项目数量
  164. pCount = common.IntAll(item["i_frequency"])
  165. }</span> else<span class="cov0" title="0"> if serviceid == 4 || serviceid == 12 || serviceid == 13 </span><span class="cov0" title="0">{ //企业情报监控 企业中标动态
  166. tEcount := common.IntAll(item["i_frequency"])
  167. if tEcount &gt; eCount </span><span class="cov0" title="0">{
  168. eCount = tEcount
  169. }</span>
  170. } else<span class="cov0" title="0"> if serviceid == 17 || serviceid == 18 </span><span class="cov0" title="0">{ //每日数据包
  171. dailyNum = common.IntAll(item["i_frequency"])
  172. }</span> else<span class="cov0" title="0"> if serviceid == 7 </span><span class="cov0" title="0">{ //潜在客户 关注客户
  173. customers = common.IntAll(item["i_frequency"])
  174. }</span>
  175. }
  176. <span class="cov0" title="0">member.EntNum = int64(eCount)
  177. member.ProNum = int64(pCount)
  178. member.DailyNum = int64(dailyNum)
  179. member.Customers = int64(customers)</span>
  180. }
  181. //
  182. <span class="cov8" title="1">phone, _ := common.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string)
  183. if phone != "" </span><span class="cov8" title="1">{
  184. //用于判断是否含有企业主体的超级订阅、大会员服务
  185. epowerData := this.Conn.Mysql.SelectBySql(`SELECT c.product_type FROM entniche_user a INNER JOIN entniche_power b
  186. INNER JOIN entniche_wait_empower c
  187. ON a.id =b.ent_user_id AND c.id = b.wait_empower_id WHERE a.phone =? AND c.end_time &gt;?`, phone, time.Now().Format(date.Date_Full_Layout))
  188. if epowerData != nil &amp;&amp; len(*epowerData) &gt; 0 </span><span class="cov0" title="0">{
  189. for _, v := range *epowerData </span><span class="cov0" title="0">{
  190. product_type := common.ObjToString(v["product_type"])
  191. if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
  192. vip.PowerType = 2
  193. }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
  194. member.PowerType = 2
  195. }</span>
  196. }
  197. }
  198. //免费用户画像和附件下载权限
  199. <span class="cov8" title="1">o_jy := common.ObjToMap((*data)["o_jy"])
  200. //IsNewFreeTimeCell dev3.6.4版本之前发了个紧急版本处理老用户订阅问题,i_newfree字段必须用户选择地区才能生成,不能作为判断是否是新用户得唯一标识,在此版本添加了常量:IsNewFreeTimeCell作为判断标准;--ws
  201. if common.IntAll((*o_jy)["i_newfree"]) &gt; 0 || entity.IsNewFreeTimeCell &lt; registeDate </span><span class="cov0" title="0">{
  202. free.IsUpgrade = true //新免费用户
  203. }</span>
  204. //查询是否是商机管理付费用户
  205. <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)
  206. if res != nil &amp;&amp; len(*res) &gt; 0 </span><span class="cov8" title="1">{
  207. for _, v := range *res </span><span class="cov8" title="1">{
  208. if common.IntAll(v["id"]) == 0 </span><span class="cov0" title="0">{
  209. continue</span>
  210. }
  211. <span class="cov8" title="1">entniche.IsNew = common.Int64All(v["isNew"])
  212. entniche.Status = common.Int64All(v["status"])
  213. entniche.IsEntPower = common.Int64All(v["power"])
  214. entniche.PowerSource = common.Int64All(v["power_source"])
  215. entniche.StartTime = common.Int64All(v["startdate"])
  216. entniche.EndTime = common.Int64All(v["enddate"])
  217. //
  218. ent.Name = common.ObjToString((*res)[0]["name"])
  219. ent.EntRoleId = common.Int64All(v["role_id"])
  220. ent.EntAuthStatus = common.Int64All(v["auth_status"])
  221. ent.EntAuthReason = common.ObjToString(v["auth_reason"])
  222. ent.DeptSubscribe = common.Int64All(v["dept_subscribe"])
  223. //判断企业是否购买企业版相关
  224. eweData := this.Conn.Mysql.SelectBySql(`select * from entniche_wait_empower where ent_id=? and end_time&gt;?`, entId, time.Now().Format(date.Date_Full_Layout))
  225. if eweData != nil &amp;&amp; len(*eweData) &gt; 0 </span><span class="cov0" title="0">{
  226. for _, v := range *eweData </span><span class="cov0" title="0">{
  227. product_type := common.ObjToString(v["product_type"])
  228. if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
  229. ent.BuyMember = 1
  230. }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
  231. ent.BuyVip = 1
  232. }</span>
  233. }
  234. }
  235. //企业管理员
  236. <span class="cov8" title="1">if ent.EntRoleId == 1 &amp;&amp; ((ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 &amp;&amp; entniche.PowerSource == 0)) </span><span class="cov8" title="1">{
  237. ent.EntSubscribeManager = 1
  238. }</span>
  239. //部门管理员
  240. <span class="cov8" title="1">if ent.EntRoleId == 2 &amp;&amp; entniche.Status == 1 &amp;&amp; entniche.PowerSource == 0 &amp;&amp; ent.DeptSubscribe == 1 </span><span class="cov0" title="0">{
  241. ent.EntSubscribeManager = 1
  242. }</span>
  243. //
  244. <span class="cov8" title="1">if ent.EntRoleId == 1 || ent.EntRoleId == 2 </span><span class="cov8" title="1">{
  245. if (ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 &amp;&amp; entniche.PowerSource == 0) </span><span class="cov8" title="1">{
  246. ent.EntSubscribe = 1
  247. }</span>
  248. }
  249. }
  250. //广东移动DICT 用户
  251. <span class="cov8" title="1">ent.PrivateGD = this.Conn.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) &gt; 0</span>
  252. }
  253. }
  254. <span class="cov8" title="1">log.Println("vip:", vip)
  255. log.Println("member:", member)
  256. log.Println("free:", free)
  257. log.Println("ent:", ent)
  258. log.Println("entniche:", entniche)
  259. return &amp;entity.Power{
  260. Vip: vip,
  261. Member: member,
  262. Free: free,
  263. Ent: ent,
  264. Entniche: entniche,
  265. }</span>
  266. }
  267. <span class="cov0" title="0">return nil</span>
  268. }
  269. //免费用户体验会员功能权限
  270. //免费用户在企业画像/采购单位画像/附件下载留资 留资成功后用户才有功能使用次数
  271. func FreeExperience(userId string) (int, int, int) <span class="cov8" title="1">{
  272. return redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheEntPortKey, userId)),
  273. redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheBuyerPortKey, userId)),
  274. redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheFileKey, userId))
  275. }</span>
  276. </pre>
  277. </div>
  278. </body>
  279. <script>
  280. (function() {
  281. var files = document.getElementById('files');
  282. var visible;
  283. files.addEventListener('change', onChange, false);
  284. function select(part) {
  285. if (visible)
  286. visible.style.display = 'none';
  287. visible = document.getElementById(part);
  288. if (!visible)
  289. return;
  290. files.value = part;
  291. visible.style.display = 'block';
  292. location.hash = part;
  293. }
  294. function onChange() {
  295. select(files.value);
  296. window.scrollTo(0, 0);
  297. }
  298. if (location.hash != "") {
  299. select(location.hash.substr(1));
  300. }
  301. if (!visible) {
  302. select("file0");
  303. }
  304. })();
  305. </script>
  306. </html>