Bladeren bron

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

csx 3 jaren geleden
bovenliggende
commit
80d182e0a5
2 gewijzigde bestanden met toevoegingen van 173 en 168 verwijderingen
  1. 172 166
      controllers/sg/his_api_controller.go
  2. 1 2
      main.go

+ 172 - 166
controllers/sg/his_api_controller.go Bestand weergeven

@@ -2712,7 +2712,12 @@ func (c *HisApiController) GetUploadInfo() {
2712 2712
 							order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
2713 2713
 							order.SetlTime = res.Output.Setlinfo.SetlTime
2714 2714
 							order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
2715
-							order.MedType = res.Output.Setlinfo.MedType
2715
+							if res.Output.Setlinfo.MedType == "140101" {
2716
+								order.MedType = "14"
2717
+
2718
+							} else {
2719
+								order.MedType = res.Output.Setlinfo.MedType
2720
+							}
2716 2721
 							order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
2717 2722
 							order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
2718 2723
 							order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
@@ -2797,200 +2802,201 @@ func (c *HisApiController) GetUploadInfo() {
2797 2802
 		}
2798 2803
 
2799 2804
 	} else if tempOrder.ID > 0 {
2805
+		if tempOrder.IsPre == 1 {
2806
+			allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
2807
+			var rf []*ResultFive
2808
+			json.Unmarshal([]byte(his.Iinfo), &rf)
2809
+			chrg_bchno := tempOrder.Number
2810
+			cert_no := his.Certno
2800 2811
 
2801
-		allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
2802
-		var rf []*ResultFive
2803
-		json.Unmarshal([]byte(his.Iinfo), &rf)
2804
-		chrg_bchno := tempOrder.Number
2805
-		cert_no := his.Certno
2806
-
2807
-		var insutypes []string
2812
+			var insutypes []string
2808 2813
 
2809
-		var insutype string
2810
-		var is390 int = 0
2811
-		var is310 int = 0
2814
+			var insutype string
2815
+			var is390 int = 0
2816
+			var is310 int = 0
2812 2817
 
2813
-		for _, item := range rf {
2814
-			if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2815
-				insutypes = append(insutypes, item.Insutype)
2818
+			for _, item := range rf {
2819
+				if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
2820
+					insutypes = append(insutypes, item.Insutype)
2821
+				}
2816 2822
 			}
2817
-		}
2818 2823
 
2819
-		if len(insutypes) == 1 {
2820
-			insutype = insutypes[0]
2821
-		} else {
2822
-			for _, i := range insutypes {
2823
-				if i == "390" {
2824
-					is390 = 1
2825
-				}
2824
+			if len(insutypes) == 1 {
2825
+				insutype = insutypes[0]
2826
+			} else {
2827
+				for _, i := range insutypes {
2828
+					if i == "390" {
2829
+						is390 = 1
2830
+					}
2826 2831
 
2827
-				if i == "310" {
2828
-					is310 = 1
2832
+					if i == "310" {
2833
+						is310 = 1
2834
+					}
2829 2835
 				}
2830 2836
 			}
2831
-		}
2832
-		if is390 == 1 {
2833
-			insutype = "390"
2834
-		}
2835
-
2836
-		if is310 == 1 {
2837
-			insutype = "310"
2838
-		}
2839
-
2840
-		if len(insutypes) == 0 {
2841
-			insutype = "310"
2842
-		}
2837
+			if is390 == 1 {
2838
+				insutype = "390"
2839
+			}
2843 2840
 
2844
-		//insutype = "390"
2845
-		if his.IdCardType == 1 {
2846
-			// cert_no = his.MedicalInsuranceNumber
2847
-			cert_no = his.Certno
2841
+			if is310 == 1 {
2842
+				insutype = "310"
2843
+			}
2848 2844
 
2849
-		} else {
2845
+			if len(insutypes) == 0 {
2846
+				insutype = "310"
2847
+			}
2850 2848
 
2851
-			cert_no = his.Certno
2849
+			//insutype = "390"
2850
+			if his.IdCardType == 1 {
2851
+				// cert_no = his.MedicalInsuranceNumber
2852
+				cert_no = his.Certno
2852 2853
 
2853
-		}
2854
-		var res ResultSeven
2855
-		var src_resquest string
2856
-		var result2 string
2854
+			} else {
2857 2855
 
2858
-		if miConfig.MdtrtareaAdmvs == "421300" {
2859
-			api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
2860
-				his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
2861
-				"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
2862
-				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
2863
-				"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
2864
-				"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
2865
-				"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
2856
+				cert_no = his.Certno
2866 2857
 
2867
-			resp, requestErr := http.Get(api)
2868
-			if requestErr != nil {
2869
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2870
-				return
2871 2858
 			}
2859
+			var res ResultSeven
2860
+			var src_resquest string
2861
+			var result2 string
2872 2862
 
2873
-			body, ioErr := ioutil.ReadAll(resp.Body)
2874
-			if ioErr != nil {
2875
-				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2876
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2877
-				return
2878
-			}
2879
-			var respJSON map[string]interface{}
2880
-			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2881
-				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2882
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2883
-				return
2884
-			}
2863
+			if miConfig.MdtrtareaAdmvs == "421300" {
2864
+				api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
2865
+					his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
2866
+					"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
2867
+					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
2868
+					"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
2869
+					"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
2870
+					"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
2885 2871
 
2886
-			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2887
-			result, _ := json.Marshal(respJSON)
2888
-			fmt.Println("log")
2889
-			fmt.Println(string(result))
2890
-			if err := json.Unmarshal([]byte(result), &res); err != nil {
2891
-				utils.ErrorLog("解析失败:%v", err)
2892
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2893
-				return
2894
-			}
2872
+				resp, requestErr := http.Get(api)
2873
+				if requestErr != nil {
2874
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2875
+					return
2876
+				}
2895 2877
 
2896
-		} else {
2878
+				body, ioErr := ioutil.ReadAll(resp.Body)
2879
+				if ioErr != nil {
2880
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2881
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2882
+					return
2883
+				}
2884
+				var respJSON map[string]interface{}
2885
+				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2886
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2887
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2888
+					return
2889
+				}
2890
+
2891
+				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2892
+				result, _ := json.Marshal(respJSON)
2893
+				fmt.Println("log")
2894
+				fmt.Println(string(result))
2895
+				if err := json.Unmarshal([]byte(result), &res); err != nil {
2896
+					utils.ErrorLog("解析失败:%v", err)
2897
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2898
+					return
2899
+				}
2897 2900
 
2898
-			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)
2899
-			var dat map[string]interface{}
2900
-			if err := json.Unmarshal([]byte(result2), &dat); err == nil {
2901
-				fmt.Println(dat)
2902 2901
 			} else {
2903
-				fmt.Println(err)
2904
-			}
2905 2902
 
2906
-			saveLog(result2, src_resquest, "2207", "结算")
2903
+				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)
2904
+				var dat map[string]interface{}
2905
+				if err := json.Unmarshal([]byte(result2), &dat); err == nil {
2906
+					fmt.Println(dat)
2907
+				} else {
2908
+					fmt.Println(err)
2909
+				}
2907 2910
 
2908
-			userJSONBytes, _ := json.Marshal(dat)
2911
+				saveLog(result2, src_resquest, "2207", "结算")
2909 2912
 
2910
-			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2911
-				utils.ErrorLog("解析失败:%v", err)
2912
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2913
-				return
2914
-			}
2913
+				userJSONBytes, _ := json.Marshal(dat)
2915 2914
 
2916
-		}
2915
+				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2916
+					utils.ErrorLog("解析失败:%v", err)
2917
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2918
+					return
2919
+				}
2917 2920
 
