|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- package svc
-
- import (
- "applet/app/e"
- "applet/app/enum"
- "applet/app/md"
- "applet/app/utils"
- db "code.fnuoos.com/zhimeng/model.git/src"
- implement2 "code.fnuoos.com/zhimeng/model.git/src/implement"
- "code.fnuoos.com/zhimeng/model.git/src/super/implement"
- "github.com/gin-gonic/gin"
- "github.com/jinzhu/copier"
- )
-
- func AgentQualificationEnterprise(c *gin.Context, minState int, req md.AgentQualificationEnterpriseReq) md.AgentQualificationEnterpriseRes {
-
- engine := db.Db
- agentListDb := implement.NewAgentListDb(engine)
- agentList, total, _ := agentListDb.FindAgentList(c.GetString("mid"), req.Name, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
- data := make([]md.AgentQualificationEnterpriseData, 0)
- if len(agentList) > 0 {
- NewAgentDb := implement2.NewAgentDb(MasterDb(c))
- for _, v := range agentList {
- var tmp md.AgentQualificationEnterpriseData
- copier.Copy(&tmp, &v)
- tmp.Id = utils.IntToStr(v.Id)
- tmp.Uuid = utils.IntToStr(v.Uuid)
- tmp.AgentId = utils.IntToStr(v.AgentId)
- tmp.Kind = utils.IntToStr(v.Kind)
- tmp.CertificateType = utils.IntToStr(v.CertificateType)
- tmp.CertificateFirstType = utils.IntToStr(v.CertificateFirstType)
- tmp.CountryRegionId = utils.IntToStr(v.CountryRegionId)
- tmp.RegisteredAddressCountryId = utils.IntToStr(v.RegisteredAddressCountryId)
- tmp.RegisteredAddressProvinceId = utils.IntToStr(v.RegisteredAddressProvinceId)
- tmp.RegisteredAddressCityId = utils.IntToStr(v.RegisteredAddressCityId)
- tmp.RegisteredAddressCountyId = utils.IntToStr(v.RegisteredAddressCountyId)
- tmp.State = utils.IntToStr(v.State)
- agent := NewAgentDb.GetSuperAdmin(v.AgentId)
- if agent != nil {
- tmp.Account = agent.Username
- }
- data = append(data, tmp)
- }
- }
- res := md.AgentQualificationEnterpriseRes{
- List: data,
- Total: total,
- State: []md.SelectData{
- {
- Name: enum.QualificationState(enum.QualificationStateForWait).String(),
- Value: utils.IntToStr(enum.QualificationStateForWait),
- },
- {
- Name: enum.QualificationState(enum.QualificationStateForNormal).String(),
- Value: utils.IntToStr(enum.QualificationStateForNormal),
- },
- {
- Name: enum.QualificationState(enum.QualificationStateForFail).String(),
- Value: utils.IntToStr(enum.QualificationStateForFail),
- },
- },
- Type: []md.SelectData{
- {
- Name: enum.QualificationType(enum.QualificationTypeCompany).String(),
- Value: utils.IntToStr(enum.QualificationTypeCompany),
- },
- {
- Name: enum.QualificationType(enum.QualificationTypeOwn).String(),
- Value: utils.IntToStr(enum.QualificationTypeOwn),
- },
- },
- }
- return res
- }
-
- func AgentQualificationEnterpriseAudit(c *gin.Context, req md.AgentQualificationEnterpriseAuditReq) error {
- engine := db.Db
- agentListDb := implement.NewAgentListDb(engine)
- data, _ := agentListDb.GetAgentList(utils.StrToInt(req.AgentId))
- if data == nil {
- return e.NewErr(400, "记录不存在")
- }
- if data.State == 1 {
- return e.NewErr(400, "记录已审核过")
- }
- data.State = utils.StrToInt(req.State)
- data.Memo = req.Memo
- engine.Where("agent_id=?", data.AgentId).Cols("state,memo").Update(data)
- return nil
- }
-
- func AgentQualificationBank(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationBankRes {
- engine := db.Db
- agentListDb := implement.NewAgentBankInfoDb(engine)
- agentList, total, _ := agentListDb.FindAgentBankInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
- list := make([]md.AgentQualificationBankData, 0)
- if agentList != nil {
- NewAgentDb := implement2.NewAgentDb(MasterDb(c))
- for _, v := range agentList {
- tmp := md.AgentQualificationBankData{
- Id: utils.IntToStr(v.AgentBankInfo.Id),
- AgentId: utils.IntToStr(v.AgentBankInfo.AgentId),
- CompanyName: v.CompanyName,
- UnifiedSocialCreditCode: v.UnifiedSocialCreditCode,
- Kind: utils.IntToStr(v.Kind),
- State: utils.IntToStr(v.AgentBankInfo.State),
- Memo: v.AgentBankInfo.Memo,
- CurrencyConf: utils.IntToStr(v.CurrencyConf),
- Bank: v.Bank,
- BankBranch: v.BankBranch,
- BankNo: v.BankNo,
- Licence: v.Licence,
- }
- agent := NewAgentDb.GetSuperAdmin(v.AgentBankInfo.AgentId)
- if agent != nil {
- tmp.Account = agent.Username
- }
- list = append(list, tmp)
- }
- }
- res := md.AgentQualificationBankRes{
- List: list,
- Total: total,
- CurrencyConf: []md.SelectData{
- {
- Value: "0", Name: "人民币",
- },
- },
- State: []md.SelectData{
- {
- Name: enum.QualificationState(enum.QualificationStateForWait).String(),
- Value: utils.IntToStr(enum.QualificationStateForWait),
- },
- {
- Name: enum.QualificationState(enum.QualificationStateForNormal).String(),
- Value: utils.IntToStr(enum.QualificationStateForNormal),
- },
- {
- Name: enum.QualificationState(enum.QualificationStateForFail).String(),
- Value: utils.IntToStr(enum.QualificationStateForFail),
- },
- },
- Type: []md.SelectData{
- {
- Name: enum.QualificationType(enum.QualificationTypeCompany).String(),
- Value: utils.IntToStr(enum.QualificationTypeCompany),
- },
- {
- Name: enum.QualificationType(enum.QualificationTypeOwn).String(),
- Value: utils.IntToStr(enum.QualificationTypeOwn),
- },
- },
- }
- return res
- }
- func AgentQualificationBankAudit(c *gin.Context, req md.AgentQualificationEnterpriseAuditReq) error {
- engine := db.Db
- agentListDb := implement.NewAgentBankInfoDb(engine)
- data, _ := agentListDb.GetAgentBankInfoList(utils.StrToInt(req.AgentId))
- if data == nil {
- return e.NewErr(400, "记录不存在")
- }
- if data.State == 1 {
- return e.NewErr(400, "记录已审核过")
- }
- data.State = utils.StrToInt(req.State)
- data.Memo = req.Memo
- engine.Where("agent_id=?", data.AgentId).Cols("state,memo").Update(data)
- return nil
- }
-
- func AgentQualificationContactInfo(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationContactRes {
- engine := db.Db
- agentListDb := implement.NewAgentContactInfoDb(engine)
- agentList, total, _ := agentListDb.FindAgentContactInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
-
- list := make([]md.AgentQualificationContactData, 0)
- if agentList != nil {
- NewAgentDb := implement2.NewAgentDb(MasterDb(c))
- for _, v := range agentList {
- tmp := md.AgentQualificationContactData{
- Id: utils.IntToStr(v.AgentContactInfo.Id),
- AgentId: utils.IntToStr(v.AgentContactInfo.AgentId),
- CompanyName: v.CompanyName,
- Kind: utils.IntToStr(v.Kind),
- State: utils.IntToStr(v.AgentContactInfo.State),
- Memo: v.AgentContactInfo.Memo,
- Name: v.AgentContactInfo.Name,
- Email: v.AgentContactInfo.Email,
- Phone: v.AgentContactInfo.Phone,
- Address: v.AgentContactInfo.Address,
- }
-
- agent := NewAgentDb.GetSuperAdmin(v.AgentContactInfo.AgentId)
- if agent != nil {
- tmp.Account = agent.Username
- }
- list = append(list, tmp)
- }
- }
- res := md.AgentQualificationContactRes{
- List: list,
- Total: total,
- State: []md.SelectData{
- {
- Name: enum.QualificationState(enum.QualificationStateForWait).String(),
- Value: utils.IntToStr(enum.QualificationStateForWait),
- },
- {
- Name: enum.QualificationState(enum.QualificationStateForNormal).String(),
- Value: utils.IntToStr(enum.QualificationStateForNormal),
- },
- {
- Name: enum.QualificationState(enum.QualificationStateForFail).String(),
- Value: utils.IntToStr(enum.QualificationStateForFail),
- },
- },
- }
- return res
- }
- func AgentQualificationContactInfoAudit(c *gin.Context, req md.AgentQualificationEnterpriseAuditReq) error {
- engine := db.Db
- agentListDb := implement.NewAgentContactInfoDb(engine)
- data, _ := agentListDb.GetAgentContactInfoList(utils.StrToInt(req.AgentId))
- if data == nil {
- return e.NewErr(400, "记录不存在")
- }
- if data.State == 1 {
- return e.NewErr(400, "记录已审核过")
- }
- data.State = utils.StrToInt(req.State)
- data.Memo = req.Memo
- engine.Where("agent_id=?", data.AgentId).Cols("state,memo").Update(data)
- return nil
- }
|