广告平台(站长使用)
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

256 rader
8.6 KiB

  1. package svc
  2. import (
  3. "applet/app/e"
  4. "applet/app/enum"
  5. "applet/app/md"
  6. "applet/app/utils"
  7. db "code.fnuoos.com/zhimeng/model.git/src"
  8. implement2 "code.fnuoos.com/zhimeng/model.git/src/implement"
  9. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  10. "github.com/gin-gonic/gin"
  11. "github.com/jinzhu/copier"
  12. )
  13. func QualificationSelectBase(c *gin.Context) {
  14. countryDb := implement.NewCountryDb(db.Db)
  15. country := countryDb.FindAll()
  16. IdcardTypeListDb := implement.NewIdcardTypeListDb(db.Db)
  17. IdcardTypeList := IdcardTypeListDb.FindAll()
  18. res := map[string]interface{}{
  19. "register_area": country,
  20. "idcard_type": IdcardTypeList,
  21. "country": md.Country,
  22. "user_type": []map[string]interface{}{
  23. {
  24. "value": "1", "name": "企业",
  25. },
  26. },
  27. "currency_conf": md.CurrencyConf,
  28. }
  29. e.OutSuc(c, res, nil)
  30. return
  31. }
  32. func AgentQualificationEnterprise(c *gin.Context, minState int, req md.AgentQualificationEnterpriseReq) md.AgentQualificationEnterpriseRes {
  33. engine := db.Db
  34. agentListDb := implement.NewAgentListDb(engine)
  35. agentList, total, _ := agentListDb.FindAgentList(c.GetString("mid"), req.Name, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  36. data := make([]md.AgentQualificationEnterpriseData, 0)
  37. if len(agentList) > 0 {
  38. NewAgentDb := implement2.NewAgentDb(MasterDb(c))
  39. for _, v := range agentList {
  40. var tmp md.AgentQualificationEnterpriseData
  41. copier.Copy(&tmp, &v)
  42. tmp.Id = utils.IntToStr(v.Id)
  43. tmp.Uuid = utils.IntToStr(v.Uuid)
  44. tmp.AgentId = utils.IntToStr(v.AgentId)
  45. tmp.Kind = utils.IntToStr(v.Kind)
  46. tmp.CertificateType = utils.IntToStr(v.CertificateType)
  47. tmp.CertificateFirstType = utils.IntToStr(v.CertificateFirstType)
  48. tmp.CountryRegionId = utils.IntToStr(v.CountryRegionId)
  49. tmp.RegisteredAddressCountryId = utils.IntToStr(v.RegisteredAddressCountryId)
  50. tmp.RegisteredAddressProvinceId = utils.IntToStr(v.RegisteredAddressProvinceId)
  51. tmp.RegisteredAddressCityId = utils.IntToStr(v.RegisteredAddressCityId)
  52. tmp.RegisteredAddressCountyId = utils.IntToStr(v.RegisteredAddressCountyId)
  53. tmp.State = utils.IntToStr(v.State)
  54. agent := NewAgentDb.GetSuperAdmin(v.AgentId)
  55. if agent != nil {
  56. tmp.Account = agent.Username
  57. }
  58. data = append(data, tmp)
  59. }
  60. }
  61. res := md.AgentQualificationEnterpriseRes{
  62. List: data,
  63. Total: total,
  64. State: []md.SelectData{
  65. {
  66. Name: enum.QualificationState(enum.QualificationStateForWait).String(),
  67. Value: utils.IntToStr(enum.QualificationStateForWait),
  68. },
  69. {
  70. Name: enum.QualificationState(enum.QualificationStateForNormal).String(),
  71. Value: utils.IntToStr(enum.QualificationStateForNormal),
  72. },
  73. {
  74. Name: enum.QualificationState(enum.QualificationStateForFail).String(),
  75. Value: utils.IntToStr(enum.QualificationStateForFail),
  76. },
  77. },
  78. Type: []md.SelectData{
  79. {
  80. Name: enum.QualificationType(enum.QualificationTypeCompany).String(),
  81. Value: utils.IntToStr(enum.QualificationTypeCompany),
  82. },
  83. {
  84. Name: enum.QualificationType(enum.QualificationTypeOwn).String(),
  85. Value: utils.IntToStr(enum.QualificationTypeOwn),
  86. },
  87. },
  88. }
  89. return res
  90. }
  91. func AgentQualificationEnterpriseAudit(c *gin.Context, req md.AgentQualificationEnterpriseAuditReq) error {
  92. engine := db.Db
  93. agentListDb := implement.NewAgentListDb(engine)
  94. data, _ := agentListDb.GetAgentList(utils.StrToInt(req.AgentId))
  95. if data == nil {
  96. return e.NewErr(400, "记录不存在")
  97. }
  98. if data.State == 2 {
  99. return e.NewErr(400, "记录已审核过")
  100. }
  101. data.State = utils.StrToInt(req.State)
  102. data.Memo = req.Memo
  103. engine.Where("agent_id=?", data.AgentId).Cols("state,memo").Update(data)
  104. return nil
  105. }
  106. func AgentQualificationBank(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationBankRes {
  107. engine := db.Db
  108. agentListDb := implement.NewAgentBankInfoDb(engine)
  109. agentList, total, _ := agentListDb.FindAgentBankInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  110. list := make([]md.AgentQualificationBankData, 0)
  111. if agentList != nil {
  112. NewAgentDb := implement2.NewAgentDb(MasterDb(c))
  113. for _, v := range agentList {
  114. tmp := md.AgentQualificationBankData{
  115. Id: utils.IntToStr(v.AgentBankInfo.Id),
  116. AgentId: utils.IntToStr(v.AgentBankInfo.AgentId),
  117. CompanyName: v.CompanyName,
  118. UnifiedSocialCreditCode: v.UnifiedSocialCreditCode,
  119. Kind: utils.IntToStr(v.Kind),
  120. State: utils.IntToStr(v.AgentBankInfo.State),
  121. Memo: v.AgentBankInfo.Memo,
  122. CurrencyConf: utils.IntToStr(v.CurrencyConf),
  123. Bank: v.Bank,
  124. BankBranch: v.BankBranch,
  125. BankNo: v.BankNo,
  126. Licence: v.Licence,
  127. }
  128. agent := NewAgentDb.GetSuperAdmin(v.AgentBankInfo.AgentId)
  129. if agent != nil {
  130. tmp.Account = agent.Username
  131. }
  132. list = append(list, tmp)
  133. }
  134. }
  135. res := md.AgentQualificationBankRes{
  136. List: list,
  137. Total: total,
  138. CurrencyConf: []md.SelectData{
  139. {
  140. Value: "0", Name: "人民币",
  141. },
  142. },
  143. State: []md.SelectData{
  144. {
  145. Name: enum.QualificationState(enum.QualificationStateForWait).String(),
  146. Value: utils.IntToStr(enum.QualificationStateForWait),
  147. },
  148. {
  149. Name: enum.QualificationState(enum.QualificationStateForNormal).String(),
  150. Value: utils.IntToStr(enum.QualificationStateForNormal),
  151. },
  152. {
  153. Name: enum.QualificationState(enum.QualificationStateForFail).String(),
  154. Value: utils.IntToStr(enum.QualificationStateForFail),
  155. },
  156. },
  157. Type: []md.SelectData{
  158. {
  159. Name: enum.QualificationType(enum.QualificationTypeCompany).String(),
  160. Value: utils.IntToStr(enum.QualificationTypeCompany),
  161. },
  162. {
  163. Name: enum.QualificationType(enum.QualificationTypeOwn).String(),
  164. Value: utils.IntToStr(enum.QualificationTypeOwn),
  165. },
  166. },
  167. }
  168. return res
  169. }
  170. func AgentQualificationBankAudit(c *gin.Context, req md.AgentQualificationEnterpriseAuditReq) error {
  171. engine := db.Db
  172. agentListDb := implement.NewAgentBankInfoDb(engine)
  173. data, _ := agentListDb.GetAgentBankInfoList(utils.StrToInt(req.AgentId))
  174. if data == nil {
  175. return e.NewErr(400, "记录不存在")
  176. }
  177. if data.State == 2 {
  178. return e.NewErr(400, "记录已审核过")
  179. }
  180. data.State = utils.StrToInt(req.State)
  181. data.Memo = req.Memo
  182. engine.Where("agent_id=?", data.AgentId).Cols("state,memo").Update(data)
  183. return nil
  184. }
  185. func AgentQualificationContactInfo(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationContactRes {
  186. engine := db.Db
  187. agentListDb := implement.NewAgentContactInfoDb(engine)
  188. agentList, total, _ := agentListDb.FindAgentContactInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  189. list := make([]md.AgentQualificationContactData, 0)
  190. if agentList != nil {
  191. NewAgentDb := implement2.NewAgentDb(MasterDb(c))
  192. for _, v := range agentList {
  193. tmp := md.AgentQualificationContactData{
  194. Id: utils.IntToStr(v.AgentContactInfo.Id),
  195. AgentId: utils.IntToStr(v.AgentContactInfo.AgentId),
  196. CompanyName: v.CompanyName,
  197. Kind: utils.IntToStr(v.Kind),
  198. State: utils.IntToStr(v.AgentContactInfo.State),
  199. Memo: v.AgentContactInfo.Memo,
  200. Name: v.AgentContactInfo.Name,
  201. Email: v.AgentContactInfo.Email,
  202. Phone: v.AgentContactInfo.Phone,
  203. Address: v.AgentContactInfo.Address,
  204. }
  205. agent := NewAgentDb.GetSuperAdmin(v.AgentContactInfo.AgentId)
  206. if agent != nil {
  207. tmp.Account = agent.Username
  208. }
  209. list = append(list, tmp)
  210. }
  211. }
  212. res := md.AgentQualificationContactRes{
  213. List: list,
  214. Total: total,
  215. State: []md.SelectData{
  216. {
  217. Name: enum.QualificationState(enum.QualificationStateForWait).String(),
  218. Value: utils.IntToStr(enum.QualificationStateForWait),
  219. },
  220. {
  221. Name: enum.QualificationState(enum.QualificationStateForNormal).String(),
  222. Value: utils.IntToStr(enum.QualificationStateForNormal),
  223. },
  224. {
  225. Name: enum.QualificationState(enum.QualificationStateForFail).String(),
  226. Value: utils.IntToStr(enum.QualificationStateForFail),
  227. },
  228. },
  229. }
  230. return res
  231. }
  232. func AgentQualificationContactInfoAudit(c *gin.Context, req md.AgentQualificationEnterpriseAuditReq) error {
  233. engine := db.Db
  234. agentListDb := implement.NewAgentContactInfoDb(engine)
  235. data, _ := agentListDb.GetAgentContactInfoList(utils.StrToInt(req.AgentId))
  236. if data == nil {
  237. return e.NewErr(400, "记录不存在")
  238. }
  239. if data.State == 2 {
  240. return e.NewErr(400, "记录已审核过")
  241. }
  242. data.State = utils.StrToInt(req.State)
  243. data.Memo = req.Memo
  244. engine.Where("agent_id=?", data.AgentId).Cols("state,memo").Update(data)
  245. return nil
  246. }