|
@@ -9,9 +9,12 @@ import (
|
9
|
9
|
"encoding/json"
|
10
|
10
|
"errors"
|
11
|
11
|
"fmt"
|
|
12
|
+ "io"
|
12
|
13
|
"io/ioutil"
|
13
|
14
|
"math"
|
14
|
15
|
"net/http"
|
|
16
|
+ "os"
|
|
17
|
+ "path/filepath"
|
15
|
18
|
"sort"
|
16
|
19
|
"strconv"
|
17
|
20
|
"strings"
|
|
@@ -34,22 +37,479 @@ func FaPiaoApiRegistRouters() {
|
34
|
37
|
beego.Router("/api/bwfapiao/sms/login", &FapiaoApiController{}, "get:Login")
|
35
|
38
|
beego.Router("/api/bwfapiao/qrcode/get", &FapiaoApiController{}, "get:GetQRCode")
|
36
|
39
|
//beego.Router("/api/bwfapiao/blue", &FapiaoApiController{}, "get:OpenFaPiao")
|
37
|
|
- //beego.Router("/api/bwfapiao/red", &FapiaoApiController{}, "get:RedFaPiao")
|
|
40
|
+ beego.Router("/api/bwfapiao/red", &FapiaoApiController{}, "get:RedFaPiao")
|
38
|
41
|
beego.Router("/api/order/fapiao/list", &FapiaoApiController{}, "get:GetOrderFaPiaoList")
|
39
|
42
|
beego.Router("/api/fapiao/list", &FapiaoApiController{}, "get:GetFaPiaoList")
|
40
|
43
|
beego.Router("/api/newfapiao/get", &HisApiController{}, "get:GetNewFaPiaoData")
|
41
|
44
|
beego.Router("/api/fapiao/query", &FapiaoApiController{}, "get:QueryFaPiao")
|
42
|
|
-
|
|
45
|
+ beego.Router("/api/bwfapiao/batchopen", &FapiaoApiController{}, "get:BwOpenBatchBlueFaPiao")
|
43
|
46
|
//百望云
|
44
|
47
|
//beego.Router("/api/bwfapiao/login", &FapiaoApiController{}, "get:GetBwFaPiaoLogin")
|
45
|
48
|
//beego.Router("/api/bwfapiao/qrcode", &FapiaoApiController{}, "get:GetBwFaPiaoQRCode")
|
46
|
|
- beego.Router("/api/bwfapiao/blue", &FapiaoApiController{}, "get:BwOpenBlueFaPiao")
|
47
|
|
- beego.Router("/api/bwfapiao/query", &FapiaoApiController{}, "get:QueryBwFaPiao")
|
48
|
|
- beego.Router("/api/bwfapiao/red", &FapiaoApiController{}, "get:BwOpenRedFaPiao")
|
|
49
|
+ //beego.Router("/api/bwfapiao/blue", &FapiaoApiController{}, "get:BwOpenBlueFaPiao")
|
|
50
|
+ //beego.Router("/api/bwfapiao/query", &FapiaoApiController{}, "get:QueryBwFaPiao")
|
|
51
|
+ //beego.Router("/api/bwfapiao/red", &FapiaoApiController{}, "get:BwOpenRedFaPiao")
|
|
52
|
+
|
|
53
|
+ //beego.Router("/api/download", &FapiaoApiController{}, "get:DownLoad")
|
|
54
|
+
|
|
55
|
+ //beego.Router("/api/all_download", &FapiaoApiController{}, "get:AllDownLoad")
|
49
|
56
|
|
50
|
57
|
}
|
51
|
58
|
|
|
59
|
+func (c *FapiaoApiController) BwOpenBatchBlueFaPiao() {
|
|
60
|
+ //判断是否处于登录状态
|
|
61
|
+ //开蓝票逻辑
|
|
62
|
+ order_ids := c.GetString("id")
|
|
63
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
64
|
+ ids := strings.Split(order_ids, ",")
|
|
65
|
+ orders, _ := service.GetFaPiaoOrderByIDS(ids)
|
|
66
|
+ fmt.Println(ids)
|
|
67
|
+ fmt.Println(orders)
|
|
68
|
+ //return
|
|
69
|
+ var success []int64
|
|
70
|
+ var errs string
|
|
71
|
+
|
|
72
|
+ for _, oss := range orders {
|
|
73
|
+ var MedfeeSumamt float64 = 0 //治疗费用
|
|
74
|
+ var PsnCashPay float64 = 0 //治疗费用
|
|
75
|
+ var FundPaySumamt float64 = 0 //治疗费用
|
|
76
|
+
|
|
77
|
+ var HifmiPay float64 = 0 //治疗费用
|
|
78
|
+ var MafPay float64 = 0 //治疗费用
|
|
79
|
+ var HifpPay float64 = 0 //治疗费用
|
|
80
|
+ var AcctPay float64 = 0 //治疗费用
|
|
81
|
+
|
|
82
|
+ var GongWuYuan float64 = 0 //治疗费用
|
|
83
|
+
|
|
84
|
+ var BuCong float64 = 0 //治疗费用
|
|
85
|
+
|
|
86
|
+ var OthPay float64 = 0 //治疗费用
|
|
87
|
+
|
|
88
|
+ var details []models.NewHisOrderInfo
|
|
89
|
+ var numbers []string
|
|
90
|
+ decimal.DivisionPrecision = 2
|
|
91
|
+ var remark string
|
|
92
|
+
|
|
93
|
+ MedfeeSumamt, _ = decimal.NewFromFloat(MedfeeSumamt).Add(decimal.NewFromFloat(oss.MedfeeSumamt)).Float64()
|
|
94
|
+ PsnCashPay, _ = decimal.NewFromFloat(PsnCashPay).Add(decimal.NewFromFloat(oss.PsnCashPay)).Float64()
|
|
95
|
+ FundPaySumamt, _ = decimal.NewFromFloat(FundPaySumamt).Add(decimal.NewFromFloat(oss.FundPaySumamt)).Float64()
|
|
96
|
+
|
|
97
|
+ HifmiPay, _ = decimal.NewFromFloat(HifmiPay).Add(decimal.NewFromFloat(oss.HifmiPay)).Float64()
|
|
98
|
+ MafPay, _ = decimal.NewFromFloat(MafPay).Add(decimal.NewFromFloat(oss.MafPay)).Float64()
|
|
99
|
+ HifpPay, _ = decimal.NewFromFloat(HifpPay).Add(decimal.NewFromFloat(oss.HifpPay)).Float64()
|
|
100
|
+ AcctPay, _ = decimal.NewFromFloat(AcctPay).Add(decimal.NewFromFloat(oss.AcctPay)).Float64()
|
|
101
|
+
|
|
102
|
+ GongWuYuan, _ = decimal.NewFromFloat(GongWuYuan).Add(decimal.NewFromFloat(oss.CvlservPay)).Float64()
|
|
103
|
+
|
|
104
|
+ BuCong, _ = decimal.NewFromFloat(BuCong).Add(decimal.NewFromFloat(oss.HifesPay)).Float64()
|
|
105
|
+
|
|
106
|
+ OthPay, _ = decimal.NewFromFloat(OthPay).Add(decimal.NewFromFloat(oss.OthPay)).Float64()
|
|
107
|
+ numbers = append(numbers, oss.Number)
|
|
108
|
+
|
|
109
|
+ // 假设你有一个以秒为单位的时间戳
|
|
110
|
+ timestamp := oss.SettleAccountsDate // 例如:2023-01-01T00:00:00Z
|
|
111
|
+ // 将时间戳转换为time.Time对象
|
|
112
|
+ t := time.Unix(timestamp, 0) // 第二个参数是纳秒,这里我们不需要转换,所以设为0
|
|
113
|
+ // 格式化日期和时间
|
|
114
|
+ //fmt.Println(t.Format("2006-01-02"))
|
|
115
|
+
|
|
116
|
+ remark = "治疗时间: " + t.Format("2006-01-02")
|
|
117
|
+
|
|
118
|
+ MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
119
|
+
|
|
120
|
+ if len(remark) == 0 {
|
|
121
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
122
|
+ remark = "医疗总费用: " + MedfeeSumamt_str
|
|
123
|
+ } else {
|
|
124
|
+ remark = remark + " 医疗总费用:" + MedfeeSumamt_str
|
|
125
|
+ }
|
|
126
|
+ FundPaySumamt_str := fmt.Sprintf("%.2f", FundPaySumamt)
|
|
127
|
+
|
|
128
|
+ if len(remark) == 0 {
|
|
129
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
130
|
+ remark = "基金支付总金额: " + FundPaySumamt_str
|
|
131
|
+ } else {
|
|
132
|
+ remark = remark + " 基金支付总金额:" + FundPaySumamt_str
|
|
133
|
+ }
|
|
134
|
+ HifpPay_str := fmt.Sprintf("%.2f", HifpPay)
|
|
135
|
+
|
|
136
|
+ if len(remark) == 0 {
|
|
137
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
138
|
+ remark = "基本统筹基金支付: " + HifpPay_str
|
|
139
|
+ } else {
|
|
140
|
+ remark = remark + " 基本统筹基金支付:" + HifpPay_str
|
|
141
|
+ }
|
|
142
|
+
|
|
143
|
+ HifmiPay_str := fmt.Sprintf("%.2f", HifmiPay)
|
|
144
|
+
|
|
145
|
+ if len(remark) == 0 {
|
|
146
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
147
|
+ remark = "大病基金支付: " + HifmiPay_str
|
|
148
|
+ } else {
|
|
149
|
+ remark = remark + " 大病基金支付:" + HifmiPay_str
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ GongWuYuan_str := fmt.Sprintf("%.2f", GongWuYuan)
|
|
153
|
+
|
|
154
|
+ if len(remark) == 0 {
|
|
155
|
+ remark = "公务员支付: " + GongWuYuan_str
|
|
156
|
+ } else {
|
|
157
|
+ remark = remark + " 公务员支付:" + GongWuYuan_str
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ BuCong_str := fmt.Sprintf("%.2f", BuCong)
|
|
161
|
+
|
|
162
|
+ if len(remark) == 0 {
|
|
163
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
164
|
+ remark = "补充医疗保险支付: " + BuCong_str
|
|
165
|
+ } else {
|
|
166
|
+ remark = remark + " 补充医疗保险支付:" + BuCong_str
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ MafPay_str := fmt.Sprintf("%.2f", MafPay)
|
|
170
|
+
|
|
171
|
+ if len(remark) == 0 {
|
|
172
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
173
|
+ remark = "医疗救助基金支付: " + MafPay_str
|
|
174
|
+ } else {
|
|
175
|
+ remark = remark + " 医疗救助基金支付:" + MafPay_str
|
|
176
|
+ }
|
|
177
|
+ OthPay_str := fmt.Sprintf("%.2f", OthPay)
|
|
178
|
+ if len(remark) == 0 {
|
|
179
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
180
|
+ remark = "其他支付: " + OthPay_str
|
|
181
|
+ } else {
|
|
182
|
+ remark = remark + " 其他支付:" + OthPay_str
|
|
183
|
+ }
|
|
184
|
+ AcctPay_str := fmt.Sprintf("%.2f", AcctPay)
|
|
185
|
+ if len(remark) == 0 {
|
|
186
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
187
|
+ remark = "医保账户支付: " + AcctPay_str
|
|
188
|
+ } else {
|
|
189
|
+ remark = remark + " 医保账户支付:" + AcctPay_str
|
|
190
|
+ }
|
|
191
|
+ PsnCashPay_str := fmt.Sprintf("%.2f", PsnCashPay)
|
|
192
|
+ if len(remark) == 0 {
|
|
193
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
194
|
+ remark = "个人现金支付: " + PsnCashPay_str
|
|
195
|
+ } else {
|
|
196
|
+ remark = remark + " 个人现金支付:" + PsnCashPay_str
|
|
197
|
+ }
|
|
198
|
+
|
|
199
|
+ details, _ = service.GetFaPiaoOrderInfoByNumbersTwo(numbers)
|
|
200
|
+ role, _ := service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
201
|
+
|
|
202
|
+ type CostType struct {
|
|
203
|
+ name string
|
|
204
|
+ price float64
|
|
205
|
+ }
|
|
206
|
+ var cts []CostType
|
|
207
|
+ var ct CostType
|
|
208
|
+ var bedCostTotal float64 = 0 //床位总费
|
|
209
|
+ var operationCostTotal float64 = 0 //手术费
|
|
210
|
+ var otherCostTotal float64 = 0 //其他费用
|
|
211
|
+ var materialCostTotal float64 = 0 //材料费
|
|
212
|
+ var westernMedicineCostTotal float64 = 0 //西药费
|
|
213
|
+ var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
|
|
214
|
+ var checkCostTotal float64 = 0 //检查费
|
|
215
|
+ var laboratoryCostTotal float64 = 0 //化验费
|
|
216
|
+ var treatCostTotal float64 = 0 //治疗费用
|
|
217
|
+ var huliCostTotal float64 = 0 //治疗费用
|
|
218
|
+ var zhencaCostTotal float64 = 0 //治疗费用
|
|
219
|
+ for _, item := range details {
|
|
220
|
+ if item.MedChrgitmType == "01" { //床位费
|
|
221
|
+ bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
222
|
+ }
|
|
223
|
+ if item.MedChrgitmType == "07" { //护理费
|
|
224
|
+ huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
225
|
+ }
|
|
226
|
+ if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
|
|
227
|
+ if item.MedChrgitmType == "03" { //检查费
|
|
228
|
+ laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
229
|
+ }
|
|
230
|
+ } else {
|
|
231
|
+ if item.MedChrgitmType == "03" { //检查费
|
|
232
|
+ checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
233
|
+ }
|
|
234
|
+
|
|
235
|
+ }
|
|
236
|
+ if item.MedChrgitmType == "04" { //化验费
|
|
237
|
+ laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
238
|
+ }
|
|
239
|
+
|
|
240
|
+ if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
|
|
241
|
+ treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
242
|
+ }
|
|
243
|
+
|
|
244
|
+ if item.MedChrgitmType == "06" { //手术费
|
|
245
|
+ operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ if item.MedChrgitmType == "08" { //材料费
|
|
249
|
+ materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
250
|
+ }
|
|
251
|
+
|
|
252
|
+ if item.MedChrgitmType == "09" { //西药费
|
|
253
|
+ westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+ if item.MedChrgitmType == "11" { //中成费
|
|
257
|
+ chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
258
|
+ }
|
|
259
|
+
|
|
260
|
+ if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
|
|
261
|
+ otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
262
|
+ }
|
|
263
|
+
|
|
264
|
+ if item.MedChrgitmType == "02" { //诊察
|
|
265
|
+ zhencaCostTotal, _ = decimal.NewFromFloat(zhencaCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
266
|
+ }
|
|
267
|
+ }
|
|
268
|
+ if bedCostTotal > 0 {
|
|
269
|
+ ct.name = "床位费"
|
|
270
|
+ ct.price = bedCostTotal
|
|
271
|
+ cts = append(cts, ct)
|
|
272
|
+ }
|
|
273
|
+ if operationCostTotal > 0 {
|
|
274
|
+ ct.name = "手术费"
|
|
275
|
+ ct.price = operationCostTotal
|
|
276
|
+ cts = append(cts, ct)
|
|
277
|
+
|
|
278
|
+ }
|
|
279
|
+ if otherCostTotal > 0 {
|
|
280
|
+ ct.name = "其他费"
|
|
281
|
+ ct.price = otherCostTotal
|
|
282
|
+ cts = append(cts, ct)
|
|
283
|
+
|
|
284
|
+ }
|
|
285
|
+ if materialCostTotal > 0 {
|
|
286
|
+ ct.name = "材料费"
|
|
287
|
+ ct.price = materialCostTotal
|
|
288
|
+ cts = append(cts, ct)
|
|
289
|
+
|
|
290
|
+ }
|
|
291
|
+ if westernMedicineCostTotal > 0 {
|
|
292
|
+ ct.name = "西药费"
|
|
293
|
+ ct.price = westernMedicineCostTotal
|
|
294
|
+ cts = append(cts, ct)
|
|
295
|
+
|
|
296
|
+ }
|
|
297
|
+ if chineseTraditionalMedicineCostTotal > 0 {
|
|
298
|
+ ct.name = "中成药费"
|
|
299
|
+ ct.price = chineseTraditionalMedicineCostTotal
|
|
300
|
+ cts = append(cts, ct)
|
|
301
|
+
|
|
302
|
+ }
|
|
303
|
+ if checkCostTotal > 0 {
|
|
304
|
+ ct.name = "检查费"
|
|
305
|
+ ct.price = checkCostTotal
|
|
306
|
+ cts = append(cts, ct)
|
|
307
|
+
|
|
308
|
+ }
|
|
309
|
+ if laboratoryCostTotal > 0 {
|
|
310
|
+ ct.name = "化验费"
|
|
311
|
+ ct.price = laboratoryCostTotal
|
|
312
|
+ cts = append(cts, ct)
|
|
313
|
+
|
|
314
|
+ }
|
|
315
|
+ if treatCostTotal > 0 {
|
|
316
|
+ ct.name = "治疗费"
|
|
317
|
+ ct.price = treatCostTotal
|
|
318
|
+ cts = append(cts, ct)
|
|
319
|
+
|
|
320
|
+ }
|
|
321
|
+ if huliCostTotal > 0 {
|
|
322
|
+ ct.name = "护理费"
|
|
323
|
+ ct.price = huliCostTotal
|
|
324
|
+ cts = append(cts, ct)
|
|
325
|
+
|
|
326
|
+ }
|
|
327
|
+ if zhencaCostTotal > 0 {
|
|
328
|
+ ct.name = "诊察费"
|
|
329
|
+ ct.price = zhencaCostTotal
|
|
330
|
+ cts = append(cts, ct)
|
|
331
|
+
|
|
332
|
+ }
|
|
333
|
+ //org_config, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
|
|
334
|
+ var config2 models.FapiaoConfig
|
|
335
|
+ config2, _ = service.FindFaPiaoConfigInfo(c.GetAdminUserInfo().CurrentOrgId)
|
|
336
|
+ number := strconv.FormatInt(time.Now().Unix(), 10) + "_" + strconv.FormatInt(oss.UserOrgId, 10) + "_" + strconv.FormatInt(oss.PatientId, 10)
|
|
337
|
+ amountWithoutTax, _, taxAmount, _ := CalculatePriceDetails(MedfeeSumamt, 1, 0.00)
|
|
338
|
+ patient, _ := service.GetPatientByIDTwo(c.GetAdminUserInfo().CurrentOrgId, oss.PatientId)
|
|
339
|
+ oss.PsnName = patient.Name
|
|
340
|
+
|
|
341
|
+ requestBody2 := map[string]interface{}{
|
|
342
|
+ "taxNo": config2.TerminalCode,
|
|
343
|
+ "taxUserName": role.UserName,
|
|
344
|
+ "invoiceTerminalCode": "",
|
|
345
|
+ "isSplit": "",
|
|
346
|
+ "orgCode": "",
|
|
347
|
+ "taxDiskNo": "",
|
|
348
|
+ "formatGenerate": "",
|
|
349
|
+ "formatPushType": "",
|
|
350
|
+ "completionCustom": "",
|
|
351
|
+ "isAsync": "",
|
|
352
|
+ "isReturnRedInfo": "",
|
|
353
|
+ }
|
|
354
|
+ //var subData map[string]interface{}
|
|
355
|
+ subData := make(map[string]interface{})
|
|
356
|
+ subData["invoiceTypeCode"] = "02"
|
|
357
|
+ subData["paperInvoiceFlag"] = ""
|
|
358
|
+ subData["paperInvoiceTypeCode"] = ""
|
|
359
|
+ subData["paperInvoiceTypeCode"] = ""
|
|
360
|
+ subData["invoiceType"] = "0"
|
|
361
|
+ subData["invoiceSpecialMark"] = "00"
|
|
362
|
+ subData["isConfirmIssue"] = ""
|
|
363
|
+ subData["confirmIssue"] = ""
|
|
364
|
+ subData["taxationMethod"] = ""
|
|
365
|
+ subData["taxationLabel"] = ""
|
|
366
|
+ subData["reducedTaxCode"] = ""
|
|
367
|
+ subData["invoiceListMark"] = ""
|
|
368
|
+ subData["priceTaxMark"] = ""
|
|
369
|
+ subData["serialNo"] = number // todo
|
|
370
|
+ subData["orderNo"] = "" //todo
|
|
371
|
+ subData["buyerTaxNo"] = patient.IdCardNo //todo
|
|
372
|
+ subData["buyerName"] = oss.PsnName + "(个人)"
|
|
373
|
+ subData["buyerAddressPhone"] = ""
|
|
374
|
+ subData["buyerBankAccount"] = ""
|
|
375
|
+ subData["drawer"] = role.UserName
|
|
376
|
+ subData["checker"] = ""
|
|
377
|
+ subData["payee"] = ""
|
|
378
|
+ subData["invoiceTotalPrice"] = MedfeeSumamt
|
|
379
|
+ subData["invoiceTotalTax"] = taxAmount
|
|
380
|
+ subData["invoiceTotalPriceTax"] = amountWithoutTax
|
|
381
|
+ subData["remarks"] = remark
|
|
382
|
+ subData["redInfoNo"] = ""
|
|
383
|
+ subData["originalInvoiceCode"] = ""
|
|
384
|
+ subData["originalInvoiceNo"] = ""
|
|
385
|
+ subData["deductibleAmount"] = ""
|
|
386
|
+ subData["sellerAddressPhone"] = ""
|
|
387
|
+ subData["sellerBankAccount"] = ""
|
|
388
|
+ //var subDetails []map[string]interface{}
|
|
389
|
+ subDetails := make([]map[string]interface{}, 0)
|
|
390
|
+ for index, item := range cts {
|
|
391
|
+ subDetailData := make(map[string]interface{})
|
|
392
|
+ amountWithoutTax_two, _, taxAmount_tow, _ := CalculatePriceDetails(item.price, 1, 0.00)
|
|
393
|
+ subDetailData["goodsLineNo"] = index + 1
|
|
394
|
+ subDetailData["originalInvoiceDetailNo"] = ""
|
|
395
|
+ subDetailData["invoiceLineNature"] = "0"
|
|
396
|
+ subDetailData["goodsCode"] = "3070202000000000000"
|
|
397
|
+ subDetailData["goodsBarCode"] = ""
|
|
398
|
+ subDetailData["goodsPersonalCode"] = ""
|
|
399
|
+ subDetailData["goodsName"] = item.name
|
|
400
|
+ subDetailData["goodsSpecification"] = ""
|
|
401
|
+ subDetailData["goodsUnit"] = ""
|
|
402
|
+ subDetailData["goodsQuantity"] = "1"
|
|
403
|
+ subDetailData["goodsPrice"] = amountWithoutTax_two
|
|
404
|
+ subDetailData["goodsTotalPrice"] = amountWithoutTax_two
|
|
405
|
+ subDetailData["goodsTotalTax"] = taxAmount_tow
|
|
406
|
+ subDetailData["goodsTaxRate"] = "0"
|
|
407
|
+ subDetailData["vatSpecialManagement"] = ""
|
|
408
|
+ subDetailData["freeTaxMark"] = "3"
|
|
409
|
+ subDetailData["preferentialMarkFlag"] = ""
|
|
410
|
+ subDetailData["goodsDiscountAmount"] = "0"
|
|
411
|
+ subDetails = append(subDetails, subDetailData)
|
|
412
|
+ }
|
|
413
|
+ subData["invoiceDetailsList"] = subDetails
|
|
414
|
+ requestBody2["data"] = subData
|
|
415
|
+
|
|
416
|
+ status, reason, response, request_log, response_log := OpenBWBlue(requestBody2)
|
|
417
|
+ if status == 0 { //失败 //TODO
|
|
418
|
+
|
|
419
|
+ if len(errs) == 0 {
|
|
420
|
+ errs = reason
|
|
421
|
+
|
|
422
|
+ } else {
|
|
423
|
+ errs = errs + "\n" + reason
|
|
424
|
+
|
|
425
|
+ }
|
|
426
|
+
|
|
427
|
+ } else { //成功
|
|
428
|
+ var fapiaos models.HisFaPiaoOrder
|
|
429
|
+ fapiaos.InvoiceId = response.Response.Success[0].SerialNo
|
|
430
|
+ fapiaos.OrderSn = response.Response.Success[0].SerialNo
|
|
431
|
+ fapiaos.OrderIds = strconv.FormatInt(oss.ID, 10)
|
|
432
|
+ fapiaos.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
|
|
433
|
+ fapiaos.Status = 1
|
|
434
|
+ // 解析日期字符串的布局(对应输入的格式)
|
|
435
|
+ layout := "20060102150405"
|
|
436
|
+
|
|
437
|
+ // 将字符串解析为时间对象
|
|
438
|
+ t, _ := time.Parse(layout, response.Response.Success[0].InvoiceDate)
|
|
439
|
+ // 将时间对象格式化为所需的输出格式
|
|
440
|
+ output := t.Format("2006-01-02 15:04:05")
|
|
441
|
+ fapiaos.TicketDate = output
|
|
442
|
+ fapiaos.PatientId = oss.PatientId
|
|
443
|
+ fapiaos.Ctime = time.Now().Unix()
|
|
444
|
+ fapiaos.Mtime = time.Now().Unix()
|
|
445
|
+ fapiaos.Creator = role.UserName
|
|
446
|
+ fapiaos.MedfeeSumamt = MedfeeSumamt
|
|
447
|
+ fapiaos.FundPaySumamt = FundPaySumamt
|
|
448
|
+ fapiaos.PsnCashPay = PsnCashPay
|
|
449
|
+ fapiaos.TicketSn = response.Response.Success[0].InvoiceNo
|
|
450
|
+ fapiaos.AmountWithTax = fmt.Sprintf("%.2f", response.Response.Success[0].InvoiceTotalPrice)
|
|
451
|
+ fapiaos.AmountWithoutTax = fmt.Sprintf("%.2f", response.Response.Success[0].InvoiceTotalPrice)
|
|
452
|
+ fapiaos.FapiaoStatus = "2"
|
|
453
|
+ fapiaos.TaxAmount = fmt.Sprintf("%.2f", response.Response.Success[0].InvoiceTotalTax)
|
|
454
|
+ fapiaos.IsRedWashed = "0"
|
|
455
|
+ fapiaos.PdfUrl = response.Response.Success[0].EInvoiceUrl
|
|
456
|
+ fapiaos.OfdUrl = ""
|
|
457
|
+ fapiaos.XmlUrl = ""
|
|
458
|
+ fapiaos.OfdUrl = ""
|
|
459
|
+ fapiaos.XmlUrl = ""
|
|
460
|
+ fapiaos.BlueRequestInfo = request_log
|
|
461
|
+ fapiaos.BlueResponseInfo = response_log
|
|
462
|
+ var ids_new []string
|
|
463
|
+ ids_new = append(ids_new, strconv.FormatInt(oss.ID, 10))
|
|
464
|
+ err := service.SaveFaPiaoOrder(&fapiaos)
|
|
465
|
+ err = service.UpdateFaPiaoSN(response.Response.Success[0].SerialNo, ids_new) //同步发票号码
|
|
466
|
+ err = service.UpdateFaPiaoNumber(response.Response.Success[0].InvoiceNo, ids_new) //同步发票号码
|
|
467
|
+ fmt.Println(err)
|
|
468
|
+ status2, msg, result := BWBanShi(config2, response.Response.Success[0].InvoiceNo)
|
|
469
|
+ if status2 == 0 { //TODO
|
|
470
|
+ if len(errs) == 0 {
|
|
471
|
+ errs = msg
|
|
472
|
+ } else {
|
|
473
|
+ errs = errs + "\n" + msg
|
|
474
|
+ }
|
|
475
|
+ } else {
|
|
476
|
+ fapiaos.PdfUrl = result.Response.UrlMap.PdfUrl
|
|
477
|
+ fapiaos.OfdUrl = result.Response.UrlMap.OfdUrl
|
|
478
|
+ fapiaos.XmlUrl = result.Response.UrlMap.XmlUrl
|
|
479
|
+ service.SaveFaPiaoOrder(&fapiaos)
|
|
480
|
+ success = append(success, fapiaos.ID)
|
|
481
|
+ }
|
|
482
|
+
|
|
483
|
+ }
|
|
484
|
+
|
|
485
|
+ }
|
|
486
|
+ if len(ids) == len(success) {
|
|
487
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
488
|
+ "msg": "批量开票成功",
|
|
489
|
+ })
|
|
490
|
+ } else {
|
|
491
|
+ if len(success) > 0 && len(success) <= len(ids) { // 部分成功
|
|
492
|
+ msgs := "部分开票成功,开票成功条数" + strconv.FormatInt(int64(len(success)), 10) + "条\n" + "开票失败原因:" + errs
|
|
493
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
494
|
+ "failed_code": -10,
|
|
495
|
+ "msg": msgs,
|
|
496
|
+ })
|
|
497
|
+
|
|
498
|
+ } else if len(success) == 0 {
|
|
499
|
+ msgs := "批量开票失败,开票失败原因:" + errs
|
|
500
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
501
|
+ "failed_code": -10,
|
|
502
|
+ "msg": msgs,
|
|
503
|
+ })
|
|
504
|
+
|
|
505
|
+ }
|
|
506
|
+ }
|
|
507
|
+}
|
52
|
508
|
func signTopRequestTwo(params map[string]string, secret string, body map[string]interface{}) (string, error) {
|
|
509
|
+ fmt.Println(params)
|
|
510
|
+ fmt.Println(secret)
|
|
511
|
+ fmt.Println(body)
|
|
512
|
+
|
53
|
513
|
// 第一步:检查参数是否已经排序
|
54
|
514
|
keys := make([]string, 0, len(params))
|
55
|
515
|
for k := range params {
|
|
@@ -88,6 +548,91 @@ func signTopRequestTwo(params map[string]string, secret string, body map[string]
|
88
|
548
|
return sign, nil
|
89
|
549
|
}
|
90
|
550
|
|
|
551
|
+func (c *FapiaoApiController) AllDownLoad() {
|
|
552
|
+ var downloadedFiles []string
|
|
553
|
+ now := time.Now()
|
|
554
|
+ dateStr1 := now.Format("2006-01-02")
|
|
555
|
+ fapiao_config, _ := service.GetFaPiaoOrderByIds()
|
|
556
|
+ downloadDir := "./发票/" + dateStr1 + "/"
|
|
557
|
+ for _, item := range fapiao_config {
|
|
558
|
+ if err := os.MkdirAll(downloadDir, os.ModePerm); err != nil {
|
|
559
|
+ fmt.Printf("Failed to create directory: %v\n", err)
|
|
560
|
+ return
|
|
561
|
+ }
|
|
562
|
+ fileName := fmt.Sprintf("%s.pdf", item.TicketSn)
|
|
563
|
+
|
|
564
|
+ // 下载文件
|
|
565
|
+ savePath := filepath.Join(downloadDir, fileName)
|
|
566
|
+ fmt.Printf("Downloading %s to %s...\n", item.PdfUrl, savePath)
|
|
567
|
+ err := DownloadFile(item.PdfUrl, savePath)
|
|
568
|
+ if err != nil {
|
|
569
|
+ fmt.Printf("Failed to download file: %v\n", err)
|
|
570
|
+ }
|
|
571
|
+ downloadedFiles = append(downloadedFiles, savePath)
|
|
572
|
+ }
|
|
573
|
+ // 检查下载结果
|
|
574
|
+ if len(downloadedFiles) > 0 {
|
|
575
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
576
|
+ "msg": "下载成功",
|
|
577
|
+ })
|
|
578
|
+ }
|
|
579
|
+
|
|
580
|
+}
|
|
581
|
+
|
|
582
|
+func (c *FapiaoApiController) DownLoad() {
|
|
583
|
+ now := time.Now()
|
|
584
|
+ dateStr1 := now.Format("2006-01-02")
|
|
585
|
+ id, _ := c.GetInt64("id")
|
|
586
|
+ fapiao_config, _ := service.GetFaPiaoOrderById(id)
|
|
587
|
+ downloadDir := "./发票/" + dateStr1 + "/"
|
|
588
|
+ if err := os.MkdirAll(downloadDir, os.ModePerm); err != nil {
|
|
589
|
+ fmt.Printf("Failed to create directory: %v\n", err)
|
|
590
|
+ return
|
|
591
|
+ }
|
|
592
|
+ fileName := fmt.Sprintf("%s.pdf", fapiao_config.TicketSn)
|
|
593
|
+
|
|
594
|
+ // 下载文件
|
|
595
|
+ var downloadedFiles []string
|
|
596
|
+ savePath := filepath.Join(downloadDir, fileName)
|
|
597
|
+ fmt.Printf("Downloading %s to %s...\n", fapiao_config.PdfUrl, savePath)
|
|
598
|
+ err := DownloadFile(fapiao_config.PdfUrl, savePath)
|
|
599
|
+ if err != nil {
|
|
600
|
+ fmt.Printf("Failed to download file: %v\n", err)
|
|
601
|
+ }
|
|
602
|
+ downloadedFiles = append(downloadedFiles, savePath)
|
|
603
|
+ // 检查下载结果
|
|
604
|
+ if len(downloadedFiles) > 0 {
|
|
605
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
606
|
+ "msg": "下载成功",
|
|
607
|
+ })
|
|
608
|
+ }
|
|
609
|
+}
|
|
610
|
+
|
|
611
|
+func DownloadFile(url, savePath string) error {
|
|
612
|
+ resp, err := http.Get(url)
|
|
613
|
+ if err != nil {
|
|
614
|
+ return fmt.Errorf("failed to download file: %v", err)
|
|
615
|
+ }
|
|
616
|
+ defer resp.Body.Close()
|
|
617
|
+
|
|
618
|
+ if resp.StatusCode != http.StatusOK {
|
|
619
|
+ return fmt.Errorf("bad status: %s", resp.Status)
|
|
620
|
+ }
|
|
621
|
+
|
|
622
|
+ out, err := os.Create(savePath)
|
|
623
|
+ if err != nil {
|
|
624
|
+ return fmt.Errorf("failed to create file: %v", err)
|
|
625
|
+ }
|
|
626
|
+ defer out.Close()
|
|
627
|
+
|
|
628
|
+ _, err = io.Copy(out, resp.Body)
|
|
629
|
+ if err != nil {
|
|
630
|
+ return fmt.Errorf("failed to save file: %v", err)
|
|
631
|
+ }
|
|
632
|
+
|
|
633
|
+ return nil
|
|
634
|
+}
|
|
635
|
+
|
91
|
636
|
func (c *FapiaoApiController) BwOpenBlueFaPiao() {
|
92
|
637
|
//判断是否处于登录状态
|
93
|
638
|
//开蓝票逻辑
|
|
@@ -104,6 +649,12 @@ func (c *FapiaoApiController) BwOpenBlueFaPiao() {
|
104
|
649
|
var HifpPay float64 = 0 //治疗费用
|
105
|
650
|
var AcctPay float64 = 0 //治疗费用
|
106
|
651
|
|
|
652
|
+ var GongWuYuan float64 = 0 //治疗费用
|
|
653
|
+
|
|
654
|
+ var BuCong float64 = 0 //治疗费用
|
|
655
|
+
|
|
656
|
+ var OthPay float64 = 0 //治疗费用
|
|
657
|
+
|
107
|
658
|
var details []models.HisOrderInfo
|
108
|
659
|
var numbers []string
|
109
|
660
|
decimal.DivisionPrecision = 2
|
|
@@ -118,78 +669,103 @@ func (c *FapiaoApiController) BwOpenBlueFaPiao() {
|
118
|
669
|
HifpPay, _ = decimal.NewFromFloat(HifpPay).Add(decimal.NewFromFloat(oss.HifpPay)).Float64()
|
119
|
670
|
AcctPay, _ = decimal.NewFromFloat(AcctPay).Add(decimal.NewFromFloat(oss.AcctPay)).Float64()
|
120
|
671
|
|
|
672
|
+ GongWuYuan, _ = decimal.NewFromFloat(GongWuYuan).Add(decimal.NewFromFloat(oss.CvlservPay)).Float64()
|
|
673
|
+
|
|
674
|
+ BuCong, _ = decimal.NewFromFloat(BuCong).Add(decimal.NewFromFloat(oss.HifesPay)).Float64()
|
|
675
|
+
|
|
676
|
+ OthPay, _ = decimal.NewFromFloat(OthPay).Add(decimal.NewFromFloat(oss.OthPay)).Float64()
|
121
|
677
|
numbers = append(numbers, oss.Number)
|
122
|
678
|
}
|
123
|
|
- if MedfeeSumamt > 0 {
|
124
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
679
|
+ // 假设你有一个以秒为单位的时间戳
|
|
680
|
+ timestamp := orders[0].SettleAccountsDate // 例如:2023-01-01T00:00:00Z
|
|
681
|
+ // 将时间戳转换为time.Time对象
|
|
682
|
+ t := time.Unix(timestamp, 0) // 第二个参数是纳秒,这里我们不需要转换,所以设为0
|
|
683
|
+ // 格式化日期和时间
|
|
684
|
+ //fmt.Println(t.Format("2006-01-02"))
|
125
|
685
|
|
126
|
|
- if len(remark) == 0 {
|
127
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
128
|
|
- remark = "医疗总费用: " + MedfeeSumamt_str
|
129
|
|
- } else {
|
130
|
|
- remark = remark + " 医疗总费用:" + MedfeeSumamt_str
|
131
|
|
- }
|
|
686
|
+ remark = "治疗时间: " + t.Format("2006-01-02")
|
|
687
|
+
|
|
688
|
+ MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
689
|
+
|
|
690
|
+ if len(remark) == 0 {
|
|
691
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
692
|
+ remark = "医疗总费用: " + MedfeeSumamt_str
|
|
693
|
+ } else {
|
|
694
|
+ remark = remark + " 医疗总费用:" + MedfeeSumamt_str
|
132
|
695
|
}
|
133
|
|
- if FundPaySumamt > 0 {
|
134
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", FundPaySumamt)
|
|
696
|
+ FundPaySumamt_str := fmt.Sprintf("%.2f", FundPaySumamt)
|
135
|
697
|
|
136
|
|
- if len(remark) == 0 {
|
137
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
138
|
|
- remark = "基金支付总金额: " + MedfeeSumamt_str
|
139
|
|
- } else {
|
140
|
|
- remark = remark + " 基金支付总金额:" + MedfeeSumamt_str
|
141
|
|
- }
|
|
698
|
+ if len(remark) == 0 {
|
|
699
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
700
|
+ remark = "基金支付总金额: " + FundPaySumamt_str
|
|
701
|
+ } else {
|
|
702
|
+ remark = remark + " 基金支付总金额:" + FundPaySumamt_str
|
142
|
703
|
}
|
143
|
|
- if PsnCashPay > 0 {
|
144
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", PsnCashPay)
|
|
704
|
+ HifpPay_str := fmt.Sprintf("%.2f", HifpPay)
|
145
|
705
|
|
146
|
|
- if len(remark) == 0 {
|
147
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
148
|
|
- remark = "个人现金支付: " + MedfeeSumamt_str
|
149
|
|
- } else {
|
150
|
|
- remark = remark + " 个人现金支付:" + MedfeeSumamt_str
|
151
|
|
- }
|
|
706
|
+ if len(remark) == 0 {
|
|
707
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
708
|
+ remark = "基本统筹基金支付: " + HifpPay_str
|
|
709
|
+ } else {
|
|
710
|
+ remark = remark + " 基本统筹基金支付:" + HifpPay_str
|
152
|
711
|
}
|
153
|
|
- if HifmiPay > 0 {
|
154
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", HifmiPay)
|
155
|
712
|
|
156
|
|
- if len(remark) == 0 {
|
157
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
158
|
|
- remark = "大病基金支付: " + MedfeeSumamt_str
|
159
|
|
- } else {
|
160
|
|
- remark = remark + " 大病基金支付:" + MedfeeSumamt_str
|
161
|
|
- }
|
|
713
|
+ HifmiPay_str := fmt.Sprintf("%.2f", HifmiPay)
|
|
714
|
+
|
|
715
|
+ if len(remark) == 0 {
|
|
716
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
717
|
+ remark = "大病基金支付: " + HifmiPay_str
|
|
718
|
+ } else {
|
|
719
|
+ remark = remark + " 大病基金支付:" + HifmiPay_str
|
162
|
720
|
}
|
163
|
|
- if AcctPay > 0 {
|
164
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", AcctPay)
|
165
|
721
|
|
166
|
|
- if len(remark) == 0 {
|
167
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
168
|
|
- remark = "个账支付: " + MedfeeSumamt_str
|
169
|
|
- } else {
|
170
|
|
- remark = remark + " 个账支付:" + MedfeeSumamt_str
|
171
|
|
- }
|
|
722
|
+ GongWuYuan_str := fmt.Sprintf("%.2f", GongWuYuan)
|
|
723
|
+
|
|
724
|
+ if len(remark) == 0 {
|
|
725
|
+ remark = "公务员支付: " + GongWuYuan_str
|
|
726
|
+ } else {
|
|
727
|
+ remark = remark + " 公务员支付:" + GongWuYuan_str
|
172
|
728
|
}
|
173
|
|
- if HifpPay > 0 {
|
174
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", HifpPay)
|
175
|
729
|
|
176
|
|
- if len(remark) == 0 {
|
177
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
178
|
|
- remark = "基本统筹基金支付: " + MedfeeSumamt_str
|
179
|
|
- } else {
|
180
|
|
- remark = remark + " 基本统筹基金支付:" + MedfeeSumamt_str
|
181
|
|
- }
|
|
730
|
+ BuCong_str := fmt.Sprintf("%.2f", BuCong)
|
|
731
|
+
|
|
732
|
+ if len(remark) == 0 {
|
|
733
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
734
|
+ remark = "补充医疗保险支付: " + BuCong_str
|
|
735
|
+ } else {
|
|
736
|
+ remark = remark + " 补充医疗保险支付:" + BuCong_str
|
182
|
737
|
}
|
183
|
|
- if MafPay > 0 {
|
184
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", MafPay)
|
185
|
738
|
|
186
|
|
- if len(remark) == 0 {
|
187
|
|
- //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
188
|
|
- remark = "医疗救助基金支付: " + MedfeeSumamt_str
|
189
|
|
- } else {
|
190
|
|
- remark = remark + " 医疗救助基金支付:" + MedfeeSumamt_str
|
191
|
|
- }
|
|
739
|
+ MafPay_str := fmt.Sprintf("%.2f", MafPay)
|
|
740
|
+
|
|
741
|
+ if len(remark) == 0 {
|
|
742
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
743
|
+ remark = "医疗救助基金支付: " + MafPay_str
|
|
744
|
+ } else {
|
|
745
|
+ remark = remark + " 医疗救助基金支付:" + MafPay_str
|
|
746
|
+ }
|
|
747
|
+ OthPay_str := fmt.Sprintf("%.2f", OthPay)
|
|
748
|
+ if len(remark) == 0 {
|
|
749
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
750
|
+ remark = "其他支付: " + OthPay_str
|
|
751
|
+ } else {
|
|
752
|
+ remark = remark + " 其他支付:" + OthPay_str
|
192
|
753
|
}
|
|
754
|
+ AcctPay_str := fmt.Sprintf("%.2f", AcctPay)
|
|
755
|
+ if len(remark) == 0 {
|
|
756
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
757
|
+ remark = "医保账户支付: " + AcctPay_str
|
|
758
|
+ } else {
|
|
759
|
+ remark = remark + " 医保账户支付:" + AcctPay_str
|
|
760
|
+ }
|
|
761
|
+ PsnCashPay_str := fmt.Sprintf("%.2f", PsnCashPay)
|
|
762
|
+ if len(remark) == 0 {
|
|
763
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
764
|
+ remark = "个人现金支付: " + PsnCashPay_str
|
|
765
|
+ } else {
|
|
766
|
+ remark = remark + " 个人现金支付:" + PsnCashPay_str
|
|
767
|
+ }
|
|
768
|
+
|
193
|
769
|
details, _ = service.GetFaPiaoOrderInfoByNumbers(numbers)
|
194
|
770
|
role, _ := service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
|
195
|
771
|
role.UserName = ""
|
|
@@ -360,9 +936,9 @@ func (c *FapiaoApiController) BwOpenBlueFaPiao() {
|
360
|
936
|
subData["reducedTaxCode"] = ""
|
361
|
937
|
subData["invoiceListMark"] = ""
|
362
|
938
|
subData["priceTaxMark"] = ""
|
363
|
|
- subData["serialNo"] = number // todo
|
364
|
|
- subData["orderNo"] = "" //todo
|
365
|
|
- subData["buyerTaxNo"] = "" //todo
|
|
939
|
+ subData["serialNo"] = number // todo
|
|
940
|
+ subData["orderNo"] = "" //todo
|
|
941
|
+ subData["buyerTaxNo"] = patient.IdCardNo //todo
|
366
|
942
|
subData["buyerName"] = orders[0].PsnName + "(个人)"
|
367
|
943
|
subData["buyerAddressPhone"] = ""
|
368
|
944
|
subData["buyerBankAccount"] = ""
|
|
@@ -406,11 +982,12 @@ func (c *FapiaoApiController) BwOpenBlueFaPiao() {
|
406
|
982
|
}
|
407
|
983
|
subData["invoiceDetailsList"] = subDetails
|
408
|
984
|
requestBody2["data"] = subData
|
|
985
|
+
|
409
|
986
|
status, reason, response, request_log, response_log := OpenBWBlue(requestBody2)
|
410
|
987
|
if status == 0 { //失败
|
411
|
988
|
c.ServeSuccessJSON(map[string]interface{}{
|
412
|
|
- "status": -10,
|
413
|
|
- "msg": reason,
|
|
989
|
+ "failed_code": -10,
|
|
990
|
+ "msg": reason,
|
414
|
991
|
})
|
415
|
992
|
} else { //成功
|
416
|
993
|
var fapiaos models.HisFaPiaoOrder
|
|
@@ -507,6 +1084,7 @@ func (c *FapiaoApiController) BwOpenRedFaPiao() {
|
507
|
1084
|
|
508
|
1085
|
}
|
509
|
1086
|
func (c *FapiaoApiController) QueryBwFaPiao() {
|
|
1087
|
+ fmt.Println("------")
|
510
|
1088
|
id, _ := c.GetInt64("id")
|
511
|
1089
|
oc, _ := service.GetFaPiaoOrderById(id)
|
512
|
1090
|
var config models.FapiaoConfig
|
|
@@ -568,24 +1146,32 @@ func OpenBWBlue(requestBody2 map[string]interface{}) (int64, string, bwfapiao.In
|
568
|
1146
|
return 0, result.ErrorResponse.Message + "\n" + result.ErrorResponse.SubMessage, result, string(reques_log), response
|
569
|
1147
|
}
|
570
|
1148
|
} else { //token 不存在,则进行获取token的操作
|
571
|
|
- fmt.Println("token 不存在")
|
572
|
1149
|
|
573
|
1150
|
tokenResp, _ := GetAccessToken("https://openapi.baiwang.com/router/rest", "b033l65qAA", "cc73223bd14a4064bb0fe9ba642da58f", "10059482", "bb481e0c-9895-44d8-b184-6b9707a60ec7", "admin_ffzyx16zmybx4", "")
|
574
|
1151
|
fmt.Println(tokenResp)
|
575
|
1152
|
|
576
|
1153
|
if len(tokenResp.Response.AccessToken) > 0 { //token请求成功,则将token和有效时间存储进redis,
|
577
|
1154
|
redisClient.Set("fapiao_access_token", tokenResp.Response.AccessToken, time.Duration(tokenResp.Response.ExpiresIn)*time.Second)
|
578
|
|
- params["token"] = tokenResp.Response.AccessToken
|
579
|
1155
|
// 生成签名
|
580
|
|
- sign, err = signTopRequestTwo(params, secret, requestBody2)
|
|
1156
|
+ secret = "bb481e0c-9895-44d8-b184-6b9707a60ec7"
|
|
1157
|
+ params_two := map[string]string{
|
|
1158
|
+ "method": "baiwang.output.invoice.issue",
|
|
1159
|
+ "version": "6.0",
|
|
1160
|
+ "appKey": "10059482",
|
|
1161
|
+ "format": "json",
|
|
1162
|
+ "timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
|
1163
|
+ "token": tokenResp.Response.AccessToken,
|
|
1164
|
+ "type": "sync",
|
|
1165
|
+ }
|
|
1166
|
+ sign, err = signTopRequestTwo(params_two, secret, requestBody2)
|
581
|
1167
|
if err != nil {
|
582
|
1168
|
fmt.Println("Error:", err)
|
583
|
1169
|
return 0, err.Error(), result, string(reques_log), ""
|
584
|
1170
|
}
|
585
|
|
- params["sign"] = sign
|
|
1171
|
+ params_two["sign"] = sign
|
586
|
1172
|
|
587
|
1173
|
// 调用 API
|
588
|
|
- response, err := callApiTwo("https://openapi.baiwang.com/router/rest", params, requestBody2)
|
|
1174
|
+ response, err := callApiTwo("https://openapi.baiwang.com/router/rest", params_two, requestBody2)
|
589
|
1175
|
if err != nil {
|
590
|
1176
|
fmt.Println("接口调用失败:", err)
|
591
|
1177
|
return 0, err.Error(), result, string(reques_log), response
|
|
@@ -711,16 +1297,18 @@ func OpenBWRed(config models.FapiaoConfig, orders models.HisFaPiaoOrder) (int64,
|
711
|
1297
|
remark = remark + " 基金支付总金额:" + MedfeeSumamt_str
|
712
|
1298
|
}
|
713
|
1299
|
}
|
714
|
|
- if PsnCashPay > 0 {
|
715
|
|
- MedfeeSumamt_str := fmt.Sprintf("%.2f", PsnCashPay)
|
|
1300
|
+
|
|
1301
|
+ if HifmiPay > 0 {
|
|
1302
|
+ MedfeeSumamt_str := fmt.Sprintf("%.2f", HifmiPay)
|
716
|
1303
|
|
717
|
1304
|
if len(remark) == 0 {
|
718
|
1305
|
//MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
719
|
|
- remark = "个人现金支付: " + MedfeeSumamt_str
|
|
1306
|
+ remark = "大病基金支付: " + MedfeeSumamt_str
|
720
|
1307
|
} else {
|
721
|
|
- remark = remark + " 个人现金支付:" + MedfeeSumamt_str
|
|
1308
|
+ remark = remark + " 大病基金支付:" + MedfeeSumamt_str
|
722
|
1309
|
}
|
723
|
1310
|
}
|
|
1311
|
+
|
724
|
1312
|
if HifmiPay > 0 {
|
725
|
1313
|
MedfeeSumamt_str := fmt.Sprintf("%.2f", HifmiPay)
|
726
|
1314
|
|
|
@@ -731,6 +1319,18 @@ func OpenBWRed(config models.FapiaoConfig, orders models.HisFaPiaoOrder) (int64,
|
731
|
1319
|
remark = remark + " 大病基金支付:" + MedfeeSumamt_str
|
732
|
1320
|
}
|
733
|
1321
|
}
|
|
1322
|
+
|
|
1323
|
+ if PsnCashPay > 0 {
|
|
1324
|
+ MedfeeSumamt_str := fmt.Sprintf("%.2f", PsnCashPay)
|
|
1325
|
+
|
|
1326
|
+ if len(remark) == 0 {
|
|
1327
|
+ //MedfeeSumamt_str := fmt.Sprintf("%.2f", MedfeeSumamt)
|
|
1328
|
+ remark = "个人现金支付: " + MedfeeSumamt_str
|
|
1329
|
+ } else {
|
|
1330
|
+ remark = remark + " 个人现金支付:" + MedfeeSumamt_str
|
|
1331
|
+ }
|
|
1332
|
+ }
|
|
1333
|
+
|
734
|
1334
|
if AcctPay > 0 {
|
735
|
1335
|
MedfeeSumamt_str := fmt.Sprintf("%.2f", AcctPay)
|
736
|
1336
|
|
|
@@ -1371,7 +1971,7 @@ type AuthResponse struct {
|
1371
|
1971
|
// GetAccessToken 获取登录授权的 access_token
|
1372
|
1972
|
func GetAccessToken(apiURL, plainPassword, salt, clientID, clientSecret, username, orgAuthCode string) (AuthResponse, error) {
|
1373
|
1973
|
// 当前时间戳(毫秒级)
|
1374
|
|
- timestamp := ""
|
|
1974
|
+ timestamp := strconv.FormatInt(time.Now().Unix(), 10)
|
1375
|
1975
|
|
1376
|
1976
|
// 密码加密:MD5 + SHA1
|
1377
|
1977
|
encryptedPassword := md5AndSha1(plainPassword + salt)
|
|
@@ -1384,7 +1984,6 @@ func GetAccessToken(apiURL, plainPassword, salt, clientID, clientSecret, usernam
|
1384
|
1984
|
|
1385
|
1985
|
// 构造请求体
|
1386
|
1986
|
authReq := map[string]interface{}{
|
1387
|
|
-
|
1388
|
1987
|
"client_secret": clientSecret,
|
1389
|
1988
|
"username": username,
|
1390
|
1989
|
"password": encryptedPassword,
|
|
@@ -1392,13 +1991,11 @@ func GetAccessToken(apiURL, plainPassword, salt, clientID, clientSecret, usernam
|
1392
|
1991
|
}
|
1393
|
1992
|
|
1394
|
1993
|
var aa AuthResponse
|
1395
|
|
-
|
1396
|
1994
|
// 转换为 JSON
|
1397
|
1995
|
reqBody, err := json.Marshal(authReq)
|
1398
|
1996
|
if err != nil {
|
1399
|
1997
|
return aa, fmt.Errorf("failed to marshal request: %v", err)
|
1400
|
1998
|
}
|
1401
|
|
-
|
1402
|
1999
|
// 发送 POST 请求
|
1403
|
2000
|
resp, err := http.Post(apiURL+"?"+"version="+"6.0"+"&method="+"baiwang.oauth.token"+"&grant_type="+"password"+"&client_id="+clientID+"×tamp="+timestamp, "application/json", bytes.NewBuffer(reqBody))
|
1404
|
2001
|
if err != nil {
|