|
@@ -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{}{
|