广告平台(媒体使用)
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.
 
 
 
 
 
 

144 lines
3.9 KiB

  1. package svc
  2. import (
  3. "applet/app/e"
  4. "applet/app/md"
  5. "applet/app/utils"
  6. db "code.fnuoos.com/zhimeng/model.git/src"
  7. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  8. model2 "code.fnuoos.com/zhimeng/model.git/src/super/model"
  9. "github.com/gin-gonic/gin"
  10. "github.com/jinzhu/copier"
  11. "time"
  12. )
  13. func QualificationInfo(c *gin.Context) {
  14. admin := GetUser(c)
  15. MediumListDb := implement.NewMediumListDb(db.Db)
  16. medium, _ := MediumListDb.GetMediumList(admin.MediumId)
  17. if medium == nil {
  18. medium = &model2.MediumList{Uuid: utils.StrToInt(c.GetString("mid")), MediumId: admin.MediumId}
  19. }
  20. enterprise := map[string]interface{}{
  21. "state": medium.State,
  22. "data": medium,
  23. }
  24. NewMediumBankInfoDb := implement.NewMediumBankInfoDb(db.Db)
  25. bank, _ := NewMediumBankInfoDb.GetMediumBankInfoList(admin.MediumId)
  26. if bank == nil {
  27. bank = &model2.MediumBankInfo{Uuid: medium.Uuid, MediumId: medium.MediumId}
  28. }
  29. bankInfo := map[string]interface{}{
  30. "state": bank.State,
  31. "data": bank,
  32. }
  33. NewMediumContactInfoDb := implement.NewMediumContactInfoDb(db.Db)
  34. contact, _ := NewMediumContactInfoDb.GetMediumContactInfoList(admin.MediumId)
  35. if contact == nil {
  36. contact = &model2.MediumContactInfo{Uuid: medium.Uuid, MediumId: medium.MediumId}
  37. }
  38. contactInfo := map[string]interface{}{
  39. "state": 0,
  40. "data": contact,
  41. }
  42. res := map[string]interface{}{
  43. "enterprise": enterprise,
  44. "bank_info": bankInfo,
  45. "contact_info": contactInfo,
  46. "state_list": []map[string]interface{}{
  47. {"value": "0", "name": "待提交"},
  48. {"value": "1", "name": "待审核"},
  49. {"value": "2", "name": "审核通过"},
  50. {"value": "3", "name": "审核拒绝"},
  51. },
  52. }
  53. e.OutSuc(c, res, nil)
  54. return
  55. }
  56. func QualificationSelectBase(c *gin.Context) {
  57. countryDb := implement.NewCountryDb(db.Db)
  58. country := countryDb.FindAll()
  59. IdcardTypeListDb := implement.NewIdcardTypeListDb(db.Db)
  60. IdcardTypeList := IdcardTypeListDb.FindAll()
  61. res := map[string]interface{}{
  62. "register_area": country,
  63. "idcard_type": IdcardTypeList,
  64. "country": md.Country,
  65. "user_type": []map[string]interface{}{
  66. {
  67. "value": "1", "name": "企业",
  68. },
  69. },
  70. "currency_conf": md.CurrencyConf,
  71. }
  72. e.OutSuc(c, res, nil)
  73. return
  74. }
  75. func QualificationEnterpriseSave(c *gin.Context, req md.MediumList) error {
  76. req.State = 1
  77. var data model2.MediumList
  78. copier.Copy(&data, &req)
  79. data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
  80. if req.Id > 0 {
  81. listDb := implement.NewMediumListDb(db.Db)
  82. list, _ := listDb.GetMediumList(req.MediumId)
  83. if list.State == 1 {
  84. return e.NewErr(400, "该记录已提交审核")
  85. }
  86. if list.State == 2 {
  87. return e.NewErr(400, "该记录已审核通过")
  88. }
  89. db.Db.Where("id=?", req.Id).Update(&data)
  90. } else {
  91. data.CreateAt = time.Now().Format("2006-01-02 15:04:05")
  92. db.Db.InsertOne(&data)
  93. }
  94. return nil
  95. }
  96. func QualificationBankSave(c *gin.Context, req md.MediumBankInfo) error {
  97. req.State = 1
  98. var data model2.MediumBankInfo
  99. copier.Copy(&data, &req)
  100. data.UpdateAt = time.Now()
  101. if req.Id > 0 {
  102. listDb := implement.NewMediumBankInfoDb(db.Db)
  103. list, _ := listDb.GetMediumBankInfoList(req.MediumId)
  104. if list.State == 1 {
  105. return e.NewErr(400, "该记录已提交审核")
  106. }
  107. if list.State == 2 {
  108. return e.NewErr(400, "该记录已审核通过")
  109. }
  110. db.Db.Where("id=?", req.Id).Update(&data)
  111. } else {
  112. data.CreateAt = time.Now()
  113. db.Db.InsertOne(&data)
  114. }
  115. return nil
  116. }
  117. func QualificationContactSave(c *gin.Context, req md.MediumContactInfo) error {
  118. req.State = 1
  119. var data model2.MediumContactInfo
  120. copier.Copy(&data, &req)
  121. data.UpdateAt = time.Now()
  122. if req.Id > 0 {
  123. listDb := implement.NewMediumContactInfoDb(db.Db)
  124. list, _ := listDb.GetMediumContactInfoList(req.MediumId)
  125. if list.State == 1 {
  126. return e.NewErr(400, "该记录已提交审核")
  127. }
  128. if list.State == 2 {
  129. return e.NewErr(400, "该记录已审核通过")
  130. }
  131. db.Db.Where("id=?", req.Id).Update(&data)
  132. } else {
  133. data.CreateAt = time.Now()
  134. db.Db.InsertOne(&data)
  135. }
  136. return nil
  137. }