Parcourir la source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

XMLWAN il y a 4 ans
Parent
révision
674e17333c

BIN
SSCardDriver_SZ.dll Voir le fichier


+ 355 - 127
controllers/sz/sz_his_api_controller.go Voir le fichier

@@ -13,6 +13,7 @@ import (
13 13
 	"math/rand"
14 14
 	"strconv"
15 15
 	"strings"
16
+	//"strings"
16 17
 	"syscall"
17 18
 	"time"
18 19
 	"unsafe"
@@ -74,14 +75,14 @@ type ResultOne struct {
74 75
 	Operatorpass       string `json:"operatorPass"`
75 76
 	Transbody          struct {
76 77
 		Ckc618     string  `json:"ckc618"`
77
-		Akc264     int     `json:"akc264"`
78
+		Akc264     float64 `json:"akc264"`
78 79
 		Akb068     int     `json:"akb068"`
79
-		Akb066     int     `json:"akb066"`
80
+		Akb066     float64 `json:"akb066"`
80 81
 		Akb067     int     `json:"akb067"`
81 82
 		Aae240     float64 `json:"aae240"`
82 83
 		Outputlist []struct {
83
-			Aaa036 string `json:"aaa036"`
84
-			Aae019 int    `json:"aae019"`
84
+			Aaa036 string  `json:"aaa036"`
85
+			Aae019 float64 `json:"aae019"`
85 86
 		} `json:"outputlist"`
86 87
 		Outputlist2 []interface{} `json:"outputlist2"`
87 88
 	} `json:"transBody"`
@@ -114,12 +115,12 @@ type ResultTwo struct {
114 115
 		Akb067      float64 `json:"akb067"`
115 116
 		Aae240      float64 `json:"aae240"`
116 117
 		Outputlist1 []struct {
117
-			Aka111 string `json:"aka111"`
118
-			Bka058 int    `json:"bka058"`
118
+			Aka111 string  `json:"aka111"`
119
+			Bka058 float64 `json:"bka058"`
119 120
 		} `json:"outputlist1"`
120 121
 		Outputlist2 []struct {
121
-			Aaa036 string `json:"aaa036"`
122
-			Aae019 int    `json:"aae019"`
122
+			Aaa036 string  `json:"aaa036"`
123
+			Aae019 float64 `json:"aae019"`
123 124
 		} `json:"outputlist2"`
124 125
 		Outputlist3 []interface{} `json:"outputlist3"`
125 126
 	} `json:"transBody"`
@@ -171,24 +172,24 @@ type ResultFour struct {
171 172
 	Operatorpass       string `json:"operatorPass"`
172 173
 	Transbody          struct {
173 174
 		Akc190      string  `json:"akc190"`
174
-		Akc194      int     `json:"akc194"`
175
+		Akc194      float64 `json:"akc194"`
175 176
 		Bae917      int64   `json:"bae917"`
176 177
 		Aka018      string  `json:"aka018"`
177 178
 		Aka030      string  `json:"aka030"`
178 179
 		Ckc618      string  `json:"ckc618"`
179
-		Akc264      int     `json:"akc264"`
180
-		Akb068      int     `json:"akb068"`
181
-		Akb066      int     `json:"akb066"`
182
-		Akb067      int     `json:"akb067"`
180
+		Akc264      float64 `json:"akc264"`
181
+		Akb068      float64 `json:"akb068"`
182
+		Akb066      float64 `json:"akb066"`
183
+		Akb067      float64 `json:"akb067"`
183 184
 		Cke298      float64 `json:"cke298"`
184 185
 		Aae240      float64 `json:"aae240"`
185 186
 		Outputlist2 []struct {
186
-			Aka111 string `json:"aka111"`
187
-			Bka058 int    `json:"bka058"`
187
+			Aka111 string  `json:"aka111"`
188
+			Bka058 float64 `json:"bka058"`
188 189
 		} `json:"outputlist2"`
189 190
 		Outputlist3 []struct {
190
-			Aaa036 string `json:"aaa036"`
191
-			Aae019 int    `json:"aae019"`
191
+			Aaa036 string  `json:"aaa036"`
192
+			Aae019 float64 `json:"aae019"`
192 193
 		} `json:"outputlist3"`
193 194
 	} `json:"transBody"`
194 195
 	Verifycode         string `json:"verifyCode"`
@@ -199,7 +200,36 @@ type ResultFour struct {
199 200
 	Caz055             string `json:"caz055"`
200 201
 	Aae501             string `json:"aae501"`
201 202
 }
202
-
203
+type ResultFive struct {
204
+	Transtime          string `json:"transTime"`
205
+	Transtype          string `json:"transType"`
206
+	Transreturncode    string `json:"transReturnCode"`
207
+	Transreturnmessage string `json:"transReturnMessage"`
208
+	Transversion       string `json:"transVersion"`
209
+	Serialnumber       string `json:"serialNumber"`
210
+	Cardarea           string `json:"cardArea"`
211
+	Hospitalcode       string `json:"hospitalCode"`
212
+	Operatorcode       string `json:"operatorCode"`
213
+	Operatorname       string `json:"operatorName"`
214
+	Operatorpass       string `json:"operatorPass"`
215
+	Transbody          struct {
216
+		Akc190     string `json:"akc190"`
217
+		Listsize   int    `json:"listsize"`
218
+		Outputlist []struct {
219
+			Aae072 string `json:"aae072"`
220
+			Bkf500 string `json:"bkf500"`
221
+			Baz700 string `json:"baz700"`
222
+			Bce574 string `json:"bce574"`
223
+		} `json:"outputlist"`
224
+	} `json:"transBody"`
225
+	Verifycode         string `json:"verifyCode"`
226
+	Extenddeviceid     string `json:"extendDeviceId"`
227
+	Transchannel       string `json:"transChannel"`
228
+	Extenduserid       string `json:"extendUserId"`
229
+	Extendserialnumber string `json:"extendSerialNumber"`
230
+	Caz055             string `json:"caz055"`
231
+	Aae501             string `json:"aae501"`
232
+}
203 233
 type SZHisApiController struct {
204 234
 	controllers.BaseAuthAPIController
205 235
 }
@@ -216,6 +246,8 @@ func SZHisManagerApiRegistRouters() {
216 246
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
217 247
 	//查询交易
218 248
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
249
+	//撤销明细
250
+	beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
219 251
 
220 252
 	//机构药品目录备案
221 253
 	beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
@@ -322,34 +354,28 @@ func (c *SZHisApiController) GetRegisterInfo() {
322 354
 		custom_project_name = "普通门诊"
323 355
 		allPrice = registration_fee + medical_expenses
324 356
 		break
325
-	case 2:
357
+	case 3:
326 358
 		custom_code = "110200002-2"
327 359
 		custom_project_name = "主任医师"
328 360
 		allPrice = registration_fee + medical_expenses
329 361
 
330 362
 		break
331
-	case 3:
363
+	case 2:
332 364
 		custom_code = "110200002-3"
333 365
 		custom_project_name = "副主任医师"
334 366
 		allPrice = registration_fee + medical_expenses
335 367
 
336 368
 		break
337 369
 	case 4:
338
-		custom_code = "110200003"
339
-		custom_project_name = "急诊诊查费"
340
-		allPrice = registration_fee + medical_expenses
341
-
370
+		custom_code = "0"
371
+		custom_project_name = "免受诊金"
372
+		allPrice = 0
342 373
 		break
343 374
 	case 5:
344 375
 		custom_code = "110200002-1"
345 376
 		custom_project_name = "专家"
346 377
 		allPrice = registration_fee + medical_expenses
347 378
 
348
-		break
349
-	case 6:
350
-		custom_code = "0"
351
-		custom_project_name = "免受诊金"
352
-		allPrice = 0
353 379
 		break
354 380
 	}
355 381
 
@@ -374,13 +400,14 @@ func (c *SZHisApiController) GetRegisterInfo() {
374 400
 
375 401
 		//流水号
376 402
 		//
377
-		//number := miConfig.Code + year + month + day +
378
-		//	fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
379
-		mz_number := year + month + day + strconv.FormatInt(patient_id, 10)
380
-		number := miConfig.Code + year + month + day + "2233445"
381
-		//verifyCode, version_code := ReadCardGetCode("MZ002" + "|" + number + "|" + miConfig.Code)
382
-		verifyCode := "000000|4d221ed0d796a493ada20244272962d4"
383
-		version_code := "0.03"
403
+		number := miConfig.Code + year + month + day +
404
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
405
+		mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
406
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
407
+		//number := miConfig.Code + year + month + day + "1590000"
408
+		verifyCode, version_code := ReadCardGetCode("MZ002" + "|" + number + "|" + miConfig.Code)
409
+		//verifyCode := "000000|4c871a545d1006754246a50a85c3a353"
410
+		//version_code := "V0.3"
384 411
 		//1.判断读卡类型
385 412
 		//2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
386 413
 		//yiliao_number, id_card_number,verifyCode, err, ret4 := ReadBasCardGetNumber(number)
@@ -448,13 +475,12 @@ func (c *SZHisApiController) GetRegisterInfo() {
448 475
 						"msg": "挂号成功",
449 476
 					})
450 477
 				} else {
451
-
478
+					c.ServeSuccessJSON(map[string]interface{}{
479
+						"failed_code": -10,
480
+						"msg":         res.Transreturnmessage,
481
+					})
482
+					return
452 483
 				}
453
-				//
454
-				//} else {
455
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
456
-				//	return
457
-				//}
458 484
 
459 485
 			} else { //异地就医流程
460 486
 				//异地走鉴权流程
@@ -514,7 +540,11 @@ func (c *SZHisApiController) GetRegisterInfo() {
514 540
 						"msg": "挂号成功",
515 541
 					})
516 542
 				} else {
517
-
543
+					c.ServeSuccessJSON(map[string]interface{}{
544
+						"failed_code": -10,
545
+						"msg":         res.Transreturnmessage,
546
+					})
547
+					return
518 548
 				}
519 549
 
520 550
 				//}
@@ -576,7 +606,11 @@ func (c *SZHisApiController) GetRegisterInfo() {
576 606
 						"msg": "挂号成功",
577 607
 					})
