Browse Source

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

csx 3 years ago
parent
commit
231b1cbbb3
3 changed files with 209 additions and 2 deletions
  1. 3 2
      conf/app.conf
  2. 152 0
      controllers/sg/his_api_controller.go
  3. 54 0
      service/gdyb_service.go

+ 3 - 2
conf/app.conf View File

@@ -44,7 +44,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 10106
47
+org_id = 9919
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,8 @@ 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 = "jm_sc_yjyy"
56
+gdyb_paasid = "sg03_prd"
57
+#    gdyb_paasid = "jm_sc_yjyy"
57 58
 
58 59
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
59 60
 readmysqlport = 3306

+ 152 - 0
controllers/sg/his_api_controller.go View File

@@ -69,6 +69,8 @@ func HisManagerApiRegistRouters() {
69 69
 
70 70
 	beego.Router("/api/test", &HisApiController{}, "get:TestTest")
71 71
 
72
+	beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
73
+
72 74
 }
73 75
 
74 76
 //func (c *HisApiController) TestPay() {
@@ -4272,6 +4274,156 @@ func (c *HisApiController) TestTest() {
4272 4274
 
4273 4275
 }
4274 4276
 
4277
+type CustomData struct {
4278
+	MsgId string
4279
+	PsnNo string
4280
+	Info  string
4281
+}
4282
+
4283
+func (c *HisApiController) ReversalData() {
4284
+	var customData []*CustomData
4285
+
4286
+	custom := &CustomData{
4287
+		MsgId: "H44022900158202103301714472004",
4288
+		PsnNo: "44020000001101329945",
4289
+		Info:  "2206",
4290
+	}
4291
+	customData = append(customData, custom)
4292
+
4293
+	custom1 := &CustomData{
4294
+		MsgId: "H4402290015820210330172057803",
4295
+		PsnNo: "44020000001101161813",
4296
+		Info:  "2206",
4297
+	}
4298
+	customData = append(customData, custom1)
4299
+	custom2 := &CustomData{
4300
+		MsgId: "H44022900158202103301705198813",
4301
+		PsnNo: "44190000133097375417",
4302
+		Info:  "2206",
4303
+	}
4304
+	customData = append(customData, custom2)
4305
+	custom3 := &CustomData{
4306
+		MsgId: "H44022900158202103301715524756",
4307
+		PsnNo: "44020000001100187221",
4308
+		Info:  "2206",
4309
+	}
4310
+	customData = append(customData, custom3)
4311
+	custom4 := &CustomData{
4312
+		MsgId: "H44022900158202103301730376224",
4313
+		PsnNo: "44020000001101959155",
4314
+		Info:  "2206",
4315
+	}
4316
+	customData = append(customData, custom4)
4317
+	custom5 := &CustomData{
4318
+		MsgId: "H44022900158202103301748008725",
4319
+		PsnNo: "44020000001104246641",
4320
+		Info:  "2206",
4321
+	}
4322
+	customData = append(customData, custom5)
4323
+	custom6 := &CustomData{
4324
+		MsgId: "H44022900158202103301718096755",
4325
+		PsnNo: "44020000001102211860",
4326
+		Info:  "2206",
4327
+	}
4328
+	customData = append(customData, custom6)
4329
+	custom7 := &CustomData{
4330
+		MsgId: "H44022900158202103301736551640",
4331
+		PsnNo: "44020000001102687718",
4332
+		Info:  "2206",
4333
+	}
4334
+
4335
+	customData = append(customData, custom7)
4336
+
4337
+	custom77 := &CustomData{
4338
+		MsgId: "H44022900158202103301736551640",
4339
+		PsnNo: "44020000001102687718",
4340
+		Info:  "2206",
4341
+	}
4342
+	customData = append(customData, custom77)
4343
+
4344
+	custom8 := &CustomData{
4345
+		MsgId: "H44022900158202103301743097676",
4346
+		PsnNo: "44020000001102127785",
4347
+		Info:  "2206",
4348
+	}
4349
+	customData = append(customData, custom8)
4350
+	custom9 := &CustomData{
4351
+		MsgId: "H44022900158202103301712304203",
4352
+		PsnNo: "44020000001101518097",
4353
+		Info:  "2206",
4354
+	}
4355
+	customData = append(customData, custom9)
4356
+	custom10 := &CustomData{
4357
+		MsgId: "H44022900158202103301738448785",
4358
+		PsnNo: "44020000001100500813",
4359
+		Info:  "2206",
4360
+	}
4361
+	customData = append(customData, custom10)
4362
+
4363
+	custom11 := &CustomData{
4364
+		MsgId: "H44022900158202103301732455843",
4365
+		PsnNo: "44020000001102690557",
4366
+		Info:  "2206",
4367
+	}
4368
+
4369
+	customData = append(customData, custom11)
4370
+
4371
+	custom12 := &CustomData{
4372
+		MsgId: "H44022900158202103301745421708",
4373
+		PsnNo: "44020000001102211928",
4374
+		Info:  "2206",
4375
+	}
4376
+	customData = append(customData, custom12)
4377
+
4378
+	custom1212 := &CustomData{
4379
+		MsgId: "H440229001582021033017351627",
4380
+		PsnNo: "44020000001102481733",
4381
+		Info:  "2206",
4382
+	}
4383
+	customData = append(customData, custom1212)
4384
+
4385
+	custom13 := &CustomData{
4386
+		MsgId: "H44022900158202103301740327951",
4387
+		PsnNo: "44020000001103174866",
4388
+		Info:  "2206",
4389
+	}
4390
+	customData = append(customData, custom13)
4391
+	custom14 := &CustomData{
4392
+		MsgId: "H4402290015820210330174922668",
4393
+		PsnNo: "44020000001102927272",
4394
+		Info:  "2206",
4395
+	}
4396
+	customData = append(customData, custom14)
4397
+	custom15 := &CustomData{
4398
+		MsgId: "H44022900158202103301752362273",
4399
+		PsnNo: "44020000001102942890",
4400
+		Info:  "2206",
4401
+	}
4402
+	customData = append(customData, custom15)
4403
+
4404
+	custom16 := &CustomData{
4405
+		MsgId: "H44022900158202103301751082917",
4406
+		PsnNo: "44020000001101662162",
4407
+		Info:  "2206",
4408
+	}
4409
+	customData = append(customData, custom16)
4410
+
4411
+	custom17 := &CustomData{
4412
+		MsgId: "H44022900158202103301754147728",
4413
+		PsnNo: "44020000000229014511",
4414
+		Info:  "2206",
4415
+	}
4416
+	customData = append(customData, custom17)
4417
+
4418
+	adminUser := c.GetAdminUserInfo()
4419
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
4420
+
4421
+	for _, item := range customData {
4422
+		result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
4423
+		fmt.Println(result)
4424
+	}
4425
+}
4426
+
4275 4427
 func PathExists(path string) (bool, error) {
4276 4428
 	_, err := os.Stat(path)
4277 4429
 	if err == nil {

+ 54 - 0
service/gdyb_service.go View File

@@ -2535,3 +2535,57 @@ func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Pa
2535 2535
 	err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
2536 2536
 	return
2537 2537
 }
2538
+
2539
+func Gdyb2601(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
2540
+	// 生成签名
2541
+	nonce := GetRandomString(32)
2542
+	timestamp := time.Now().Unix()
2543
+	signature := setSignature(timestamp, nonce, secret_key)
2544
+
2545
+	// 生成输入报文
2546
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
2547
+	input := make(map[string]interface{})
2548
+	inputData := make(map[string]interface{})
2549
+	inputMessage["infno"] = "2601" // 交易编码
2550
+	inputData["psn_no"] = psnNo
2551
+	inputData["omsgid"] = omsgid
2552
+	inputData["oinfno"] = oinfno
2553
+
2554
+	input["data"] = inputData
2555
+	inputMessage["input"] = input //交易输入
2556
+	bytesData, err := json.Marshal(inputMessage)
2557
+	fmt.Println(string(bytesData))
2558
+	if err != nil {
2559
+		fmt.Println(err.Error())
2560
+		return err.Error()
2561
+	}
2562
+	reader := bytes.NewReader(bytesData)
2563
+	gdyb_url := beego.AppConfig.String("gdyb_url")
2564
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
2565
+	url := gdyb_url + "2601"
2566
+	request, err := http.NewRequest("POST", url, reader)
2567
+	if err != nil {
2568
+		fmt.Println(err.Error())
2569
+		return err.Error()
2570
+	}
2571
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
2572
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
2573
+	request.Header.Set("x-tif-signature", signature)
2574
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
2575
+	request.Header.Set("x-tif-nonce", nonce)
2576
+
2577
+	client := http.Client{}
2578
+	resp, err := client.Do(request)
2579
+	if err != nil {
2580
+		fmt.Println(err.Error())
2581
+		return err.Error()
2582
+	}
2583
+	respBytes, err := ioutil.ReadAll(resp.Body)
2584
+	if err != nil {
2585
+		fmt.Println(err.Error())
2586
+		return err.Error()
2587
+	}
2588
+	str := string(respBytes)
2589
+	fmt.Println(str)
2590
+	return str
2591
+}