coordinate_controller.go 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "io/ioutil"
  11. "math/rand"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. type CoordinateController struct {
  17. BaseAPIController
  18. }
  19. type ResultReg struct {
  20. ResultCode string `json:"resultCode"`
  21. ResultDesc string `json:"resultDesc"`
  22. InfoSeq string `json:"infoSeq"`
  23. }
  24. type ResultSettle struct {
  25. ResultCode string `json:"resultCode"`
  26. ResultDesc string `json:"resultDesc"`
  27. DocId string `json:"docId"`
  28. Amount string `json:"amount"`
  29. }
  30. type ResultCancelSettle struct {
  31. ResultCode string `json:"resultCode"`
  32. ResultDesc string `json:"resultDesc"`
  33. }
  34. type Settle struct {
  35. PatientId string `json:"resultCode"`
  36. DocId string `json:"docId"`
  37. InfoSeq string `json:"infoSeq"`
  38. }
  39. type Refund struct {
  40. PatientId string `json:"resultCode"`
  41. DocId string `json:"docId"`
  42. InfoSeq string `json:"infoSeq"`
  43. }
  44. type RefundDetail struct {
  45. Msg string `json:"msg"`
  46. Result []struct {
  47. ResultMsg string `json:"resultMsg"`
  48. Code string `json:"code"`
  49. Records int `json:"records"`
  50. TotalPage int `json:"totalPage"`
  51. List []struct {
  52. Zae01 int64 `json:"ZAE01"`
  53. } `json:"list"`
  54. RecordsTotal int `json:"recordsTotal"`
  55. Pagenumber int `json:"pagenumber"`
  56. Result string `json:"result"`
  57. Total int `json:"total"`
  58. RecordsFtered int `json:"recordsFtered"`
  59. Page int `json:"page"`
  60. } `json:"result"`
  61. Code string `json:"code"`
  62. }
  63. func CoordinateRcegistRouters() {
  64. beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
  65. //坐标挂号
  66. beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
  67. //beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
  68. //坐标记账
  69. beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
  70. //坐标撤销记账
  71. beego.Router("/coordinate/opCancelKeepAccounts", &CoordinateController{}, "get:OpCancelKeepAccounts")
  72. //坐标结算回调
  73. beego.Router("/coordinate/settle", &CoordinateController{}, "post:Settle")
  74. //坐标退费回调
  75. beego.Router("/coordinate/refund", &CoordinateController{}, "post:Refund")
  76. }
  77. func (c *CoordinateController) Settle() {
  78. //参数1 patient_id
  79. //参数2 就诊号
  80. //参数3 单据id
  81. fmt.Println(c.Ctx.Request.Body)
  82. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  83. fmt.Println(string(body))
  84. var respJSON map[string]interface{}
  85. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  86. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  87. return
  88. }
  89. patien_id := respJSON["patientid"].(string)
  90. infoSeq := respJSON["infoseq"].(string)
  91. docId := respJSON["docid"].(string)
  92. fmt.Println(patien_id)
  93. fmt.Println(infoSeq)
  94. fmt.Println(docId)
  95. order, _ := service.GetHisOrderFour(patien_id, infoSeq, "")
  96. order.SetlId = docId
  97. if order.ID == 0 {
  98. json := make(map[string]interface{})
  99. json["msg"] = "结算记录不存在,请检查参数是否正确"
  100. json["code"] = "-1"
  101. c.Data["json"] = json
  102. c.ServeJSON()
  103. return
  104. }
  105. order.OrderStatus = 2
  106. service.UpDateOrder(order)
  107. service.UpdataOrderStatusTwo(order.Number, order.UserOrgId)
  108. json := make(map[string]interface{})
  109. json["msg"] = "结算成功"
  110. json["code"] = "0"
  111. c.Data["json"] = json
  112. c.ServeJSON()
  113. return
  114. }
  115. func (c *CoordinateController) Refund() {
  116. //参数1 patient_id
  117. //参数2 就诊号
  118. //参数3 单据id
  119. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  120. var respJSON map[string]interface{}
  121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  123. return
  124. }
  125. patien_id := respJSON["patientid"].(string)
  126. infoSeq := respJSON["infoseq"].(string)
  127. docId := respJSON["docid"].(string)
  128. order, _ := service.GetHisOrderFour(patien_id, infoSeq, docId)
  129. if order.ID == 0 {
  130. json := make(map[string]interface{})
  131. json["msg"] = "结算记录不存在,请检查参数是否正确"
  132. json["code"] = "-1"
  133. c.Data["json"] = json
  134. c.ServeJSON()
  135. return
  136. }
  137. service.UpdataOrderStatus(order.ID, order.Number, order.UserOrgId)
  138. json := make(map[string]interface{})
  139. json["msg"] = "退费成功"
  140. json["code"] = "0"
  141. c.Data["json"] = json
  142. c.ServeJSON()
  143. return
  144. }
  145. func (c *CoordinateController) SavePatientMessageInfo() {
  146. result, request_log := service.SavePatientMessageInfo()
  147. fmt.Println(result)
  148. fmt.Println(request_log)
  149. }
  150. func (c *CoordinateController) Register() {
  151. patient_id, _ := c.GetInt64("patient_id")
  152. diagnosis_time := c.GetString("diagnosis_time")
  153. record_date := c.GetString("record_date")
  154. admin_user_id, _ := c.GetInt64("admin_user_id")
  155. org_id, _ := c.GetInt64("org_id")
  156. org_id = 4
  157. patient, _ := service.GetPatientByID(org_id, patient_id)
  158. timeLayout := "2006-01-02"
  159. loc, _ := time.LoadLocation("Local")
  160. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  161. if err != nil {
  162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  163. return
  164. }
  165. recordDateTime := theTime.Unix()
  166. patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  167. if patientPrescription.ID == 0 {
  168. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  169. }
  170. //department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  171. doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  172. //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  173. reg := models.Reg{
  174. DeptId: "0112",
  175. PatientId: patient.ZbPatientId,
  176. PatientName: patient.Name,
  177. DoctorId: doctor_info.DoctorNumber,
  178. RegDate: strings.Split(diagnosis_time, " ")[0],
  179. RegFee: "8",
  180. TreatFee: "10",
  181. OperatorId: "测试",
  182. IdCardNo: patient.IdCardNo,
  183. }
  184. result, request_log := service.SaveReg(reg)
  185. fmt.Println(result)
  186. fmt.Println(request_log)
  187. var res ResultReg
  188. //if err := json.Unmarshal([]byte(result), &res); err != nil {
  189. // utils.ErrorLog("解析失败:%v", err)
  190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. // return
  192. //}
  193. res.ResultCode = "0"
  194. res.InfoSeq = "122333"
  195. if res.ResultCode == "0" {
  196. timestamp := time.Now().Unix()
  197. tempTime := time.Unix(timestamp, 0)
  198. timeFormat := tempTime.Format("20060102150405")
  199. chrgBchno := rand.Intn(100000) + 10000
  200. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
  201. his := models.VMHisPatient{
  202. Name: patient.Name,
  203. Gender: patient.Gender,
  204. Birthday: patient.Birthday,
  205. MedicalTreatmentType: 0,
  206. IdType: 1,
  207. IdCardNo: patient.IdCardNo,
  208. BalanceAccountsType: 1,
  209. MedicalInsuranceNumber: "",
  210. RegisterType: 0,
  211. RegisterCost: 0,
  212. TreatmentCost: 0,
  213. Status: 1,
  214. Ctime: time.Now().Unix(),
  215. Mtime: time.Now().Unix(),
  216. PsnNo: patient.ZbPatientId,
  217. PsnCertType: "",
  218. Certno: patient.IdCardNo,
  219. PsnName: patient.Name,
  220. Gend: "",
  221. Naty: "",
  222. Brdy: "",
  223. Age: 0,
  224. Iinfo: "",
  225. Idetinfo: "",
  226. PatientId: patient.ID,
  227. RecordDate: theTime.Unix(),
  228. UserOrgId: org_id,
  229. AdminUserId: admin_user_id,
  230. IsReturn: 1,
  231. Doctor: patientPrescription.DoctorId,
  232. Departments: patientPrescription.Departments,
  233. IptOtpNo: ipt_otp_no,
  234. Number: res.InfoSeq,
  235. PhoneNumber: patient.Phone,
  236. }
  237. service.UpdateHisPatientStatus(&his)
  238. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
  239. c.ServeSuccessJSON(map[string]interface{}{
  240. "his_info": his,
  241. })
  242. } else {
  243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  244. return
  245. }
  246. }
  247. //func (c *CoordinateController) GetWaitPayDetail() {
  248. // result, request_log := service.GetWaitPayDetail()
  249. // fmt.Println(result)
  250. // fmt.Println(request_log)
  251. //
  252. //}
  253. func (c *CoordinateController) OpKeepAccounts() {
  254. id, _ := c.GetInt64("id")
  255. record_time := c.GetString("record_time")
  256. his_patient_id, _ := c.GetInt64("his_patient_id")
  257. timeLayout := "2006-01-02"
  258. loc, _ := time.LoadLocation("Local")
  259. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  260. fapiao_code := c.GetString("fapiao_code")
  261. fapiao_number := c.GetString("fapiao_number")
  262. diagnosis_id := c.GetString("diagnosis")
  263. sick_type, _ := c.GetInt64("sick_type")
  264. reg_type, _ := c.GetInt64("p_type")
  265. org_id, _ := c.GetInt64("org_id")
  266. org_id = 4
  267. his, _ := service.GetHisPatientByIdThree(his_patient_id)
  268. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  269. if err != nil {
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  271. return
  272. }
  273. recordDateTime := theTime.Unix()
  274. //adminUser := c.GetAdminUserInfo()
  275. var prescriptions []*models.HisPrescription
  276. var start_time int64
  277. var end_time int64
  278. //ids_str := c.GetString("ids")
  279. //ids_arr := strings.Split(ids_str, ",")
  280. if settle_accounts_type == 1 { //日结
  281. //fmt.Println(reg_type)
  282. prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, id, recordDateTime, 2)
  283. } else { //月结
  284. start_time_str := c.GetString("start_time")
  285. end_time_str := c.GetString("end_time")
  286. timeLayout := "2006-01-02"
  287. loc, _ := time.LoadLocation("Local")
  288. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  289. if err != nil {
  290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  291. return
  292. }
  293. recordStartTime := theStartTime.Unix()
  294. start_time = recordStartTime
  295. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  296. if err != nil {
  297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  298. return
  299. }
  300. recordEndTime := theEndTime.Unix()
  301. end_time = recordEndTime
  302. prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, id, recordStartTime, recordEndTime)
  303. }
  304. timestamp := time.Now().Unix()
  305. tempTime := time.Unix(timestamp, 0)
  306. timeFormat := tempTime.Format("20060102150405")
  307. chrgBchno := rand.Intn(100000) + 10000
  308. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  309. strconv.FormatInt(his.PatientId, 10)
  310. var ids []int64
  311. for _, item := range prescriptions {
  312. ids = append(ids, item.ID)
  313. }
  314. var total float64
  315. for _, item := range prescriptions {
  316. fmt.Println(item)
  317. if item.Type == 1 { //药品
  318. for _, subItem := range item.HisDoctorAdviceInfo {
  319. total = total + (subItem.Price * subItem.PrescribingNumber)
  320. }
  321. }
  322. if item.Type == 2 { //项目
  323. for _, subItem := range item.HisPrescriptionProject {
  324. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  325. total = total + (subItem.Price * cnt)
  326. }
  327. }
  328. for _, subItem := range item.HisAdditionalCharge {
  329. total = total + (subItem.Price * float64(subItem.Count))
  330. }
  331. }
  332. tm := time.Unix(time.Now().Unix(), 0)
  333. var customs []*models.NewCustomTwo
  334. for _, item := range prescriptions {
  335. if item.Type == 1 { //药品
  336. for _, subItem := range item.HisDoctorAdviceInfo {
  337. cus := &models.NewCustomTwo{
  338. AdviceId: subItem.ID,
  339. ProjectId: 0,
  340. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  341. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  342. FeedetlSn: subItem.FeedetlSn,
  343. Price: fmt.Sprintf("%.2f", subItem.Price),
  344. MedListCodg: subItem.Drug.MedicalInsuranceNumber,
  345. Type: 1,
  346. }
  347. customs = append(customs, cus)
  348. }
  349. }
  350. if item.Type == 2 { //项目
  351. for _, subItem := range item.HisPrescriptionProject {
  352. if subItem.Type == 2 {
  353. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  354. cus := &models.NewCustomTwo{
  355. AdviceId: 0,
  356. ProjectId: subItem.ID,
  357. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  358. Cut: fmt.Sprintf("%.4f", cnt),
  359. FeedetlSn: subItem.FeedetlSn,
  360. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  361. MedListCodg: subItem.HisProject.MedicalCode,
  362. Type: 2,
  363. }
  364. customs = append(customs, cus)
  365. } else {
  366. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  367. cus := &models.NewCustomTwo{
  368. AdviceId: 0,
  369. ProjectId: subItem.ID,
  370. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  371. Cut: fmt.Sprintf("%.4f", cnt),
  372. FeedetlSn: subItem.FeedetlSn,
  373. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  374. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  375. Type: 3,
  376. }
  377. customs = append(customs, cus)
  378. }
  379. }
  380. }
  381. for _, item := range item.HisAdditionalCharge {
  382. cus := &models.NewCustomTwo{
  383. ItemId: item.ID,
  384. AdviceId: 0,
  385. ProjectId: 0,
  386. DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
  387. Cut: fmt.Sprintf("%.4f", float64(item.Count)),
  388. FeedetlSn: item.FeedetlSn,
  389. Price: fmt.Sprintf("%.4f", float64(item.Price)),
  390. MedListCodg: item.XtHisAddtionConfig.Code,
  391. Type: 3,
  392. }
  393. customs = append(customs, cus)
  394. }
  395. }
  396. result, request_log := service.OpKeepAccounts(his.Number, customs)
  397. fmt.Println(result)
  398. fmt.Println(request_log)
  399. var res ResultSettle
  400. res.ResultCode = "0"
  401. res.DocId = "708275799870021632"
  402. res.Amount = "1088.00"
  403. //if err := json.Unmarshal([]byte(result), &res); err != nil {
  404. // utils.ErrorLog("解析失败:%v", err)
  405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  406. // return
  407. //}
  408. if res.ResultCode == "0" {
  409. //allTotal := fmt.Sprintf("%.4f", total)
  410. totals, _ := strconv.ParseFloat(res.Amount, 64)
  411. order := &models.HisOrder{
  412. PsnNo: his.PsnNo,
  413. UserOrgId: org_id,
  414. HisPatientId: his.ID,
  415. PatientId: id,
  416. SettleAccountsDate: recordDateTime,
  417. Ctime: time.Now().Unix(),
  418. Mtime: time.Now().Unix(),
  419. Status: 1,
  420. OrderStatus: 1,
  421. MdtrtId: his.Number,
  422. Number: chrg_bchno,
  423. SetlId: res.DocId,
  424. MedfeeSumamt: totals,
  425. MedType: strconv.Itoa(int(reg_type)),
  426. SettleEndTime: end_time,
  427. SettleStartTime: start_time,
  428. SettleType: settle_accounts_type,
  429. FaPiaoCode: fapiao_code,
  430. FaPiaoNumber: fapiao_number,
  431. Diagnosis: diagnosis_id,
  432. PType: 2,
  433. SetlTime: tm.Format("2006-01-02 15:04:05"),
  434. }
  435. err = service.CreateOrder(order)
  436. if err != nil {
  437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  438. return
  439. }
  440. for _, item := range customs {
  441. var advice_id int64 = 0
  442. var project_id int64 = 0
  443. var item_id int64 = 0
  444. var types int64 = 0
  445. if item.Type == 1 {
  446. advice_id = item.AdviceId
  447. project_id = 0
  448. item_id = 0
  449. } else if item.Type == 2 {
  450. advice_id = 0
  451. item_id = 0
  452. project_id = item.ProjectId
  453. } else if item.Type == 3 {
  454. advice_id = 0
  455. item_id = item.ItemId
  456. project_id = 0
  457. }
  458. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  459. cut, _ := strconv.ParseFloat(item.Cut, 32)
  460. pric, _ := strconv.ParseFloat(item.Price, 32)
  461. info := &models.HisOrderInfo{
  462. OrderNumber: order.Number,
  463. UploadDate: time.Now().Unix(),
  464. AdviceId: advice_id,
  465. DetItemFeeSumamt: detItemFeeSumamt,
  466. Cnt: cut,
  467. Pric: pric,
  468. PatientId: id,
  469. Status: 1,
  470. Mtime: time.Now().Unix(),
  471. Ctime: time.Now().Unix(),
  472. UserOrgId: org_id,
  473. HisPatientId: his.ID,
  474. OrderId: order.ID,
  475. ProjectId: project_id,
  476. Type: types,
  477. ItemId: item_id,
  478. }
  479. service.CreateOrderInfo(info)
  480. }
  481. his.Diagnosis = diagnosis_id
  482. his.SickType = sick_type
  483. his.RegisterType = reg_type
  484. his.MedicalTreatmentType = reg_type
  485. service.UpdataHisPateint(&his)
  486. err = service.UpDatePrescriptionNumber(org_id, ids, chrg_bchno)
  487. err = service.UpDateHisPrescriptionInfoNumber(org_id, id, chrg_bchno, recordDateTime, his_patient_id)
  488. err = service.UpdataOrderStatusThree(chrg_bchno, org_id)
  489. if err == nil {
  490. c.ServeSuccessJSON(map[string]interface{}{
  491. "msg": "记账成功",
  492. })
  493. }
  494. }
  495. }
  496. func (c *CoordinateController) OpCancelKeepAccounts() {
  497. order_id, _ := c.GetInt64("order_id")
  498. admin_user_id, _ := c.GetInt64("admin_user_id")
  499. org_id, _ := c.GetInt64("org_id")
  500. org_id = 4
  501. order, _ := service.GetHisOrderByID(order_id)
  502. if order.ID == 0 {
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  504. return
  505. }
  506. role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  507. result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
  508. var res RefundDetail
  509. if err := json.Unmarshal([]byte(result), &res); err != nil {
  510. utils.ErrorLog("解析失败:%v", err)
  511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  512. return
  513. }
  514. fmt.Println(result)
  515. fmt.Println(request_log)
  516. fmt.Println(res)
  517. flag := 0
  518. isSuccess := false
  519. for _, item := range res.Result {
  520. if item.Code == "200" {
  521. flag = flag + 1
  522. }
  523. }
  524. if len(res.Result) == flag {
  525. isSuccess = true
  526. }
  527. if isSuccess {
  528. err := service.UpdataOrderStatus(order_id, order.Number, org_id)
  529. if err == nil {
  530. c.ServeSuccessJSON(map[string]interface{}{
  531. "msg": "撤销记账成功",
  532. })
  533. } else {
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. return
  536. }
  537. } else {
  538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  539. return
  540. }
  541. }
  542. //func saveLog(result string, request string, infno string, desc string) {
  543. //
  544. // org_id, _ := beego.AppConfig.Int64("org_id")
  545. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  546. // dir := miConfig.OrgName + "日志"
  547. // utils.Mkdir(dir)
  548. // month := time.Unix(1557042972, 0).Format("1")
  549. // year := time.Now().Format("2006")
  550. // month = time.Now().Format("01")
  551. // day := time.Now().Format("02")
  552. // hour := time.Now().Format("15")
  553. // min := time.Now().Format("04")
  554. // sec := time.Now().Format("05")
  555. //
  556. // result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  557. //
  558. // file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  559. // file_name := file + ".txt"
  560. // file_path := miConfig.OrgName + "日志" + "/" + file_name
  561. // exist, _ := utils.PathExists(file_path)
  562. // if exist { //存在
  563. // fmt.Println("存在")
  564. // f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  565. // if err != nil {
  566. // fmt.Println("read fail")
  567. // }
  568. // content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  569. // n, _ := f.Seek(0, 2)
  570. // _, err = f.WriteAt([]byte(content), n)
  571. //
  572. // } else { //不存在
  573. // fmt.Println("文件不存在,创建文件")
  574. // f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  575. // defer f.Close()
  576. // if err != nil {
  577. // } else {
  578. // _, err = f.Write([]byte("记录日志"))
  579. // }
  580. // }
  581. //
  582. //}
  583. type Charset string
  584. const (
  585. UTF8 = Charset("UTF-8")
  586. GB18030 = Charset("GB18030")
  587. )