CompanyPayOrder.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package Company
  2. import (
  3. "Cold_Api/controllers/lib"
  4. "github.com/beego/beego/v2/adapter/orm"
  5. "github.com/beego/beego/v2/core/logs"
  6. "time"
  7. )
  8. // 用户支付订单
  9. type CompanyPayOrder struct {
  10. Id int `orm:"column(ID);size(11);auto;pk"`
  11. T_pid int `orm:"index;size(256);"` // 公司id
  12. T_type string `orm:"size(256)"` // 微信 支付宝 等等
  13. T_title string `orm:"type(text)"` // 标题
  14. T_total float64 `orm:"digits(12);decimals(2)"` // 金额
  15. T_order_no string `orm:"size(256)"` // 支付订单
  16. T_status string `orm:"size(256)"` // 支付状态
  17. T_remark string `orm:"size(256)"` // 备注
  18. CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
  19. }
  20. func (t *CompanyPayOrder) TableName() string {
  21. return "company_pay_order" // 数据库名称 // ************** 替换 DesignDeviceNotice **************
  22. }
  23. func init() {
  24. //注册模型
  25. orm.RegisterModel(new(CompanyPayOrder))
  26. }
  27. func Add_CompanyPayOrder(r CompanyPayOrder) (id int64, err error) {
  28. o := orm.NewOrm()
  29. id, err = o.Insert(&r)
  30. if err != nil {
  31. logs.Error(lib.FuncName(), err)
  32. return
  33. }
  34. return
  35. }
  36. // 修改
  37. func Update_CompanyPayOrder(m CompanyPayOrder, cols ...string) error {
  38. o := orm.NewOrm()
  39. num, err := o.Update(&m, cols...)
  40. if err != nil {
  41. logs.Error(lib.FuncName(), err)
  42. return err
  43. }
  44. logs.Info("Number of records updated in database:", num)
  45. return nil
  46. }
  47. // 获取 ByT_order_no
  48. func Get_CompanyPayOrder_ByT_order_no(T_order_no string) (r CompanyPayOrder, err error) {
  49. o := orm.NewOrm()
  50. qs := o.QueryTable(new(CompanyPayOrder))
  51. err = qs.Filter("T_order_no", T_order_no).One(&r)
  52. if err != nil {
  53. logs.Error(lib.FuncName(), err)
  54. }
  55. return
  56. }