578 608
 				} else {
579
-
609
+					c.ServeSuccessJSON(map[string]interface{}{
610
+						"failed_code": -10,
611
+						"msg":         res.Transreturnmessage,
612
+					})
613
+					return
580 614
 				}
581 615
 
582 616
 			} else { //异地就医需要走鉴权流程
@@ -633,7 +667,11 @@ func (c *SZHisApiController) GetRegisterInfo() {
633 667
 						"msg": "挂号成功",
634 668
 					})
635 669
 				} else {
636
-
670
+					c.ServeSuccessJSON(map[string]interface{}{
671
+						"failed_code": -10,
672
+						"msg":         res.Transreturnmessage,
673
+					})
674
+					return
637 675
 				}
638 676
 
639 677
 			}
@@ -646,7 +684,7 @@ func (c *SZHisApiController) GetRegisterInfo() {
646 684
 
647 685
 //上传明细----预结算----确认订单
648 686
 func (c *SZHisApiController) GetUploadInfo() {
649
-	patient_id, _ := c.GetInt64("id")
687
+	patient_id, _ := c.GetInt64("patient_id")
650 688
 	record_time := c.GetString("record_time")
651 689
 	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
652 690
 	admin_user_id, _ := c.GetInt64("admin_user_id")
@@ -709,16 +747,26 @@ func (c *SZHisApiController) GetUploadInfo() {
709 747
 		ids = append(ids, item.ID)
710 748
 	}
711 749
 
750
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
751
+
752
+	adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
753
+
712 754
 	adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
713 755
 	his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
714
-	number := his.MzNumber
756
+	//number := his.MzNumber
757
+
715 758
 	mz_number := his.Number
716 759
 
760
+	number := miConfig.Code + year + month + day +
761
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
762
+	//number := miConfig.Code + year + month + day + "1590003"
763
+
717 764
 	var doctor_name string
718 765
 	var doctor_code string
719 766
 
720 767
 	var drug_doctor_code string
721
-	drug_doctor_code = "H24962918"
768
+	drug_doctor_code = adminRole_two.DoctorCode
769
+	drug_doctor_name := adminRole_two.UserName
722 770
 
723 771
 	if adminRole.ID == 0 {
724 772
 		doctor_name = "黄亦轩"
@@ -728,14 +776,20 @@ func (c *SZHisApiController) GetUploadInfo() {
728 776
 		doctor_code = strconv.FormatInt(admin_user_id, 10)
729 777
 	}
730 778
 
731
-	//verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
732
-	verifyCode := ""
733
-	version_code := ""
779
+	verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
780
+	//verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
781
+	//version_code := "V0.3"
734 782
 	var customs []*models.CustomDetail
735 783
 	for _, item := range prescriptions {
784
+		fmt.Println("111111")
736 785
 		if item.Type == 1 { //药品
786
+			fmt.Println("222222")
737 787
 			for _, subItem := range item.HisDoctorAdviceInfo {
788
+				fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
789
+
738 790
 				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
791
+					fmt.Println("3333333")
792
+
739 793
 					_, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
740 794
 					detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
741 795
 					price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
@@ -752,7 +806,7 @@ func (c *SZHisApiController) GetUploadInfo() {
752 806
 						DoctorCode:         doctor_code,
753 807
 						Total:              detItemFeeSumamt,
754 808
 						DoseCode:           dose_code,
755
-						Spec:               strconv.FormatFloat(subItem.DrugSpec, 'E', -1, 64) + subItem.DrugSpecUnit,
809
+						Spec:               subItem.BaseDrugLib.DrugSpec,
756 810
 					}
757 811
 					customs = append(customs, cus)
758 812
 				}
@@ -811,22 +865,6 @@ func (c *SZHisApiController) GetUploadInfo() {
811 865
 		//}
812 866
 	}
813 867
 
814
-	//c1 := &models.CustomDetail{
815
-	//	PrescriptionNumber: chrg_bchno,
816
-	//	OrderType:          "1",
817
-	//	ChargeSerialNumber: "202101130843076996-1-488",
818
-	//	Code:               "86901187000367",
819
-	//	CodeName:           "普瑞巴林胶囊",
820
-	//	Flag:               "1",
821
-	//	Price:              10.00,
822
-	//	Count:              10.00,
823
-	//	ChargeOrderDate:    year + month + day,
824
-	//	DoctorCode:         doctor_code,
825
-	//	Total:              100.00,
826
-	//	DoseCode:           "",
827
-	//	Spec:               strconv.FormatFloat(75.00, 'E', -1, 64) + "mg",
828
-	//}
829
-
830 868
 	var pagesize int = 50
831 869
 	var start int = 1
832 870
 	var stop int
@@ -882,13 +920,20 @@ func (c *SZHisApiController) GetUploadInfo() {
882 920
 				Stage:      10,
883 921
 			}
884 922
 			service.CreateErrMsgLog(errlog)
885
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
923
+
924
+			c.ServeSuccessJSON(map[string]interface{}{
925
+				"failed_code": -10,
926
+				"msg":         res.Transreturnmessage,
927
+			})
928
+
929
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
886 930
 			return
887 931
 		}
888 932
 		//设置变量,根据变量的值来判断上传是否成功
889 933
 	}
890 934
 
891 935
 	if isSuccess == true {
936
+
892 937
 		order := &models.HisOrder{
893 938
 			UserOrgId:           adminUser.CurrentOrgId,
894 939
 			HisPatientId:        0,
@@ -911,7 +956,11 @@ func (c *SZHisApiController) GetUploadInfo() {
911 956
 			SettleEndTime:       end_time,
912 957
 			Creator:             admin_user_id,
913 958
 			Modify:              admin_user_id,
959
+			OrgSetlNumber:       number,
914 960
 		}
961
+		data, _ := json.Marshal(ress)
962
+		order.DetailLog = string(data)
963
+
915 964
 		err = service.CreateOrder(order)
916 965
 		if err != nil {
917 966
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
@@ -982,10 +1031,10 @@ func (c *SZHisApiController) GetUploadInfo() {
982 1031
 				total = total + (subItem.Price * float64(subItem.Count))
983 1032
 			}
984 1033
 		}
985
-		//verifyCode, version_code := ReadCardGetCode("FY004" + "|" + number + "|" + miConfig.Code)
986
-		verifyCode := ""
987
-		version_code := ""
988
-		result_two := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, verifyCode, number, mz_number, version_code)
1034
+		verifyCode, version_code := ReadCardGetCode("FY004" + "|" + number + "|" + miConfig.Code)
1035
+		//verifyCode := "000000|08728e77da60a4857803af17aba9caae"
1036
+		//version_code := "V0.3"
1037
+		result_two := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name)
989 1038
 		var dat map[string]interface{}
990 1039
 		if err := json.Unmarshal([]byte(result_two), &dat); err == nil {
991 1040
 			fmt.Println(dat)
@@ -1004,7 +1053,12 @@ func (c *SZHisApiController) GetUploadInfo() {
1004 1053
 				"msg": "预结算成功",
1005 1054
 			})
1006 1055
 		} else {
1007
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
1056
+
1057
+			c.ServeSuccessJSON(map[string]interface{}{
1058
+				"failed_code": -10,
1059
+				"msg":         res.Transreturnmessage,
1060
+			})
1061
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
1008 1062
 			return
1009 1063
 		}
1010 1064
 	} else {
@@ -1099,27 +1153,32 @@ func (c *SZHisApiController) GetSettleInfo() {
1099 1153
 				}
1100 1154
 			}
1101 1155
 
1156
+			patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
1157
+
1158
+			adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
1159
+
1160
+			var drug_doctor string
1161
+			drug_doctor = adminRole_two.DoctorCode
1162
+			drug_doctor_name := adminRole_two.UserName
1102 1163
 			//结算流程
1103 1164
 			var doctor_name string
1104 1165
 			var doctor_code string
1105 1166
 			if roles.ID == 0 {
1106 1167
 				doctor_name = "黄亦轩"
1107
-				doctor_code = "H24962918"
1168
+				doctor_code = "1010"
1108 1169
 			} else {
1109 1170
 				doctor_name = roles.UserName
1110 1171
 				doctor_code = strconv.FormatInt(admin_user_id, 10)
1111 1172
 			}
1112
-			number := his.MzNumber
1173
+			number := order_src.OrgSetlNumber
1113 1174
 			mz_number := his.Number
1114
-			//verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
1175
+			verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
1115 1176
 
1116
-			verifyCode := ""
1117
-			version_code := ""
1118
-			//verifyCode := "000000|eb7acc3ec61eb5e3fd12a3586ad3a9c5"
1119
-			//version_code := "0.03"
1177
+			//verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
1178
+			//version_code := "V0.3"
1120 1179
 			//yiliao_number, id_card_number,verifyCode,versionCode, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
1121 1180
 			yiliao_number := his.YiliaoNumber
1122
-			result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code)
1181
+			result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
1123 1182
 			var dat map[string]interface{}
