SystemStoreStaff.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\models\system;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * 店员 model
  7. * Class SystemStore
  8. * @package app\admin\model\system
  9. */
  10. class SystemStoreStaff extends BaseModel
  11. {
  12. use ModelTrait;
  13. /**
  14. * 数据表主键
  15. * @var string
  16. */
  17. protected $pk = 'id';
  18. /**
  19. * 模型名称
  20. * @var string
  21. */
  22. protected $name = 'system_store_staff';
  23. /**
  24. * 时间戳获取器转日期
  25. * @param $value
  26. * @return false|string
  27. */
  28. public static function getAddTimeAttr($value)
  29. {
  30. return date('Y-m-d H:i:s',$value);
  31. }
  32. /**
  33. * 判断是否是有权限核销的店员
  34. * @param $uid
  35. * @return int
  36. */
  37. public static function verifyStatus($uid)
  38. {
  39. return self::where('uid', $uid)->where('status', 1)->where('verify_status', 1)->count();
  40. }
  41. /**
  42. * 获取店员列表
  43. * @param array $where
  44. * @return array
  45. */
  46. public static function getList($where = [])
  47. {
  48. $model = new self();
  49. $model = $model->alias('a')
  50. ->join('wechat_user u', 'u.uid=a.uid')
  51. ->join('system_store s', 'a.store_id = s.id')
  52. ->field('a.id,u.nickname,a.avatar,a.staff_name,a.status,a.add_time,s.name');
  53. if (isset($where['store_id']) && $where['store_id'] > 0) {
  54. $model = $model->where('store_id', $where['store_id']);
  55. }
  56. if (isset($where['mer_id']) && $where['mer_id'] > 0) {
  57. $model = $model->where('a.mer_id', $where['mer_id']);
  58. }
  59. $count = $model->count();
  60. $list = $model->page((int)$where['page'], (int)$where['limit'])->select();
  61. if (count($list)) {
  62. $list = $list->toArray();
  63. } else {
  64. $list = [];
  65. }
  66. return compact('count', 'list');
  67. }
  68. }