From e1834dc8a2decfecce6c2cc408af935aa1101fd5 Mon Sep 17 00:00:00 2001 From: limu Date: Sun, 18 Feb 2024 13:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=81=9C=E8=BD=A6=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/service/Goods.php | 8 +++ app/common/model/store/ShopParking.php | 71 ++++++++++++++++++++++++++ app/store/controller/Shop.php | 19 +++++++ 3 files changed, 98 insertions(+) create mode 100644 app/common/model/store/ShopParking.php diff --git a/app/api/service/Goods.php b/app/api/service/Goods.php index 0eca5075..5e0d104a 100644 --- a/app/api/service/Goods.php +++ b/app/api/service/Goods.php @@ -25,6 +25,7 @@ use app\api\model\sharp\Active as SharpActiveModel; use app\api\model\sharp\ActiveTime as ActiveTimeModel; use app\api\controller\sharp\Goods as miaosha; use app\store\model\goods\GoodsPrice as GoodsPriceModel; +use app\common\model\store\ShopParking as ParkingModel; /** * 商品服务类 @@ -227,6 +228,13 @@ class Goods extends GoodsService 'https://www.saas.njrenzhou.com/uploads/10001/20240116/18adc22ad9ea021ab2586878fe1035b0.png' ]; + //读取门店停车场 + $parkingModel = new ParkingModel(); + $parkingInfo = $parkingModel::where(['shop_id' => $info['shop_id']])->find(); + $info['parking_name'] = $parkingInfo->parking_name ?? ''; + $info['parking_desc'] = $parkingInfo->desc ?? ''; + $info['parking_longitude'] = $parkingInfo->longitude ?? ''; + $info['parking_latitude'] = $parkingInfo->latitude ?? ''; return $info; } diff --git a/app/common/model/store/ShopParking.php b/app/common/model/store/ShopParking.php new file mode 100644 index 00000000..b605c91e --- /dev/null +++ b/app/common/model/store/ShopParking.php @@ -0,0 +1,71 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\common\model\store; + +use cores\BaseModel; +use app\common\model\Region as RegionModel; +use think\model\relation\HasOne; + +/** + * 商家门店模型 + * Class Shop + * @package app\common\model\store + */ +class ShopParking extends BaseModel +{ + // 定义表名 + protected $name = 'store_parking'; + + // 定义主键 + protected $pk = 'id'; + + + /** + * 获取器:坐标经纬度 + * @param $value + * @param $data + * @return string + */ + public function getCoordinateAttr($value, $data): string + { + return "{$data['latitude']},{$data['longitude']}"; + } + + + /** + * 门店详情 + * @param int $shopId 门店ID + * @param array $with 关联查询 + * @return static|array|null + */ + public static function detail(int $id) + { + return self::where(['shop_id' => $id])->find(); + } + + public function edit($data) + { + if (!empty($data['id'])) { + $info = self::where(['id' => $data['id']])->find(); + } else { + $info = new self(); + } + $info->parking_name = $data['name']; + $info->longitude = $data['longitude']; + $info->latitude = $data['latitude']; + $info->shop_id = $data['shop_id']; + $info->desc = $data['desc'] ?? ''; + $info->store_id = self::$storeId; + return $info->save(); + } +} diff --git a/app/store/controller/Shop.php b/app/store/controller/Shop.php index 3d033386..44cae0c8 100644 --- a/app/store/controller/Shop.php +++ b/app/store/controller/Shop.php @@ -14,6 +14,7 @@ namespace app\store\controller; use think\response\Json; use app\store\model\store\Shop as ShopModel; +use app\common\model\store\ShopParking as ParkingModel; /** * 门店管理 @@ -106,4 +107,22 @@ class Shop extends Controller } return $this->renderSuccess('删除成功'); } + + //获取门店停车场 + public function getParking(int $id): Json + { + // 获取门店详情 + $detail = ParkingModel::detail($id); + return $this->renderSuccess(compact('detail')); + } + + //添加,编辑门店停车场 + public function editParking(){ + + $model = new ParkingModel(); + if ($model->edit($this->request->param())) { + return $this->renderSuccess('成功'); + } + return $this->renderError($model->getError() ?: '失败'); + } }