1124 1183
 			if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
1125 1184
 				fmt.Println(dat)
@@ -1154,7 +1213,6 @@ func (c *SZHisApiController) GetSettleInfo() {
1154 1213
 				order_src.PsnCashPay = res.Transbody.Akb067
1155 1214
 				order_src.PsnPartAmt = res.Transbody.Akb067
1156 1215
 				order_src.AccountPrice = res.Transbody.Aae240
1157
-				order_src.OrgSetlNumber = number
1158 1216
 				order_src.MzNumber = mz_number
1159 1217
 				order_src.YiliaoNumber = yiliao_number
1160 1218
 				setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
@@ -1166,12 +1224,20 @@ func (c *SZHisApiController) GetSettleInfo() {
1166 1224
 				setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
1167 1225
 				detailStrThree := string(setlDetailThree)
1168 1226
 				order_src.SzMedicineInsuranceInfo = detailStrThree
1227
+				order_src.Cainfo = result_three
1228
+
1169 1229
 				err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
1170 1230
 				err = service.UpDateOrder(order_src)
1231
+
1171 1232
 				c.ServeSuccessJSON(map[string]interface{}{
1172 1233
 					"msg": "结算成功",
1173 1234
 				})
1174 1235
 			} else {
1236
+				//version_code := "0.03"
1237
+				c.ServeSuccessJSON(map[string]interface{}{
1238
+					"failed_code": -10,
1239
+					"msg":         res.Transreturnmessage,
1240
+				})
1175 1241
 
1176 1242
 			}
1177 1243
 		} else {
@@ -1188,26 +1254,27 @@ func (c *SZHisApiController) GetSettleInfo() {
1188 1254
 //当月退费
1189 1255
 func (c *SZHisApiController) Refund() {
1190 1256
 	order_id, _ := c.GetInt64("order_id")
1191
-	//record_time := c.GetString("record_time")
1192
-	//patient_id, _ := c.GetInt64("patient_id")
1257
+	record_time := c.GetString("record_time")
1258
+	patient_id, _ := c.GetInt64("patient_id")
1193 1259
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1194
-	//timeLayout := "2006-01-02"
1195
-	//loc, _ := time.LoadLocation("Local")
1260
+	timeLayout := "2006-01-02"
1261
+	loc, _ := time.LoadLocation("Local")
1196 1262
 	adminUser := c.GetAdminUserInfo()
1197
-	//theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1198
-	//fmt.Println(err)
1199
-	//if err != nil {
1200
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1201
-	//	return
1202
-	//}
1203
-	//recordDateTime := theTime.Unix()
1263
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1264
+	fmt.Println(err)
1265
+	if err != nil {
1266
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1267
+		return
1268
+	}
1269
+	recordDateTime := theTime.Unix()
1270
+	fmt.Println(recordDateTime)
1204 1271
 	var order models.HisOrder
1205 1272
 	order, _ = service.GetHisOrderByID(order_id)
1206 1273
 	if order.ID == 0 {
1207 1274
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
1208 1275
 		return
1209 1276
 	}
1210
-
1277
+	his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
1211 1278
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1212 1279
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1213 1280
 	//结算流程
@@ -1221,20 +1288,25 @@ func (c *SZHisApiController) Refund() {
1221 1288
 		doctor_code = strconv.FormatInt(admin_user_id, 10)
1222 1289
 
1223 1290
 	}
1224
-	//month := time.Unix(1557042972, 0).Format("1")
1225
-	//year := time.Now().Format("2006")
1226
-	//month = time.Now().Format("01")
1227
-	//day := time.Now().Format("02")
1291
+	month := time.Unix(1557042972, 0).Format("1")
1292
+	year := time.Now().Format("2006")
1293
+	month = time.Now().Format("01")
1294
+	day := time.Now().Format("02")
1295
+	//number := miConfig.Code  + year + month + day + "1367866"
1296
+	number := miConfig.Code + year + month + day +
1297
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
1298
+	//number := miConfig.Code + year + month + day + "1590003"
1299
+
1228 1300
 	//流水号
1229 1301
 	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1230
-	//verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
1231
-	version_code := "0.03"
1232
-
1233
-	verifyCode := "000000|9703b55d0862204b631e43fa922394b5"
1302
+	verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
1303
+	//version_code := "V0.3"
1304
+	//
1305
+	//verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
1234 1306
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1235 1307
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1236 1308
 
1237
-		result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, "", version_code)
1309
+		result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
1238 1310
 		fmt.Println(result)
1239 1311
 
1240 1312
 		var dat map[string]interface{}
@@ -1251,10 +1323,17 @@ func (c *SZHisApiController) Refund() {
1251 1323
 			return
1252 1324
 		}
1253 1325
 		if res.Transreturncode == "00000000" {
1326
+			service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
1327
+			service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
1254 1328
 			c.ServeSuccessJSON(map[string]interface{}{
1255 1329
 				"msg": "退费成功",
1256 1330
 			})
1257 1331
 		} else {
1332
+			c.ServeSuccessJSON(map[string]interface{}{
1333
+				"failed_code": -10,
1334
+				"msg":         res.Transreturnmessage,
1335
+			})
1336
+
1258 1337
 		}
1259 1338
 	}
1260 1339
 }
