|
|
@@ -0,0 +1,62 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/super/dao" |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/super/model" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewMasterDataStatisticsDb(engine *xorm.Engine) dao.MasterDataStatisticsDao { |
|
|
|
return &MasterDataStatisticsDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type MasterDataStatisticsDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (m MasterDataStatisticsDb) GetMasterDataStatistics(uuid int, date string) (data *model.MasterDataStatistics, err error) { |
|
|
|
data = new(model.MasterDataStatistics) |
|
|
|
has, err := m.Db.Where("uuid =? and date =?", uuid, date).Get(data) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return data, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (m MasterDataStatisticsDb) UpdateMasterDataStatistics(mm *model.MasterDataStatistics, columns ...string) (int64, error) { |
|
|
|
affected, err := m.Db.Where("id =?", mm.Id).Cols(columns...).Update(mm) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (m MasterDataStatisticsDb) UpdateMasterDataStatisticsBySession(session *xorm.Session, mm *model.MasterDataStatistics, columns ...string) (int64, error) { |
|
|
|
affected, err := session.Where("id =?", mm.Id).Cols(columns...).Update(mm) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (m MasterDataStatisticsDb) FindMasterDataStatisticsList(uuid, startDate, endDate string, page, limit int) (list []model.MasterDataStatistics, total int64, err error) { |
|
|
|
sess := m.Db.OrderBy("date desc,id desc").Limit(limit, (page-1)*limit) |
|
|
|
if uuid != "" { |
|
|
|
sess.And("uuid = ?", uuid) |
|
|
|
} |
|
|
|
if startDate != "" { |
|
|
|
sess.And("date>=", startDate) |
|
|
|
} |
|
|
|
if endDate != "" { |
|
|
|
sess.And("date<=", endDate) |
|
|
|
} |
|
|
|
total, err = sess.FindAndCount(&list) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
return |
|
|
|
} |