service.go 19 KB

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