SystemStoreStaff.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\system\store;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 店员模型
  18. * Class SystemStoreStaff
  19. * @package app\model\system\store
  20. */
  21. class SystemStoreStaff extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 模型名称
  26. * @var string
  27. */
  28. protected $name = 'system_store_staff';
  29. /**
  30. * user用户表一对一关联
  31. * @return \think\model\relation\HasOne
  32. */
  33. public function user()
  34. {
  35. return $this->hasOne(User::class, 'uid', 'uid')->field(['uid', 'nickname'])->bind([
  36. 'nickname' => 'nickname'
  37. ]);
  38. }
  39. /**
  40. * 门店表一对一关联
  41. * @return \think\model\relation\HasOne
  42. */
  43. public function store()
  44. {
  45. return $this->hasOne(SystemStore::class, 'id', 'store_id')->field(['id', 'name'])->bind([
  46. 'name' => 'name'
  47. ]);
  48. }
  49. /**
  50. * 时间戳获取器转日期
  51. * @param $value
  52. * @return false|string
  53. */
  54. public static function getAddTimeAttr($value)
  55. {
  56. return date('Y-m-d H:i:s', $value);
  57. }
  58. /**
  59. * 是否有核销权限搜索器
  60. * @param Model $query
  61. * @param $value 用户uid
  62. */
  63. public function searchIsStatusAttr($query, $value)
  64. {
  65. $query->where(['uid' => $value, 'status' => 1, 'verify_status' => 1]);
  66. }
  67. /**
  68. * uid搜索器
  69. * @param Model $query
  70. * @param $value
  71. */
  72. public function searchUidAttr($query, $value)
  73. {
  74. $query->where('uid', $value);
  75. }
  76. /**
  77. * 门店id搜索器
  78. * @param Model $query
  79. * @param $value
  80. */
  81. public function searchStoreIdAttr($query, $value)
  82. {
  83. if ($value && $value > 0) {
  84. $query->where('store_id', $value);
  85. }
  86. }
  87. }