Coupon.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\index\controller\shop;
  3. use app\common\controller\Frontend;
  4. use addons\shop\library\IntCode;
  5. use addons\shop\model\UserCoupon;
  6. class Coupon extends Frontend
  7. {
  8. protected $layout = 'default';
  9. protected $noNeedLogin = [];
  10. protected $noNeedRight = ['*'];
  11. //我的优惠券列表
  12. public function index()
  13. {
  14. $param = $this->request->param();
  15. $param['user_id'] = $this->auth->id;
  16. $param['f'] = isset($param['is_used'])?$param['is_used']:'0';
  17. if(isset($param['expire_time']) && !empty($param['expire_time'])){
  18. $param['f'] = 4;
  19. }
  20. if(isset($param['begin_time']) && !empty($param['begin_time'])){
  21. $param['f'] = 3;
  22. }
  23. $list = UserCoupon::tableList($param);
  24. foreach ($list as $item) {
  25. $item->coupon_id = IntCode::encode($item->coupon_id);
  26. if ($item->coupon) {
  27. $item->coupon->id = $item->coupon_id;
  28. }
  29. }
  30. $this->view->assign('title', '我的优惠券');
  31. $this->view->assign('param',$param);
  32. $this->view->assign('coupon_list',$list);
  33. return $this->view->fetch();
  34. }
  35. }