@@ -1378,9 +1457,9 @@ func (c *SZHisApiController) GetSettleAccounts() {
1378 1457
 	//流水号
1379 1458
 	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1380 1459
 	//fmt.Println(number_two)
1381
-	//verifyCode,version_code := ReadCardGetCode("JY001" + "|" + number_two + "|" + miConfig.Code)
1382
-	version_code := "0.03"
1383
-	verifyCode := "000000|31b7646eda5bcbf5f5ef5e82d368a0e1"
1460
+	verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
1461
+	//version_code := "V0.3"
1462
+	//verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
1384 1463
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1385 1464
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1386 1465
 
@@ -1403,31 +1482,158 @@ func (c *SZHisApiController) GetSettleAccounts() {
1403 1482
 		if res.Transreturncode == "00000000" {
1404 1483
 			c.ServeSuccessJSON(map[string]interface{}{})
1405 1484
 		} else {
1485
+			c.ServeSuccessJSON(map[string]interface{}{
1486
+				"failed_code": -10,
1487
+				"msg":         res.Transreturnmessage,
1488
+			})
1489
+		}
1490
+	}
1491
+}
1492
+
1493
+//费用录入取消
1494
+func (c *SZHisApiController) CancelOrderDetail() {
1495
+	order_id, _ := c.GetInt64("order_id")
1496
+	record_time := c.GetString("record_time")
1497
+	patient_id, _ := c.GetInt64("patient_id")
1498
+	admin_user_id, _ := c.GetInt64("admin_user_id")
1499
+	timeLayout := "2006-01-02"
1500
+	loc, _ := time.LoadLocation("Local")
1501
+	adminUser := c.GetAdminUserInfo()
1502
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1503
+	fmt.Println(err)
1504
+	if err != nil {
1505
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1506
+		return
1507
+	}
1508
+	recordDateTime := theTime.Unix()
1509
+	var order models.HisOrder
1510
+	order, _ = service.GetHisOrderByID(order_id)
1511
+
1512
+	if order.ID == 0 {
1513
+		order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
1514
+
1515
+	}
1516
+
1517
+	order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
1518
+
1519
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1520
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1521
+	//结算流程
1522
+	var doctor_name string
1523
+	var doctor_code string
1524
+	if roles.ID == 0 {
1525
+		doctor_name = "黄亦轩"
1526
+		doctor_code = "1001"
1527
+	} else {
1528
+		doctor_name = roles.UserName
1529
+		doctor_code = strconv.FormatInt(admin_user_id, 10)
1530
+
1531
+	}
1532
+	var customs []*models.CustomDetail
1533
+
1534
+	for _, item := range order_infos {
1535
+		cus := &models.CustomDetail{
1536
+			PrescriptionNumber: item.OrderNumber,
1537
+			ChargeSerialNumber: item.FeedetlSn,
1538
+		}
1539
+		customs = append(customs, cus)
1540
+	}
1541
+
1542
+	verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
1543
+
1544
+	var pagesize int = 50
1545
+	var start int = 1
1546
+	var stop int
1547
+	var pagecount int
1548
+	var curpage int
1549
+	var isSuccess bool = true
1550
+	var ress []*ResultFive
1551
+
1552
+	//总页数,向上取整,注意除之前要先转换类型为float64
1553
+	pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
1554
+
1555
+	for curpage = 1; curpage <= pagecount; curpage++ {
1556
+		if curpage == 1 {
1557
+			start = 1
1558
+		} else {
1559
+			start = (curpage-1)*pagesize + 1
1406 1560
 		}
1561
+		stop = curpage * pagesize
1562
+		if stop > len(customs) {
1563
+			stop = len(customs)
1564
+		}
1565
+
1566
+		result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, order.MzNumber, version_code)
1567
+		fmt.Println(result)
1568
+
1569
+		var dat map[string]interface{}
1570
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
1571
+			fmt.Println(dat)
1572
+		} else {
1573
+			fmt.Println(err)
1574
+		}
1575
+		userJSONBytes, _ := json.Marshal(dat)
1576
+		var res ResultFive
1577
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1578
+			utils.ErrorLog("解析失败:%v", err)
1579
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1580
+			return
1581
+		}
1582
+		if res.Transreturncode == "00000000" {
1583
+			ress = append(ress, &res)
1584
+		} else {
1585
+			isSuccess = false
1586
+			//预结算报错
1587
+			errlog := &models.HisOrderError{
1588
+				UserOrgId:  adminUser.CurrentOrgId,
1589
+				Ctime:      time.Now().Unix(),
1590
+				Mtime:      time.Now().Unix(),
1591
+				ErrMsg:     res.Transreturnmessage,
1592
+				Status:     1,
1593
+				PatientId:  patient_id,
1594
+				RecordTime: recordDateTime,
1595
+				Stage:      11,
1596
+			}
1597
+			service.CreateErrMsgLog(errlog)
1598
+
1599
+			c.ServeSuccessJSON(map[string]interface{}{
1600
+				"faild_code": -10,
1601
+				"msg":        res.Transreturnmessage,
1602
+			})
1603
+			return
1604
+		}
1605
+	}
1606
+	if isSuccess == true {
1607
+		c.ServeSuccessJSON(map[string]interface{}{
1608
+			"msg": "撤销成功",
1609
+		})
1407 1610
 	}
