Clerk.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\api\model\store\shop;
  3. use app\common\exception\BaseException;
  4. use app\common\model\store\shop\Clerk as ClerkModel;
  5. /**
  6. * 商家门店店员模型
  7. * Class Clerk
  8. * @package app\api\model\store\shop
  9. */
  10. class Clerk extends ClerkModel
  11. {
  12. /**
  13. * 隐藏字段
  14. * @var array
  15. */
  16. protected $hidden = [
  17. 'is_delete',
  18. 'wxapp_id',
  19. 'create_time',
  20. 'update_time'
  21. ];
  22. /**
  23. * 店员详情
  24. * @param $where
  25. * @return static
  26. * @throws BaseException
  27. * @throws \think\exception\DbException
  28. */
  29. public static function detail($where)
  30. {
  31. /* @var static $model */
  32. $model = parent::detail($where);
  33. if (!$model) {
  34. throw new BaseException(['msg' => '未找到店员信息']);
  35. }
  36. return $model;
  37. }
  38. /**
  39. * 验证用户是否为核销员
  40. * @param $shop_id
  41. * @return bool
  42. */
  43. public function checkUser($shop_id)
  44. {
  45. if ($this['is_delete']) {
  46. $this->error = '未找到店员信息';
  47. return false;
  48. }
  49. if ($this['shop_id'] != $shop_id) {
  50. $this->error = '当前店员不属于该门店,没有核销权限';
  51. return false;
  52. }
  53. if (!$this['status']) {
  54. $this->error = '当前店员状态已被禁用';
  55. return false;
  56. }
  57. return true;
  58. }
  59. }