附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_user.go 3.0 KiB

2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/md"
  7. "applet/app/svc"
  8. "applet/app/utils"
  9. "github.com/gin-gonic/gin"
  10. "github.com/jinzhu/copier"
  11. )
  12. // User 用户信息
  13. // @Summary 用户信息
  14. // @Tags 用户信息
  15. // @Description 用户信息
  16. // @Accept json
  17. // @Produce json
  18. // @Success 200 {string} ""
  19. // @Failure 400 {object} md.Response "具体错误"
  20. // @Router /api/v1/communityTeam/ownStore/user [GET]
  21. func User(c *gin.Context) {
  22. user := svc.GetUser(c)
  23. third_gd_web_app_key := db.SysCfgGet(c, "third_gd_web_app_key")
  24. res := map[string]string{
  25. "head_img": user.Profile.AvatarUrl,
  26. "nickname": user.Info.Nickname,
  27. "phone": user.Info.Phone,
  28. "state": "0",
  29. "info": "",
  30. "store_type": "0",
  31. "third_gd_web_app_key": third_gd_web_app_key,
  32. }
  33. storeCheck := db.StoreAuditByUid(svc.MasterDb(c), user.Info.Uid)
  34. if storeCheck != nil {
  35. if storeCheck.State == 1 {
  36. res["state"] = "1"
  37. }
  38. if storeCheck.State == 3 {
  39. res["state"] = "3"
  40. res["info"] = storeCheck.Info
  41. }
  42. }
  43. userParty := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  44. if userParty != nil {
  45. if userParty.State == 1 {
  46. res["state"] = "2"
  47. } else if storeCheck != nil && storeCheck.State == 2 {
  48. res["state"] = "3"
  49. }
  50. res["store_type"] = utils.IntToStr(userParty.StoreType)
  51. }
  52. db.GetStorePayQrcodeByUId(svc.MasterDb(c), user.Info.Uid)
  53. e.OutSuc(c, res, nil)
  54. return
  55. }
  56. func GdKey(c *gin.Context) {
  57. third_gd_web_app_key := db.SysCfgGet(c, "third_gd_js_app_key")
  58. third_gd_web_app_secret := db.SysCfgGet(c, "third_gd_web_app_secret")
  59. res := map[string]string{
  60. "third_gd_web_app_key": third_gd_web_app_key,
  61. "third_gd_web_app_secret": third_gd_web_app_secret,
  62. }
  63. e.OutSuc(c, res, nil)
  64. return
  65. }
  66. func Base(c *gin.Context) {
  67. user := svc.GetUser(c)
  68. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  69. var res = md.CommunityTeamStore{}
  70. if store != nil {
  71. copier.Copy(&res, &store)
  72. res.DistrictId = utils.IntToStr(store.DistrictId)
  73. res.CityId = utils.IntToStr(store.CityId)
  74. res.WorkState = utils.IntToStr(store.WorkState)
  75. res.ProvinceId = utils.IntToStr(store.ProvinceId)
  76. }
  77. e.OutSuc(c, res, nil)
  78. return
  79. }
  80. func BaseSet(c *gin.Context) {
  81. var arg md.CommunityTeamStore
  82. if err := c.ShouldBindJSON(&arg); err != nil {
  83. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  84. return
  85. }
  86. user := svc.GetUser(c)
  87. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  88. var storeData model.CommunityTeamStore
  89. copier.Copy(&storeData, &arg)
  90. storeData.DistrictId = utils.StrToInt(arg.DistrictId)
  91. storeData.CityId = utils.StrToInt(arg.CityId)
  92. storeData.WorkState = utils.StrToInt(arg.WorkState)
  93. storeData.ProvinceId = utils.StrToInt(arg.ProvinceId)
  94. svc.MasterDb(c).Where("id=?", store.Id).Cols("lat,lng,address,work_state,name,province,city,district,timer,phone,logo,province_id,city_id,district_id").Update(&storeData)
  95. e.OutSuc(c, "success", nil)
  96. return
  97. }