Omessages.php
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
use think\Validate;
/**
* 订单消息接口**
*/
class Omessages extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $user_id = '';//token存贮user_id
protected $normal = '';//商品正常状态,1:下架
public function _initialize()
{
parent::_initialize();
$this->normal = config('site.goods_status');
$this->user_id = $this->auth->getUserId();
}
/**
* @ApiTitle (我的订单消息列表)
* @ApiSummary (我的订单消息列表)
* @ApiMethod (GET)
* @ApiRoute (/api/omessages/orderMessageList)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="page", type="integer", required=true, description="分页页码")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1553777266",
"data":[
{
"id": 1,
"order_sn": "gc_155358608729209200",//订单号
"status": 3,//订单状态 0:待付款 1:待收货 2:待评价 3:已完成
"title": "我的垃圾商品1",//商品名称
"username": "风起时呀"//收货人
"is_read":0,//0:未读 1:已读
},
{
"id": 3,
"order_sn": "gc_155358608729212300",
"status": 0,
"title": "废品商品2",
"username": "风起时呀",
"is_read":0,//0:未读 1:已读
}
]
})
*/
public function orderMessageList(){
if($this->request->isGet()){
$page = $this->request->get('page');//分页页码
$limit = config('site.page_limit');//分页限制数量
$rule = config('site.gift_pages');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['page'=>$page])) {
$this->error($validate->getError());
}
$data = Db::table('gc_porder')
->alias('o')
->join('gc_product p','o.p_id = p.id','LEFT')
->join('gc_user u','o.s_uid = u.id','LEFT')
->where(['o.s_uid'=>$this->user_id,'p.status'=>$this->normal,'u.status'=>'normal'])
->page($page,$limit)
->field('o.id,o.order_sn,o.status,p.title,u.username,o.is_read')
->select();
$this->success('成功',$data);
}else{
$this->error('请求方式出错');
}
}
}