xcx_api_controller.go 55KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. package xcx_mobile_api_controller_go
  2. import (
  3. "Xcx_New/controllers/mobile_api_controllers"
  4. "Xcx_New/enums"
  5. "Xcx_New/models"
  6. "Xcx_New/service"
  7. "Xcx_New/utils"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "github.com/jinzhu/gorm"
  11. "github.com/shopspring/decimal"
  12. "strconv"
  13. "time"
  14. )
  15. func XcxApiControllersRegisterRouters() {
  16. ////传送codeinit
  17. beego.Router("/xcx/m/api/code", &XcxApiController{}, "Get:GetCodeInit")
  18. //获取验证码
  19. beego.Router("/xcx/api/mobile/code", &XcxApiController{}, "Post:GetCodeInfo")
  20. //用户绑定
  21. beego.Router("/xcx/api/mobile/register", &XcxApiController{}, "Get:GetUserNameRegister")
  22. //手机号登录
  23. beego.Router("/xcx/api/mobile/login", &XcxApiController{}, "Get:GetLoginInfor")
  24. //openid登录
  25. beego.Router("/xcx/api/openid/login", &XcxApiController{}, "Get:GetLoginInfoByOpenid")
  26. //获取二维码信息
  27. beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
  28. //获取登录后的信息
  29. beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
  30. //获取排班数据
  31. beego.Router("/xcx/api/mobile/schedulebyweek", &XcxApiController{}, "Post:GetSchedulesByWeek")
  32. //获取排班数据
  33. beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
  34. //获取透析记录
  35. beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
  36. //获取体重纪录
  37. beego.Router("/xcx/api/mobile/signweight", &XcxApiController{}, "Get:GetSignsByWeight")
  38. //获取血压纪录
  39. beego.Router("/xcx/api/mobile/signblood", &XcxApiController{}, "Get:GetSignsByBlood")
  40. //获取患者的电子病历
  41. beego.Router("/xcx/api/mobile/getpatientinfo", &XcxApiController{}, "Get:GetPatientInfo")
  42. //获取机构名称
  43. beego.Router("/xcx/api/mobile/getorginfo", &XcxApiController{}, "Get:GetOrgInfo")
  44. //获取宣教信息
  45. beego.Router("/xcx/api/mobile/geteducation", &XcxApiController{}, "Get:GetEducationList")
  46. //获取医嘱信息
  47. beego.Router("/xcx/api/mobile/getdoctoradvice", &XcxApiController{}, "Get:GetDoctorAdvice")
  48. //获取机构医生护士的姓名
  49. beego.Router("/xcx/api/mobile/getdoctorname", &XcxApiController{}, "Get:GetDoctorName")
  50. //获取显示配置
  51. beego.Router("/xcx/api/moible/getfieldconfig", &XcxApiController{}, "Get:GetFieldConfig")
  52. //获取数据字典数据
  53. beego.Router("/xcx/api/mobile/getdataconfig", &XcxApiController{}, "Get:GetDataConfig")
  54. //检验检查列表
  55. beego.Router("/xcx/api/mobile/getinspectionlist", &XcxApiController{}, "Get:GetInspectionList")
  56. //检验检查详情
  57. beego.Router("/xcx/api/mobile/getinspectioninfo", &XcxApiController{}, "Get:GetInspectionInfo")
  58. //肾有杯
  59. beego.Router("/xcx/api/mobile/getarticlist", &XcxApiController{}, "Get:GetArticList")
  60. beego.Router("/xcx/api/mobile/getarticlistdetail", &XcxApiController{}, "Get:GetArticListDetail")
  61. beego.Router("/xcx/api/mobile/getstoryscore", &XcxApiController{}, "Get:GetStoryScoreList")
  62. //获取appid
  63. beego.Router("/xcx/api/mobile/getappid", &XcxApiController{}, "Get:GetAppId")
  64. // 获取充值当前余额信息
  65. beego.Router("/xcx/api/mobile/getbalance", &XcxApiController{}, "Get:IdToBalance")
  66. // 获取一段时间内
  67. beego.Router("/xcx/api/mobile/getbalanceinfo", &XcxApiController{}, "Get:DepositFlow")
  68. }
  69. type XcxApiController struct {
  70. mobile_api_controllers.MobileBaseAPIController
  71. }
  72. // 根据id获取押金流水
  73. func (this *XcxApiController) DepositFlow() {
  74. orgid, _ := this.GetInt64("org_id", 0)
  75. patient_id, _ := this.GetInt64("patient_id", 0) //患者id
  76. //获取当前患者的姓名
  77. tmp, _ := service.GetHisUserName(orgid, patient_id)
  78. name := tmp.Name
  79. start_time := this.GetString("start_time", "") //开始时间
  80. end_time := this.GetString("end_time", "") //结束时间
  81. timeLayout := "2006-01-02"
  82. loc, _ := time.LoadLocation("Local")
  83. var stime int64 //开始时间
  84. var etime int64 //结束时间
  85. if start_time == "" || end_time == "" {
  86. //如果为空则查全部的
  87. stime, etime = service.GetMonth()
  88. } else {
  89. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  90. etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  91. stime = stmp.Unix()
  92. etime = etmp.Unix()
  93. }
  94. ////获取该角色当前时间段的余额
  95. //decimal := service.GetMoneyforTime(id, orgid, etime)
  96. //获取列表
  97. deposirhistory, errs := service.GetFlowList(patient_id, orgid, stime, etime)
  98. if errs != nil {
  99. utils.ErrorLog("获取列表失败,原因为:", errs.Error())
  100. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
  101. return
  102. }
  103. var expenditure, recharge decimal.Decimal
  104. for i := 0; i < len(deposirhistory); i++ {
  105. //如果为扣费,或退费 则把订单id变为就诊号
  106. if deposirhistory[i].DepositStatus == 1 || deposirhistory[i].DepositStatus == 3 || deposirhistory[i].DepositStatus == 4 {
  107. recharge = recharge.Add(deposirhistory[i].Deposit)
  108. }
  109. if deposirhistory[i].DepositStatus == 2 {
  110. expenditure = expenditure.Add(deposirhistory[i].Deposit)
  111. }
  112. }
  113. this.ServeSuccessJSON(map[string]interface{}{
  114. "list": deposirhistory,
  115. "name": name,
  116. "start_time": time.Unix(stime, 0).Format("2006-01-02"),
  117. "end_time": time.Unix(etime, 0).Format("2006-01-02"),
  118. "expenditure": expenditure,
  119. "recharge": recharge,
  120. })
  121. return
  122. }
  123. // 根据患者id查询患者的余额
  124. func (this *XcxApiController) IdToBalance() {
  125. orgid, _ := this.GetInt64("org_id", 0)
  126. his_patient_id, _ := this.GetInt64("patient_id", 0)
  127. if orgid <= 0 || his_patient_id <= 0 {
  128. this.ServeSuccessJSON(map[string]interface{}{
  129. "error_code": 1001,
  130. "error_msg": "参数错误",
  131. })
  132. }
  133. balance := service.GetUserMoney(his_patient_id, orgid)
  134. patient, _ := service.GetPatientByIdXcx(his_patient_id)
  135. this.ServeSuccessJSON(map[string]interface{}{
  136. "balance": balance,
  137. "patient": patient,
  138. })
  139. return
  140. }
  141. func (this *XcxApiController) GetCodeInit() {
  142. redisClient := service.RedisClient()
  143. defer redisClient.Close()
  144. req := this.Ctx.Request
  145. addr := utils.GetIP(req)
  146. cur_time := time.Now().Format("2006-01-02")
  147. _, err := redisClient.Get("ip:host_" + cur_time + "_" + addr).Result()
  148. if err != nil {
  149. redisClient.Set("ip:host_"+cur_time+"_"+addr, 0, time.Second*24*60*60)
  150. }
  151. //将客户端的ip加密传给前端,作为短信验证的密钥,来验证短信发送的IP地址
  152. aespass := utils.AESEncrypt(addr)
  153. this.ServeSuccessJSON(map[string]interface{}{
  154. "aespass": aespass,
  155. })
  156. }
  157. func (this *XcxApiController) GetUserNameRegister() {
  158. // name := this.GetString("name")
  159. // relationship := this.GetString("relationship")
  160. id_card_no := this.GetString("id_card_no")
  161. mobile := this.GetString("mobile")
  162. // code := this.GetString("code")
  163. openid := this.GetString("openid")
  164. if len(mobile) == 0 || len(openid) == 0 {
  165. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  166. return
  167. }
  168. // redisClient := service.RedisClient()
  169. // defer redisClient.Close()
  170. // cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
  171. // utils.TraceLog("cache_code:%v code:%v", cache_code, code)
  172. // if cache_code != code {
  173. // this.ServeSuccessJSON(map[string]interface{}{
  174. // "err_code": "1001",
  175. // "err_msg": "验证码错误",
  176. // })
  177. // return
  178. // }
  179. // this.Ctx.SetCookie("mobile", mobile)
  180. // // 注册成功后验证码就要使其失效
  181. // redisClient.Del("code_msg_" + mobile)
  182. patient, errcodes := service.GetPatientByIdcardno(id_card_no)
  183. if errcodes == nil {
  184. role := models.XcxAdminUserRole{
  185. PatientName: patient.Name,
  186. // Relationship: relationship,
  187. IdCardNo: id_card_no,
  188. Mobile: mobile,
  189. // Code: code,
  190. PatientId: patient.ID,
  191. UserOrgId: patient.UserOrgId,
  192. Status: 1,
  193. Ctime: time.Now().Unix(),
  194. Mtime: 0,
  195. Appid: "",
  196. Appsecret: "",
  197. SessionKey: "",
  198. Openid: openid,
  199. }
  200. err := service.CreateXcxAdminUser(role)
  201. if err == nil {
  202. //mobilePatient, _ := service.GetNamePatient(name, id_card_no)
  203. //template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  204. ////处方
  205. //prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  206. //
  207. ////接诊评估
  208. //receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  209. //
  210. ////透前评估
  211. //dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  212. //
  213. ////透析上机
  214. //dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  215. //
  216. ////透析监测
  217. //monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  218. //
  219. ////透后评估
  220. //dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  221. //
  222. //treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  223. //var configList interface{}
  224. //configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  225. this.ServeSuccessJSON(map[string]interface{}{
  226. "role": role,
  227. "is_bind": true,
  228. "err_code": "0",
  229. "err_msg": "",
  230. //"patient": mobilePatient,
  231. //"template_id": template_id,
  232. "user_org_id": patient.UserOrgId,
  233. //"prescripition_config": prescripition_config,
  234. //"receive_treatement_config": receive_treatement_config,
  235. //"dialysis_befor": dialysis_befor,
  236. //"dialysis_order": dialysis_order,
  237. //"monitor_record": monitor_record,
  238. //"dialysis_after": dialysis_after,
  239. //"treate_ment": treate_ment,
  240. //"configList": configList,
  241. //"result": false,
  242. })
  243. } else {
  244. this.ServeSuccessJSON(map[string]interface{}{
  245. "is_bind": false,
  246. "msg": "绑定失败",
  247. "result": false,
  248. })
  249. }
  250. } else {
  251. this.ServeSuccessJSON(map[string]interface{}{
  252. "is_bind": false,
  253. "msg": "绑定失败,没有对应的患者信息",
  254. "result": false,
  255. })
  256. }
  257. }
  258. func (this *XcxApiController) GetUserRegister() {
  259. //用户绑定
  260. name := this.GetString("name")
  261. id_card_no := this.GetString("id_card_no")
  262. fmt.Println("id_card_no", id_card_no)
  263. mobile := this.GetString("mobile")
  264. code := this.GetString("code")
  265. if len(code) == 0 {
  266. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
  267. return
  268. }
  269. if code == "000000" {
  270. patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
  271. fmt.Println("errcodes2323232232", errcodes)
  272. if errcodes == nil {
  273. role := models.XcxAdminUserRole{
  274. PatientName: name,
  275. IdCardNo: id_card_no,
  276. Mobile: mobile,
  277. Code: code,
  278. PatientId: patient.ID,
  279. UserOrgId: patient.UserOrgId,
  280. Status: 1,
  281. Ctime: time.Now().Unix(),
  282. Mtime: 0,
  283. Appid: "",
  284. Appsecret: "",
  285. SessionKey: "",
  286. }
  287. //查找该电话号码是否存在
  288. _, errcode := service.GetMobilePatientOne(mobile)
  289. if errcode == gorm.ErrRecordNotFound {
  290. err := service.CreateXcxAdminUser(role)
  291. if err == nil {
  292. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  293. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  294. //处方
  295. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  296. //接诊评估
  297. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  298. //透前评估
  299. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  300. //透析上机
  301. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  302. //透析监测
  303. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  304. //透后评估
  305. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  306. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  307. var configList interface{}
  308. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  309. this.ServeSuccessJSON(map[string]interface{}{
  310. "role": role,
  311. "is_bind": true,
  312. "patient": mobilePatient,
  313. "template_id": template_id,
  314. "user_org_id": mobilePatient.UserOrgId,
  315. "prescripition_config": prescripition_config,
  316. "receive_treatement_config": receive_treatement_config,
  317. "dialysis_befor": dialysis_befor,
  318. "dialysis_order": dialysis_order,
  319. "monitor_record": monitor_record,
  320. "dialysis_after": dialysis_after,
  321. "treate_ment": treate_ment,
  322. "configList": configList,
  323. "result": false,
  324. })
  325. } else {
  326. this.ServeSuccessJSON(map[string]interface{}{
  327. "is_bind": false,
  328. "msg": "绑定失败",
  329. "result": false,
  330. })
  331. }
  332. } else if errcode == nil {
  333. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  334. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  335. //处方
  336. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  337. //接诊评估
  338. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  339. //透前评估
  340. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  341. //透析上机
  342. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  343. //透析监测
  344. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  345. //透后评估
  346. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  347. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  348. var configList interface{}
  349. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  350. this.ServeSuccessJSON(map[string]interface{}{
  351. "is_bind": true,
  352. "patient": mobilePatient,
  353. "template_id": template_id,
  354. "user_org_id": mobilePatient.UserOrgId,
  355. "prescripition_config": prescripition_config,
  356. "receive_treatement_config": receive_treatement_config,
  357. "dialysis_befor": dialysis_befor,
  358. "dialysis_order": dialysis_order,
  359. "monitor_record": monitor_record,
  360. "dialysis_after": dialysis_after,
  361. "treate_ment": treate_ment,
  362. "list": configList,
  363. "result": false,
  364. })
  365. }
  366. fmt.Println("roler", role)
  367. } else if errcodes == gorm.ErrRecordNotFound {
  368. this.ServeSuccessJSON(map[string]interface{}{
  369. "is_bind": false,
  370. "result": false,
  371. })
  372. }
  373. this.ServeJSON()
  374. } else {
  375. redisClient := service.RedisClient()
  376. defer redisClient.Close()
  377. cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
  378. fmt.Println("cache_code9999999293323232322323", cache_code)
  379. if cache_code != code {
  380. this.ServeSuccessJSON(map[string]interface{}{
  381. "result": false,
  382. })
  383. return
  384. } else {
  385. this.Ctx.SetCookie("mobile", mobile)
  386. // 注册成功后验证码就要使其失效
  387. redisClient.Del("code_msg_" + mobile)
  388. patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
  389. fmt.Println("errcodes2323232232", errcodes)
  390. if errcodes == nil {
  391. role := models.XcxAdminUserRole{
  392. PatientName: name,
  393. IdCardNo: id_card_no,
  394. Mobile: mobile,
  395. Code: code,
  396. PatientId: patient.ID,
  397. UserOrgId: patient.UserOrgId,
  398. Status: 1,
  399. Ctime: time.Now().Unix(),
  400. Mtime: 0,
  401. Appid: "",
  402. Appsecret: "",
  403. SessionKey: "",
  404. }
  405. //查找该电话号码是否存在
  406. _, errcode := service.GetMobilePatientOne(mobile)
  407. if errcode == gorm.ErrRecordNotFound {
  408. err := service.CreateXcxAdminUser(role)
  409. if err == nil {
  410. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  411. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  412. //处方
  413. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  414. //接诊评估
  415. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  416. //透前评估
  417. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  418. //透析上机
  419. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  420. //透析监测
  421. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  422. //透后评估
  423. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  424. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  425. var configList interface{}
  426. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  427. this.ServeSuccessJSON(map[string]interface{}{
  428. "role": role,
  429. "is_bind": true,
  430. "patient": mobilePatient,
  431. "template_id": template_id,
  432. "user_org_id": mobilePatient.UserOrgId,
  433. "prescripition_config": prescripition_config,
  434. "receive_treatement_config": receive_treatement_config,
  435. "dialysis_befor": dialysis_befor,
  436. "dialysis_order": dialysis_order,
  437. "monitor_record": monitor_record,
  438. "dialysis_after": dialysis_after,
  439. "treate_ment": treate_ment,
  440. "configList": configList,
  441. "result": false,
  442. })
  443. } else {
  444. this.ServeSuccessJSON(map[string]interface{}{
  445. "is_bind": false,
  446. "msg": "绑定失败",
  447. "result": false,
  448. })
  449. }
  450. } else if errcode == nil {
  451. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  452. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  453. //处方
  454. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  455. //接诊评估
  456. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  457. //透前评估
  458. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  459. //透析上机
  460. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  461. //透析监测
  462. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  463. //透后评估
  464. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  465. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  466. var configList interface{}
  467. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  468. this.ServeSuccessJSON(map[string]interface{}{
  469. "is_bind": true,
  470. "patient": mobilePatient,
  471. "template_id": template_id,
  472. "user_org_id": mobilePatient.UserOrgId,
  473. "prescripition_config": prescripition_config,
  474. "receive_treatement_config": receive_treatement_config,
  475. "dialysis_befor": dialysis_befor,
  476. "dialysis_order": dialysis_order,
  477. "monitor_record": monitor_record,
  478. "dialysis_after": dialysis_after,
  479. "treate_ment": treate_ment,
  480. "list": configList,
  481. "result": false,
  482. })
  483. }
  484. fmt.Println("roler", role)
  485. } else if errcodes == gorm.ErrRecordNotFound {
  486. this.ServeSuccessJSON(map[string]interface{}{
  487. "is_bind": false,
  488. "result": false,
  489. })
  490. }
  491. this.ServeJSON()
  492. }
  493. }
  494. }
  495. func (this *XcxApiController) GetCodeInfo() {
  496. mobile := this.GetString("phone")
  497. aespass := this.GetString("aespass")
  498. utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
  499. if utils.CellPhoneRegexp().MatchString(mobile) == false {
  500. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
  501. this.ServeJSON()
  502. return
  503. }
  504. if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
  505. this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
  506. this.ServeJSON()
  507. } else {
  508. this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
  509. "msg": "短信发送成功,有效期为10分钟",
  510. })
  511. this.ServeJSON()
  512. }
  513. this.ServeSuccessJSON(map[string]interface{}{
  514. "code": "100100",
  515. })
  516. }
  517. func (this *XcxApiController) GetLoginInfoByOpenid() {
  518. openid := this.GetString("openid")
  519. user_admin, errcodes := service.GetXcxOpneidInformation(openid)
  520. if errcodes == gorm.ErrRecordNotFound {
  521. this.ServeSuccessJSON(map[string]interface{}{
  522. "patient": "",
  523. "patient_id": 0,
  524. "user_org_id": 0,
  525. "role": user_admin,
  526. "is_bind": false,
  527. })
  528. } else if errcodes == nil {
  529. info, _ := service.GetPatientListByPatientId(user_admin.PatientId)
  530. this.ServeSuccessJSON(map[string]interface{}{
  531. "patient": info,
  532. "role": user_admin,
  533. "is_bind": true,
  534. "user_org_id": info.UserOrgId,
  535. "patient_id": user_admin.PatientId,
  536. })
  537. }
  538. }
  539. func (this *XcxApiController) GetLoginInfor() {
  540. mobile := this.GetString("mobile")
  541. user_admin, errcodes := service.GetXcxMobileInformation(mobile)
  542. if errcodes == gorm.ErrRecordNotFound {
  543. this.ServeSuccessJSON(map[string]interface{}{
  544. "patient": "",
  545. "patient_id": 0,
  546. "user_org_id": 0,
  547. "role": user_admin,
  548. "is_bind": false,
  549. })
  550. } else if errcodes == nil {
  551. info, _ := service.GetPatientListByPatientId(user_admin.PatientId)
  552. this.ServeSuccessJSON(map[string]interface{}{
  553. "patient": info,
  554. "role": user_admin,
  555. "is_bind": true,
  556. "user_org_id": info.UserOrgId,
  557. "patient_id": user_admin.PatientId,
  558. })
  559. }
  560. }
  561. func (this *XcxApiController) GetPatientList() {
  562. //appid := "wx20b60369111b063a"
  563. appid := "wxcdf53b48b7df107e"
  564. key := "Yz1HgsFX3yJvWPJSEdwJDA=="
  565. strs := "uSevGQ5ShkiHjQuqz7s36SKZisVGA4fHH/dy+etg0W7ibVeidl6TyFS+kQZ6B9AI2T+1kOtKXeyveQR7q2TXJdu3fhKCFoLKVFzICNEvkiHMnchJ0T0OpRO3oT+icYq80+egvT+jMSgP7yi0cAgmiKaK/4QURD7+nvxRAj9drzz77sbeFt8KElb1LN/+Wn8dIoQzisxbON9G1VJYYtyBkQ=="
  566. iv := "JgsbDhJ613uaAgAoBVh0Zw=="
  567. //data, err := service.Dncrypt(strs, key, iv)
  568. //fmt.Println(err)
  569. data, err := service.DecryptData(appid, key, iv, strs)
  570. patient_id, _ := this.GetInt64("patient_id")
  571. patient, err := service.GetPatientListByPatientId(patient_id)
  572. if err == nil {
  573. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  574. return
  575. }
  576. this.ServeSuccessJSON(map[string]interface{}{
  577. "patient": patient,
  578. "data": data,
  579. })
  580. }
  581. func (this *XcxApiController) GetDataInfo() {
  582. appid := this.GetString("appid")
  583. fmt.Println(appid)
  584. key := this.GetString("key")
  585. iv := this.GetString("iv")
  586. encryptedData := this.GetString("encryptedData")
  587. list, _ := service.DecryptData(appid, key, iv, encryptedData)
  588. //list, _ := service.Dncrypt(encryptedData, key, iv)
  589. this.ServeSuccessJSON(map[string]interface{}{
  590. "list": list,
  591. })
  592. }
  593. func (this *XcxApiController) GetSignsByBlood() {
  594. start := this.GetString("start", "")
  595. end := this.GetString("end", "")
  596. patient_id, _ := this.GetInt64("patient_id", 0)
  597. org_id, _ := this.GetInt64("org_id", 0)
  598. if len(start) <= 0 || len(end) <= 0 || patient_id <= 0 || org_id <= 0 {
  599. this.ServeSuccessJSON(map[string]interface{}{
  600. "err_code": 1001,
  601. "err_msg": "缺少参数",
  602. "data": "",
  603. })
  604. }
  605. loc, _ := time.LoadLocation("Local")
  606. startTime, _ := time.ParseInLocation("2006-01-02", start, loc)
  607. startTimeUnix := startTime.Unix()
  608. endTime, _ := time.ParseInLocation("2006-01-02", end, loc)
  609. endTimeUinx := endTime.Unix()
  610. utils.TraceLog("startTime:%v endTime:%v", startTime, endTime)
  611. utils.TraceLog("startTimeUnix:%v endTimeUinx:%v", startTimeUnix, endTimeUinx)
  612. if startTimeUnix < 0 || endTimeUinx < 0 {
  613. this.ServeSuccessJSON(map[string]interface{}{
  614. "err_code": 1001,
  615. "err_msg": "时间超出范围",
  616. "data": "",
  617. })
  618. }
  619. if startTimeUnix > endTimeUinx {
  620. this.ServeSuccessJSON(map[string]interface{}{
  621. "err_code": 1001,
  622. "err_msg": "开始时间大于结束时间",
  623. "data": "",
  624. })
  625. }
  626. if endTimeUinx-startTimeUnix > 60*60*24*60 {
  627. this.ServeSuccessJSON(map[string]interface{}{
  628. "err_code": 1001,
  629. "err_msg": "时间范围超过60天",
  630. "data": "",
  631. })
  632. }
  633. beforeblood, _ := service.GetSignsByBlood(org_id, startTimeUnix, endTimeUinx, patient_id)
  634. afterblood, _ := service.GetSignsByAfterBlood(org_id, startTimeUnix, endTimeUinx, patient_id)
  635. this.ServeSuccessJSON(map[string]interface{}{
  636. "err_code": 0,
  637. "err_msg": "",
  638. "before_blood": beforeblood,
  639. "after_blood": afterblood,
  640. })
  641. //now := time.Now()
  642. //offset := int(time.Monday - now.Weekday())
  643. //if offset > 0 {
  644. // offset = -6
  645. //}
  646. //monday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
  647. //endday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset+6)
  648. //startTime := monday.Unix()
  649. //endTime := endday.Unix()
  650. //
  651. //this.ServeSuccessJSON(map[string]interface{}{
  652. // "monday": startTime,
  653. // "endday": endTime,
  654. //})
  655. }
  656. func (this *XcxApiController) GetSignsByWeight() {
  657. start := this.GetString("start", "")
  658. end := this.GetString("end", "")
  659. patient_id, _ := this.GetInt64("patient_id", 0)
  660. org_id, _ := this.GetInt64("org_id", 0)
  661. if len(start) <= 0 || len(end) <= 0 || patient_id <= 0 || org_id <= 0 {
  662. this.ServeSuccessJSON(map[string]interface{}{
  663. "err_code": 1001,
  664. "err_msg": "缺少参数",
  665. "data": "",
  666. })
  667. }
  668. loc, _ := time.LoadLocation("Local")
  669. startTime, _ := time.ParseInLocation("2006-01-02", start, loc)
  670. startTimeUnix := startTime.Unix()
  671. endTime, _ := time.ParseInLocation("2006-01-02", end, loc)
  672. endTimeUinx := endTime.Unix()
  673. utils.TraceLog("startTime:%v endTime:%v", startTime, endTime)
  674. utils.TraceLog("startTimeUnix:%v endTimeUinx:%v", startTimeUnix, endTimeUinx)
  675. if startTimeUnix < 0 || endTimeUinx < 0 {
  676. this.ServeSuccessJSON(map[string]interface{}{
  677. "err_code": 1001,
  678. "err_msg": "时间超出范围",
  679. "data": "",
  680. })
  681. }
  682. if startTimeUnix > endTimeUinx {
  683. this.ServeSuccessJSON(map[string]interface{}{
  684. "err_code": 1001,
  685. "err_msg": "开始时间大于结束时间",
  686. "data": "",
  687. })
  688. }
  689. if endTimeUinx-startTimeUnix > 60*60*24*60 {
  690. this.ServeSuccessJSON(map[string]interface{}{
  691. "err_code": 1001,
  692. "err_msg": "时间范围超过60天",
  693. "data": "",
  694. })
  695. }
  696. beforeweight, _ := service.GetSignsByWeight(org_id, startTimeUnix, endTimeUinx, patient_id)
  697. dryweight, _ := service.GetSignsByDryWeight(org_id, startTimeUnix, endTimeUinx, patient_id)
  698. afterweight, _ := service.GetSignsByAfterWeight(org_id, startTimeUnix, endTimeUinx, patient_id)
  699. this.ServeSuccessJSON(map[string]interface{}{
  700. "err_code": 0,
  701. "err_msg": "",
  702. "before_eweight": beforeweight,
  703. "dry_eweight": dryweight,
  704. "after_eweight": afterweight,
  705. })
  706. //now := time.Now()
  707. //offset := int(time.Monday - now.Weekday())
  708. //if offset > 0 {
  709. // offset = -6
  710. //}
  711. //monday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
  712. //endday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset+6)
  713. //startTime := monday.Unix()
  714. //endTime := endday.Unix()
  715. //
  716. //this.ServeSuccessJSON(map[string]interface{}{
  717. // "monday": startTime,
  718. // "endday": endTime,
  719. //})
  720. }
  721. func (this *XcxApiController) GetSchedulesByWeek() {
  722. start := this.GetString("start", "")
  723. end := this.GetString("end", "")
  724. patient_id, _ := this.GetInt64("patient_id", 0)
  725. org_id, _ := this.GetInt64("org_id", 0)
  726. if len(start) <= 0 || len(end) <= 0 || patient_id <= 0 || org_id <= 0 {
  727. this.ServeSuccessJSON(map[string]interface{}{
  728. "err_code": 1001,
  729. "err_msg": "缺少参数",
  730. "data": "",
  731. })
  732. }
  733. loc, _ := time.LoadLocation("Local")
  734. startTime, _ := time.ParseInLocation("2006-01-02", start, loc)
  735. startTimeUnix := startTime.Unix()
  736. endTime, _ := time.ParseInLocation("2006-01-02", end, loc)
  737. endTimeUinx := endTime.Unix()
  738. utils.TraceLog("startTime:%v endTime:%v", startTime, endTime)
  739. utils.TraceLog("startTimeUnix:%v endTimeUinx:%v", startTimeUnix, endTimeUinx)
  740. if startTimeUnix < 0 || endTimeUinx < 0 {
  741. this.ServeSuccessJSON(map[string]interface{}{
  742. "err_code": 1001,
  743. "err_msg": "时间超出范围",
  744. "data": "",
  745. })
  746. }
  747. if startTimeUnix > endTimeUinx {
  748. this.ServeSuccessJSON(map[string]interface{}{
  749. "err_code": 1001,
  750. "err_msg": "开始时间大于结束时间",
  751. "data": "",
  752. })
  753. }
  754. if endTimeUinx-startTimeUnix > 60*60*24*60 {
  755. this.ServeSuccessJSON(map[string]interface{}{
  756. "err_code": 1001,
  757. "err_msg": "时间范围超过60天",
  758. "data": "",
  759. })
  760. }
  761. schedule, _ := service.GetScheduleByXcx(org_id, startTimeUnix, endTimeUinx, patient_id)
  762. this.ServeSuccessJSON(map[string]interface{}{
  763. "err_code": 0,
  764. "err_msg": "",
  765. "data": schedule,
  766. })
  767. //now := time.Now()
  768. //offset := int(time.Monday - now.Weekday())
  769. //if offset > 0 {
  770. // offset = -6
  771. //}
  772. //monday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
  773. //endday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset+6)
  774. //startTime := monday.Unix()
  775. //endTime := endday.Unix()
  776. //
  777. //this.ServeSuccessJSON(map[string]interface{}{
  778. // "monday": startTime,
  779. // "endday": endTime,
  780. //})
  781. }
  782. func (this *XcxApiController) GetScheduleInfo() {
  783. patient_id, _ := this.GetInt64("patient_id")
  784. fmt.Println(patient_id)
  785. thisWeekMonday := service.GetFirstDateOfWeek()
  786. weekDayWeek := service.GetWeekDayOfWeek()
  787. TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
  788. weekDays, _ := time.Parse("2006-01-02", weekDayWeek)
  789. lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
  790. nextWeekMonday := weekDays.AddDate(0, 0, +13)
  791. var weekMonday = lastWeekMonday.Format("2006-01-02")
  792. var weekDay = nextWeekMonday.Format("2006-01-02")
  793. //fmt.Println("weekmodonday", weekMonday)
  794. //fmt.Println("nextweeekday", weekDay)
  795. timeLayout := "2006-01-02"
  796. loc, _ := time.LoadLocation("Local")
  797. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
  798. fmt.Println("startiem", startTime)
  799. endTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekDay+"00:00:00", loc)
  800. fmt.Println(startTime.Unix(), endTime.Unix())
  801. schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), patient_id)
  802. //获取当前今日的排班日期
  803. time_now := time.Now().Format("2006-01-02")
  804. fmt.Println("time_now", time_now)
  805. timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
  806. fmt.Println("timeNowUnix", timeNowUnix.Unix())
  807. //获取今日下机日期
  808. order, _ := service.GetTodayDialysis(timeNowUnix.Unix(), patient_id)
  809. devicenumber, _ := service.GetAllBedNumberListTwo(schedule[0].UserOrgId)
  810. //获取今日的处方
  811. prescription, _ := service.GetTodayPrescription(timeNowUnix.Unix(), patient_id)
  812. //获取下一次排班信息
  813. patientSchedule, _ := service.GetNextPatientSchedule(patient_id, timeNowUnix.Unix())
  814. if err != nil {
  815. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  816. return
  817. }
  818. var one = startTime.Unix()
  819. fmt.Println("one2322332", one)
  820. var two = one + 86400
  821. var three = two + 86400
  822. var four = three + 86400
  823. var five = four + 86400
  824. var six = five + 86400
  825. var seven = six + 86400
  826. var nextOne = seven + 86400
  827. var nexttwo = nextOne + 86400
  828. var nextthree = nexttwo + 86400
  829. var nextfour = nextthree + 86400
  830. var nextfive = nextfour + 86400
  831. var nextsix = nextfive + 86400
  832. var nextseven = nextsix + 86400
  833. var lastOne = nextseven + 86400
  834. var lastwo = lastOne + 86400
  835. var lasthree = lastwo + 86400
  836. var lastfour = lasthree + 86400
  837. var lastfive = lastfour + 86400
  838. var lastsix = lastfive + 86400
  839. var lastseven = lastsix + 86400
  840. array := []interface{}{
  841. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  842. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  843. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  844. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  845. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  846. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  847. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  848. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  849. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  850. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  851. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  852. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  853. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  854. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  855. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  856. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  857. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  858. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  859. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  860. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  861. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  862. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  863. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  864. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  865. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  866. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  867. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  868. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  869. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  870. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  871. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  872. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  873. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  874. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  875. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  876. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  877. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  878. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  879. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  880. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  881. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  882. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  883. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  884. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  885. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  886. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  887. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  888. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  889. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  890. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  891. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  892. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  893. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  894. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  895. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  896. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  897. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  898. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  899. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  900. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  901. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  902. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  903. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  904. }
  905. this.ServeSuccessJSON(map[string]interface{}{
  906. "list": schedule,
  907. "array": array,
  908. "order": order,
  909. "patientSchedule": patientSchedule,
  910. "prescription": prescription,
  911. "devicenumber": devicenumber,
  912. })
  913. }
  914. func (this *XcxApiController) GetMobileSchedule() {
  915. patientID, _ := this.GetInt64("patient_id")
  916. info, _ := service.GetXcxPatientInfo(patientID)
  917. timeLayout := "2006-01-02"
  918. loc, _ := time.LoadLocation("Local")
  919. time_now := time.Now().Format("2006-01-02")
  920. timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
  921. //获取该患者最后一次排班
  922. list, _ := service.GetLastScheduleListOne(patientID, timeNowUnix.Unix())
  923. patient, getPatientErr := service.MobileGetPatientDetail(info.UserOrgId, patientID)
  924. if getPatientErr != nil {
  925. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  926. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  927. return
  928. } else if patient == nil {
  929. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  930. return
  931. }
  932. schedual, getSchedualErr := service.MobileGetSchedualDetailOne(info.UserOrgId, patientID)
  933. if getSchedualErr != nil {
  934. this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
  935. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecordOne(info.UserOrgId, patientID, list.ScheduleDate)
  939. if getRTARErr != nil {
  940. this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
  941. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(info.UserOrgId, patientID, list.ScheduleDate)
  945. if getPEErr != nil {
  946. this.ErrorLog("获取透前评估失败:%v", getPEErr)
  947. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  948. return
  949. }
  950. lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluationOne(info.UserOrgId, patientID)
  951. if getLPEErr != nil {
  952. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  953. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroupsOne(info.UserOrgId, patientID, list.ScheduleDate)
  957. if getDoctorAdvicesErr != nil {
  958. this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
  959. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  960. return
  961. }
  962. dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecordOne(info.UserOrgId, patientID, list.ScheduleDate)
  963. if getDialysisOrderErr != nil {
  964. this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
  965. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  966. return
  967. }
  968. doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheckOne(info.UserOrgId, patientID, list.ScheduleDate)
  969. if getDoubleCheckErr != nil {
  970. this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
  971. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  972. return
  973. }
  974. monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecordsOne(info.UserOrgId, patientID, list.ScheduleDate)
  975. if getMonitorRecordsErr != nil {
  976. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  977. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. var lastMonitorRecord *models.MonitoringRecord
  981. lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecordOne(info.UserOrgId, patientID)
  982. if getLastErr != nil {
  983. this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
  984. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  985. return
  986. }
  987. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(info.UserOrgId, patientID, list.ScheduleDate)
  988. if getAADErr != nil {
  989. this.ErrorLog("获取透后评估失败:%v", getAADErr)
  990. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. lastAssessmentAfterDislysis, getLAADErr := service.MobileGetAssessmentAfterDislysisOne(info.UserOrgId, patientID, list.ScheduleDate)
  994. if getLAADErr != nil {
  995. this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
  996. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  997. return
  998. }
  999. treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummaryOne(info.UserOrgId, patientID, list.ScheduleDate)
  1000. if getTreatmentSummaryErr != nil {
  1001. this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
  1002. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1003. return
  1004. }
  1005. dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(info.UserOrgId, patientID, schedual.ModeId)
  1006. lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(info.UserOrgId, patientID, schedual.ModeId)
  1007. //获取系统透析处方模版
  1008. systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(info.UserOrgId, schedual.ModeId)
  1009. _, is_open_config := service.FindXTHisRecordByOrgId(info.UserOrgId)
  1010. _, is_project_open_config := service.FindXTHisProjectByOrgId(info.UserOrgId)
  1011. projects, _ := service.GetHisPrescriptionProjectsOne(info.UserOrgId, patientID)
  1012. stockType, _ := service.GetStockType(info.UserOrgId)
  1013. prepare, _ := service.GetDialyStockOutOne(info.UserOrgId, patientID)
  1014. //获取最后一次血管通路
  1015. lastAssessment, _ := service.GetLastPassWayAssessment(info.UserOrgId, patientID)
  1016. prescribeOne, _ := service.MobileGetDialysisPrescribeByModeIdFive(info.UserOrgId, patientID, list.ScheduleDate)
  1017. var his_advices []*models.HisDoctorAdviceInfo
  1018. if is_open_config.IsOpen == 1 {
  1019. his_advices, _ = service.GetAllHisDoctorAdviceOne(info.UserOrgId, patientID, list.ScheduleDate)
  1020. }
  1021. if getLPEErr != nil {
  1022. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  1023. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(info.UserOrgId, patientID)
  1027. if getDryErr != nil {
  1028. this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
  1029. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. _, gobalConfig := service.FindAutomaticReduceRecordByOrgId(info.UserOrgId)
  1033. operators, _ := service.GetAllStarfEs(info.UserOrgId)
  1034. returnData := map[string]interface{}{
  1035. "patient": patient,
  1036. "schedual": schedual,
  1037. "prescription": prescribeOne,
  1038. "solution": dialysisSolution,
  1039. "last_prescription": lastDialysisPrescribe,
  1040. "receiver_treatment_access": receiverTreatmentAccess,
  1041. "predialysis_evaluation": predialysisEvaluation,
  1042. "doctor_advices": doctorAdvices,
  1043. "double_check": doubleCheck,
  1044. "assessment_after_dislysis": assessmentAfterDislysis,
  1045. "treatment_summary": treatmentSummary,
  1046. "monitor_records": monitorRecords,
  1047. "dialysis_order": dialysisOrder,
  1048. "operators": operators,
  1049. "last_predialysis_evaluation": lastPredialysisEvaluation,
  1050. "last_assessment_after_dislysis": lastAssessmentAfterDislysis,
  1051. "last_monitor_record": lastMonitorRecord,
  1052. "config": gobalConfig,
  1053. "dry_weight": lastDryWeightDislysis,
  1054. "system_prescription": systemDialysisPrescribe,
  1055. "his_advices": his_advices,
  1056. "is_open_config": is_open_config,
  1057. "stockType": stockType,
  1058. "prepare": prepare,
  1059. "lastAssessment": lastAssessment,
  1060. "is_project_open_config": is_project_open_config,
  1061. "project": projects,
  1062. "scheduleDate": list.ScheduleDate,
  1063. }
  1064. this.ServeSuccessJSON(returnData)
  1065. }
  1066. func (this *XcxApiController) GetPatientInfo() {
  1067. patient_id, _ := this.GetInt64("patient_id")
  1068. patient, _ := service.GetXcxPatientInfo(patient_id)
  1069. this.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. })
  1072. }
  1073. func (this *XcxApiController) GetOrgInfo() {
  1074. patient_id, _ := this.GetInt64("patient_id")
  1075. info, _ := service.GetXcxPatientInfo(patient_id)
  1076. orgInfo, _ := service.GetOrgInfo(info.UserOrgId)
  1077. this.ServeSuccessJSON(map[string]interface{}{
  1078. "orgInfo": orgInfo,
  1079. })
  1080. }
  1081. func (this *XcxApiController) GetEducationList() {
  1082. start_time := this.GetString("start_time")
  1083. end_time := this.GetString("end_time")
  1084. patient_id, _ := this.GetInt64("patient_id")
  1085. timeLayout := "2006-01-02"
  1086. loc, _ := time.LoadLocation("Local")
  1087. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1088. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1089. list, _ := service.GetEducationList(startTime.Unix(), endTime.Unix(), patient_id)
  1090. this.ServeSuccessJSON(map[string]interface{}{
  1091. "list": list,
  1092. })
  1093. }
  1094. func (this *XcxApiController) GetDoctorAdvice() {
  1095. //判断是否开启医嘱同步功能
  1096. start_time := this.GetString("start_time")
  1097. end_time := this.GetString("end_time")
  1098. patient_id, _ := this.GetInt64("patient_id")
  1099. fmt.Println("patient_id", patient_id)
  1100. timeLayout := "2006-01-02"
  1101. loc, _ := time.LoadLocation("Local")
  1102. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1103. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1104. info, _ := service.GetXcxPatientInfo(patient_id)
  1105. _, config := service.FindXTHisRecordByOrgId(info.UserOrgId)
  1106. fmt.Println(startTime, endTime, config.IsOpen)
  1107. if config.IsOpen == 0 {
  1108. list, _ := service.GetDoctorAdviceGroup(patient_id, startTime.Unix(), endTime.Unix())
  1109. advice, _ := service.GetDoctorAdvice(patient_id, startTime.Unix(), endTime.Unix())
  1110. for _, item := range list {
  1111. for _, it := range advice {
  1112. if item.AdviceDate == it.AdviceDate {
  1113. item.Childs = append(item.Childs, it)
  1114. }
  1115. }
  1116. }
  1117. this.ServeSuccessJSON(map[string]interface{}{
  1118. "list": list,
  1119. })
  1120. }
  1121. if config.IsOpen == 1 {
  1122. list, _ := service.GetHisDoctorAdviceGroup(patient_id, startTime.Unix(), endTime.Unix())
  1123. advice, _ := service.GetHisDoctorAdvice(patient_id, startTime.Unix(), endTime.Unix())
  1124. for _, item := range list {
  1125. for _, it := range advice {
  1126. if item.AdviceDate == it.AdviceDate {
  1127. item.Childs = append(item.Childs, it)
  1128. }
  1129. }
  1130. }
  1131. this.ServeSuccessJSON(map[string]interface{}{
  1132. "list": list,
  1133. })
  1134. }
  1135. }
  1136. func (this *XcxApiController) GetDoctorName() {
  1137. patient_id, _ := this.GetInt64("patient_id")
  1138. fmt.Println("patient_id", patient_id)
  1139. info, _ := service.GetXcxPatientInfo(patient_id)
  1140. user_name, _ := service.GetDoctorName(info.UserOrgId)
  1141. this.ServeSuccessJSON(map[string]interface{}{
  1142. "user_name": user_name,
  1143. })
  1144. }
  1145. func (this *XcxApiController) GetFieldConfig() {
  1146. patient_id, _ := this.GetInt64("patient_id")
  1147. fmt.Println("patient_id", patient_id)
  1148. info, _ := service.GetXcxPatientInfo(patient_id)
  1149. //处方
  1150. prescripition_config, _ := service.GetPrescripionFieldConfig(info.UserOrgId)
  1151. //接诊评估
  1152. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(info.UserOrgId)
  1153. //透前评估
  1154. dialysis_befor, _ := service.GetDialysisBefor(info.UserOrgId)
  1155. //透析上机
  1156. dialysis_order, _ := service.GetDialysisOrderConfig(info.UserOrgId)
  1157. //透析监测
  1158. monitor_record, _ := service.GetMonitorRecordConfig(info.UserOrgId)
  1159. //透后评估
  1160. dialysis_after, _ := service.GetDialysisAfeterConfig(info.UserOrgId)
  1161. treate_ment, _ := service.GetTreatMentConfig(info.UserOrgId)
  1162. this.ServeSuccessJSON(map[string]interface{}{
  1163. "prescripition_config": prescripition_config,
  1164. "receive_treatement_config": receive_treatement_config,
  1165. "dialysis_befor": dialysis_befor,
  1166. "dialysis_order": dialysis_order,
  1167. "monitor_record": monitor_record,
  1168. "dialysis_after": dialysis_after,
  1169. "treate_ment": treate_ment,
  1170. })
  1171. }
  1172. func (this *XcxApiController) GetDataConfig() {
  1173. var configList interface{}
  1174. patient_id, _ := this.GetInt64("patient_id")
  1175. fmt.Println("patient_id", patient_id)
  1176. info, _ := service.GetXcxPatientInfo(patient_id)
  1177. //list, _ := service.GetDataConfig(info.UserOrgId)
  1178. configList, _ = service.GetConfigList(info.UserOrgId)
  1179. this.ServeSuccessJSON(map[string]interface{}{
  1180. "list": configList,
  1181. })
  1182. }
  1183. func (this *XcxApiController) GetInspectionList() {
  1184. page, _ := this.GetInt64("page", 0)
  1185. number, _ := this.GetInt64("number", 10)
  1186. patient_id, _ := this.GetInt64("patient_id", 0)
  1187. //fmt.Println("patient_id", patient_id)
  1188. //timeLayout := "2006-01-02"
  1189. //loc, _ := time.LoadLocation("Local")
  1190. //startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1191. //endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1192. list, err := service.GetInspectionGroupListByXcx(patient_id, page, number)
  1193. if err == gorm.ErrRecordNotFound {
  1194. this.ServeSuccessJSON(map[string]interface{}{
  1195. "error_code": "1001",
  1196. "error_msg": "没有更多数据",
  1197. })
  1198. }
  1199. this.ServeSuccessJSON(map[string]interface{}{
  1200. "error_code": "0",
  1201. "error_msg": "",
  1202. "list": list,
  1203. })
  1204. }
  1205. func (this *XcxApiController) GetInspectionInfo() {
  1206. project_id, _ := this.GetInt64("project_id", 0)
  1207. inspect_date, _ := this.GetInt64("inspect_date", 0)
  1208. patient_id, _ := this.GetInt64("patient_id", 0)
  1209. if project_id <= 0 || inspect_date <= 0 || patient_id <= 0 {
  1210. this.ServeSuccessJSON(map[string]interface{}{
  1211. "error_code": 1001,
  1212. "error_msg": "缺少参数",
  1213. })
  1214. }
  1215. list, _ := service.GetInspectionInfoByXcx(patient_id, project_id, inspect_date)
  1216. this.ServeSuccessJSON(map[string]interface{}{
  1217. "list": list,
  1218. })
  1219. }
  1220. func (this *XcxApiController) GetArticList() {
  1221. page, _ := this.GetInt64("page")
  1222. limit, _ := this.GetInt64("limit")
  1223. activity_id, _ := this.GetInt64("activity_id")
  1224. list, total, _ := service.GetArticList(activity_id, page, limit)
  1225. this.ServeSuccessJSON(map[string]interface{}{
  1226. "list": list,
  1227. "total": total,
  1228. })
  1229. }
  1230. func (this *XcxApiController) GetArticListDetail() {
  1231. id, _ := this.GetInt64("id")
  1232. detail, _ := service.GetArticListDetail(id)
  1233. this.ServeSuccessJSON(map[string]interface{}{
  1234. "story": detail,
  1235. })
  1236. }
  1237. func (this *XcxApiController) GetStoryScoreList() {
  1238. page, _ := this.GetInt64("page")
  1239. limit, _ := this.GetInt64("limit")
  1240. activity_id, _ := this.GetInt64("activity_id")
  1241. list, total, _ := service.GetStoryScoreList(activity_id, page, limit)
  1242. this.ServeSuccessJSON(map[string]interface{}{
  1243. "list": list,
  1244. "total": total,
  1245. })
  1246. }
  1247. func (this *XcxApiController) GetAppId() {
  1248. var appid = "wxcdf53b48b7df107e"
  1249. var secret = "94e944a69ad1d43ac447f5a8769ab801"
  1250. var grant_type = "authorization_code"
  1251. code := this.GetString("js_code")
  1252. //var code = "041pXnGa1eLxTB0iypFa1W6USs1pXnGK"
  1253. openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
  1254. //session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)
  1255. this.ServeSuccessJSON(map[string]interface{}{
  1256. "data": openId,
  1257. //"session_key": session_key,
  1258. })
  1259. }