package controllers import ( "XT_New/models" "XT_New/service" "encoding/json" "fmt" "github.com/astaxie/beego" "github.com/jung-kurt/gofpdf" "time" ) type SignApiController struct { BaseAuthAPIController } func SignApiRegistRouters() { //获取短信验证码 beego.Router("/api/sign/getsign", &SignApiController{}, "Get:GetSign") //创建个人用户并实名 beego.Router("/api/sign/createrusername", &SignApiController{}, "Get:CreateUserName") //创建企业用户并实名 beego.Router("/api/sign/createenterpriserealname", &SignApiController{}, "Get:CreateEnterPriseRealName") //添加企业成员 beego.Router("/api/sign/createuserid", &SignApiController{}, "Get:CreateUserId") //创建个人印章 beego.Router("/api/sign/createpersionseal", &SignApiController{}, "Get:CreatePersionSeal") //上传文件创建创建合同 beego.Router("/api/sign/createuploadpact", &SignApiController{}, "Get:CreateUploadPact") //添加合同签署人 beego.Router("/api/sign/addcontractsignatory", &SignApiController{}, "Get:AddContractSignatory") //获取短信验证 beego.Router("/api/sign/getverificationcode", &SignApiController{}, "Get:GetVerificationCode") //后台签署(返回签署文件) beego.Router("/api/sign/createbackstagesign", &SignApiController{}, "Get:CreateBackStageSign") //署意愿认证-短信验证 beego.Router("/api/sign/totestelment", &SignApiController{}, "Get:CreateEnterprise") //测试PDF beego.Router("/api/sign/totestthrityment", &SignApiController{}, "Get:GetTestThrityMent") //CA企业认证 beego.Router("/api/sign/saveenerprise", &SignApiController{}, "Post:SaveEnerprise") // beego.Router("/api/sign/getenerprisebyid", &SignApiController{}, "Get:GetEnerPriseById") beego.Router("/api/sign/getmobilecode", &SignApiController{}, "Get:GetMobileCode") beego.Router("/api/sign/getpersionenterprise", &SignApiController{}, "Post:GetPersionEnterPrise") beego.Router("/api/sign/getpersenterprisebyid", &SignApiController{}, "Get:GetPerseEnterPriseById") beego.Router("/api/device/sign/creterpersionseal", &SignApiController{}, "Get:CreateNewPersionSeal") beego.Router("/api/device/sign/createnewenterprise", &SignApiController{}, "Get:CreateNewEnterPrise") beego.Router("/api/device/contractid", &SignApiController{}, "Get:GetContractId") beego.Router("/api/device/endenterprise", &SignApiController{}, "Get:EndEnterPrise") beego.Router("/api/device/getenterprisedetail", &SignApiController{}, "Get:GetEnterPriseDetail") beego.Router("/api/device/uploadprintorder", &SignApiController{}, "Post:UploadPrintOrder") } // 短信服务接口 func (this *SignApiController) GetSign() { phone := this.GetString("phone") fmt.Println("phone", phone) var tempphone string tempphone = "13318464642" sign := service.GetSignNameByPhone(tempphone) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } type Result2121 struct { Phone string `json:"phone"` DisPlayName string `json:"dis_play_name"` Authentication string `json:"authentication"` TwAuthReq struct { OneLineAuth string `json:"oneLineAuth"` ApiAuthReq struct { RealName float64 `json:"real_name"` IdCardType string `json:"id_card_type"` IdCardNum string `json:"id_card_num"` BankCard string `json:"bank_card"` CodeNumber string `json:"code_number"` VerifyCode string `json:"verify_code"` } `json:"apiAuthReq"` } `json:"twAuthReq"` } type MapData struct { dat struct { Code float64 `json:"code"` data struct { userId string `json:"userId"` } } } // 创建个人用户并实名 func (this *SignApiController) CreateUserName() { phone := this.GetString("phone") disPlayName := this.GetString("disPlayName") sign, userId := service.CreateUserName(phone, disPlayName) var dat map[string]interface{} if err := json.Unmarshal([]byte(sign), &dat); err == nil { fmt.Println(dat) } else { fmt.Println(err) } this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, "dat": dat, "userId": userId, }) return } // 创建个人印章 func (this *SignApiController) CreatePersionSeal() { user_id := this.GetString("user_id") person_seal_type, _ := this.GetInt64("person_seal_type") person_seal_name := this.GetString("person_seal_name") person_seal_base := this.GetString("person_seal_base") color, _ := this.GetInt64("color") alpha, _ := this.GetInt64("alpha") width, _ := this.GetInt64("width") height, _ := this.GetInt64("height") border, _ := this.GetInt64("border") font_type, _ := this.GetInt64("font_type") sign, personSealId := service.CreatePersionSeal(user_id, person_seal_type, person_seal_name, person_seal_base, color, alpha, width, height, border, font_type) var dat map[string]interface{} if err := json.Unmarshal([]byte(sign), &dat); err == nil { fmt.Println(dat) } else { fmt.Println(err) } this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, "dat": dat, "personSealId": personSealId, }) return } func (this *SignApiController) CreateUploadPact() { contractcode := this.GetString("contractcode") contractname := this.GetString("contractname") signcount, _ := this.GetInt64("signcount") docname := this.GetString("docname") contractbase := this.GetString("contractbase") creator := this.GetString("creator") enterpriseid := this.GetString("enterpriseid") signvalidays, _ := this.GetInt64("signvalidays") sysncurl := this.GetString("sysncurl") asyncurl := this.GetString("asyncurl") sign := service.CreateUploadPact(contractcode, contractname, signcount, docname, contractbase, creator, enterpriseid, signvalidays, sysncurl, asyncurl) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } // 添加企业成员 func (this *SignApiController) CreateUserId() { userId := this.GetString("userId") displayName := this.GetString("displayName") sign := service.CreateUserId(userId, displayName) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } func (this *SignApiController) CreateEnterPriseRealName() { enterprisename := this.GetString("enterprisename") sign := service.CreateEnterPriseRealName(enterprisename) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } // 添加合同签署人 func (this *SignApiController) AddContractSignatory() { contractId := this.GetString("contractId") signers := this.GetString("signers") var newContract models.NewContract newContract.ContractId = "156001444267295949" sign := service.AddContractSignatory(contractId, signers, newContract) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } type Struct2401 struct { someTimestampStyle []someTimestampStyle } type someTimestampStyle struct { ControlsKey string Pattern string Color string } func (this *SignApiController) CreateBackStageSign() { contractId := this.GetString("contractId") signers := this.GetString("signers") sign := service.CreateBackStageSign(contractId, signers) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } func (this *SignApiController) GetVerificationCode() { sign := service.GetVerificationCode() this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } func (this *SignApiController) CreateEnterprise() { sign := service.CreateEnterprise() this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } func (this *SignApiController) GetTestThrityMent() { pdf := gofpdf.New("P", "mm", "A4", "") pdf.AddPage() pdf.SetFont("Arial", "B", 16) pdf.Cell(40, 10, "Hello, World!") pdf.OutputFileAndClose("output.pdf") this.ServeSuccessJSON(map[string]interface{}{ "sign": "msg", }) return } func loremList() []string { return []string{ "我爱你中国" + "tempor incididunt ut labore et dolore magna aliqua.", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " + "aliquip ex ea commodo consequat.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " + "dolore eu fugiat nulla pariatur.", "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " + "officia deserunt mollit anim id est laborum.", } } func (this *SignApiController) SaveEnerprise() { orgId := this.GetAdminUserInfo().CurrentOrgId creater := this.GetAdminUserInfo().AdminUser.Id dataBody := make(map[string]interface{}, 0) err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody) fmt.Println("err", err) id := int64(dataBody["id"].(float64)) org_type := int64(dataBody["org_type"].(float64)) enterprise_name := dataBody["enterprise_name"].(string) code := dataBody["code"].(string) org_code := dataBody["org_code"].(string) legal_person_name := dataBody["legal_person_name"].(string) legal_id_card_num := dataBody["legal_id_card_num"].(string) legal_phone := dataBody["legal_phone"].(string) enterprise := models.XtDeviceEnterprise{ ID: id, UserOrgId: orgId, OrgType: org_type, EnterpriseName: enterprise_name, Code: code, OrgCode: org_code, LegalPersonName: legal_person_name, LegalIdCardNum: legal_id_card_num, LegalPhone: legal_phone, Creater: creater, Ctime: time.Now().Unix(), Mtime: 0, Enterpriseid: "", Status: 1, } service.SaveEnerPrise(enterprise) //查找该机构有没有认证信息 lastenterprise, _ := service.GetEnterPriseByUserOrgId(orgId) //调用企业认证接口 if lastenterprise.ID > 0 { enterPrise, enterpriseid := service.CreateNewEnterPriseRealName(lastenterprise) fmt.Println("enterprise2ooo2oo2o2o2o", enterPrise) updateEnterprise := models.XtDeviceEnterprise{ ID: enterprise.ID, UserOrgId: orgId, OrgType: org_type, EnterpriseName: enterprise_name, Code: code, OrgCode: org_code, LegalPersonName: legal_person_name, LegalIdCardNum: legal_id_card_num, LegalPhone: legal_phone, Creater: creater, Ctime: time.Now().Unix(), Mtime: 0, Enterpriseid: enterpriseid, Status: 1, } service.SaveEnerPrise(updateEnterprise) this.ServeSuccessJSON(map[string]interface{}{ "enterPrise": enterPrise, }) return } } func (this *SignApiController) GetEnerPriseById() { orgId := this.GetAdminUserInfo().CurrentOrgId enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId) this.ServeSuccessJSON(map[string]interface{}{ "enterPrise": enterPrise, }) return } func (this *SignApiController) GetMobileCode() { phone := this.GetString("phone") sign, orderNumber := service.GetNewSignNameByPhone(phone) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, "orderNumber": orderNumber, }) return } func (this *SignApiController) GetPersionEnterPrise() { orgId := this.GetAdminUserInfo().CurrentOrgId creater := this.GetAdminUserInfo().AdminUser.Id dataBody := make(map[string]interface{}, 0) err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody) fmt.Println("err", err) id := int64(dataBody["id"].(float64)) admin_user_id := int64(dataBody["admin_user_id"].(float64)) code := dataBody["code"].(string) display_name := dataBody["display_name"].(string) id_card_num := dataBody["id_card_num"].(string) phone := dataBody["phone"].(string) enterprise := models.XtDevicePersonEnterprise{ ID: id, AdminUserId: admin_user_id, DisplayName: display_name, Phone: phone, IdCardNum: id_card_num, UserOrgId: orgId, Status: 1, Creater: creater, Ctime: time.Now().Unix(), Mtime: 0, UserId: "", } service.SavePersonEnterPrise(enterprise) lastEnterPrise, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId) _, orderNumber := service.GetNewSignNameByPhone(phone) personEnterPrse, UserId := service.CreateNewUserName(lastEnterPrise.Phone, lastEnterPrise.DisplayName, code, orderNumber, lastEnterPrise.IdCardNum) firstenterprise := models.XtDevicePersonEnterprise{ ID: id, AdminUserId: admin_user_id, DisplayName: display_name, Phone: phone, IdCardNum: id_card_num, UserOrgId: orgId, Status: 1, Creater: creater, Ctime: time.Now().Unix(), Mtime: 0, UserId: UserId, } service.SavePersonEnterPrise(firstenterprise) this.ServeSuccessJSON(map[string]interface{}{ "personEnterPrse": personEnterPrse, }) return } func (this *SignApiController) GetPerseEnterPriseById() { orgId := this.GetAdminUserInfo().CurrentOrgId admin_user_id, _ := this.GetInt64("admin_user_id") lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId) this.ServeSuccessJSON(map[string]interface{}{ "lastPerson": lastPerson, }) return } func (this *SignApiController) CreateNewPersionSeal() { orgId := this.GetAdminUserInfo().CurrentOrgId admin_user_id, _ := this.GetInt64("admin_user_id") lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId) personSeal, personSealId := service.CreateNewPersionSeal(lastPerson.UserId) service.UpdatePerseEnterPriseById(lastPerson.ID, personSealId) this.ServeSuccessJSON(map[string]interface{}{ "personSeal": personSeal, }) return } func (this *SignApiController) CreateNewEnterPrise() { orgId := this.GetAdminUserInfo().CurrentOrgId admin_user_id, _ := this.GetInt64("admin_user_id") enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId) fmt.Println("地址日活", enterPrise.Enterpriseid) lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId) newEnterPrise, sealId := service.CreateNewEnterPrise(enterPrise.Enterpriseid, lastPerson.UserId) service.UpdatePersonEnterPrise(lastPerson.ID, sealId) this.ServeSuccessJSON(map[string]interface{}{ "newEnterPrise": newEnterPrise, }) return } func (this *SignApiController) GetContractId() { sign := service.GetContractId() this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } func (this *SignApiController) EndEnterPrise() { sign := service.EndEnterPrise() this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) return } func (this *SignApiController) GetEnterPriseDetail() { sign, url := service.GetEnterPriseDetail() this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, "url": url, }) return } func (this *SignApiController) UploadPrintOrder() { dataBody := make(map[string]interface{}, 0) err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody) fmt.Println("err", err) name := dataBody["name"].(string) sign := service.CreateNewUploadPact(name) this.ServeSuccessJSON(map[string]interface{}{ "sign": sign, }) }