Files
kami_gateway/internal/models/payfor/payfor_info.go
danial e88ff05a14 refactor(trace): 重命名 otel 包为 otelTrace并更新相关引用
- 将内部使用的 otel 包重命名为 otelTrace
- 更新了所有引用该包的文件中的导入路径
- 修改了部分函数和变量名称以适应新的包名
2025-02-23 21:56:29 +08:00

110 lines
2.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package payfor
import (
"context"
"gateway/internal/otelTrace"
"time"
"github.com/beego/beego/v2/client/orm"
"go.uber.org/zap"
)
type PayforInfo struct {
Id int
PayforUid string
MerchantUid string
MerchantName string
MerchantOrderId string
BankOrderId string
BankTransId string
RoadUid string
RoadName string
RollPoolCode string
RollPoolName string
PayforFee float64
PayforAmount float64
PayforTotalAmount float64
BankCode string
BankName string
BankAccountName string
BankAccountNo string
BankAccountType string
Country string
City string
Ares string
BankAccountAddress string
PhoneNo string
GiveType string
Type string
NotifyUrl string
Status string
IsSend string
RequestTime time.Time
ResponseTime string
ResponseContent string
Remark string
CreateTime time.Time
UpdateTime time.Time
}
const PAYFORINFO = "payfor_info"
func InsertPayFor(ctx context.Context, payFor PayforInfo) bool {
o := orm.NewOrm()
_, err := o.Insert(&payFor)
if err != nil {
otelTrace.Logger.WithContext(ctx).Error("insert payfor fail: ", zap.Error(err))
return false
}
return true
}
func IsExistPayForByBankOrderId(bankOrderId string) bool {
o := orm.NewOrm()
exist := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Exist()
return exist
}
func IsExistPayForByMerchantOrderId(merchantOrderId string) bool {
o := orm.NewOrm()
exist := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Exist()
return exist
}
func GetPayForByBankOrderId(ctx context.Context, bankOrderId string) PayforInfo {
o := orm.NewOrm()
var payFor PayforInfo
_, err := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&payFor)
if err != nil {
otelTrace.Logger.WithContext(ctx).Error("get pay for by bank_order_id fail: ", zap.Error(err))
}
return payFor
}
func GetPayForByMerchantOrderId(ctx context.Context, merchantOrderId string) PayforInfo {
o := orm.NewOrm()
var payFor PayforInfo
_, err := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Limit(1).All(&payFor)
if err != nil {
otelTrace.Logger.WithContext(ctx).Error("fail: ", zap.Error(err))
}
return payFor
}
func UpdatePayFor(ctx context.Context, payFor PayforInfo) bool {
o := orm.NewOrm()
_, err := o.Update(&payFor)
if err != nil {
otelTrace.Logger.WithContext(ctx).Error("update pay for fail", zap.Error(err))
return false
}
return true
}