rabin 3 år sedan
förälder
incheckning
90e2d59476
4 ändrade filer med 37 tillägg och 6 borttagningar
  1. 24 3
      app/mshop/lib/Out.php
  2. 1 0
      app/shop/lib/Cron.php
  3. 1 0
      app/shop/lib/Goods.php
  4. 11 3
      app/shop/lib/Sell.php

+ 24 - 3
app/mshop/lib/Out.php

@@ -171,7 +171,8 @@ class Out
     {
         $id = Dever::input('id');
         $order_id = Dever::input('order_id');
-        $this->set(2, 1);
+        $type = Dever::input('type', 2);
+        $this->set($type, 1);
 
         $info = $this->getView($id, $order_id, false);
 
@@ -184,6 +185,19 @@ class Out
         return 'reload';
     }
 
+    # 取消出库单
+    public function no()
+    {
+        $id = Dever::input('id');
+        $order_id = Dever::input('order_id');
+        $type = Dever::input('type', 2);
+        $this->set($type, 1);
+
+        $this->cancel($id, $order_id);
+
+        return 'reload';
+    }
+
     # 取消出库单
     public function cancel($id, $order_id)
     {
@@ -324,8 +338,15 @@ class Out
             $button[] = array
             (
                 'type' => 'action',
-                'link' => Dever::url('lib/out.yes?id='.$info['type_id'].'&order_id='.$info['id'], 'mshop'),
-                'name' => '审核',
+                'link' => Dever::url('lib/out.yes?id='.$info['type_id'].'&order_id='.$info['id'] . '&type=' . $info['type'], 'mshop'),
+                'name' => '审核通过',
+            );
+
+            $button[] = array
+            (
+                'type' => 'action',
+                'link' => Dever::url('lib/out.no?id='.$info['type_id'].'&order_id='.$info['id'] . '&type=' . $info['type'], 'mshop'),
+                'name' => '审核不通过',
             );
 
             $button[] = array

+ 1 - 0
app/shop/lib/Cron.php

@@ -177,6 +177,7 @@ class Cron
             $config = Dever::db('shop/sell_order')->config;
             foreach ($order as $k => $v) {
                 if ($time - $v['cdate'] >= 900) {
+                    Dever::load('shop/lib/sell')->set(1, 2)->cancel($v['uid'], $v['id'], 11);
                     Dever::db('shop/sell_order')->update(array('where_id' => $v['id'], 'status' => 11, 'notice' => 2));
                 } elseif ($v['notice'] == 1) {
                     Dever::db('shop/sell_order')->update(array('where_id' => $v['id'], 'notice' => 2));

+ 1 - 0
app/shop/lib/Goods.php

@@ -134,6 +134,7 @@ class Goods
             Dever::db($table . '/goods_sku')->update(array('where_id' => $info['id'], 'state' => 1));
         }
 
+        $up['where_sku_id'] = $w['sku_id'];
         $up['where_goods_id'] = $v['goods_id'];
         $up[$num] = $v['num'];
         $state = Dever::db($table . '/goods')->$method($up);

+ 11 - 3
app/shop/lib/Sell.php

@@ -150,7 +150,15 @@ class Sell
             if ($info['time'] >= $m) {
                 # 已过期,自动取消
                 $info['time'] = -1;
-                Dever::db($this->table)->update(array('where_id' => $info['id'], 'status' => 11));
+                //Dever::db($this->table)->update(array('where_id' => $info['id'], 'status' => 11));
+                # 还原库存
+                if ($this->type == 1) {
+                    $this->cancel($info['uid'], $info['id'], 11);
+                } else {
+                    $this->type = 2;
+                    $this->cancel($info['shop_id'], $info['id'], 11);
+                }
+
                 $info['status'] = 11;
             } else {
                 $info['time'] = $m - $info['time'];
@@ -360,11 +368,11 @@ class Sell
     }
 
     # 取消订单
-    public function cancel($id, $order_id)
+    public function cancel($id, $order_id, $status = 7)
     {
         $data = $this->getView($id, $order_id, false);
         if ($data['status'] == 1) {
-            $state = Dever::db('shop/sell_order')->update(array('where_id' => $data['id'], 'status' => 7, 'operdate' => time()));
+            $state = Dever::db('shop/sell_order')->update(array('where_id' => $data['id'], 'status' => $status, 'operdate' => time()));
             if ($state) {
                 if ($data['user_coupon_id']) {
                     # 还原优惠券