39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"slogan-agent/styleagent/consts"
|
|
"slogan-agent/styleagent/model/entity"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
var PayNotifyLog = &payNotifyLogDao{}
|
|
|
|
type payNotifyLogDao struct{}
|
|
|
|
func init() {
|
|
ctx := context.Background()
|
|
_, err := g.DB().Exec(ctx, `CREATE TABLE IF NOT EXISTS `+consts.TableNamePayNotifyLog+` (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
order_no TEXT NOT NULL DEFAULT '',
|
|
body TEXT NOT NULL DEFAULT '',
|
|
sign TEXT NOT NULL DEFAULT '',
|
|
remote_ip TEXT NOT NULL DEFAULT '',
|
|
status TEXT NOT NULL DEFAULT 'ok',
|
|
created_at DATETIME DEFAULT (datetime('now','localtime'))
|
|
)`)
|
|
if err != nil {
|
|
g.Log().Warningf(ctx, "create pay_notify_log table failed: %v", err)
|
|
}
|
|
}
|
|
|
|
func (d *payNotifyLogDao) Insert(ctx context.Context, log *entity.PayNotifyLog) error {
|
|
_, err := g.DB().Model(consts.TableNamePayNotifyLog).Ctx(ctx).Data(g.Map{
|
|
"order_no": log.OrderNo, "body": log.Body, "sign": log.Sign,
|
|
"remote_ip": log.RemoteIp, "status": log.Status,
|
|
}).Insert()
|
|
return err
|
|
}
|