dever 3 years ago
parent
commit
d8c4a9a274

+ 1 - 1
app/goods/database/info.php

@@ -284,7 +284,7 @@ $config = array
         (
             'type'      => 'int-11',
             'name'      => '起购数',
-            'default'   => '1',
+            'default'   => '0',
             'desc'      => '起购数',
             'match'     => 'is_string',
             //'update'    => 'text',

+ 1 - 1
app/goods/database/info_sku.php

@@ -103,7 +103,7 @@ $config = array
         (
             'type'      => 'int-11',
             'name'      => '起购数',
-            'default'   => '1',
+            'default'   => '0',
             'desc'      => '起购数',
             'match'     => 'is_string',
             'update'    => 'text',

+ 15 - 0
app/shop/database/user_coupon.php

@@ -149,6 +149,21 @@ return array
 
     'request' => array
     (
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'shop_coupon_id' => 'yes',
+                'coupon_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+
         # 列表
         'getAll' => array
         (

+ 8 - 2
app/shop/lib/Coupon.php

@@ -58,6 +58,7 @@ class Coupon
         $data = Dever::db('shop/coupon')->getOne($shop_coupon_id);
 
         if (!$data) {
+            Dever::alert('优惠券不存在');
             return false;
         }
 
@@ -72,17 +73,21 @@ class Coupon
             $data = Dever::db('shop/coupon_act')->getOne(array('shop_id' => $shop['id'], 'act_id' => $act_id, 'shop_coupon_id' => $shop_coupon_id));
 
             if (!$data) {
+                Dever::alert('优惠券不存在');
                 return false;
             }
 
             $state = Dever::load('shop/lib/share')->getOne($uid, $shop['id'], 1);
             if (!$state) {
+                Dever::alert('您还完成分享');
                 return false;
             }
 
-            $user = Dever::db('shop/user_coupon')->find(array('uid' => $uid, 'shop_coupon_id' => $data['id'], 'status' => 1));
+            # 验证是否已经领取,一周内不能再次领取
+            $user = Dever::db('shop/user_coupon')->getOne(array('uid' => $uid, 'coupon_id' => $data['id']));
 
-            if ($user) {
+            if ($user && time() - $user['cdate'] < 86400*7) {
+                Dever::alert('您已领取过该优惠劵');
                 return false;
             }
         }
@@ -92,6 +97,7 @@ class Coupon
             return true;
         }
 
+        Dever::alert('领取失败');
         return false;
     }