2918
-		if res.Infcode != 0 {
2919
-			errlog := &models.HisOrderError{
2920
-				UserOrgId:  adminUser.CurrentOrgId,
2921
-				Ctime:      time.Now().Unix(),
2922
-				Mtime:      time.Now().Unix(),
2923
-				Number:     chrg_bchno,
2924
-				ErrMsg:     res.ErrMsg,
2925
-				Status:     1,
2926
-				PatientId:  id,
2927
-				RecordTime: recordDateTime,
2928
-				Stage:      6,
2929 2921
 			}
2930
-			service.CreateErrMsgLog(errlog)
2931
-			c.ServeSuccessJSON(map[string]interface{}{
2932
-				"failed_code": -10,
2933
-				"msg":         res.ErrMsg,
2934
-			})
2935
-			return
2936
-		} else {
2937
-			order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
2938
-			order.OrderStatus = 2
2939
-			order.MdtrtId = res.Output.Setlinfo.MdtrtID
2940
-			order.SetlId = res.Output.Setlinfo.SetlID
2941
-			order.PsnNo = res.Output.Setlinfo.PsnNo
2942
-			order.PsnName = res.Output.Setlinfo.PsnName
2943
-			order.PsnCertType = res.Output.Setlinfo.PsnCertType
2944
-			order.Certno = res.Output.Setlinfo.Certno
2945
-			order.Gend = res.Output.Setlinfo.Gend
2946
-			order.Naty = res.Output.Setlinfo.Naty
2947
-			order.Age = res.Output.Setlinfo.Age
2948
-			order.Insutype = res.Output.Setlinfo.Insutype
2949
-			order.PsnType = res.Output.Setlinfo.PsnType
2950
-			order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
2951
-			order.SetlTime = res.Output.Setlinfo.SetlTime
2952
-			order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
2953
-			order.MedType = res.Output.Setlinfo.MedType
2954
-			order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
2955
-			order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
2956
-			order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
2957
-			order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
2958
-			order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
2959
-			order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
2960
-			order.HifpPay = res.Output.Setlinfo.HifpPay
2961
-			order.CvlservPay = res.Output.Setlinfo.CvlservPay
2962
-			order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
2963
-			order.HifesPay = res.Output.Setlinfo.HifesPay
2964
-			order.HifobPay = res.Output.Setlinfo.HifobPay
2965
-			order.MafPay = res.Output.Setlinfo.MafPay
2966
-			order.HifmiPay = res.Output.Setlinfo.HifmiPay
2967
-			order.OthPay = res.Output.Setlinfo.OthPay
2968
-			order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
2969
-			order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
2970
-			order.AcctPay = res.Output.Setlinfo.AcctPay
2971
-			order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
2972
-			order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
2973
-			order.Balc = res.Output.Setlinfo.Balc
2974
-			order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
2975
-			order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
2976
-			order.ClrOptins = res.Output.Setlinfo.ClrOptins
2977
-			order.ClrWay = res.Output.Setlinfo.ClrWay
2978
-			order.Creator = order.Creator
2979
-			order.Modify = roles.AdminUserId
2980
-			order.RequestLog = src_resquest
2981
-			order.Diagnosis = diagnosis_id
2982
-			setlDetail, _ := json.Marshal(res.Output.Setldetail)
2983
-			detailStr := string(setlDetail)
2984
-			order.SetlDetail = detailStr
2985
-			err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
2986
-			err = service.UpDateOrder(order)
2987
-			if err == nil {
2922
+
2923
+			if res.Infcode != 0 {
2924
+				errlog := &models.HisOrderError{
2925
+					UserOrgId:  adminUser.CurrentOrgId,
2926
+					Ctime:      time.Now().Unix(),
2927
+					Mtime:      time.Now().Unix(),
2928
+					Number:     chrg_bchno,
2929
+					ErrMsg:     res.ErrMsg,
2930
+					Status:     1,
2931
+					PatientId:  id,
2932
+					RecordTime: recordDateTime,
2933
+					Stage:      6,
2934
+				}
2935
+				service.CreateErrMsgLog(errlog)
2988 2936
 				c.ServeSuccessJSON(map[string]interface{}{
2989
-					"msg": "结算成功",
2937
+					"failed_code": -10,
2938
+					"msg":         res.ErrMsg,
2990 2939
 				})
2991
-			} else {
2992
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
2993 2940
 				return
2941
+			} else {
2942
+				order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
2943
+				order.OrderStatus = 2
2944
+				order.MdtrtId = res.Output.Setlinfo.MdtrtID
2945
+				order.SetlId = res.Output.Setlinfo.SetlID
2946
+				order.PsnNo = res.Output.Setlinfo.PsnNo
2947
+				order.PsnName = res.Output.Setlinfo.PsnName
2948
+				order.PsnCertType = res.Output.Setlinfo.PsnCertType
2949
+				order.Certno = res.Output.Setlinfo.Certno
2950
+				order.Gend = res.Output.Setlinfo.Gend
2951
+				order.Naty = res.Output.Setlinfo.Naty
2952
+				order.Age = res.Output.Setlinfo.Age
2953
+				order.Insutype = res.Output.Setlinfo.Insutype
2954
+				order.PsnType = res.Output.Setlinfo.PsnType
2955
+				order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
2956
+				order.SetlTime = res.Output.Setlinfo.SetlTime
2957
+				order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
2958
+				order.MedType = res.Output.Setlinfo.MedType
2959
+				order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
2960
+				order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
2961
+				order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
2962
+				order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
2963
+				order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
2964
+				order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
2965
+				order.HifpPay = res.Output.Setlinfo.HifpPay
2966
+				order.CvlservPay = res.Output.Setlinfo.CvlservPay
2967
+				order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
2968
+				order.HifesPay = res.Output.Setlinfo.HifesPay
2969
+				order.HifobPay = res.Output.Setlinfo.HifobPay
2970
+				order.MafPay = res.Output.Setlinfo.MafPay
2971
+				order.HifmiPay = res.Output.Setlinfo.HifmiPay
2972
+				order.OthPay = res.Output.Setlinfo.OthPay
2973
+				order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
2974
+				order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
2975
+				order.AcctPay = res.Output.Setlinfo.AcctPay
2976
+				order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
2977
+				order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
2978
+				order.Balc = res.Output.Setlinfo.Balc
2979
+				order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
2980
+				order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
2981
+				order.ClrOptins = res.Output.Setlinfo.ClrOptins
2982
+				order.ClrWay = res.Output.Setlinfo.ClrWay
2983
+				order.Creator = order.Creator
2984
+				order.Modify = roles.AdminUserId
2985
+				order.RequestLog = src_resquest
2986
+				order.Diagnosis = diagnosis_id
2987
+				setlDetail, _ := json.Marshal(res.Output.Setldetail)
2988
+				detailStr := string(setlDetail)
2989
+				order.SetlDetail = detailStr
2990
+				err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
2991
+				err = service.UpDateOrder(order)
2992
+				if err == nil {
2993
+					c.ServeSuccessJSON(map[string]interface{}{
2994
+						"msg": "结算成功",
2995
+					})
2996
+				} else {
2997
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
2998
+					return
2999
+				}
2994 3000
 			}
2995 3001
 		}
2996 3002
 	}

+ 1 - 2
main.go Bestand weergeven

@@ -5,7 +5,6 @@ import (
5 5
 	"fmt"
6 6
 	"gdyb/models"
7 7
 	_ "gdyb/routers"
8
-	"gdyb/service"
9 8
 	"github.com/astaxie/beego"
10 9
 	"github.com/qiniu/api.v7/auth/qbox"
11 10
 	"github.com/qiniu/api.v7/storage"
@@ -15,7 +14,7 @@ import (
15 14
 )
16 15
 
17 16
 func init() {
18
-	service.ConnectDB()
17
+	//service.ConnectDB()
19 18
 	//org_id, _ := beego.AppConfig.Int64("org_id")
20 19
 	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
21 20
 	//CreateLog(miConfig)