Просмотр исходного кода

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

csx 3 лет назад
Родитель
Сommit
24ee2790c4

+ 2 - 2
conf/app.conf Просмотреть файл

@@ -44,7 +44,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 9919
47
+org_id = 10106
48 48
 mobile_token_expiration_second = 86400
49 49
 httpdomain = https://api.xt.kuyicloud.com
50 50
 sso_domain = https://sso.kuyicloud.com
@@ -53,7 +53,7 @@ front_end_domain = "https://xt.kuyicloud.com/#"
53 53
 #url  = "http://192.168.1.228:17001/szsi-portal/transData"
54 54
 url = "http://192.168.1.88:6666/szsi-portal/transData"
55 55
 gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
56
-gdyb_paasid = "sg03_prd"
56
+gdyb_paasid = "jm_sc_yjyy"
57 57
 
58 58
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
59 59
 readmysqlport = 3306

+ 20 - 4
controllers/sg/gdyb_controller.go Просмотреть файл

@@ -323,7 +323,7 @@ func (c *GdybController) PostEight() {
323 323
 	preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
324 324
 	inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
325 325
 
326
-	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt)
326
+	result, srcRequest := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt)
327 327
 	var dat map[string]interface{}
328 328
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
329 329
 		fmt.Println(dat)
@@ -331,8 +331,16 @@ func (c *GdybController) PostEight() {
331 331
 		fmt.Println(err)
332 332
 	}
333 333
 
334
+	var dat2 map[string]interface{}
335
+	if err := json.Unmarshal([]byte(srcRequest), &dat2); err == nil {
336
+		fmt.Println(dat2)
337
+	} else {
338
+		fmt.Println(err)
339
+	}
340
+
334 341
 	c.ServeSuccessJSON(map[string]interface{}{
335
-		"pre": dat,
342
+		"pre":  dat,
343
+		"pre2": dat2,
336 344
 	})
337 345
 }
338 346
 
@@ -346,15 +354,23 @@ func (c *GdybController) PostNine() {
346 354
 	fixmedins_code := c.GetString("fixmedins_code")
347 355
 	insuplc_admdvs := c.GetString("insuplc_admdvs")
348 356
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
349
-	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
357
+	result, src_request := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
350 358
 	var dat map[string]interface{}
351 359
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
352 360
 		fmt.Println(dat)
353 361
 	} else {
354 362
 		fmt.Println(err)
355 363
 	}
364
+
365
+	var dat2 map[string]interface{}
366
+	if err := json.Unmarshal([]byte(src_request), &dat2); err == nil {
367
+		fmt.Println(dat2)
368
+	} else {
369
+		fmt.Println(err)
370
+	}
356 371
 	c.ServeSuccessJSON(map[string]interface{}{
357
-		"pre": dat,
372
+		"pre":  dat,
373
+		"pre2": dat2,
358 374
 	})
359 375
 }
360 376
 

+ 213 - 162
controllers/sg/his_api_controller.go Просмотреть файл

@@ -821,6 +821,64 @@ type ResultFourteen struct {
821 821
 	WarnInfo    interface{} `json:"warn_info"`
822 822
 }
823 823
 
