feat: update pay notify
This commit is contained in:
@@ -3,12 +3,11 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"quyun/app/requests"
|
||||
"quyun/database/fields"
|
||||
"quyun/database/schemas/public/model"
|
||||
"quyun/database/schemas/public/table"
|
||||
"time"
|
||||
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
"github.com/pkg/errors"
|
||||
@@ -243,3 +242,68 @@ func (m *ordersModel) SumAmount(ctx context.Context) (int64, error) {
|
||||
|
||||
return cnt.Cnt, nil
|
||||
}
|
||||
|
||||
// GetByOrderNo
|
||||
func (m *ordersModel) GetByOrderNo(ctx context.Context, orderNo string) (*model.Orders, error) {
|
||||
tbl := table.Orders
|
||||
stmt := tbl.
|
||||
SELECT(tbl.AllColumns).
|
||||
WHERE(
|
||||
tbl.OrderNo.EQ(String(orderNo)),
|
||||
)
|
||||
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||
|
||||
var order model.Orders
|
||||
err := stmt.QueryContext(ctx, db, &order)
|
||||
if err != nil {
|
||||
m.log.Errorf("error querying order by orderNo: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &order, nil
|
||||
}
|
||||
|
||||
// SetTranscationID
|
||||
func (m *ordersModel) SetTranscationID(ctx context.Context, id int64, transactionID string) error {
|
||||
tbl := table.Orders
|
||||
stmt := tbl.
|
||||
UPDATE(tbl.TransactionID).
|
||||
SET(String(transactionID)).
|
||||
WHERE(
|
||||
tbl.ID.EQ(Int64(id)),
|
||||
)
|
||||
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||
|
||||
if _, err := stmt.ExecContext(ctx, db); err != nil {
|
||||
m.log.Errorf("error set order transaction ID: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update
|
||||
func (m *ordersModel) Update(ctx context.Context, order *model.Orders) error {
|
||||
tbl := table.Orders
|
||||
stmt := tbl.
|
||||
UPDATE(
|
||||
tbl.MutableColumns.Except(
|
||||
tbl.OrderNo,
|
||||
tbl.Price,
|
||||
tbl.Discount,
|
||||
tbl.SubOrderNo,
|
||||
tbl.PostID,
|
||||
tbl.UserID,
|
||||
),
|
||||
).
|
||||
MODEL(order).
|
||||
WHERE(
|
||||
tbl.ID.EQ(Int64(order.ID)),
|
||||
)
|
||||
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||
|
||||
if _, err := stmt.ExecContext(ctx, db); err != nil {
|
||||
m.log.Errorf("error updating order: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user