dever 3 anos atrás
pai
commit
1accae07bf
3 arquivos alterados com 62 adições e 0 exclusões
  1. 36 0
      app/mshop/lib/Buy.php
  2. 17 0
      app/mshop/src/Buy.php
  3. 9 0
      app/shop/database/buy_order.php

+ 36 - 0
app/mshop/lib/Buy.php

@@ -377,6 +377,42 @@ class Buy
         return 'ok';
     }
 
+    # 发货
+    public function fahuo_api()
+    {
+        $id = Dever::input('id');
+        $process = Dever::input('process', 3);
+        $info = Dever::db('shop/buy_order_tui')->find($id);
+
+        if ($info && $info['process'] == 1) {
+            $update['process'] = $process;
+            $update['where_id'] = $info['id'];
+            $state = Dever::db('shop/buy_order_tui')->update($update);
+
+            if ($state && $process == 2) {
+                $data = $this->getView($info['shop_id'], $info['order_id'], false);
+                if ($data) {
+                    if ($info['order_goods_id'] > 0) {
+                        $state = Dever::db('shop/buy_order_goods')->update(array('where_id' => $info['order_goods_id'], 'status' => 3));
+                        $this->pay_tui($state, $data, $info['cash']);
+
+                        # 检查这个订单下的商品是不是都退了
+                        $total = Dever::db('shop/buy_order_goods')->total(array('order_id' => $info['order_id'], 'shop_id' => $id, 'status' => 1));
+                        if ($total <= 0) {
+                            $state = Dever::db('shop/buy_order')->update(array('where_id' => $info['order_id'], 'status' => 8));
+                        }
+                    } else {
+                        # 全部退款
+                        $state = Dever::db('shop/buy_order')->update(array('where_id' => $info['order_id'], 'status' => 8));
+                        $this->pay_tui($state, $data, $info['cash']);
+                    }
+                }
+            }
+        }
+
+        return 'ok';
+    }
+
     # 申请退款
     public function tui_action($shop_id, $order_id, $order_goods_id, $status, $price, $num = false, $desc = '', $pic = '')
     {

+ 17 - 0
app/mshop/src/Buy.php

@@ -153,6 +153,23 @@ class Buy extends Core
         return Dever::load('mshop/lib/buy')->tui_one($this->shop_id, $order_id, $order_goods_id, $num, $status, $desc, $pic);
     }
 
+    # 收货确认
+    public function finish()
+    {
+        $order_id = Dever::input('order_id');
+
+        $info = Dever::db('shop/buy_order')->find(array('shop_id' => $this->shop_id, 'id' => $order_id));
+
+        if ($info && $info['status'] == 4) {
+
+            $state = Dever::db('shop/sell_order')->update(array('where_id' => $info['id'], 'status' => 5, 'qsdate' => time()));
+
+            return 'ok';
+        } else {
+            Dever::alert('您没有权限');
+        }
+    }
+
     # 测试审核拆单
     public function audit()
     {

+ 9 - 0
app/shop/database/buy_order.php

@@ -242,6 +242,15 @@ return array
             'match'     => 'is_numeric',
             'desc'      => '',
         ),
+
+        'qsdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '确认收货时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+        ),
         
         'cdate'     => array
         (