附近小店
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.
 
 
 

76 lines
1.9 KiB

  1. package svc
  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. "time"
  12. )
  13. func AuditInfo(c *gin.Context) {
  14. var res md.CommunityTeamStoreAudit
  15. user := svc.GetUser(c)
  16. storeCheck := db.StoreAuditByUid(svc.MasterDb(c), user.Info.Uid)
  17. res.State = "0"
  18. if storeCheck != nil {
  19. copier.Copy(&res, &storeCheck)
  20. res.State = utils.IntToStr(storeCheck.State)
  21. res.ProvinceId = utils.IntToStr(storeCheck.ProvinceId)
  22. res.CityId = utils.IntToStr(storeCheck.CityId)
  23. res.DistrictId = utils.IntToStr(storeCheck.DistrictId)
  24. }
  25. userParty := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  26. if userParty != nil {
  27. if userParty.State == 1 {
  28. res.State = "2"
  29. } else if storeCheck != nil && storeCheck.State == 2 {
  30. res.State = "3"
  31. }
  32. }
  33. e.OutSuc(c, res, nil)
  34. return
  35. }
  36. func AuditDoing(c *gin.Context) {
  37. var arg md.CommunityTeamStoreAudit
  38. if err := c.ShouldBindJSON(&arg); err != nil {
  39. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  40. return
  41. }
  42. user := svc.GetUser(c)
  43. userParty := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  44. if userParty != nil {
  45. if userParty.State == 1 {
  46. e.OutErr(c, 400, e.NewErr(400, "已审核通过"))
  47. return
  48. }
  49. }
  50. var tmp model.CommunityTeamStoreAudit
  51. copier.Copy(&tmp, &arg)
  52. tmp.State = 1
  53. tmp.ProvinceId = utils.StrToInt(arg.ProvinceId)
  54. tmp.CityId = utils.StrToInt(arg.CityId)
  55. tmp.DistrictId = utils.StrToInt(arg.DistrictId)
  56. tmp.Uid = user.Info.Uid
  57. tmp.CreateAt = time.Now()
  58. tmp.UpdateAt = time.Now()
  59. storeCheck := db.StoreAuditByUid(svc.MasterDb(c), user.Info.Uid)
  60. if storeCheck != nil {
  61. if storeCheck.State == 2 {
  62. e.OutErr(c, 400, e.NewErr(400, "已审核通过"))
  63. return
  64. }
  65. tmp.CreateAt = storeCheck.CreateAt
  66. svc.MasterDb(c).Where("id=?", storeCheck.Id).Update(&tmp)
  67. } else {
  68. svc.MasterDb(c).Insert(&tmp)
  69. }
  70. e.OutSuc(c, "success", nil)
  71. return
  72. }