|
@@ -4,7 +4,6 @@ namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
|
|
-use app\common\library\Sms;
|
|
|
|
|
|
/**
|
|
|
* 用户优惠券
|
|
@@ -17,6 +16,41 @@ class Usercoupon extends Api
|
|
|
|
|
|
//优惠券里列表
|
|
|
public function lists(){
|
|
|
+ $status = input('status',0);
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ 'cu.user_id' => $this->auth->id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if($status == 0){
|
|
|
+ //待使用
|
|
|
+ $where['c.deletetime'] = NULL;
|
|
|
+ $where['c.switch'] = 1;
|
|
|
+ $where['c.starttime'] = ['<',time()];
|
|
|
+ $where['c.endtime'] = ['>',time()];
|
|
|
+ $where['cu.status'] = 0;
|
|
|
+ }
|
|
|
+ if($status == 1){
|
|
|
+ //已使用
|
|
|
+ $where['cu.status'] = 1;
|
|
|
+ }
|
|
|
+ if($status == 2){
|
|
|
+ //已失效
|
|
|
+ $where['c.deletetime'] = NULL;
|
|
|
+ $where['c.switch'] = 1;
|
|
|
+ $where['c.starttime'] = ['<',time()];
|
|
|
+ $where['c.endtime'] = ['<',time()];
|
|
|
+ $where['cu.status'] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = Db::name('unishop_coupon_user')->alias('cu')
|
|
|
+ ->field(['c.id','c.title','c.least','c.value','c.starttime','c.endtime','cu.status'])
|
|
|
+ ->join('unishop_coupon c','cu.coupon_id = c.id','LEFT')
|
|
|
+ ->where($where)
|
|
|
+ ->autopage()
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
|
|
|
}
|
|
|
|