sign_service.go 63KB

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