rabin 6 months ago
parent
commit
e28efa1212
4 changed files with 72 additions and 27 deletions
  1. 31 2
      src/place/lib/Act.php
  2. 12 0
      src/place/table/order.php
  3. 1 0
      src/resource/goods/lib/Info.php
  4. 28 25
      src/resource/goods/lib/Order.php

+ 31 - 2
src/place/lib/Act.php

@@ -54,7 +54,8 @@ class Act
     # 获取详情页
     public function getView($field = array())
     {
-        $info = $this->getInfo(array(), $field);
+        $data['id'] = Dever::input('data_id', 'is_numeric', 'ID');
+        $info = $this->getInfo($data, $field);
         return Dever::load('order', $this->app)->getView($info);
     }
 
@@ -120,9 +121,11 @@ class Act
         }
         $info = $this->getTypeInfo($v['type'], $v['type_id']);
         if ($info) {
+            $info['status'] = $v['status'];
             $info['status_name'] = $this->db->value('status', $v['status']);
             $info['type'] = $v['type'];
-            $info['type_id'] = $v['id'];
+            $info['type_id'] = $v['type_id'];
+            $info['data_id'] = $v['id'];
             //$info['cdate'] = $v['cdate'];
             $info['cdate_str'] = date('Y-m-d H:i:s', $v['cdate']);
             if ($field) {
@@ -131,6 +134,19 @@ class Act
                 }
             }
             if ($this->db->config['load'] == 'place/order') {
+                if ($v['status'] == 1) {
+                    $m = 3600;
+                    # 支付倒计时
+                    $info['time'] = time() - $v['cdate'];
+                    if ($info['time'] >= $m) {
+                        # 已过期,自动取消
+                        $info['time'] = -1;
+                        $this->cancel($info);
+                        $info['status'] = 10;
+                    } else {
+                        $info['time'] = $m - $info['time'];
+                    }
+                }
                 $info['cash'] = Dever::load('price', 'place')->getText($info['cash'], $info['type']);
                 if ($v['type'] == 3) {
                     $info['detail'] = Dever::load('order', $this->app)->getDetail($v['id']);
@@ -150,4 +166,17 @@ class Act
             return $info;
         }
     }
+
+    # 取消订单
+    public function cancel($order, $status = 9)
+    {
+        if ($order['status'] == 1) {
+            $state = Dever::db('order', 'place')->update($order['data_id'], array('status' => $status, 'fdate' => time()));
+            if ($state) {
+                # 恢复库存
+            }
+
+            return 'ok';
+        }
+    }
 }

+ 12 - 0
src/place/table/order.php

@@ -71,6 +71,18 @@ return array
             'type'      => 'int(11)',
             'name'      => '付款时间',
         ),
+
+        'ddate'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '发货时间',
+        ),
+
+        'fdate'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '完成时间',
+        ),
     ),
 
     'index' => array

+ 1 - 0
src/resource/goods/lib/Info.php

@@ -20,6 +20,7 @@ class Info
         }
         $sku = Dever::load('sku', 'api')->getPrice($where, $info['spec_type'], 'goods');
         $info['price'] = $sku['price'];
+        $info['sku'] = $sku;
         $info['sku_name'] = $sku['name'];
         $info['sku_id'] = $sku['id'];
         if (Dever::input('show_sku')) {

+ 28 - 25
src/resource/goods/lib/Order.php

@@ -18,32 +18,35 @@ class Order
     # 获取订单详情
     public function getView($info)
     {
-        $info['status_list'] = array
-        (
-            1 => array
+        if ($info) {
+            $info['yun'] = Dever::load('price', 'place')->getText(0, 3);
+            $info['status_list'] = array
             (
-                'selected' => false,
-                'name' => '已拍下',
-            ),
-            2 => array
-            (
-                'selected' => false,
-                'name' => '待付款',
-            ),
-            3 => array
-            (
-                'selected' => false,
-                'name' => '待发货',
-            ),
-            4 => array
-            (
-                'selected' => false,
-                'name' => '待收货',
-            ),
-        );
-        foreach ($info['status_list'] as $k => &$v) {
-            if ($info['status'] >= $k) {
-                $v['selected'] = true;
+                1 => array
+                (
+                    'selected' => false,
+                    'name' => '已拍下',
+                ),
+                2 => array
+                (
+                    'selected' => false,
+                    'name' => '待付款',
+                ),
+                3 => array
+                (
+                    'selected' => false,
+                    'name' => '待发货',
+                ),
+                4 => array
+                (
+                    'selected' => false,
+                    'name' => '待收货',
+                ),
+            );
+            foreach ($info['status_list'] as $k => &$v) {
+                if ($info['status'] >= $k) {
+                    $v['selected'] = true;
+                }
             }
         }
         return $info;