StoreService.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\models\store;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. /**
  6. * TODO 客服Model
  7. * Class StoreService
  8. * @package app\models\store
  9. */
  10. class StoreService extends BaseModel
  11. {
  12. /**
  13. * 数据表主键
  14. * @var string
  15. */
  16. protected $pk = 'id';
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'store_service';
  22. use ModelTrait;
  23. /**
  24. * 获取客服列表
  25. * @param $page
  26. * @param $limit
  27. * @return object
  28. */
  29. public static function lst(int $page, int $limit)
  30. {
  31. $model = new self;
  32. $model = $model->where('status', SHOW);
  33. $model = $model->page($page, $limit);
  34. return $model->select();
  35. }
  36. /**
  37. * 获取客服信息
  38. * @param $uid
  39. * @param string $field
  40. * @return array|null|\think\Model
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @throws \think\exception\DbException
  44. */
  45. public static function getServiceInfo($uid, $field = '*')
  46. {
  47. return self::where('uid', $uid)->where('status', SHOW)->field($field)->find();
  48. }
  49. /**
  50. * 判断是否客服
  51. * @param $uid
  52. * @return int
  53. */
  54. public static function orderServiceStatus($uid)
  55. {
  56. return self::where('uid', $uid)->where('status', SHOW)->where('customer', YES)->count();
  57. }
  58. /**
  59. * 获取接受通知的客服
  60. *
  61. * @return array
  62. */
  63. public static function getStoreServiceOrderNotice()
  64. {
  65. return self::where('status', SHOW)->where('notify', ENABLED)->column('uid', 'uid');
  66. }
  67. }