StoreService.php 1.8 KB

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