package svc import ( "applet/app/e" "applet/app/enum" "applet/app/md" "applet/app/utils" db "code.fnuoos.com/zhimeng/model.git/src" "code.fnuoos.com/zhimeng/model.git/src/super/implement" "github.com/gin-gonic/gin" "github.com/jinzhu/copier" ) func AgentQualificationEnterprise(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationEnterpriseRes { engine := db.Db agentListDb := implement.NewAgentListDb(engine) agentList, total, _ := agentListDb.FindAgentList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.AgentQualificationEnterpriseData, 0) if len(agentList) > 0 { 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) 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(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) list := make([]md.AgentQualificationBankData, 0) if agentList != nil { 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, } 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(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) list := make([]md.AgentQualificationContactData, 0) if agentList != nil { 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, } 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 }