sign_service.go 69KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388
  1. package service
  2. import (
  3. "bytes"
  4. "crypto/hmac"
  5. "crypto/sha1"
  6. "encoding/base64"
  7. "encoding/json"
  8. "fmt"
  9. "XT_New/models"
  10. "XT_New/utils"
  11. "github.com/astaxie/beego"
  12. //"github.com/jung-kurt/gofpdf"
  13. "io/ioutil"
  14. "net/http"
  15. )
  16. func GetSignNameByPhone(phoneOne string) string {
  17. var url string
  18. url = "http://demo-open.itruscloud.com/apigate/smsService/sendingSms"
  19. var phone string
  20. phone = "13318464642"
  21. var content string
  22. content = "123456"
  23. var autograph string
  24. autograph = "【天威诚信】"
  25. maprequest := make(map[string]interface{})
  26. maprequest["phone"] = phone
  27. maprequest["content"] = content
  28. maprequest["autograph"] = autograph
  29. byterequest, _ := json.Marshal(maprequest)
  30. appId := beego.AppConfig.String("sign_appid")
  31. serviceKye := beego.AppConfig.String("serviceKye")
  32. serviceCode := beego.AppConfig.String("serviceCode")
  33. reader := bytes.NewReader(byterequest)
  34. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  35. fmt.Println(signatureStr)
  36. request, err := http.NewRequest("POST", url, reader)
  37. if err != nil {
  38. fmt.Println(err.Error())
  39. }
  40. fmt.Println("请求参数", request)
  41. fmt.Println("Content-Signature", signatureStr)
  42. fmt.Println("appID", appId)
  43. fmt.Println("serviceCode", serviceCode)
  44. request.Header.Set("appId", appId)
  45. request.Header.Set("serviceCode", serviceCode)
  46. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  47. request.Header.Set("Content-Signature", signatureStr)
  48. client := http.Client{}
  49. resp, err := client.Do(request)
  50. if err != nil {
  51. fmt.Println(err.Error())
  52. }
  53. respBytes, err := ioutil.ReadAll(resp.Body)
  54. if err != nil {
  55. fmt.Println(err.Error())
  56. }
  57. str := string(respBytes)
  58. fmt.Println(str)
  59. return str
  60. }
  61. func generateHMACSHA1SignatureOne(data interface{}, key, serviceCode string) (string, error) {
  62. // 将数据转换为 JSON 格式的字节数组
  63. jsonData, err := json.Marshal(data)
  64. if err != nil {
  65. return "", err
  66. }
  67. // 将密钥和 serviceCode 进行拼接
  68. signingKey := key + serviceCode
  69. // 将签名密钥转换为字节数组
  70. keyBytes := []byte(signingKey)
  71. // 创建一个新的 HMAC-SHA1 实例
  72. h := hmac.New(sha1.New, keyBytes)
  73. // 将 JSON 数据添加到 HMAC 实例中
  74. h.Write(jsonData)
  75. signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
  76. // 返回带有前缀的签名字符串
  77. return "HMAC-SHA1 " + signature, nil
  78. }
  79. func GenerateHMACSHA1SignatureTwo(data interface{}, key string) (string, error) {
  80. // 将数据转换为 JSON 格式的字节数组
  81. jsonData, err := json.Marshal(data)
  82. if err != nil {
  83. return "", err
  84. }
  85. // 将密钥和 serviceCode 进行拼接
  86. signingKey := key
  87. // 将签名密钥转换为字节数组
  88. keyBytes := []byte(signingKey)
  89. // 创建一个新的 HMAC-SHA1 实例
  90. h := hmac.New(sha1.New, keyBytes)
  91. // 将 JSON 数据添加到 HMAC 实例中
  92. h.Write(jsonData)
  93. signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
  94. // 返回带有前缀的签名字符串
  95. return "HMAC-SHA1 " + signature, nil
  96. }
  97. func CreateUserName(phone string, disPlayName string) (string, string) {
  98. var url string
  99. url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createUserRealName"
  100. var phoneOne string
  101. phoneOne = "13318464642"
  102. var disPlayNameOne string
  103. disPlayNameOne = "马云的朋友"
  104. var authentication string
  105. //测试环境用true
  106. authentication = "true"
  107. maprequest := make(map[string]interface{})
  108. twAuthReq := make(map[string]interface{})
  109. apiAuthReq := make(map[string]interface{})
  110. customerReq := make(map[string]interface{})
  111. customerReq["idCardType"] = "0"
  112. customerReq["idCardNum"] = "430526199408156511"
  113. apiAuthReq["realNameType"] = 3
  114. apiAuthReq["idCardType"] = "0"
  115. apiAuthReq["idCardNum"] = "430526199408156511"
  116. apiAuthReq["bankCard"] = "6225551675364804"
  117. //验证码流水号
  118. apiAuthReq["codeNumber"] = "msg202307071510269187701"
  119. //验证码
  120. apiAuthReq["verifyCode"] = "123456"
  121. twAuthReq["oneLineAuth"] = "false"
  122. twAuthReq["apiAuthReq"] = apiAuthReq
  123. maprequest["phone"] = phoneOne
  124. maprequest["displayName"] = disPlayNameOne
  125. maprequest["authentication"] = authentication
  126. maprequest["twAuthReq"] = twAuthReq
  127. maprequest["customerAuthReq"] = customerReq
  128. byterequest, _ := json.Marshal(maprequest)
  129. appId := beego.AppConfig.String("sign_appid")
  130. serviceKye := beego.AppConfig.String("serviceKye")
  131. serviceCode := beego.AppConfig.String("serviceCode")
  132. reader := bytes.NewReader(byterequest)
  133. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  134. fmt.Println(signatureStr)
  135. request, err := http.NewRequest("POST", url, reader)
  136. if err != nil {
  137. fmt.Println(err.Error())
  138. }
  139. fmt.Println("请求参数", request)
  140. fmt.Println("Content-Signature", signatureStr)
  141. fmt.Println("appID", appId)
  142. fmt.Println("serviceCode", serviceCode)
  143. request.Header.Set("appId", appId)
  144. request.Header.Set("serviceCode", serviceCode)
  145. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  146. request.Header.Set("Content-Signature", signatureStr)
  147. client := http.Client{}
  148. resp, err := client.Do(request)
  149. if err != nil {
  150. fmt.Println(err.Error())
  151. }
  152. respBytes, err := ioutil.ReadAll(resp.Body)
  153. if err != nil {
  154. fmt.Println(err.Error())
  155. }
  156. str := string(respBytes)
  157. var respJSON map[string]interface{}
  158. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  160. }
  161. var UserId string
  162. UserId = respJSON["data"].(map[string]interface{})["userId"].(string)
  163. fmt.Println("str", UserId)
  164. return str, UserId
  165. }
  166. 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) {
  167. maprequest := make(map[string]interface{})
  168. maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  169. maprequest["personSealType"] = 1
  170. maprequest["personSealName"] = "小朋友的印章"
  171. var url string
  172. url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createPersonSeal"
  173. appId := beego.AppConfig.String("sign_appid")
  174. serviceKye := beego.AppConfig.String("serviceKye")
  175. serviceCode := beego.AppConfig.String("serviceCode")
  176. byterequest, _ := json.Marshal(maprequest)
  177. reader := bytes.NewReader(byterequest)
  178. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  179. fmt.Println(signatureStr)
  180. request, err := http.NewRequest("POST", url, reader)
  181. if err != nil {
  182. fmt.Println(err.Error())
  183. }
  184. request.Header.Set("appId", appId)
  185. request.Header.Set("serviceCode", serviceCode)
  186. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  187. request.Header.Set("Content-Signature", signatureStr)
  188. client := http.Client{}
  189. resp, err := client.Do(request)
  190. if err != nil {
  191. fmt.Println(err.Error())
  192. }
  193. respBytes, err := ioutil.ReadAll(resp.Body)
  194. if err != nil {
  195. fmt.Println(err.Error())
  196. }
  197. str := string(respBytes)
  198. var respJSON map[string]interface{}
  199. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  201. }
  202. var personSealId string
  203. personSealId = respJSON["data"].(map[string]interface{})["personSealId"].(string)
  204. fmt.Println("str", personSealId)
  205. return str, personSealId
  206. }
  207. func CreateUploadPact(contractcode string, contractname string, signcount int64, docname string, contractbase string, creator string, enterpriseid string, signvalidays int64, sysncurl string, asyncurl string) string {
  208. var url string
  209. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/createByFile"
  210. appId := beego.AppConfig.String("sign_appid")
  211. serviceKye := beego.AppConfig.String("serviceKye")
  212. serviceCode := beego.AppConfig.String("serviceCode")
  213. maprequest := make(map[string]interface{})
  214. maprequest["contractName"] = "电脑购买交易合同"
  215. maprequest["signCount"] = 10
  216. maprequest["docName"] = "日本员工保密协议"
  217. file := "C:/Users/28169/Desktop/2.pdf"
  218. fileBytes, err := ioutil.ReadFile(file) // 读取file
  219. contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  220. maprequest["contractBase64"] = contractBase64
  221. //添加企业成员 里面的USERID
  222. maprequest["creator"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  223. maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
  224. maprequest["signValidDays"] = 90
  225. maprequest["sysnUrl"] = "https://kuyi.shengws.com/chenxuemin1.png"
  226. maprequest["asyncUrl"] = "https://kuyi.shengws.com/chenxuemin1.png"
  227. byterequest, _ := json.Marshal(maprequest)
  228. reader := bytes.NewReader(byterequest)
  229. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  230. request, err := http.NewRequest("POST", url, reader)
  231. if err != nil {
  232. fmt.Println(err.Error())
  233. }
  234. request.Header.Set("appId", appId)
  235. request.Header.Set("serviceCode", serviceCode)
  236. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  237. request.Header.Set("Content-Signature", signatureStr)
  238. client := http.Client{}
  239. resp, err := client.Do(request)
  240. if err != nil {
  241. fmt.Println(err.Error())
  242. }
  243. respBytes, err := ioutil.ReadAll(resp.Body)
  244. if err != nil {
  245. fmt.Println(err.Error())
  246. }
  247. str := string(respBytes)
  248. return str
  249. }
  250. func CreateEnterPriseRealName(enterprisename string) string {
  251. var url string
  252. url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createEnterpriseRealName"
  253. appId := beego.AppConfig.String("sign_appid")
  254. serviceKye := beego.AppConfig.String("serviceKye")
  255. serviceCode := beego.AppConfig.String("serviceCode")
  256. maprequest := make(map[string]interface{})
  257. customerReq := make(map[string]interface{})
  258. customerReq["idCardType"] = "N"
  259. customerReq["idCardNum"] = "430526199408156511"
  260. maprequest["enterpriseName"] = "深圳德马西科技有限公司"
  261. maprequest["authentication"] = true
  262. maprequest["customerAuthReq"] = customerReq
  263. fmt.Println("maprequest", maprequest)
  264. byterequest, _ := json.Marshal(maprequest)
  265. reader := bytes.NewReader(byterequest)
  266. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  267. request, err := http.NewRequest("POST", url, reader)
  268. if err != nil {
  269. fmt.Println(err.Error())
  270. }
  271. request.Header.Set("appId", appId)
  272. request.Header.Set("serviceCode", serviceCode)
  273. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  274. request.Header.Set("Content-Signature", signatureStr)
  275. client := http.Client{}
  276. resp, err := client.Do(request)
  277. if err != nil {
  278. fmt.Println(err.Error())
  279. }
  280. respBytes, err := ioutil.ReadAll(resp.Body)
  281. if err != nil {
  282. fmt.Println(err.Error())
  283. }
  284. str := string(respBytes)
  285. return str
  286. }
  287. func CreateUserId(userId string, displayName string) string {
  288. var url string
  289. url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/joinEnterprise"
  290. appId := beego.AppConfig.String("sign_appid")
  291. serviceKye := beego.AppConfig.String("serviceKye")
  292. serviceCode := beego.AppConfig.String("serviceCode")
  293. maprequest := make(map[string]interface{})
  294. maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
  295. maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  296. byterequest, _ := json.Marshal(maprequest)
  297. reader := bytes.NewReader(byterequest)
  298. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  299. request, err := http.NewRequest("POST", url, reader)
  300. if err != nil {
  301. fmt.Println(err.Error())
  302. }
  303. request.Header.Set("appId", appId)
  304. request.Header.Set("serviceCode", serviceCode)
  305. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  306. request.Header.Set("Content-Signature", signatureStr)
  307. client := http.Client{}
  308. resp, err := client.Do(request)
  309. if err != nil {
  310. fmt.Println(err.Error())
  311. }
  312. respBytes, err := ioutil.ReadAll(resp.Body)
  313. if err != nil {
  314. fmt.Println(err.Error())
  315. }
  316. str := string(respBytes)
  317. return str
  318. }
  319. //type ResultTwo struct {
  320. // ErrMsg string `json:"err_msg"`
  321. // InfRefmsgid string `json:"inf_refmsgid"`
  322. // Infcode int64 `json:"infcode"`
  323. // Output struct {
  324. // Baseinfo struct {
  325. // Age float64 `json:"age"`
  326. // Brdy string `json:"brdy"`
  327. // Certno string `json:"certno"`
  328. // Gend string `json:"gend"`
  329. // Naty string `json:"naty"`
  330. // PsnCertType string `json:"psn_cert_type"`
  331. // PsnName string `json:"psn_name"`
  332. // PsnNo string `json:"psn_no"`
  333. // } `json:"baseinfo"`
  334. // Idetinfo []interface{} `json:"idetinfo"`
  335. // Iinfo []struct {
  336. // Balc float64 `json:"balc"`
  337. // CvlservFlag string `json:"cvlserv_flag"`
  338. // EmpName string `json:"emp_name"`
  339. // InsuplcAdmdvs string `json:"insuplc_admdvs"`
  340. // Insutype string `json:"insutype"`
  341. // PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  342. // PausInsuDate string `json:"paus_insu_date"`
  343. // PsnInsuDate string `json:"psn_insu_date"`
  344. // PsnInsuStas string `json:"psn_insu_stas"`
  345. // PsnType string `json:"psn_type"`
  346. // } `json:"insuinfo"`
  347. // } `json:"output"`
  348. // RefmsgTime string `json:"refmsg_time"`
  349. // RespondTime string `json:"respond_time"`
  350. // Signtype interface{} `json:"signtype"`
  351. // WarnInfo interface{} `json:"warn_info"`
  352. //}
  353. func AddContractSignatory(contractId string, signers string, contract models.NewContract) string {
  354. var url string
  355. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/addSignerByFile"
  356. appId := beego.AppConfig.String("sign_appid")
  357. serviceKye := beego.AppConfig.String("serviceKye")
  358. serviceCode := beego.AppConfig.String("serviceCode")
  359. signFiles := make(map[string]interface{})
  360. //创建合同返回
  361. signFiles["docId"] = "158807311102510183"
  362. inputDataArr := make([]map[string]interface{}, 0)
  363. for _, item := range signFiles {
  364. fmt.Println("item", item)
  365. xySignControls := make(map[string]interface{})
  366. xySignControls["key"] = "1"
  367. xySignControls["type"] = "autograph"
  368. xySignControls["pageNum"] = 1
  369. xySignControls["positionX"] = "120F"
  370. xySignControls["positionY"] = "120F"
  371. inputDataArr = append(inputDataArr, xySignControls)
  372. }
  373. inputDataArrTwo := make([]map[string]interface{}, 0)
  374. for _, item := range signFiles {
  375. fmt.Println(item)
  376. keywordSignControls := make(map[string]interface{})
  377. keywordSignControls["key"] = "2"
  378. keywordSignControls["type"] = "date"
  379. keywordSignControls["pageNum"] = 1
  380. keywordSignControls["keyword"] = "王志文"
  381. keywordSignControls["offsetX"] = "100F"
  382. keywordSignControls["offsetY"] = "100F"
  383. inputDataArrTwo = append(inputDataArrTwo, keywordSignControls)
  384. }
  385. signFiles["xySignControls"] = inputDataArr
  386. signFiles["keywordSignControls"] = inputDataArrTwo
  387. inputDataArrThree := make([]map[string]interface{}, 0)
  388. inputDataArrThree = append(inputDataArrThree, signFiles)
  389. signersFiles := make(map[string]interface{})
  390. signersFiles["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  391. signersFiles["signerType"] = "1"
  392. signersFiles["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
  393. signersFiles["sequence"] = "8"
  394. signersFiles["sendMsg"] = false
  395. signersFiles["setting"] = true
  396. signersFiles["signFiles"] = inputDataArrThree
  397. inputDataArrFour := make([]map[string]interface{}, 0)
  398. inputDataArrFour = append(inputDataArrFour, signersFiles)
  399. maprequest := make(map[string]interface{})
  400. maprequest["contractId"] = "158807311102510182"
  401. maprequest["signers"] = inputDataArrFour
  402. byterequest, _ := json.Marshal(maprequest)
  403. reader := bytes.NewReader(byterequest)
  404. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  405. request, err := http.NewRequest("POST", url, reader)
  406. if err != nil {
  407. fmt.Println(err.Error())
  408. }
  409. request.Header.Set("appId", appId)
  410. request.Header.Set("serviceCode", serviceCode)
  411. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  412. request.Header.Set("Content-Signature", signatureStr)
  413. client := http.Client{}
  414. resp, err := client.Do(request)
  415. if err != nil {
  416. fmt.Println(err.Error())
  417. }
  418. respBytes, err := ioutil.ReadAll(resp.Body)
  419. if err != nil {
  420. fmt.Println(err.Error())
  421. }
  422. str := string(respBytes)
  423. return str
  424. }
  425. func CreateBackStageSign(contractId string, signers string) string {
  426. var url string
  427. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/signByFile"
  428. appId := beego.AppConfig.String("sign_appid")
  429. serviceKye := beego.AppConfig.String("serviceKye")
  430. serviceCode := beego.AppConfig.String("serviceCode")
  431. sealTimestampFiles := make(map[string]interface{})
  432. inputDataArr := make([]map[string]interface{}, 0)
  433. signFiles := make(map[string]interface{})
  434. keywordSignControls := make(map[string]interface{})
  435. keywordSignControls["controlsKey"] = "2"
  436. keywordSignControls["pattern"] = 1
  437. keywordSignControls["color"] = "#FF0000"
  438. inputDataArr = append(inputDataArr, keywordSignControls)
  439. sealTimestampFiles["allAddTimestamp"] = false
  440. sealTimestampFiles["someTimestampStyle"] = inputDataArr
  441. inputDataArrOne := make([]map[string]interface{}, 0)
  442. keySignControls := make(map[string]interface{})
  443. keySignControls["controlsKey"] = "1"
  444. keySignControls["fontType"] = 1
  445. keySignControls["fontSize"] = 8.5
  446. keySignControls["fontColor"] = "#56600F"
  447. keySignControls["alignment"] = 1
  448. inputDataArrOne = append(inputDataArrOne, keySignControls)
  449. signFiles["fonts"] = inputDataArrOne
  450. signFiles["showTimestamp"] = false
  451. signFiles["sealTimestamp"] = sealTimestampFiles
  452. signControl := make(map[string]interface{})
  453. signControl["1"] = "{sealId:157474548357267755}"
  454. signControl["2"] = "姓名"
  455. fmt.Println("signContorlwqowowo", signControl)
  456. signFiles["signControl"] = signControl
  457. signFiles["docId"] = "158807311102510183"
  458. inputDataArrThree := make([]map[string]interface{}, 0)
  459. inputDataArrThree = append(inputDataArrThree, signFiles)
  460. signer := make(map[string]interface{})
  461. //添加合同签署人接口返回
  462. signer["signerId"] = "158807462500107405"
  463. signer["isUserWishes"] = true
  464. signer["userWishesWay"] = 1
  465. signer["codeNumber"] = "msg202309081937527315153"
  466. signer["verifyCode"] = "252234"
  467. signer["signFiles"] = inputDataArrThree
  468. maprequest := make(map[string]interface{})
  469. maprequest["contractId"] = "158807311102510182"
  470. maprequest["signer"] = signer
  471. byterequest, _ := json.Marshal(maprequest)
  472. reader := bytes.NewReader(byterequest)
  473. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  474. request, err := http.NewRequest("POST", url, reader)
  475. if err != nil {
  476. fmt.Println(err.Error())
  477. }
  478. request.Header.Set("appId", appId)
  479. request.Header.Set("serviceCode", serviceCode)
  480. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  481. request.Header.Set("Content-Signature", signatureStr)
  482. client := http.Client{}
  483. resp, err := client.Do(request)
  484. if err != nil {
  485. fmt.Println(err.Error())
  486. }
  487. respBytes, err := ioutil.ReadAll(resp.Body)
  488. if err != nil {
  489. fmt.Println(err.Error())
  490. }
  491. str := string(respBytes)
  492. return str
  493. }
  494. func GetVerificationCode() string {
  495. var url string
  496. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/sendSmsCode"
  497. appId := beego.AppConfig.String("sign_appid")
  498. serviceKye := beego.AppConfig.String("serviceKye")
  499. serviceCode := beego.AppConfig.String("serviceCode")
  500. maprequest := make(map[string]interface{})
  501. maprequest["contractId"] = "158807311102510182"
  502. maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  503. byterequest, _ := json.Marshal(maprequest)
  504. reader := bytes.NewReader(byterequest)
  505. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  506. request, err := http.NewRequest("POST", url, reader)
  507. if err != nil {
  508. fmt.Println(err.Error())
  509. }
  510. request.Header.Set("appId", appId)
  511. request.Header.Set("serviceCode", serviceCode)
  512. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  513. request.Header.Set("Content-Signature", signatureStr)
  514. client := http.Client{}
  515. resp, err := client.Do(request)
  516. if err != nil {
  517. fmt.Println(err.Error())
  518. }
  519. respBytes, err := ioutil.ReadAll(resp.Body)
  520. if err != nil {
  521. fmt.Println(err.Error())
  522. }
  523. str := string(respBytes)
  524. return str
  525. }
  526. func CreateEnterprise() string {
  527. var url string
  528. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/sendSmsCode"
  529. appId := beego.AppConfig.String("sign_appid")
  530. serviceKye := beego.AppConfig.String("serviceKye")
  531. serviceCode := beego.AppConfig.String("serviceCode")
  532. maprequest := make(map[string]interface{})
  533. maprequest["contractId"] = "157413765980094742"
  534. maprequest["userId"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  535. maprequest["sealType"] = 1
  536. maprequest["sealName"] = "测试用章"
  537. maprequest["sealBase64"] = ""
  538. maprequest["color"] = 1
  539. maprequest["width"] = 40
  540. maprequest["authUserId"] = ""
  541. maprequest["sealCreateType"] = false
  542. byterequest, _ := json.Marshal(maprequest)
  543. reader := bytes.NewReader(byterequest)
  544. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  545. request, err := http.NewRequest("POST", url, reader)
  546. if err != nil {
  547. fmt.Println(err.Error())
  548. }
  549. request.Header.Set("appId", appId)
  550. request.Header.Set("serviceCode", serviceCode)
  551. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  552. request.Header.Set("Content-Signature", signatureStr)
  553. client := http.Client{}
  554. resp, err := client.Do(request)
  555. if err != nil {
  556. fmt.Println(err.Error())
  557. }
  558. respBytes, err := ioutil.ReadAll(resp.Body)
  559. if err != nil {
  560. fmt.Println(err.Error())
  561. }
  562. str := string(respBytes)
  563. return str
  564. }
  565. func GetTestThrityMent(org_id int64) (base []*models.XtBaseDrug, err error) {
  566. err = XTReadDB().Where("org_id = ? and status=1", org_id).Find(&base).Error
  567. return base, err
  568. }
  569. func UpdateDrugWarehouseInfoByDrugId(drug_id int64, min_price float64) error {
  570. 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
  571. return err
  572. }
  573. func GetEnterPriseByUserOrgId(user_org_id int64) (models.XtDeviceEnterprise, error) {
  574. enterprise := models.XtDeviceEnterprise{}
  575. err := XTReadDB().Where("user_org_id = ? and status =1", user_org_id).Find(&enterprise).Error
  576. return enterprise, err
  577. }
  578. func CreateEnterPrise(enterprise models.XtDeviceEnterprise) error {
  579. err := XTWriteDB().Create(&enterprise).Error
  580. return err
  581. }
  582. func SaveEnerPrise(enterprise models.XtDeviceEnterprise) error {
  583. err := XTWriteDB().Save(&enterprise).Error
  584. return err
  585. }
  586. func CreateNewEnterPriseRealName(enterprise models.XtDeviceEnterprise) (string, string) {
  587. var url string
  588. url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createEnterpriseRealName"
  589. appId := beego.AppConfig.String("sign_appid")
  590. serviceKye := beego.AppConfig.String("serviceKye")
  591. serviceCode := beego.AppConfig.String("serviceCode")
  592. maprequest := make(map[string]interface{})
  593. customerReq := make(map[string]interface{})
  594. customerReq["idCardType"] = "N"
  595. customerReq["idCardNum"] = "430526199408156511"
  596. maprequest["enterpriseName"] = enterprise.EnterpriseName
  597. maprequest["authentication"] = true
  598. maprequest["customerAuthReq"] = customerReq
  599. fmt.Println("maprequest", maprequest)
  600. byterequest, _ := json.Marshal(maprequest)
  601. reader := bytes.NewReader(byterequest)
  602. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  603. request, err := http.NewRequest("POST", url, reader)
  604. if err != nil {
  605. fmt.Println(err.Error())
  606. }
  607. request.Header.Set("appId", appId)
  608. request.Header.Set("serviceCode", serviceCode)
  609. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  610. request.Header.Set("Content-Signature", signatureStr)
  611. client := http.Client{}
  612. resp, err := client.Do(request)
  613. if err != nil {
  614. fmt.Println(err.Error())
  615. }
  616. respBytes, err := ioutil.ReadAll(resp.Body)
  617. if err != nil {
  618. fmt.Println(err.Error())
  619. }
  620. str := string(respBytes)
  621. var respJSON map[string]interface{}
  622. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  624. }
  625. var enterpriseId string
  626. enterpriseId = respJSON["data"].(map[string]interface{})["enterpriseId"].(string)
  627. fmt.Println("enterpriseId", enterpriseId)
  628. return str, enterpriseId
  629. }
  630. func GetNewSignNameByPhone(phone string) (string, string) {
  631. var url string
  632. url = "http://demo-open.itruscloud.com/apigate/smsService/sendingSms"
  633. var content string
  634. content = "123456"
  635. var autograph string
  636. autograph = "【天威诚信】"
  637. maprequest := make(map[string]interface{})
  638. maprequest["phone"] = phone
  639. maprequest["content"] = content
  640. maprequest["autograph"] = autograph
  641. byterequest, _ := json.Marshal(maprequest)
  642. appId := beego.AppConfig.String("sign_appid")
  643. serviceKye := beego.AppConfig.String("serviceKye")
  644. serviceCode := beego.AppConfig.String("serviceCode")
  645. reader := bytes.NewReader(byterequest)
  646. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  647. fmt.Println(signatureStr)
  648. request, err := http.NewRequest("POST", url, reader)
  649. if err != nil {
  650. fmt.Println(err.Error())
  651. }
  652. request.Header.Set("appId", appId)
  653. request.Header.Set("serviceCode", serviceCode)
  654. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  655. request.Header.Set("Content-Signature", signatureStr)
  656. client := http.Client{}
  657. resp, err := client.Do(request)
  658. if err != nil {
  659. fmt.Println(err.Error())
  660. }
  661. respBytes, err := ioutil.ReadAll(resp.Body)
  662. if err != nil {
  663. fmt.Println(err.Error())
  664. }
  665. str := string(respBytes)
  666. var respJSON map[string]interface{}
  667. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. }
  670. var orderNumber string
  671. orderNumber = respJSON["orderNumber"].(string)
  672. fmt.Println("orderNumberWOWOWOWOWO", orderNumber)
  673. return str, orderNumber
  674. }
  675. func SavePersonEnterPrise(enterprise models.XtDevicePersonEnterprise) error {
  676. err := XTWriteDB().Save(&enterprise).Error
  677. return err
  678. }
  679. func GetLastPersonEnterPrise(admin_user_id int64, orgId int64) (models.XtDevicePersonEnterprise, error) {
  680. enterprise := models.XtDevicePersonEnterprise{}
  681. err := XTReadDB().Where("admin_user_id = ? and user_org_id = ? and status = 1", admin_user_id, orgId).Find(&enterprise).Error
  682. return enterprise, err
  683. }
  684. func CreateNewUserName(phone string, disPlayName string, code string, orderNumber string, id_card_number string) (string, string) {
  685. var url string
  686. url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createUserRealName"
  687. var authentication string
  688. //测试环境用true
  689. authentication = "true"
  690. maprequest := make(map[string]interface{})
  691. twAuthReq := make(map[string]interface{})
  692. apiAuthReq := make(map[string]interface{})
  693. customerReq := make(map[string]interface{})
  694. fmt.Println("身份证id_card_number", id_card_number)
  695. customerReq["idCardType"] = "0"
  696. customerReq["idCardNum"] = id_card_number
  697. apiAuthReq["realNameType"] = 3
  698. apiAuthReq["idCardType"] = "0"
  699. apiAuthReq["idCardNum"] = id_card_number
  700. apiAuthReq["bankCard"] = "6225551675364804"
  701. //验证码流水号
  702. apiAuthReq["codeNumber"] = orderNumber
  703. //验证码
  704. apiAuthReq["verifyCode"] = code
  705. twAuthReq["oneLineAuth"] = "false"
  706. twAuthReq["apiAuthReq"] = apiAuthReq
  707. maprequest["phone"] = phone
  708. maprequest["displayName"] = disPlayName
  709. maprequest["authentication"] = authentication
  710. maprequest["twAuthReq"] = twAuthReq
  711. maprequest["customerAuthReq"] = customerReq
  712. byterequest, _ := json.Marshal(maprequest)
  713. appId := beego.AppConfig.String("sign_appid")
  714. serviceKye := beego.AppConfig.String("serviceKye")
  715. serviceCode := beego.AppConfig.String("serviceCode")
  716. reader := bytes.NewReader(byterequest)
  717. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  718. fmt.Println(signatureStr)
  719. request, err := http.NewRequest("POST", url, reader)
  720. if err != nil {
  721. fmt.Println(err.Error())
  722. }
  723. fmt.Println("请求参数", request)
  724. fmt.Println("Content-Signature", signatureStr)
  725. fmt.Println("appID", appId)
  726. fmt.Println("serviceCode", serviceCode)
  727. request.Header.Set("appId", appId)
  728. request.Header.Set("serviceCode", serviceCode)
  729. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  730. request.Header.Set("Content-Signature", signatureStr)
  731. client := http.Client{}
  732. resp, err := client.Do(request)
  733. if err != nil {
  734. fmt.Println(err.Error())
  735. }
  736. respBytes, err := ioutil.ReadAll(resp.Body)
  737. if err != nil {
  738. fmt.Println(err.Error())
  739. }
  740. str := string(respBytes)
  741. var respJSON map[string]interface{}
  742. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  744. }
  745. var UserId string
  746. UserId = respJSON["data"].(map[string]interface{})["userId"].(string)
  747. fmt.Println("str", UserId)
  748. return str, UserId
  749. }
  750. func CreateNewPersionSeal(userId string) (string, string) {
  751. maprequest := make(map[string]interface{})
  752. maprequest["userId"] = userId
  753. maprequest["personSealType"] = 1
  754. maprequest["personSealName"] = "小马印章"
  755. var url string
  756. url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/createPersonSeal"
  757. appId := beego.AppConfig.String("sign_appid")
  758. serviceKye := beego.AppConfig.String("serviceKye")
  759. serviceCode := beego.AppConfig.String("serviceCode")
  760. byterequest, _ := json.Marshal(maprequest)
  761. reader := bytes.NewReader(byterequest)
  762. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  763. fmt.Println(signatureStr)
  764. request, err := http.NewRequest("POST", url, reader)
  765. if err != nil {
  766. fmt.Println(err.Error())
  767. }
  768. request.Header.Set("appId", appId)
  769. request.Header.Set("serviceCode", serviceCode)
  770. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  771. request.Header.Set("Content-Signature", signatureStr)
  772. client := http.Client{}
  773. resp, err := client.Do(request)
  774. if err != nil {
  775. fmt.Println(err.Error())
  776. }
  777. respBytes, err := ioutil.ReadAll(resp.Body)
  778. if err != nil {
  779. fmt.Println(err.Error())
  780. }
  781. str := string(respBytes)
  782. var respJSON map[string]interface{}
  783. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  785. }
  786. var personSealId string
  787. personSealId = respJSON["data"].(map[string]interface{})["personSealId"].(string)
  788. fmt.Println("str", personSealId)
  789. return str, personSealId
  790. }
  791. func CreateSKDPersionSeal(userId string, user_name string) (string, string) {
  792. maprequest := make(map[string]interface{})
  793. //印章字体 1宋体(默认)2 黑体
  794. maprequest["fontType"] = 1
  795. //个人姓名(1-42位字符)
  796. maprequest["personName"] = user_name
  797. var url string
  798. url = "http://localhost:8890/sdk/seal/createPersonSeal"
  799. appId := beego.AppConfig.String("sign_appid")
  800. fmt.Println("appId", appId)
  801. serviceKye := beego.AppConfig.String("serviceKye")
  802. fmt.Println("serviceKye", serviceKye)
  803. serviceCode := beego.AppConfig.String("serviceCode")
  804. fmt.Println("serviceCode", serviceCode)
  805. byterequest, _ := json.Marshal(maprequest)
  806. reader := bytes.NewReader(byterequest)
  807. signatureStr, ERR := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  808. fmt.Println(ERR)
  809. request, err := http.NewRequest("POST", url, reader)
  810. fmt.Println("errwowowoowowowow", err)
  811. if err != nil {
  812. fmt.Println(err.Error())
  813. }
  814. request.Header.Set("appId", appId)
  815. request.Header.Set("serviceCode", serviceCode)
  816. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  817. request.Header.Set("Content-Signature", signatureStr)
  818. client := http.Client{}
  819. resp, err := client.Do(request)
  820. if err != nil {
  821. fmt.Println(err.Error())
  822. }
  823. respBytes, err := ioutil.ReadAll(resp.Body)
  824. if err != nil {
  825. fmt.Println(err.Error())
  826. }
  827. str := string(respBytes)
  828. fmt.Println("strwoooooooooooooooooooo", str)
  829. var respJSON map[string]interface{}
  830. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  832. }
  833. var sealBase64 string
  834. sealBase64 = respJSON["data"].(map[string]interface{})["sealBase64"].(string)
  835. return str, sealBase64
  836. }
  837. func UpdatePerseEnterPriseById(id int64, personSealId string) error {
  838. err := XTWriteDB().Model(models.XtDevicePersonEnterprise{}).Where("id= ? and status =1", id).Updates(map[string]interface{}{"person_seal_id": personSealId}).Error
  839. return err
  840. }
  841. func CreateNewEnterPrise(enterpriseId string, userId string) (string, string) {
  842. var url string
  843. url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createSeal"
  844. appId := beego.AppConfig.String("sign_appid")
  845. serviceKye := beego.AppConfig.String("serviceKye")
  846. serviceCode := beego.AppConfig.String("serviceCode")
  847. fmt.Println("enterpriseId", enterpriseId)
  848. fmt.Println("userId", userId)
  849. maprequest := make(map[string]interface{})
  850. maprequest["enterpriseId"] = enterpriseId
  851. maprequest["userId"] = userId
  852. maprequest["sealType"] = 1
  853. maprequest["sealName"] = "测试用章"
  854. fmt.Println("request23222222222222222", maprequest)
  855. byterequest, _ := json.Marshal(maprequest)
  856. reader := bytes.NewReader(byterequest)
  857. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  858. request, err := http.NewRequest("POST", url, reader)
  859. fmt.Println("中国人民欢迎您", request)
  860. if err != nil {
  861. fmt.Println(err.Error())
  862. }
  863. request.Header.Set("appId", appId)
  864. request.Header.Set("serviceCode", serviceCode)
  865. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  866. request.Header.Set("Content-Signature", signatureStr)
  867. client := http.Client{}
  868. resp, err := client.Do(request)
  869. if err != nil {
  870. fmt.Println(err.Error())
  871. }
  872. respBytes, err := ioutil.ReadAll(resp.Body)
  873. if err != nil {
  874. fmt.Println(err.Error())
  875. }
  876. str := string(respBytes)
  877. fmt.Println("strwowowowowo", str)
  878. var respJSON map[string]interface{}
  879. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  881. }
  882. var sealId string
  883. sealId = respJSON["data"].(map[string]interface{})["sealId"].(string)
  884. fmt.Println("sealId", sealId)
  885. return str, sealId
  886. }
  887. func CreateSDKEnterPrise() (string, string) {
  888. var url string
  889. url = "http://localhost:8890/sdk/seal/createEnterpriseSeal"
  890. appId := beego.AppConfig.String("sign_appid")
  891. serviceKye := beego.AppConfig.String("serviceKye")
  892. serviceCode := beego.AppConfig.String("serviceCode")
  893. maprequest := make(map[string]interface{})
  894. maprequest["sealType"] = 1
  895. maprequest["enterpriseName"] = "深圳伊森时光科技有限公司"
  896. maprequest["horizontalText"] = "财务专用章"
  897. byterequest, _ := json.Marshal(maprequest)
  898. reader := bytes.NewReader(byterequest)
  899. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  900. fmt.Println("signatureStr", signatureStr)
  901. request, err := http.NewRequest("POST", url, reader)
  902. if err != nil {
  903. fmt.Println(err.Error())
  904. }
  905. request.Header.Set("appId", appId)
  906. request.Header.Set("serviceCode", serviceCode)
  907. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  908. request.Header.Set("Content-Signature", signatureStr)
  909. client := http.Client{}
  910. resp, err := client.Do(request)
  911. if err != nil {
  912. fmt.Println(err.Error())
  913. }
  914. respBytes, err := ioutil.ReadAll(resp.Body)
  915. if err != nil {
  916. fmt.Println(err.Error())
  917. }
  918. str := string(respBytes)
  919. var respJSON map[string]interface{}
  920. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  922. }
  923. var sealId string
  924. //sealId = respJSON["data"].(map[string]interface{})["sealId"].(string)
  925. //fmt.Println("sealId", sealId)
  926. return str, sealId
  927. }
  928. func UpdatePersonEnterPrise(id int64, sealId string) error {
  929. err := XTWriteDB().Model(models.XtDevicePersonEnterprise{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"seal_id": sealId}).Error
  930. return err
  931. }
  932. func GetContractId() string {
  933. var url string
  934. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/search"
  935. appId := beego.AppConfig.String("sign_appid")
  936. serviceKye := beego.AppConfig.String("serviceKye")
  937. serviceCode := beego.AppConfig.String("serviceCode")
  938. maprequest := make(map[string]interface{})
  939. maprequest["contractId"] = "158799561907766048"
  940. maprequest["responseContractFile"] = true
  941. fmt.Println("request23222222222222222", maprequest)
  942. byterequest, _ := json.Marshal(maprequest)
  943. reader := bytes.NewReader(byterequest)
  944. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  945. request, err := http.NewRequest("POST", url, reader)
  946. fmt.Println("request23222222222222222", request)
  947. if err != nil {
  948. fmt.Println(err.Error())
  949. }
  950. request.Header.Set("appId", appId)
  951. request.Header.Set("serviceCode", serviceCode)
  952. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  953. request.Header.Set("Content-Signature", signatureStr)
  954. client := http.Client{}
  955. resp, err := client.Do(request)
  956. if err != nil {
  957. fmt.Println(err.Error())
  958. }
  959. respBytes, err := ioutil.ReadAll(resp.Body)
  960. if err != nil {
  961. fmt.Println(err.Error())
  962. }
  963. str := string(respBytes)
  964. fmt.Println("strwowowowowo", str)
  965. return str
  966. }
  967. func EndEnterPrise() string {
  968. var url string
  969. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/finished"
  970. appId := beego.AppConfig.String("sign_appid")
  971. serviceKye := beego.AppConfig.String("serviceKye")
  972. serviceCode := beego.AppConfig.String("serviceCode")
  973. maprequest := make(map[string]interface{})
  974. maprequest["contractId"] = "157475501840007476"
  975. byterequest, _ := json.Marshal(maprequest)
  976. reader := bytes.NewReader(byterequest)
  977. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  978. request, err := http.NewRequest("POST", url, reader)
  979. if err != nil {
  980. fmt.Println(err.Error())
  981. }
  982. request.Header.Set("appId", appId)
  983. request.Header.Set("serviceCode", serviceCode)
  984. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  985. request.Header.Set("Content-Signature", signatureStr)
  986. client := http.Client{}
  987. resp, err := client.Do(request)
  988. if err != nil {
  989. fmt.Println(err.Error())
  990. }
  991. respBytes, err := ioutil.ReadAll(resp.Body)
  992. if err != nil {
  993. fmt.Println(err.Error())
  994. }
  995. str := string(respBytes)
  996. fmt.Println("strwowowowowo", str)
  997. return str
  998. }
  999. func GetEnterPriseDetail() (string, string) {
  1000. var url string
  1001. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/preview"
  1002. appId := beego.AppConfig.String("sign_appid")
  1003. serviceKye := beego.AppConfig.String("serviceKye")
  1004. serviceCode := beego.AppConfig.String("serviceCode")
  1005. maprequest := make(map[string]interface{})
  1006. maprequest["contractId"] = "158807311102510182"
  1007. byterequest, _ := json.Marshal(maprequest)
  1008. reader := bytes.NewReader(byterequest)
  1009. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  1010. request, err := http.NewRequest("POST", url, reader)
  1011. if err != nil {
  1012. fmt.Println(err.Error())
  1013. }
  1014. request.Header.Set("appId", appId)
  1015. request.Header.Set("serviceCode", serviceCode)
  1016. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1017. request.Header.Set("Content-Signature", signatureStr)
  1018. client := http.Client{}
  1019. resp, err := client.Do(request)
  1020. if err != nil {
  1021. fmt.Println(err.Error())
  1022. }
  1023. respBytes, err := ioutil.ReadAll(resp.Body)
  1024. if err != nil {
  1025. fmt.Println(err.Error())
  1026. }
  1027. str := string(respBytes)
  1028. fmt.Println("strwowowowowo", str)
  1029. var respJSON map[string]interface{}
  1030. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  1031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1032. }
  1033. var urlOne string
  1034. urlOne = respJSON["data"].(map[string]interface{})["url"].(string)
  1035. fmt.Println("url", urlOne)
  1036. return str, urlOne
  1037. }
  1038. func CreateNewUploadPact(name string) string {
  1039. var url string
  1040. url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/createByFile"
  1041. appId := beego.AppConfig.String("sign_appid")
  1042. serviceKye := beego.AppConfig.String("serviceKye")
  1043. serviceCode := beego.AppConfig.String("serviceCode")
  1044. maprequest := make(map[string]interface{})
  1045. //maprequest["contractCode"] = "102020620701056856"
  1046. maprequest["contractName"] = "手机购买交易合同"
  1047. maprequest["signCount"] = 10
  1048. maprequest["docName"] = "美国员工保密协议"
  1049. //file := "C:/Users/28169/Desktop/打印单.pdf"
  1050. //
  1051. //fileBytes, err := ioutil.ReadFile(file) // 读取file
  1052. //
  1053. //contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  1054. //fmt.Println(contractBase64)
  1055. maprequest["contractBase64"] = name
  1056. //添加企业成员 里面的USERID
  1057. maprequest["creator"] = "PBRLMBFVIRR3BV8JGGOX9C7N"
  1058. maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
  1059. maprequest["signValidDays"] = 90
  1060. maprequest["sysnUrl"] = "https://kuyi.shengws.com/chenxuemin1.png"
  1061. maprequest["asyncUrl"] = "https://kuyi.shengws.com/chenxuemin1.png"
  1062. byterequest, _ := json.Marshal(maprequest)
  1063. reader := bytes.NewReader(byterequest)
  1064. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  1065. request, err := http.NewRequest("POST", url, reader)
  1066. if err != nil {
  1067. fmt.Println(err.Error())
  1068. }
  1069. request.Header.Set("appId", appId)
  1070. request.Header.Set("serviceCode", serviceCode)
  1071. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1072. request.Header.Set("Content-Signature", signatureStr)
  1073. client := http.Client{}
  1074. resp, err := client.Do(request)
  1075. if err != nil {
  1076. fmt.Println(err.Error())
  1077. }
  1078. respBytes, err := ioutil.ReadAll(resp.Body)
  1079. if err != nil {
  1080. fmt.Println(err.Error())
  1081. }
  1082. str := string(respBytes)
  1083. fmt.Println("strwwoowowow", str)
  1084. return str
  1085. }
  1086. func GetDataConfigDisinfectionFluid(org_id int64) (models.Dataconfig, error) {
  1087. dataconfig := models.Dataconfig{}
  1088. err := XTReadDB().Where("org_id = ? and status =1 and id =12536", org_id).Find(&dataconfig).Error
  1089. return dataconfig, err
  1090. }
  1091. func CreateQianshuUserName(user_name string, phone string, id_card_number string) (string, string) {
  1092. var url string
  1093. url = "http://localhost:8890/sdk/user/create"
  1094. //var account string
  1095. //
  1096. //account = "13318464642"
  1097. //var realName string
  1098. //
  1099. //realName = "马文强"
  1100. maprequest := make(map[string]interface{})
  1101. maprequest["account"] = phone
  1102. //账号类型:1手机号,2邮箱
  1103. maprequest["accountType"] = 1
  1104. maprequest["realName"] = user_name
  1105. //签署人类型 1个人 2.企业
  1106. maprequest["signerType"] = 1
  1107. // 0表示 身份证
  1108. maprequest["cardType"] = 0
  1109. //maprequest["cardNumber"] = "430526199408156511"
  1110. maprequest["cardNumber"] = id_card_number
  1111. byterequest, _ := json.Marshal(maprequest)
  1112. appId := beego.AppConfig.String("sign_appid")
  1113. serviceKye := beego.AppConfig.String("serviceKye")
  1114. serviceCode := beego.AppConfig.String("serviceCode")
  1115. reader := bytes.NewReader(byterequest)
  1116. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  1117. request, err := http.NewRequest("POST", url, reader)
  1118. if err != nil {
  1119. fmt.Println(err.Error())
  1120. }
  1121. fmt.Println("请求参数", request)
  1122. fmt.Println("Content-Signature", signatureStr)
  1123. request.Header.Set("appId", appId)
  1124. request.Header.Set("appKey", serviceKye)
  1125. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1126. request.Header.Set("Content-Signature", signatureStr)
  1127. client := http.Client{}
  1128. resp, err := client.Do(request)
  1129. if err != nil {
  1130. fmt.Println(err.Error())
  1131. }
  1132. respBytes, err := ioutil.ReadAll(resp.Body)
  1133. if err != nil {
  1134. fmt.Println(err.Error())
  1135. }
  1136. str := string(respBytes)
  1137. var respJSON map[string]interface{}
  1138. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  1139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1140. }
  1141. var UserId string
  1142. UserId = respJSON["data"].(map[string]interface{})["userId"].(string)
  1143. fmt.Println("str", UserId)
  1144. return str, UserId
  1145. }
  1146. func CreateSdkSendInformation() (string, string) {
  1147. var url string
  1148. url = "http://localhost:8890/sdk/msg/sendMsg"
  1149. maprequest := make(map[string]interface{})
  1150. maprequest["phone"] = "13318464642"
  1151. maprequest["signType"] = "pdf"
  1152. byterequest, _ := json.Marshal(maprequest)
  1153. appId := beego.AppConfig.String("sign_appid")
  1154. serviceKye := beego.AppConfig.String("serviceKye")
  1155. reader := bytes.NewReader(byterequest)
  1156. serviceCode := beego.AppConfig.String("serviceCode")
  1157. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  1158. request, err := http.NewRequest("POST", url, reader)
  1159. if err != nil {
  1160. fmt.Println(err.Error())
  1161. }
  1162. fmt.Println("请求参数", request)
  1163. fmt.Println("Content-Signature", signatureStr)
  1164. request.Header.Set("appId", appId)
  1165. request.Header.Set("appKey", serviceKye)
  1166. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1167. request.Header.Set("Content-Signature", signatureStr)
  1168. client := http.Client{}
  1169. resp, err := client.Do(request)
  1170. if err != nil {
  1171. fmt.Println(err.Error())
  1172. }
  1173. respBytes, err := ioutil.ReadAll(resp.Body)
  1174. if err != nil {
  1175. fmt.Println(err.Error())
  1176. }
  1177. str := string(respBytes)
  1178. var respJSON map[string]interface{}
  1179. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  1180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1181. }
  1182. var orderId string
  1183. //orderId = respJSON["data"].(map[string]interface{})["orderId"].(string)
  1184. //fmt.Println("str", orderId)
  1185. return str, orderId
  1186. }
  1187. func SavePdfInformation(name string) (string, string) {
  1188. var url string
  1189. url = "http://localhost:8890/sdk/pdf/sign"
  1190. maprequest := make(map[string]interface{})
  1191. Receiver := make(map[string]interface{})
  1192. //业务单号
  1193. maprequest["orderId"] = "13318464642"
  1194. maprequest["signTitle"] = "举报合同"
  1195. //file := "C:/Users/28169/Desktop/9.pdf"
  1196. //file := "/swspan/gopath/src/XT_New/static/16.pdf"
  1197. //fileBytes, _ := ioutil.ReadFile(file) // 读取file
  1198. //
  1199. //contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  1200. //fmt.Println("contractBase64", contractBase64)
  1201. //文件获取方式
  1202. maprequest["fileType"] = 3
  1203. //maprequest["pdfBase64"] = name
  1204. //合同内容
  1205. maprequest["fileContent"] = "https://kuyi.shengws.com/20.pdf"
  1206. //签署用户人ID
  1207. maprequest["userId"] = "JMO9U8JH4TN8E3QOI0GUVUF2"
  1208. //业务单号
  1209. maprequest["receiver"] = Receiver
  1210. //签署人账号
  1211. Receiver["account"] = "13318464642"
  1212. //签署个人类型 1.个人 2.企业
  1213. Receiver["signerType"] = 1
  1214. //签署人姓名
  1215. Receiver["realName "] = "马文强"
  1216. // 证件类型
  1217. Receiver["cardType"] = 0
  1218. //证件编码
  1219. Receiver["cardNumber"] = "430526199408156511"
  1220. stepStamper := make(map[string]interface{})
  1221. keywordSignControls := make([]map[string]interface{}, 0)
  1222. //预冲者样式
  1223. inputArrOne := make(map[string]interface{})
  1224. inputArrOne["sealName"] = "1"
  1225. inputArrOne["keyword"] = "穿刺者"
  1226. inputArrOne["pages"] = "0"
  1227. inputArrOne["offsetX"] = "50"
  1228. inputArrOne["offsetY"] = "0"
  1229. keywordSignControls = append(keywordSignControls, inputArrOne)
  1230. stepStamper["keywordSignControls"] = keywordSignControls
  1231. //医生签名
  1232. //inputArr := make(map[string]interface{})
  1233. //inputArr["sealName"] = "2"
  1234. //inputArr["keyword"] = "医生签名"
  1235. //inputArr["pages"] = "1"
  1236. //inputArr["offsetX"] = "100"
  1237. //inputArr["offsetY"] = "0"
  1238. //
  1239. //keywordSignControls = append(keywordSignControls, inputArr)
  1240. //
  1241. //上机者
  1242. //inputArrSix := make(map[string]interface{})
  1243. //inputArrSix["sealName"] = "3"
  1244. //inputArrSix["keyword"] = "护士签名"
  1245. //inputArrSix["pages"] = "1"
  1246. //inputArrSix["offsetX"] = "100"
  1247. //inputArrSix["offsetY"] = "0"
  1248. //
  1249. //keywordSignControls = append(keywordSignControls, inputArrSix)
  1250. ////医生签名
  1251. //inputArrSeven := make(map[string]interface{})
  1252. //inputArrSeven["sealName"] = "4"
  1253. //inputArrSeven["keyword"] = "核对护士签名"
  1254. //inputArrSeven["pages"] = "1"
  1255. //inputArrSeven["offsetX"] = "100"
  1256. //inputArrSeven["offsetY"] = "0"
  1257. //
  1258. //keywordSignControls = append(keywordSignControls, inputArrSeven)
  1259. //stepStamper["keywordSignControls"] = keywordSignControls
  1260. //
  1261. //crossSignControls := make([]map[string]interface{}, 0)
  1262. //
  1263. //inputArrTwo := make(map[string]interface{})
  1264. //inputArrTwo["sealName"] = "1"
  1265. //inputArrTwo["positionX"] = "0"
  1266. //inputArrTwo["positionY"] = "0"
  1267. //inputArrTwo["pages"] = "0"
  1268. //crossSignControls = append(crossSignControls, inputArrTwo)
  1269. //
  1270. //stepStamper["crossSignControls"] = crossSignControls
  1271. //
  1272. //xySignControls := make([]map[string]interface{}, 0)
  1273. //inputArrThree := make(map[string]interface{})
  1274. //inputArrThree["sealName"] = "1"
  1275. //inputArrThree["positionX"] = "200"
  1276. //inputArrThree["positionY"] = "100"
  1277. //inputArrThree["pages"] = "0"
  1278. //
  1279. //xySignControls = append(xySignControls, inputArrThree)
  1280. ////
  1281. //stepStamper["xySignControls"] = xySignControls
  1282. //
  1283. maprequest["stepStamper"] = stepStamper
  1284. seals := make([]map[string]interface{}, 0)
  1285. //预冲者
  1286. sealImagesList := make(map[string]interface{})
  1287. fileOne := "/swspan/gopath/src/XT_New/static/huangzihui.jpg"
  1288. fileBytesOne, _ := ioutil.ReadFile(fileOne) // 读取file
  1289. contractBase64One := base64.StdEncoding.EncodeToString(fileBytesOne) // 加密成base64字符串
  1290. sealImagesList["sealBase64"] = contractBase64One
  1291. //控制签名的大小
  1292. sealImagesList["width"] = "50"
  1293. sealImagesList["height"] = "50"
  1294. sealImagesList["verticalAlign"] = "middle"
  1295. sealTextsList := make(map[string]interface{})
  1296. sealTextsList["text"] = "2023年8月8日"
  1297. sealTextsList["fontSize"] = "12"
  1298. sealTextsList["fontColor"] = "#333333"
  1299. sealTextsList["isTextArea"] = true
  1300. sealTextsList["textAlign"] = 0
  1301. sealTextsList["width"] = 150
  1302. sealTextsList["height"] = 20
  1303. sealsObj := make(map[string]interface{})
  1304. sealsObj["sealWidth"] = "150"
  1305. sealsObj["sealHeight"] = "150"
  1306. sealsObj["sealName"] = "1"
  1307. sealsObj["sealImage"] = sealImagesList
  1308. sealsObj["sealText"] = sealTextsList
  1309. seals = append(seals, sealsObj)
  1310. //穿刺者
  1311. //sealImagesListOne := make(map[string]interface{})
  1312. //
  1313. //fileTwo := "/swspan/gopath/src/XT_New/static/huangjunji.jpg"
  1314. //
  1315. //fileBytesTwo, _ := ioutil.ReadFile(fileTwo) // 读取file
  1316. //
  1317. //contractBase64Two := base64.StdEncoding.EncodeToString(fileBytesTwo) // 加密成base64字符串
  1318. //sealImagesListOne["sealBase64"] = contractBase64Two
  1319. ////控制签名的大小
  1320. //sealImagesListOne["width"] = "50"
  1321. //sealImagesListOne["height"] = "50"
  1322. //sealImagesListOne["verticalAlign"] = "middle"
  1323. //
  1324. //sealTextsListOne := make(map[string]interface{})
  1325. //sealTextsListOne["text"] = "2023年8月8日"
  1326. //sealTextsListOne["fontSize"] = "100"
  1327. //sealTextsListOne["fontColor"] = "100"
  1328. //sealTextsListOne["isTextArea"] = true
  1329. //sealTextsListOne["textAlign"] = 0
  1330. //sealTextsListOne["width"] = 150
  1331. //sealTextsListOne["height"] = 20
  1332. //
  1333. //sealsObjOne := make(map[string]interface{})
  1334. //
  1335. //sealsObjOne["sealWidth"] = "150"
  1336. //sealsObjOne["sealHeight"] = "150"
  1337. //sealsObjOne["sealName"] = "2"
  1338. //sealsObjOne["sealImage"] = sealImagesListOne
  1339. //sealsObjOne["sealText"] = sealTextsListOne
  1340. //seals = append(seals, sealsObjOne)
  1341. //间隔签名
  1342. //上机者
  1343. //sealImagesListTwo := make(map[string]interface{})
  1344. //fileThree := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  1345. //fileBytesThree, _ := ioutil.ReadFile(fileThree) // 读取file
  1346. //contractBase64Three := base64.StdEncoding.EncodeToString(fileBytesThree) // 加密成base64字符串
  1347. //sealImagesListTwo["sealBase64"] = contractBase64Three
  1348. ////控制签名的大小
  1349. //sealImagesListTwo["width"] = "50"
  1350. //sealImagesListTwo["height"] = "50"
  1351. //sealImagesListTwo["verticalAlign"] = "middle"
  1352. //
  1353. //sealTextsListTwo := make(map[string]interface{})
  1354. //sealTextsListTwo["text"] = "2023年8月8日"
  1355. //sealTextsListTwo["fontSize"] = "100"
  1356. //sealTextsListTwo["fontColor"] = "100"
  1357. //sealTextsListTwo["isTextArea"] = true
  1358. //sealTextsListTwo["textAlign"] = 0
  1359. //sealTextsListTwo["width"] = 150
  1360. //sealTextsListTwo["height"] = 20
  1361. //
  1362. //sealsObjTwo := make(map[string]interface{})
  1363. //
  1364. //sealsObjTwo["sealWidth"] = "150"
  1365. //sealsObjTwo["sealHeight"] = "150"
  1366. //sealsObjTwo["sealName"] = "3"
  1367. //sealsObjTwo["sealImage"] = sealImagesListTwo
  1368. //sealsObjTwo["sealText"] = sealTextsListTwo
  1369. //seals = append(seals, sealsObjTwo)
  1370. //医生签名
  1371. //sealImagesListThree := make(map[string]interface{})
  1372. //fileFour := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  1373. //fileBytesFour, _ := ioutil.ReadFile(fileFour) // 读取file
  1374. //contractBase64Tour := base64.StdEncoding.EncodeToString(fileBytesFour) // 加密成base64字符串
  1375. //sealImagesListThree["sealBase64"] = contractBase64Tour
  1376. ////控制签名的大小
  1377. //sealImagesListThree["width"] = "50"
  1378. //sealImagesListThree["height"] = "50"
  1379. //sealImagesListThree["verticalAlign"] = "middle"
  1380. //
  1381. //sealTextsListThree := make(map[string]interface{})
  1382. //sealTextsListThree["text"] = "2023年8月8日"
  1383. //sealTextsListThree["fontSize"] = "100"
  1384. //sealTextsListThree["fontColor"] = "100"
  1385. //sealTextsListThree["isTextArea"] = true
  1386. //sealTextsListThree["textAlign"] = 0
  1387. //sealTextsListThree["width"] = 150
  1388. //sealTextsListThree["height"] = 20
  1389. //
  1390. //sealsObjThree := make(map[string]interface{})
  1391. //
  1392. //sealsObjThree["sealWidth"] = "150"
  1393. //sealsObjThree["sealHeight"] = "150"
  1394. //sealsObjThree["sealName"] = "4"
  1395. //sealsObjThree["sealImage"] = sealImagesListThree
  1396. //sealsObjThree["sealText"] = sealTextsListThree
  1397. //seals = append(seals, sealsObjThree)
  1398. maprequest["seals"] = seals
  1399. maprequest["isUserWishes"] = true
  1400. maprequest["phone"] = "13318464642"
  1401. maprequest["verificationCode"] = "18888888888"
  1402. byterequest, _ := json.Marshal(maprequest)
  1403. appId := beego.AppConfig.String("sign_appid")
  1404. serviceKye := beego.AppConfig.String("serviceKye")
  1405. reader := bytes.NewReader(byterequest)
  1406. serviceCode := beego.AppConfig.String("serviceCode")
  1407. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  1408. request, err := http.NewRequest("POST", url, reader)
  1409. if err != nil {
  1410. fmt.Println(err.Error())
  1411. }
  1412. fmt.Println("请求参数", request)
  1413. fmt.Println("Content-Signature", signatureStr)
  1414. request.Header.Set("appId", appId)
  1415. request.Header.Set("appKey", serviceKye)
  1416. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1417. request.Header.Set("Content-Signature", signatureStr)
  1418. client := http.Client{}
  1419. resp, err := client.Do(request)
  1420. if err != nil {
  1421. fmt.Println(err.Error())
  1422. }
  1423. respBytes, err := ioutil.ReadAll(resp.Body)
  1424. if err != nil {
  1425. fmt.Println(err.Error())
  1426. }
  1427. str := string(respBytes)
  1428. fmt.Println("报错提示", str)
  1429. var respJSON map[string]interface{}
  1430. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  1431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1432. }
  1433. var pdfBase64 string
  1434. pdfBase64 = respJSON["data"].(map[string]interface{})["pdfBase64"].(string)
  1435. return str, pdfBase64
  1436. }
  1437. func ToCheckInformation(contractBase64 string) string {
  1438. var url string
  1439. url = "http://localhost:8890/sdk/pdf/verify"
  1440. maprequest := make(map[string]interface{})
  1441. //file := "/swspan/gopath/src/XT_New/static/a.pdf"
  1442. //
  1443. //fileBytes, _ := ioutil.ReadFile(file) // 读取file
  1444. //
  1445. //contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  1446. maprequest["fileType"] = 1
  1447. maprequest["fileContent"] = contractBase64
  1448. byterequest, _ := json.Marshal(maprequest)
  1449. appId := beego.AppConfig.String("sign_appid")
  1450. serviceKye := beego.AppConfig.String("serviceKye")
  1451. reader := bytes.NewReader(byterequest)
  1452. serviceCode := beego.AppConfig.String("serviceCode")
  1453. signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
  1454. request, err := http.NewRequest("POST", url, reader)
  1455. if err != nil {
  1456. fmt.Println(err.Error())
  1457. }
  1458. fmt.Println("请求参数", request)
  1459. fmt.Println("Content-Signature", signatureStr)
  1460. request.Header.Set("appId", appId)
  1461. request.Header.Set("appKey", serviceKye)
  1462. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1463. request.Header.Set("Content-Signature", signatureStr)
  1464. client := http.Client{}
  1465. resp, err := client.Do(request)
  1466. if err != nil {
  1467. fmt.Println(err.Error())
  1468. }
  1469. respBytes, err := ioutil.ReadAll(resp.Body)
  1470. if err != nil {
  1471. fmt.Println(err.Error())
  1472. }
  1473. str := string(respBytes)
  1474. var respJSON map[string]interface{}
  1475. if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  1476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1477. }
  1478. return str
  1479. }
  1480. func GetLastAdminUserName(doctor, orgid int64) string {
  1481. var tmp models.VmUserAdminRole
  1482. XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Last(&tmp)
  1483. return tmp.UserName
  1484. }
  1485. func GetLastAdminUserIdCardNumber(doctor, orgid int64) string {
  1486. var tmp models.VmUserAdminRole
  1487. XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Last(&tmp)
  1488. return tmp.JobNumber
  1489. }
  1490. func CreateEnterpriseUserName(enterprise models.XtDevicePersonEnterprise) error {
  1491. err := XTWriteDB().Create(&enterprise).Error
  1492. return err
  1493. }
  1494. func UpdatePersionEnterPrise(id int64, userId string) error {
  1495. err := XTWriteDB().Model(&models.XtDevicePersonEnterprise{}).Where("id=? and status =1", id).Updates(map[string]interface{}{"user_id": userId}).Error
  1496. return err
  1497. }
  1498. func SingleImg2Pdf(pathStr string) {
  1499. //pdf := gofpdf.New("P", "mm", "A4", "")
  1500. //pdf.AddPage()
  1501. //pdf.SetFont("Arial", "", 11)
  1502. //pdf.Image(pathStr, 10, 10, pdf.GetPageSizeStr("A4").Wd-20, 0, false, "", 0, "")
  1503. //// pdf.Text(50, 20, "logo.png")
  1504. //fileNameAll := path.Base(pathStr)
  1505. //fileSuffix := path.Ext(pathStr)
  1506. //fileStr := fmt.Sprintf("./pdfs/%s.pdf", fileNameAll[0:len(fileNameAll)-len(fileSuffix)])
  1507. //err := pdf.OutputFileAndClose(fileStr)
  1508. //fmt.Println(err)
  1509. }
  1510. func GetAllPatientNew(org_id int64) (new []*models.XtPatients, err error) {
  1511. err = XTReadDB().Where("user_org_id = ? and status=1", org_id).Find(&new).Error
  1512. return new, err
  1513. }
  1514. func UpdatePatientNew(id int64, firstleterr string) error {
  1515. err := XTWriteDB().Model(models.XtPatients{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
  1516. return err
  1517. }
  1518. func GeteAllBaseList(user_org_id int64) (list []*models.BaseDrugLib, err error) {
  1519. err = XTWriteDB().Model(&list).Where("org_id = ? and status =1", user_org_id).Find(&list).Error
  1520. return list, err
  1521. }
  1522. func UpdateBaseList(id int64, firstleterr string) error {
  1523. err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
  1524. return err
  1525. }
  1526. func GetAutoDrugList(user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
  1527. err = XTReadDB().Where("user_org_id =? and status =1 and advice_date = 1700582400 and drug_id =239", user_org_id).Find(&advice).Error
  1528. return advice, err
  1529. }
  1530. func GetDrugAutoWarehouseOutList(patient_id int64, user_org_id int64, drug_id int64, advice_date int64) (models.DrugWarehouseOutInfo, error) {
  1531. info := models.DrugWarehouseOutInfo{}
  1532. 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
  1533. return info, err2
  1534. }
  1535. func UpdateSchPatient(patient_id int64, schedule_date int64, user_org_id int64, DialysisMachineName string) error {
  1536. 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
  1537. return err
  1538. }
  1539. func GetNewAllpatient(org_id int64) (list []*models.XtPatientsNew, err error) {
  1540. err = XTReadDB().Where("status =1 and user_org_id =?", org_id).Find(&list).Error
  1541. return list, err
  1542. }
  1543. func UpdateAllPatient(id int64, diagose string, orgid int64) error {
  1544. err := XTWriteDB().Model(models.XtPatients{}).Where("id = ? and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"diagnose": diagose}).Error
  1545. return err
  1546. }
  1547. func GetAllDialysisOrderTwo(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
  1548. err = XTReadDB().Where("user_org_id = ? and status =1 and dialysis_date=1730736000", user_org_id).Find(&list).Error
  1549. return list, err
  1550. }
  1551. func GetAllDialysisPrescription(patient_id int64) (list []*models.XtDialysisPrescription, err error) {
  1552. err = XTReadDB().Where("patient_id = ? and status=1", patient_id).Find(&list).Error
  1553. return list, err
  1554. }
  1555. func GetPatientLapseList() (list []*models.XtPatients, err error) {
  1556. err = XTReadDB().Where("(lapseto =2 or lapseto =3) and status=1 and user_org_id !=10503 and user_org_id !=10447").Find(&list).Error
  1557. return list, err
  1558. }
  1559. func GetHisDoctorAdviceNoCheck(user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
  1560. err = XTReadDB().Where("user_org_id = ? and status=1 and checker = 0", user_org_id).Find(&advice).Error
  1561. return advice, err
  1562. }
  1563. func UpdateHisAdvice(patient_id int64, advice_date int64, user_org_id int64, creater int64, check_date int64) (models.HisDoctorAdviceInfo, error) {
  1564. adviceInfo := models.HisDoctorAdviceInfo{}
  1565. err := XTWriteDB().Model(&adviceInfo).Where("patient_id = ? and advice_date = ? and user_org_id = ? and status=1", patient_id, advice_date, user_org_id).Updates(map[string]interface{}{"checker": creater, "check_state": 1, "check_time": check_date}).Error
  1566. return adviceInfo, err
  1567. }
  1568. func GetPatientScheduleListByItem(patient_id int64) (list []*models.XtSchedule, err error) {
  1569. err = XTReadDB().Where("patient_id = ? and status=1", patient_id).Find(&list).Error
  1570. return list, err
  1571. }
  1572. func UpdateSchedulePrescrition(patient_id int64, record_date int64, user_org_id int64, mode_id int64) (models.XtSchedule, error) {
  1573. schedule := models.XtSchedule{}
  1574. err := XTWriteDB().Model(&schedule).Where("patient_id = ? and schedule_date = ? and status=1 and user_org_id =?", patient_id, record_date, user_org_id).Updates(map[string]interface{}{"mode_id": mode_id}).Error
  1575. return schedule, err
  1576. }
  1577. func GetAllDialysisOrder(patient_id int64, start_time int64, end_time int64) (list []*models.XtDialysisOrder, err error) {
  1578. err = XTReadDB().Where("patient_id = ? and status =1 and dialysis_date>=1199116800 and dialysis_date<=?", patient_id, end_time).Find(&list).Error
  1579. return list, err
  1580. }
  1581. func GetLastScheduleByUserOrg(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) (models.Schedule, error) {
  1582. schedule := models.Schedule{}
  1583. err := XTReadDB().Where("patient_id = ? and schedule_date = ?", patient_id, schedule_date).First(&schedule).Error
  1584. return schedule, err
  1585. }
  1586. func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64, id int64, mode_id int64) error {
  1587. err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ?", id).Updates(map[string]interface{}{"bed_id": bed_id, "partition_id": zone_id, "schedule_type": shcedule_type, "status": 1, "mode_id": mode_id}).Error
  1588. return err
  1589. }
  1590. func GetScheduleListByOrder(user_org_id int64) (list []*models.XtSchedule, err error) {
  1591. err = XTReadDB().Where("user_org_id = ? and schedule_date >=? and status =1 and schedule_date<=?", 10579, 1703260800, 1703347200).Find(&list).Error
  1592. return list, err
  1593. }
  1594. func GetDialysisSoluton(patient_id int64, mode_id int64) (models.DialysisSolution, error) {
  1595. solution := models.DialysisSolution{}
  1596. err := XTReadDB().Where("patient_id =? and mode_id =? and status =1 and solution_status = 1", patient_id, mode_id).Find(&solution).Error
  1597. return solution, err
  1598. }
  1599. func UpdateDialysisSchedule(id int64, dialysis_machine_name string) error {
  1600. err := XTWriteDB().Model(models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"dialysis_machine_name": dialysis_machine_name}).Error
  1601. return err
  1602. }
  1603. func GetPrescriptionListOne(user_org_id int64) (prescription []*models.DialysisPrescription, err error) {
  1604. err = XTReadDB().Model(&prescription).Where("user_org_id = ? and status= 1 and record_date =? and status=1", 10579, 1701360000).Find(&prescription).Error
  1605. return prescription, err
  1606. }
  1607. func GetPatientScheduleById(patient_id int64, schedule_date int64) (models.XtSchedule, error) {
  1608. schedule := models.XtSchedule{}
  1609. err := XTReadDB().Where("patient_id= ? and schedule_date = ? and status =1 and user_org_id =10579", patient_id, schedule_date).First(&schedule).Error
  1610. return schedule, err
  1611. }
  1612. func UpdateDialysisScheduleOne(id int64, mode_id int64, dialysis_machine_name string) error {
  1613. 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
  1614. return err
  1615. }
  1616. func GetDialysisOrderTotalCount() (order []*models.XtDialysisOrderLost, err error) {
  1617. err = XTReadDB().Select("patient_id,Count(id) as count").Where("user_org_id = ? and status =1", 10265).Group("patient_id").Find(&order).Error
  1618. return order, err
  1619. }
  1620. func ModifyPatient(patient_id int64, count int64) (models.XtPatients, error) {
  1621. patients := models.XtPatients{}
  1622. err := XTReadDB().Model(&models.XtPatients{}).Where("id = ? and status =1", patient_id).Updates(map[string]interface{}{"total_dialysis": count}).Error
  1623. return patients, err
  1624. }
  1625. func UpdateDrugWarehouseInfoByDrug(drug_id int64, reatial_price float64, user_org_id int64) (models.DrugWarehouseInfo, error) {
  1626. drugWarehouseInfo := models.DrugWarehouseInfo{}
  1627. err := XTWriteDB().Model(&drugWarehouseInfo).Where("drug_id = ? and org_id =?", drug_id, user_org_id).Updates(map[string]interface{}{"retail_price": reatial_price}).Error
  1628. return drugWarehouseInfo, err
  1629. }
  1630. func UpdasteGoodWarehouseInfoByGood(good_id int64, packing_price float64, org_id int64) (models.WarehousingInfo, error) {
  1631. info := models.WarehousingInfo{}
  1632. 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
  1633. return info, err
  1634. }
  1635. func UpdateHisDoctorAdviceOne(drug_id int64, retail_price float64, user_org_id int64) (models.HisDoctorAdvice, error) {
  1636. advice := models.HisDoctorAdvice{}
  1637. 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
  1638. return advice, err
  1639. }
  1640. func GetWarehouseOutOrderList() (out []*models.WarehouseOut, err error) {
  1641. err = XTReadDB().Where("status=1").Find(&out).Error
  1642. return out, err
  1643. }
  1644. func UpdateWarehouseOutOrderInfo(id int64, warehouse_out_order_number string) error {
  1645. err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id = ? and status=1", id).Updates(map[string]interface{}{"warehouse_out_order_number": warehouse_out_order_number}).Error
  1646. return err
  1647. }
  1648. func GetDialysisOrderListOne(patient_id int64) (order []*models.DialysisOrder, err error) {
  1649. err = XTReadDB().Where("patient_id = ? and status=1 and user_org_id =10495", patient_id).Find(&order).Error
  1650. return order, err
  1651. }
  1652. func UpdateSchedulePatient(patient_id int64, schedule_date int64, zone_id int64, bed_id int64) error {
  1653. err := XTWriteDB().Model(&models.XtSchedule{}).Where("patient_id = ? and schedule_date =? and partition_id = ? and bed_id =?", patient_id, schedule_date, zone_id, bed_id).Updates(map[string]interface{}{"status": 1}).Error
  1654. return err
  1655. }
  1656. func GetDialysisOrderByUserOrgId() (order []*models.XtDialysisOrder, err error) {
  1657. err = XTReadDB().Where("status=1").Group("user_org_id").Find(&order).Error
  1658. return order, err
  1659. }
  1660. func GetFieldConfigGroupList(module int64) (filedConfig []*models.FiledConfig, err error) {
  1661. err = XTReadDB().Where("module = ?", module).Group("filed_name").Order("filed_name_cn asc").Find(&filedConfig).Error
  1662. return filedConfig, err
  1663. }
  1664. func GetFieldConfigByOrgId(org_id int64, field_name_cn string, module int64) (fiedConfig models.FiledConfig, err error) {
  1665. err = XTReadDB().Where("org_id = ? and filed_name_cn = ? and module =?", org_id, field_name_cn, module).Find(&fiedConfig).Error
  1666. return fiedConfig, err
  1667. }
  1668. func CretedConfig(config models.FiledConfig) error {
  1669. err := XTWriteDB().Create(&config).Error
  1670. return err
  1671. }
  1672. func GetFieldConfigList(user_org_id int64) (filedConfig []*models.FiledConfig, err error) {
  1673. err = XTReadDB().Where("org_id =?", user_org_id).Find(&filedConfig).Error
  1674. return filedConfig, err
  1675. }
  1676. func GetAllCheckQuery() (query []*models.XtDrugQuery, err error) {
  1677. err = XTReadDB().Where("status=1").Find(&query).Error
  1678. return query, err
  1679. }
  1680. func GetAllDoctorAdviceQueryList(user_org_id int64, advice_date int64) (advice []*models.HisDoctorAdvice, err error) {
  1681. err = XTReadDB().Where("user_org_id = ? and advice_date = ? and status=1", user_org_id, advice_date).Find(&advice).Error
  1682. return advice, err
  1683. }
  1684. func GetDrugListById(drug_id int64, advice_date int64, patient_id int64) (advice []*models.HisDoctorAdvice, err error) {
  1685. err = XTReadDB().Where("drug_id = ? and status =1 and advice_date = ? and patient_id =?", drug_id, advice_date, patient_id).Find(&advice).Error
  1686. return advice, err
  1687. }
  1688. func GetDrugWarehouseOutQueryListById(drug_id int64, sys_record_date int64, patient_id int64) (outinfo []*models.DrugWarehouseOutInfo, err error) {
  1689. err = XTReadDB().Where("drug_id = ? and sys_record_time = ? and status =1 and patient_id = ?", drug_id, sys_record_date, patient_id).Find(&outinfo).Error
  1690. return outinfo, err
  1691. }
  1692. func CreateCheckQuery(query models.XtDrugCheckQuery) error {
  1693. err := XTWriteDB().Create(&query).Error
  1694. return err
  1695. }
  1696. func GetAllPrescriptionProjectList(user_org_id int64, record_date int64) (project []*models.HisPrescriptionProject, err error) {
  1697. err = XTReadDB().Where("user_org_id = ? and record_date = ? and status =1 and type =3", user_org_id, record_date).Find(&project).Error
  1698. return project, err
  1699. }
  1700. func GetProjectListByPatient(patient_id int64, project_id int64, record_date int64) (project []*models.HisPrescriptionProject, err error) {
  1701. err = XTReadDB().Where("patient_id =? and project_id = ? and record_date =?", patient_id, project_id, record_date).Find(&project).Error
  1702. return project, err
  1703. }
  1704. func GetWarehosueOutQueryList(patient_id int64, project_id int64, record_date int64) (out []*models.WarehouseOutInfo, err error) {
  1705. err = XTReadDB().Where("patient_id = ? and good_id = ? and sys_record_time = ? and status=1", patient_id, project_id, record_date).Find(&out).Error
  1706. return out, err
  1707. }
  1708. func CreteStockCheckQuery(query models.XtStockCheckQuery) error {
  1709. err := XTWriteDB().Create(&query).Error
  1710. return err
  1711. }