package service import ( "ElectronicInvoice/util" "fmt" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" ) // 红票信息 type RedMsg struct { InvoiceCode string `json:"invoice_code"` InvoiceNumber string `json:"invoice_number"` Url string `json:"url"` InvoiceSerialnum string `json:"invoice_serialnum"` InvoiceStatus string `json:"invoice_status"` BillingTime int64 `json:"billing_time"` } // InvoicingMakeRedCallBackLogic 开票回调逻辑 func InvoicingMakeRedCallBackLogic(r *ghttp.Request) error { tType := r.Get("type").Int() switch tType { case 0: //红冲成功 var ( pdfBase64 = r.Get("pdf").String() num = r.Get("num") //蓝票号 err error path string ) //更新旧蓝票状态 //保存红票信息 path, err = util.SavePdfFile(r.Context(), fmt.Sprintf("RED_%s", num), pdfBase64) if err != nil { return gerror.Wrap(err, "保存红冲pdf文件失败") } g.Dump(path) case 1: //失败 case 2: //授信额度等信息 g.Log().Info(r.Context(), "授信额度等信息") case 3: g.Log().Info(r.Context(), "活体验证已过期,未完成活体验证") case 4: g.Log().Info(r.Context(), "活体成功") case 5: g.Log().Info(r.Context(), "返回活体检测二维码的内容") case 9: g.Log().Info(r.Context(), "活体码未知错误") case 10: g.Log().Info(r.Context(), "非数电票试点纳税人,未核定数电票票种,不允许开票") case 11: g.Log().Info(r.Context(), "获取授信额度失败") default: g.Log().Info(r.Context(), "InvoicingMakeRedCallBackLogic tType:%s", tType) } return nil }