1408 1611
 }
1409 1612
 
1410 1613
 //获取verifyCode
1411
-//func ReadCardGetCode(request string) (string, string) {
1412
-//	DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
1413
-//	readCards := DllDef2.MustFindProc("iVerifyCode")
1414
-//	str := request
1415
-//	str3 := make([]byte, 256)
1416
-//	ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
1417
-//	fmt.Println(":", string(str3))
1418
-//
1419
-//	if ret4 == 0 {
1420
-//		result := string(str3)
1421
-//		fmt.Println(result)
1422
-//		result_arr := strings.Split(result, "|")
1423
-//		verifyCode := result_arr[0] + "|" + result_arr[1]
1424
-//		versionCode := result_arr[2]
1425
-//
1426
-//		return verifyCode, versionCode
1427
-//
1428
-//	}
1429
-//	return "", ""
1430
-//}
1614
+func ReadCardGetCode(request string) (string, string) {
1615
+	request = request + "|"
1616
+	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
1617
+	readCards := DllDef2.MustFindProc("iVerifyCode")
1618
+	str := request
1619
+	str3 := make([]byte, 256)
1620
+	ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
1621
+	fmt.Println(":", string(str3))
1622
+
1623
+	//fmt.Println(":",ConvertByte2String(str3,GB18030) )
1624
+
1625
+	if ret4 == 0 {
1626
+		result := string(str3)
1627
+		fmt.Println(result)
1628
+		result_arr := strings.Split(result, "|")
1629
+		verifyCode := result_arr[0] + "|" + result_arr[1]
1630
+		versionCode := result_arr[2]
1631
+
1632
+		return verifyCode, versionCode
1633
+
1634
+	}
1635
+	return "", ""
1636
+}
1431 1637
 
