| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\api\model\massager;
- use app\api\model\BaseModel;
- class Work extends BaseModel
- {
- // 表名
- protected $name = 'massager_work';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- function getLastRecord($m_id)
- {
- return $this->where("massager_id", $m_id)
- ->order("updatetime", "desc")
- ->find();
- }
- function sumByNowMonth($m_id, $y = null, $m = null)
- {
- $ym = ym($y, $m);
- return $this->where("massager_id", $m_id)
- ->where("DATE_FORMAT(FROM_UNIXTIME(createtime),'%Y-%m') = '{$ym}'")
- ->sum("duration");
- }
- function sumDurationByMassager($m_id)
- {
- return $this->where("massager_id", $m_id)
- ->where("duration", ">", 0)
- ->sum("duration");
- }
- function fetchByMassager($m_id, $page, $size)
- {
- return $this->where("massager_id", $m_id)
- ->where("DATE_FORMAT(FROM_UNIXTIME(createtime),'%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')")
- ->order("updatetime", "desc")
- ->page($size)
- ->paginate($size);
- }
- }
|