作者 Cool

商家商圈信息接口开发

@@ -118,7 +118,7 @@ class Hot extends Api @@ -118,7 +118,7 @@ class Hot extends Api
118 // } 118 // }
119 // }; 119 // };
120 $where = [ 120 $where = [
121 - 'where' => ['house_ids'=>['like',['%'.$this->auth->house_id.'%']]], 121 + 'where' => ['status'=>2,'house_ids'=>['like',['%'.$this->auth->house_id.'%']]],
122 'with' => ['store'] 122 'with' => ['store']
123 ]; 123 ];
124 $order = ['number'=>'DESC','createtime'=>'DESC']; 124 $order = ['number'=>'DESC','createtime'=>'DESC'];
@@ -237,7 +237,7 @@ class Hot extends Api @@ -237,7 +237,7 @@ class Hot extends Api
237 if($this->request->isPost()){ 237 if($this->request->isPost()){
238 $param = (new HotValidate())->goCheck('get_red_package'); 238 $param = (new HotValidate())->goCheck('get_red_package');
239 $where = [ 239 $where = [
240 - 'where' => ['id'=>$param['store_inform_id']] 240 + 'where' => ['id'=>$param['store_inform_id'],'status'=>2]
241 ]; 241 ];
242 $inform = $this->store_inform_model->findOrFail($where); 242 $inform = $this->store_inform_model->findOrFail($where);
243 if($inform['surplus'] == 0) { 243 if($inform['surplus'] == 0) {
@@ -276,6 +276,7 @@ class House extends Api @@ -276,6 +276,7 @@ class House extends Api
276 "id"://小区id 276 "id"://小区id
277 "name"://小区名称 277 "name"://小区名称
278 "area"://所在区 278 "area"://所在区
  279 + "address"://地址
279 "shen_status"://状态0选择1申请中2已绑定 280 "shen_status"://状态0选择1申请中2已绑定
280 } 281 }
281 ] 282 ]
@@ -299,7 +300,7 @@ class House extends Api @@ -299,7 +300,7 @@ class House extends Api
299 //查询该市区下的所有小区 300 //查询该市区下的所有小区
300 $data = Db::name('house') 301 $data = Db::name('house')
301 ->where($where) 302 ->where($where)
302 - ->field('id,name,area') 303 + ->field('id,name,area,address')
303 ->order('createtime desc') 304 ->order('createtime desc')
304 ->select(); 305 ->select();
305 306
@@ -12,6 +12,8 @@ use app\api\model\Report; @@ -12,6 +12,8 @@ use app\api\model\Report;
12 use app\api\model\StoreApply; 12 use app\api\model\StoreApply;
13 use app\api\model\StoreComment; 13 use app\api\model\StoreComment;
14 use app\api\model\StoreInform; 14 use app\api\model\StoreInform;
  15 +use app\api\model\StoreInformGood;
  16 +use app\api\model\StoreInformView;
15 use app\api\model\StoreOrder; 17 use app\api\model\StoreOrder;
16 use app\api\model\UserScoreLog; 18 use app\api\model\UserScoreLog;
17 use app\api\validate\StoreValidate; 19 use app\api\validate\StoreValidate;
@@ -33,22 +35,22 @@ class Store extends Api @@ -33,22 +35,22 @@ class Store extends Api
33 protected $noNeedLogin = []; 35 protected $noNeedLogin = [];
34 protected $noNeedRight = ['*']; 36 protected $noNeedRight = ['*'];
35 protected $store_model; 37 protected $store_model;
  38 + protected $store_inform_model;
