|
- 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)
- AgentListDb := implement.NewAgentListDb(db.Db)
- Agent, _ := AgentListDb.GetAgentList(admin.AgentId)
- if Agent == nil {
- Agent = &model2.AgentList{Uuid: utils.StrToInt(c.GetString("mid")), AgentId: admin.AgentId}
- }
- enterprise := map[string]interface{}{
- "state": Agent.State,
- "data": Agent,
- }
- NewAgentBankInfoDb := implement.NewAgentBankInfoDb(db.Db)
- bank, _ := NewAgentBankInfoDb.GetAgentBankInfoList(admin.AgentId)
- if bank == nil {
- bank = &model2.AgentBankInfo{Uuid: Agent.Uuid, AgentId: Agent.AgentId}
- }
- bankInfo := map[string]interface{}{
- "state": bank.State,
- "data": bank,
- }
- NewAgentContactInfoDb := implement.NewAgentContactInfoDb(db.Db)
- contact, _ := NewAgentContactInfoDb.GetAgentContactInfoList(admin.AgentId)
- if contact == nil {
- contact = &model2.AgentContactInfo{Uuid: Agent.Uuid, AgentId: Agent.AgentId}
- }
- 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.AgentList) error {
- req.State = 1
- var data model2.AgentList
- copier.Copy(&data, &req)
- data.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
- if req.Id > 0 {
- listDb := implement.NewAgentListDb(db.Db)
- list, _ := listDb.GetAgentList(req.AgentId)
- 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.AgentBankInfo) error {
- req.State = 1
- var data model2.AgentBankInfo
- copier.Copy(&data, &req)
- data.UpdateAt = time.Now()
-
- if req.Id > 0 {
- listDb := implement.NewAgentBankInfoDb(db.Db)
- list, _ := listDb.GetAgentBankInfoList(req.AgentId)
- 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.AgentContactInfo) error {
- req.State = 1
- var data model2.AgentContactInfo
- copier.Copy(&data, &req)
- data.UpdateAt = time.Now()
- if req.Id > 0 {
- listDb := implement.NewAgentContactInfoDb(db.Db)
- list, _ := listDb.GetAgentContactInfoList(req.AgentId)
- 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
- }
|