瀏覽代碼

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

csx 3 年之前
父節點
當前提交
09275cce68
共有 1 個文件被更改,包括 164 次插入168 次删除
  1. 164 168
      controllers/sg/his_api_controller.go

+ 164 - 168
controllers/sg/his_api_controller.go 查看文件

@@ -2741,206 +2741,202 @@ func (c *HisApiController) GetUploadInfo() {
2741 2741
 		}
2742 2742
 
2743 2743
 	} else if tempOrder.ID > 0 {
2744
-		if tempOrder.IsPre == 1 {
2745 2744
 
2746
-			allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
2747
-			var rf []*ResultFive
2748
-			json.Unmarshal([]byte(his.Iinfo), &rf)
2749
-			chrg_bchno := tempOrder.Number
2750
-			cert_no := his.Certno
2745
+		allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
2746
+		var rf []*ResultFive
2747
+		json.Unmarshal([]byte(his.Iinfo), &rf)
2748
+		chrg_bchno := tempOrder.Number
2749
+		cert_no := his.Certno
2751 2750
 
2752
-			var insutypes []string
2751
+		var insutypes []string
2753 2752
 
2754
-			var insutype string
2755
-			var is390 int = 0
2756
-			var is310 int = 0
2753
+		var insutype string
2754
+		var is390 int = 0
2755
+		var is310 int = 0
2757 2756
 
2758
-			for _, item := range rf {
2759
-				if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2760
-					insutypes = append(insutypes, item.Insutype)
2761
-				}
2757
+		for _, item := range rf {
2758
+			if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2759
+				insutypes = append(insutypes, item.Insutype)
2762 2760
 			}
2761
+		}
2763 2762
 
2764
-			if len(insutypes) == 1 {
2765
-				insutype = insutypes[0]
2766
-			} else {
2767
-				for _, i := range insutypes {
2768
-					if i == "390" {
2769
-						is390 = 1
2770
-					}
2763
+		if len(insutypes) == 1 {
2764
+			insutype = insutypes[0]
2765
+		} else {
2766
+			for _, i := range insutypes {
2767
+				if i == "390" {
2768
+					is390 = 1
2769
+				}
2771 2770
 
2772
-					if i == "310" {
2773
-						is310 = 1
2774
-					}
2771
+				if i == "310" {
2772
+					is310 = 1
2775 2773
 				}
2776 2774
 			}
2777
-			if is390 == 1 {
2778
-				insutype = "390"
2779
-			}
2775
+		}
2776
+		if is390 == 1 {
2777
+			insutype = "390"
2778
+		}
2780 2779
 
2781
-			if is310 == 1 {
2782
-				insutype = "310"
2783
-			}
2780
+		if is310 == 1 {
2781
+			insutype = "310"
2782
+		}
2784 2783
 
2785
-			if len(insutypes) == 0 {
2786
-				insutype = "310"
2787
-			}
2784
+		if len(insutypes) == 0 {
2785
+			insutype = "310"
2786
+		}
2788 2787
 
2789
-			//insutype = "390"
2790
-			if his.IdCardType == 1 {
2791
-				// cert_no = his.MedicalInsuranceNumber
2792
-				cert_no = his.Certno
2788
+		//insutype = "390"
2789
+		if his.IdCardType == 1 {
2790
+			// cert_no = his.MedicalInsuranceNumber
2791
+			cert_no = his.Certno
2793 2792
 
2794
-			} else {
2793
+		} else {
2795 2794
 
2796
-				cert_no = his.Certno
2795
+			cert_no = his.Certno
2797 2796
 
2798
-			}
2799
-			var res ResultSeven
2800
-			var src_resquest string
2801
-			var result2 string
2797
+		}
2798
+		var res ResultSeven
2799
+		var src_resquest string
2800
+		var result2 string
2802 2801
 
2803
-			if miConfig.MdtrtareaAdmvs == "421300" {
2804
-				api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
2805
-					his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
2806
-					"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
2807
-					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
2808
-					"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
2809
-					"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
2810
-					"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
2802
+		if miConfig.MdtrtareaAdmvs == "421300" {
2803
+			api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
2804
+				his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
2805
+				"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
2806
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
2807
+				"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
2808
+				"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
2809
+				"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
2811 2810
 
2812
-				resp, requestErr := http.Get(api)
2813
-				if requestErr != nil {
2814
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2815
-					return
2816
-				}
2811
+			resp, requestErr := http.Get(api)
2812
+			if requestErr != nil {
2813
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2814
+				return
2815
+			}
2817 2816
 
2818
-				body, ioErr := ioutil.ReadAll(resp.Body)
2819
-				if ioErr != nil {
2820
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2821
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2822
-					return
2823
-				}
2824
-				var respJSON map[string]interface{}
2825
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2826
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2827
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2828
-					return
2829
-				}
2817
+			body, ioErr := ioutil.ReadAll(resp.Body)
2818
+			if ioErr != nil {
2819
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2820
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2821
+				return
2822
+			}
2823
+			var respJSON map[string]interface{}
2824
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2825
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2826
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2827
+				return
2828
+			}
2830 2829
 
2831
-				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2832
-				result, _ := json.Marshal(respJSON)
2833
-				fmt.Println("log")
2834
-				fmt.Println(string(result))
2835
-				if err := json.Unmarshal([]byte(result), &res); err != nil {
2836
-					utils.ErrorLog("解析失败:%v", err)
2837
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2838
-					return
2839
-				}
2830
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2831
+			result, _ := json.Marshal(respJSON)
2832
+			fmt.Println("log")
2833
+			fmt.Println(string(result))
2834
+			if err := json.Unmarshal([]byte(result), &res); err != nil {
2835
+				utils.ErrorLog("解析失败:%v", err)
2836
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2837
+				return
2838
+			}
2839
+
2840
+		} else {
2840 2841
 
2842
+			result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
2843
+			var dat map[string]interface{}
2844
+			if err := json.Unmarshal([]byte(result2), &dat); err == nil {
2845
+				fmt.Println(dat)
2841 2846
 			} else {
2847
+				fmt.Println(err)
2848
+			}
2842 2849
 
2843
-				result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
2844
-				var dat map[string]interface{}
2845
-				if err := json.Unmarshal([]byte(result2), &dat); err == nil {
2846
-					fmt.Println(dat)
2847
-				} else {
2848
-					fmt.Println(err)
2849
-				}
2850
+			saveLog(result2, src_resquest, "2207", "结算")
2850 2851
 
2851
-				saveLog(result2, src_resquest, "2207", "结算")
2852
+			userJSONBytes, _ := json.Marshal(dat)
2852 2853
 
2853
-				userJSONBytes, _ := json.Marshal(dat)
2854
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2855
+				utils.ErrorLog("解析失败:%v", err)
2856
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2857
+				return
2858
+			}
2854 2859
 
2855
-				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2856
-					utils.ErrorLog("解析失败:%v", err)
2857
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2858
-					return
2859
-				}
2860
+		}
2860 2861
 