36 protected $industry_model; 39 protected $industry_model;
37 protected $deposit_model; 40 protected $deposit_model;
38 protected $deposit_order_model; 41 protected $deposit_order_model;
39 - protected $favorite_model;  
40 - protected $comment_model;  
41 - protected $good_model;  
42 - protected $follow_model; 42 + protected $house_model;
43 protected $user_id; 43 protected $user_id;
44 44
45 - public function __construct(Request $request,\app\api\model\Store $store,Industry $industry,Deposit $deposit,DepositOrder $deposit_order) 45 + public function __construct(Request $request,\app\api\model\Store $store,Industry $industry,Deposit $deposit,DepositOrder $deposit_order,StoreInform $inform,\app\api\model\House $house)
46 { 46 {
47 parent::__construct($request); 47 parent::__construct($request);
  48 + $this->store_model = $store;
  49 + $this->store_inform_model = $inform;
48 $this->industry_model = $industry; 50 $this->industry_model = $industry;
49 $this->deposit_model = $deposit; 51 $this->deposit_model = $deposit;
50 $this->deposit_order_model = $deposit_order; 52 $this->deposit_order_model = $deposit_order;
51 - $this->store_model = $store; 53 + $this->house_model = $house;
52 $this->user_id = $this->auth->id; 54 $this->user_id = $this->auth->id;
53 } 55 }
54 56
@@ -526,6 +528,7 @@ class Store extends Api @@ -526,6 +528,7 @@ class Store extends Api
526 "id"://小区id 528 "id"://小区id
527 "name"://小区名称 529 "name"://小区名称
528 "area"://所在区 530 "area"://所在区
  531 + "address"://地址
