|
@@ -44,11 +44,28 @@ class Index extends Api
|
|
|
$buttom_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 0])->order('weigh', 'asc')->select();
|
|
|
$buttom_category = list_domain_image($buttom_category, ['image']);
|
|
|
|
|
|
+ //未领取的优惠券
|
|
|
+ $coupon = (object)[];
|
|
|
+ if($this->auth->isLogin()){
|
|
|
+ //我拥有的
|
|
|
+ $user_coupon = Db::name('unishop_coupon_user')->where('user_id',$this->auth->id)->column('coupon_id');
|
|
|
+ //我没有的,可领取的
|
|
|
+ $coupon = Db::name('unishop_coupon')->field('id,title,least,value')
|
|
|
+ ->where('id','NOTIN',$user_coupon)
|
|
|
+ ->where('deletetime',NULL)
|
|
|
+ ->where('switch',1)
|
|
|
+ ->where('starttime','<',time())
|
|
|
+ ->where('endtime','>',time())
|
|
|
+ ->order('id asc')->find();
|
|
|
+
|
|
|
+ if(empty($coupon)){ $coupon = (object)[];}
|
|
|
+ }
|
|
|
//
|
|
|
$result = [
|
|
|
'banner' => $banner,
|
|
|
'top_category' => $top_category,
|
|
|
'buttom_category' => $buttom_category,
|
|
|
+ 'coupon' => $coupon,
|
|
|
];
|
|
|
$this->success(1,$result);
|
|
|
}
|