service.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. package service
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "log"
  6. "strconv"
  7. "strings"
  8. "time"
  9. "context"
  10. "app.yhyue.com/moapp/jybase/mongodb"
  11. . "bp.jydev.jianyu360.cn/BaseService/entManageApplication/entity"
  12. "bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/entmanageapplication"
  13. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
  14. // "github.com/zeromicro/go-zero/core/logx"
  15. "app.yhyue.com/moapp/jybase/common"
  16. "app.yhyue.com/moapp/jybase/redis"
  17. )
  18. func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplication.AddUsePersonResp {
  19. timeStr, ok, id, msg, code := time.Now().Format("2006-01-02 15:04:05"), false, int64(0), "", int64(0)
  20. if this.EntUserId == "" {
  21. return &entmanageapplication.AddUsePersonResp{
  22. ErrorCode: -1,
  23. ErrorMsg: "添加失败",
  24. Data: &entmanageapplication.AddUsePerson{Status: int64(-1)},
  25. }
  26. }
  27. UserArr := strings.Split(this.EntUserId, ",")
  28. sourceData := JyMysql.FindOne(EntnicheWaitEmpower, map[string]interface{}{"id": this.WaitEmpowerId}, "", "")
  29. if sourceData != nil && len(*sourceData) > 0 {
  30. empower_count := common.IntAll((*sourceData)["empower_count"])
  31. use_count := common.IntAll((*sourceData)["use_count"])
  32. if empower_count-use_count < len(UserArr) {
  33. msg = "购买数量不足"
  34. code = int64(-1)
  35. } else {
  36. for _, v := range UserArr {
  37. //过滤空值2023-01-04
  38. if v == "" {
  39. continue
  40. }
  41. //
  42. entUserId, _ := strconv.Atoi(v)
  43. data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, "", "")
  44. if data != nil && len(*data) > 0 {
  45. dataStatus := common.IntAll((*data)["status"])
  46. if dataStatus == -1 {
  47. ok = JyMysql.Update(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, map[string]interface{}{"wait_empower_id": this.WaitEmpowerId, "status": 1, "update_time": timeStr})
  48. } else {
  49. msg = "人员已经拥有权限,请先删除原有权限"
  50. code = int64(-1)
  51. break
  52. }
  53. } else {
  54. id = JyMysql.Insert(EntnichePower, map[string]interface{}{
  55. "wait_empower_id": this.WaitEmpowerId,
  56. "ent_id": this.EntId,
  57. "ent_user_id": entUserId,
  58. "status": 1,
  59. "create_time": timeStr,
  60. "update_time": timeStr,
  61. })
  62. }
  63. JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count + 1 where id = ?`, this.WaitEmpowerId)
  64. addPower(this.WaitEmpowerId, entUserId)
  65. }
  66. }
  67. }
  68. status := 0
  69. if ok || id > 0 {
  70. status = 1
  71. }
  72. return &entmanageapplication.AddUsePersonResp{
  73. ErrorCode: code,
  74. ErrorMsg: msg,
  75. Data: &entmanageapplication.AddUsePerson{Status: int64(status)},
  76. }
  77. }
  78. func DelUsePerson(this *entmanageapplication.DelUsePersonReq) *entmanageapplication.AddUsePersonResp {
  79. timeStr := time.Now().Format("2006-01-02 15:04:05")
  80. ok := JyMysql.Update(EntnichePower, map[string]interface{}{"id": this.EntnichePowerId},
  81. map[string]interface{}{"status": -1, "update_time": timeStr})
  82. delPower(this.EntnichePowerId)
  83. status := 0
  84. if ok {
  85. status = 1
  86. }
  87. return &entmanageapplication.AddUsePersonResp{
  88. ErrorCode: 0,
  89. Data: &entmanageapplication.AddUsePerson{Status: int64(status)},
  90. }
  91. }
  92. func UsePersonList(this *entmanageapplication.UsePersonListReq) *entmanageapplication.UsePersonListResp {
  93. data := JyMysql.SelectBySql(`select a.id,a.wait_empower_id,c.name,c.phone,c.mail,g.name as department,e.name as role from entniche_power a
  94. INNER JOIN entniche_user c on (a.ent_user_id=c.id and a.ent_id = c.ent_id)
  95. LEFT JOIN entniche_user_role d on (c.id=d.user_id)
  96. LEFT JOIN entniche_role e on (d.role_id=e.id)
  97. LEFT JOIN entniche_department_user f on (a.ent_user_id=f.user_id)
  98. LEFT JOIN entniche_department g on (g.id=f.dept_id)
  99. where a.status = 1 and a.ent_id = ?
  100. order by a.update_time desc`, this.EntId)
  101. arr := []*entmanageapplication.UsePersonList{}
  102. if data != nil && len(*data) > 0 {
  103. for _, v := range *data {
  104. wait_empower_id := common.Int64All(v["wait_empower_id"])
  105. if wait_empower_id == this.WaitEmpowerId {
  106. obj := &entmanageapplication.UsePersonList{
  107. EntnichePowerId: common.Int64All(v["id"]),
  108. Name: common.ObjToString(v["name"]),
  109. Phone: common.ObjToString(v["phone"]),
  110. Email: common.ObjToString(v["mail"]),
  111. Department: common.ObjToString(v["department"]),
  112. Role: common.ObjToString(v["role"]),
  113. Status: 1,
  114. }
  115. arr = append(arr, obj)
  116. } else {
  117. obj := &entmanageapplication.UsePersonList{
  118. EntnichePowerId: common.Int64All(v["id"]),
  119. Name: common.ObjToString(v["name"]),
  120. Phone: common.ObjToString(v["phone"]),
  121. Email: common.ObjToString(v["mail"]),
  122. Department: common.ObjToString(v["department"]),
  123. Role: common.ObjToString(v["role"]),
  124. Status: 2,
  125. }
  126. arr = append(arr, obj)
  127. }
  128. }
  129. }
  130. return &entmanageapplication.UsePersonListResp{
  131. ErrorCode: 0,
  132. Data: arr,
  133. }
  134. }
  135. func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageapplication.BuyProductListResp {
  136. data := JyMysql.Find(EntnicheWaitEmpower, map[string]interface{}{"ent_id": this.EntId}, "", "create_time desc", 0, 0)
  137. arr := []*entmanageapplication.BuyProductList{}
  138. if data != nil && len(*data) > 0 {
  139. for _, v := range *data {
  140. product_type := common.ObjToString(v["product_type"])
  141. if product_type == "VIP订阅" {
  142. product_type = "超级订阅"
  143. }
  144. obj := &entmanageapplication.BuyProductList{
  145. WaitEmpowerId: common.Int64All(v["id"]),
  146. ProductType: product_type,
  147. UseCount: common.Int64All(v["use_count"]),
  148. EmpowerCount: common.Int64All(v["empower_count"]),
  149. ProvinceCount: common.Int64All(v["province_count"]),
  150. EndTime: common.ObjToString(v["end_time"]),
  151. }
  152. arr = append(arr, obj)
  153. }
  154. }
  155. return &entmanageapplication.BuyProductListResp{
  156. ErrorCode: 0,
  157. Data: arr,
  158. }
  159. }
  160. func addPower(waitEmpowerId int64, entUserId int) {
  161. data := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
  162. if data != nil && len(*data) > 0 {
  163. orderId := common.Int64All((*data)["order_id"])
  164. orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
  165. if orderData != nil && len(*orderData) > 0 {
  166. productType := common.ObjToString((*orderData)["product_type"])
  167. userId := getUserId(entUserId)
  168. if productType == "VIP订阅" {
  169. log.Println("开通超级订阅", userId)
  170. openPowerVip(*orderData, userId)
  171. } else if productType == "大会员" {
  172. log.Println("开通大会员", userId)
  173. openPowerBig(*orderData, userId)
  174. }
  175. }
  176. }
  177. }
  178. func openPowerBig(orderData map[string]interface{}, userId string) bool {
  179. filterMap := common.ObjToMap(orderData["filter"])
  180. startTime := common.ObjToString(orderData["vip_starttime"])
  181. endTime := common.ObjToString(orderData["vip_endtime"])
  182. tmp := "2006-01-02 15:04:05"
  183. startdate, _ := time.ParseInLocation(tmp, startTime, time.Local)
  184. enddate, _ := time.ParseInLocation(tmp, endTime, time.Local)
  185. level := common.IntAll((*filterMap)["level"])
  186. comboId := common.IntAll((*filterMap)["comboId"])
  187. payCycle := common.IntAll((*filterMap)["cycle"])
  188. serversId := common.ObjToString((*filterMap)["serversId"])
  189. serverMap := GetServerPid()
  190. dataType := 1
  191. if startdate.Unix() > time.Now().Unix() {
  192. dataType = 2
  193. }
  194. sets := map[string]interface{}{
  195. "i_member_status": common.If(dataType == 1, level, -level),
  196. "i_member_starttime": startdate.Unix(),
  197. "i_member_endtime": enddate.Unix(),
  198. "i_mainaccount": 1,
  199. "o_member_jy.i_wxpush": 1,
  200. }
  201. set := map[string]interface{}{
  202. "$set": sets,
  203. }
  204. ok := Mgo.UpdateById("user", userId, set)
  205. if !ok {
  206. log.Println("大会员创建订单user表大会员状态更新失败")
  207. }
  208. if comboId != 0 {
  209. datas := JyMysql.FindOne("bigmember_combo", map[string]interface{}{"id": comboId}, "", "")
  210. if datas == nil || len(*datas) == 0 {
  211. log.Println("未找到此套餐")
  212. return false
  213. }
  214. s_servers := common.ObjToString((*datas)["s_servers"])
  215. for _, s := range strings.Split(s_servers, ",") {
  216. serverId, _ := strconv.Atoi(s)
  217. mainId := serverId
  218. if serverMap[serverId] != 0 {
  219. serverId = serverMap[serverId]
  220. }
  221. serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
  222. frequency := 0
  223. if serverData != nil && len(*serverData) > 0 {
  224. if serverId == 11 || serverId == 15 {
  225. if serverId == 15 {
  226. if payCycle >= 12 {
  227. frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
  228. } else {
  229. frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
  230. }
  231. } else {
  232. frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
  233. }
  234. } else {
  235. frequency = common.IntAll((*serverData)["s_count_month"])
  236. }
  237. }
  238. sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
  239. serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
  240. if serverDatas != nil && len(*serverDatas) > 0 {
  241. i_status := common.If(dataType == 1, 0, 1)
  242. // sql := ""
  243. // if serverId == 17 || serverId == 18 {
  244. sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
  245. // } else {
  246. // sql = "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
  247. // }
  248. status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
  249. if status1 < 0 {
  250. log.Println("新建服务-更新服务表出错", userId)
  251. return false
  252. }
  253. } else {
  254. insert := map[string]interface{}{
  255. "s_smainid": mainId,
  256. "s_userid": userId,
  257. "s_serviceid": serverId,
  258. "i_frequency": frequency,
  259. "l_starttime": startdate.Format(tmp),
  260. "l_endtime": enddate.Format(tmp),
  261. "i_status": common.If(dataType == 1, 0, 1),
  262. "l_createtime": time.Now().Format(tmp),
  263. "l_updatetime": time.Now().Format(tmp),
  264. }
  265. order_id := JyMysql.Insert(BigServiceUser, insert)
  266. if order_id > 0 {
  267. log.Println("用户服务表插入成功", userId)
  268. } else {
  269. log.Println("用户服务表插入失败", userId)
  270. return false
  271. }
  272. }
  273. }
  274. } else {
  275. for _, s := range strings.Split(serversId, ",") {
  276. serverId, _ := strconv.Atoi(s)
  277. mainId := serverId
  278. if serverMap[serverId] != 0 {
  279. serverId = serverMap[serverId]
  280. }
  281. serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
  282. frequency := 0
  283. if serverData != nil && len(*serverData) > 0 {
  284. if serverId == 11 || serverId == 15 {
  285. if serverId == 15 {
  286. if payCycle >= 12 {
  287. frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
  288. } else {
  289. frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
  290. }
  291. } else {
  292. frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
  293. }
  294. } else {
  295. frequency = common.IntAll((*serverData)["s_count_month"])
  296. }
  297. }
  298. sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
  299. serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
  300. if serverDatas != nil && len(*serverDatas) > 0 {
  301. i_status := common.If(dataType == 1, 0, 1)
  302. sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
  303. status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
  304. if status1 < 0 {
  305. log.Println("新建服务-更新服务表出错")
  306. return false
  307. }
  308. } else {
  309. insert := map[string]interface{}{
  310. "s_userid": userId,
  311. "s_smainid": mainId,
  312. "s_serviceid": serverId,
  313. "i_frequency": frequency,
  314. "l_starttime": startdate.Format(tmp),
  315. "l_endtime": enddate.Format(tmp),
  316. "i_status": common.If(dataType == 1, 0, 1),
  317. "l_createtime": time.Now().Format(tmp),
  318. "l_updatetime": time.Now().Format(tmp),
  319. }
  320. order_id := JyMysql.Insert(BigServiceUser, insert)
  321. if order_id > 0 {
  322. log.Println("用户服务表插入成功", userId)
  323. } else {
  324. log.Println("用户服务表插入失败")
  325. return false
  326. }
  327. }
  328. }
  329. }
  330. RedisDel(userId)
  331. return true
  332. }
  333. func GetServerPid() map[int]int {
  334. pidMap := map[int]int{}
  335. datas := JyMysql.Find("bigmember_service", map[string]interface{}{"i_status": 0}, "id,i_pid", "", 0, 0)
  336. if datas != nil && len(*datas) > 0 {
  337. for _, v := range *datas {
  338. if v["i_pid"] != nil {
  339. pidMap[common.IntAll(v["id"])] = common.IntAll(v["i_pid"])
  340. }
  341. }
  342. }
  343. return pidMap
  344. }
  345. func RedisDel(userId string) {
  346. redis.Del(NewOther, "pl_indexMessage_"+userId)
  347. cacheKey := fmt.Sprintf(PowerCacheKey, userId)
  348. baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
  349. redisMenuKeyPC := fmt.Sprintf(RedisMenuKeyPC, userId)
  350. redisMenuKeyWX := fmt.Sprintf(RedisMenuKeyWX, userId)
  351. redisMenuKeyAPP := fmt.Sprintf(RedisMenuKeyAPP, userId)
  352. userPowerRedisKey := fmt.Sprintf(UserPowerRedisKey, time.Now().Day(), userId)
  353. redis.Del(NewOther, cacheKey)
  354. redis.Del(NewOther, baseInfoCacheKey)
  355. redis.Del(NewOther, redisMenuKeyPC)
  356. redis.Del(NewOther, redisMenuKeyWX)
  357. redis.Del(NewOther, redisMenuKeyAPP)
  358. redis.Del(NewOther, userPowerRedisKey)
  359. }
  360. func openPowerVip(orderData map[string]interface{}, userId string) bool {
  361. vms := VipSimpleMsg{}
  362. json.Unmarshal([]byte(common.ObjToString(orderData["filter"])), &vms)
  363. startTime := common.ObjToString(orderData["vip_starttime"])
  364. endTime := common.ObjToString(orderData["vip_endtime"])
  365. Date_Full_Layout := "2006-01-02 15:04:05"
  366. user_phone := common.ObjToString(orderData["user_phone"])
  367. startdate, _ := time.ParseInLocation(Date_Full_Layout, startTime, time.Local)
  368. enddate, _ := time.ParseInLocation(Date_Full_Layout, endTime, time.Local)
  369. dataType := 1
  370. if startdate.Unix() > time.Now().Unix() {
  371. dataType = 2
  372. }
  373. //为用户开通超级订阅权限
  374. //是否开通超级订阅 -1 试用到期 -2 正式到期 1 试用 2 开通
  375. isTrial := false
  376. if dataType == 2 {
  377. isTrial = true
  378. }
  379. isOk := StartSubVip(user_phone, *vms.Area, *vms.NewBuyset, startdate, enddate, isTrial, userId)
  380. return isOk
  381. }
  382. func StartSubVip(phone string, area map[string]interface{}, newBuyset SubvipBuySet, startTime, endTime time.Time, isTrial bool, userId string) bool {
  383. set := map[string]interface{}{
  384. "o_vipjy.i_trial": -1, //已激活试用
  385. "o_vipjy.o_area": area, //设置地区
  386. "o_vipjy.o_buyset": newBuyset, //购买内容 城市、省份、行业数量
  387. "l_vip_starttime": startTime.Unix(), //开始时间
  388. "l_vip_endtime": endTime.Unix(), //结束时间
  389. "i_vip_status": common.If(isTrial, -2, 2), //1试用 2正式 -2 试用到期
  390. "i_vip_expire_tip": 0, //消息提示初始化
  391. "o_vipjy.a_buyerclass": []interface{}{}, //设置行业
  392. }
  393. isOk := Mgo.UpdateById("user", userId, map[string]interface{}{
  394. "$set": set,
  395. })
  396. go func() {
  397. MergeKws(userId)
  398. RedisDel(userId)
  399. }()
  400. if isOk {
  401. return true
  402. }
  403. return true
  404. }
  405. // 初始化vip订阅关键词
  406. func MergeKws(userId string) {
  407. if userId == "" { //11-11 取消此操作
  408. return
  409. }
  410. data, ok := Mgo.FindById("user", userId, `{"o_jy":1,"o_vipjy":1}`)
  411. var o_vipjy map[string]interface{}
  412. if ok && data != nil && len(*data) > 0 {
  413. o_vipjy, _ = (*data)["o_vipjy"].(map[string]interface{})
  414. a_items, _ := o_vipjy["a_items"].([]interface{})
  415. if a_items == nil { //首次
  416. Mgo.UpdateById("user", userId, map[string]interface{}{
  417. "$set": map[string]interface{}{"o_vipjy.i_matchway": 1, "o_vipjy.i_ratemode": 1, "o_vipjy.i_wxpush": 1, "o_vipjy.i_apppush": 1, "o_vipjy.i_projectmatch": 0, "o_vipjy.a_infotype": []string{}, "o_vipjy.a_items": []string{}, "o_vipjy.l_modifydate": time.Now().Unix()},
  418. })
  419. }
  420. }
  421. }
  422. func delPower(id int64) {
  423. data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"id": id}, "", "")
  424. if data != nil && len(*data) > 0 {
  425. waitEmpowerId := common.Int64All((*data)["wait_empower_id"])
  426. entUserId := common.IntAll((*data)["ent_user_id"])
  427. JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count - 1 where id = ?`, waitEmpowerId)
  428. eOData := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
  429. if eOData != nil && len(*eOData) > 0 {
  430. orderId := common.Int64All((*eOData)["order_id"])
  431. orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
  432. if orderData != nil && len(*orderData) > 0 {
  433. productType := common.ObjToString((*orderData)["product_type"])
  434. userId := getUserId(entUserId)
  435. if productType == "VIP订阅" {
  436. Mgo.UpdateById("user", userId, map[string]interface{}{"$unset": map[string]interface{}{"i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1}})
  437. } else if productType == "大会员" {
  438. Mgo.UpdateById("user", userId, map[string]interface{}{"$unset": map[string]interface{}{"i_member_status": 1, "i_member_starttime": 1, "i_member_endtime": 1}})
  439. JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": userId}, map[string]interface{}{"i_status": -1})
  440. }
  441. RedisDel(userId)
  442. }
  443. }
  444. }
  445. }
  446. func getUserId(entUserId int) string {
  447. data := JyMysql.FindOne(EntnicheUser, map[string]interface{}{"id": entUserId}, "", "")
  448. userId := ""
  449. now := time.Now()
  450. if data != nil && len(*data) > 0 {
  451. phone := common.ObjToString((*data)["phone"])
  452. userData, ok := Mgo.FindOne("user", map[string]interface{}{"s_phone": phone})
  453. if ok && userData != nil && len(*userData) > 0 {
  454. userId = mongodb.BsonIdToSId((*userData)["_id"])
  455. } else {
  456. userDatas, oks := Mgo.FindOne("user", map[string]interface{}{"s_m_phone": phone})
  457. if oks && userDatas != nil && len(*userDatas) > 0 {
  458. userId = mongodb.BsonIdToSId((*userDatas)["_id"])
  459. } else {
  460. ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
  461. res, _ := UserCenterRpc.UserAdd(ctx, &usercenter.UserAddReq{
  462. Appid: "10000",
  463. Phone: phone,
  464. })
  465. data := map[string]interface{}{
  466. "i_appid": 2,
  467. "s_phone": phone,
  468. "s_password": "",
  469. "l_registedate": now.Unix(),
  470. "i_ts_guide": 2,
  471. "o_jy": map[string]interface{}{
  472. "i_wxpush": 1,
  473. "i_apppush": 1,
  474. "i_ratemode": 2,
  475. "l_modifydate": now.Unix(),
  476. },
  477. "s_regsource": "qmx_admin",
  478. "base_user_id": res.Data.Id,
  479. }
  480. _id := Mgo.Save("user", data)
  481. log.Println("新增用户", _id)
  482. if _id != "" {
  483. userId = _id
  484. }
  485. }
  486. }
  487. }
  488. return userId
  489. }