power.go 19 KB

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