|
@@ -44,6 +44,18 @@ 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']);
|
|
|
|
|
|
+
|
|
|
+ //
|
|
|
+ $result = [
|
|
|
+ 'banner' => $banner,
|
|
|
+ 'top_category' => $top_category,
|
|
|
+ 'buttom_category' => $buttom_category,
|
|
|
+ ];
|
|
|
+ $this->success(1,$result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否有可领取的优惠券
|
|
|
+ public function new_coupon(){
|
|
|
//未领取的优惠券
|
|
|
$coupon = (object)[];
|
|
|
if($this->auth->isLogin()){
|
|
@@ -60,14 +72,34 @@ class Index extends Api
|
|
|
|
|
|
if(empty($coupon)){ $coupon = (object)[];}
|
|
|
}
|
|
|
- //
|
|
|
- $result = [
|
|
|
- 'banner' => $banner,
|
|
|
- 'top_category' => $top_category,
|
|
|
- 'buttom_category' => $buttom_category,
|
|
|
- 'coupon' => $coupon,
|
|
|
- ];
|
|
|
- $this->success(1,$result);
|
|
|
+
|
|
|
+ $this->success(1,$coupon);
|
|
|
+ }
|
|
|
+
|
|
|
+ //领取优惠券
|
|
|
+ public function get_coupon(){
|
|
|
+ $coupon_id = input('coupon_id',0);
|
|
|
+
|
|
|
+ $coupon = Db::name('unishop_coupon')->field('id,title,least,value')
|
|
|
+ ->where('id',$coupon_id)
|
|
|
+ ->where('deletetime',NULL)
|
|
|
+ ->where('switch',1)
|
|
|
+ ->where('starttime','<',time())
|
|
|
+ ->where('endtime','>',time())
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if($coupon){
|
|
|
+ $user_coupon = Db::name('unishop_coupon_user')->where('user_id',$this->auth->id)->where('coupon_id',$coupon_id)->find();
|
|
|
+ if(empty($user_coupon)){
|
|
|
+ $data = [
|
|
|
+ 'coupon_id' => $coupon_id,
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ ];
|
|
|
+ Db::name('unishop_coupon_user')->insertGetId($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('领取成功');
|
|
|
}
|
|
|
|
|
|
//吃喝玩乐
|