824
+type ResultSixteen struct {
825
+	Cainfo      string `json:"cainfo"`
826
+	ErrMsg      string `json:"err_msg"`
827
+	InfRefmsgid string `json:"inf_refmsgid"`
828
+	Infcode     int64  `json:"infcode"`
829
+	Output      struct {
830
+		Setldetail []interface{} `json:"setldetail"`
831
+		Setlinfo   struct {
832
+			MdtrtID         string  `json:"mdtrt_id"`
833
+			SetlID          string  `json:"setl_id"`
834
+			ClrOptins       string  `json:"clr_optins"`
835
+			SetlTime        string  `json:"setl_time"`
836
+			MedfeeSumamt    float64 `json:"medfee_sumamt"`
837
+			FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
838
+			OverlmtSelfpay  float64 `json:"overlmt_selfpay"`
839
+			PreselfpayAmt   float64 `json:"preselfpay_amt"`
840
+			InscpScpAmt     float64 `json:"inscp_scp_amt"`
841
+			ActPayDedc      float64 `json:"act_pay_dedc"`
842
+			HifpPay         float64 `json:"hifp_pay"`
843
+			PoolPropSe      float64 `json:"pool_prop_selfpay"`
844
+			Lfpay           float64 `json:"selfpay"`
845
+			CvlservPay      float64 `json:"cvlserv_pay"`
846
+			HifesPay        float64 `json:"hifes_pay"`
847
+			HifmiPay        float64 `json:"hifmi_pay"`
848
+			HifobPay        float64 `json:"hifob_pay"`
849
+			MafPay          float64 `json:"maf_pay"`
850
+			OthPay          float64 `json:"oth_pay"`
851
+			FundPaySumamt   float64 `json:"fund_pay_sumamt"`
852
+			PsnPartAmt      float64 `json:"psn_part_amt"`
853
+			AcctPay         float64 `json:"acct_pay"`
854
+			Balc            float64 `json:"balc"`
855
+			AcctMulaidPay   float64 `json:"acct_mulaid_pay"`
856
+			HospPartAmt     float64 `json:"hosp_part_amt"`
857
+			MedinsSetlID    string  `json:"medins_setl_id"`
858
+			Age             float64 `json:"age"`
859
+			Brdy            string  `json:"brdy"`
860
+			Certno          string  `json:"certno"`
861
+			ClrType         string  `json:"clr_type"`
862
+			ClrWay          string  `json:"clr_way"`
863
+			CvlservFlag     string  `json:"cvlserv_flag"`
864
+			Gend            string  `json:"gend"`
865
+			Insutype        string  `json:"insutype"`
866
+			MdtrtCertType   string  `json:"mdtrt_cert_type"`
867
+			MedType         string  `json:"med_type"`
868
+			Naty            string  `json:"naty"`
869
+			PsnCashPay      float64 `json:"psn_cash_pay"`
870
+			PsnCertType     string  `json:"psn_cert_type"`
871
+			PsnName         string  `json:"psn_name"`
872
+			PsnNo           string  `json:"psn_no"`
873
+			PsnType         string  `json:"psn_type"`
874
+		} `json:"setlinfo"`
875
+	} `json:"output"`
876
+	RefmsgTime  string      `json:"refmsg_time"`
877
+	RespondTime string      `json:"respond_time"`
878
+	Signtype    interface{} `json:"signtype"`
879
+	WarnMsg     interface{} `json:"warn_msg"`
880
+}
881
+
824 882
 type Custom struct {
825 883
 	DetItemFeeSumamt string
826 884
 	Cut              string
@@ -976,7 +1034,7 @@ func (c *HisApiController) GetRegisterInfo() {
976 1034
 			timeFormat := tempTime.Format("20060102150405")
977 1035
 			chrgBchno := rand.Intn(100000) + 10000
978 1036
 			ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
979
-			count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
1037
+			//count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
980 1038
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
981 1039
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
982 1040
 
@@ -992,13 +1050,11 @@ func (c *HisApiController) GetRegisterInfo() {
992 1050
 			var insutype string
993 1051
 			var is390 int = 0
994 1052
 			var is310 int = 0
995
-
996 1053
 			for _, item := range res.Output.Iinfo {
997 1054
 				if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
998 1055
 					insutypes = append(insutypes, item.Insutype)
999 1056
 				}
1000 1057
 			}
1001
-
1002 1058
 			if len(insutypes) == 1 {
1003 1059
 				insutype = insutypes[0]
1004 1060
 			} else {
@@ -1018,138 +1074,131 @@ func (c *HisApiController) GetRegisterInfo() {
1018 1074
 			if is310 == 1 {
1019 1075
 				insutype = "310"
1020 1076
 			}
1021
-			fmt.Println(insutype)
1077
+			api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
1078
+				insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1079
+				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1080
+				"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
1081
+			resp, requestErr := http.Get(api)
1082
+			if requestErr != nil {
1083
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1084
+				return
1085
+			}
1086
+			defer resp.Body.Close()
1087
+			body, ioErr := ioutil.ReadAll(resp.Body)
1088
+			if ioErr != nil {
1089
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
1090
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1091
+				return
1092
+			}
1093
+			var respJSON map[string]interface{}
1094
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
1095
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1096
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1097
+				return
1098
+			}
1022 1099
 
1023
-			if count <= 0 {
1024
-				api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
1025
-					insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1026
-					"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1027
-					"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
1028
-				resp, requestErr := http.Get(api)
1029
-				if requestErr != nil {
1100
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
1101
+			userJSONBytes, _ := json.Marshal(respJSON)
1102
+			var res ResultThree
1103
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1104
+				utils.ErrorLog("解析失败:%v", err)
1105
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1106
+				return
1107
+			}
1108
+			if res.Infcode == -1 {
1109
+				adminUser := c.GetAdminUserInfo()
1110
+				errlog := &models.HisOrderError{
1111
+					UserOrgId:  adminUser.CurrentOrgId,
1112
+					Ctime:      time.Now().Unix(),
1113
+					Mtime:      time.Now().Unix(),
1114
+					ErrMsg:     res.ErrMsg,
1115
+					Status:     1,
1116
+					PatientId:  id,
1117
+					RecordTime: recordDateTime,
1118
+					Stage:      2,
1119
+				}
1120
+				service.CreateErrMsgLog(errlog)
1121
+				c.ServeSuccessJSON(map[string]interface{}{
1122
+					"failed_code": -10,
1123
+					"msg":         res.ErrMsg,
1124
+				})
1125
+				return
1126
+				//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
1127
+				//return
1128
+			}
1129
+
1130
+			his.Number = res.Output.Data.MdtrtID
1131
+			his.PsnNo = res.Output.Data.PsnNo
1132
+			his.IptOtpNo = res.Output.Data.IptOtpNo
1133
+			his.IdCardNo = patient.IdCardNo
1134
+			his.PhoneNumber = patient.Phone
1135
+			his.UserOrgId = adminInfo.CurrentOrgId
1136
+			his.Ctime = time.Now().Unix()
1137
+			his.Mtime = time.Now().Unix()
1138
+			his.Status = 1
1139
+			err := service.CreateHisPatientTwo(&his)
1140
+			if err == nil {
1141
+				api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
1142
+					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1143
+					"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + reg_type + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
1144
+					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
1145
+				resp2, requestErr2 := http.Get(api2)
1146
+				if requestErr2 != nil {
1030 1147
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1031 1148
 					return
1032 1149
 				}
1033
-				defer resp.Body.Close()
1034
-				body, ioErr := ioutil.ReadAll(resp.Body)
1035
-				if ioErr != nil {
1036
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
1150
+				body2, ioErr2 := ioutil.ReadAll(resp2.Body)
1151
+				if ioErr2 != nil {
1152
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
1037 1153
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1038 1154
 					return
1039 1155
 				}
1040
-				var respJSON map[string]interface{}
1041
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
1156
+				var respJSON2 map[string]interface{}
1157
+				if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
1042 1158
 					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1043 1159
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1044 1160
 					return
1045 1161
 				}
1162
+				respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
1163
+				userJSONBytes2, _ := json.Marshal(respJSON2)
1046 1164
 
1047
-				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
1048
-				userJSONBytes, _ := json.Marshal(respJSON)
1049
-				var res ResultThree
1050
-				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1165
+				var res2 ResultSix
1166
+				if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
1051 1167
 					utils.ErrorLog("解析失败:%v", err)
1052 1168
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1053 1169
 					return
1054 1170
 				}
1055
-				if res.Infcode == -1 {
1171
+				if res2.Infcode == -1 {
1056 1172
 					adminUser := c.GetAdminUserInfo()
1057 1173
 					errlog := &models.HisOrderError{
1058 1174
 						UserOrgId:  adminUser.CurrentOrgId,
1059 1175
 						Ctime:      time.Now().Unix(),
1060 1176
 						Mtime:      time.Now().Unix(),
1061
-						ErrMsg:     res.ErrMsg,
1177
+						ErrMsg:     res2.ErrMsg,
1062 1178
 						Status:     1,
1063 1179
 						PatientId:  id,
1064 1180
 						RecordTime: recordDateTime,
1065
-						Stage:      2,
1181
+						Stage:      3,
1066 1182
 					}
1067 1183
 					service.CreateErrMsgLog(errlog)
1068 1184
 					c.ServeSuccessJSON(map[string]interface{}{
1069 1185
 						"failed_code": -10,
1070
-						"msg":         res.ErrMsg,
1186
+						"msg":         res2.ErrMsg,
1071 1187
 					})
1072 1188
 					return
1073
-					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
1074
-					//return
1075
-				}
1076
-
1077
-				his.Number = res.Output.Data.MdtrtID
1078
-				his.PsnNo = res.Output.Data.PsnNo
1079
-				his.IptOtpNo = res.Output.Data.IptOtpNo
1080
-				his.IdCardNo = patient.IdCardNo
1081
-				his.PhoneNumber = patient.Phone
1082
-				his.UserOrgId = adminInfo.CurrentOrgId
1083
-				his.Ctime = time.Now().Unix()
1084
-				his.Mtime = time.Now().Unix()
1085
-				his.Status = 1
1086
-				err := service.CreateHisPatientTwo(&his)
1087
-				if err == nil {
1088
-					api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
1089
-						"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1090
-						"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + reg_type + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
1091
-						"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
1092
-					resp2, requestErr2 := http.Get(api2)
1093
-					if requestErr2 != nil {
1094
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1095
-						return
1096
-					}
1097
-					body2, ioErr2 := ioutil.ReadAll(resp2.Body)
1098
-					if ioErr2 != nil {
1099
-						utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
1100
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1101
-						return
1102
-					}
1103
-					var respJSON2 map[string]interface{}
1104
-					if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
1105
-						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1106
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1107
-						return
1108
-					}
1109
-					respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
1110
-					userJSONBytes2, _ := json.Marshal(respJSON2)
1111
-
1112
-					var res2 ResultSix
1113
-					if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
1114
-						utils.ErrorLog("解析失败:%v", err)
1115
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1116
-						return
1117
-					}
1118
-					if res2.Infcode == -1 {
1119
-						adminUser := c.GetAdminUserInfo()
1120
-						errlog := &models.HisOrderError{
1121
-							UserOrgId:  adminUser.CurrentOrgId,
1122
-							Ctime:      time.Now().Unix(),
1123
-							Mtime:      time.Now().Unix(),
1124
-							ErrMsg:     res2.ErrMsg,
1125
-							Status:     1,
1126
-							PatientId:  id,
1127
-							RecordTime: recordDateTime,
1128
-							Stage:      3,
1129
-						}
1130
-						service.CreateErrMsgLog(errlog)
1131
-						c.ServeSuccessJSON(map[string]interface{}{
1132
-							"failed_code": -10,
1133
-							"msg":         res2.ErrMsg,
1134
-						})
1135
-						return
1136
-
1137
-					} else {
1138
-
1139
-						c.ServeSuccessJSON(map[string]interface{}{
1140
-							"his_info": his,
1141
-						})
1142
-					}
1143 1189
 
1144 1190
 				} else {
1145
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1146
-					return
1191
+
1192
+					c.ServeSuccessJSON(map[string]interface{}{
1193
+						"his_info": his,
1194
+					})
1147 1195
 				}
1148 1196
 
1149 1197
 			} else {
1150
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1198
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1151 1199
 				return
1152 1200
 			}
1201
+
1153 1202
 		} else {
1154 1203
 			adminUser := c.GetAdminUserInfo()
1155 1204
 			errlog := &models.HisOrderError{
@@ -1368,8 +1417,8 @@ func (c *HisApiController) GetUploadInfo() {
1368 1417
 				SettleType:            settle_accounts_type,
1369 1418
 				SettleStartTime:       start_time,
1370 1419
 				SettleEndTime:         end_time,
1371
-				Creator:               roles.ID,
1372
-				Modify:                roles.ID,
1420
+				Creator:               roles.AdminUserId,
1421
+				Modify:                roles.AdminUserId,
1373 1422
 			}
1374 1423
 			err = service.CreateOrder(order)
1375 1424
 			if err != nil {
@@ -1529,6 +1578,12 @@ func (c *HisApiController) GetUploadInfo() {
1529 1578
 				fmt.Println(respJSON)
1530 1579
 				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
1531 1580
 				userJSONBytes, _ := json.Marshal(respJSON)
1581
+
1582
+				respJSON2 := respJSON["data"].(map[string]interface{})["pre2"].(map[string]interface{})
1583
+				userJSONBytes2, _ := json.Marshal(respJSON2)
1584
+
1585
+				src_request := string(userJSONBytes2)
1586
+
1532 1587
 				var res ResultSeven
1533 1588
 				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1534 1589
 					utils.ErrorLog("解析失败:%v", err)
@@ -1595,7 +1650,8 @@ func (c *HisApiController) GetUploadInfo() {
1595 1650
 					order.ClrOptins = res.Output.Setlinfo.ClrOptins
1596 1651
 					order.ClrWay = res.Output.Setlinfo.ClrWay
1597 1652
 					order.Creator = order.Creator
1598
-					order.Modify = roles.ID
1653
+					order.Modify = roles.AdminUserId
1654
+					order.RequestLog = src_request
1599 1655
 					setlDetail, _ := json.Marshal(res.Output.Setldetail)
1600 1656
 					detailStr := string(setlDetail)
1601 1657
 					order.SetlDetail = detailStr
@@ -2560,35 +2616,26 @@ func (c *HisApiController) GetSettleInfo() {
2560 2616
 func (c *HisApiController) Refund() {
2561 2617
 	order_id, _ := c.GetInt64("order_id")
2562 2618
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2563
-
2564
-	number := c.GetString("number")
2565 2619
 	record_time := c.GetString("record_time")
2566 2620
 	patient_id, _ := c.GetInt64("patient_id")
2567 2621
 	timeLayout := "2006-01-02"
2568 2622
 	loc, _ := time.LoadLocation("Local")
2569 2623
 	adminUser := c.GetAdminUserInfo()
2570 2624
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
2571
-	fmt.Println(err)
2572 2625
 	if err != nil {
2573 2626
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2574 2627
 		return
2575 2628
 	}
2576 2629
 	recordDateTime := theTime.Unix()
2577 2630
 	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2578
-	//patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2579 2631
 	var order models.HisOrder
2580 2632
 	order, _ = service.GetHisOrderByID(order_id)
2581
-
2582 2633
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
2583
-
2584 2634
 	if order.ID == 0 {
2585 2635
 		order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
2586
-
2587 2636
 	}
2588
-
2589 2637
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
2590 2638
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2591
-
2592 2639
 	if config.IsOpen == 1 { //对接了医保,走医保流程
2593 2640
 		api := "http://127.0.0.1:9532/" + "gdyb/nine?psn_no=" + his.PsnNo +
2594 2641
 			"&mdtrt_id=" + his.Number + "&doctor=" + roles.UserName + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
@@ -2612,65 +2659,69 @@ func (c *HisApiController) Refund() {
2612 2659
 		}
2613 2660
 		respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2614 2661
 		userJSONBytes, _ := json.Marshal(respJSON)
2615
-		fmt.Println(respJSON)
2616
-		fmt.Println(userJSONBytes)
2617 2662
 
2618
-		api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
2619
-			"&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2620
-			"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2621
-		resp2, requestErr2 := http.Get(api2)
2622
-		if requestErr2 != nil {
2623
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2624
-			return
2625
-		}
2663
+		respJSON2 := respJSON["data"].(map[string]interface{})["pre2"].(map[string]interface{})
2664
+		userJSONBytes2, _ := json.Marshal(respJSON2)
2626 2665
 
2627
-		body2, ioErr2 := ioutil.ReadAll(resp2.Body)
2628
-		if ioErr2 != nil {
2629
-			utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
2630
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2631
-			return
2632
-		}
2633
-		var respJSON2 map[string]interface{}
2634
-		if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
2635
-			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2666
+		var res ResultSixteen
2667
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2668
+			utils.ErrorLog("解析失败:%v", err)
2636 2669
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2637 2670
 			return
2638 2671
 		}
2639
-
2640
-		//api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
2641
-		//	"&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2642
-		//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2643
-		//resp3, requestErr3 := http.Get(api3)
2644
-		//if requestErr3 != nil {
2645
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2646
-		//	return
2647
-		//}
2648
-		//
2649
-		//body3, ioErr3 := ioutil.ReadAll(resp3.Body)
2650
-		//if ioErr3 != nil {
2651
-		//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
2652
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2653
-		//	return
2654
-		//}
2655
-		//var respJSON3 map[string]interface{}
2656
-		//if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
2657
-		//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2658
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2659
-		//	return
2660
-		//}
2661
-		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2662
-		//service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
2663
-
2664
-		if err == nil {
2672
+		if res.Infcode == 0 {
2673
+			api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
2674
+				"&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2675
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2676
+			resp2, requestErr2 := http.Get(api2)
2677
+			if requestErr2 != nil {
2678
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2679
+				return
2680
+			}
2681
+			body2, ioErr2 := ioutil.ReadAll(resp2.Body)
2682
+			if ioErr2 != nil {
2683
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
2684
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2685
+				return
2686
+			}
2687
+			var respJSON2 map[string]interface{}
2688
+			if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
2689
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2690
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2691
+				return
2692
+			}
2693
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2694
+			userJSONBytes, _ := json.Marshal(respJSON)
2695
+			var res2 ResultSix
2696
+			if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
2697
+				utils.ErrorLog("解析失败:%v", err)
2698
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2699
+				return
2700
+			}
2701
+			if res2.Infcode == 0 {
2702
+				err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, string(userJSONBytes2))
2703
+				if err == nil {
2704
+					c.ServeSuccessJSON(map[string]interface{}{
2705
+						"msg": "退费成功",
2706
+					})
2707
+				} else {
2708
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2709
+					return
2710
+				}
2711
+			} else {
2712
+				c.ServeSuccessJSON(map[string]interface{}{
2713
+					"code": -10,
2714
+					"msg":  res2.ErrMsg,
2715
+				})
2716
+			}
2717
+		} else {
2665 2718
 			c.ServeSuccessJSON(map[string]interface{}{
2666
-				"msg": "退费成功",
2719
+				"code": -10,
2720
+				"msg":  res.ErrMsg,
2667 2721
 			})
2668
-		} else {
2669
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2670
-			return
2671 2722
 		}
2672 2723
 	} else {
2673
-		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2724
+		err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "")
2674 2725
 		if err == nil {
2675 2726
 			c.ServeSuccessJSON(map[string]interface{}{
2676 2727
 				"msg": "退费成功",
@@ -2802,7 +2853,7 @@ func (c *HisApiController) RefundDetail() {
2802 2853
 			return
2803 2854
 		}
2804 2855
 
2805
-		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2856
+		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "")
2806 2857
 		if err == nil {
2807 2858
 			c.ServeSuccessJSON(map[string]interface{}{
2808 2859
 				"msg": "退费成功",
@@ -2812,7 +2863,7 @@ func (c *HisApiController) RefundDetail() {
2812 2863
 			return
2813 2864
 		}
2814 2865
 	} else {
2815
-		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2866
+		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "")
2816 2867
 		if err == nil {
2817 2868
 			c.ServeSuccessJSON(map[string]interface{}{
2818 2869
 				"msg": "退费成功",

+ 3 - 0
models/his_models.go Просмотреть файл

@@ -675,6 +675,9 @@ type HisOrder struct {
675 675
 	RefundLog string `gorm:"column:refund_log" json:"refund_log" form:"refund_log"`
676 676
 	DetailLog string `gorm:"column:detail_log" json:"detail_log" form:"detail_log"`
677 677
 
678
+	RequestLog       string `gorm:"column:request_log" json:"request_log" form:"request_log"`
679
+	RefundRequestLog string `gorm:"column:refund_request_log" json:"refund_request_log" form:"refund_request_log"`
680
+
678 681
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
679 682
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
680 683
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`

+ 18 - 15
service/gdyb_service.go Просмотреть файл

@@ -919,7 +919,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
919 919
 }
920 920
 
921 921
 //  门诊结算
922
-func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64) string {
922
+func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64) (string, string) {
923 923
 	// 生成签名
924 924
 	nonce := GetRandomString(32)
925 925
 	timestamp := time.Now().Unix()
@@ -962,7 +962,7 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
962 962
 	fmt.Println(string(bytesData))
963 963
 	if err != nil {
964 964
 		fmt.Println(err.Error())
965
-		return err.Error()
965
+		return err.Error(), ""
966 966
 	}
967 967
 	reader := bytes.NewReader(bytesData)
968 968
 	gdyb_url := beego.AppConfig.String("gdyb_url")
@@ -978,7 +978,7 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
978 978
 	request, err := http.NewRequest("POST", url, reader)
979 979
 	if err != nil {
980 980
 		fmt.Println(err.Error())
981
-		return err.Error()
981
+		return err.Error(), ""
982 982
 	}
983 983
 
984 984
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
@@ -991,20 +991,23 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
991 991
 	resp, err := client.Do(request)
992 992
 	if err != nil {
993 993
 		fmt.Println(err.Error())
994
-		return err.Error()
994
+		return err.Error(), ""
995 995
 	}
996 996
 	respBytes, err := ioutil.ReadAll(resp.Body)
997 997
 	if err != nil {
998 998
 		fmt.Println(err.Error())
999
-		return err.Error()
999
+		return err.Error(), ""
1000 1000
 	}
1001 1001
 	str := string(respBytes)
1002 1002
 	fmt.Println(str)
1003
-	return str
1003
+	mjson, _ := json.Marshal(inputMessage)
1004
+	str2 := string(mjson)
1005
+
1006
+	return str, str2
1004 1007
 }
1005 1008
 
1006 1009
 //  门诊结算撤销
1007
-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 {
1010
+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, string) {
1008 1011
 	// 生成签名
1009 1012
 	nonce := GetRandomString(32)
1010 1013
 	timestamp := time.Now().Unix()
@@ -1027,7 +1030,7 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
1027 1030
 	fmt.Println(string(bytesData))
1028 1031
 	if err != nil {
1029 1032
 		fmt.Println(err.Error())
1030
-		return err.Error()
1033
+		return err.Error(), ""
1031 1034
 	}
1032 1035
 	reader := bytes.NewReader(bytesData)
1033 1036
 	gdyb_url := beego.AppConfig.String("gdyb_url")
@@ -1043,7 +1046,7 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
1043 1046
 	request, err := http.NewRequest("POST", url, reader)
1044 1047
 	if err != nil {
1045 1048
 		fmt.Println(err.Error())
1046
-		return err.Error()
1049
+		return err.Error(), ""
1047 1050
 	}
1048 1051
 
1049 1052
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
@@ -1056,16 +1059,18 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
1056 1059
 	resp, err := client.Do(request)
1057 1060
 	if err != nil {
1058 1061
 		fmt.Println(err.Error())
1059
-		return err.Error()
1062
+		return err.Error(), ""
1060 1063
 	}
1061 1064
 	respBytes, err := ioutil.ReadAll(resp.Body)
1062 1065
 	if err != nil {
1063 1066
 		fmt.Println(err.Error())
1064
-		return err.Error()
1067
+		return err.Error(), ""
1065 1068
 	}
1066 1069
 	str := string(respBytes)
1067 1070
 	fmt.Println(str)
1068
-	return str
1071
+	mjson, _ := json.Marshal(inputMessage)
1072
+	str2 := string(mjson)
1073
+	return str, str2
1069 1074
 }
1070 1075
 
1071 1076
 //确认订单
@@ -1626,12 +1631,10 @@ func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type
1626 1631
 	input := make(map[string]interface{})
1627 1632
 	inputData := make(map[string]interface{})
1628 1633
 	inputMessage["infno"] = "3302" // 交易编码
1634
+	inputData["fixmedins_code"] = baseParams.FixmedinsCode
1629 1635
 	inputData["fixmedins_hilist_id"] = codg
1630
-	inputData["fixmedins_hilist_name"] = name
1631 1636
 	inputData["list_type"] = list_type_code
1632 1637
 	inputData["med_list_codg"] = codg
1633
-	inputData["begndate"] = "2021-01-01"
1634
-	inputData["enddate"] = "2099-01-07"
1635 1638
 
1636 1639
 	input["data"] = inputData
1637 1640
 	inputMessage["input"] = input //交易输入

+ 2 - 2
service/his_service.go Просмотреть файл

@@ -660,8 +660,8 @@ func GetMedicalInsuranceConfig(org_id int64) (medicalInsuranceConfig models.Medi
660 660
 
661 661
 }
662 662
 
663
-func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
664
-	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()}).Error
663
+func UpdataOrderStatus(id int64, number string, user_org_id int64, log string) (err error) {
664
+	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(), "refund_request_log": log}).Error
665 665
 	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
666 666
 	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
667 667
 	return