1432 1638
 //
1433 1639
 ////读卡
@@ -2425,3 +2631,25 @@ func (c *SZHisApiController) GetGoodsList() {
2425 2631
 
2426 2632
 	}
2427 2633
 }
2634
+
2635
+//type Charset string
2636
+
2637
+//const (
2638
+//	UTF8    = Charset("UTF-8")
2639
+//	GB18030 = Charset("GB18030")
2640
+//)
2641
+//func ConvertByte2String(byte []byte, charset Charset) string {
2642
+//
2643
+//	var str string
2644
+//	switch charset {
2645
+//	case GB18030:
2646
+//		decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
2647
+//		str = string(decodeBytes)
2648
+//	case UTF8:
2649
+//		fallthrough
2650
+//	default:
2651
+//		str = string(byte)
2652
+//	}
2653
+//
2654
+//	return str
2655
+//}

+ 3 - 0
models/his_models.go Voir le fichier

@@ -668,6 +668,9 @@ type HisOrder struct {
668 668
 	SettleStartTime int64 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
669 669
 	SettleEndTime   int64 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
670 670
 
671
+	RefundLog string `gorm:"column:refund_log" json:"refund_log" form:"refund_log"`
672
+	DetailLog string `gorm:"column:detail_log" json:"detail_log" form:"detail_log"`
673
+
671 674
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
672 675
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
673 676
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`

+ 49 - 16
models/patient_models.go Voir le fichier

@@ -313,22 +313,55 @@ func (DialysisSolution) TableName() string {
313 313
 }
314 314
 
315 315
 type UserAdminRole struct {
316
-	ID              int64           `gorm:"column:id" json:"id"`
317
-	AdminUserId     int64           `gorm:"column:admin_user_id" json:"admin_user_id"`
318
-	OrgId           int64           `gorm:"column:org_id" json:"org_id"`
319
-	AppId           int64           `gorm:"column:app_id" json:"app_id"`
320
-	RoleId          int64           `gorm:"column:role_id" json:"role_id"`
321
-	UserName        string          `gorm:"column:user_name" json:"user_name"`
322
-	Avatar          string          `gorm:"column:avatar" json:"avatar"`
323
-	UserType        int64           `gorm:"column:user_type" json:"user_type"`
324
-	UserTitle       int64           `gorm:"column:user_title" json:"user_title"`
325
-	Intro           string          `gorm:"column:intro" json:"intro"`
326
-	Status          int64           `gorm:"column:status" json:"status"`
327
-	Ctime           int64           `gorm:"column:ctime" json:"ctime"`
328
-	Mtime           int64           `gorm:"column:mtime" json:"mtime"`
329
-	Department      string          `gorm:"column:department" json:"department"`
330
-	DepartmentId    int64           `gorm:"column:department_id" json:"department_id"`
331
-	XtHisDepartment XtHisDepartment `json:"department" gorm:"foreignkey:DepartmentId;AssociationForeignKey:ID;"`
316
+	ID                                      int64           `gorm:"column:id" json:"id" form:"id"`
317
+	AdminUserId                             int64           `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
318
+	OrgId                                   int64           `gorm:"column:org_id" json:"org_id" form:"org_id"`
319
+	AppId                                   int64           `gorm:"column:app_id" json:"app_id" form:"app_id"`
320
+	RoleId                                  int64           `gorm:"column:role_id" json:"role_id" form:"role_id"`
321
+	UserName                                string          `gorm:"column:user_name" json:"user_name" form:"user_name"`
322
+	Avatar                                  string          `gorm:"column:avatar" json:"avatar" form:"avatar"`
323
+	UserType                                int64           `gorm:"column:user_type" json:"user_type" form:"user_type"`
324
+	UserTitle                               int64           `gorm:"column:user_title" json:"user_title" form:"user_title"`
325
+	Intro                                   string          `gorm:"column:intro" json:"intro" form:"intro"`
326
+	Status                                  int64           `gorm:"column:status" json:"status" form:"status"`
327
+	Ctime                                   int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
328
+	Mtime                                   int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
329
+	UserTitleName                           string          `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
330
+	RoleIds                                 string          `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
331
+	Message                                 string          `gorm:"column:message" json:"message" form:"message"`
332
+	Sex                                     int64           `gorm:"column:sex" json:"sex" form:"sex"`
333
+	Birthday                                int64           `gorm:"column:birthday" json:"birthday" form:"birthday"`
334
+	Sort                                    int64           `gorm:"column:sort" json:"sort" form:"sort"`
335
+	IsSort                                  int64           `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
336
+	Department                              string          `gorm:"column:department" json:"department" form:"department"`
337
+	DepartmentId                            int64           `gorm:"column:department_id" json:"department_id" form:"department_id"`
338
+	Age                                     int64           `gorm:"column:age" json:"age" form:"age"`
339
+	Nation                                  string          `gorm:"column:nation" json:"nation" form:"nation"`
340
+	CardType                                int64           `gorm:"column:card_type" json:"card_type" form:"card_type"`
341
+	IdCard                                  string          `gorm:"column:id_card" json:"id_card" form:"id_card"`
342
+	Education                               int64           `gorm:"column:education" json:"education" form:"education"`
343
+	StudyMajorName                          string          `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
344
+	WorkMajorName                           string          `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
345
+	RoleType                                int64           `gorm:"column:role_type" json:"role_type" form:"role_type"`
346
+	MedicalCode                             string          `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
347
+	DoctorCode                              string          `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
348
+	Licensing                               int64           `gorm:"column:licensing" json:"licensing" form:"licensing"`
349
+	JobNumber                               string          `gorm:"column:job_number" json:"job_number" form:"job_number"`
350
+	PrescriptionQualificationIdentification int64           `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
351
+	IdentificationOutpatients               int64           `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
352
+	StartTime                               int64           `gorm:"column:start_time" json:"start_time" form:"start_time"`
353
+	MedicalRangeCode                        int64           `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
354
+	MedicalLevel                            int64           `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
355
+	MedicalTypeJob                          int64           `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
356
+	PharmacistRegistrationNumber            string          `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
357
+	DoctorRangeCode                         int64           `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
358
+	DoctorLevel                             int64           `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
359
+	DoctorTypeJob                           int64           `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
360
+	DoctorNumber                            string          `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
361
+	OutpatientIllnessCategory               string          `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
362
+	IsActive                                int64           `gorm:"column:is_active" json:"is_active" form:"is_active"`
363
+	ActiveStatus                            int64           `gorm:"column:active_status" json:"active_status" form:"active_status"`
364
+	XtHisDepartment                         XtHisDepartment `json:"department" gorm:"foreignkey:DepartmentId;AssociationForeignKey:ID;"`
332 365
 }
