作者 Cool
1 个管道 的构建 通过 耗费 0 秒

店铺接口调试

... ... @@ -4,8 +4,11 @@
namespace app\api\controller;
use addons\litestore\model\Litestoreorder;
use app\api\model\Industry;
use app\api\model\LitestoreBanner;
use app\api\model\LitestoreGoodsSpec;
use app\api\model\Report;
use app\api\model\StoreApply;
use app\api\model\UserSearch;
use app\common\controller\Api;
use EasyWeChat\Foundation\Application;
... ... @@ -24,6 +27,7 @@ class Store extends Api
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
protected $store_model;
protected $industry_model;
protected $goods_model;
protected $banner_model;
protected $spec_model;
... ... @@ -34,10 +38,11 @@ class Store extends Api
protected $follow_model;
protected $user_id;
public function __construct(Request $request, LitestoreBanner $banner, \app\api\model\LitestoreGoods $goods,LitestoreGoodsSpec $spec,UserSearch $search,\app\api\model\Store $store)
public function __construct(Request $request, LitestoreBanner $banner, \app\api\model\LitestoreGoods $goods,LitestoreGoodsSpec $spec,UserSearch $search,\app\api\model\Store $store,Industry $industry)
{
parent::__construct($request);
$this->banner_model = $banner;
$this->industry_model = $industry;
$this->goods_model = $goods;
$this->spec_model = $spec;
$this->search_model = $search;
... ... @@ -46,17 +51,60 @@ class Store extends Api
}
/**
* 行业列表
* @ApiWeigh (80)
*
* @ApiTitle (行业列表)
* @ApiSummary (行业列表)
* @ApiMethod (POST)
* @ApiRoute (/api/store/industry)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="keyword", type="string", required=true, description="关键词")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"list": [
{
"id": 1,
"name": "行业名称",
"weigh": 0,
}
]
}
})
*/
public function industry()
{
if($this->request->isPost()){
$keyword = $this->request->param('keyword','');
$where = [
'where' => []
];
if($keyword) {
$where['where'] = ['name'=>['like','%'.$keyword.'%']];
}
$indus = $this->industry_model->selectOrFail($where,false,'*','weigh');
$return = [
'list' => $indus,
];
$this->success('请求成功',$return);
}
}
/**
* 店铺申请
* @ApiWeigh (3)
* @ApiWeigh (77)
*
* @ApiTitle (店铺申请)
* @ApiSummary (店铺申请)
* @ApiMethod (POST)
* @ApiRoute (/api/store/store_add)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_name", type="integer", required=true, description="店铺名称")
* @ApiParams (name="store_name", type="string", required=true, description="店铺名称")
* @ApiParams (name="house_ids", type="string", sample="店铺1id,店铺2id", required=true, description="入驻社区")
* @ApiParams (name="job", type="string", sample="[{'name':'职位名称1','number':'招聘人数1'},{'name':'职位名称2','number':'招聘人数2'}]", required=true, description="招聘职位")
* @ApiParams (name="industry_id", type="string", required=true, description="行业/关键词id")
* @ApiParams (name="name", type="string", required=true, description="联系人姓名")
* @ApiParams (name="mobile", type="string", required=true, description="联系人手机号")
... ... @@ -119,4 +167,91 @@ class Store extends Api
}
$this->success('申请提交成功',['id'=>$id,'status'=>$param['status'],'pay_data'=>$pay_data]);
}
/**
* 开通社区提交
* @ApiWeigh (74)
*
* @ApiTitle (开通社区提交)
* @ApiSummary (开通社区提交)
* @ApiMethod (POST)
* @ApiRoute (/api/store/store_apply)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_name", type="string", required=true, description="店铺名称")
* @ApiParams (name="province", type="string", required=true, description="省")
* @ApiParams (name="city", type="string", required=true, description="市")
* @ApiParams (name="region", type="string", required=true, description="区")
* @ApiParams (name="name", type="string", required=true, description="联系人姓名")
* @ApiParams (name="mobile", type="string", required=true, description="联系人手机号")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function store_apply()
{
// $param = (new RecruitValidate())->goCheck('add');
Db::startTrans();
$result = false;
try{
$param['user_id'] = $this->auth->id;
$model = new StoreApply();
$result = $model->add($param);
$id = $model->id;
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(!$result) {
$this->error('提交失败');
}
$this->success('提交成功');
}
/**
* 举报建议提交
* @ApiWeigh (70)
*
* @ApiTitle (举报建议提交)
* @ApiSummary (举报建议提交)
* @ApiMethod (POST)
* @ApiRoute (/api/store/store_report)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="content", type="string", required=true, description="建议内容")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function store_report()
{
// $param = (new RecruitValidate())->goCheck('add');
Db::startTrans();
$result = false;
try{
$param['user_id'] = $this->auth->id;
$model = new Report();
$result = $model->add($param);
$id = $model->id;
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(!$result) {
$this->error('提交失败');
}
$this->success('提交成功');
}
}
\ No newline at end of file
... ...
<?php
namespace app\api\model;
class Industry extends Base
{
}
\ No newline at end of file
... ...
<?php
namespace app\api\model;
class Report extends Base
{
}
\ No newline at end of file
... ...
<?php
namespace app\api\model;
class StoreApply extends Base
{
}
\ No newline at end of file
... ...
此 diff 太大无法显示。