Files
fast/addons/shopro/controller/user/Coupon.php
xiadc c6a4e1f5f6 init
- 框架初始化
 - 安装插件
 - 修复PHP8.4报错
2025-04-19 17:21:20 +08:00

31 lines
992 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace addons\shopro\controller\user;
use think\helper\Str;
use addons\shopro\controller\Common;
use app\admin\model\shopro\user\Coupon as UserCouponModel;
class Coupon extends Common
{
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
public function index()
{
$user = auth_user();
$type = $this->request->param('type', 'can_use'); // 优惠券类型geted=已领取can_use=可用cannot_use=暂不可用used=已使用expired=已过期,invalid=已失效(包含已使用和已过期)
$userCoupons = UserCouponModel::with('coupon')->where('user_id', $user->id);
if (in_array($type, ['geted', 'can_use', 'cannot_use', 'used', 'expired', 'invalid'])) {
$userCoupons = $userCoupons->{Str::camel($type)}();
}
$userCoupons = $userCoupons->order('id', 'desc')->paginate($this->request->param('list_rows', 10));
$this->success('获取成功', $userCoupons);
}
}