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

192 lines
6.5 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. var mediumNew md.MediumList
  21. copier.Copy(&mediumNew, &medium)
  22. mediumNew.Id = utils.IntToStr(medium.Id)
  23. mediumNew.Uuid = utils.IntToStr(medium.Uuid)
  24. mediumNew.MediumId = utils.IntToStr(medium.MediumId)
  25. mediumNew.Kind = utils.IntToStr(medium.Kind)
  26. mediumNew.CertificateType = utils.IntToStr(medium.CertificateType)
  27. mediumNew.CertificateFirstType = utils.IntToStr(medium.CertificateFirstType)
  28. mediumNew.CountryRegionId = utils.IntToStr(medium.CountryRegionId)
  29. mediumNew.RegisteredAddressCountryId = utils.IntToStr(medium.RegisteredAddressCountryId)
  30. mediumNew.RegisteredAddressProvinceId = utils.IntToStr(medium.RegisteredAddressProvinceId)
  31. mediumNew.RegisteredAddressCountyId = utils.IntToStr(medium.RegisteredAddressCountyId)
  32. mediumNew.RegisteredAddressCityId = utils.IntToStr(medium.RegisteredAddressCityId)
  33. mediumNew.State = utils.IntToStr(medium.State)
  34. enterprise := map[string]interface{}{
  35. "state": mediumNew.State,
  36. "data": mediumNew,
  37. }
  38. NewMediumBankInfoDb := implement.NewMediumBankInfoDb(db.Db)
  39. bank, _ := NewMediumBankInfoDb.GetMediumBankInfoList(admin.MediumId)
  40. if bank == nil {
  41. bank = &model2.MediumBankInfo{Uuid: medium.Uuid, MediumId: medium.MediumId}
  42. }
  43. var bankNew md.MediumBankInfo
  44. copier.Copy(&bankNew, &bank)
  45. bankNew.State = utils.IntToStr(bank.State)
  46. bankNew.Id = utils.IntToStr(bank.Id)
  47. bankNew.Uuid = utils.IntToStr(bank.Uuid)
  48. bankNew.MediumId = utils.IntToStr(bank.MediumId)
  49. bankNew.CurrencyConf = utils.IntToStr(bank.CurrencyConf)
  50. bankInfo := map[string]interface{}{
  51. "state": bankNew.State,
  52. "data": bankNew,
  53. }
  54. NewMediumContactInfoDb := implement.NewMediumContactInfoDb(db.Db)
  55. contact, _ := NewMediumContactInfoDb.GetMediumContactInfoList(admin.MediumId)
  56. if contact == nil {
  57. contact = &model2.MediumContactInfo{Uuid: medium.Uuid, MediumId: medium.MediumId}
  58. }
  59. var contactNew md.MediumContactInfo
  60. copier.Copy(&contactNew, &contact)
  61. contactNew.State = utils.IntToStr(contact.State)
  62. contactNew.Id = utils.IntToStr(contact.Id)
  63. contactNew.Uuid = utils.IntToStr(contact.Uuid)
  64. contactNew.MediumId = utils.IntToStr(contact.MediumId)
  65. contactInfo := map[string]interface{}{
  66. "state": contactNew.State,
  67. "data": contactNew,
  68. }
  69. res := map[string]interface{}{
  70. "enterprise": enterprise,
  71. "bank_info": bankInfo,
  72. "contact_info": contactInfo,
  73. "state_list": []map[string]interface{}{
  74. {"value": "0", "name": "待提交"},
  75. {"value": "1", "name": "待审核"},
  76. {"value": "2", "name": "审核通过"},
  77. {"value": "3", "name": "审核拒绝"},
  78. },
  79. }
  80. e.OutSuc(c, res, nil)
  81. return
  82. }
  83. func QualificationSelectBase(c *gin.Context) {
  84. countryDb := implement.NewCountryDb(db.Db)
  85. country := countryDb.FindAll()
  86. IdcardTypeListDb := implement.NewIdcardTypeListDb(db.Db)
  87. IdcardTypeList := IdcardTypeListDb.FindAll()
  88. res := map[string]interface{}{
  89. "register_area": country,
  90. "idcard_type": IdcardTypeList,
  91. "country": md.Country,
  92. "user_type": []map[string]interface{}{
  93. {
  94. "value": "1", "name": "企业",
  95. },
  96. },
  97. "currency_conf": md.CurrencyConf,
  98. }
  99. e.OutSuc(c, res, nil)
  100. return
  101. }
  102. func QualificationEnterpriseSave(c *gin.Context, req md.MediumList) error {
  103. req.State = "1"
  104. var data model2.MediumList
  105. copier.Copy(&data, &req)
  106. data.Id = utils.StrToInt(req.Id)
  107. data.Uuid = utils.StrToInt(req.Uuid)
  108. data.MediumId = utils.StrToInt(req.MediumId)
  109. data.Kind = utils.StrToInt(req.Kind)
  110. data.CertificateType = utils.StrToInt(req.CertificateType)
  111. data.CertificateFirstType = utils.StrToInt(req.CertificateFirstType)
  112. data.CountryRegionId = utils.StrToInt(req.CountryRegionId)
  113. data.RegisteredAddressCountryId = utils.StrToInt(req.RegisteredAddressCountryId)
  114. data.RegisteredAddressProvinceId = utils.StrToInt(req.RegisteredAddressProvinceId)
  115. data.RegisteredAddressCountyId = utils.StrToInt(req.RegisteredAddressCountyId)
  116. data.RegisteredAddressCityId = utils.StrToInt(req.RegisteredAddressCityId)
  117. data.State = utils.StrToInt(req.State)
  118. data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
  119. if utils.StrToInt(req.Id) > 0 {
  120. listDb := implement.NewMediumListDb(db.Db)
  121. list, _ := listDb.GetMediumList(utils.StrToInt(req.MediumId))
  122. if list.State == 1 {
  123. return e.NewErr(400, "该记录已提交审核")
  124. }
  125. if list.State == 2 {
  126. return e.NewErr(400, "该记录已审核通过")
  127. }
  128. db.Db.Where("id=?", req.Id).Update(&data)
  129. } else {
  130. data.CreateAt = time.Now().Format("2006-01-02 15:04:05")
  131. db.Db.InsertOne(&data)
  132. }
  133. return nil
  134. }
  135. func QualificationBankSave(c *gin.Context, req md.MediumBankInfo) error {
  136. req.State = "1"
  137. var data model2.MediumBankInfo
  138. copier.Copy(&data, &req)
  139. data.State = utils.StrToInt(req.State)
  140. data.Id = utils.StrToInt(req.Id)
  141. data.Uuid = utils.StrToInt(req.Uuid)
  142. data.MediumId = utils.StrToInt(req.MediumId)
  143. data.CurrencyConf = utils.StrToInt(req.CurrencyConf)
  144. data.UpdateAt = time.Now()
  145. if utils.StrToInt(req.Id) > 0 {
  146. listDb := implement.NewMediumBankInfoDb(db.Db)
  147. list, _ := listDb.GetMediumBankInfoList(utils.StrToInt(req.MediumId))
  148. if list.State == 1 {
  149. return e.NewErr(400, "该记录已提交审核")
  150. }
  151. if list.State == 2 {
  152. return e.NewErr(400, "该记录已审核通过")
  153. }
  154. db.Db.Where("id=?", req.Id).Update(&data)
  155. } else {
  156. data.CreateAt = time.Now()
  157. db.Db.InsertOne(&data)
  158. }
  159. return nil
  160. }
  161. func QualificationContactSave(c *gin.Context, req md.MediumContactInfo) error {
  162. req.State = "1"
  163. var data model2.MediumContactInfo
  164. copier.Copy(&data, &req)
  165. data.UpdateAt = time.Now()
  166. data.State = utils.StrToInt(req.State)
  167. data.Id = utils.StrToInt(req.Id)
  168. data.Uuid = utils.StrToInt(req.Uuid)
  169. data.MediumId = utils.StrToInt(req.MediumId)
  170. if utils.StrToInt(req.Id) > 0 {
  171. listDb := implement.NewMediumContactInfoDb(db.Db)
  172. list, _ := listDb.GetMediumContactInfoList(utils.StrToInt(req.MediumId))
  173. if list.State == 1 {
  174. return e.NewErr(400, "该记录已提交审核")
  175. }
  176. if list.State == 2 {
  177. return e.NewErr(400, "该记录已审核通过")
  178. }
  179. db.Db.Where("id=?", req.Id).Update(&data)
  180. } else {
  181. data.CreateAt = time.Now()
  182. db.Db.InsertOne(&data)
  183. }
  184. return nil
  185. }