配置修改
This commit is contained in:
@ -35,18 +35,29 @@ class Shop extends Api
|
|||||||
{
|
{
|
||||||
if($this->request->isGet()) {
|
if($this->request->isGet()) {
|
||||||
$shopId = $this->request->get('shop_id', '', 'trim');
|
$shopId = $this->request->get('shop_id', '', 'trim');
|
||||||
$city_id = $this->request->get('city_id', 0);
|
|
||||||
$validate = Validate::rule('shop_id', 'require|integer|gt:0');
|
$validate = Validate::rule('shop_id', 'require|integer|gt:0');
|
||||||
if(!$validate->check(['shop_id'=>$shopId])) {
|
if(!$validate->check(['shop_id'=>$shopId])) {
|
||||||
return JsonServer::error($validate->getError());
|
return JsonServer::error($validate->getError());
|
||||||
}
|
}
|
||||||
$data = ShopLogic::getShopInfo($city_id,$shopId, $this->user_id, input());
|
$data = ShopLogic::getShopInfo($shopId, $this->user_id, input());
|
||||||
|
return JsonServer::success('获取店铺信息成功', $data);
|
||||||
|
}else{
|
||||||
|
return JsonServer::error('请求类型错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 店铺列表信息
|
||||||
|
*/
|
||||||
|
public function getShopCityInfo()
|
||||||
|
{
|
||||||
|
if($this->request->isGet()) {
|
||||||
|
$city_id = $this->request->get('city_id', 0);
|
||||||
|
$data = ShopLogic::getShopCityInfo($city_id, $this->user_id, input());
|
||||||
return JsonServer::success('获取店铺信息成功', $data);
|
return JsonServer::success('获取店铺信息成功', $data);
|
||||||
}else{
|
}else{
|
||||||
return JsonServer::error('请求类型错误');
|
return JsonServer::error('请求类型错误');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺列表
|
* 店铺列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -120,6 +120,95 @@ class ShopLogic extends Logic
|
|||||||
return $shop;
|
return $shop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getShopCityInfo($city_id,$userId, $params = [])
|
||||||
|
{
|
||||||
|
// 记录统计信息(访问商铺用户量)
|
||||||
|
Event::listen('ShopStat', 'app\common\listener\ShopStat');
|
||||||
|
|
||||||
|
$shop_msg = Shop::where("city_id",$city_id)
|
||||||
|
->where("is_run",1)
|
||||||
|
->where("is_freeze",0)
|
||||||
|
->where("del",0)
|
||||||
|
->find();
|
||||||
|
$c = "";
|
||||||
|
if($shop_msg == null){
|
||||||
|
$c = "id = 1";
|
||||||
|
}else{
|
||||||
|
$c = "city_id = ".$city_id."";
|
||||||
|
}
|
||||||
|
|
||||||
|
$field = [
|
||||||
|
'id', 'create_time', 'name', 'logo', 'background',
|
||||||
|
'type', 'score', 'star', 'intro',
|
||||||
|
'visited_num', 'cover', 'banner', 'is_freeze',
|
||||||
|
'is_run', 'expire_time',
|
||||||
|
'province_id', 'city_id', 'district_id', 'address',
|
||||||
|
'run_start_time', 'run_end_time', 'weekdays',
|
||||||
|
];
|
||||||
|
$shop = Shop::field($field)
|
||||||
|
->where($c)
|
||||||
|
->append([ 'type_desc', 'is_expire' ])
|
||||||
|
->find();
|
||||||
|
//
|
||||||
|
$shop['logo'] = UrlServer::getFileUrl($shop['logo'] ? : ShopEnum::DEFAULT_LOGO);
|
||||||
|
$shop['background'] = UrlServer::getFileUrl($shop['background'] ? : ShopEnum::DEFAULT_BG);
|
||||||
|
$shop['cover'] = UrlServer::getFileUrl($shop['cover'] ? :ShopEnum::DEFAULT_COVER);
|
||||||
|
$shop['banner'] = UrlServer::getFileUrl($shop['banner'] ? : ShopEnum::DEFAULT_BANNER);
|
||||||
|
$shop['run_start_time'] = $shop['run_start_time'] ? date('H:i:s', $shop['run_start_time']) : '';
|
||||||
|
$shop['run_end_time'] = $shop['run_end_time'] ? date('H:i:s', $shop['run_end_time']) : '';
|
||||||
|
$shop['province'] = DevRegion::getAreaName($shop['province_id']);
|
||||||
|
$shop['city'] = DevRegion::getAreaName($shop['city_id']);
|
||||||
|
$shop['district'] = DevRegion::getAreaName($shop['district_id']);
|
||||||
|
|
||||||
|
$shop['qr_code'] = (new QrCodeLogic)->shopQrCode($shop['id'], $params['terminal'] ?? '');
|
||||||
|
|
||||||
|
// 在售商品
|
||||||
|
// 销售中商品:未删除/审核通过/已上架
|
||||||
|
$onSaleWhere = [
|
||||||
|
['del', '=', GoodsEnum::DEL_NORMAL], // 未删除
|
||||||
|
['status', '=', GoodsEnum::STATUS_SHELVES], // 上架中
|
||||||
|
['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK], // 审核通过
|
||||||
|
];
|
||||||
|
$shop['on_sale_count'] = Goods::where($onSaleWhere)->where('shop_id', $shopId)->count();
|
||||||
|
|
||||||
|
// 店铺推荐商品
|
||||||
|
$shop['goods_list'] = Goods::field('id,image,name,min_price,market_price')
|
||||||
|
->where($onSaleWhere)
|
||||||
|
->where([
|
||||||
|
'shop_id' => $shop['id'],
|
||||||
|
'is_recommend' => 1, // 推荐商品
|
||||||
|
])
|
||||||
|
->limit(9)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
// 用户是否关注店铺
|
||||||
|
$shop['shop_follow_status'] = 0;
|
||||||
|
if($userId) { // 用户已登录
|
||||||
|
$shopFollow = ShopFollow::where(['user_id'=>$userId, 'shop_id'=>$shopId])->findOrEmpty();
|
||||||
|
if(!$shopFollow->isEmpty()) {
|
||||||
|
$shop['shop_follow_status'] = $shopFollow['status'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$shop['follow_num'] = ShopFollow::where(['shop_id' => $shopId,'status' => 1])->count('id');
|
||||||
|
$image = ConfigServer::get('shop_customer_service', 'image', '', $shopId);
|
||||||
|
$shop['customer_image'] = $image ? UrlServer::getFileUrl($image) : '';
|
||||||
|
$shop['customer_wechat'] = ConfigServer::get('shop_customer_service', 'wechat', '', $shopId);
|
||||||
|
$shop['customer_phone'] = ConfigServer::get('shop_customer_service', 'phone', '', $shopId);
|
||||||
|
|
||||||
|
// 店铺广告
|
||||||
|
$adWhere = [
|
||||||
|
[ 'shop_id', '=', $shopId ],
|
||||||
|
[ 'status', '=', 1 ],
|
||||||
|
];
|
||||||
|
$shop['ad'] = [
|
||||||
|
'pc' => ShopAd::where($adWhere)->where('terminal', ShopAdEnum::TERMINAL_PC)->append([ 'link_path', 'link_query' ])->order('sort desc,id desc')->select()->toArray(),
|
||||||
|
'mobile' => ShopAd::where($adWhere)->where('terminal', ShopAdEnum::TERMINAL_MOBILE)->append([ 'link_path', 'link_query' ])->order('sort desc,id desc')->select()->toArray(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $shop;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺列表
|
* 店铺列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user