Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 1 month ago
parent
commit
41c4a5aabc
4 changed files with 382 additions and 117 deletions
  1. 287 57
      controllers/fapiao_controller.go
  2. 16 1
      controllers/his_api_controller.go
  3. 77 59
      models/fapiao.go
  4. 2 0
      models/his_models.go

+ 287 - 57
controllers/fapiao_controller.go View File

@@ -30,6 +30,108 @@ func FaPiaoApiRegistRouters() {
30 30
 
31 31
 	beego.Router("/api/newfapiao/get", &HisApiController{}, "get:GetNewFaPiaoData")
32 32
 
33
+	beego.Router("/api/fapiao/query", &FapiaoApiController{}, "get:QueryFaPiao")
34
+
35
+}
36
+
37
+func (c *FapiaoApiController) QueryFaPiao() {
38
+	id, _ := c.GetInt64("id")
39
+	oc, _ := service.GetFaPiaoOrderById(id)
40
+	sdk := invoice.NewSdk(common.HMAC_SHA256, "5058f0defd12047ee2a7", "51440fbee667ea9a53aaa68c9c408367", "", "")
41
+	var config models.FapiaoConfig
42
+	config, _ = service.FindFaPiaoConfigInfo(c.GetAdminUserInfo().CurrentOrgId)
43
+	routerAddress2, postData2 := fapiao.Query(config.SellerTaxpayerNum, oc.OrderSn, "")
44
+	r3, err2 := sdk.HttpPost("https://apigw.goldentec.com", routerAddress2, postData2)
45
+	fmt.Println("query")
46
+	fmt.Println(string(r3))
47
+	if err2 != nil {
48
+		fmt.Println(err2)
49
+	} else {
50
+		var resp3 QueryFaPiaoResultResponse
51
+		// 将 byte 切片转换为结构体
52
+		json.Unmarshal(r3, &resp3)
53
+		if resp3.Code == 0 {
54
+			//var fapiaos models.HisFaPiaoOrder
55
+			if resp3.Data.Status == 3 {
56
+				// 异步调用查询操作,不阻塞主程序
57
+				oc.TicketSn = resp3.Data.TicketSn
58
+				oc.TicketDate = resp3.Data.TicketDate
59
+				oc.AmountWithTax = resp3.Data.AmountWithoutTax
60
+				oc.AmountWithoutTax = resp3.Data.AmountWithoutTax
61
+				oc.FapiaoStatus = "2"
62
+				oc.TaxAmount = resp3.Data.TaxAmount
63
+				oc.IsRedWashed = strconv.FormatInt(int64(resp3.Data.IsRedWashed), 10)
64
+				oc.PdfUrl = resp3.Data.PdfUrl
65
+				oc.OfdUrl = resp3.Data.OfdUrl
66
+				oc.XmlUrl = resp3.Data.XmlUrl
67
+				service.SaveFaPiaoOrder(&oc)
68
+				ids := strings.Split(oc.OrderIds, ",")
69
+				service.UpdateFaPiaoNumber(resp3.Data.TicketSn, ids) //同步发票号码
70
+
71
+				c.ServeSuccessJSON(map[string]interface{}{
72
+					"msg": "同步成功",
73
+				})
74
+
75
+			} else if resp3.Data.Status == 1 {
76
+				oc.FapiaoStatus = "1"
77
+				oc.TicketSn = ""
78
+				service.SaveFaPiaoOrder(&oc)
79
+
80
+				c.ServeSuccessJSON(map[string]interface{}{
81
+					"msg": "同步成功",
82
+				})
83
+				//service.UpdateFaPiaoNumber(resp3.Data.TicketSn, ids) //同步发票号码
84
+			} else if resp3.Data.Status == 2 {
85
+				oc.FapiaoStatus = "3"
86
+				oc.TicketSn = ""
87
+				oc.Message = resp3.Data.Message
88
+				service.SaveFaPiaoOrder(&oc)
89
+
90
+				c.ServeSuccessJSON(map[string]interface{}{
91
+					"msg": "同步成功",
92
+				})
93
+			} else {
94
+				oc.FapiaoStatus = "3"
95
+				oc.TicketSn = ""
96
+				oc.Message = resp3.Data.Message
97
+				service.SaveFaPiaoOrder(&oc)
98
+
99
+				c.ServeSuccessJSON(map[string]interface{}{
100
+					"msg": "同步成功",
101
+				})
102
+			}
103
+		} else {
104
+			//错误处理
105
+			c.ServeSuccessJSON(map[string]interface{}{
106
+				"msg": "查询失败" + resp3.Message,
107
+			})
108
+		}
109
+		//if resp3.Code == 0 {
110
+		//	// 异步调用查询操作,不阻塞主程序
111
+		//	oc.TicketSn = resp3.Data.TicketSn
112
+		//	oc.TicketDate = resp3.Data.TicketDate
113
+		//	oc.AmountWithTax = resp3.Data.AmountWithoutTax
114
+		//	oc.AmountWithoutTax = resp3.Data.AmountWithoutTax
115
+		//	oc.FapiaoStatus = "2"
116
+		//	oc.TaxAmount = resp3.Data.TaxAmount
117
+		//	oc.IsRedWashed = strconv.FormatInt(int64(resp3.Data.IsRedWashed), 10)
118
+		//	oc.PdfUrl = resp3.Data.PdfUrl
119
+		//	oc.OfdUrl = resp3.Data.OfdUrl
120
+		//	oc.XmlUrl = resp3.Data.XmlUrl
121
+		//	service.SaveFaPiaoOrder(oc)
122
+		//	ids := strings.Split(oc.OrderIds, ",")
123
+		//	service.UpdateFaPiaoNumber(resp3.Data.TicketSn, ids) //同步发票号码
124
+		//	c.ServeSuccessJSON(map[string]interface{}{
125
+		//		"msg": "查询成功",
126
+		//	})
127
+		//} else {
128
+		//	//错误处理
129
+		//	c.ServeSuccessJSON(map[string]interface{}{
130
+		//		"msg": "查询失败" + resp3.Message,
131
+		//	})
132
+		//}
133
+	}
134
+
33 135
 }
