Browse Source

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

csx 2 years ago
parent
commit
a0f3f995f9
3 changed files with 144 additions and 5 deletions
  1. 5 5
      conf/app.conf
  2. 80 0
      controllers/zh/zh_his_api_controller.go
  3. 59 0
      service/zh_his_service.go

+ 5 - 5
conf/app.conf View File

@@ -45,7 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10188
48
+org_id = 10215
49 49
 mobile_token_expiration_second = 86400
50 50
 httpdomain = https://api.xt.kuyicloud.com
51 51
 sso_domain = https://sso.kuyicloud.com
@@ -53,8 +53,8 @@ call_domain = https://hf.sgjyun.com
53 53
 front_end_domain = "https://xt.kuyicloud.com/#"
54 54
 #url  = "http://192.168.1.228:17001/szsi-portal/transData"
55 55
 #url = "http://192.168.1.88:6666/szsi-portal/transData"
56
-# gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
57
-gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
56
+gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
57
+# gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
58 58
 #内蒙古
59 59
 # http://tyjk.nm.hsip.gov.cn:8090/uif-hsaf-med-api/api/medical/service
60 60
 # gdyb_url = "http://tyjk.nm.hsip.gov.cn:8090/uif-hsaf-med-api/api/medical/service"
@@ -65,9 +65,9 @@ gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
65 65
 #珠海
66 66
 # gdyb_paasid="zh_prd_yrojyy"
67 67
 #深圳
68
-gdyb_paasid = "sz_prd_yjyy"
68
+# gdyb_paasid = "sz_prd_yjyy"
69 69
 #肇庆
70
-#  gdyb_paasid = "zq_prd_yjyy"
70
+gdyb_paasid = "zq_prd_yjyy"
71 71
 
72 72
 
73 73
 

+ 80 - 0
controllers/zh/zh_his_api_controller.go View File

@@ -480,7 +480,87 @@ func ZHHisManagerApiRegistRouters() {
480 480
 	beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
481 481
 	beego.Router("/zh/api/readcard", &ZHHisApiController{}, "get:ReadCard")
482 482
 
483
+	beego.Router("/zh/api/clearsettle", &ZHHisApiController{}, "get:ClearSettle")
484
+
483 485
 }
486
+func (c *ZHHisApiController) ClearSettle() {
487
+	order_id, _ := c.GetInt64("order_id")
488
+	admin_user_id, _ := c.GetInt64("admin_user_id")
489
+	adminUser := c.GetAdminUserInfo()
490
+	var order models.HisOrder
491
+	order, _ = service.GetHisOrderByID(order_id)
492
+	record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
493
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
494
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
495
+	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
496
+	if config.IsOpen == 1 { //对接了医保,走医保流程
497
+		var result string
498
+		var requestLog string
499
+		result, requestLog = service.Gdyb90306(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
500
+		saveLog(result, requestLog, "90306", "撤销结算清单")
501
+
502
+		var dat map[string]interface{}
503
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
504
+			fmt.Println(dat)
505
+		} else {
506
+			fmt.Println(err)
507
+		}
508
+
509
+		userJSONBytes, _ := json.Marshal(dat)
510
+
511
+		var res ResultSixteen
512
+		var resSixteen ResultSixteen10265
513
+		if miConfig.Code == "H15049901371" {
514
+			if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
515
+				utils.ErrorLog("解析失败:%v", err)
516
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
517
+				return
518
+			}
519
+			res.Cainfo = resSixteen.Cainfo
520
+			res.WarnMsg = resSixteen.WarnMsg
521
+			res.Output = resSixteen.Output
522
+			res.ErrMsg = resSixteen.ErrMsg
523
+			res.RespondTime = resSixteen.RespondTime
524
+			Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
525
+			res.Infcode = Infcode
526
+
527
+		} else {
528
+
529
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
530
+				utils.ErrorLog("解析失败:%v", err)
531
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
532
+				return
533
+			}
534
+
535
+		}
536
+
537
+		if res.Infcode == 0 {
538
+
539
+			c.ServeSuccessJSON(map[string]interface{}{
540
+				"msg": "撤销成功",
541
+			})
542
+
543
+		} else {
544
+			c.ServeSuccessJSON(map[string]interface{}{
545
+				"code": -10,
546
+				"msg":  res.ErrMsg,
547
+			})
548
+		}
549
+
550
+	} else {
551
+		err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
552
+		if err == nil {
553
+			c.ServeSuccessJSON(map[string]interface{}{
554
+				"msg": "退费成功",
555
+			})
556
+		} else {
557
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
558
+			return
559
+		}
560
+	}
561
+
562
+}
563
+
484 564
 func (c *ZHHisApiController) GetZHPatientInfo() {
485 565
 	id_card_no := c.GetString("id_card_no")
486 566
 	admin_user_id, _ := c.GetInt64("admin_user_id")

+ 59 - 0
service/zh_his_service.go View File

@@ -1107,6 +1107,65 @@ func Gdyb2305(psnNo string, mdtrtId string, setlId string, org_name string, doct
1107 1107
 	return str, str2
1108 1108
 }
1109 1109
 
1110
+func Gdyb90306(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) {
1111
+	// 生成签名
1112
+	nonce := GetRandomString(32)
1113
+	timestamp := time.Now().Unix()
1114
+	signature := setSignature(timestamp, nonce, secret_key)
1115
+
1116
+	// 生成输入报文
1117
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
1118
+	input := make(map[string]interface{})
1119
+	inputData := make(map[string]interface{})
1120
+	inputMessage["infno"] = "90306" // 交易编码
1121
+	inputData["psn_no"] = psnNo     // 人员编号 (来自1101接口返回)
1122
+	inputData["setl_id"] = setlId   // 结算 ID
1123
+	input["data"] = inputData
1124
+	inputMessage["input"] = input //交易输入
1125
+
1126
+	bytesData, err := json.Marshal(inputMessage)
1127
+	fmt.Println(string(bytesData))
1128
+	if err != nil {
1129
+		fmt.Println(err.Error())
1130
+		return err.Error(), ""
1131
+	}
1132
+	reader := bytes.NewReader(bytesData)
1133
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1134
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1135
+	url := gdyb_url + "90306"
1136
+	if mdtrtarea_admvs == "150499" {
1137
+		url = gdyb_url
1138
+	}
1139
+	request, err := http.NewRequest("POST", url, reader)
1140
+	if err != nil {
1141
+		fmt.Println(err.Error())
1142
+		return err.Error(), ""
1143
+	}
1144
+
1145
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1146
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1147
+	request.Header.Set("x-tif-signature", signature)
1148
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1149
+	request.Header.Set("x-tif-nonce", nonce)
1150
+
1151
+	client := http.Client{}
1152
+	resp, err := client.Do(request)
1153
+	if err != nil {
1154
+		fmt.Println(err.Error())
1155
+		return err.Error(), ""
1156
+	}
1157
+	respBytes, err := ioutil.ReadAll(resp.Body)
1158
+	if err != nil {
1159
+		fmt.Println(err.Error())
1160
+		return err.Error(), ""
1161
+	}
1162
+	str := string(respBytes)
1163
+	fmt.Println(str)
1164
+	mjson, _ := json.Marshal(inputMessage)
1165
+	str2 := string(mjson)
1166
+	return str, str2
1167
+}
1168
+
1110 1169
 func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
1111 1170
 	err = writeDb.Save(&record).Error
1112 1171
 	return