StoreService.php 1.7 KB

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