43 lines
755 B
Go
43 lines
755 B
Go
package dao
|
|
|
|
import (
|
|
"enterprise/common/model"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type CorpOrderData struct {
|
|
}
|
|
|
|
func NewCorpOrderData() *CorpOrderData {
|
|
return &CorpOrderData{}
|
|
}
|
|
|
|
func (d *CorpOrderData) TableName() string {
|
|
return "cp_order"
|
|
}
|
|
|
|
func (d *CorpOrderData) QueryOwnerData(owner, startDay, endDay string) (*model.CorpOrderData, error) {
|
|
tx := corpDB.Table(d.TableName())
|
|
|
|
var o model.CorpOrderData
|
|
|
|
tx = tx.Where("data_type = ?", "account_report")
|
|
tx = tx.Where("owner = ?", owner)
|
|
if startDay != "" {
|
|
tx = tx.Where("day >= ?", startDay)
|
|
}
|
|
if endDay != "" {
|
|
tx = tx.Where("day <= ?", endDay)
|
|
}
|
|
|
|
tx = tx.First(&o)
|
|
if tx.Error == gorm.ErrRecordNotFound {
|
|
return &o, nil
|
|
}
|
|
|
|
if tx.Error != nil {
|
|
return nil, tx.Error
|
|
}
|
|
return &o, nil
|
|
}
|