dever 3 years ago
parent
commit
8d309963b9
1 changed files with 22 additions and 13 deletions
  1. 22 13
      app/card/src/Api.php

+ 22 - 13
app/card/src/Api.php

@@ -134,20 +134,29 @@ class Api extends Core
         if (!$card) {
             Dever::alert('请输入正确的卡号');
         }
-        $data = Dever::db('card/code')->find(array('card' => $card, 'status' => 2));
-        if (!$data) {
-            Dever::alert('礼品卡卡号错误或礼品卡已兑换');
-        }
-        $update['where_id'] = $data['id'];
-        $update['dh_uid'] = $this->uid;
-        $update['status'] = 3;
-        $update['ddate'] = time();
-        $state = Dever::db('card/code')->update($update);
-
-        if (!$state) {
-            Dever::alert('兑换失败,请重新兑换');
-        }
 
+        $test = Dever::input('test');
+
+        if ($test == 1) {
+            $data = Dever::db('card/code')->find(array('card' => $card));
+            if (!$data) {
+                Dever::alert('礼品卡卡号错误或礼品卡已兑换');
+            }
+        } else {
+            $data = Dever::db('card/code')->find(array('card' => $card, 'status' => 2));
+            if (!$data) {
+                Dever::alert('礼品卡卡号错误或礼品卡已兑换');
+            }
+            $update['where_id'] = $data['id'];
+            $update['dh_uid'] = $this->uid;
+            $update['status'] = 3;
+            $update['ddate'] = time();
+            $state = Dever::db('card/code')->update($update);
+
+            if (!$state) {
+                Dever::alert('兑换失败,请重新兑换');
+            }
+        }
 
         $info = array();
         $config = Dever::db('main/sell_config')->find();