汪总电商平台
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.

115 lines
3.4 KiB

3 months ago
<?php
namespace app\api\controller\wanlshop;
use app\common\controller\Api;
2 months ago
use app\admin\model\wanlshop\Auth;
3 months ago
use fast\Tree;
/**
* WanlShop店铺接口
*/
class Shop extends Api
{
protected $noNeedLogin = ['getShopInfo'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
$this->model = model('app\api\model\wanlshop\Shop');
}
/**
* 一次性获取店铺相关数据 1.0.8升级
*
* @ApiSummary (WanlShop 一次性获取店铺相关数据)
* @ApiMethod (GET)
*
* @param string $id 页面ID
*/
public function getShopInfo($id = null)
{
//设置过滤方法
$this->request->filter(['strip_tags']);
// 获取店铺信息
$row = $this->model->get($id);
if (!$row) {
$this->error(__('未找到此商家'));
}
// 获取商家类目
$tree = Tree::instance();
$tree->init(
model('app\api\model\wanlshop\ShopSort')
->where(['shop_id' => $row['id']])
->field('id, pid, name, image')
->order('weigh asc')
->select()
);
$row['category'] = $tree->getTreeArray(0);
// 查看是否被关注
$row['isFollow'] = model('app\api\model\wanlshop\find\Follow')
->where([
'user_no' => $row['find_user']['user_no'],
'user_id' => $this->auth->id
])
->count();
$row['isLive'] = model('app\api\model\wanlshop\Live')
->where(['shop_id' => $row['id'], 'state' => 1])
->field('id')
->find();
// 获取类目样式配置
$shopConfig = model('app\api\model\wanlshop\ShopConfig')
->where(['shop_id' => $row['id']])
->find();
$row['categoryStyle'] = (int)$shopConfig['category_style'];
// 获取商家自定义页面
$row['page'] = model('app\api\model\wanlshop\Page')
->where([
'shop_id' => $row['id'],
'type' => 'shop'
])
->field('id, name, page, item')
->find();
$this->success('返回成功', $row);
}
2 months ago
//供应商入驻
public function gongyingshangruzhu(){
if($this->request->isPost()){
$uid =$this->auth->id;
$data = $this->request->post();
$insert['state'] = $data['state'];
$insert['name'] = $data['name'];
$insert['number'] = $data['number'];
$insert['mobile'] = $this->auth->mobile;
$insert['image'] = $data['image'];
$insert['user_id'] = $uid;
//供应商店铺名称
$insert['shopname'] = $data['name'];
//店铺头像
$insert['avatar'] = $data['avatar'];
//店铺简介
$insert['bio'] = $data['bio'];
$insert['content'] = $data['bio'];
//省市
$insert['city'] = $data['city'];
$insert['verify'] = 2;
if(empty($data['id'])){
if(!Auth::insert($insert)) $this->error("申请提交失败");
$this->success("申请已提交等待管理员审核");
}else{
$insert['id'] = $data['id'];
if(!Auth::update($insert)) $this->error("重新提交失败");
$this->success("申请已重新提交,待管理员审核");
}
}
}
public function getgongyingshanginfo(){
if($this->request->isPost()){
$uid =$this->auth->id;
$info=Auth::field("id,state,name,number,image,avatar,bio,city,refuse,user_id")->where("user_id",$uid)->find();
return $this->success("获取成功",$info);
}
}
3 months ago
}