package contract

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

// PayChannel 支付渠道
type PayChannel struct {
	Id         int       `orm:"column(id);pk"`
	PayChannel string    `description:"支付渠道,长度32位"`
	CreateTime time.Time `description:"添加时间"`
}

// Update 更新支付渠道基础信息
func (payChannel *PayChannel) Update(cols []string) (err error) {
	o := orm.NewOrm()
	_, err = o.Update(payChannel, cols...)
	return
}

// GetPayChannelList 模糊搜索 获取支付渠道列表数据
func GetPayChannelList(keyword string) (list []*PayChannel, err error) {
	o := orm.NewOrm()
	sql := `select * from pay_channel where 1=1 `
	if keyword != "" {
		sql += `AND pay_channel like "%` + keyword + `%"`
	}
	_, err = o.Raw(sql).QueryRows(&list)
	return
}