sign_service.go 68KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356
  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 UpdateSchedulePrescrition(patient_id int64, record_date int64, user_org_id int64, mode_id int64) (models.XtSchedule, error) {
  1556. schedule := models.XtSchedule{}
  1557. 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
  1558. return schedule, err
  1559. }
  1560. func GetAllDialysisOrder(patient_id int64, start_time int64, end_time int64) (list []*models.XtDialysisOrder, err error) {
  1561. err = XTReadDB().Where("patient_id = ? and status =1 and dialysis_date>=1541001600 and dialysis_date<=?", patient_id, end_time).Find(&list).Error
  1562. return list, err
  1563. }
  1564. func GetLastScheduleByUserOrg(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) (models.Schedule, error) {
  1565. schedule := models.Schedule{}
  1566. err := XTReadDB().Where("patient_id = ? and schedule_date = ?", patient_id, schedule_date).First(&schedule).Error
  1567. return schedule, err
  1568. }
  1569. 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 {
  1570. 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
  1571. return err
  1572. }
  1573. func GetScheduleListByOrder(user_org_id int64) (list []*models.XtSchedule, err error) {
  1574. err = XTReadDB().Where("user_org_id = ? and schedule_date >=? and status =1 and schedule_date<=?", 10579, 1703260800, 1703347200).Find(&list).Error
  1575. return list, err
  1576. }
  1577. func GetDialysisSoluton(patient_id int64, mode_id int64) (models.DialysisSolution, error) {
  1578. solution := models.DialysisSolution{}
  1579. err := XTReadDB().Where("patient_id =? and mode_id =? and status =1 and solution_status = 1", patient_id, mode_id).Find(&solution).Error
  1580. return solution, err
  1581. }
  1582. func UpdateDialysisSchedule(id int64, dialysis_machine_name string) error {
  1583. err := XTWriteDB().Model(models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"dialysis_machine_name": dialysis_machine_name}).Error
  1584. return err
  1585. }
  1586. func GetPrescriptionListOne(user_org_id int64) (prescription []*models.DialysisPrescription, err error) {
  1587. err = XTReadDB().Model(&prescription).Where("user_org_id = ? and status= 1 and record_date =? and status=1", 10579, 1701360000).Find(&prescription).Error
  1588. return prescription, err
  1589. }
  1590. func GetPatientScheduleById(patient_id int64, schedule_date int64) (models.XtSchedule, error) {
  1591. schedule := models.XtSchedule{}
  1592. err := XTReadDB().Where("patient_id= ? and schedule_date = ? and status =1 and user_org_id =10579", patient_id, schedule_date).First(&schedule).Error
  1593. return schedule, err
  1594. }
  1595. func UpdateDialysisScheduleOne(id int64, mode_id int64, dialysis_machine_name string) error {
  1596. 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
  1597. return err
  1598. }
  1599. func GetDialysisOrderTotalCount() (order []*models.XtDialysisOrderLost, err error) {
  1600. err = XTReadDB().Select("patient_id,Count(id) as count").Where("user_org_id = ? and status =1", 10265).Group("patient_id").Find(&order).Error
  1601. return order, err
  1602. }
  1603. func ModifyPatient(patient_id int64, count int64) (models.XtPatients, error) {
  1604. patients := models.XtPatients{}
  1605. err := XTReadDB().Model(&models.XtPatients{}).Where("id = ? and status =1", patient_id).Updates(map[string]interface{}{"total_dialysis": count}).Error
  1606. return patients, err
  1607. }
  1608. func UpdateDrugWarehouseInfoByDrug(drug_id int64, reatial_price float64, user_org_id int64) (models.DrugWarehouseInfo, error) {
  1609. drugWarehouseInfo := models.DrugWarehouseInfo{}
  1610. err := XTWriteDB().Model(&drugWarehouseInfo).Where("drug_id = ? and org_id =?", drug_id, user_org_id).Updates(map[string]interface{}{"retail_price": reatial_price}).Error
  1611. return drugWarehouseInfo, err
  1612. }
  1613. func UpdasteGoodWarehouseInfoByGood(good_id int64, packing_price float64, org_id int64) (models.WarehousingInfo, error) {
  1614. info := models.WarehousingInfo{}
  1615. 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
  1616. return info, err
  1617. }
  1618. func UpdateHisDoctorAdviceOne(drug_id int64, retail_price float64, user_org_id int64) (models.HisDoctorAdvice, error) {
  1619. advice := models.HisDoctorAdvice{}
  1620. 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
  1621. return advice, err
  1622. }
  1623. func GetWarehouseOutOrderList() (out []*models.WarehouseOut, err error) {
  1624. err = XTReadDB().Where("status=1").Find(&out).Error
  1625. return out, err
  1626. }
  1627. func UpdateWarehouseOutOrderInfo(id int64, warehouse_out_order_number string) error {
  1628. 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
  1629. return err
  1630. }
  1631. func GetDialysisOrderListOne(patient_id int64) (order []*models.DialysisOrder, err error) {
  1632. err = XTReadDB().Where("patient_id = ? and status=1 and user_org_id =10495", patient_id).Find(&order).Error
  1633. return order, err
  1634. }
  1635. func UpdateSchedulePatient(patient_id int64, schedule_date int64, zone_id int64, bed_id int64) error {
  1636. 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
  1637. return err
  1638. }
  1639. func GetDialysisOrderByUserOrgId() (order []*models.XtDialysisOrder, err error) {
  1640. err = XTReadDB().Where("status=1").Group("user_org_id").Find(&order).Error
  1641. return order, err
  1642. }
  1643. func GetFieldConfigGroupList(module int64) (filedConfig []*models.FiledConfig, err error) {
  1644. err = XTReadDB().Where("module = ?", module).Group("filed_name").Order("filed_name_cn asc").Find(&filedConfig).Error
  1645. return filedConfig, err
  1646. }
  1647. func GetFieldConfigByOrgId(org_id int64, field_name_cn string, module int64) (fiedConfig models.FiledConfig, err error) {
  1648. err = XTReadDB().Where("org_id = ? and filed_name_cn = ? and module =?", org_id, field_name_cn, module).Find(&fiedConfig).Error
  1649. return fiedConfig, err
  1650. }
  1651. func CretedConfig(config models.FiledConfig) error {
  1652. err := XTWriteDB().Create(&config).Error
  1653. return err
  1654. }
  1655. func GetFieldConfigList(user_org_id int64) (filedConfig []*models.FiledConfig, err error) {
  1656. err = XTReadDB().Where("org_id =?", user_org_id).Find(&filedConfig).Error
  1657. return filedConfig, err
  1658. }
  1659. func GetAllCheckQuery() (query []*models.XtDrugQuery, err error) {
  1660. err = XTReadDB().Where("status=1").Find(&query).Error
  1661. return query, err
  1662. }
  1663. func GetAllDoctorAdviceQueryList(user_org_id int64, advice_date int64) (advice []*models.HisDoctorAdvice, err error) {
  1664. err = XTReadDB().Where("user_org_id = ? and advice_date = ? and status=1", user_org_id, advice_date).Find(&advice).Error
  1665. return advice, err
  1666. }
  1667. func GetDrugListById(drug_id int64, advice_date int64, patient_id int64) (advice []*models.HisDoctorAdvice, err error) {
  1668. err = XTReadDB().Where("drug_id = ? and status =1 and advice_date = ? and patient_id =?", drug_id, advice_date, patient_id).Find(&advice).Error
  1669. return advice, err
  1670. }
  1671. func GetDrugWarehouseOutQueryListById(drug_id int64, sys_record_date int64, patient_id int64) (outinfo []*models.DrugWarehouseOutInfo, err error) {
  1672. 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
  1673. return outinfo, err
  1674. }
  1675. func CreateCheckQuery(query models.XtDrugCheckQuery) error {
  1676. err := XTWriteDB().Create(&query).Error
  1677. return err
  1678. }
  1679. func GetAllPrescriptionProjectList(user_org_id int64, record_date int64) (project []*models.HisPrescriptionProject, err error) {
  1680. err = XTReadDB().Where("user_org_id = ? and record_date = ? and status =1 and type =3", user_org_id, record_date).Find(&project).Error
  1681. return project, err
  1682. }
  1683. func GetProjectListByPatient(patient_id int64, project_id int64, record_date int64) (project []*models.HisPrescriptionProject, err error) {
  1684. err = XTReadDB().Where("patient_id =? and project_id = ? and record_date =?", patient_id, project_id, record_date).Find(&project).Error
  1685. return project, err
  1686. }
  1687. func GetWarehosueOutQueryList(patient_id int64, project_id int64, record_date int64) (out []*models.WarehouseOutInfo, err error) {
  1688. err = XTReadDB().Where("patient_id = ? and good_id = ? and sys_record_time = ? and status=1", patient_id, project_id, record_date).Find(&out).Error
  1689. return out, err
  1690. }
  1691. func CreteStockCheckQuery(query models.XtStockCheckQuery) error {
  1692. err := XTWriteDB().Create(&query).Error
  1693. return err
  1694. }