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 MediumQualificationEnterprise(c *gin.Context, minState int, req md.MediumQualificationEnterpriseReq) md.MediumQualificationEnterpriseRes { engine := db.Db MediumListDb := implement.NewMediumListDb(engine) user := GetUser(c) appIds := GetMediumIdStr(c, user.AdmId, req.Name, "") MediumList, total, _ := MediumListDb.FindMediumList(c.GetString("mid"), "", appIds, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.MediumQualificationEnterpriseData, 0) if len(MediumList) > 0 { NewMediumDb := implement2.NewMediumDb(MasterDb(c)) for _, v := range MediumList { var tmp md.MediumQualificationEnterpriseData copier.Copy(&tmp, &v) tmp.Id = utils.IntToStr(v.Id) tmp.Uuid = utils.IntToStr(v.Uuid) tmp.MediumId = utils.IntToStr(v.MediumId) 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) medium := NewMediumDb.GetSuperAdmin(v.MediumId) if medium != nil { tmp.Account = medium.Username } data = append(data, tmp) } } res := md.MediumQualificationEnterpriseRes{ 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 MediumQualificationEnterpriseAudit(c *gin.Context, req md.MediumQualificationEnterpriseAuditReq) error { engine := db.Db MediumListDb := implement.NewMediumListDb(engine) data, _ := MediumListDb.GetMediumList(utils.StrToInt(req.MediumId)) 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("medium_id=?", data.MediumId).Cols("state,memo").Update(data) return nil } func MediumQualificationBank(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationBankRes { engine := db.Db MediumListDb := implement.NewMediumBankInfoDb(engine) user := GetUser(c) appIds := GetMediumIdStr(c, user.AdmId, req.Name, "") MediumList, total, _ := MediumListDb.FindMediumBankInfoList(c.GetString("mid"), "", appIds, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) list := make([]md.MediumQualificationBankData, 0) if MediumList != nil { NewMediumDb := implement2.NewMediumDb(MasterDb(c)) for _, v := range MediumList { tmp := md.MediumQualificationBankData{ Id: utils.IntToStr(v.MediumBankInfo.Id), MediumId: utils.IntToStr(v.MediumBankInfo.MediumId), CompanyName: v.CompanyName, UnifiedSocialCreditCode: v.UnifiedSocialCreditCode, Kind: utils.IntToStr(v.Kind), State: utils.IntToStr(v.MediumBankInfo.State), Memo: v.MediumBankInfo.Memo, CurrencyConf: utils.IntToStr(v.CurrencyConf), Bank: v.Bank, BankBranch: v.BankBranch, BankNo: v.BankNo, Licence: v.Licence, } medium := NewMediumDb.GetSuperAdmin(v.MediumBankInfo.MediumId) if medium != nil { tmp.Account = medium.Username } list = append(list, tmp) } } res := md.MediumQualificationBankRes{ 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 MediumQualificationBankAudit(c *gin.Context, req md.MediumQualificationEnterpriseAuditReq) error { engine := db.Db MediumListDb := implement.NewMediumBankInfoDb(engine) data, _ := MediumListDb.GetMediumBankInfoList(utils.StrToInt(req.MediumId)) 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("medium_id=?", data.MediumId).Cols("state,memo").Update(data) return nil } func MediumQualificationContactInfo(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationContactRes { engine := db.Db MediumListDb := implement.NewMediumContactInfoDb(engine) user := GetUser(c) appIds := GetMediumIdStr(c, user.AdmId, req.Name, "") MediumList, total, _ := MediumListDb.FindMediumContactInfoList(c.GetString("mid"), "", appIds, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) list := make([]md.MediumQualificationContactData, 0) if MediumList != nil { NewMediumDb := implement2.NewMediumDb(MasterDb(c)) for _, v := range MediumList { tmp := md.MediumQualificationContactData{ Id: utils.IntToStr(v.MediumContactInfo.Id), MediumId: utils.IntToStr(v.MediumContactInfo.MediumId), CompanyName: v.CompanyName, Kind: utils.IntToStr(v.Kind), State: utils.IntToStr(v.MediumContactInfo.State), Memo: v.MediumContactInfo.Memo, Name: v.MediumContactInfo.Name, Email: v.MediumContactInfo.Email, Phone: v.MediumContactInfo.Phone, Address: v.MediumContactInfo.Address, } medium := NewMediumDb.GetSuperAdmin(v.MediumContactInfo.MediumId) if medium != nil { tmp.Account = medium.Username } list = append(list, tmp) } } res := md.MediumQualificationContactRes{ 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 MediumQualificationContactInfoAudit(c *gin.Context, req md.MediumQualificationEnterpriseAuditReq) error { engine := db.Db MediumListDb := implement.NewMediumContactInfoDb(engine) data, _ := MediumListDb.GetMediumContactInfoList(utils.StrToInt(req.MediumId)) 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("medium_id=?", data.MediumId).Cols("state,memo").Update(data) return nil }