invoiceCallback_red.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package service
  2. import (
  3. "ElectronicInvoice/util"
  4. "fmt"
  5. "github.com/gogf/gf/v2/errors/gerror"
  6. "github.com/gogf/gf/v2/frame/g"
  7. "github.com/gogf/gf/v2/net/ghttp"
  8. )
  9. // 红票信息
  10. type RedMsg struct {
  11. InvoiceCode string `json:"invoice_code"`
  12. InvoiceNumber string `json:"invoice_number"`
  13. Url string `json:"url"`
  14. InvoiceSerialnum string `json:"invoice_serialnum"`
  15. InvoiceStatus string `json:"invoice_status"`
  16. BillingTime int64 `json:"billing_time"`
  17. }
  18. // InvoicingMakeRedCallBackLogic 开票回调逻辑
  19. func InvoicingMakeRedCallBackLogic(r *ghttp.Request) error {
  20. tType := r.Get("type").Int()
  21. switch tType {
  22. case 0: //红冲成功
  23. var (
  24. pdfBase64 = r.Get("pdf").String()
  25. num = r.Get("num") //蓝票号
  26. err error
  27. path string
  28. )
  29. //更新旧蓝票状态
  30. //保存红票信息
  31. path, err = util.SavePdfFile(r.Context(), fmt.Sprintf("RED_%s", num), pdfBase64)
  32. if err != nil {
  33. return gerror.Wrap(err, "保存红冲pdf文件失败")
  34. }
  35. g.Dump(path)
  36. case 1: //失败
  37. case 2: //授信额度等信息
  38. g.Log().Info(r.Context(), "授信额度等信息")
  39. case 3:
  40. g.Log().Info(r.Context(), "活体验证已过期,未完成活体验证")
  41. case 4:
  42. g.Log().Info(r.Context(), "活体成功")
  43. case 5:
  44. g.Log().Info(r.Context(), "返回活体检测二维码的内容")
  45. case 9:
  46. g.Log().Info(r.Context(), "活体码未知错误")
  47. case 10:
  48. g.Log().Info(r.Context(), "非数电票试点纳税人,未核定数电票票种,不允许开票")
  49. case 11:
  50. g.Log().Info(r.Context(), "获取授信额度失败")
  51. default:
  52. g.Log().Info(r.Context(), "InvoicingMakeRedCallBackLogic tType:%s", tType)
  53. }
  54. return nil
  55. }