529 } 532 }
530 ] 533 ]
531 } 534 }
@@ -547,7 +550,7 @@ class Store extends Api @@ -547,7 +550,7 @@ class Store extends Api
547 } 550 }
548 $data = Db::name('house') 551 $data = Db::name('house')
549 ->where($where) 552 ->where($where)
550 - ->field('id,name,area') 553 + ->field('id,name,area,address')
551 ->order('createtime desc') 554 ->order('createtime desc')
552 ->select(); 555 ->select();
553 $this->success('success',$data); 556 $this->success('success',$data);
@@ -637,6 +640,161 @@ class Store extends Api @@ -637,6 +640,161 @@ class Store extends Api
637 } 640 }
638 641
639 /** 642 /**
  643 + * 商圈信息列表
  644 + * @ApiWeigh (29)
  645 + *
  646 + * @ApiTitle (商圈信息列表)
  647 + * @ApiSummary (商圈信息列表)
  648 + * @ApiMethod (POST)
  649 + * @ApiRoute (/api/store/store_list)
  650 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  651 + * @ApiParams (name="status", type="integer", required=true, description="状态0=全部1=审核中2=已发布3=已下架")
  652 + * @ApiParams (name="page", type="integer", required=true, description="页数")
  653 + * @ApiReturnParams (name="code", type="integer", required=true, sample="0")
  654 + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
  655 + * @ApiReturn ({
  656 + 'code':'1',
  657 + 'msg':'返回成功',
  658 + "data": {
  659 + "list": [
  660 + {
  661 + "id": 5,
  662 + "user_id": 1,
  663 + "store_id": 1,
  664 + "content": "标题",
  665 + "images": "/assets/img/qrcode.png",
  666 + "house_ids": ",1,",
  667 + "type": 2,
  668 + "score": "0",
  669 + "red_package": "红包总金额",
  670 + "number": 红包数量,
  671 + "single": "单个红包金额",
  672 + "get": 已领取数量,
  673 + "surplus": 剩余数量,
  674 + "views": 0,
  675 + "status": 状态1=审核中2=已发布3=已下架4=审核失败,
  676 + "createtime": "2020-08-27 20:10:50",
  677 + "image_arr"图片: [
  678 + "http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png"
  679 + ],
  680 + "store": {
  681 + "id": 1,
  682 + "store_name": "店铺名称",
  683 + "store_icon": "图标",
  684 + "industry_id": "行业标签",
  685 + },
  686 + },
  687 + ],
  688 + "this_page": 当前页数,
  689 + "total_page": 总页数
  690 + }
  691 + })
  692 + */
  693 + public function store_list()
  694 + {
  695 + if($this->request->isPost()){
  696 + $page = $this->request->param('page',1,'intval');
  697 + $status = $this->request->param('status',0,'intval');
  698 + $store = $this->get_store();
  699 + $where_s = [
  700 + 'store_id' => $store['id']
  701 + ];
  702 + if($status) {
  703 + $where_s['status'] = $status;
  704 + }
  705 + $where = [
  706 + 'where' => $where_s,
  707 + 'with' => ['store']
  708 + ];
  709 + $order = ['number'=>'DESC','createtime'=>'DESC'];
  710 + $inform = $this->store_inform_model->pageSelect($page,$where,'*',$order,config('option.num'));
  711 + $list = $inform->items();
  712 + $return = [
  713 + 'list' => $list,
  714 + 'this_page' => $inform->currentPage(),
  715 + 'total_page' => $inform->lastPage()
  716 + ];
  717 + $this->success('请求成功',$return);
  718 + }
  719 + }
  720 +
  721 + /**
  722 + * 商圈信息详情
  723 + * @ApiWeigh (28)
  724 + *
  725 + * @ApiTitle (商圈信息详情)
  726 + * @ApiSummary (商圈信息详情)
  727 + * @ApiMethod (POST)
  728 + * @ApiRoute (/api/store/store_detail)
  729 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  730 + * @ApiParams (name="inform_id", type="integer", required=true, description="商圈信息id")
  731 + * @ApiReturnParams (name="code", type="integer", required=true, sample="0")
  732 + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
  733 + * @ApiReturn ({
  734 + 'code':'1',
  735 + 'msg':'返回成功',
  736 + "data": {
  737 + "inform": {
  738 + "id": 1,
  739 + "user_id": 1,
  740 + "store_id": 1,
  741 + "content": "内容",
  742 + "images": "/assets/img/qrcode.png",
  743 + "house_ids": ",1,",
  744 + "type": 2,
  745 + "score": "0",
  746 + "red_package": "红包总金额",
  747 + "number": 红包数量,
  748 + "single": "单个红包金额",
  749 + "get": 已领取数量,
  750 + "surplus": 剩余数量,
  751 + "views": 0,
  752 + "status": 状态1=审核中2=已发布3=已下架4=审核失败,
  753 + "createtime": "2020-08-27 20:10:50",
  754 + "updatetime": 1598530250,
  755 + "image_arr"图片: [
  756 + "http://community.qiniu.brotop.cn/assets/img/qrcode.png"
  757 + ],
  758 + "house_names": "社区名称",
  759 + "surplus_package": 剩余红包金额,
  760 + "good_count": 点赞总数,
  761 + "is_good": 是否点赞0=否1=是
  762 + }
  763 + }
  764 + })
  765 + */
  766 + public function store_detail()
  767 + {
  768 + if($this->request->isPost()){
  769 + $inform_id = $this->request->param('inform_id',0,'intval');
  770 + $store = $this->get_store();
  771 + $where_s = [
  772 + 'id' => $inform_id
  773 + ];
  774 + $where = [
  775 + 'where' => $where_s
  776 + ];
  777 + $order = ['createtime'=>'DESC'];
  778 + $inform = $this->store_inform_model->findOrFail($where,true,'*',$order);
  779 + $house_name = $this->house_model->whereIn('id',$inform['house_ids'])->column('name');
  780 + $inform['house_names'] = implode(',',$house_name);
  781 + $inform['surplus_package'] = $inform['single'] * $inform['surplus'];
  782 + // 获取点赞数及是否点赞
  783 + $good_model = new StoreInformGood();
  784 + $where_g = [
  785 + 'object_id' => $inform['id']
  786 + ];
  787 + $inform['good_count'] = $good_model->getCount($where_g);
  788 + $where_g['user_id'] = $this->user_id;
  789 + $inform['is_good'] = $good_model->getCount($where_g);
  790 + $return = [
  791 + 'inform' => $inform,
  792 + ];
  793 + $this->success('请求成功',$return);
  794 + }
  795 + }
  796 +
  797 + /**
640 * 绑定新社区 798 * 绑定新社区
641 * @ApiWeigh (25) 799 * @ApiWeigh (25)
642 * 800 *
@@ -10,6 +10,7 @@ class StoreInform extends Base @@ -10,6 +10,7 @@ class StoreInform extends Base
10 protected $append = [ 10 protected $append = [
11 'image_arr' 11 'image_arr'
12 ]; 12 ];
  13 +
13 public function getImageArrAttr($value,$data) 14 public function getImageArrAttr($value,$data)
14 { 15 {
15 $image_arr = []; 16 $image_arr = [];
@@ -21,4 +22,9 @@ class StoreInform extends Base @@ -21,4 +22,9 @@ class StoreInform extends Base
21 } 22 }
22 return $image_arr; 23 return $image_arr;
23 } 24 }
  25 +
  26 + public function getCreatetimeAttr($value)
  27 + {
  28 + return date('Y-m-d H:i:s',$value);
  29 + }
24 } 30 }