|
@@ -54,76 +54,5 @@ class Index extends Api
|
|
$this->success(1,$result);
|
|
$this->success(1,$result);
|
|
}
|
|
}
|
|
|
|
|
|
- //是否有可领取的优惠券
|
|
|
|
- public function new_coupon(){
|
|
|
|
- //未领取的优惠券
|
|
|
|
- $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,number')
|
|
|
|
- ->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)[];
|
|
|
|
- }else{
|
|
|
|
- $coupon['value'] = intval($coupon['value']);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $this->success(1,$coupon);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //领取优惠券
|
|
|
|
- public function get_coupon(){
|
|
|
|
- $coupon_id = input('coupon_id',0);
|
|
|
|
-
|
|
|
|
- $coupon = Db::name('unishop_coupon')->field('id,title,least,value,number')
|
|
|
|
- ->where('id',$coupon_id)
|
|
|
|
- ->where('deletetime',NULL)
|
|
|
|
- ->where('switch',1)
|
|
|
|
- ->where('starttime','<',time())
|
|
|
|
- ->where('endtime','>',time())
|
|
|
|
- ->find();
|
|
|
|
-
|
|
|
|
- $user_coupon = Db::name('unishop_coupon_user')->where('user_id',$this->auth->id)->where('coupon_id',$coupon_id)->find();
|
|
|
|
-
|
|
|
|
- if($coupon && empty($user_coupon)){
|
|
|
|
- $data = [];
|
|
|
|
- for($i=1;$i<=$coupon['number'];$i++){
|
|
|
|
- $data[] = [
|
|
|
|
- 'coupon_id' => $coupon_id,
|
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
|
- ];
|
|
|
|
- }
|
|
|
|
- Db::name('unishop_coupon_user')->insertAll($data);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $this->success('领取成功');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //吃喝玩乐
|
|
|
|
- //列表
|
|
|
|
- public function chihewanle_list(){
|
|
|
|
- $list = Db::name('chihewanle')->field('id, title, info, image')->where(['status' => 1])->order('weigh', 'desc')->select();
|
|
|
|
- $list = list_domain_image($list, ['image']);
|
|
|
|
-
|
|
|
|
- $this->success(1,$list);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //吃喝玩乐
|
|
|
|
- //详情
|
|
|
|
- public function chihewanle_info(){
|
|
|
|
- $id = input('id',0);
|
|
|
|
- $info = Db::name('chihewanle')->field('id, title, info, image, content')->where('id',$id)->order('weigh', 'desc')->find();
|
|
|
|
- $info = info_domain_image($info, ['image']);
|
|
|
|
-
|
|
|
|
- $this->success(1,$info);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|