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} } enterprise := map[string]interface{}{ "state": medium.State, "data": medium, } NewMediumBankInfoDb := implement.NewMediumBankInfoDb(db.Db) bank, _ := NewMediumBankInfoDb.GetMediumBankInfoList(admin.MediumId) if bank == nil { bank = &model2.MediumBankInfo{Uuid: medium.Uuid, MediumId: medium.MediumId} } bankInfo := map[string]interface{}{ "state": bank.State, "data": bank, } NewMediumContactInfoDb := implement.NewMediumContactInfoDb(db.Db) contact, _ := NewMediumContactInfoDb.GetMediumContactInfoList(admin.MediumId) if contact == nil { contact = &model2.MediumContactInfo{Uuid: medium.Uuid, MediumId: medium.MediumId} } contactInfo := map[string]interface{}{ "state": 0, "data": contact, } 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": []map[string]interface{}{ { "value": "1", "name": "中国/国内", }, }, "user_type": []map[string]interface{}{ { "value": "1", "name": "企业", }, }, "currency_conf": []map[string]interface{}{ { "value": "0", "name": "人民币", }, }, } 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.UpdateAt = time.Now().Format("2006-01-02 15:04:05") if req.Id > 0 { listDb := implement.NewMediumListDb(db.Db) list, _ := listDb.GetMediumList(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.UpdateAt = time.Now() if req.Id > 0 { listDb := implement.NewMediumBankInfoDb(db.Db) list, _ := listDb.GetMediumBankInfoList(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() 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() if req.Id > 0 { listDb := implement.NewMediumContactInfoDb(db.Db) list, _ := listDb.GetMediumContactInfoList(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() db.Db.InsertOne(&data) } return nil }