|
@@ -31,27 +31,28 @@ func InvoicingCallBackLogic(r *ghttp.Request) error {
|
|
kptime = r.Get("kptime").String()
|
|
kptime = r.Get("kptime").String()
|
|
data = r.Get("data").Map()
|
|
data = r.Get("data").Map()
|
|
invoiceTime time.Time
|
|
invoiceTime time.Time
|
|
- path string
|
|
|
|
|
|
|
|
- err error
|
|
|
|
|
|
+ sourceUrl string //税务局发票链接
|
|
|
|
+ fileUrl string //剑鱼文件地址
|
|
|
|
+ err error
|
|
)
|
|
)
|
|
if pdfBase64 == "" || callBackId == "" || num == "" || kptime == "" || len(data) == 0 {
|
|
if pdfBase64 == "" || callBackId == "" || num == "" || kptime == "" || len(data) == 0 {
|
|
return gerror.New("缺少回调参数")
|
|
return gerror.New("缺少回调参数")
|
|
}
|
|
}
|
|
// 需求变更,数据库存储税务局发票地址
|
|
// 需求变更,数据库存储税务局发票地址
|
|
- if path = gconv.String(data["jfUrl"]); path == "" {
|
|
|
|
|
|
+ if sourceUrl = gconv.String(data["jfUrl"]); sourceUrl == "" {
|
|
return gerror.New("获取pdf交付地址异常")
|
|
return gerror.New("获取pdf交付地址异常")
|
|
}
|
|
}
|
|
invoiceTime, err = time.ParseInLocation(consts.DateFormat_Full, kptime, time.Local)
|
|
invoiceTime, err = time.ParseInLocation(consts.DateFormat_Full, kptime, time.Local)
|
|
if err != nil {
|
|
if err != nil {
|
|
return gerror.Wrap(err, "时间格式化异常")
|
|
return gerror.Wrap(err, "时间格式化异常")
|
|
}
|
|
}
|
|
- //path, err = util.SavePdfFile(r.Context(), num, pdfBase64)
|
|
|
|
- //if err != nil {
|
|
|
|
- // return gerror.Wrap(err, "保存pdf文件失败")
|
|
|
|
- //}
|
|
|
|
- //g.Log().Infof(r.Context(), "pdf保存成功 sign:%s filePath:%s ", callBackId, path)
|
|
|
|
- return updateOrderInvoiceStatus(r.Context(), callBackId, num, invoiceTime, path)
|
|
|
|
|
|
+ fileUrl, err = util.SavePdfFile(r.Context(), num, pdfBase64)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return gerror.Wrap(err, "保存pdf文件失败")
|
|
|
|
+ }
|
|
|
|
+ g.Log().Infof(r.Context(), "pdf保存成功 sign:%s filePath:%s ", callBackId, fileUrl)
|
|
|
|
+ return updateOrderInvoiceStatus(r.Context(), callBackId, num, invoiceTime, sourceUrl, fileUrl)
|
|
case 3:
|
|
case 3:
|
|
g.Log().Info(r.Context(), "活体验证已过期,未完成活体验证")
|
|
g.Log().Info(r.Context(), "活体验证已过期,未完成活体验证")
|
|
case 4:
|
|
case 4:
|
|
@@ -71,7 +72,7 @@ func InvoicingCallBackLogic(r *ghttp.Request) error {
|
|
// invoiceNum 发票号码
|
|
// invoiceNum 发票号码
|
|
// createData 开票时间
|
|
// createData 开票时间
|
|
// pdfPath 下载地址
|
|
// pdfPath 下载地址
|
|
-func updateOrderInvoiceStatus(ctx context.Context, callBackId, invoiceNum string, invoiceTime time.Time, pdfPath string) error {
|
|
|
|
|
|
+func updateOrderInvoiceStatus(ctx context.Context, callBackId, invoiceNum string, invoiceTime time.Time, sourceUrl, pdfPath string) error {
|
|
var (
|
|
var (
|
|
queryItem = "order_code"
|
|
queryItem = "order_code"
|
|
queryValue = ""
|
|
queryValue = ""
|
|
@@ -105,6 +106,7 @@ func updateOrderInvoiceStatus(ctx context.Context, callBackId, invoiceNum string
|
|
_, err = tx.Update("invoice", g.Map{
|
|
_, err = tx.Update("invoice", g.Map{
|
|
"invoice_number": invoiceNum,
|
|
"invoice_number": invoiceNum,
|
|
"url": pdfPath,
|
|
"url": pdfPath,
|
|
|
|
+ "source_url": sourceUrl,
|
|
"billing_time": invoiceTime.Unix(),
|
|
"billing_time": invoiceTime.Unix(),
|
|
"invoice_status": 1,
|
|
"invoice_status": 1,
|
|
}, fmt.Sprintf(" %s = ? AND invoice_status in(0,2) ", queryItem), queryValue)
|
|
}, fmt.Sprintf(" %s = ? AND invoice_status in(0,2) ", queryItem), queryValue)
|