package service import ( "XT_New/models" "XT_New/utils" "bytes" "crypto/hmac" "crypto/sha1" "encoding/base64" "encoding/json" "fmt" "github.com/astaxie/beego" "github.com/jung-kurt/gofpdf" "io/ioutil" "net/http" "path" ) func GetSignNameByPhone(phoneOne string) string { var url string url = "http://demo-open.itruscloud.com/apigate/smsService/sendingSms" var phone string phone = "13318464642" var content string content = "123456" var autograph string autograph = "【天威诚信】" maprequest := make(map[string]interface{}) maprequest["phone"] = phone maprequest["content"] = content maprequest["autograph"] = autograph byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) fmt.Println("appID", appId) fmt.Println("serviceCode", serviceCode) request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println(str) return str } func generateHMACSHA1SignatureOne(data interface{}, key, serviceCode string) (string, error) { // 将数据转换为 JSON 格式的字节数组 jsonData, err := json.Marshal(data) if err != nil { return "", err } // 将密钥和 serviceCode 进行拼接 signingKey := key + serviceCode // 将签名密钥转换为字节数组 keyBytes := []byte(signingKey) // 创建一个新的 HMAC-SHA1 实例 h := hmac.New(sha1.New, keyBytes) // 将 JSON 数据添加到 HMAC 实例中 h.Write(jsonData) signature := base64.StdEncoding.EncodeToString(h.Sum(nil)) // 返回带有前缀的签名字符串 return "HMAC-SHA1 " + signature, nil } func GenerateHMACSHA1SignatureTwo(data interface{}, key string) (string, error) { // 将数据转换为 JSON 格式的字节数组 jsonData, err := json.Marshal(data) if err != nil { return "", err } // 将密钥和 serviceCode 进行拼接 signingKey := key // 将签名密钥转换为字节数组 keyBytes := []byte(signingKey) // 创建一个新的 HMAC-SHA1 实例 h := hmac.New(sha1.New, keyBytes) // 将 JSON 数据添加到 HMAC 实例中 h.Write(jsonData) signature := base64.StdEncoding.EncodeToString(h.Sum(nil)) // 返回带有前缀的签名字符串 return "HMAC-SHA1 " + signature, nil } func CreateUserName(phone string, disPlayName string) (string, string) { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createUserRealName" var phoneOne string phoneOne = "13318464642" var disPlayNameOne string disPlayNameOne = "马云的朋友" var authentication string //测试环境用true authentication = "true" maprequest := make(map[string]interface{}) twAuthReq := make(map[string]interface{}) apiAuthReq := make(map[string]interface{}) customerReq := make(map[string]interface{}) customerReq["idCardType"] = "0" customerReq["idCardNum"] = "430526199408156511" apiAuthReq["realNameType"] = 3 apiAuthReq["idCardType"] = "0" apiAuthReq["idCardNum"] = "430526199408156511" apiAuthReq["bankCard"] = "6225551675364804" //验证码流水号 apiAuthReq["codeNumber"] = "msg202307071510269187701" //验证码 apiAuthReq["verifyCode"] = "123456" twAuthReq["oneLineAuth"] = "false" twAuthReq["apiAuthReq"] = apiAuthReq maprequest["phone"] = phoneOne maprequest["displayName"] = disPlayNameOne maprequest["authentication"] = authentication maprequest["twAuthReq"] = twAuthReq maprequest["customerAuthReq"] = customerReq byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) fmt.Println("appID", appId) fmt.Println("serviceCode", serviceCode) request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var UserId string UserId = respJSON["data"].(map[string]interface{})["userId"].(string) fmt.Println("str", UserId) return str, UserId } func CreatePersionSeal(user_id string, person_seal_type int64, person_seal_name string, person_seal_base string, color int64, alpha int64, width int64, height int64, border int64, font_type int64) (string, string) { maprequest := make(map[string]interface{}) maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N" maprequest["personSealType"] = 1 maprequest["personSealName"] = "小朋友的印章" var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createPersonSeal" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var personSealId string personSealId = respJSON["data"].(map[string]interface{})["personSealId"].(string) fmt.Println("str", personSealId) return str, personSealId } func CreateUploadPact(contractcode string, contractname string, signcount int64, docname string, contractbase string, creator string, enterpriseid string, signvalidays int64, sysncurl string, asyncurl string) string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/createByFile" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["contractName"] = "电脑购买交易合同" maprequest["signCount"] = 10 maprequest["docName"] = "日本员工保密协议" file := "C:/Users/28169/Desktop/2.pdf" fileBytes, err := ioutil.ReadFile(file) // 读取file contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串 maprequest["contractBase64"] = contractBase64 //添加企业成员 里面的USERID maprequest["creator"] = "PBRLMBFVIRR3BV8JGGOX9C7N" maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8" maprequest["signValidDays"] = 90 maprequest["sysnUrl"] = "https://kuyi.shengws.com/chenxuemin1.png" maprequest["asyncUrl"] = "https://kuyi.shengws.com/chenxuemin1.png" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } func CreateEnterPriseRealName(enterprisename string) string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createEnterpriseRealName" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) customerReq := make(map[string]interface{}) customerReq["idCardType"] = "N" customerReq["idCardNum"] = "430526199408156511" maprequest["enterpriseName"] = "深圳德马西科技有限公司" maprequest["authentication"] = true maprequest["customerAuthReq"] = customerReq fmt.Println("maprequest", maprequest) byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } func CreateUserId(userId string, displayName string) string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/joinEnterprise" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8" maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } //type ResultTwo struct { // ErrMsg string `json:"err_msg"` // InfRefmsgid string `json:"inf_refmsgid"` // Infcode int64 `json:"infcode"` // Output struct { // Baseinfo struct { // Age float64 `json:"age"` // Brdy string `json:"brdy"` // Certno string `json:"certno"` // Gend string `json:"gend"` // Naty string `json:"naty"` // PsnCertType string `json:"psn_cert_type"` // PsnName string `json:"psn_name"` // PsnNo string `json:"psn_no"` // } `json:"baseinfo"` // Idetinfo []interface{} `json:"idetinfo"` // Iinfo []struct { // Balc float64 `json:"balc"` // CvlservFlag string `json:"cvlserv_flag"` // EmpName string `json:"emp_name"` // InsuplcAdmdvs string `json:"insuplc_admdvs"` // Insutype string `json:"insutype"` // PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"` // PausInsuDate string `json:"paus_insu_date"` // PsnInsuDate string `json:"psn_insu_date"` // PsnInsuStas string `json:"psn_insu_stas"` // PsnType string `json:"psn_type"` // } `json:"insuinfo"` // } `json:"output"` // RefmsgTime string `json:"refmsg_time"` // RespondTime string `json:"respond_time"` // Signtype interface{} `json:"signtype"` // WarnInfo interface{} `json:"warn_info"` //} func AddContractSignatory(contractId string, signers string, contract models.NewContract) string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/addSignerByFile" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") signFiles := make(map[string]interface{}) //创建合同返回 signFiles["docId"] = "158807311102510183" inputDataArr := make([]map[string]interface{}, 0) for _, item := range signFiles { fmt.Println("item", item) xySignControls := make(map[string]interface{}) xySignControls["key"] = "1" xySignControls["type"] = "autograph" xySignControls["pageNum"] = 1 xySignControls["positionX"] = "120F" xySignControls["positionY"] = "120F" inputDataArr = append(inputDataArr, xySignControls) } inputDataArrTwo := make([]map[string]interface{}, 0) for _, item := range signFiles { fmt.Println(item) keywordSignControls := make(map[string]interface{}) keywordSignControls["key"] = "2" keywordSignControls["type"] = "date" keywordSignControls["pageNum"] = 1 keywordSignControls["keyword"] = "王志文" keywordSignControls["offsetX"] = "100F" keywordSignControls["offsetY"] = "100F" inputDataArrTwo = append(inputDataArrTwo, keywordSignControls) } signFiles["xySignControls"] = inputDataArr signFiles["keywordSignControls"] = inputDataArrTwo inputDataArrThree := make([]map[string]interface{}, 0) inputDataArrThree = append(inputDataArrThree, signFiles) signersFiles := make(map[string]interface{}) signersFiles["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N" signersFiles["signerType"] = "1" signersFiles["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8" signersFiles["sequence"] = "8" signersFiles["sendMsg"] = false signersFiles["setting"] = true signersFiles["signFiles"] = inputDataArrThree inputDataArrFour := make([]map[string]interface{}, 0) inputDataArrFour = append(inputDataArrFour, signersFiles) maprequest := make(map[string]interface{}) maprequest["contractId"] = "158807311102510182" maprequest["signers"] = inputDataArrFour byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } func CreateBackStageSign(contractId string, signers string) string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/signByFile" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") sealTimestampFiles := make(map[string]interface{}) inputDataArr := make([]map[string]interface{}, 0) signFiles := make(map[string]interface{}) keywordSignControls := make(map[string]interface{}) keywordSignControls["controlsKey"] = "2" keywordSignControls["pattern"] = 1 keywordSignControls["color"] = "#FF0000" inputDataArr = append(inputDataArr, keywordSignControls) sealTimestampFiles["allAddTimestamp"] = false sealTimestampFiles["someTimestampStyle"] = inputDataArr inputDataArrOne := make([]map[string]interface{}, 0) keySignControls := make(map[string]interface{}) keySignControls["controlsKey"] = "1" keySignControls["fontType"] = 1 keySignControls["fontSize"] = 8.5 keySignControls["fontColor"] = "#56600F" keySignControls["alignment"] = 1 inputDataArrOne = append(inputDataArrOne, keySignControls) signFiles["fonts"] = inputDataArrOne signFiles["showTimestamp"] = false signFiles["sealTimestamp"] = sealTimestampFiles signControl := make(map[string]interface{}) signControl["1"] = "{sealId:157474548357267755}" signControl["2"] = "姓名" fmt.Println("signContorlwqowowo", signControl) signFiles["signControl"] = signControl signFiles["docId"] = "158807311102510183" inputDataArrThree := make([]map[string]interface{}, 0) inputDataArrThree = append(inputDataArrThree, signFiles) signer := make(map[string]interface{}) //添加合同签署人接口返回 signer["signerId"] = "158807462500107405" signer["isUserWishes"] = true signer["userWishesWay"] = 1 signer["codeNumber"] = "msg202309081937527315153" signer["verifyCode"] = "252234" signer["signFiles"] = inputDataArrThree maprequest := make(map[string]interface{}) maprequest["contractId"] = "158807311102510182" maprequest["signer"] = signer byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } func GetVerificationCode() string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/sendSmsCode" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["contractId"] = "158807311102510182" maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } func CreateEnterprise() string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/sendSmsCode" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["contractId"] = "157413765980094742" maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N" maprequest["sealType"] = 1 maprequest["sealName"] = "测试用章" maprequest["sealBase64"] = "" maprequest["color"] = 1 maprequest["width"] = 40 maprequest["authUserId"] = "" maprequest["sealCreateType"] = false byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) return str } func GetTestThrityMent(org_id int64) (base []*models.XtBaseDrug, err error) { err = XTReadDB().Where("org_id = ? and status=1", org_id).Find(&base).Error return base, err } func UpdateDrugWarehouseInfoByDrugId(drug_id int64, min_price float64) error { err := XTWriteDB().Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? and (stock_max_number>0 or stock_min_number>0) and status= 1 and is_check=1 and org_id =10375", drug_id).Updates(map[string]interface{}{"retail_price": min_price}).Error return err } func GetEnterPriseByUserOrgId(user_org_id int64) (models.XtDeviceEnterprise, error) { enterprise := models.XtDeviceEnterprise{} err := XTReadDB().Where("user_org_id = ? and status =1", user_org_id).Find(&enterprise).Error return enterprise, err } func CreateEnterPrise(enterprise models.XtDeviceEnterprise) error { err := XTWriteDB().Create(&enterprise).Error return err } func SaveEnerPrise(enterprise models.XtDeviceEnterprise) error { err := XTWriteDB().Save(&enterprise).Error return err } func CreateNewEnterPriseRealName(enterprise models.XtDeviceEnterprise) (string, string) { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createEnterpriseRealName" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) customerReq := make(map[string]interface{}) customerReq["idCardType"] = "N" customerReq["idCardNum"] = "430526199408156511" maprequest["enterpriseName"] = enterprise.EnterpriseName maprequest["authentication"] = true maprequest["customerAuthReq"] = customerReq fmt.Println("maprequest", maprequest) byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var enterpriseId string enterpriseId = respJSON["data"].(map[string]interface{})["enterpriseId"].(string) fmt.Println("enterpriseId", enterpriseId) return str, enterpriseId } func GetNewSignNameByPhone(phone string) (string, string) { var url string url = "http://demo-open.itruscloud.com/apigate/smsService/sendingSms" var content string content = "123456" var autograph string autograph = "【天威诚信】" maprequest := make(map[string]interface{}) maprequest["phone"] = phone maprequest["content"] = content maprequest["autograph"] = autograph byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var orderNumber string orderNumber = respJSON["orderNumber"].(string) fmt.Println("orderNumberWOWOWOWOWO", orderNumber) return str, orderNumber } func SavePersonEnterPrise(enterprise models.XtDevicePersonEnterprise) error { err := XTWriteDB().Save(&enterprise).Error return err } func GetLastPersonEnterPrise(admin_user_id int64, orgId int64) (models.XtDevicePersonEnterprise, error) { enterprise := models.XtDevicePersonEnterprise{} err := XTReadDB().Where("admin_user_id = ? and user_org_id = ? and status = 1", admin_user_id, orgId).Find(&enterprise).Error return enterprise, err } func CreateNewUserName(phone string, disPlayName string, code string, orderNumber string, id_card_number string) (string, string) { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createUserRealName" var authentication string //测试环境用true authentication = "true" maprequest := make(map[string]interface{}) twAuthReq := make(map[string]interface{}) apiAuthReq := make(map[string]interface{}) customerReq := make(map[string]interface{}) fmt.Println("身份证id_card_number", id_card_number) customerReq["idCardType"] = "0" customerReq["idCardNum"] = id_card_number apiAuthReq["realNameType"] = 3 apiAuthReq["idCardType"] = "0" apiAuthReq["idCardNum"] = id_card_number apiAuthReq["bankCard"] = "6225551675364804" //验证码流水号 apiAuthReq["codeNumber"] = orderNumber //验证码 apiAuthReq["verifyCode"] = code twAuthReq["oneLineAuth"] = "false" twAuthReq["apiAuthReq"] = apiAuthReq maprequest["phone"] = phone maprequest["displayName"] = disPlayName maprequest["authentication"] = authentication maprequest["twAuthReq"] = twAuthReq maprequest["customerAuthReq"] = customerReq byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) fmt.Println("appID", appId) fmt.Println("serviceCode", serviceCode) request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var UserId string UserId = respJSON["data"].(map[string]interface{})["userId"].(string) fmt.Println("str", UserId) return str, UserId } func CreateNewPersionSeal(userId string) (string, string) { maprequest := make(map[string]interface{}) maprequest["userId"] = userId maprequest["personSealType"] = 1 maprequest["personSealName"] = "小马印章" var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createPersonSeal" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var personSealId string personSealId = respJSON["data"].(map[string]interface{})["personSealId"].(string) fmt.Println("str", personSealId) return str, personSealId } func CreateSKDPersionSeal(userId string, user_name string) (string, string) { maprequest := make(map[string]interface{}) //印章字体 1宋体(默认)2 黑体 maprequest["fontType"] = 1 //个人姓名(1-42位字符) maprequest["personName"] = user_name var url string url = "http://localhost:8890/sdk/seal/createPersonSeal" appId := beego.AppConfig.String("sign_appid") fmt.Println("appId", appId) serviceKye := beego.AppConfig.String("serviceKye") fmt.Println("serviceKye", serviceKye) serviceCode := beego.AppConfig.String("serviceCode") fmt.Println("serviceCode", serviceCode) byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, ERR := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println(ERR) request, err := http.NewRequest("POST", url, reader) fmt.Println("errwowowoowowowow", err) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("strwoooooooooooooooooooo", str) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var sealBase64 string sealBase64 = respJSON["data"].(map[string]interface{})["sealBase64"].(string) return str, sealBase64 } func UpdatePerseEnterPriseById(id int64, personSealId string) error { err := XTWriteDB().Model(models.XtDevicePersonEnterprise{}).Where("id= ? and status =1", id).Updates(map[string]interface{}{"person_seal_id": personSealId}).Error return err } func CreateNewEnterPrise(enterpriseId string, userId string) (string, string) { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createSeal" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") fmt.Println("enterpriseId", enterpriseId) fmt.Println("userId", userId) maprequest := make(map[string]interface{}) maprequest["enterpriseId"] = enterpriseId maprequest["userId"] = userId maprequest["sealType"] = 1 maprequest["sealName"] = "测试用章" fmt.Println("request23222222222222222", maprequest) byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) fmt.Println("中国人民欢迎您", request) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("strwowowowowo", str) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var sealId string sealId = respJSON["data"].(map[string]interface{})["sealId"].(string) fmt.Println("sealId", sealId) return str, sealId } func CreateSDKEnterPrise() (string, string) { var url string url = "http://localhost:8890/sdk/seal/createEnterpriseSeal" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["sealType"] = 1 maprequest["enterpriseName"] = "深圳伊森时光科技有限公司" maprequest["horizontalText"] = "财务专用章" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) fmt.Println("signatureStr", signatureStr) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var sealId string //sealId = respJSON["data"].(map[string]interface{})["sealId"].(string) //fmt.Println("sealId", sealId) return str, sealId } func UpdatePersonEnterPrise(id int64, sealId string) error { err := XTWriteDB().Model(models.XtDevicePersonEnterprise{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"seal_id": sealId}).Error return err } func GetContractId() string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/search" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["contractId"] = "158799561907766048" maprequest["responseContractFile"] = true fmt.Println("request23222222222222222", maprequest) byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) fmt.Println("request23222222222222222", request) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("strwowowowowo", str) return str } func EndEnterPrise() string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/finished" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["contractId"] = "157475501840007476" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("strwowowowowo", str) return str } func GetEnterPriseDetail() (string, string) { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/preview" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) maprequest["contractId"] = "158807311102510182" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("strwowowowowo", str) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var urlOne string urlOne = respJSON["data"].(map[string]interface{})["url"].(string) fmt.Println("url", urlOne) return str, urlOne } func CreateNewUploadPact(name string) string { var url string url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/createByFile" appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") maprequest := make(map[string]interface{}) //maprequest["contractCode"] = "102020620701056856" maprequest["contractName"] = "手机购买交易合同" maprequest["signCount"] = 10 maprequest["docName"] = "美国员工保密协议" //file := "C:/Users/28169/Desktop/打印单.pdf" // //fileBytes, err := ioutil.ReadFile(file) // 读取file // //contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串 //fmt.Println(contractBase64) maprequest["contractBase64"] = name //添加企业成员 里面的USERID maprequest["creator"] = "PBRLMBFVIRR3BV8JGGOX9C7N" maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8" maprequest["signValidDays"] = 90 maprequest["sysnUrl"] = "https://kuyi.shengws.com/chenxuemin1.png" maprequest["asyncUrl"] = "https://kuyi.shengws.com/chenxuemin1.png" byterequest, _ := json.Marshal(maprequest) reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } request.Header.Set("appId", appId) request.Header.Set("serviceCode", serviceCode) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("strwwoowowow", str) return str } func GetDataConfigDisinfectionFluid(org_id int64) (models.Dataconfig, error) { dataconfig := models.Dataconfig{} err := XTReadDB().Where("org_id = ? and status =1 and id =12536", org_id).Find(&dataconfig).Error return dataconfig, err } func CreateQianshuUserName(user_name string, phone string, id_card_number string) (string, string) { var url string url = "http://localhost:8890/sdk/user/create" //var account string // //account = "13318464642" //var realName string // //realName = "马文强" maprequest := make(map[string]interface{}) maprequest["account"] = phone //账号类型:1手机号,2邮箱 maprequest["accountType"] = 1 maprequest["realName"] = user_name //签署人类型 1个人 2.企业 maprequest["signerType"] = 1 // 0表示 身份证 maprequest["cardType"] = 0 //maprequest["cardNumber"] = "430526199408156511" maprequest["cardNumber"] = id_card_number byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") serviceCode := beego.AppConfig.String("serviceCode") reader := bytes.NewReader(byterequest) signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) request.Header.Set("appId", appId) request.Header.Set("appKey", serviceKye) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var UserId string UserId = respJSON["data"].(map[string]interface{})["userId"].(string) fmt.Println("str", UserId) return str, UserId } func CreateSdkSendInformation() (string, string) { var url string url = "http://localhost:8890/sdk/msg/sendMsg" maprequest := make(map[string]interface{}) maprequest["phone"] = "13318464642" maprequest["signType"] = "pdf" byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") reader := bytes.NewReader(byterequest) serviceCode := beego.AppConfig.String("serviceCode") signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) request.Header.Set("appId", appId) request.Header.Set("appKey", serviceKye) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var orderId string //orderId = respJSON["data"].(map[string]interface{})["orderId"].(string) //fmt.Println("str", orderId) return str, orderId } func SavePdfInformation(name string) (string, string) { var url string url = "http://localhost:8890/sdk/pdf/sign" maprequest := make(map[string]interface{}) Receiver := make(map[string]interface{}) //业务单号 maprequest["orderId"] = "13318464642" maprequest["signTitle"] = "举报合同" //file := "C:/Users/28169/Desktop/9.pdf" //file := "/swspan/gopath/src/XT_New/static/16.pdf" //fileBytes, _ := ioutil.ReadFile(file) // 读取file // //contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串 //fmt.Println("contractBase64", contractBase64) //文件获取方式 maprequest["fileType"] = 3 //maprequest["pdfBase64"] = name //合同内容 maprequest["fileContent"] = "https://kuyi.shengws.com/20.pdf" //签署用户人ID maprequest["userId"] = "JMO9U8JH4TN8E3QOI0GUVUF2" //业务单号 maprequest["receiver"] = Receiver //签署人账号 Receiver["account"] = "13318464642" //签署个人类型 1.个人 2.企业 Receiver["signerType"] = 1 //签署人姓名 Receiver["realName "] = "马文强" // 证件类型 Receiver["cardType"] = 0 //证件编码 Receiver["cardNumber"] = "430526199408156511" stepStamper := make(map[string]interface{}) keywordSignControls := make([]map[string]interface{}, 0) //预冲者样式 inputArrOne := make(map[string]interface{}) inputArrOne["sealName"] = "1" inputArrOne["keyword"] = "穿刺者" inputArrOne["pages"] = "0" inputArrOne["offsetX"] = "50" inputArrOne["offsetY"] = "0" keywordSignControls = append(keywordSignControls, inputArrOne) stepStamper["keywordSignControls"] = keywordSignControls //医生签名 //inputArr := make(map[string]interface{}) //inputArr["sealName"] = "2" //inputArr["keyword"] = "医生签名" //inputArr["pages"] = "1" //inputArr["offsetX"] = "100" //inputArr["offsetY"] = "0" // //keywordSignControls = append(keywordSignControls, inputArr) // //上机者 //inputArrSix := make(map[string]interface{}) //inputArrSix["sealName"] = "3" //inputArrSix["keyword"] = "护士签名" //inputArrSix["pages"] = "1" //inputArrSix["offsetX"] = "100" //inputArrSix["offsetY"] = "0" // //keywordSignControls = append(keywordSignControls, inputArrSix) ////医生签名 //inputArrSeven := make(map[string]interface{}) //inputArrSeven["sealName"] = "4" //inputArrSeven["keyword"] = "核对护士签名" //inputArrSeven["pages"] = "1" //inputArrSeven["offsetX"] = "100" //inputArrSeven["offsetY"] = "0" // //keywordSignControls = append(keywordSignControls, inputArrSeven) //stepStamper["keywordSignControls"] = keywordSignControls // //crossSignControls := make([]map[string]interface{}, 0) // //inputArrTwo := make(map[string]interface{}) //inputArrTwo["sealName"] = "1" //inputArrTwo["positionX"] = "0" //inputArrTwo["positionY"] = "0" //inputArrTwo["pages"] = "0" //crossSignControls = append(crossSignControls, inputArrTwo) // //stepStamper["crossSignControls"] = crossSignControls // //xySignControls := make([]map[string]interface{}, 0) //inputArrThree := make(map[string]interface{}) //inputArrThree["sealName"] = "1" //inputArrThree["positionX"] = "200" //inputArrThree["positionY"] = "100" //inputArrThree["pages"] = "0" // //xySignControls = append(xySignControls, inputArrThree) //// //stepStamper["xySignControls"] = xySignControls // maprequest["stepStamper"] = stepStamper seals := make([]map[string]interface{}, 0) //预冲者 sealImagesList := make(map[string]interface{}) fileOne := "/swspan/gopath/src/XT_New/static/huangzihui.jpg" fileBytesOne, _ := ioutil.ReadFile(fileOne) // 读取file contractBase64One := base64.StdEncoding.EncodeToString(fileBytesOne) // 加密成base64字符串 sealImagesList["sealBase64"] = contractBase64One //控制签名的大小 sealImagesList["width"] = "50" sealImagesList["height"] = "50" sealImagesList["verticalAlign"] = "middle" sealTextsList := make(map[string]interface{}) sealTextsList["text"] = "2023年8月8日" sealTextsList["fontSize"] = "12" sealTextsList["fontColor"] = "#333333" sealTextsList["isTextArea"] = true sealTextsList["textAlign"] = 0 sealTextsList["width"] = 150 sealTextsList["height"] = 20 sealsObj := make(map[string]interface{}) sealsObj["sealWidth"] = "150" sealsObj["sealHeight"] = "150" sealsObj["sealName"] = "1" sealsObj["sealImage"] = sealImagesList sealsObj["sealText"] = sealTextsList seals = append(seals, sealsObj) //穿刺者 //sealImagesListOne := make(map[string]interface{}) // //fileTwo := "/swspan/gopath/src/XT_New/static/huangjunji.jpg" // //fileBytesTwo, _ := ioutil.ReadFile(fileTwo) // 读取file // //contractBase64Two := base64.StdEncoding.EncodeToString(fileBytesTwo) // 加密成base64字符串 //sealImagesListOne["sealBase64"] = contractBase64Two ////控制签名的大小 //sealImagesListOne["width"] = "50" //sealImagesListOne["height"] = "50" //sealImagesListOne["verticalAlign"] = "middle" // //sealTextsListOne := make(map[string]interface{}) //sealTextsListOne["text"] = "2023年8月8日" //sealTextsListOne["fontSize"] = "100" //sealTextsListOne["fontColor"] = "100" //sealTextsListOne["isTextArea"] = true //sealTextsListOne["textAlign"] = 0 //sealTextsListOne["width"] = 150 //sealTextsListOne["height"] = 20 // //sealsObjOne := make(map[string]interface{}) // //sealsObjOne["sealWidth"] = "150" //sealsObjOne["sealHeight"] = "150" //sealsObjOne["sealName"] = "2" //sealsObjOne["sealImage"] = sealImagesListOne //sealsObjOne["sealText"] = sealTextsListOne //seals = append(seals, sealsObjOne) //间隔签名 //上机者 //sealImagesListTwo := make(map[string]interface{}) //fileThree := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg" //fileBytesThree, _ := ioutil.ReadFile(fileThree) // 读取file //contractBase64Three := base64.StdEncoding.EncodeToString(fileBytesThree) // 加密成base64字符串 //sealImagesListTwo["sealBase64"] = contractBase64Three ////控制签名的大小 //sealImagesListTwo["width"] = "50" //sealImagesListTwo["height"] = "50" //sealImagesListTwo["verticalAlign"] = "middle" // //sealTextsListTwo := make(map[string]interface{}) //sealTextsListTwo["text"] = "2023年8月8日" //sealTextsListTwo["fontSize"] = "100" //sealTextsListTwo["fontColor"] = "100" //sealTextsListTwo["isTextArea"] = true //sealTextsListTwo["textAlign"] = 0 //sealTextsListTwo["width"] = 150 //sealTextsListTwo["height"] = 20 // //sealsObjTwo := make(map[string]interface{}) // //sealsObjTwo["sealWidth"] = "150" //sealsObjTwo["sealHeight"] = "150" //sealsObjTwo["sealName"] = "3" //sealsObjTwo["sealImage"] = sealImagesListTwo //sealsObjTwo["sealText"] = sealTextsListTwo //seals = append(seals, sealsObjTwo) //医生签名 //sealImagesListThree := make(map[string]interface{}) //fileFour := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg" //fileBytesFour, _ := ioutil.ReadFile(fileFour) // 读取file //contractBase64Tour := base64.StdEncoding.EncodeToString(fileBytesFour) // 加密成base64字符串 //sealImagesListThree["sealBase64"] = contractBase64Tour ////控制签名的大小 //sealImagesListThree["width"] = "50" //sealImagesListThree["height"] = "50" //sealImagesListThree["verticalAlign"] = "middle" // //sealTextsListThree := make(map[string]interface{}) //sealTextsListThree["text"] = "2023年8月8日" //sealTextsListThree["fontSize"] = "100" //sealTextsListThree["fontColor"] = "100" //sealTextsListThree["isTextArea"] = true //sealTextsListThree["textAlign"] = 0 //sealTextsListThree["width"] = 150 //sealTextsListThree["height"] = 20 // //sealsObjThree := make(map[string]interface{}) // //sealsObjThree["sealWidth"] = "150" //sealsObjThree["sealHeight"] = "150" //sealsObjThree["sealName"] = "4" //sealsObjThree["sealImage"] = sealImagesListThree //sealsObjThree["sealText"] = sealTextsListThree //seals = append(seals, sealsObjThree) maprequest["seals"] = seals maprequest["isUserWishes"] = true maprequest["phone"] = "13318464642" maprequest["verificationCode"] = "18888888888" byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") reader := bytes.NewReader(byterequest) serviceCode := beego.AppConfig.String("serviceCode") signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) request.Header.Set("appId", appId) request.Header.Set("appKey", serviceKye) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) fmt.Println("报错提示", str) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } var pdfBase64 string pdfBase64 = respJSON["data"].(map[string]interface{})["pdfBase64"].(string) return str, pdfBase64 } func ToCheckInformation(contractBase64 string) string { var url string url = "http://localhost:8890/sdk/pdf/verify" maprequest := make(map[string]interface{}) //file := "/swspan/gopath/src/XT_New/static/a.pdf" // //fileBytes, _ := ioutil.ReadFile(file) // 读取file // //contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串 maprequest["fileType"] = 1 maprequest["fileContent"] = contractBase64 byterequest, _ := json.Marshal(maprequest) appId := beego.AppConfig.String("sign_appid") serviceKye := beego.AppConfig.String("serviceKye") reader := bytes.NewReader(byterequest) serviceCode := beego.AppConfig.String("serviceCode") signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode) request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) } fmt.Println("请求参数", request) fmt.Println("Content-Signature", signatureStr) request.Header.Set("appId", appId) request.Header.Set("appKey", serviceKye) request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("Content-Signature", signatureStr) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) } str := string(respBytes) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) } return str } func GetLastAdminUserName(doctor, orgid int64) string { var tmp models.VmUserAdminRole XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Last(&tmp) return tmp.UserName } func GetLastAdminUserIdCardNumber(doctor, orgid int64) string { var tmp models.VmUserAdminRole XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Last(&tmp) return tmp.JobNumber } func CreateEnterpriseUserName(enterprise models.XtDevicePersonEnterprise) error { err := XTWriteDB().Create(&enterprise).Error return err } func UpdatePersionEnterPrise(id int64, userId string) error { err := XTWriteDB().Model(&models.XtDevicePersonEnterprise{}).Where("id=? and status =1", id).Updates(map[string]interface{}{"user_id": userId}).Error return err } func SingleImg2Pdf(pathStr string) { pdf := gofpdf.New("P", "mm", "A4", "") pdf.AddPage() pdf.SetFont("Arial", "", 11) pdf.Image(pathStr, 10, 10, pdf.GetPageSizeStr("A4").Wd-20, 0, false, "", 0, "") // pdf.Text(50, 20, "logo.png") fileNameAll := path.Base(pathStr) fileSuffix := path.Ext(pathStr) fileStr := fmt.Sprintf("./pdfs/%s.pdf", fileNameAll[0:len(fileNameAll)-len(fileSuffix)]) err := pdf.OutputFileAndClose(fileStr) fmt.Println(err) } func GetAllPatientNew(org_id int64) (new []*models.XtPatients, err error) { err = XTReadDB().Where("user_org_id = ? and status=1", org_id).Find(&new).Error return new, err } func UpdatePatientNew(id int64, firstleterr string) error { err := XTWriteDB().Model(models.XtPatients{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error return err } func GeteAllBaseList(user_org_id int64) (list []*models.BaseDrugLib, err error) { err = XTWriteDB().Model(&list).Where("org_id = ? and status =1", user_org_id).Find(&list).Error return list, err } func UpdateBaseList(id int64, firstleterr string) error { err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error return err } func GetAutoDrugList(user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) { err = XTReadDB().Where("user_org_id =? and status =1 and advice_date = 1700582400 and drug_id =239", user_org_id).Find(&advice).Error return advice, err } func GetDrugAutoWarehouseOutList(patient_id int64, user_org_id int64, drug_id int64, advice_date int64) (models.DrugWarehouseOutInfo, error) { info := models.DrugWarehouseOutInfo{} err2 := XTReadDB().Where("patient_id = ? and org_id = ? and drug_id = ? and sys_record_time =? and status=1", patient_id, user_org_id, drug_id, advice_date).Find(&info).Error return info, err2 } func UpdateSchPatient(patient_id int64, schedule_date int64, user_org_id int64, DialysisMachineName string) error { err := XTWriteDB().Model(&models.XtSchedule{}).Where("patient_id =? and schedule_date =? and user_org_id =?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"dialysis_machine_name": DialysisMachineName}).Error return err } func GetNewAllpatient(org_id int64) (list []*models.XtPatientsNew, err error) { err = XTReadDB().Where("status =1 and user_org_id =10567").Find(&list).Error return list, err } func UpdateAllPatient(id int64, diagose string, orgid int64) error { err := XTWriteDB().Model(models.XtPatients{}).Where("id = ? and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"diagnose": diagose}).Error return err } func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) { err = XTReadDB().Where("user_org_id = ? and dialysis_date =?", 10579, 1701360000).Find(&list).Error return list, err } func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) error { err := XTWriteDB().Model(&models.XtSchedule{}).Where("schedule_date =? and user_org_id =? and status=1 and patient_id =?", schedule_date, user_org_id, patient_id).Updates(map[string]interface{}{"bed_id": bed_id, "partition_id": zone_id, "schedule_type": shcedule_type}).Error return err } func GetScheduleListByOrder(user_org_id int64) (list []*models.XtSchedule, err error) { err = XTReadDB().Where("user_org_id = ? and schedule_date >=? and status =1 and schedule_date<=?", 10579, 1703260800, 1703347200).Find(&list).Error return list, err } func GetDialysisSoluton(patient_id int64, mode_id int64) (models.DialysisSolution, error) { solution := models.DialysisSolution{} err := XTReadDB().Where("patient_id =? and mode_id =? and status =1 and solution_status = 1", patient_id, mode_id).Find(&solution).Error return solution, err } func UpdateDialysisSchedule(id int64, dialysis_machine_name string) error { err := XTWriteDB().Model(models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"dialysis_machine_name": dialysis_machine_name}).Error return err } func GetPrescriptionListOne(user_org_id int64) (prescription []*models.DialysisPrescription, err error) { err = XTReadDB().Model(&prescription).Where("user_org_id = ? and status= 1 and record_date =? and status=1", 10579, 1701360000).Find(&prescription).Error return prescription, err } func GetPatientScheduleById(patient_id int64, schedule_date int64) (models.XtSchedule, error) { schedule := models.XtSchedule{} err := XTReadDB().Where("patient_id= ? and schedule_date = ? and status =1 and user_org_id =10579", patient_id, schedule_date).First(&schedule).Error return schedule, err } func UpdateDialysisScheduleOne(id int64, mode_id int64, dialysis_machine_name string) error { err := XTWriteDB().Model(models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"dialysis_machine_name": dialysis_machine_name, "mode_id": mode_id}).Error return err } func GetDialysisOrderTotalCount() (order []*models.XtDialysisOrderLost, err error) { err = XTReadDB().Select("patient_id,Count(id) as count").Where("user_org_id = ? and status =1", 10265).Group("patient_id").Find(&order).Error return order, err } func ModifyPatient(patient_id int64, count int64) (models.XtPatients, error) { patients := models.XtPatients{} err := XTReadDB().Model(&models.XtPatients{}).Where("id = ? and status =1", patient_id).Updates(map[string]interface{}{"total_dialysis": count}).Error return patients, err } func UpdateDrugWarehouseInfoByDrug(drug_id int64, reatial_price float64, user_org_id int64) (models.DrugWarehouseInfo, error) { drugWarehouseInfo := models.DrugWarehouseInfo{} err := XTWriteDB().Model(&drugWarehouseInfo).Where("drug_id = ? and org_id =?", drug_id, user_org_id).Updates(map[string]interface{}{"retail_price": reatial_price}).Error return drugWarehouseInfo, err } func UpdasteGoodWarehouseInfoByGood(good_id int64, packing_price float64, org_id int64) (models.WarehousingInfo, error) { info := models.WarehousingInfo{} err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("good_id=? and org_id = ? and status =1", good_id, org_id).Updates(map[string]interface{}{"packing_price": packing_price}).Error return info, err } func UpdateHisDoctorAdviceOne(drug_id int64, retail_price float64, user_org_id int64) (models.HisDoctorAdvice, error) { advice := models.HisDoctorAdvice{} err := XTWriteDB().Model(&models.HisDoctorAdvice{}).Where("drug_id = ? and user_org_id = ? and status=1", drug_id, user_org_id).Updates(map[string]interface{}{"price": retail_price}).Error return advice, err }