SystemStoreApply.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\models\system;
  3. use app\admin\model\system\SystemAdmin;
  4. use app\models\user\User;
  5. use crmeb\traits\ModelTrait;
  6. use crmeb\basic\BaseModel;
  7. /**
  8. * 门店自提 model
  9. * Class SystemStore
  10. * @package app\model\system
  11. */
  12. class SystemStoreApply 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_apply';
  25. /**
  26. * 获取门店列表
  27. * @param $where
  28. * @return array
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. */
  33. public static function getList($where)
  34. {
  35. $model = new self();
  36. if (isset($where['name']) && $where['name'] != '') {
  37. $model = $model->where('id|name|introduction', 'like', '%' . $where['name'] . '%');
  38. }
  39. if (isset($where['type']) && $where['type'] != '' && ($data = self::setData($where['type']))) {
  40. $model = $model->where($data);
  41. }
  42. $count = $model->count();
  43. $data = $model->page((int)$where['page'], (int)$where['limit'])->select();
  44. foreach ($data as &$v) {
  45. $v['user'] = User::where('uid', $v['uid'])->value('nickname') . '/' . $v['uid'];
  46. }
  47. return compact('count', 'data');
  48. }
  49. /**
  50. * 获取连表查询条件
  51. * @param $type
  52. * @return array
  53. */
  54. public static function setData($type)
  55. {
  56. switch ((int)$type) {
  57. case 1:
  58. $data = ['status' => 1];
  59. break;
  60. case 2:
  61. $data = ['status' => 0];
  62. break;
  63. case 3:
  64. $data = ['status' => 2];
  65. break;
  66. };
  67. return isset($data) ? $data : [];
  68. }
  69. }