广告平台(站长下代理使用)
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.

svc_qualification.go 4.0 KiB

4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. AgentListDb := implement.NewAgentListDb(db.Db)
  16. Agent, _ := AgentListDb.GetAgentList(admin.AgentId)
  17. if Agent == nil {
  18. Agent = &model2.AgentList{Uuid: utils.StrToInt(c.GetString("mid")), AgentId: admin.AgentId}
  19. }
  20. enterprise := map[string]interface{}{
  21. "state": Agent.State,
  22. "data": Agent,
  23. }
  24. NewAgentBankInfoDb := implement.NewAgentBankInfoDb(db.Db)
  25. bank, _ := NewAgentBankInfoDb.GetAgentBankInfoList(admin.AgentId)
  26. if bank == nil {
  27. bank = &model2.AgentBankInfo{Uuid: Agent.Uuid, AgentId: Agent.AgentId}
  28. }
  29. bankInfo := map[string]interface{}{
  30. "state": bank.State,
  31. "data": bank,
  32. }
  33. NewAgentContactInfoDb := implement.NewAgentContactInfoDb(db.Db)
  34. contact, _ := NewAgentContactInfoDb.GetAgentContactInfoList(admin.AgentId)
  35. if contact == nil {
  36. contact = &model2.AgentContactInfo{Uuid: Agent.Uuid, AgentId: Agent.AgentId}
  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.AgentList) error {
  84. req.State = 1
  85. var data model2.AgentList
  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.NewAgentListDb(db.Db)
  90. list, _ := listDb.GetAgentList(req.AgentId)
  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.AgentBankInfo) error {
  105. req.State = 1
  106. var data model2.AgentBankInfo
  107. copier.Copy(&data, &req)
  108. data.UpdateAt = time.Now()
  109. if req.Id > 0 {
  110. listDb := implement.NewAgentBankInfoDb(db.Db)
  111. list, _ := listDb.GetAgentBankInfoList(req.AgentId)
  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.AgentContactInfo) error {
  126. req.State = 1
  127. var data model2.AgentContactInfo
  128. copier.Copy(&data, &req)
  129. data.UpdateAt = time.Now()
  130. if req.Id > 0 {
  131. listDb := implement.NewAgentContactInfoDb(db.Db)
  132. list, _ := listDb.GetAgentContactInfoList(req.AgentId)
  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. }