Kaynağa Gözat

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

csx 4 yıl önce
ebeveyn
işleme
a431c29c54

+ 1 - 1
conf/app.conf Dosyayı Görüntüle

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

+ 7 - 8
controllers/base_api_controller.go Dosyayı Görüntüle

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

+ 18 - 4
controllers/gdyb_controller.go Dosyayı Görüntüle

226
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
226
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
227
 
227
 
228
 	secret_key := c.GetString("secret_key")
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
 	c.ServeSuccessJSON(map[string]interface{}{
238
 	c.ServeSuccessJSON(map[string]interface{}{
233
 		"pre": result,
239
 		"pre": result,
234
 	})
240
 	})
291
 	org_name := c.GetString("org_name")
297
 	org_name := c.GetString("org_name")
292
 	doctor := c.GetString("doctor")
298
 	doctor := c.GetString("doctor")
293
 	secret_key := c.GetString("secret_key")
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
 	c.ServeSuccessJSON(map[string]interface{}{
310
 	c.ServeSuccessJSON(map[string]interface{}{
297
 		"pre": result,
311
 		"pre": result,
298
 	})
312
 	})

+ 71 - 9
controllers/his_api_controller.go Dosyayı Görüntüle

57
 
57
 
58
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
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
 	beego.Router("/api/hisprescription/get", &DialysisApiController{}, "Get:GetLastOrNextHisPrescription")
60
 	beego.Router("/api/hisprescription/get", &DialysisApiController{}, "Get:GetLastOrNextHisPrescription")
68
 
61
 
69
 	beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
62
 	beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
2013
 func (c *HisApiController) Refund() {
2006
 func (c *HisApiController) Refund() {
2014
 	order_id, _ := c.GetInt64("order_id")
2007
 	order_id, _ := c.GetInt64("order_id")
2015
 	number := c.GetString("number")
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
 	adminUser := c.GetAdminUserInfo()
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
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2028
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2019
 	if config.IsOpen == 1 { //对接了医保,走医保流程
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
 	} else {
2085
 	} else {
2022
 		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2086
 		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2023
 		if err == nil {
2087
 		if err == nil {
2028
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2092
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2029
 			return
2093
 			return
2030
 		}
2094
 		}
2031
-
2032
 	}
2095
 	}
2033
-
2034
 }
2096
 }
2035
 
2097
 
2036
 func (this *HisApiController) AdditionalCharge() {
2098
 func (this *HisApiController) AdditionalCharge() {

+ 3 - 3
main.go Dosyayı Görüntüle

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

+ 4 - 4
service/gdyb_service.go Dosyayı Görüntüle

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
 	nonce := GetRandomString(32)
489
 	nonce := GetRandomString(32)
490
 	timestamp := time.Now().Unix()
490
 	timestamp := time.Now().Unix()
491
 	signature := setSignature(timestamp, nonce, secret_key)
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
 	input := make(map[string]interface{})
495
 	input := make(map[string]interface{})
496
 	inputData := make(map[string]interface{})
496
 	inputData := make(map[string]interface{})
497
 	inputMessage["infno"] = "2205" // 交易编码
497
 	inputMessage["infno"] = "2205" // 交易编码
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
 	nonce := GetRandomString(32)
678
 	nonce := GetRandomString(32)
679
 	timestamp := time.Now().Unix()
679
 	timestamp := time.Now().Unix()
680
 	signature := setSignature(timestamp, nonce, secret_key)
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
 	input := make(map[string]interface{})
684
 	input := make(map[string]interface{})
685
 	inputData := make(map[string]interface{})
685
 	inputData := make(map[string]interface{})
686
 	inputMessage["infno"] = "2208" // 交易编码
686
 	inputMessage["infno"] = "2208" // 交易编码

+ 5 - 0
service/his_service.go Dosyayı Görüntüle

793
 
793
 
794
 	return
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
+}