SystemStoreApply.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. public static function getLatlngAttr($value, $data)
  26. {
  27. return $data['latitude'] . ',' . $data['longitude'];
  28. }
  29. /**
  30. * 获取门店列表
  31. * @param $where
  32. * @return array
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. */
  37. public static function getList($where)
  38. {
  39. $model = new self();
  40. if (isset($where['name']) && $where['name'] != '') {
  41. $model = $model->where('id|name|introduction', 'like', '%' . $where['name'] . '%');
  42. }
  43. if (isset($where['type']) && $where['type'] != '' && ($data = self::setData($where['type']))) {
  44. $model = $model->where($data);
  45. }
  46. $count = $model->count();
  47. $data = $model->page((int)$where['page'], (int)$where['limit'])->select();
  48. foreach ($data as &$v) {
  49. $v['user'] = User::where('uid', $v['uid'])->value('nickname') . '/' . $v['uid'];
  50. }
  51. return compact('count', 'data');
  52. }
  53. /**
  54. * 获取连表查询条件
  55. * @param $type
  56. * @return array
  57. */
  58. public static function setData($type)
  59. {
  60. switch ((int)$type) {
  61. case 1:
  62. $data = ['status' => 0];
  63. break;
  64. case 2:
  65. $data = ['status' => 1];
  66. break;
  67. case 3:
  68. $data = ['status' => 2];
  69. break;
  70. };
  71. return isset($data) ? $data : [];
  72. }
  73. }