service.go 19 KB

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