login_auth.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. package service
  2. import (
  3. "context"
  4. "encoding/json"
  5. "errors"
  6. "fmt"
  7. "strconv"
  8. "strings"
  9. "time"
  10. "youngee_b_api/consts"
  11. "youngee_b_api/db"
  12. "youngee_b_api/model/gorm_model"
  13. "youngee_b_api/model/http_model"
  14. "youngee_b_api/model/redis_model"
  15. "youngee_b_api/model/system_model"
  16. "youngee_b_api/redis"
  17. "youngee_b_api/util"
  18. "github.com/sirupsen/logrus"
  19. )
  20. var LoginAuth *loginAuth
  21. func LoginAuthInit(config *system_model.Session) {
  22. auth := new(loginAuth)
  23. auth.sessionTTL = time.Duration(config.TTL) * time.Minute
  24. LoginAuth = auth
  25. }
  26. type loginAuth struct {
  27. sessionTTL time.Duration
  28. }
  29. func (l *loginAuth) AuthToken(ctx context.Context, token string) (*redis_model.Auth, error) {
  30. phone, err := l.parseToken(ctx, token)
  31. if err != nil {
  32. logrus.Debug("token格式错误:%+v", token)
  33. return nil, err
  34. }
  35. auth, err := l.getSessionAuth(ctx, phone)
  36. if err != nil {
  37. logrus.Debug("获取session redis错误: token:%+v,err:%+v", token, err)
  38. return nil, err
  39. }
  40. if auth.Token != token {
  41. logrus.Debug("获取session time过期错误: token:%+v", token)
  42. return nil, errors.New("auth failed")
  43. }
  44. return auth, nil
  45. }
  46. // AuthCode 判断此手机号是否有账号存在 鉴定验证码 用户信息存入redis 并返回Token
  47. func (l *loginAuth) AuthCode(ctx context.Context, phone string, code string) (int, *http_model.CodeLoginData, error) {
  48. // 1. 验证码校验
  49. vcode, err := l.getSessionCode(ctx, phone)
  50. if err != nil {
  51. return 0, nil, err
  52. }
  53. fmt.Printf("缓存的验证码 vcode: %v,实际填入的 code:%v", vcode, code)
  54. if vcode != code {
  55. // 验证码错误
  56. logrus.Debugf("[AuthCode] auth fail,phone:%+v", phone)
  57. return 1, nil, nil
  58. }
  59. // 2. 查询是否存在用户信息,存在则取出,不存在则注册并取出
  60. var userData *gorm_model.YounggeeUser
  61. userInfo, err := db.GetUserByPhone(ctx, phone)
  62. // fmt.Println("login_auth", user, err)
  63. if err != nil {
  64. // 数据库操作错误
  65. return 0, nil, err
  66. }
  67. if userInfo == nil {
  68. subUserInfo, subUserErr := db.GetSubUserByPhone(ctx, phone)
  69. if subUserErr != nil {
  70. return 0, nil, subUserErr
  71. }
  72. if subUserInfo == nil {
  73. // fmt.Println("子账号也不存在")
  74. // 账号不存在,则默认注册商家账号
  75. _, createEnterpriseErr := Enterprise.CreateEnterprise(ctx, phone)
  76. if createEnterpriseErr != nil {
  77. return 0, nil, createEnterpriseErr
  78. }
  79. enterpriseUserInfo, enterpriseUserErr := db.GetUserByPhone(ctx, phone)
  80. if enterpriseUserErr != nil {
  81. return 0, nil, enterpriseUserErr
  82. }
  83. userData = enterpriseUserInfo
  84. // fmt.Println("login_auth", user, err)
  85. } else {
  86. userData = subUserInfo
  87. }
  88. } else {
  89. userData = userInfo
  90. }
  91. token := l.getToken(ctx, phone, userData.Role)
  92. var jobData gorm_model.YounggeeJob
  93. var accountData gorm_model.YounggeeSubAccount
  94. var enterpriseUser gorm_model.Enterprise
  95. var loginUserData http_model.CodeLoginData
  96. var ifEnterprise int = 0
  97. // 3. 根据用户类型的不同补充信息
  98. // 若为商家用户
  99. if string(userData.Role) == consts.BRole {
  100. ifEnterprise = 1
  101. // fmt.Println("商家主账号")
  102. enterpriseUserInfo, enterpriseUserErr := db.GetEnterpriseByUID(ctx, userData.ID)
  103. if enterpriseUserErr != nil {
  104. return 0, nil, enterpriseUserErr
  105. }
  106. if enterpriseUserInfo != nil {
  107. enterpriseUser = *enterpriseUserInfo
  108. auth := &redis_model.Auth{
  109. Phone: phone,
  110. ID: userData.ID,
  111. User: userData.User,
  112. Username: userData.Username,
  113. RealName: userData.RealName,
  114. Role: userData.Role,
  115. Email: userData.Email,
  116. Token: token,
  117. EnterpriseID: enterpriseUserInfo.EnterpriseID,
  118. }
  119. key := phone + userData.Role
  120. if sessionErr := l.setSession(ctx, key, auth); sessionErr != nil {
  121. fmt.Printf("setSession error\n")
  122. return 0, nil, sessionErr
  123. }
  124. }
  125. } else {
  126. // 若为商家子账号
  127. fmt.Printf("商家子账号")
  128. subAccountUserInfo, subAccountUserErr := db.FindSubAccountByPhone(ctx, phone)
  129. if subAccountUserErr != nil {
  130. return 0, nil, subAccountUserErr
  131. }
  132. if subAccountUserInfo != nil {
  133. accountData = *subAccountUserInfo
  134. auth := &redis_model.Auth{
  135. Phone: phone,
  136. ID: userData.ID,
  137. User: userData.User,
  138. Username: userData.Username,
  139. RealName: userData.RealName,
  140. Role: userData.Role,
  141. Email: userData.Email,
  142. Token: token,
  143. EnterpriseID: subAccountUserInfo.EnterpriseId,
  144. }
  145. jobInfo, jobErr := db.FindJobByJobId(ctx, subAccountUserInfo.JobId)
  146. if jobErr != nil {
  147. return 0, nil, jobErr
  148. }
  149. if jobInfo != nil {
  150. jobData = *jobInfo
  151. key := phone + userData.Role
  152. if sessionErr := l.setSession(ctx, key, auth); sessionErr != nil {
  153. fmt.Printf("setSession error\n")
  154. return 0, nil, sessionErr
  155. }
  156. }
  157. }
  158. }
  159. if ifEnterprise == 1 {
  160. loginUserData = http_model.CodeLoginData{
  161. UserId: userData.ID,
  162. Token: token,
  163. Role: userData.Role,
  164. SubAccountId: 0,
  165. JobName: "主账号无岗位",
  166. EnterpriseId: enterpriseUser.EnterpriseID,
  167. WorkshopPermission: "1",
  168. CooperatePermission: "1",
  169. FinancialPermission: "1",
  170. TaskcenterPermission: "1",
  171. }
  172. } else {
  173. loginUserData = http_model.CodeLoginData{
  174. UserId: userData.ID,
  175. Token: token,
  176. Role: userData.Role,
  177. SubAccountId: accountData.SubAccountId,
  178. JobName: jobData.JobName,
  179. EnterpriseId: accountData.EnterpriseId,
  180. WorkshopPermission: jobData.WorkshopPermission,
  181. CooperatePermission: jobData.CooperatePermission,
  182. FinancialPermission: jobData.FinancialPermission,
  183. TaskcenterPermission: jobData.TaskcenterPermission,
  184. }
  185. }
  186. return 0, &loginUserData, nil
  187. }
  188. // func (l *loginAuth) AuthPassword(ctx context.Context, phone string, password string) (string, error) {
  189. // // 验证是否存在
  190. // user, err := db.GetUserByPhone(ctx, phone)
  191. // if err != nil {
  192. // return "", err
  193. // }
  194. // // 验证正确性
  195. // if user == nil || user.Role != consts.BRole || user.Password != l.encryptPassword(password) {
  196. // // 登录失败
  197. // logrus.Debugf("[AuthPassword] auth fail,phone:%+v", phone)
  198. // return "", errors.New("auth fail")
  199. // }
  200. // token := l.getToken(ctx, phone)
  201. // auth := &redis_model.Auth{
  202. // Phone: phone,
  203. // ID: user.ID,
  204. // User: user.User,
  205. // Username: user.Username,
  206. // RealName: user.RealName,
  207. // Role: user.Role,
  208. // Email: user.Email,
  209. // Token: token,
  210. // }
  211. // if err := l.setSession(ctx, phone, auth); err != nil {
  212. // return "", err
  213. // }
  214. // return token, nil
  215. // }
  216. func (l *loginAuth) setSession(ctx context.Context, phone string, auth *redis_model.Auth) error {
  217. if authJson, err := json.Marshal(auth); err == nil {
  218. err = redis.Set(ctx, l.getRedisKey(phone), string(authJson), l.sessionTTL)
  219. if err == nil {
  220. return err
  221. }
  222. }
  223. return nil
  224. }
  225. func (l *loginAuth) getSessionCode(ctx context.Context, phone string) (string, error) {
  226. value, err := redis.Get(ctx, l.getRedisKey(phone))
  227. if err != nil {
  228. if err == consts.RedisNil {
  229. return "", fmt.Errorf("not found in redis,phone:%+v", phone)
  230. }
  231. return "", err
  232. }
  233. return value, nil
  234. }
  235. func (l *loginAuth) getSessionAuth(ctx context.Context, phone string) (*redis_model.Auth, error) {
  236. value, err := redis.Get(ctx, l.getRedisKey(phone))
  237. if err != nil {
  238. if err == consts.RedisNil {
  239. return nil, fmt.Errorf("not found in redis,phone:%+v", phone)
  240. }
  241. return nil, err
  242. }
  243. auth := new(redis_model.Auth)
  244. if err = json.Unmarshal([]byte(value), auth); err != nil {
  245. return nil, err
  246. }
  247. return auth, nil
  248. }
  249. func (l *loginAuth) getToken(ctx context.Context, phone string, role string) string {
  250. timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
  251. token := phone + role + "." + timeSeed + "." + util.MD5(phone+role, timeSeed, consts.AuthSalt)
  252. return token
  253. }
  254. func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error) {
  255. parts := strings.Split(token, ".")
  256. if len(parts) == 3 {
  257. phone := parts[0]
  258. timeSeed := parts[1]
  259. if parts[2] == util.MD5(phone, timeSeed, consts.AuthSalt) {
  260. return phone, nil
  261. }
  262. }
  263. return "", errors.New("token invalid")
  264. }
  265. func (l *loginAuth) encryptPassword(password string) string {
  266. return util.MD5(password)
  267. }
  268. func (l *loginAuth) getRedisKey(key string) string {
  269. return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
  270. }
  271. func (l *loginAuth) SubAccountAuthCode(ctx context.Context, req *http_model.AddNewSubAccountRequest) (int, error) {
  272. // 验证码校验
  273. phoneNumber := req.PhoneNumber
  274. vCode, err := l.getSessionCode(ctx, phoneNumber)
  275. if err != nil {
  276. return 0, err
  277. }
  278. fmt.Printf("缓存的验证码 vcode: %v,实际填入的 code:%v", vCode, req.Code)
  279. if vCode != req.Code {
  280. // 验证码错误
  281. logrus.Debugf("[AuthCode] auth fail,phone:%+v", phoneNumber)
  282. return 1, nil
  283. }
  284. subAccountUserInfo, subAccountUserErr := db.FindSubAccountByPhone(ctx, phoneNumber)
  285. if subAccountUserErr != nil {
  286. return 0, subAccountUserErr
  287. }
  288. if subAccountUserInfo == nil {
  289. // 子账号不存在,则判断此手机号码是否被商家主账号注册
  290. bUser, bUserErr := db.GetUserByPhone(ctx, phoneNumber)
  291. if bUserErr != nil {
  292. return 0, bUserErr
  293. }
  294. if bUser == nil {
  295. createSubAccountErr := SubAccount.CreateSubAccount(ctx, req)
  296. if createSubAccountErr != nil {
  297. return 0, createSubAccountErr
  298. }
  299. } else {
  300. if bUser.AuthStatus != 1 {
  301. // 被商家主账户注册,未认证,则可以注册
  302. createSubAccountErr := SubAccount.CreateSubAccount(ctx, req)
  303. if createSubAccountErr != nil {
  304. return 0, createSubAccountErr
  305. }
  306. } else {
  307. return 2, nil
  308. }
  309. }
  310. } else {
  311. // 子账号存在,则无法注册
  312. logrus.Debugf("[AuthCode] subAccountExist,phone:%+v", phoneNumber)
  313. return 3, nil
  314. }
  315. return 0, nil
  316. }
  317. // UpdateEnterpriseAccountInfo 更新商家账号信息
  318. func (l *loginAuth) UpdateEnterpriseAccountInfo(ctx context.Context, req *http_model.UpdateAccountInfoRequest) (*http_model.UpdateAccountInfoData, int, error) {
  319. var supplierUserInfo *http_model.UpdateAccountInfoData
  320. supplierUserInfo = &http_model.UpdateAccountInfoData{}
  321. supplierUserInfo.EnterpriseName = req.EnterpriseName
  322. supplierUserInfo.Avatar = req.Avatar
  323. supplierUserInfo.Phone = req.Phone
  324. supplierUserInfo.SubAccountName = req.SubAccountName
  325. if req.SubAccountId == 0 {
  326. // 商家主账号
  327. // 1. 若修改绑定手机号
  328. if req.Phone != "" {
  329. // 1.1. 校验验证码
  330. vCode, err := l.getSessionCode(ctx, req.Phone)
  331. if err != nil {
  332. return nil, 0, err
  333. }
  334. if vCode != req.Code {
  335. return nil, 1, nil
  336. }
  337. // 1.2. 手机号是否已经被其他主账号绑定
  338. enterpriseNum, enterpriseNumErr := db.CountEnterpriseUserByPhone(ctx, req.Phone)
  339. if enterpriseNumErr != nil {
  340. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", supplierNumErr)
  341. return nil, 0, enterpriseNumErr
  342. }
  343. if enterpriseNum != 0 {
  344. return nil, 2, nil
  345. }
  346. // 1.3. 手机号是否被子账号绑定
  347. subAccountNum, SubAccountErr := db.CountSubAccountUserByPhone(ctx, req.Phone)
  348. if SubAccountErr != nil {
  349. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", SubAccountErr)
  350. return nil, 0, SubAccountErr
  351. }
  352. if subAccountNum != 0 {
  353. return nil, 3, nil
  354. }
  355. // 1.4. 修改Enterprise信息
  356. var enterpriseInfo *gorm_model.Enterprise
  357. enterpriseInfo = &gorm_model.Enterprise{}
  358. enterpriseInfo.EnterpriseID = req.EnterpriseId
  359. enterpriseInfo.EnterpriseName = req.EnterpriseName
  360. enterpriseInfo.Avatar = req.Avatar
  361. enterpriseInfo.Phone = req.Phone
  362. updateEnterpriseErr := db.UpdateEnterpriseById(ctx, enterpriseInfo)
  363. if updateEnterpriseErr != nil {
  364. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", updateEnterpriseErr)
  365. return nil, 0, updateEnterpriseErr
  366. }
  367. // 1.5. 修改User表信息
  368. enterpriseInfoQuery, enterpriseInfoQueryErr := db.GetEnterpriseByEnterpriseID(ctx, enterpriseInfo.EnterpriseID)
  369. if enterpriseInfoQueryErr != nil {
  370. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", supplierInfoQueryErr)
  371. return nil, 0, enterpriseInfoQueryErr
  372. }
  373. if enterpriseInfoQuery != nil {
  374. var userInfo *gorm_model.YounggeeUser
  375. userInfo = &gorm_model.YounggeeUser{}
  376. userInfo.ID = enterpriseInfoQuery.UserID
  377. userInfo.Phone = enterpriseInfoQuery.Phone
  378. userInfo.Username = enterpriseInfoQuery.Phone
  379. updateUserInfoErr := db.UpdateUserById(ctx, userInfo)
  380. if updateUserInfoErr != nil {
  381. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", updateUserInfoErr)
  382. return nil, 0, updateUserInfoErr
  383. }
  384. }
  385. } else {
  386. var enterpriseInfo *gorm_model.Enterprise
  387. enterpriseInfo = &gorm_model.Enterprise{}
  388. enterpriseInfo.EnterpriseID = req.EnterpriseId
  389. enterpriseInfo.EnterpriseName = req.EnterpriseName
  390. enterpriseInfo.Avatar = req.Avatar
  391. enterpriseInfo.Phone = req.Phone
  392. updateEnterpriseErr := db.UpdateEnterpriseById(ctx, enterpriseInfo)
  393. if updateEnterpriseErr != nil {
  394. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", updateEnterpriseErr)
  395. return nil, 0, updateEnterpriseErr
  396. }
  397. }
  398. } else {
  399. // 商家子账号
  400. var subAccountInfo *gorm_model.YounggeeSubAccount
  401. subAccountInfo = &gorm_model.YounggeeSubAccount{}
  402. subAccountInfo.SubAccountType = 3
  403. subAccountInfo.EnterpriseId = req.EnterpriseId
  404. subAccountInfo.SubAccountId = req.SubAccountId
  405. subAccountInfo.SubAccountName = req.SubAccountName
  406. subAccountInfo.Avatar = req.Avatar
  407. subAccountInfo.PhoneNumber = req.Phone
  408. updateSubAccountErr := db.UpdateSubAccount(ctx, subAccountInfo)
  409. if updateSubAccountErr != nil {
  410. // log.Infof("[GetSupplierAccountInfo] fail,err:%+v", updateSubAccountErr)
  411. return nil, 0, updateSubAccountErr
  412. }
  413. }
  414. return supplierUserInfo, 0, nil
  415. }
  416. // UpdateEnterpriseContactInfo 更新商家联系方式
  417. func (l *loginAuth) UpdateEnterpriseContactInfo(ctx context.Context, req *http_model.UpdateContactInfoRequest) (*http_model.UpdateContactInfoData, bool, error) {
  418. var contactInfo *http_model.UpdateContactInfoData
  419. contactInfo = &http_model.UpdateContactInfoData{}
  420. // 主账号
  421. if req.SubAccountId == 0 {
  422. // 1. 若更新联系电话则需要验证码校验
  423. if req.ContactPhone != "" {
  424. vcode, err := l.getSessionCode(ctx, req.ContactPhone)
  425. if err != nil {
  426. return nil, false, err
  427. }
  428. // fmt.Printf("缓存的验证码 vcode: %v,实际填入的 code:%v", vcode, req.Code)
  429. if vcode != req.Code {
  430. // 验证码错误
  431. return nil, true, err
  432. }
  433. var enterpriseInfo *gorm_model.Enterprise
  434. enterpriseInfo = &gorm_model.Enterprise{}
  435. enterpriseInfo.ContactPhone = req.ContactPhone
  436. enterpriseInfo.EnterpriseID = req.EnterpriseId
  437. updateEnterpriseErr := db.UpdateEnterpriseById(ctx, enterpriseInfo)
  438. if updateEnterpriseErr != nil {
  439. // log.Infof("[updateEnterpriseErr] fail,err:%+v", updateEnterpriseErr)
  440. return nil, false, updateEnterpriseErr
  441. }
  442. contactInfo.ContactPhone = req.ContactPhone
  443. }
  444. // 2. 微信二维码更新
  445. if req.WechatQRCode != "" {
  446. var enterpriseInfo *gorm_model.Enterprise
  447. enterpriseInfo = &gorm_model.Enterprise{}
  448. enterpriseInfo.WechatQrCode = req.WechatQRCode
  449. enterpriseInfo.EnterpriseID = req.EnterpriseId
  450. updateEnterpriseErr := db.UpdateEnterpriseById(ctx, enterpriseInfo)
  451. if updateEnterpriseErr != nil {
  452. // log.Infof("[UpdateSupplierContactInfo] fail,err:%+v", updateEnterpriseErr)
  453. return nil, false, updateEnterpriseErr
  454. }
  455. contactInfo.WechatQRCode = req.WechatQRCode
  456. }
  457. // 2. 微信号码更新
  458. if req.WechatNumber != "" {
  459. var enterpriseInfo *gorm_model.Enterprise
  460. enterpriseInfo = &gorm_model.Enterprise{}
  461. enterpriseInfo.WechatNumber = req.WechatNumber
  462. enterpriseInfo.EnterpriseID = req.EnterpriseId
  463. updateEnterpriseErr := db.UpdateEnterpriseById(ctx, enterpriseInfo)
  464. if updateEnterpriseErr != nil {
  465. // log.Infof("[UpdateSupplierContactInfo] fail,err:%+v", updateEnterpriseErr)
  466. return nil, false, updateEnterpriseErr
  467. }
  468. contactInfo.WechatNumber = req.WechatNumber
  469. }
  470. } else {
  471. // 子账号
  472. // 1. 若更新联系电话则需要验证码校验
  473. if req.ContactPhone != "" {
  474. vcode, err := l.getSessionCode(ctx, req.ContactPhone)
  475. if err != nil {
  476. return nil, false, err
  477. }
  478. // fmt.Printf("缓存的验证码 vcode: %v,实际填入的 code:%v", vcode, req.Code)
  479. if vcode != req.Code {
  480. // 验证码错误
  481. return nil, true, err
  482. }
  483. var subAccountInfo *gorm_model.YounggeeSubAccount
  484. subAccountInfo = &gorm_model.YounggeeSubAccount{}
  485. subAccountInfo.ContactPhone = req.ContactPhone
  486. subAccountInfo.SubAccountId = req.SubAccountId
  487. updateSupplierErr := db.UpdateSubAccount(ctx, subAccountInfo)
  488. if updateSupplierErr != nil {
  489. // log.Infof("[UpdateSupplierContactInfo] fail,err:%+v", updateSupplierErr)
  490. return nil, false, updateSupplierErr
  491. }
  492. contactInfo.ContactPhone = req.ContactPhone
  493. }
  494. // 2. 微信二维码更新
  495. if req.WechatQRCode != "" {
  496. var subAccountInfo *gorm_model.YounggeeSubAccount
  497. subAccountInfo = &gorm_model.YounggeeSubAccount{}
  498. subAccountInfo.WechatQRCode = req.WechatQRCode
  499. subAccountInfo.SubAccountId = req.SubAccountId
  500. updateSupplierErr := db.UpdateSubAccount(ctx, subAccountInfo)
  501. if updateSupplierErr != nil {
  502. // log.Infof("[UpdateSupplierContactInfo] fail,err:%+v", updateSupplierErr)
  503. return nil, false, updateSupplierErr
  504. }
  505. contactInfo.WechatQRCode = req.WechatQRCode
  506. }
  507. // 2. 微信号码更新
  508. if req.WechatNumber != "" {
  509. var subAccountInfo *gorm_model.YounggeeSubAccount
  510. subAccountInfo = &gorm_model.YounggeeSubAccount{}
  511. subAccountInfo.WechatNumber = req.WechatNumber
  512. subAccountInfo.SubAccountId = req.SubAccountId
  513. updateSupplierErr := db.UpdateSubAccount(ctx, subAccountInfo)
  514. if updateSupplierErr != nil {
  515. // log.Infof("[UpdateSupplierContactInfo] fail,err:%+v", updateSupplierErr)
  516. return nil, false, updateSupplierErr
  517. }
  518. contactInfo.WechatNumber = req.WechatNumber
  519. }
  520. }
  521. return contactInfo, true, nil
  522. }