|
- 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)
- MediumListDb := implement.NewMediumListDb(db.Db)
- medium, _ := MediumListDb.GetMediumList(admin.MediumId)
- if medium == nil {
- medium = &model2.MediumList{Uuid: utils.StrToInt(c.GetString("mid")), MediumId: admin.MediumId}
- }
- var mediumNew md.MediumList
- copier.Copy(&mediumNew, &medium)
- mediumNew.Id = utils.IntToStr(medium.Id)
- mediumNew.Uuid = utils.IntToStr(medium.Uuid)
- mediumNew.MediumId = utils.IntToStr(medium.MediumId)
- mediumNew.Kind = utils.IntToStr(medium.Kind)
- mediumNew.CertificateType = utils.IntToStr(medium.CertificateType)
- mediumNew.CertificateFirstType = utils.IntToStr(medium.CertificateFirstType)
- mediumNew.CountryRegionId = utils.IntToStr(medium.CountryRegionId)
- mediumNew.RegisteredAddressCountryId = utils.IntToStr(medium.RegisteredAddressCountryId)
- mediumNew.RegisteredAddressProvinceId = utils.IntToStr(medium.RegisteredAddressProvinceId)
- mediumNew.RegisteredAddressCountyId = utils.IntToStr(medium.RegisteredAddressCountyId)
- mediumNew.RegisteredAddressCityId = utils.IntToStr(medium.RegisteredAddressCityId)
- mediumNew.State = utils.IntToStr(medium.State)
- enterprise := map[string]interface{}{
- "state": mediumNew.State,
- "data": mediumNew,
- }
-
- NewMediumBankInfoDb := implement.NewMediumBankInfoDb(db.Db)
- bank, _ := NewMediumBankInfoDb.GetMediumBankInfoList(admin.MediumId)
- if bank == nil {
- bank = &model2.MediumBankInfo{Uuid: medium.Uuid, MediumId: medium.MediumId}
- }
- var bankNew md.MediumBankInfo
- copier.Copy(&bankNew, &bank)
- bankNew.State = utils.IntToStr(bank.State)
- bankNew.Id = utils.IntToStr(bank.Id)
- bankNew.Uuid = utils.IntToStr(bank.Uuid)
- bankNew.MediumId = utils.IntToStr(bank.MediumId)
- bankNew.CurrencyConf = utils.IntToStr(bank.CurrencyConf)
-
- bankInfo := map[string]interface{}{
- "state": bankNew.State,
- "data": bankNew,
- }
- NewMediumContactInfoDb := implement.NewMediumContactInfoDb(db.Db)
- contact, _ := NewMediumContactInfoDb.GetMediumContactInfoList(admin.MediumId)
- if contact == nil {
- contact = &model2.MediumContactInfo{Uuid: medium.Uuid, MediumId: medium.MediumId}
- }
- var contactNew md.MediumContactInfo
- copier.Copy(&contactNew, &contact)
- contactNew.State = utils.IntToStr(contact.State)
- contactNew.Id = utils.IntToStr(contact.Id)
- contactNew.Uuid = utils.IntToStr(contact.Uuid)
- contactNew.MediumId = utils.IntToStr(contact.MediumId)
- 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": md.Country,
- "user_type": []map[string]interface{}{
- {
- "value": "1", "name": "企业",
- },
- },
- "currency_conf": md.CurrencyConf,
- }
- e.OutSuc(c, res, nil)
- return
- }
- func QualificationEnterpriseSave(c *gin.Context, req md.MediumList) error {
- req.State = "1"
- var data model2.MediumList
- copier.Copy(&data, &req)
- data.Id = utils.StrToInt(req.Id)
- data.Uuid = utils.StrToInt(req.Uuid)
- data.MediumId = utils.StrToInt(req.MediumId)
- 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)
- data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
- if utils.StrToInt(req.Id) > 0 {
- listDb := implement.NewMediumListDb(db.Db)
- list, _ := listDb.GetMediumList(utils.StrToInt(req.MediumId))
- 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.MediumBankInfo) error {
- req.State = "1"
- var data model2.MediumBankInfo
- copier.Copy(&data, &req)
- data.State = utils.StrToInt(req.State)
- data.Id = utils.StrToInt(req.Id)
- data.Uuid = utils.StrToInt(req.Uuid)
- data.MediumId = utils.StrToInt(req.MediumId)
- 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.NewMediumBankInfoDb(db.Db)
- list, _ := listDb.GetMediumBankInfoList(utils.StrToInt(req.MediumId))
- 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.MediumContactInfo) error {
- req.State = "1"
- var data model2.MediumContactInfo
- copier.Copy(&data, &req)
- data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
- data.State = utils.StrToInt(req.State)
- data.Id = utils.StrToInt(req.Id)
- data.Uuid = utils.StrToInt(req.Uuid)
- data.MediumId = utils.StrToInt(req.MediumId)
- if utils.StrToInt(req.Id) > 0 {
- listDb := implement.NewMediumContactInfoDb(db.Db)
- list, _ := listDb.GetMediumContactInfoList(utils.StrToInt(req.MediumId))
- 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
- }
|