You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
3 months ago
|
<?php
|
||
|
|
||
|
|
||
|
namespace app\controller\api\v1\activity;
|
||
|
|
||
|
|
||
|
use app\Request;
|
||
|
use app\services\activity\discounts\StoreDiscountsServices;
|
||
|
|
||
|
/**
|
||
|
* 优惠套餐控制器
|
||
|
* Class StoreDiscounts
|
||
|
* @package app\controller\api\v1\activity
|
||
|
*/
|
||
|
class StoreDiscounts
|
||
|
{
|
||
|
protected $services;
|
||
|
|
||
|
/**
|
||
|
* StoreDiscounts constructor.
|
||
|
* @param StoreDiscountsServices $services
|
||
|
*/
|
||
|
public function __construct(StoreDiscountsServices $services)
|
||
|
{
|
||
|
$this->services = $services;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取优惠商品列表
|
||
|
* @param Request $request
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function index(Request $request)
|
||
|
{
|
||
|
[$product_id] = $request->postMore([
|
||
|
['product_id', 0]
|
||
|
], true);
|
||
|
$uid = (int)$request->uid();
|
||
|
if (!$product_id) return app('json')->fail('参数错误');
|
||
|
$list = $this->services->getDiscounts((int)$product_id, $uid);
|
||
|
return $list ? app('json')->successful($list) : app('json')->successful([]);
|
||
|
}
|
||
|
public function getList(Request $request){
|
||
|
[$vip_type] = $request->postMore([
|
||
|
['vip_type', 0]
|
||
|
], true);
|
||
|
if (!$vip_type) return app('json')->fail('参数错误');
|
||
|
$list = $this->services->getList(['vip_type'=>$vip_type]);
|
||
|
foreach($list['list'] as $key => &$v){
|
||
|
$v['attr_value'] = $this->services->getInfo($v['id']);
|
||
|
}
|
||
|
return $list ? app('json')->successful($list) : app('json')->fail('无商品礼包');
|
||
|
|
||
|
}
|
||
|
}
|