service.go 19 KB

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