IntegralGoods.php
3.8 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Config;
/**
* 积分商品接口
*/
class IntegralGoods extends Api
{
protected $integralGoodsModel;
public function _initialize()
{
parent::_initialize();
$this->integralGoodsModel = new \app\api\model\IntegralGoods;
}
/**
* @ApiTitle (积分商品列表)
* @ApiSummary (积分商品列表)
* @ApiMethod (POST)
* @ApiRoute (/api/integral_goods/getGoodsList)
* @ApiParams (name=keyword, type=string, required=false, description="关键字搜索")
* @ApiParams (name=page, type=string, required=false, description="页数")
* @ApiReturn({
"code": 1,
"msg": "请求成功",
"time": "1587463117",
"data": [
{
"integral_goods_id": 1, 商品id
"ch_name": "EMP精选 澳洲白肉油桃 500~540g 4只装", 中文名称
"en_name": "EMP selected Australian white meat nectarines Australian meat nectarines", 英文名称
"image": "http://q7s0a1rb4.bkt.clouddn.com/uploads/20200420/26f5e51b8ac7fbd6f1c649cc45a18265.png", 缩略图
"integral": "100", 积分
"goods_price": "0.00", 售价
"original_price": "123.00", 原价
"country_ch_name": "意大利", 原产地中文
"country_en_name": "Ltaly", 原产地英文
"stock_num": 55 库存
}
]
})
*/
public function getGoodsList()
{
$page = $this->request->param('page');
$keyword = $this->request->param('keyword');
$limit = Config::get('paginate.index_rows');
$where = [];
if (!empty($keyword)) $where['g.ch_name|g.en_name|g.ch_content|g.en_content'] = ['like','%'.$keyword.'%'];
$data = $this->integralGoodsModel->selectPageData($where,$page,$limit,$this->lang);
$this->success('请求成功', $data);
}
/**
* @ApiTitle (积分商品详情)
* @ApiSummary (积分商品详情)
* @ApiMethod (POST)
* @ApiRoute (/api/integral_goods/getGoodsInfo)
* @ApiParams (name=integral_goods_id, type=string, required=true, description="积分商品id")
* @ApiReturn({
"code": 1,
"msg": "请求成功",
"time": "1587463117",
"data": [
{
"code": 1,
"msg": "请求成功",
"time": "1587471193",
"data": {
"integral_goods_id": 1, 商品id
"ch_name": "EMP精选 澳洲白肉油桃 500~540g 4只装", 中文名称
"en_name": "EMP selected Australian white meat nectarines Australian meat nectarines", 英文名称
"image": "http://q7s0a1rb4.bkt.clouddn.com/uploads/20200420/26f5e51b8ac7fbd6f1c649cc45a18265.png", 缩略图
"integral": "100", 积分
"goods_price": "123.00", 价格
"original_price": "123.00", 原价
"images": [
"http://q7s0a1rb4.bkt.clouddn.com/uploads/20200420/26f5e51b8ac7fbd6f1c649cc45a18265.png"
], 轮播图
"goods_no": "", 商品编码
"ch_specification": "", 中文包装规格
"en_specification": "", 英文包装规格
"ch_save_where": "", 中文保存条件
"en_save_where": "", 英文保存条件
"ch_period": "", 中文有效期
"en_period": "", 英文有效期
"ch_content": "", 中文详情
"en_content": "", 英文详情
"stock_num": 55, 库存
"sales_actual": 3, 实际销量
"ch_country_name": "意大利",
"en_country_name": "Ltaly"
}
}
]
})
*/
public function getGoodsInfo()
{
$integral_goods_id = $this->request->param('integral_goods_id');
if (!$integral_goods_id) $this->error('缺少参数 integral_goods_id!');
$where = ['g.id'=>$integral_goods_id];
$data = $this->integralGoodsModel->getInfo($where,$this->lang);
if ($data['status'] == 2) $this->error('商品已下架');
$this->success('请求成功', $data);
}
}