coordinate_controller.go 19KB

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