<?php
|
|
namespace app\api\controller\store;
|
|
use app\api\controller\Controller;
|
use app\api\model\user\Favorite as FavoriteModel;
|
use app\common\library\easywechat\AppMp;
|
use app\api\model\store\Store as StoreModel;
|
use app\api\model\supplier\Supplier as SupplierModel;
|
use app\api\model\page\Ad as AdModel;
|
/**
|
* 门店列表
|
*/
|
class Store extends Controller
|
{
|
/**
|
* 门店列表
|
*/
|
public function lists($longitude = '', $latitude = '', $url = '', $shop_supplier_id = 0, $is_check = true)
|
{
|
$model = new StoreModel;
|
$list = $model->getList($is_check, $longitude, $latitude, false, $shop_supplier_id);
|
$signPackage = '';
|
if($url != ''){
|
$app = AppMp::getApp($this->app_id);
|
$app->jssdk->setUrl($url);
|
$signPackage = $app->jssdk->buildConfig(array('getLocation', 'openLocation'), false);
|
}
|
return $this->renderSuccess('', compact('list', 'signPackage'));
|
}
|
|
/**
|
* 门店详情
|
*/
|
public function detail($store_id)
|
{
|
$detail = StoreModel::detail($store_id);
|
//获取商户营业时间
|
if(!empty($detail)){
|
$supplier = SupplierModel::detail($detail["shop_supplier_id"]);
|
if(!empty($supplier)){
|
$detail["shop_hours"] = $supplier["business_start_time"]."至".$supplier["business_end_time"];
|
}
|
}
|
//banner图
|
$AdModel = new AdModel;
|
$adList = $AdModel->getIndex(['shop_supplier_id' => $detail['shop_supplier_id'], 'status' => 1], 5);
|
$is_collect = 0;
|
// 用户信息
|
$user = $this->getUser(false);
|
if ($user) {
|
if (FavoriteModel::detail($detail['shop_supplier_id'], 10, $user['user_id'])) {
|
$is_collect= 1;
|
}
|
}
|
return $this->renderSuccess('', compact('detail','adList','is_collect'));
|
}
|
|
/**
|
* 门店列表(分页)
|
*/
|
public function storelist()
|
{
|
$model = new StoreModel;
|
$list = $model->storeList($this->postData());
|
return $this->renderSuccess('', compact('list'));
|
}
|
/**
|
* 虚拟商品可核销门店列表
|
*/
|
public function verifyLists($storeIds, $longitude = '', $latitude = '')
|
{
|
$storeIds = json_decode(htmlspecialchars_decode($storeIds), true);
|
if (is_array($storeIds)) {
|
$storeIds = implode(',', $storeIds);
|
}
|
$model = new StoreModel;
|
$list = $storeIds ? $model->getListByStoreIds($storeIds, $longitude, $latitude) : $model->getList(true, $longitude, $latitude);
|
return $this->renderSuccess('', compact('list'));
|
}
|
}
|