34 136
 
35 137
 func (c *HisApiController) GetNewFaPiaoData() {
@@ -719,6 +821,7 @@ func (c *FapiaoApiController) GetQRCode() {
719 821
 		//fmt.Println(string(r))
720 822
 	}
721 823
 }
824
+
722 825
 func (c *FapiaoApiController) OpenFaPiao() {
723 826
 	//var config models.FapiaoConfig
724 827
 	//config, _ = service.FindFaPiaoConfigInfo(c.GetAdminUserInfo().CurrentOrgId)
@@ -769,19 +872,109 @@ func (c *FapiaoApiController) OpenFaPiao() {
769 872
 	var PsnCashPay float64 = 0    //治疗费用
770 873
 	var FundPaySumamt float64 = 0 //治疗费用
771 874
 
875
+	var HifmiPay float64 = 0 //治疗费用
876
+	var MafPay float64 = 0   //治疗费用
877
+	var HifpPay float64 = 0  //治疗费用
878
+	var AcctPay float64 = 0  //治疗费用
879
+
772 880
 	var details []models.HisOrderInfo
773 881
 	var numbers []string
774 882
 	decimal.DivisionPrecision = 2
775 883
 
884
+	var remark string
885
+
776 886
 	for _, oss := range orders {
777 887
 		MedfeeSumamt, _ = decimal.NewFromFloat(MedfeeSumamt).Add(decimal.NewFromFloat(oss.MedfeeSumamt)).Float64()
778 888
 		PsnCashPay, _ = decimal.NewFromFloat(PsnCashPay).Add(decimal.NewFromFloat(oss.PsnCashPay)).Float64()
779 889
 		FundPaySumamt, _ = decimal.NewFromFloat(FundPaySumamt).Add(decimal.NewFromFloat(oss.FundPaySumamt)).Float64()
890
+
891
+		HifmiPay, _ = decimal.NewFromFloat(HifmiPay).Add(decimal.NewFromFloat(oss.HifmiPay)).Float64()
892
+		MafPay, _ = decimal.NewFromFloat(MafPay).Add(decimal.NewFromFloat(oss.MafPay)).Float64()
893
+		HifpPay, _ = decimal.NewFromFloat(HifpPay).Add(decimal.NewFromFloat(oss.HifpPay)).Float64()
894
+		AcctPay, _ = decimal.NewFromFloat(AcctPay).Add(decimal.NewFromFloat(oss.AcctPay)).Float64()
895
+
780 896
 		numbers = append(numbers, oss.Number)
781 897
 	}
898
+	if MedfeeSumamt > 0 {
899
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
900
+
901
+		if len(remark) == 0 {
902
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
903
+			remark = "医疗总费用: " + MedfeeSumamt_str
904
+		} else {
905
+			remark = remark + " 医疗总费用:" + MedfeeSumamt_str
906
+		}
907
+	}
908
+
909
+	if FundPaySumamt > 0 {
910
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", FundPaySumamt)
911
+
912
+		if len(remark) == 0 {
913
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
914
+			remark = "基金支付总金额: " + MedfeeSumamt_str
915
+		} else {
916
+			remark = remark + " 基金支付总金额:" + MedfeeSumamt_str
917
+		}
918
+	}
919
+
920
+	if PsnCashPay > 0 {
921
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", PsnCashPay)
922
+
923
+		if len(remark) == 0 {
924
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
925
+			remark = "个人现金支付: " + MedfeeSumamt_str
926
+		} else {
927
+			remark = remark + " 个人现金支付:" + MedfeeSumamt_str
928
+		}
929
+	}
930
+
931
+	if HifmiPay > 0 {
932
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", HifmiPay)
933
+
934
+		if len(remark) == 0 {
935
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
936
+			remark = "大病基金支付: " + MedfeeSumamt_str
937
+		} else {
938
+			remark = remark + " 大病基金支付:" + MedfeeSumamt_str
939
+		}
940
+	}
941
+
942
+	if AcctPay > 0 {
943
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", AcctPay)
944
+
945
+		if len(remark) == 0 {
946
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
947
+			remark = "个账支付: " + MedfeeSumamt_str
948
+		} else {
949
+			remark = remark + " 个账支付:" + MedfeeSumamt_str
950
+		}
951
+	}
952
+
953
+	if HifpPay > 0 {
954
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", HifpPay)
955
+
956
+		if len(remark) == 0 {
957
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
958
+			remark = "基本统筹基金支付: " + MedfeeSumamt_str
959
+		} else {
960
+			remark = remark + " 基本统筹基金支付:" + MedfeeSumamt_str
961
+		}
962
+	}
963
+
964
+	if MafPay > 0 {
965
+		MedfeeSumamt_str := fmt.Sprintf("%.2f", MafPay)
966
+
967
+		if len(remark) == 0 {
968
+			//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
969
+			remark = "医疗救助基金支付: " + MedfeeSumamt_str
970
+		} else {
971
+			remark = remark + " 医疗救助基金支付:" + MedfeeSumamt_str
972
+		}
973
+	}
974
+
782 975
 	details, _ = service.GetFaPiaoOrderInfoByNumbers(numbers)
783 976
 	role, _ := service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
784
-	role.UserName = "邹碧琳"
977
+	//role.UserName = ""
785 978
 	type CostType struct {
786 979
 		name  string
787 980
 		price float64
@@ -922,8 +1115,12 @@ func (c *FapiaoApiController) OpenFaPiao() {
922 1115
 	var config2 models.FapiaoConfig
923 1116
 	config2, _ = service.FindFaPiaoConfigInfo(c.GetAdminUserInfo().CurrentOrgId)
924 1117
 	number := strconv.FormatInt(time.Now().Unix(), 10) + "_" + strconv.FormatInt(orders[0].UserOrgId, 10) + "_" + strconv.FormatInt(orders[0].PatientId, 10)
925
-	amountWithoutTax, _, taxAmount, amountHasTax := CalculatePriceDetails(MedfeeSumamt, 1, 0.13)
1118
+	amountWithoutTax, _, taxAmount, amountHasTax := CalculatePriceDetails(MedfeeSumamt, 1, 0.00)
926 1119
 
1120
+	patient, _ := service.GetXTPatientInfo(c.GetAdminUserInfo().CurrentOrgId, orders[0].PatientId)
1121
+
1122
+	orders[0].PsnName = patient.Name
1123
+	role.UserName = "陈金娣"
927 1124
 	postData3 := map[string]interface{}{
928 1125
 		"seller_name":          org_config.OrgName,
929 1126
 		"seller_taxpayer_num":  config2.SellerTaxpayerNum,
@@ -932,7 +1129,7 @@ func (c *FapiaoApiController) OpenFaPiao() {
932 1129
 		"seller_bank_name":     config2.SellerBankName,
933 1130
 		"seller_bank_account":  config2.SellerBankAccount,
934 1131
 		"title_type":           1,
935
-		"buyer_title":          orders[0].PsnName,
1132
+		"buyer_title":          orders[0].PsnName + "(个人)",
936 1133
 		"buyer_taxpayer_num":   "",
937 1134
 		"buyer_address":        "",
938 1135
 		"buyer_phone":          "",
@@ -953,14 +1150,14 @@ func (c *FapiaoApiController) OpenFaPiao() {
953 1150
 		"amount_has_tax":       amountHasTax,
954 1151
 		"tax_amount":           taxAmount,
955 1152
 		"amount_without_tax":   amountWithoutTax,
956
-		"remark":               "医疗发票",
1153
+		"remark":               remark,
957 1154
 	}
958 1155
 
959 1156
 	////项目商品明细
960 1157
 	items := make([]map[string]interface{}, 0)
961 1158
 	for _, ct := range cts {
962 1159
 		item := make(map[string]interface{})
963
-		amountWithoutTax, _, taxAmount, _ := CalculatePriceDetails(ct.price, 1, 0.06)
1160
+		amountWithoutTax, _, taxAmount, _ := CalculatePriceDetails(ct.price, 1, 0.00)
964 1161
 		item["name"] = ct.name
965 1162
 		item["tax_code"] = "3070202000000000000"
966 1163
 		item["models"] = ""
@@ -968,20 +1165,21 @@ func (c *FapiaoApiController) OpenFaPiao() {
968 1165
 		item["total_price"] = amountWithoutTax
969 1166
 		item["total"] = "1"
970 1167
 		item["price"] = amountWithoutTax
971
-		item["tax_rate"] = "0.06"
1168
+		item["tax_rate"] = "0.00"
972 1169
 		item["tax_amount"] = taxAmount
973 1170
 		item["discount"] = "0"
974
-		item["preferential_policy_flag"] = ""
975
-		item["zero_tax_flag"] = ""
976
-		item["vat_special_management"] = ""
1171
+		item["preferential_policy_flag"] = "1"
1172
+		item["zero_tax_flag"] = "1"
1173
+		item["vat_special_management"] = "免税"
977 1174
 		items = append(items, item)
978 1175
 	}
979
-
980 1176
 	postData3["items"] = items
981
-
982 1177
 	routerAddress, postData4 := fapiao.Blue(postData3) //发票开具
1178
+	fmt.Println(postData4)
1179
+
983 1180
 	r, err4 := sdk.HttpPost("https://apigw.goldentec.com", routerAddress, postData4)
984 1181
 	fmt.Println("blue")
1182
+	fmt.Println(err4)
985 1183
 	fmt.Println(string(r))
986 1184
 	if err4 != nil {
987 1185
 		fmt.Println(err4)
@@ -996,56 +1194,87 @@ func (c *FapiaoApiController) OpenFaPiao() {
996 1194
 			fmt.Println(resp)
997 1195
 
998 1196
 			if resp.Code == 0 {
999
-				//开具蓝票成功,请求查询接口,获取发票相关数据
1000
-				routerAddress2, postData2 := fapiao.Query(config2.SellerTaxpayerNum, resp.Data.OrderSn, number)
1001
-				r3, err2 := sdk.HttpPost("https://apigw.goldentec.com", routerAddress2, postData2)
1002
-				fmt.Println("query")
1003
-				fmt.Println(string(r3))
1004
-				if err2 != nil {
1005
-					fmt.Println(err2)
1006
-				} else {
1007
-					var resp3 QueryFaPiaoResultResponse
1008
-					// 将 byte 切片转换为结构体
1009
-					json.Unmarshal(r3, &resp3)
1010
-					if resp3.Code == 0 {
1011
-						var fapiao models.HisFaPiaoOrder
1012
-						fapiao.InvoiceId = resp.Data.InvoiceId
1013
-						fapiao.OrderSn = resp.Data.OrderSn
1014
-						fapiao.TicketSn = resp3.Data.TicketSn
1015
-						fapiao.TicketDate = resp3.Data.TicketDate
1016
-						fapiao.AmountWithTax = resp3.Data.AmountWithoutTax
1017
-						fapiao.AmountWithoutTax = resp3.Data.AmountWithoutTax
1018
-						fapiao.TaxAmount = resp3.Data.TaxAmount
1019
-						fapiao.IsRedWashed = strconv.FormatInt(int64(resp3.Data.IsRedWashed), 10)
1020
-						fapiao.PdfUrl = resp3.Data.PdfUrl
1021
-						fapiao.OfdUrl = resp3.Data.OfdUrl
1022
-						fapiao.XmlUrl = resp3.Data.XmlUrl
1023
-						fapiao.FapiaoStatus = "1"
1024
-						fapiao.OrderIds = order_ids
1025
-						fapiao.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
1026
-						fapiao.Status = 1
1027
-						fapiao.PatientId = orders[0].PatientId
1028
-						fapiao.Ctime = time.Now().Unix()
1029
-						fapiao.Mtime = time.Now().Unix()
1030
-						fapiao.Creator = role.UserName
1031
-						fapiao.MedfeeSumamt = MedfeeSumamt
1032
-						fapiao.FundPaySumamt = FundPaySumamt
1033
-						fapiao.PsnCashPay = PsnCashPay
1034
-						err5 := service.SaveFaPiaoOrder(fapiao)
1035
-						fmt.Println(err5)
1036
-						if err5 == nil {
1037
-							service.UpdateFaPiaoNumber(resp3.Data.TicketSn, ids) //同步发票号码
1197
+				var fapiaos models.HisFaPiaoOrder
1198
+				fapiaos.InvoiceId = resp.Data.InvoiceId
1199
+				fapiaos.OrderSn = resp.Data.OrderSn
1200
+				fapiaos.FapiaoStatus = "1"
1201
+				fapiaos.OrderIds = order_ids
1202
+				fapiaos.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
1203
+				fapiaos.Status = 1
1204
+				fapiaos.PatientId = orders[0].PatientId
1205
+				fapiaos.Ctime = time.Now().Unix()
1206
+				fapiaos.Mtime = time.Now().Unix()
1207
+				fapiaos.Creator = role.UserName
1208
+				fapiaos.MedfeeSumamt = MedfeeSumamt
1209
+				fapiaos.FundPaySumamt = FundPaySumamt
1210
+				fapiaos.PsnCashPay = PsnCashPay
1211
+				fmt.Println(ids)
1212
+				service.UpdateFaPiaoSN(resp.Data.OrderSn, ids) //同步发票号码
1213
+				err5 := service.SaveFaPiaoOrder(&fapiaos)
1214
+				// 异步调用查询操作,通过闭包传递参数
1215
+				// 异步调用查询操作,通过闭包传递多个参数
1216
+				go func(num string, sn string, number string, fapiaos models.HisFaPiaoOrder, ids []string) {
1217
+					// 延迟等待一定时间再查询
1218
+					time.Sleep(30 * time.Second)
1219
+					// 调用查询发票的函数
1220
+					//queryInvoice(id, user, retries)
1221
+					routerAddress2, postData2 := fapiao.Query(num, sn, number)
1222
+					r3, err2 := sdk.HttpPost("https://apigw.goldentec.com", routerAddress2, postData2)
1223
+					fmt.Println("query")
1224
+					fmt.Println(string(r3))
1225
+					if err2 != nil {
1226
+						fmt.Println(err2)
1227
+					} else {
1228
+						var resp3 QueryFaPiaoResultResponse
1229
+						// 将 byte 切片转换为结构体
1230
+						json.Unmarshal(r3, &resp3)
1231
+						if resp3.Code == 0 {
1232
+							if resp3.Data.Status == 3 {
1233
+								// 异步调用查询操作,不阻塞主程序
1234
+								fapiaos.TicketSn = resp3.Data.TicketSn
1235
+								fapiaos.TicketDate = resp3.Data.TicketDate
1236
+								fapiaos.AmountWithTax = resp3.Data.AmountWithoutTax
1237
+								fapiaos.AmountWithoutTax = resp3.Data.AmountWithoutTax
1238
+								fapiaos.FapiaoStatus = "2"
1239
+								fapiaos.TaxAmount = resp3.Data.TaxAmount
1240
+								fapiaos.IsRedWashed = strconv.FormatInt(int64(resp3.Data.IsRedWashed), 10)
1241
+								fapiaos.PdfUrl = resp3.Data.PdfUrl
1242
+								fapiaos.OfdUrl = resp3.Data.OfdUrl
1243
+								fapiaos.XmlUrl = resp3.Data.XmlUrl
1244
+								service.SaveFaPiaoOrder(&fapiaos)
1245
+								service.UpdateFaPiaoNumber(resp3.Data.TicketSn, ids) //同步发票号码
1246
+
1247
+							} else if resp3.Data.Status == 1 {
1248
+								fapiaos.FapiaoStatus = "1"
1249
+								fapiaos.TicketSn = ""
1250
+								service.SaveFaPiaoOrder(&fapiaos)
1251
+								//service.UpdateFaPiaoNumber(resp3.Data.TicketSn, ids) //同步发票号码
1252
+							} else if resp3.Data.Status == 2 {
1253
+								fapiaos.FapiaoStatus = "3"
1254
+								fapiaos.TicketSn = ""
1255
+								fapiaos.Message = resp3.Data.Message
1256
+								service.SaveFaPiaoOrder(&fapiaos)
1257
+							} else {
1258
+								fapiaos.FapiaoStatus = "3"
1259
+								fapiaos.TicketSn = ""
1260
+								fapiaos.Message = resp3.Data.Message
1261
+								service.SaveFaPiaoOrder(&fapiaos)
1262
+							}
1263
+						} else {
1264
+							//错误处理
1038 1265
 							c.ServeSuccessJSON(map[string]interface{}{
1039
-								"msg": "开具成功",
1266
+								"msg": "查询失败" + resp3.Message,
1040 1267
 							})
1041 1268
 						}
1042
-					} else {
1043
-						//错误处理
1044
-						c.ServeSuccessJSON(map[string]interface{}{
1045
-							"msg": "查询失败" + resp3.Message,
1046
-						})
1047 1269
 					}
1270
+				}(config2.SellerTaxpayerNum, resp.Data.OrderSn, number, fapiaos, ids) // 这里将多个参数传递给闭包
1271
+
1272
+				if err5 == nil {
1273
+					c.ServeSuccessJSON(map[string]interface{}{
1274
+						"msg": "开具成功,审核中。",
1275
+					})
1048 1276
 				}
1277
+
1049 1278
 			} else {
1050 1279
 				//错误处理
1051 1280
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -1055,6 +1284,7 @@ func (c *FapiaoApiController) OpenFaPiao() {
1055 1284
 		}
1056 1285
 	}
1057 1286
 }
1287
+
1058 1288
 func (c *FapiaoApiController) RedFaPiao() {
1059 1289
 
1060 1290
 	id, _ := c.GetInt64("id")
@@ -1103,7 +1333,7 @@ func (c *FapiaoApiController) RedFaPiao() {
1103 1333
 						fapiao_config.Status = 0
1104 1334
 						fapiao_config.RedInvoiceId = resp.Data[0].InvoiceId
1105 1335
 						fapiao_config.RedInvoiceCreator = role2.UserName
1106
-						service.SaveFaPiaoOrder(fapiao_config)
1336
+						service.SaveFaPiaoOrder(&fapiao_config)
1107 1337
 						//将结算表的发票号码清空
1108 1338
 						service.UpdateFaPiaoNumberByNumber(fapiao_config.TicketSn)
1109 1339
 						c.ServeSuccessJSON(map[string]interface{}{

+ 16 - 1
controllers/his_api_controller.go View File

@@ -9413,6 +9413,7 @@ type Custom struct {
9413 9413
 	AdviceId         int64
9414 9414
 	ProjectId        int64
9415 9415
 	ItemId           int64
9416
+	CostType         int64
9416 9417
 }
9417 9418
 
9418 9419
 // 获取个人信息----挂号-----上传就诊信息
@@ -9948,6 +9949,7 @@ func (c *HisApiController) GetUploadInfo() {
9948 9949
 						Price:            fmt.Sprintf("%.4f", subItem.Price),
9949 9950
 						MedListCodg:      subItem.MedListCodg,
9950 9951
 						Type:             1,
9952
+						CostType:         9,
9951 9953
 					}
9952 9954
 					customs = append(customs, cus)
9953 9955
 				}
@@ -9964,6 +9966,7 @@ func (c *HisApiController) GetUploadInfo() {
9964 9966
 						Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
9965 9967
 						MedListCodg:      subItem.MedListCodg,
9966 9968
 						Type:             2,
9969
+						CostType:         subItem.HisProject.CostClassify,
9967 9970
 					}
9968 9971
 					customs = append(customs, cus)
9969 9972
 				}
@@ -9979,6 +9982,7 @@ func (c *HisApiController) GetUploadInfo() {
9979 9982
 					Price:            fmt.Sprintf("%.4f", float64(item.Price)),
9980 9983
 					MedListCodg:      item.XtHisAddtionConfig.Code,
9981 9984
 					Type:             3,
9985
+					CostType:         5,
9982 9986
 				}
9983 9987
 				customs = append(customs, cus)
9984 9988
 			}
@@ -9990,12 +9994,20 @@ func (c *HisApiController) GetUploadInfo() {
9990 9994
 			var item_id int64 = 0
9991 9995
 
9992 9996
 			var types int64 = 0
9993
-
9997
+			var med_chrgitm_type string
9994 9998
 			if item.Type == 1 {
9995 9999
 				advice_id = item.AdviceId
9996 10000
 				project_id = 0
9997 10001
 				item_id = 0
10002
+				med_chrgitm_type = "09"
9998 10003
 			} else if item.Type == 2 {
10004
+				med_chrgitm_type = "05"
10005
+				if item.CostType == 3 {
10006
+					med_chrgitm_type = "04"
10007
+				}
10008
+				if item.CostType == 8 {
10009
+					med_chrgitm_type = "03"
10010
+				}
9999 10011
 				advice_id = 0
10000 10012
 				item_id = 0
10001 10013
 
@@ -10004,6 +10016,8 @@ func (c *HisApiController) GetUploadInfo() {
10004 10016
 				advice_id = 0
10005 10017
 				item_id = item.ItemId
10006 10018
 				project_id = 0
10019
+				med_chrgitm_type = "08"
10020
+
10007 10021
 			}
10008 10022
 			detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
10009 10023
 			cut, _ := strconv.ParseFloat(item.Cut, 32)
@@ -10013,6 +10027,7 @@ func (c *HisApiController) GetUploadInfo() {
10013 10027
 				UploadDate:       time.Now().Unix(),
10014 10028
 				AdviceId:         advice_id,
10015 10029
 				DetItemFeeSumamt: detItemFeeSumamt,
10030
+				MedChrgitmType:   med_chrgitm_type,
10016 10031
 				Cnt:              cut,
10017 10032
 				Pric:             pric,
10018 10033
 				PatientId:        id,

+ 77 - 59
models/fapiao.go View File

@@ -22,39 +22,41 @@ func (FapiaoConfig) TableName() string {
22 22
 }
23 23
 
24 24
 type HisOrderByFaPiao struct {
25
-	ID                 int64          `gorm:"column:id" json:"id" form:"id"`
26
-	UserOrgId          int64          `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
27
-	HisPatientId       int64          `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
28
-	SettleAccountsDate int64          `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
29
-	Ctime              int64          `gorm:"column:ctime" json:"ctime" form:"ctime"`
30
-	Mtime              int64          `gorm:"column:mtime" json:"mtime" form:"mtime"`
31
-	Status             int64          `gorm:"column:status" json:"status" form:"status"`
32
-	Number             string         `gorm:"column:number" json:"number" form:"number"`
33
-	PatientId          int64          `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
34
-	Infcode            int64          `gorm:"column:infcode" json:"infcode" form:"infcode"`
35
-	WarnMsg            string         `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
36
-	Cainfo             string         `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
37
-	ErrMsg             string         `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
38
-	RespondTime        string         `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
39
-	InfRefmsgid        string         `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
40
-	OrderStatus        int64          `gorm:"column:order_status" json:"order_status" form:"order_status"`
41
-	MdtrtId            string         `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
42
-	SetlId             string         `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
43
-	PsnNo              string         `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
44
-	PsnName            string         `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
45
-	PsnCertType        string         `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
46
-	Certno             string         `gorm:"column:certno" json:"certno" form:"certno"`
47
-	Gend               string         `gorm:"column:gend" json:"gend" form:"gend"`
48
-	Insutype           string         `gorm:"column:insutype" json:"insutype" form:"insutype"`
49
-	SetlTime           string         `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
50
-	MedType            string         `gorm:"column:med_type" json:"med_type" form:"med_type"`
51
-	MedfeeSumamt       float64        `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
52
-	FaPiaoCode         string         `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
53
-	FaPiaoNumber       string         `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
54
-	Patients           Patients       `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
55
-	HisPatient         HisPatient     `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
56
-	HisFaPiaoOrder     HisFaPiaoOrder `gorm:"ForeignKey:FaPiaoNumber;AssociationForeignKey:TicketSn" json:"result"`
57
-	Creator            int64          `gorm:"column:creator" json:"creator" form:"creator"`
25
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
26
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
27
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
28
+	SettleAccountsDate int64  `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
29
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
30
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
31
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
32
+	Number             string `gorm:"column:number" json:"number" form:"number"`
33
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
34
+	Infcode            int64  `gorm:"column:infcode" json:"infcode" form:"infcode"`
35
+	WarnMsg            string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
36
+	Cainfo             string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
37
+	ErrMsg             string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
38
+	RespondTime        string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
39
+	InfRefmsgid        string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
40
+	OrderStatus        int64  `gorm:"column:order_status" json:"order_status" form:"order_status"`
41
+	MdtrtId            string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
42
+	SetlId             string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
43
+	PsnNo              string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
44
+	PsnName            string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
45
+	PsnCertType        string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
46
+	Certno             string `gorm:"column:certno" json:"certno" form:"certno"`
47
+	Gend               string `gorm:"column:gend" json:"gend" form:"gend"`
48
+	Insutype           string `gorm:"column:insutype" json:"insutype" form:"insutype"`
49
+	SetlTime           string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
50
+	MedType            string `gorm:"column:med_type" json:"med_type" form:"med_type"`
51
+	FaPiaoSn           string `gorm:"column:fa_piao_sn" json:"fa_piao_sn" form:"fa_piao_sn"`
52
+
53
+	MedfeeSumamt   float64        `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
54
+	FaPiaoCode     string         `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
55
+	FaPiaoNumber   string         `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
56
+	Patients       Patients       `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
57
+	HisPatient     HisPatient     `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
58
+	HisFaPiaoOrder HisFaPiaoOrder `gorm:"ForeignKey:FaPiaoSn;AssociationForeignKey:OrderSn" json:"result"`
59
+	Creator        int64          `gorm:"column:creator" json:"creator" form:"creator"`
58 60
 }
59 61
 
60 62
 func (HisOrderByFaPiao) TableName() string {
@@ -62,34 +64,50 @@ func (HisOrderByFaPiao) TableName() string {
62 64
 }
63 65
 
64 66
 type HisFaPiaoOrder struct {
65
-	ID                int64    `gorm:"column:id" json:"id" form:"id"`
66
-	InvoiceId         string   `gorm:"column:invoice_id" json:"invoice_id" form:"invoice_id"`
67
-	OrderSn           string   `gorm:"column:order_sn" json:"order_sn" form:"order_sn"`
68
-	TicketSn          string   `gorm:"column:ticket_sn" json:"ticket_sn" form:"ticket_sn"`
69
-	TicketDate        string   `gorm:"column:ticket_date" json:"ticket_date" form:"ticket_date"`
70
-	AmountWithTax     string   `gorm:"column:amount_with_tax" json:"amount_with_tax" form:"amount_with_tax"`
71
-	AmountWithoutTax  string   `gorm:"column:amount_without_tax" json:"amount_without_tax" form:"amount_without_tax"`
72
-	TaxAmount         string   `gorm:"column:tax_amount" json:"tax_amount" form:"tax_amount"`
73
-	IsRedWashed       string   `gorm:"column:is_red_washed" json:"is_red_washed" form:"is_red_washed"`
74
-	PdfUrl            string   `gorm:"column:pdf_url" json:"pdf_url" form:"pdf_url"`
75
-	OfdUrl            string   `gorm:"column:ofd_url" json:"ofd_url" form:"ofd_url"`
76
-	XmlUrl            string   `gorm:"column:xml_url" json:"xml_url" form:"xml_url"`
77
-	FapiaoStatus      string   `gorm:"column:fapiao_status" json:"fapiao_status" form:"fapiao_status"`
78
-	OrderIds          string   `gorm:"column:order_ids" json:"order_ids" form:"order_ids"`
79
-	UserOrgId         int64    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
80
-	Status            int64    `gorm:"column:status" json:"status" form:"status"`
81
-	PatientId         int64    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
82
-	Ctime             int64    `gorm:"column:ctime" json:"ctime" form:"ctime"`
83
-	Mtime             int64    `gorm:"column:mtime" json:"mtime" form:"mtime"`
84
-	Creator           string   `gorm:"column:creator" json:"creator" form:"creator"`
85
-	MedfeeSumamt      float64  `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
86
-	PsnCashPay        float64  `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
87
-	FundPaySumamt     float64  `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
88
-	RedInvoiceId      string   `gorm:"column:red_invoice_id" json:"red_invoice_id" form:"red_invoice_id"`
89
-	RedInvoiceCreator string   `gorm:"column:red_invoice_creator" json:"red_invoice_creator" form:"red_invoice_creator"`
90
-	Patients          Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
67
+	ID                      int64                      `gorm:"column:id" json:"id" form:"id"`
68
+	InvoiceId               string                     `gorm:"column:invoice_id" json:"invoice_id" form:"invoice_id"`
69
+	OrderSn                 string                     `gorm:"column:order_sn" json:"order_sn" form:"order_sn"`
70
+	TicketSn                string                     `gorm:"column:ticket_sn" json:"ticket_sn" form:"ticket_sn"`
71
+	TicketDate              string                     `gorm:"column:ticket_date" json:"ticket_date" form:"ticket_date"`
72
+	AmountWithTax           string                     `gorm:"column:amount_with_tax" json:"amount_with_tax" form:"amount_with_tax"`
73
+	AmountWithoutTax        string                     `gorm:"column:amount_without_tax" json:"amount_without_tax" form:"amount_without_tax"`
74
+	TaxAmount               string                     `gorm:"column:tax_amount" json:"tax_amount" form:"tax_amount"`
75
+	IsRedWashed             string                     `gorm:"column:is_red_washed" json:"is_red_washed" form:"is_red_washed"`
76
+	PdfUrl                  string                     `gorm:"column:pdf_url" json:"pdf_url" form:"pdf_url"`
77
+	OfdUrl                  string                     `gorm:"column:ofd_url" json:"ofd_url" form:"ofd_url"`
78
+	XmlUrl                  string                     `gorm:"column:xml_url" json:"xml_url" form:"xml_url"`
79
+	FapiaoStatus            string                     `gorm:"column:fapiao_status" json:"fapiao_status" form:"fapiao_status"`
80
+	OrderIds                string                     `gorm:"column:order_ids" json:"order_ids" form:"order_ids"`
81
+	UserOrgId               int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
82
+	Status                  int64                      `gorm:"column:status" json:"status" form:"status"`
83
+	PatientId               int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
84
+	Ctime                   int64                      `gorm:"column:ctime" json:"ctime" form:"ctime"`
85
+	Mtime                   int64                      `gorm:"column:mtime" json:"mtime" form:"mtime"`
86
+	Creator                 string                     `gorm:"column:creator" json:"creator" form:"creator"`
87
+	MedfeeSumamt            float64                    `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
88
+	PsnCashPay              float64                    `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
89
+	FundPaySumamt           float64                    `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
90
+	RedInvoiceId            string                     `gorm:"column:red_invoice_id" json:"red_invoice_id" form:"red_invoice_id"`
91
+	RedInvoiceCreator       string                     `gorm:"column:red_invoice_creator" json:"red_invoice_creator" form:"red_invoice_creator"`
92
+	Patients                Patients                   `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
93
+	SettleAccountsDateOrder []*SettleAccountsDateOrder `gorm:"-" json:"orders" form:"orders"`
94
+	Message                 string                     `gorm:"column:message" json:"message" form:"message"`
91 95
 }
92 96
 
93 97
 func (HisFaPiaoOrder) TableName() string {
94 98
 	return "his_fapiao_order"
95 99
 }
100
+
101
+type SettleAccountsDateOrder struct {
102
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
103
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
104
+	HisPatientId       int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
105
+	SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
106
+	Ctime              int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
107
+	Mtime              int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
108
+	Status             int64 `gorm:"column:status" json:"status" form:"status"`
109
+}
110
+
111
+func (SettleAccountsDateOrder) TableName() string {
112
+	return "his_order"
113
+}

+ 2 - 0
models/his_models.go View File

@@ -1077,6 +1077,7 @@ type HisOrder struct {
1077 1077
 
1078 1078
 	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1079 1079
 	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
1080
+	FaPiaoSn     string `gorm:"column:fa_piao_sn" json:"fa_piao_sn" form:"fa_piao_sn"`
1080 1081
 
1081 1082
 	AdminUser AdminUser `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
1082 1083
 
@@ -1097,6 +1098,7 @@ type HisOrder struct {
1097 1098
 	IsUploadDiagnose        int64                   `gorm:"column:is_upload_diagnose" json:"is_upload_diagnose" form:"is_upload_diagnose"`
1098 1099
 	IsUploadOrderInfo       int64                   `gorm:"column:is_upload_order_info" json:"is_upload_order_info" form:"is_upload_order_info"`
1099 1100
 	IsUploadSuccess         int64                   `gorm:"column:is_upload_success" json:"is_upload_success" form:"is_upload_success"`
1101
+	SickName                string                  `gorm:"column:sick_name" json:"sick_name" form:"sick_name"`
1100 1102
 }
1101 1103
 
1102 1104
 func (HisOrder) TableName() string {