Closing.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\api\model\massager;
  3. use app\api\model\BaseModel;
  4. class Closing extends BaseModel
  5. {
  6. // 表名
  7. protected $name = 'massager_closing';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'status_text'
  17. ];
  18. public function getStatusList()
  19. {
  20. return ['checking' => __('审核中'), 'reject' => __('拒绝'), 'allow' => __('通过')];
  21. }
  22. public function getStatusTextAttr($value, $data)
  23. {
  24. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  25. $list = $this->getStatusList();
  26. return isset($list[$value]) ? $list[$value] : '';
  27. }
  28. public function massager()
  29. {
  30. return $this->belongsTo(Massager::class, 'massager_id', 'id', [], 'LEFT')->setEagerlyType(0);
  31. }
  32. public function findByMIdAndYm($m_id, $city_code, $year, $month)
  33. {
  34. return $this->where([
  35. "massager_id" => $m_id,
  36. "city_code" => $city_code,
  37. "year" => $year,
  38. "month" => $month
  39. ])->where("status", "in", [\E_BASE_STATUS::Checking, "allow"])
  40. ->order("id", "desc")->find();
  41. }
  42. public function fetchByMassasger($m_id, $page, $size)
  43. {
  44. return $this->where([
  45. "massager_id" => $m_id,
  46. ])->order("updatetime", "desc")
  47. ->page($page)
  48. ->paginate($size);
  49. }
  50. }