You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/controller/Shop.php

118 lines
4.1 KiB

11 months ago
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\controller;
use app\api\model\store\Shop as ShopModel;
10 months ago
use think\response\Json;
11 months ago
/**
* 门店列表
* Class Shop
* @package app\api\controller
*/
class Shop extends Controller
{
/**
* 门店列表
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function list(): Json
{
$model = new ShopModel;
$list = $model->getList($this->request->param());
return $this->renderSuccess(compact('list'));
}
/**
* 门店详情
* @param int $shopId
* @return Json
*/
public function detail(int $shopId): Json
{
$detail = ShopModel::detail($shopId, ['logoImage']);
return $this->renderSuccess(compact('detail'));
}
10 months ago
public function stopTimes(): Json
{
$data = [];
$shopId = intval($this->request->post('shop_id'));
if (!$shopId) {
return $this->renderError('缺少必要参数');
}
$detail = ShopModel::detail($shopId);
if (!empty($detail['shop_hours'])) {
8 months ago
$shop_hours = explode('-', $detail['shop_hours'] ?? "00:00");
10 months ago
if (count($shop_hours) == 2) {
$array = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
for ($i = 0; $i < 3; $i++) {
$start_time = date('Y-m-d', strtotime('+' . $i . ' day', time())) . ' ' . $shop_hours[0];
$end_time = date('Y-m-d', strtotime('+' . $i . ' day', time())) . ' ' . $shop_hours[1];
$timeOne = strtotime($start_time);
$timeTwo = strtotime($end_time);
$times = [];
while ($timeOne < $timeTwo) {
$status = 0;
if ($timeOne > time()) {
$status = 1;
}
$times[] = [
9 months ago
'value' => date('H:i', (int)$timeOne),
10 months ago
'status' => $status,
9 months ago
'time' => date('Y-m-d H:i:s', (int)$timeOne)
10 months ago
];
$timeOne = $timeOne + 30 * 60;
}
$data[] = [
'name' => $array[date("w", strtotime($start_time))],
10 months ago
'date' => date('m-d', strtotime($start_time)),
10 months ago
'list' => $times,
];
}
}
}
return $this->renderSuccess($data);
}
9 months ago
public function editShop(int $shopId): Json
{
$param = $this->request->param();
$upData = [
8 months ago
'shop_name' => $param['shop_name'] ?? "",
'address' => $param['address'] ?? "",
'phone' => $param['phone'] ?? "",
'wechat_img_id' => $param['wechat_img_id'] ?? "",
9 months ago
];
8 months ago
ShopModel::where('shop_id', $param['shop_id'])->update($upData);
9 months ago
return $this->renderSuccess('ok');
}
8 months ago
public function getShopInfo()
{
9 months ago
$banner_imgs = [];
$share_imgs = [];
$activity_imgs = [];
$data = [
'banner_imgs' => $banner_imgs,
'share_imgs' => $share_imgs,
'activity_imgs' => $activity_imgs,
];
return $this->renderSuccess('ok');
}
11 months ago
}