...
|
...
|
@@ -9,7 +9,10 @@ use app\api\model\Industry; |
|
|
use app\api\model\StoreComment;
|
|
|
use app\api\model\StoreInform;
|
|
|
use app\api\model\StoreInformGood;
|
|
|
use app\api\model\StoreInformLog;
|
|
|
use app\api\model\StoreInformView;
|
|
|
use app\api\model\UserHouse;
|
|
|
use app\api\model\UserMoneyLog;
|
|
|
use app\api\validate\HotValidate;
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
...
|
...
|
@@ -32,7 +35,6 @@ class Hot extends Api |
|
|
protected $favorite_model;
|
|
|
protected $comment_model;
|
|
|
protected $good_model;
|
|
|
protected $follow_model;
|
|
|
protected $user_id;
|
|
|
|
|
|
public function __construct(Request $request,\app\api\model\Store $store,Industry $industry,StoreInform $store_inform,UserHouse $user_house,StoreInformGood $store_inform_good)
|
...
|
...
|
@@ -55,6 +57,7 @@ class Hot extends Api |
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/hot/store_list)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="store_id", type="integer", required=false, description="店铺id")
|
|
|
* @ApiParams (name="page", type="integer", required=true, description="页数")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
...
|
...
|
@@ -100,8 +103,12 @@ class Hot extends Api |
|
|
{
|
|
|
if($this->request->isPost()){
|
|
|
$page = $this->request->param('page',1,'intval');
|
|
|
$this->store_id = $this->request->param('store_id',0,'intval');
|
|
|
$house_ids = $this->user_house_model->where('user_id',$this->user_id)->column('house_id');
|
|
|
$query = function ($query) use ($house_ids){
|
|
|
if($this->store_id) {
|
|
|
$query->where('store_id',$this->store_id);
|
|
|
}
|
|
|
foreach ($house_ids as $k=>$v){
|
|
|
$w = ['house_ids'=>['like','%,'.$v.',%']];
|
|
|
if($k == 0) {
|
...
|
...
|
@@ -118,6 +125,7 @@ class Hot extends Api |
|
|
$order = ['number'=>'DESC','createtime'=>'DESC'];
|
|
|
$inform = $this->store_inform_model->pageSelect($page,$where,'*',$order,config('option.num'));
|
|
|
$list = $inform->items();
|
|
|
$view_model = new StoreInformView();
|
|
|
foreach ($list as &$v) {
|
|
|
// 获取点赞数及是否点赞
|
|
|
$where_g = [
|
...
|
...
|
@@ -126,6 +134,24 @@ class Hot extends Api |
|
|
$v['good_count'] = $this->store_inform_good_model->getCount($where_g);
|
|
|
$where_g['user_id'] = $this->user_id;
|
|
|
$v['is_good'] = $this->store_inform_good_model->getCount($where_g);
|
|
|
// 记录浏览量
|
|
|
$where_v = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'object_id' => $v['id']
|
|
|
];
|
|
|
$view = $view_model->where($where_v)->find();
|
|
|
if($view) {
|
|
|
$where_v = [
|
|
|
'id' => $view['id']
|
|
|
];
|
|
|
$view_model->where($where_v)->setInc('count');
|
|
|
} else {
|
|
|
$insert = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'object_id' => $v['id']
|
|
|
];
|
|
|
$view_model->add($insert);
|
|
|
}
|
|
|
}
|
|
|
$return = [
|
|
|
'list' => $list,
|
...
|
...
|
@@ -137,6 +163,185 @@ class Hot extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 商圈店铺主页
|
|
|
* @ApiWeigh (75)
|
|
|
*
|
|
|
* @ApiTitle (商圈店铺主页)
|
|
|
* @ApiSummary (商圈店铺主页)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/hot/store_detail)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="store_id", type="integer", required=true, description="店铺id")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
"store": {
|
|
|
"id": 1,
|
|
|
"user_id": 1,
|
|
|
"store_name": "店铺名称",
|
|
|
"industry_id": "行业标签",
|
|
|
"name": "测试11",
|
|
|
"mobile": "联系电话",
|
|
|
"store_icon": "图标",
|
|
|
"province": "地址省",
|
|
|
"city": "市",
|
|
|
"region": "区",
|
|
|
"images": "/assets/img/qrcode.png,/assets/img/qrcode.png",
|
|
|
"content": "店铺详情",
|
|
|
"image_arr"店铺轮播: [
|
|
|
"http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png",
|
|
|
"http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png"
|
|
|
]
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function store_detail()
|
|
|
{
|
|
|
if($this->request->isPost()){
|
|
|
$store_id = $this->request->param('store_id',0,'intval');
|
|
|
$where = [
|
|
|
'where' => ['id'=>$store_id]
|
|
|
];
|
|
|
$store = $this->store_model->findOrFail($where);
|
|
|
$return = [
|
|
|
'store' => $store
|
|
|
];
|
|
|
$this->success('请求成功',$return);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 领取红包
|
|
|
* @ApiWeigh (60)
|
|
|
*
|
|
|
* @ApiTitle (领取红包)
|
|
|
* @ApiSummary (领取红包)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/hot/get_red_package)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="store_inform_id", type="integer", required=true, description="商家信息id")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function get_red_package()
|
|
|
{
|
|
|
if($this->request->isPost()){
|
|
|
$param = (new HotValidate())->goCheck('get_red_package');
|
|
|
$where = [
|
|
|
'where' => ['id'=>$param['store_inform_id']]
|
|
|
];
|
|
|
$inform = $this->store_inform_model->findOrFail($where);
|
|
|
if($inform['surplus'] == 0) {
|
|
|
$this->error('红包已抢完');
|
|
|
}
|
|
|
$log_model = new StoreInformLog();
|
|
|
$user_model = new \app\api\model\User();
|
|
|
$money_log_model = new UserMoneyLog();
|
|
|
$where_l = [
|
|
|
'where' => [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'inform_id' => $inform['id'],
|
|
|
]
|
|
|
];
|
|
|
$log = $log_model->findOrFail($where_l,false);
|
|
|
if($log) {
|
|
|
$this->error('已领取过该商圈红包');
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
// 录入领取记录
|
|
|
$log_data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'inform_id' => $inform['id'],
|
|
|
'money' => $inform['single']
|
|
|
];
|
|
|
$res_log = $log_model->add($log_data);
|
|
|
// 新增用户余额
|
|
|
$res_user = $user_model->where('id',$this->auth->id)->setInc('money',$inform['single']);
|
|
|
// 新增余额记录
|
|
|
$money_log_data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'money' => $inform['single'],
|
|
|
'before' => $this->auth->money,
|
|
|
'after' => bcadd($this->auth->money,$inform['single'],2),
|
|
|
'memo' => '领取红包'
|
|
|
];
|
|
|
$res_moeny_log = $money_log_model->add($money_log_data);
|
|
|
if(!$res_log || !$res_user || !$res_moeny_log) {
|
|
|
Db::rollback();
|
|
|
$this->error('红包领取失败');
|
|
|
}
|
|
|
Db::commit();
|
|
|
$this->success('领取成功');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 留言列表
|
|
|
* @ApiWeigh (50)
|
|
|
*
|
|
|
* @ApiTitle (留言列表)
|
|
|
* @ApiSummary (留言列表)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/hot/comment_list)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="store_id", type="integer", required=true, description="店铺id")
|
|
|
* @ApiParams (name="page", type="integer", 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 comment_list()
|
|
|
{
|
|
|
$param = (new HotValidate())->goCheck('common');
|
|
|
$where = [
|
|
|
'where' => ['store_id' => $param['store_id']]
|
|
|
];
|
|
|
$model = new StoreComment();
|
|
|
$order = ['createtime'=>'DESC'];
|
|
|
$comment = $model->pageSelect($param['page'],$where,'*',$order,config('option.num'));
|
|
|
$list = $comment->items();
|
|
|
if($list) {
|
|
|
foreach ($list as &$v) {
|
|
|
$v['is_self'] = $v['type'] == 1 ? 1 : 0;
|
|
|
if($v['is_self'] == 1) {
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
$v['nickname'] = $user['nickname'];
|
|
|
$v['avatar'] = $user['avatar'];
|
|
|
} else {
|
|
|
$where_s = [
|
|
|
'where' => [
|
|
|
'id' => $v['store_id']
|
|
|
]
|
|
|
];
|
|
|
$store = $this->store_model->findOrFail($where_s,false,'id,store_name as nickname,store_icon as avatar');
|
|
|
$v['nickname'] = $store['nickname'];
|
|
|
$v['avatar'] = cdnurl($store['avatar']);
|
|
|
}
|
|
|
}
|
|
|
// $list = array_sort($list,'id',SORT_ASC);
|
|
|
}
|
|
|
$return = [
|
|
|
'list' => $list,
|
|
|
'this_page' => $comment->currentPage(),
|
|
|
'total_page' => $comment->lastPage()
|
|
|
];
|
|
|
$this->success('成功',$return);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 留言提交
|
|
|
* @ApiWeigh (50)
|
|
|
*
|
...
|
...
|
|