门店停车场

pull/1/head
limu 11 months ago
parent 220b1b4c36
commit e1834dc8a2
  1. 8
      app/api/service/Goods.php
  2. 71
      app/common/model/store/ShopParking.php
  3. 19
      app/store/controller/Shop.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;
}

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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();
}
}

@ -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() ?: '失败');
}
}

Loading…
Cancel
Save