| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\api\controller;
- use app\api\lists\UserCouponLists;
- use app\api\logic\UserCouponLogic;
- use app\api\validate\UserCouponValidate;
- class UserCouponController extends BaseApiController
- {
- public array $notNeedLogin = ['categoryCouponList'];
- /**
- * 我的优惠卷列表
- * @return \think\response\Json
- */
- public function lists()
- {
- $params = (new UserCouponValidate())->goCheck('voucher',[
- 'user_id'=>$this->userId
- ]);
- $result = UserCouponLogic::userCouponList($params);
- if (false === $result) {
- return $this->fail(UserCouponLogic::getError());
- }
- return $this->data($result);
- }
- /**
- * 一键领取优惠卷
- * @return \think\response\Json
- */
- public function add()
- {
- $params = (new UserCouponValidate())->post()->goCheck('add',[
- 'user_id'=>$this->userId
- ]);
- $result = UserCouponLogic::add($params);
- if (false !== $result) {
- return $this->success('领取成功'.implode('\n',$result), [], 1, 1);
- }
- return $this->fail(UserCouponLogic::getError());
- }
- public function categoryCouponLists()
- {
- $params = (new UserCouponValidate())->goCheck('category',[
- 'user_id'=>$this->userId
- ]);
- $result = UserCouponLogic::categoryCouponLists($params);
- if (false === $result) {
- return $this->fail(UserCouponLogic::getError());
- }
- return $this->data($result);
- }
- public function categoryWithAmountLists()
- {
- $params = (new UserCouponValidate())->goCheck('categoryWithAmountList',[
- 'user_id'=>$this->userId
- ]);
- $result = UserCouponLogic::categoryWithAmountLists($params);
- if (false === $result) {
- return $this->fail(UserCouponLogic::getError());
- }
- return $this->data($result);
- }
- }
|