|
|
@@ -0,0 +1,43 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewPlatformRevenueDataDb(engine *xorm.Engine) dao.PlatformRevenueDataDao { |
|
|
|
return &PlatformRevenueDataDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type PlatformRevenueDataDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (p PlatformRevenueDataDb) PlatformRevenueDataInsert(platformRevenueData *model.PlatformRevenueData) (int, error) { |
|
|
|
_, err := p.Db.InsertOne(platformRevenueData) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return platformRevenueData.Id, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (p PlatformRevenueDataDb) PlatformRevenueDataFindAndCount(page, limit int, startAt, endAt string, kind int) ([]model.PlatformRevenueData, int64, error) { |
|
|
|
var m []model.PlatformRevenueData |
|
|
|
session := p.Db.Where("") |
|
|
|
if kind > 0 { |
|
|
|
session = session.Where("kind = ?", kind) |
|
|
|
} |
|
|
|
if startAt != "" { |
|
|
|
session = session.Where("start_at >= ?", startAt) |
|
|
|
} |
|
|
|
if endAt != "" { |
|
|
|
session = session.Where("end_at <= ?", endAt) |
|
|
|
} |
|
|
|
total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, zhios_order_relate_logx.Error(err.Error()) |
|
|
|
} |
|
|
|
return m, total, nil |
|
|
|
} |