csx 4 年之前
父節點
當前提交
e9eece1110
共有 1 個文件被更改,包括 66 次插入0 次删除
  1. 66 0
      controllers/his_api_controller.go

+ 66 - 0
controllers/his_api_controller.go 查看文件

@@ -40,6 +40,7 @@ func HisManagerApiRegistRouters() {
40 40
 	beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
41 41
 
42 42
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
43
+	beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
43 44
 
44 45
 }
45 46
 
@@ -1417,6 +1418,71 @@ func (c *HisApiController) RefundNumber() {
1417 1418
 		//}
1418 1419
 	}
1419 1420
 }
1421
+func (c *HisApiController) RefundDetail() {
1422
+	order_id, _ := c.GetInt64("order_id")
1423
+	number := c.GetString("number")
1424
+	record_time := c.GetString("record_time")
1425
+	patient_id, _ := c.GetInt64("patient_id")
1426
+	timeLayout := "2006-01-02"
1427
+	loc, _ := time.LoadLocation("Local")
1428
+	adminUser := c.GetAdminUserInfo()
1429
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1430
+	fmt.Println(err)
1431
+	if err != nil {
1432
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1433
+		return
1434
+	}
1435
+	recordDateTime := theTime.Unix()
1436
+	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
1437
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
1438
+	order, _ := service.GetHisOrderByID(order_id)
1439
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1440
+	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1441
+
1442
+	if config.IsOpen == 1 { //对接了医保,走医保流程
1443
+		api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
1444
+			"&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
1445
+			"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1446
+		resp2, requestErr2 := http.Get(api2)
1447
+		if requestErr2 != nil {
1448
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1449
+			return
1450
+		}
1451
+
1452
+		body2, ioErr2 := ioutil.ReadAll(resp2.Body)
1453
+		if ioErr2 != nil {
1454
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
1455
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1456
+			return
1457
+		}
1458
+		var respJSON2 map[string]interface{}
1459
+		if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
1460
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1461
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1462
+			return
1463
+		}
1464
+
1465
+		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
1466
+		if err == nil {
1467
+			c.ServeSuccessJSON(map[string]interface{}{
1468
+				"msg": "退费成功",
1469
+			})
1470
+		} else {
1471
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1472
+			return
1473
+		}
1474
+	} else {
1475
+		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
1476
+		if err == nil {
1477
+			c.ServeSuccessJSON(map[string]interface{}{
1478
+				"msg": "退费成功",
1479
+			})
1480
+		} else {
1481
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1482
+			return
1483
+		}
1484
+	}
1485
+}
1420 1486
 
1421 1487
 //对账
1422 1488
 func (c *HisApiController) GetCheckAccount() {