2862
+		if res.Infcode != 0 {
2863
+			errlog := &models.HisOrderError{
2864
+				UserOrgId:  adminUser.CurrentOrgId,
2865
+				Ctime:      time.Now().Unix(),
2866
+				Mtime:      time.Now().Unix(),
2867
+				Number:     chrg_bchno,
2868
+				ErrMsg:     res.ErrMsg,
2869
+				Status:     1,
2870
+				PatientId:  id,
2871
+				RecordTime: recordDateTime,
2872
+				Stage:      6,
2861 2873
 			}
2862
-
2863
-			if res.Infcode != 0 {
2864
-				errlog := &models.HisOrderError{
2865
-					UserOrgId:  adminUser.CurrentOrgId,
2866
-					Ctime:      time.Now().Unix(),
2867
-					Mtime:      time.Now().Unix(),
2868
-					Number:     chrg_bchno,
2869
-					ErrMsg:     res.ErrMsg,
2870
-					Status:     1,
2871
-					PatientId:  id,
2872
-					RecordTime: recordDateTime,
2873
-					Stage:      6,
2874
-				}
2875
-				service.CreateErrMsgLog(errlog)
2874
+			service.CreateErrMsgLog(errlog)
2875
+			c.ServeSuccessJSON(map[string]interface{}{
2876
+				"failed_code": -10,
2877
+				"msg":         res.ErrMsg,
2878
+			})
2879
+			return
2880
+		} else {
2881
+			order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
2882
+			order.OrderStatus = 2
2883
+			order.MdtrtId = res.Output.Setlinfo.MdtrtID
2884
+			order.SetlId = res.Output.Setlinfo.SetlID
2885
+			order.PsnNo = res.Output.Setlinfo.PsnNo
2886
+			order.PsnName = res.Output.Setlinfo.PsnName
2887
+			order.PsnCertType = res.Output.Setlinfo.PsnCertType
2888
+			order.Certno = res.Output.Setlinfo.Certno
2889
+			order.Gend = res.Output.Setlinfo.Gend
2890
+			order.Naty = res.Output.Setlinfo.Naty
2891
+			order.Age = res.Output.Setlinfo.Age
2892
+			order.Insutype = res.Output.Setlinfo.Insutype
2893
+			order.PsnType = res.Output.Setlinfo.PsnType
2894
+			order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
2895
+			order.SetlTime = res.Output.Setlinfo.SetlTime
2896
+			order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
2897
+			order.MedType = res.Output.Setlinfo.MedType
2898
+			order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
2899
+			order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
2900
+			order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
2901
+			order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
2902
+			order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
2903
+			order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
2904
+			order.HifpPay = res.Output.Setlinfo.HifpPay
2905
+			order.CvlservPay = res.Output.Setlinfo.CvlservPay
2906
+			order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
2907
+			order.HifesPay = res.Output.Setlinfo.HifesPay
2908
+			order.HifobPay = res.Output.Setlinfo.HifobPay
2909
+			order.MafPay = res.Output.Setlinfo.MafPay
2910
+			order.HifmiPay = res.Output.Setlinfo.HifmiPay
2911
+			order.OthPay = res.Output.Setlinfo.OthPay
2912
+			order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
2913
+			order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
2914
+			order.AcctPay = res.Output.Setlinfo.AcctPay
2915
+			order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
2916
+			order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
2917
+			order.Balc = res.Output.Setlinfo.Balc
2918
+			order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
2919
+			order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
2920
+			order.ClrOptins = res.Output.Setlinfo.ClrOptins
2921
+			order.ClrWay = res.Output.Setlinfo.ClrWay
2922
+			order.Creator = order.Creator
2923
+			order.Modify = roles.AdminUserId
2924
+			order.RequestLog = src_resquest
2925
+			order.Diagnosis = diagnosis_id
2926
+			setlDetail, _ := json.Marshal(res.Output.Setldetail)
2927
+			detailStr := string(setlDetail)
2928
+			order.SetlDetail = detailStr
2929
+			err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
2930
+			err = service.UpDateOrder(order)
2931
+			if err == nil {
2876 2932
 				c.ServeSuccessJSON(map[string]interface{}{
2877
-					"failed_code": -10,
2878
-					"msg":         res.ErrMsg,
2933
+					"msg": "结算成功",
2879 2934
 				})
2880
-				return
2881 2935
 			} else {
2882
-				order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
2883
-				order.OrderStatus = 2
2884
-				order.MdtrtId = res.Output.Setlinfo.MdtrtID
2885
-				order.SetlId = res.Output.Setlinfo.SetlID
2886
-				order.PsnNo = res.Output.Setlinfo.PsnNo
2887
-				order.PsnName = res.Output.Setlinfo.PsnName
2888
-				order.PsnCertType = res.Output.Setlinfo.PsnCertType
2889
-				order.Certno = res.Output.Setlinfo.Certno
2890
-				order.Gend = res.Output.Setlinfo.Gend
2891
-				order.Naty = res.Output.Setlinfo.Naty
2892
-				order.Age = res.Output.Setlinfo.Age
2893
-				order.Insutype = res.Output.Setlinfo.Insutype
2894
-				order.PsnType = res.Output.Setlinfo.PsnType
2895
-				order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
2896
-				order.SetlTime = res.Output.Setlinfo.SetlTime
2897
-				order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
2898
-				order.MedType = res.Output.Setlinfo.MedType
2899
-				order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
2900
-				order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
2901
-				order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
2902
-				order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
2903
-				order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
2904
-				order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
2905
-				order.HifpPay = res.Output.Setlinfo.HifpPay
2906
-				order.CvlservPay = res.Output.Setlinfo.CvlservPay
2907
-				order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
2908
-				order.HifesPay = res.Output.Setlinfo.HifesPay
2909
-				order.HifobPay = res.Output.Setlinfo.HifobPay
2910
-				order.MafPay = res.Output.Setlinfo.MafPay
2911
-				order.HifmiPay = res.Output.Setlinfo.HifmiPay
2912
-				order.OthPay = res.Output.Setlinfo.OthPay
2913
-				order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
2914
-				order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
2915
-				order.AcctPay = res.Output.Setlinfo.AcctPay
2916
-				order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
2917
-				order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
2918
-				order.Balc = res.Output.Setlinfo.Balc
2919
-				order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
2920
-				order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
2921
-				order.ClrOptins = res.Output.Setlinfo.ClrOptins
2922
-				order.ClrWay = res.Output.Setlinfo.ClrWay
2923
-				order.Creator = order.Creator
2924
-				order.Modify = roles.AdminUserId
2925
-				order.RequestLog = src_resquest
2926
-				order.Diagnosis = diagnosis_id
2927
-				setlDetail, _ := json.Marshal(res.Output.Setldetail)
2928
-				detailStr := string(setlDetail)
2929
-				order.SetlDetail = detailStr
2930
-				err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
2931
-				err = service.UpDateOrder(order)
2932
-				if err == nil {
2933
-					c.ServeSuccessJSON(map[string]interface{}{
2934
-						"msg": "结算成功",
2935
-					})
2936
-				} else {
2937
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
2938
-					return
2939
-				}
2936
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
2937
+				return
2940 2938
 			}
2941
-
2942 2939
 		}
2943
-
2944 2940
 	}
2945 2941
 }
2946 2942