333 366
 
334 367
 func (UserAdminRole) TableName() string {

+ 25 - 8
service/sz_his_service.go Voir le fichier

@@ -149,7 +149,7 @@ func SzybFY001(doctor string, doctor_code string, fixmedins_code string, datas [
149 149
 		feedetailInfo["bkm017"] = item.Code
150 150
 		feedetailInfo["aka070"] = item.DoseCode
151 151
 		feedetailInfo["aka074"] = item.Spec
152
-		feedetailInfo["aka064"] = 0
152
+		feedetailInfo["aka064"] = 1
153 153
 		feedetailInfo["ake005"] = item.Code
154 154
 		feedetailInfo["ake006"] = item.CodeName
155 155
 		feedetailInfo["akc225"] = item.Price
@@ -252,7 +252,7 @@ func SzybFY002(doctor string, doctor_code string, fixmedins_code string, datas [
252 252
 	str := string(respBytes)
253 253
 	return str
254 254
 }
255
-func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, verify_code string, serial_number string, mz_number string, version_code string) string {
255
+func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor_code string, drug_doctor_name string) string {
256 256
 	// 生成输入报文
257 257
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
258 258
 	inputData := make(map[string]interface{})
@@ -261,8 +261,8 @@ func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total f
261 261
 
262 262
 	inputData["akc190"] = mz_number
263 263
 	inputData["aka130"] = "11"
264
-	inputData["bkc320"] = doctor_code
265
-	inputData["ckc350"] = doctor
264
+	inputData["bkc320"] = drug_doctor_code
265
+	inputData["ckc350"] = drug_doctor_name
266 266
 	inputData["aka030"] = "12"
267 267
 	inputData["akc264"] = total
268 268
 	inputData["ckc601"] = "0"
@@ -301,7 +301,7 @@ func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total f
301 301
 	str := string(respBytes)
302 302
 	return str
303 303
 }
304
-func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string) string {
304
+func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string) string {
305 305
 	// 生成输入报文
306 306
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
307 307
 	inputData := make(map[string]interface{})
@@ -313,8 +313,8 @@ func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total f
313 313
 	inputData["bzz269"] = "000000"
314 314
 	inputData["akc190"] = mz_number
315 315
 	inputData["aka130"] = "11"
316
-	inputData["bkc320"] = doctor_code
317
-	inputData["ckc350"] = doctor
316
+	inputData["bkc320"] = drug_doctor
317
+	inputData["ckc350"] = drug_doctor_name
318 318
 	inputData["aka030"] = "12"
319 319
 	inputData["akc264"] = total
320 320
 	inputData["ckc601"] = "0"
@@ -1061,6 +1061,23 @@ func SzybYML007(doctor string, doctor_code string, fixmedins_code string, datas
1061 1061
 
1062 1062
 func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
1063 1063
 	var data models.DictDataconfig
1064
-	err := readDb.Model(&models.DictDataconfig{}).Where(" (user_org_id = ? Or user_org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
1064
+	err := readDb.Model(&models.DictDataconfig{}).Where(" (org_id = ? Or org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
1065 1065
 	return err, data.Code
1066 1066
 }
1067
+
1068
+func UpdataOrderStatusSZ(id int64, number string, user_org_id int64, his_mz_number string, his_number string) (err error) {
1069
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
1070
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
1071
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
1072
+	err = writeDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? AND mz_number = ? AND number = ?", user_org_id, his_mz_number, his_number).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1073
+
1074
+	return
1075
+
1076
+}
1077
+
1078
+func UpdataOrderlog(id int64, user_org_id int64, refund_log string) (err error) {
1079
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0, "refund_log": refund_log}).Error
1080
+
1081
+	return
1082
+
1083
+}