1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203 |
- 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
- }
|