فهرست منبع

查询可用优惠券

15954078560 2 سال پیش
والد
کامیت
f289262e53
1فایلهای تغییر یافته به همراه18 افزوده شده و 2 حذف شده
  1. 18 2
      application/api/controller/Index.php

+ 18 - 2
application/api/controller/Index.php

@@ -2,9 +2,7 @@
 
 namespace app\api\controller;
 
-use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\ListCallTaskResponseBody\data;
 use app\common\controller\Api;
-use function GuzzleHttp\Psr7\uri_for;
 use think\Db;
 use wxpay;
 
@@ -128,6 +126,24 @@ class Index extends Api
         $this->success('检查通过');
     }
 
+    //查询可用优惠券
+    public function canusercoupon() {
+        $price = input('price', '', 'trim'); //价格
+        if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $price) || $price < 0) {
+            $this->error('价格错误');
+        }
+
+        $where['user_id'] = $this->auth->id;
+        $where['endtime'] = ['gt', time()];
+        $where['status'] = 0;
+        $map = 'type = 1 or (type = 2 and minmoney <= '.$price.')';
+
+        $list = Db::name('user_coupon')->field('id, title, desc, type, money, minmoney')->where($where)->where($map)->select();
+//        p(\db()->getLastSql());
+
+        $this->success('查询可用优惠券', $list);
+    }
+    
     //报名活动
     public function signupactive() {
         //检查自己信息是否完善