SystemStoreStaff.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\admin\model\system;
  3. use app\admin\model\user\User;
  4. use crmeb\traits\ModelTrait;
  5. use crmeb\basic\BaseModel;
  6. use crmeb\services\PHPExcelService;
  7. /**
  8. * 店员 model
  9. * Class SystemStore
  10. * @package app\admin\model\system
  11. */
  12. class SystemStoreStaff extends BaseModel
  13. {
  14. use ModelTrait;
  15. /**
  16. * 数据表主键
  17. * @var string
  18. */
  19. protected $pk = 'id';
  20. /**
  21. * 模型名称
  22. * @var string
  23. */
  24. protected $name = 'system_store_staff';
  25. protected function getAddTimeAttr($value)
  26. {
  27. if ($value) $value = date('Y-m-d H:i:s', $value);
  28. return $value;
  29. }
  30. /**
  31. * 获取门店列表
  32. * @param $where
  33. * @return array
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. */
  38. public static function lst($where)
  39. {
  40. $model = self::page((int)$where['page'], (int)$where['limit']);
  41. if (isset($where['store_id']) && $where['store_id'] != '') {
  42. $model = $model->where('store_id', $where['store_id']);
  43. }
  44. // if (isset($where['type']) && $where['type'] != '' && ($data = self::setData($where['type']))) {
  45. // $model = $model->where($data);
  46. // }
  47. $model = $model->alias('a')
  48. ->join('wechat_user u', 'u.uid=a.uid')
  49. ->join('system_store s', 'a.store_id = s.id')
  50. ->field('a.id,u.nickname,a.avatar,a.staff_name,a.status,a.add_time,s.name');
  51. $data = $model->select();
  52. $count = $data->count();
  53. return compact('count', 'data');
  54. }
  55. /**
  56. * 获取选择的商城用户
  57. */
  58. public static function getUserList()
  59. {
  60. $uids = self::column('uid');
  61. $uids = array_values($uids);
  62. $uids = implode(',', $uids);
  63. $list = User::where('uid', 'not in', $uids)->select();
  64. return ['data' => $list];
  65. }
  66. }