123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package Company
- import (
- "Cold_Api/controllers/lib"
- "github.com/beego/beego/v2/adapter/orm"
- "github.com/beego/beego/v2/core/logs"
- "time"
- )
- // 用户支付订单
- type CompanyPayOrder struct {
- Id int `orm:"column(ID);size(11);auto;pk"`
- T_pid int `orm:"index;size(256);"` // 公司id
- T_type string `orm:"size(256)"` // 微信 支付宝 等等
- T_title string `orm:"type(text)"` // 标题
- T_total float64 `orm:"digits(12);decimals(2)"` // 金额
- T_order_no string `orm:"size(256)"` // 支付订单
- T_status string `orm:"size(256)"` // 支付状态
- T_remark string `orm:"size(256)"` // 备注
- CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
- }
- func (t *CompanyPayOrder) TableName() string {
- return "company_pay_order" // 数据库名称 // ************** 替换 DesignDeviceNotice **************
- }
- func init() {
- //注册模型
- orm.RegisterModel(new(CompanyPayOrder))
- }
- func Add_CompanyPayOrder(r CompanyPayOrder) (id int64, err error) {
- o := orm.NewOrm()
- id, err = o.Insert(&r)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- return
- }
- return
- }
- // 修改
- func Update_CompanyPayOrder(m CompanyPayOrder, cols ...string) error {
- o := orm.NewOrm()
- num, err := o.Update(&m, cols...)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- return err
- }
- logs.Info("Number of records updated in database:", num)
- return nil
- }
- // 获取 ByT_order_no
- func Get_CompanyPayOrder_ByT_order_no(T_order_no string) (r CompanyPayOrder, err error) {
- o := orm.NewOrm()
- qs := o.QueryTable(new(CompanyPayOrder))
- err = qs.Filter("T_order_no", T_order_no).One(&r)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- }
- return
- }
|