SystemStore.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\models\system;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * 门店自提 model
  7. * Class SystemStore
  8. * @package app\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,$felid='')
  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['_valid_time'] = str_replace('-','/',$storeInfo['valid_time'][0].' ~ '.$storeInfo['valid_time'][1]);
  45. $storeInfo['day_time'] = $storeInfo['day_time'] ? str_replace(' - ',' ~ ',$storeInfo['day_time']) : [];
  46. $storeInfo['_detailed_address'] = $storeInfo['address'].' '.$storeInfo['detailed_address'];
  47. $storeInfo['address'] = $storeInfo['address'] ? explode(',', $storeInfo['address']) : [];
  48. if($felid) return $storeInfo[$felid] ?? '';
  49. }
  50. return $storeInfo;
  51. }
  52. }