|
@@ -24,16 +24,16 @@ func InvoicingCallBackLogic(r *ghttp.Request) error {
|
|
|
g.Log().Info(r.Context(), "蓝票需要活体认证,已发送二维码消息")
|
|
|
case 1: //开票成功
|
|
|
var (
|
|
|
- pdfBase64 = r.Get("pdf").String()
|
|
|
- orderCode = r.Get("id").String()
|
|
|
- num = r.Get("num").String()
|
|
|
- kptime = r.Get("kptime").String()
|
|
|
+ pdfBase64 = r.Get("pdf").String()
|
|
|
+ callBackId = r.Get("id").String()
|
|
|
+ num = r.Get("num").String()
|
|
|
+ kptime = r.Get("kptime").String()
|
|
|
|
|
|
invoiceTime time.Time
|
|
|
err error
|
|
|
path string
|
|
|
)
|
|
|
- if pdfBase64 == "" || orderCode == "" || num == "" || kptime == "" {
|
|
|
+ if pdfBase64 == "" || callBackId == "" || num == "" || kptime == "" {
|
|
|
return gerror.New("缺少回调参数")
|
|
|
}
|
|
|
|
|
@@ -45,8 +45,8 @@ func InvoicingCallBackLogic(r *ghttp.Request) error {
|
|
|
if err != nil {
|
|
|
return gerror.Wrap(err, "保存pdf文件失败")
|
|
|
}
|
|
|
- g.Log().Infof(r.Context(), "pdf保存成功 orderCode:%s filePath:%s ", orderCode, path)
|
|
|
- return updateOrderInvoiceStatus(r.Context(), orderCode, num, invoiceTime, path)
|
|
|
+ g.Log().Infof(r.Context(), "pdf保存成功 sign:%s filePath:%s ", callBackId, path)
|
|
|
+ return updateOrderInvoiceStatus(r.Context(), callBackId, num, invoiceTime, path)
|
|
|
case 3:
|
|
|
g.Log().Info(r.Context(), "活体验证已过期,未完成活体验证")
|
|
|
case 4:
|
|
@@ -66,40 +66,43 @@ func InvoicingCallBackLogic(r *ghttp.Request) error {
|
|
|
// invoiceNum 发票号码
|
|
|
// createData 开票时间
|
|
|
// pdfPath 下载地址
|
|
|
-func updateOrderInvoiceStatus(ctx context.Context, orderCode, invoiceNum string, invoiceTime time.Time, pdfPath string) error {
|
|
|
+func updateOrderInvoiceStatus(ctx context.Context, callBackId, invoiceNum string, invoiceTime time.Time, pdfPath string) error {
|
|
|
var (
|
|
|
- queryItem = "order_code"
|
|
|
- err error
|
|
|
+ queryItem = "order_code"
|
|
|
+ queryValue = ""
|
|
|
+ err error
|
|
|
)
|
|
|
- if strings.Contains(orderCode, "xx") {
|
|
|
- //自助开票
|
|
|
- queryItem = "only_Identifying"
|
|
|
+
|
|
|
+ queryItem, queryValue, err = GetQueryObj(callBackId)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
}
|
|
|
+
|
|
|
_, err = g.DB().Update(ctx, "invoice", g.Map{
|
|
|
"invoice_number": invoiceNum,
|
|
|
"url": pdfPath,
|
|
|
"billing_time": invoiceTime.Unix(),
|
|
|
"invoice_status": 1,
|
|
|
- }, fmt.Sprintf("invoice_changed = 0 AND %s = ? ", queryItem), orderCode)
|
|
|
+ }, fmt.Sprintf(" %s = ? ", queryItem), queryValue)
|
|
|
if err != nil {
|
|
|
return gerror.Wrap(err, "更新发票状态异常")
|
|
|
}
|
|
|
|
|
|
// 王浩说开票成功 订单状态不用更新;以下代码来自王浩
|
|
|
- if strings.Contains(orderCode, "xx") {
|
|
|
- selfInvoicing(ctx, orderCode)
|
|
|
+ if queryItem == "only_Identifying" {
|
|
|
+ selfInvoicing(ctx, queryValue)
|
|
|
}
|
|
|
|
|
|
- if err := SendInvoiceSuccessMail(ctx, orderCode); err != nil {
|
|
|
- g.Log().Errorf(ctx, "%s 发送邮件失败 err: %v ", orderCode, err)
|
|
|
+ if err := SendInvoiceSuccessMail(ctx, callBackId); err != nil {
|
|
|
+ g.Log().Errorf(ctx, "%s 发送邮件失败 err: %v ", callBackId, err)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// selfInvoicing 自助开票
|
|
|
-func selfInvoicing(ctx context.Context, orderCode string) {
|
|
|
+func selfInvoicing(ctx context.Context, identifyingValue string) {
|
|
|
//自助开票
|
|
|
- res, err := g.DB().GetOne(ctx, "SELECT GROUP_CONCAT(order_code) as order_code from invoice where only_Identifying=?", orderCode)
|
|
|
+ res, err := g.DB().GetOne(ctx, "SELECT GROUP_CONCAT(order_code) as order_code from invoice where only_Identifying=?", identifyingValue)
|
|
|
if err != nil {
|
|
|
g.Log().Errorf(ctx, "自助开票异常")
|
|
|
}
|
|
@@ -109,7 +112,7 @@ func selfInvoicing(ctx context.Context, orderCode string) {
|
|
|
continue
|
|
|
}
|
|
|
updateData := map[string]interface{}{}
|
|
|
- if InvoiceStatusHandle(ctx, v) {
|
|
|
+ if invoiceStatusHandle(ctx, v) {
|
|
|
updateData["applybill_status"] = 2
|
|
|
} else {
|
|
|
updateData["applybill_status"] = 3
|
|
@@ -125,7 +128,7 @@ func selfInvoicing(ctx context.Context, orderCode string) {
|
|
|
|
|
|
// InvoiceStatusHandle 判断是全额还是部分回款
|
|
|
// auth :王浩
|
|
|
-func InvoiceStatusHandle(ctx context.Context, orderCode string) bool {
|
|
|
+func invoiceStatusHandle(ctx context.Context, orderCode string) bool {
|
|
|
orderData, err := g.DB().GetOne(ctx, "SELECT pay_money FROM dataexport_order WHERE order_code=?", orderCode)
|
|
|
if err != nil || orderData.IsEmpty() {
|
|
|
return false
|
|
@@ -136,8 +139,8 @@ func InvoiceStatusHandle(ctx context.Context, orderCode string) bool {
|
|
|
return false
|
|
|
}
|
|
|
allMoney := gconv.Int64(invoiceData["money"])
|
|
|
- pay_money := gconv.Int64(orderData["pay_money"])
|
|
|
- if pay_money == allMoney {
|
|
|
+ payMoney := gconv.Int64(orderData["pay_money"])
|
|
|
+ if payMoney == allMoney {
|
|
|
return true
|
|
|
}
|
|
|
return false
|