Browse Source

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 4 years ago
parent
commit
a431c29c54

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9532
3 3
 runmode = dev
4 4
 
5 5
 #

+ 7 - 8
controllers/base_api_controller.go View File

@@ -70,8 +70,8 @@ func (this *BaseAuthAPIController) Prepare() {
70 70
 	this.BaseAPIController.Prepare()
71 71
 	if this.GetAdminUserInfo() == nil {
72 72
 		var userAdmin models.AdminUser
73
-		userAdmin.Id = 558
74
-		userAdmin.Mobile = "13535547901"
73
+		userAdmin.Id = 1448
74
+		userAdmin.Mobile = "13318599895"
75 75
 
76 76
 		//userAdmin.Id = 597
77 77
 		//userAdmin.Mobile = "19874122664"
@@ -92,7 +92,7 @@ func (this *BaseAuthAPIController) Prepare() {
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94 94
 		adminUserInfo.CurrentOrgId = 4
95
-		adminUserInfo.CurrentAppId = 18
95
+		adminUserInfo.CurrentAppId = 8642
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
98 98
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -316,8 +316,9 @@ func (this *BaseServeAPIController) Prepare() {
316 316
 	this.BaseAPIController.Prepare()
317 317
 	if this.GetAdminUserInfo() == nil {
318 318
 		var userAdmin models.AdminUser
319
-		userAdmin.Id = 558
320
-		userAdmin.Mobile = "13535547901"
319
+		userAdmin.Id = 1448
320
+		userAdmin.Mobile = "13318599895"
321
+
321 322
 		//userAdmin.Id = 597
322 323
 		//userAdmin.Mobile = "19874122664"
323 324
 		userAdmin.IsSuperAdmin = false
@@ -333,16 +334,14 @@ func (this *BaseServeAPIController) Prepare() {
333 334
 		subscibe.Status = 1
334 335
 		subscibe.CreatedTime = 1538035409
335 336
 		subscibe.UpdatedTime = 1538035409
336
-
337 337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338 338
 		subscibes[4] = &subscibe
339 339
 		var adminUserInfo service.AdminUserInfo
340 340
 		adminUserInfo.CurrentOrgId = 4
341
-		adminUserInfo.CurrentAppId = 18
341
+		adminUserInfo.CurrentAppId = 8642
342 342
 		adminUserInfo.AdminUser = &userAdmin
343 343
 		adminUserInfo.Subscibes = subscibes
344 344
 		this.SetSession("admin_user_info", &adminUserInfo)
345
-
346 345
 		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347 346
 		//this.StopRun()
348 347
 	}

+ 18 - 4
controllers/gdyb_controller.go View File

@@ -226,9 +226,15 @@ func (c *GdybController) PostSix() {
226 226
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
227 227
 
228 228
 	secret_key := c.GetString("secret_key")
229
+	fixmedins_code := c.GetString("fixmedins_code")
229 230
 
230
-	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key)
231
-
231
+	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
232
+	var dat map[string]interface{}
233
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
234
+		fmt.Println(dat)
235
+	} else {
236
+		fmt.Println(err)
237
+	}
232 238
 	c.ServeSuccessJSON(map[string]interface{}{
233 239
 		"pre": result,
234 240
 	})
@@ -291,8 +297,16 @@ func (c *GdybController) PostNine() {
291 297
 	org_name := c.GetString("org_name")
292 298
 	doctor := c.GetString("doctor")
293 299
 	secret_key := c.GetString("secret_key")
294
-
295
-	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key)
300
+	fixmedins_code := c.GetString("fixmedins_code")
301
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
302
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
303
+	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
304
+	var dat map[string]interface{}
305
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
306
+		fmt.Println(dat)
307
+	} else {
308
+		fmt.Println(err)
309
+	}
296 310
 	c.ServeSuccessJSON(map[string]interface{}{
297 311
 		"pre": result,
298 312
 	})

+ 71 - 9
controllers/his_api_controller.go View File

@@ -57,13 +57,6 @@ func HisManagerApiRegistRouters() {
57 57
 
58 58
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
59 59
 
60
-	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
61
-
62
-	//新增附加费用
63
-	//beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
64
-
65
-	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
66
-
67 60
 	beego.Router("/api/hisprescription/get", &DialysisApiController{}, "Get:GetLastOrNextHisPrescription")
68 61
 
69 62
 	beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
@@ -2013,11 +2006,82 @@ func (c *HisApiController) GetUploadInfo() {
2013 2006
 func (c *HisApiController) Refund() {
2014 2007
 	order_id, _ := c.GetInt64("order_id")
2015 2008
 	number := c.GetString("number")
2009
+	record_time := c.GetString("record_time")
2010
+	patient_id, _ := c.GetInt64("patient_id")
2011
+
2012
+	timeLayout := "2006-01-02"
2013
+	loc, _ := time.LoadLocation("Local")
2016 2014
 
2017 2015
 	adminUser := c.GetAdminUserInfo()
2016
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
2017
+	if err != nil {
2018
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2019
+		return
2020
+	}
2021
+	recordDateTime := theTime.Unix()
2022
+
2023
+	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2024
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
2025
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2026
+	order, _ := service.GetHisOrderByID(order_id)
2027
+
2018 2028
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2019 2029
 	if config.IsOpen == 1 { //对接了医保,走医保流程
2030
+		api := "http://127.0.0.1:9531/" + "gdyb/nine?psn_no=" + his.PsnNo +
2031
+			"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2032
+			"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2033
+		resp, requestErr := http.Get(api)
2034
+		if requestErr != nil {
2035
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2036
+			return
2037
+		}
2038
+		body, ioErr := ioutil.ReadAll(resp.Body)
2039
+		if ioErr != nil {
2040
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2041
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2042
+			return
2043
+		}
2044
+		var respJSON map[string]interface{}
2045
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2046
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2047
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2048
+			return
2049
+		}
2050
+		respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2051
+		userJSONBytes, _ := json.Marshal(respJSON)
2052
+		fmt.Println(respJSON)
2053
+		fmt.Println(userJSONBytes)
2054
+
2055
+		api2 := "http://127.0.0.1:9531/" + "gdyb/six?psn_no=" + his.PsnNo +
2056
+			"&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2057
+			"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2058
+		resp2, requestErr2 := http.Get(api2)
2059
+		if requestErr2 != nil {
2060
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2061
+			return
2062
+		}
2020 2063
 
2064
+		body2, ioErr2 := ioutil.ReadAll(resp2.Body)
2065
+		if ioErr2 != nil {
2066
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
2067
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2068
+			return
2069
+		}
2070
+		var respJSON2 map[string]interface{}
2071
+		if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
2072
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2073
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2074
+			return
2075
+		}
2076
+		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2077
+		if err == nil {
2078
+			c.ServeSuccessJSON(map[string]interface{}{
2079
+				"msg": "退费成功",
2080
+			})
2081
+		} else {
2082
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2083
+			return
2084
+		}
2021 2085
 	} else {
2022 2086
 		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2023 2087
 		if err == nil {
@@ -2028,9 +2092,7 @@ func (c *HisApiController) Refund() {
2028 2092
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2029 2093
 			return
2030 2094
 		}
2031
-
2032 2095
 	}
2033
-
2034 2096
 }
2035 2097
 
2036 2098
 func (this *HisApiController) AdditionalCharge() {

+ 3 - 3
main.go View File

@@ -12,10 +12,10 @@ func init() {
12 12
 }
13 13
 
14 14
 func main() {
15
-	service.BeginAutoCreateWeekSchedulesJob()
16
-	service.BeginAutoCreateWeekDisinfectionJob()
15
+	//service.BeginAutoCreateWeekSchedulesJob()
16
+	//service.BeginAutoCreateWeekDisinfectionJob()
17 17
 	//service.BeginAutoCreatePlanJob()
18 18
 	//service.AutoClearSchedules()
19
-	service.BeginAutoCreateStaffScheduleJob()
19
+	//service.BeginAutoCreateStaffScheduleJob()
20 20
 	beego.Run()
21 21
 }

+ 4 - 4
service/gdyb_service.go View File

@@ -484,14 +484,14 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
484 484
 }
485 485
 
486 486
 //  门诊费用明细信息撤销
487
-func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
487
+func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
488 488
 	// 生成签名
489 489
 	nonce := GetRandomString(32)
490 490
 	timestamp := time.Now().Unix()
491 491
 	signature := setSignature(timestamp, nonce, secret_key)
492 492
 
493 493
 	// 生成输入报文
494
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", insuplc_admdvs, mdtrtarea_admvs)
494
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
495 495
 	input := make(map[string]interface{})
496 496
 	inputData := make(map[string]interface{})
497 497
 	inputMessage["infno"] = "2205" // 交易编码
@@ -673,14 +673,14 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
673 673
 }
674 674
 
675 675
 //  门诊结算撤销
676
-func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string) string {
676
+func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
677 677
 	// 生成签名
678 678
 	nonce := GetRandomString(32)
679 679
 	timestamp := time.Now().Unix()
680 680
 	signature := setSignature(timestamp, nonce, secret_key)
681 681
 
682 682
 	// 生成输入报文
683
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", "", "")
683
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
684 684
 	input := make(map[string]interface{})
685 685
 	inputData := make(map[string]interface{})
686 686
 	inputMessage["infno"] = "2208" // 交易编码

+ 5 - 0
service/his_service.go View File

@@ -793,3 +793,8 @@ func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, pat
793 793
 
794 794
 	return
795 795
 }
796
+
797
+func GetHisOrderByID(order_id int64) (order models.HisOrder, err error) {
798
+	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
799
+	return
800
+}