|
- 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 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": md.Country,
- "user_type": []map[string]interface{}{
- {
- "value": "1", "name": "企业",
- },
- },
- "currency_conf": md.CurrencyConf,
- }
- e.OutSuc(c, res, nil)
- return
- }
-
- func AgentQualificationEnterprise(c *gin.Context, minState int, req md.AgentQualificationEnterpriseReq) md.AgentQualificationEnterpriseRes {
-
- engine := db.Db
- agentListDb := implement.NewAgentListDb(engine)
- user := GetUser(c)
- appIds := GetAgentIdStr(c, user.AdmId, req.Name, "")
- agentList, total, _ := agentListDb.FindAgentList(c.GetString("mid"), "", appIds, 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 == 2 {
- 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)
- user := GetUser(c)
- appIds := GetAgentIdStr(c, user.AdmId, req.Name, "")
- agentList, total, _ := agentListDb.FindAgentBankInfoList(c.GetString("mid"), "", appIds, 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 == 2 {
- 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)
- user := GetUser(c)
- appIds := GetAgentIdStr(c, user.AdmId, req.Name, "")
- agentList, total, _ := agentListDb.FindAgentContactInfoList(c.GetString("mid"), "", appIds, 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 == 2 {
- 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
- }
|