|
- package svc
-
- import (
- "applet/app/e"
- "applet/app/md"
- "applet/app/utils"
- db "code.fnuoos.com/zhimeng/model.git/src"
- "code.fnuoos.com/zhimeng/model.git/src/super/implement"
- model2 "code.fnuoos.com/zhimeng/model.git/src/super/model"
- "github.com/gin-gonic/gin"
- "github.com/jinzhu/copier"
- "time"
- )
-
- func QualificationInfo(c *gin.Context) {
- admin := GetUser(c)
- AgentListDb := implement.NewAgentListDb(db.Db)
- Agent, _ := AgentListDb.GetAgentList(admin.AgentId)
- if Agent == nil {
- Agent = &model2.AgentList{Uuid: utils.StrToInt(c.GetString("mid")), AgentId: admin.AgentId}
- }
- var AgentNew md.AgentList
- copier.Copy(&AgentNew, &Agent)
- AgentNew.Id = utils.IntToStr(Agent.Id)
- AgentNew.Uuid = utils.IntToStr(Agent.Uuid)
- AgentNew.AgentId = utils.IntToStr(Agent.AgentId)
- AgentNew.Kind = utils.IntToStr(Agent.Kind)
- AgentNew.CertificateType = utils.IntToStr(Agent.CertificateType)
- AgentNew.CertificateFirstType = utils.IntToStr(Agent.CertificateFirstType)
- AgentNew.CountryRegionId = utils.IntToStr(Agent.CountryRegionId)
- AgentNew.RegisteredAddressCountryId = utils.IntToStr(Agent.RegisteredAddressCountryId)
- AgentNew.RegisteredAddressProvinceId = utils.IntToStr(Agent.RegisteredAddressProvinceId)
- AgentNew.RegisteredAddressCountyId = utils.IntToStr(Agent.RegisteredAddressCountyId)
- AgentNew.RegisteredAddressCityId = utils.IntToStr(Agent.RegisteredAddressCityId)
- AgentNew.State = utils.IntToStr(Agent.State)
- enterprise := map[string]interface{}{
- "state": AgentNew.State,
- "data": AgentNew,
- }
- NewAgentBankInfoDb := implement.NewAgentBankInfoDb(db.Db)
- bank, _ := NewAgentBankInfoDb.GetAgentBankInfoList(admin.AgentId)
- if bank == nil {
- bank = &model2.AgentBankInfo{Uuid: Agent.Uuid, AgentId: Agent.AgentId}
- }
- var bankNew md.AgentBankInfo
- copier.Copy(&bankNew, &bank)
- bankNew.State = utils.IntToStr(bank.State)
- bankNew.Id = utils.IntToStr(bank.Id)
- bankNew.Uuid = utils.IntToStr(bank.Uuid)
- bankNew.AgentId = utils.IntToStr(bank.AgentId)
- bankNew.CurrencyConf = utils.IntToStr(bank.CurrencyConf)
-
- bankInfo := map[string]interface{}{
- "state": bankNew.State,
- "data": bankNew,
- }
- NewAgentContactInfoDb := implement.NewAgentContactInfoDb(db.Db)
- contact, _ := NewAgentContactInfoDb.GetAgentContactInfoList(admin.AgentId)
- if contact == nil {
- contact = &model2.AgentContactInfo{Uuid: Agent.Uuid, AgentId: Agent.AgentId}
- }
- var contactNew md.AgentContactInfo
- copier.Copy(&contactNew, &contact)
- contactNew.State = utils.IntToStr(contact.State)
- contactNew.Id = utils.IntToStr(contact.Id)
- contactNew.Uuid = utils.IntToStr(contact.Uuid)
- contactNew.AgentId = utils.IntToStr(contact.AgentId)
- contactInfo := map[string]interface{}{
- "state": contactNew.State,
- "data": contactNew,
- }
- res := map[string]interface{}{
- "enterprise": enterprise,
- "bank_info": bankInfo,
- "contact_info": contactInfo,
- "state_list": []map[string]interface{}{
- {"value": "0", "name": "待提交"},
- {"value": "1", "name": "待审核"},
- {"value": "2", "name": "审核通过"},
- {"value": "3", "name": "审核拒绝"},
- },
- }
- e.OutSuc(c, res, nil)
- return
- }
-
- func QualificationSelectBase(c *gin.Context) {
- countryDb := implement.NewCountryDb(db.Db)
- country := countryDb.FindAll()
- IdcardTypeListDb := implement.NewIdcardTypeListDb(db.Db)
- IdcardTypeList := IdcardTypeListDb.FindAll()
- res := map[string]interface{}{
- "register_area": country,
- "idcard_type": IdcardTypeList,
- "country": []map[string]interface{}{
- {
- "value": "1", "name": "中国/国内",
- },
- },
- "user_type": []map[string]interface{}{
- {
- "value": "1", "name": "企业",
- },
- },
- "currency_conf": []map[string]interface{}{
- {
- "value": "0", "name": "人民币",
- },
- },
- }
- e.OutSuc(c, res, nil)
- return
- }
- func QualificationEnterpriseSave(c *gin.Context, req md.AgentList) error {
- req.State = "1"
- var data model2.AgentList
- copier.Copy(&data, &req)
- data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
- data.Id = utils.StrToInt(req.Id)
- data.Uuid = utils.StrToInt(req.Uuid)
- data.AgentId = utils.StrToInt(req.AgentId)
- data.Kind = utils.StrToInt(req.Kind)
- data.CertificateType = utils.StrToInt(req.CertificateType)
- data.CertificateFirstType = utils.StrToInt(req.CertificateFirstType)
- data.CountryRegionId = utils.StrToInt(req.CountryRegionId)
- data.RegisteredAddressCountryId = utils.StrToInt(req.RegisteredAddressCountryId)
- data.RegisteredAddressProvinceId = utils.StrToInt(req.RegisteredAddressProvinceId)
- data.RegisteredAddressCountyId = utils.StrToInt(req.RegisteredAddressCountyId)
- data.RegisteredAddressCityId = utils.StrToInt(req.RegisteredAddressCityId)
- data.State = utils.StrToInt(req.State)
- if utils.StrToInt(req.Id) > 0 {
- listDb := implement.NewAgentListDb(db.Db)
- list, _ := listDb.GetAgentList(utils.StrToInt(req.AgentId))
- if list.State == 1 {
- return e.NewErr(400, "该记录已提交审核")
- }
- if list.State == 2 {
- return e.NewErr(400, "该记录已审核通过")
- }
- db.Db.Where("id=?", req.Id).Update(&data)
- } else {
- data.CreateAt = time.Now().Format("2006-01-02 15:04:05")
- db.Db.InsertOne(&data)
- }
- return nil
- }
- func QualificationBankSave(c *gin.Context, req md.AgentBankInfo) error {
- req.State = "1"
-
- var data model2.AgentBankInfo
- copier.Copy(&data, &req)
- data.State = utils.StrToInt(req.State)
- data.Id = utils.StrToInt(req.Id)
- data.Uuid = utils.StrToInt(req.Uuid)
- data.AgentId = utils.StrToInt(req.AgentId)
- data.CurrencyConf = utils.StrToInt(req.CurrencyConf)
- data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
- if utils.StrToInt(req.Id) > 0 {
-
- listDb := implement.NewAgentBankInfoDb(db.Db)
- list, _ := listDb.GetAgentBankInfoList(utils.StrToInt(req.AgentId))
- if list.State == 1 {
- return e.NewErr(400, "该记录已提交审核")
- }
- if list.State == 2 {
- return e.NewErr(400, "该记录已审核通过")
- }
- db.Db.Where("id=?", req.Id).Update(&data)
- } else {
- data.CreateAt = time.Now().Format("2006-01-02 15:04:05")
- db.Db.InsertOne(&data)
- }
- return nil
- }
- func QualificationContactSave(c *gin.Context, req md.AgentContactInfo) error {
- req.State = "1"
-
- var data model2.AgentContactInfo
- copier.Copy(&data, &req)
- data.State = utils.StrToInt(req.State)
- data.Id = utils.StrToInt(req.Id)
- data.Uuid = utils.StrToInt(req.Uuid)
- data.AgentId = utils.StrToInt(req.AgentId)
- data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
- if utils.StrToInt(req.Id) > 0 {
-
- listDb := implement.NewAgentContactInfoDb(db.Db)
- list, _ := listDb.GetAgentContactInfoList(utils.StrToInt(req.AgentId))
- if list.State == 1 {
- return e.NewErr(400, "该记录已提交审核")
- }
- if list.State == 2 {
- return e.NewErr(400, "该记录已审核通过")
- }
- db.Db.Where("id=?", req.Id).Update(&data)
- } else {
- data.CreateAt = time.Now().Format("2006-01-02 15:04:05")
- db.Db.InsertOne(&data)
- }
- return nil
- }
|