SystemStore.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\system\store;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * 门店列表
  17. * Class SystemStore
  18. * @package app\model\system\store
  19. */
  20. class SystemStore extends BaseModel
  21. {
  22. use ModelTrait;
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'system_store';
  33. /**
  34. * 经纬度获取器
  35. * @param $value
  36. * @param $data
  37. * @return string
  38. */
  39. public static function getLatlngAttr($value, $data)
  40. {
  41. return $data['latitude'] . ',' . $data['longitude'];
  42. }
  43. /**
  44. * 店铺类型搜索器
  45. * @param Model $query
  46. * @param $value
  47. */
  48. public function searchTypeAttr($query, $value)
  49. {
  50. switch ((int)$value) {
  51. case 1:
  52. $query->where(['is_del' => 0, 'is_show' => 0]);
  53. break;
  54. case 0:
  55. $query->where(['is_del' => 0, 'is_show' => 1]);
  56. break;
  57. default:
  58. $query->where('is_del', 1);
  59. break;
  60. }
  61. }
  62. /**
  63. * 手机号,id,昵称搜索器
  64. * @param Model $query
  65. * @param $value
  66. */
  67. public function searchKeywordsAttr($query, $value)
  68. {
  69. if ($value) {
  70. $query->where('id|name|introduction|phone', 'LIKE', "%$value%");
  71. }
  72. }
  73. }