SystemStore.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\model\system;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * 门店自提 model
  7. * Class SystemStore
  8. * @package app\admin\model\system
  9. */
  10. class SystemStore extends BaseModel
  11. {
  12. use ModelTrait;
  13. /**
  14. * 数据表主键
  15. * @var string
  16. */
  17. protected $pk = 'id';
  18. /**
  19. * 模型名称
  20. * @var string
  21. */
  22. protected $name = 'system_store';
  23. public static function getLatlngAttr($value,$data)
  24. {
  25. return $data['latitude'].','.$data['longitude'];
  26. }
  27. public static function verificWhere()
  28. {
  29. return self::where('is_show',1)->where('is_del',0);
  30. }
  31. /*
  32. * 获取门店信息
  33. * @param int $id
  34. * */
  35. public static function getStoreDispose($id = 0)
  36. {
  37. if($id)
  38. $storeInfo = self::verificWhere()->where('id',$id)->find();
  39. else
  40. $storeInfo = self::verificWhere()->find();
  41. if($storeInfo) {
  42. $storeInfo['latlng'] = self::getLatlngAttr(null, $storeInfo);
  43. $storeInfo['valid_time'] = $storeInfo['valid_time'] ? explode(' - ', $storeInfo['valid_time']) : [];
  44. $storeInfo['day_time'] = $storeInfo['day_time'] ? explode(' - ', $storeInfo['day_time']) : [];
  45. $storeInfo['address'] = $storeInfo['address'] ? explode(',', $storeInfo['address']) : [];
  46. }else{
  47. $storeInfo['latlng'] =[];
  48. $storeInfo['valid_time']=[];
  49. $storeInfo['valid_time']=[];
  50. $storeInfo['day_time']=[];
  51. $storeInfo['address']=[];
  52. $storeInfo['id']=0;
  53. }
  54. return $storeInfo;
  55. }
  56. }