...
|
...
|
@@ -67,7 +67,7 @@ class Coupons extends Api |
|
|
}
|
|
|
|
|
|
$flag = config('verify.flag');
|
|
|
$where = ['is_new'=>$flag[0],'coupon_number'=>['<>',0],'end_time'=>['>',time()]];
|
|
|
$where = ['is_new'=>$flag[0],'end_time'=>['>',time()]];
|
|
|
//查询已经领取过
|
|
|
$receive = Common::selectWhereData('rcoupon',['uid'=>$this->uid],'id,c_id');
|
|
|
$receive_s = array_column($receive,'c_id');
|
...
|
...
|
@@ -240,7 +240,6 @@ class Coupons extends Api |
|
|
* @ApiRoute (/api/coupons/goodsCouponList)
|
|
|
*
|
|
|
* @ApiParams (name="goods_id", type="inter", required=true, description="商品id")
|
|
|
* @ApiParams (name="is_flag", type="inter", required=true, description="优惠券标识(0:未使用,1:已使用,2:已过期)")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
...
|
...
|
@@ -252,18 +251,20 @@ class Coupons extends Api |
|
|
"coupon_tag": "无门槛",//优惠券(无门槛,折扣券,满减券)
|
|
|
"coupon_price": "¥300",//(折扣或减少金额)
|
|
|
"coupon_tag1": "无门槛",优惠券(无门槛,满多少可用)
|
|
|
"is_receive": 0,//是否领取(0:否,1:是)
|
|
|
"coupon_name": "全场优惠券",//优惠券名称
|
|
|
"end_time": "2020.1.31",//优惠券有效期
|
|
|
"coupon_number": 100,//优惠券剩余数量(0:领光了)
|
|
|
"type": "全场通用"//优惠券用途
|
|
|
},
|
|
|
{
|
|
|
"id": 10,
|
|
|
"coupon_tag": "折扣券",
|
|
|
"coupon_price": "9.5折",
|
|
|
"coupon_tag1": "满2000可用",
|
|
|
"coupon_name": "商品优惠券",
|
|
|
"end_time": "2020.1.31",
|
|
|
"type": "商品可用"
|
|
|
"id": 2,//优惠券id
|
|
|
"coupon_tag": "无门槛",//优惠券(无门槛,折扣券,满减券)
|
|
|
"coupon_price": "¥300",//(折扣或减少金额)
|
|
|
"coupon_tag1": "无门槛",优惠券(无门槛,满多少可用)
|
|
|
"is_receive": 0,//是否领取(0:否,1:是)
|
|
|
"coupon_name": "全场优惠券",//优惠券名称
|
|
|
"coupon_number": 100,//优惠券剩余数量(0:领光了)
|
|
|
"type": "全场通用"//优惠券用途
|
|
|
}
|
|
|
]
|
|
|
})
|
...
|
...
|
@@ -271,35 +272,21 @@ class Coupons extends Api |
|
|
public function goodsCouponList(){
|
|
|
if($this->request->isGet()){
|
|
|
$goods_id = $this->request->get('goods_id');
|
|
|
$is_flag = $this->request->get('is_flag');
|
|
|
$rule = config('verify.goods_coupon');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check(['goods_id'=>$goods_id,'is_flag'=>$is_flag])) {
|
|
|
if (!$validate->check(['goods_id'=>$goods_id])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
|
|
|
$type = config('verify.type');
|
|
|
$where = ['type'=>$type[2],'bg_id'=>$goods_id,'end_time'=>['>',time()]];
|
|
|
//查询已经领取过
|
|
|
$receive = Common::selectWhereData('rcoupon',['uid'=>$this->uid],'id,c_id');
|
|
|
$receive_s = array_column($receive,'c_id');
|
|
|
|
|
|
$type = config('verify.type');
|
|
|
$flag = config('verify.flag');
|
|
|
//不显示没有库存的优惠券
|
|
|
$where = ['is_new'=>$flag[0],'type'=>$type[2],'bg_id'=>$goods_id,'coupon_number'=>['<>',0]];
|
|
|
if($is_flag == 0){
|
|
|
//未使用
|
|
|
$where['id'] = ['not in',$receive_s];
|
|
|
$where['end_time'] = ['>',time()];
|
|
|
}else if($is_flag == 1){
|
|
|
//已使用
|
|
|
$where['id'] = ['in',$receive_s];
|
|
|
$where['end_time'] = ['>',time()];
|
|
|
}else{
|
|
|
//已过期
|
|
|
$where['end_time'] = ['<',time()];
|
|
|
}
|
|
|
$data = Common::selectWhereData('coupon',$where,'id,type,coupon_name,c_type,coupon_type,full_reduce,reduce,discount,coupon_number,end_time','c_type asc,coupon_type desc');
|
|
|
$data = Common::selectWhereData('coupon',$where,'id,type,coupon_name,c_type,coupon_type,full_reduce,reduce,discount,coupon_number','c_type asc,coupon_type desc');
|
|
|
$res = [];
|
|
|
|
|
|
foreach($data as $key=>$value){
|
|
|
|
|
|
$res[$key]['id'] = $value['id'];
|
...
|
...
|
@@ -338,9 +325,23 @@ class Coupons extends Api |
|
|
}
|
|
|
}
|
|
|
|
|
|
$res[$key]['is_receive'] = 0;//未领取
|
|
|
if(in_array($value['id'],$receive_s)){
|
|
|
$res[$key]['is_receive'] = 1;//已领取
|
|
|
}
|
|
|
$res[$key]['coupon_name'] = $value['coupon_name'];//优惠券名称
|
|
|
$res[$key]['end_time'] = date('Y.n.j',$value['end_time']);//优惠券有效期
|
|
|
$res[$key]['type'] = '商品可用';
|
|
|
$res[$key]['coupon_number'] = $value['coupon_number'];//优惠券剩余数量
|
|
|
//全场,品牌,商品
|
|
|
if($value['type'] == 0){
|
|
|
$res[$key]['type'] = '全场通用';
|
|
|
|
|
|
}else if($value['type'] == 1){
|
|
|
$res[$key]['type'] = '部分品牌可用';
|
|
|
|
|
|
}else{
|
|
|
$res[$key]['type'] = '部分商品可用';
|
|
|
|
|
|
}
|
|
|
}
|
|
|
$this->success('成功',$res);
|
|
|
}else{
|
...
|
...
|
|