广告平台(媒体使用)
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

152 řádky
4.0 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": []map[string]interface{}{
  65. {
  66. "value": "1", "name": "中国/国内",
  67. },
  68. },
  69. "user_type": []map[string]interface{}{
  70. {
  71. "value": "1", "name": "企业",
  72. },
  73. },
  74. "currency_conf": []map[string]interface{}{
  75. {
  76. "value": "0", "name": "人民币",
  77. },
  78. },
  79. }
  80. e.OutSuc(c, res, nil)
  81. return
  82. }
  83. func QualificationEnterpriseSave(c *gin.Context, req md.MediumList) error {
  84. req.State = 1
  85. var data model2.MediumList
  86. copier.Copy(&data, &req)
  87. data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
  88. if req.Id > 0 {
  89. listDb := implement.NewMediumListDb(db.Db)
  90. list, _ := listDb.GetMediumList(req.MediumId)
  91. if list.State == 1 {
  92. return e.NewErr(400, "该记录已提交审核")
  93. }
  94. if list.State == 2 {
  95. return e.NewErr(400, "该记录已审核通过")
  96. }
  97. db.Db.Where("id=?", req.Id).Update(&data)
  98. } else {
  99. data.CreateAt = time.Now().Format("2006-01-02 15:04:05")
  100. db.Db.InsertOne(&data)
  101. }
  102. return nil
  103. }
  104. func QualificationBankSave(c *gin.Context, req md.MediumBankInfo) error {
  105. req.State = 1
  106. var data model2.MediumBankInfo
  107. copier.Copy(&data, &req)
  108. data.UpdateAt = time.Now()
  109. if req.Id > 0 {
  110. listDb := implement.NewMediumBankInfoDb(db.Db)
  111. list, _ := listDb.GetMediumBankInfoList(req.MediumId)
  112. if list.State == 1 {
  113. return e.NewErr(400, "该记录已提交审核")
  114. }
  115. if list.State == 2 {
  116. return e.NewErr(400, "该记录已审核通过")
  117. }
  118. db.Db.Where("id=?", req.Id).Update(&data)
  119. } else {
  120. data.CreateAt = time.Now()
  121. db.Db.InsertOne(&data)
  122. }
  123. return nil
  124. }
  125. func QualificationContactSave(c *gin.Context, req md.MediumContactInfo) error {
  126. req.State = 1
  127. var data model2.MediumContactInfo
  128. copier.Copy(&data, &req)
  129. data.UpdateAt = time.Now()
  130. if req.Id > 0 {
  131. listDb := implement.NewMediumContactInfoDb(db.Db)
  132. list, _ := listDb.GetMediumContactInfoList(req.MediumId)
  133. if list.State == 1 {
  134. return e.NewErr(400, "该记录已提交审核")
  135. }
  136. if list.State == 2 {
  137. return e.NewErr(400, "该记录已审核通过")
  138. }
  139. db.Db.Where("id=?", req.Id).Update(&data)
  140. } else {
  141. data.CreateAt = time.Now()
  142. db.Db.InsertOne(&data)
  143. }
  144. return nil
  145. }