| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\api\model\massager;
- use app\api\model\BaseModel;
- class Closing extends BaseModel
- {
- // 表名
- protected $name = 'massager_closing';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'status_text'
- ];
- public function getStatusList()
- {
- return ['checking' => __('审核中'), 'reject' => __('拒绝'), 'allow' => __('通过')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function massager()
- {
- return $this->belongsTo(Massager::class, 'massager_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function findByMIdAndYm($m_id, $city_code, $year, $month)
- {
- return $this->where([
- "massager_id" => $m_id,
- "city_code" => $city_code,
- "year" => $year,
- "month" => $month
- ])->where("status", "in", [\E_BASE_STATUS::Checking, "allow"])
- ->order("id", "desc")->find();
- }
- public function fetchByMassasger($m_id, $page, $size)
- {
- return $this->where([
- "massager_id" => $m_id,
- ])->order("updatetime", "desc")
- ->page($page)
- ->paginate($size);
- }
- }
|