coverage.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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 (6.1%)</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. "encoding/json"
  68. "fmt"
  69. "log"
  70. "math/rand"
  71. "strings"
  72. "time"
  73. "app.yhyue.com/moapp/jybase/common"
  74. "app.yhyue.com/moapp/jybase/date"
  75. "app.yhyue.com/moapp/jybase/redis"
  76. "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/entity"
  77. )
  78. //权益
  79. type PowerService struct {
  80. *entity.Conn
  81. }
  82. //
  83. func NewPower(conn *entity.Conn) *PowerService <span class="cov8" title="1">{
  84. return &amp;PowerService{
  85. conn,
  86. }
  87. }</span>
  88. var level_map = map[int64]string{
  89. 1: "专家版",
  90. 2: "智慧版",
  91. 3: "商机版",
  92. 4: "试用版",
  93. 5: "自定义",
  94. 6: "商机版2.0",
  95. 7: "专家版2.0",
  96. }
  97. /*
  98. 权益相关
  99. userid //mongodb用户id
  100. baseUserId //base_user用户id
  101. accountId //账户id
  102. entId =5; //企业id
  103. positionType //职位类型 0个人 1企业
  104. positionId //职位id
  105. 切换到企业身份后,session中userId存的是企业雇员的职位id,个人身份,userId还是原来mgo库里的_id
  106. */
  107. func (this *PowerService) Power(userid string, baseUserId, accountId, entId, positionType, positionId int64) *entity.Power <span class="cov8" title="1">{
  108. ent := &amp;entity.Ent{}
  109. entniche := &amp;entity.Entniche{}
  110. vip := &amp;entity.Vip{}
  111. member := &amp;entity.Member{}
  112. free := &amp;entity.Free{}
  113. userPower := entity.Power{}
  114. if bytes, err := redis.GetBytes("newother", GetRedisName(positionId)); err == nil &amp;&amp; bytes != nil </span><span class="cov8" title="1">{
  115. if err := json.Unmarshal(*bytes, &amp;userPower); err == nil </span><span class="cov8" title="1">{
  116. return &amp;userPower
  117. }</span>
  118. }
  119. <span class="cov0" title="0">log.Println("##########", redis.Get("newother", "zxl"))
  120. //获取用户本身的注册时间和邮箱、这个与个人、企业无关
  121. mgoUserFields := map[string]interface{}{
  122. "s_myemail": 1,
  123. "l_registedate": 1,
  124. "s_phone": 1,
  125. "s_m_phone": 1,
  126. "base_user_id": 1,
  127. }
  128. //大会员权益表查询条件
  129. bigmemberServiceUserQuery := map[string]interface{}{"s_userid": userid, "i_status": 0}
  130. //个人身份 取user表中权益
  131. if positionType == 0 </span><span class="cov0" title="0">{
  132. mgoUserFields["i_vip_status"] = 1
  133. mgoUserFields["l_vip_starttime"] = 1
  134. mgoUserFields["l_vip_endtime"] = 1
  135. mgoUserFields["o_vipjy"] = 1
  136. mgoUserFields["i_member_status"] = 1
  137. mgoUserFields["i_member_give"] = 1
  138. mgoUserFields["s_member_mainid"] = 1
  139. mgoUserFields["i_member_sub_status"] = 1
  140. mgoUserFields["i_member_trial"] = 1
  141. mgoUserFields["o_member_jy"] = 1
  142. mgoUserFields["o_jy"] = 1
  143. mgoUserFields["i_ts_guide"] = 1
  144. mgoUserFields["i_member_apppushunread"] = 1
  145. mgoUserFields["i_entniche_apppushunread"] = 1
  146. mgoUserFields["i_apppushunread"] = 1
  147. }</span> else<span class="cov0" title="0"> {
  148. bigmemberServiceUserQuery["s_userid"] = positionId
  149. }</span>
  150. <span class="cov0" title="0">data, ok := this.Conn.MgoJy.FindById("user", userid, mgoUserFields)
  151. if ok &amp;&amp; data != nil &amp;&amp; len(*data) &gt; 0 </span><span class="cov0" title="0">{
  152. //基本信息
  153. registeDate := common.Int64All((*data)["l_registedate"]) //注册时间
  154. phone, _ := common.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string) //
  155. mail := common.ObjToString((*data)["s_myemail"])
  156. i_ts_guide := common.Int64All((*data)["i_ts_guide"])
  157. i_member_apppushunread := common.Int64All((*data)["i_member_apppushunread"])
  158. i_entniche_apppushunread := common.Int64All((*data)["i_entniche_apppushunread"])
  159. i_apppushunread := common.Int64All((*data)["i_apppushunread"])
  160. free.Mail = mail
  161. free.Registedate = registeDate
  162. free.Phone = phone
  163. free.TsGuide = i_ts_guide
  164. free.Apppushunread = i_apppushunread
  165. free.EntnicheApppushunread = i_entniche_apppushunread
  166. free.MemberApppushunread = i_member_apppushunread
  167. //个人权益
  168. if positionType == 0 </span><span class="cov0" title="0">{
  169. o_jy, _ := (*data)["o_jy"].(map[string]interface{})
  170. a_key, _ := o_jy["a_key"].([]interface{})
  171. free.FreeHasKey = len(a_key) &gt; 0
  172. if common.IntAll((o_jy)["i_newfree"]) &gt; 0 || entity.IsNewFreeTimeCell &lt; registeDate </span><span class="cov0" title="0">{
  173. //IsNewFreeTimeCell dev3.6.4版本之前发了个紧急版本处理老用户订阅问题,i_newfree字段必须用户选择地区才能生成,不能作为判断是否是新用户得唯一标识,在此版本添加了常量:IsNewFreeTimeCell作为判断标准;--ws
  174. free.IsUpgrade = true //新免费用户
  175. }</span>
  176. //超级订阅
  177. <span class="cov0" title="0">vipStatus := common.Int64All((*data)["i_vip_status"])
  178. vipStartTime := common.Int64All((*data)["l_vip_starttime"])
  179. vipEndTime := common.Int64All((*data)["l_vip_endtime"])
  180. ovipjy := common.ObjToMap((*data)["o_vipjy"])
  181. oBuyset := common.ObjToMap((*ovipjy)["o_buyset"])
  182. upgrade := common.Int64All((*oBuyset)["upgrade"])
  183. areacount := common.Int64All((*oBuyset)["areacount"])
  184. buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
  185. vip = &amp;entity.Vip{
  186. Status: vipStatus,
  187. StartTime: vipStartTime,
  188. EndTime: vipEndTime,
  189. Upgrade: upgrade,
  190. Areacount: areacount,
  191. Buyerclasscount: buyerclasscount,
  192. MaxKeyLength: 300,
  193. PowerType: common.Int64All(common.If(vipStatus &gt; 0, 1, 0)),
  194. //TODO 附件下载次数
  195. }
  196. if (*ovipjy)["a_items"] != nil </span><span class="cov0" title="0">{
  197. a_items := common.ObjArrToMapArr((*ovipjy)["a_items"].([]interface{}))
  198. vip.HasKey = HasKey(a_items)
  199. }</span>
  200. //个人member
  201. <span class="cov0" title="0">i_member_sub_status := common.IntAllDef((*data)["i_member_sub_status"], 0)
  202. memberStatus := common.Int64All((*data)["i_member_status"])
  203. memberStarttime := common.Int64All((*data)["i_member_starttime"])
  204. memberEndtime := common.Int64All((*data)["i_member_endtime"])
  205. member = &amp;entity.Member{
  206. Status: memberStatus,
  207. StartTime: memberStarttime,
  208. EndTime: memberEndtime,
  209. MaxKeyLength: 300, //最大关键词数量限制
  210. PowerType: common.Int64All(common.If(memberStatus &gt; 0, 1, 0)),
  211. }
  212. omemberjy := common.ObjToMap((*data)["o_member_jy"])
  213. if (*omemberjy)["a_items"] != nil </span><span class="cov0" title="0">{
  214. if arr, ok := (*omemberjy)["a_items"].([]interface{}); ok </span><span class="cov0" title="0">{
  215. a_items := common.ObjArrToMapArr(arr)
  216. member.HasKey = HasKey(a_items)
  217. }</span>
  218. }
  219. <span class="cov0" title="0">if memberStatus &gt; 0 </span><span class="cov0" title="0">{
  220. member.MemberPower = 1 //是否分配了大会员;0:否 1:是
  221. }</span>
  222. <span class="cov0" title="0">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">{
  223. member.Pid = common.ObjToString((*data)["s_member_mainid"])
  224. member.IsSubCount = 1
  225. }</span>
  226. <span class="cov0" title="0">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="cov0" title="0">{
  227. member.Used = true
  228. }</span>
  229. <span class="cov0" title="0">if (*data)["i_member_trial"] != nil </span><span class="cov0" title="0">{
  230. member.IsMemberTrial = 1
  231. }</span>
  232. //获取大会员版本名称
  233. <span class="cov0" title="0">member.MemberName = level_map[memberStatus]</span>
  234. } else<span class="cov0" title="0"> if positionType == 1 </span><span class="cov0" title="0">{
  235. entnicheUserId := this.GetEntnicheUserId(entId, phone)
  236. //免费
  237. fdata, ok := this.Conn.MgoJy.FindOne("entniche_rule", map[string]interface{}{
  238. "i_ent": entId,
  239. "i_userid": entnicheUserId,
  240. "i_type": 2, //0:商机管理 1:超级订阅/大会员 2:免费
  241. })
  242. o_jy, _ := (*fdata)["o_entniche"].(map[string]interface{})
  243. a_key, _ := o_jy["a_key"].([]interface{})
  244. free.FreeHasKey = len(a_key) &gt; 0
  245. if common.IntAll((o_jy)["i_newfree"]) &gt; 0 || entity.IsNewFreeTimeCell &lt; registeDate </span><span class="cov0" title="0">{ //IsNewFreeTimeCell dev3.6.4版本之前发了个紧急版本处理老用户订阅问题,i_newfree字段必须用户选择地区才能生成,不能作为判断是否是新用户得唯一标识,在此版本添加了常量:IsNewFreeTimeCell作为判断标准;--ws
  246. free.IsUpgrade = true //新免费用户
  247. }</span>
  248. //企业
  249. <span class="cov0" title="0">edata, ok := this.Conn.MgoJy.FindOne("entniche_rule", map[string]interface{}{
  250. "i_ent": entId,
  251. "i_userid": entnicheUserId,
  252. "i_type": 1, //0:商机管理 1:超级订阅/大会员
  253. "l_endtime": map[string]interface{}{
  254. "$gt": time.Now().Unix(),
  255. },
  256. })
  257. if ok &amp;&amp; edata != nil &amp;&amp; len(*edata) &gt; 0 </span><span class="cov0" title="0">{
  258. haskey := false
  259. status := common.Int64All((*edata)["i_status"])
  260. starttime := common.Int64All((*edata)["l_starttime"])
  261. endtime := common.Int64All((*edata)["l_endtime"])
  262. o_entniche := common.ObjToMap((*edata)["o_entniche"])
  263. if (*o_entniche)["a_items"] != nil </span><span class="cov0" title="0">{
  264. if arr, ok := (*o_entniche)["a_items"].([]interface{}); ok </span><span class="cov0" title="0">{
  265. a_items := common.ObjArrToMapArr(arr)
  266. haskey = HasKey(a_items)
  267. }</span>
  268. }
  269. //获取用户是什么版本权益
  270. //用于判断是否含有企业主体的超级订阅、大会员服务
  271. <span class="cov0" title="0">epowerData := this.Conn.Mysql.SelectBySql(`SELECT c.product_type FROM entniche_user a INNER JOIN entniche_power b
  272. INNER JOIN entniche_wait_empower c
  273. 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 &gt;?`, phone, entId, time.Now().Format(date.Date_Full_Layout))
  274. if epowerData != nil &amp;&amp; len(*epowerData) &gt; 0 </span><span class="cov0" title="0">{
  275. for _, v := range *epowerData </span><span class="cov0" title="0">{
  276. product_type := common.ObjToString(v["product_type"])
  277. if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
  278. oBuyset := common.ObjToMap((*o_entniche)["o_buyset"])
  279. upgrade := common.Int64All((*oBuyset)["oBuyset"])
  280. areacount := common.Int64All((*oBuyset)["areacount"])
  281. buyerclasscount := common.Int64All((*oBuyset)["buyerclasscount"])
  282. vip = &amp;entity.Vip{
  283. Status: status,
  284. StartTime: starttime,
  285. EndTime: endtime,
  286. Upgrade: upgrade,
  287. Areacount: areacount,
  288. Buyerclasscount: buyerclasscount,
  289. MaxKeyLength: 300,
  290. PowerType: 2,
  291. HasKey: haskey,
  292. }
  293. }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
  294. member.PowerType = 2
  295. member = &amp;entity.Member{
  296. Status: status,
  297. StartTime: starttime,
  298. EndTime: endtime,
  299. MemberName: level_map[status],
  300. PowerType: 2,
  301. HasKey: haskey,
  302. }
  303. //是否试用
  304. if this.Conn.MgoJy.Count("member", map[string]interface{}{"userid": positionId}) &gt; 0 </span><span class="cov0" title="0">{
  305. member.Used = true
  306. }</span>
  307. }
  308. }
  309. }
  310. }
  311. }
  312. //大会员相关权益数量
  313. <span class="cov0" title="0">memberServiceMap := map[int64]bool{}
  314. serviceList := this.Conn.Mysql.Find("bigmember_service_user", bigmemberServiceUserQuery, "DISTINCT(s_serviceid),i_frequency", "", -1, -1)
  315. if serviceList != nil &amp;&amp; len(*serviceList) != 0 </span><span class="cov0" title="0">{
  316. pCount, eCount, dailyNum, customers := 0, 0, 0, 10
  317. for _, item := range *serviceList </span><span class="cov0" title="0">{
  318. serviceid := common.Int64All(item["s_serviceid"])
  319. memberServiceMap[serviceid] = true
  320. member.MemberPowerList = append(member.MemberPowerList, serviceid)
  321. if serviceid == 14 </span><span class="cov0" title="0">{ //项目数量
  322. pCount = common.IntAll(item["i_frequency"])
  323. }</span> else<span class="cov0" title="0"> if serviceid == 4 || serviceid == 12 || serviceid == 13 </span><span class="cov0" title="0">{ //企业情报监控 企业中标动态
  324. tEcount := common.IntAll(item["i_frequency"])
  325. if tEcount &gt; eCount </span><span class="cov0" title="0">{
  326. eCount = tEcount
  327. }</span>
  328. } else<span class="cov0" title="0"> if serviceid == 17 || serviceid == 18 </span><span class="cov0" title="0">{ //每日数据包
  329. dailyNum = common.IntAll(item["i_frequency"])
  330. }</span> else<span class="cov0" title="0"> if serviceid == 7 </span><span class="cov0" title="0">{ //潜在客户 关注客户
  331. customers = common.IntAll(item["i_frequency"])
  332. }</span>
  333. }
  334. <span class="cov0" title="0">member.EntNum = int64(eCount)
  335. member.ProNum = int64(pCount)
  336. member.DailyNum = int64(dailyNum)
  337. member.Customers = int64(customers)</span>
  338. }
  339. //
  340. <span class="cov0" title="0">if phone != "" </span><span class="cov0" title="0">{
  341. //查询是否是商机管理付费用户
  342. 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)
  343. if res != nil &amp;&amp; len(*res) &gt; 0 </span><span class="cov0" title="0">{
  344. for _, v := range *res </span><span class="cov0" title="0">{
  345. if common.IntAll(v["id"]) == 0 </span><span class="cov0" title="0">{
  346. continue</span>
  347. }
  348. <span class="cov0" title="0">entniche.IsNew = common.Int64All(v["isNew"])
  349. entniche.Status = common.Int64All(v["status"])
  350. entniche.IsEntPower = common.Int64All(v["power"])
  351. entniche.PowerSource = common.Int64All(v["power_source"])
  352. entniche.StartTime = common.Int64All(v["startdate"])
  353. entniche.EndTime = common.Int64All(v["enddate"])
  354. //
  355. ent.Name = common.ObjToString(v["name"])
  356. ent.EntRoleId = common.Int64All(v["role_id"])
  357. ent.EntAuthStatus = common.Int64All(v["auth_status"])
  358. ent.EntAuthReason = common.ObjToString(v["auth_reason"])
  359. ent.DeptSubscribe = common.Int64All(v["dept_subscribe"])
  360. //判断企业是否购买企业版相关
  361. 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))
  362. if eweData != nil &amp;&amp; len(*eweData) &gt; 0 </span><span class="cov0" title="0">{
  363. for _, v := range *eweData </span><span class="cov0" title="0">{
  364. product_type := common.ObjToString(v["product_type"])
  365. if strings.Contains(product_type, entity.ProductType_member) </span><span class="cov0" title="0">{
  366. ent.BuyMember = 1
  367. }</span> else<span class="cov0" title="0"> if strings.Contains(product_type, entity.ProductType_vip) </span><span class="cov0" title="0">{
  368. ent.BuyVip = 1
  369. }</span>
  370. }
  371. }
  372. //企业管理员
  373. <span class="cov0" title="0">if ent.EntRoleId == 1 &amp;&amp; ((ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 &amp;&amp; entniche.PowerSource == 0)) </span><span class="cov0" title="0">{
  374. ent.EntSubscribeManager = 1
  375. }</span>
  376. //部门管理员
  377. <span class="cov0" title="0">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">{
  378. ent.EntSubscribeManager = 1
  379. }</span>
  380. //
  381. <span class="cov0" title="0">if ent.EntRoleId == 1 || ent.EntRoleId == 2 </span><span class="cov0" title="0">{
  382. if (ent.BuyMember == 1 || ent.BuyVip == 1) || (entniche.Status == 1 &amp;&amp; entniche.PowerSource == 0) </span><span class="cov0" title="0">{
  383. ent.EntSubscribe = 1
  384. }</span>
  385. }
  386. }
  387. //广东移动DICT 用户
  388. <span class="cov0" title="0">ent.PrivateGD = this.Conn.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) &gt; 0</span>
  389. }
  390. }
  391. <span class="cov0" title="0">if vip.Status &lt;= 0 &amp;&amp; member.Status &lt;= 0 &amp;&amp; entniche.Status &lt;= 0 </span><span class="cov0" title="0">{
  392. free.IsFree = true
  393. }</span> else<span class="cov0" title="0"> {
  394. free.IsFree = false
  395. }</span>
  396. }
  397. <span class="cov0" title="0">userPower = entity.Power{
  398. Vip: vip,
  399. Member: member,
  400. Free: free,
  401. Ent: ent,
  402. Entniche: entniche,
  403. }
  404. //存储缓存
  405. go func() </span><span class="cov0" title="0">{
  406. if bytes, err := json.Marshal(userPower); err == nil &amp;&amp; bytes != nil </span><span class="cov0" title="0">{
  407. oneDayMore := 60*60*24 + rand.Intn(60*60)
  408. _ = redis.PutBytes("newother", GetRedisName(positionId), &amp;bytes, oneDayMore)
  409. }</span>
  410. }()
  411. <span class="cov0" title="0">return &amp;userPower</span>
  412. }
  413. //免费用户体验会员功能权限
  414. //免费用户在企业画像/采购单位画像/附件下载留资 留资成功后用户才有功能使用次数
  415. func FreeExperience(userId string) (int, int, int) <span class="cov0" title="0">{
  416. return redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheEntPortKey, userId)),
  417. redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheBuyerPortKey, userId)),
  418. redis.GetInt(entity.PowerCacheDb, fmt.Sprintf(entity.PowerCacheFileKey, userId))
  419. }</span>
  420. /*
  421. 判断是企业或个人
  422. 1.企业
  423. entniche_rule
  424. 查询 vip/member free ent entniche
  425. 2.个人
  426. 查询vip member free
  427. */
  428. func (this *PowerService) GetEntnicheUserId(entId int64, phone string) int64 <span class="cov0" title="0">{
  429. data := this.Conn.Mysql.SelectBySql(`select id from entniche_user where phone =? and ent_id =?`, phone, entId)
  430. if data != nil &amp;&amp; len(*data) &gt; 0 </span><span class="cov0" title="0">{
  431. return common.Int64All((*data)[0]["id"])
  432. }</span>
  433. <span class="cov0" title="0">return -1</span>
  434. }
  435. //是否有关键词
  436. func HasKey(a_items []map[string]interface{}) bool <span class="cov0" title="0">{
  437. for _, v := range a_items </span><span class="cov0" title="0">{
  438. akey, _ := v["a_key"].([]interface{})
  439. if len(akey) &gt; 0 </span><span class="cov0" title="0">{
  440. return true
  441. }</span>
  442. }
  443. <span class="cov0" title="0">return false</span>
  444. }
  445. //获取redis key
  446. func GetRedisName(positionId int64) string <span class="cov8" title="1">{
  447. if positionId == 0 </span><span class="cov0" title="0">{
  448. return ""
  449. }</span>
  450. <span class="cov8" title="1">return fmt.Sprintf("user_power_info_%v", positionId)</span>
  451. }
  452. //清除redis缓存
  453. func (this *PowerService) DelRedisPower(positionId int64) bool <span class="cov0" title="0">{
  454. if positionId == 0 </span><span class="cov0" title="0">{
  455. return false
  456. }</span>
  457. <span class="cov0" title="0">return redis.Del("newother", GetRedisName(positionId))</span>
  458. }
  459. </pre>
  460. </div>
  461. </body>
  462. <script>
  463. (function() {
  464. var files = document.getElementById('files');
  465. var visible;
  466. files.addEventListener('change', onChange, false);
  467. function select(part) {
  468. if (visible)
  469. visible.style.display = 'none';
  470. visible = document.getElementById(part);
  471. if (!visible)
  472. return;
  473. files.value = part;
  474. visible.style.display = 'block';
  475. location.hash = part;
  476. }
  477. function onChange() {
  478. select(files.value);
  479. window.scrollTo(0, 0);
  480. }
  481. if (location.hash != "") {
  482. select(location.hash.substr(1));
  483. }
  484. if (!visible) {
  485. select("file0");
  486. }
  487. })();
  488. </script>
  489. </html>