Clerk.php 1.6 KB

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