rabin 6 months ago
parent
commit
c894dc3b47

+ 2 - 2
src/place/api/Order.php

@@ -23,7 +23,7 @@ class Order extends Main
     # 查看订单详情
     public function getView()
     {
-        $info = $this->act->getInfo();
-        return Dever::load('order', 'goods')->getView($info);
+        $data['info'] = $this->act->getView(array('order_num', 'status', 'cash', 'num'));
+        return $data;
     }
 }

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

@@ -10,6 +10,7 @@ class Act
         $this->type = Dever::input('type');
         $this->type_id = Dever::input('type_id');
         $this->db = Dever::db($name, 'place');
+        $this->app = Dever::config('setting')['type'][$this->type];
     }
 
     protected function check()
@@ -40,14 +41,21 @@ class Act
     }
 
     # 获取用户互动相关的信息
-    public function getInfo($data = array())
+    public function getInfo($data = array(), $field = array())
     {
         $this->check();
         $this->data = $data;
         $this->data['type'] = $this->type;
         $this->data['type_id'] = $this->type_id;
         $this->data['uid'] = Place::$uid;
-        return $this->db->find($this->data);
+        return $this->handleInfo($this->db->find($this->data), $field);
+    }
+
+    # 获取详情页
+    public function getView($field = array())
+    {
+        $info = $this->getInfo(array(), $field);
+        return Dever::load('order', $this->app)->getView($info);
     }
 
     # 评论列表
@@ -84,36 +92,8 @@ class Act
         $result = array();
         if ($data) {
             foreach ($data as $k => $v) {
-                $info = $this->getTypeInfo($v['type'], $v['type_id']);
+                $info = $this->handleInfo($v, $field);
                 if ($info) {
-                    $info['status_name'] = $this->db->value('status', $v['status']);
-                    $info['type'] = $v['type'];
-                    $info['type_id'] = $v['id'];
-                    //$info['cdate'] = $v['cdate'];
-                    $info['cdate_str'] = date('Y-m-d H:i:s', $v['cdate']);
-                    if ($field) {
-                        foreach ($field as $v1) {
-                            $info[$v1] = $v[$v1];
-                        }
-                    }
-                    if (strstr($this->db->config['load'], 'order')) {
-                        $info['cash'] = Dever::load('price', 'place')->getText($info['cash'], $info['type']);
-                        if ($v['type'] == 3) {
-                            $info['detail'] = Dever::load('order', 'goods')->getDetail($v['id']);
-                            $info['info'] = '共' . intval($info['num']) . '件商品';
-                        } else {
-                            $detail['id'] = $info['id'];
-                            $detail['name'] = $info['name'];
-                            $detail['pic'] = $info['pic'];
-                            $detail['sku_name'] = '';
-                            $detail['sku_id'] = 0;
-                            $detail['cash'] = $info['cash'];
-                            $detail['num'] = $info['num'];
-                            $info['detail'][] = $detail;
-                            $info['info'] = '';
-                        }
-                    }
-                    
                     $result[] = $info;
                 }
             }
@@ -132,4 +112,42 @@ class Act
             return $info;
         }
     }
+
+    private function handleInfo($v, $field = array())
+    {
+        if (!$v) {
+            return array();
+        }
+        $info = $this->getTypeInfo($v['type'], $v['type_id']);
+        if ($info) {
+            $info['status_name'] = $this->db->value('status', $v['status']);
+            $info['type'] = $v['type'];
+            $info['type_id'] = $v['id'];
+            //$info['cdate'] = $v['cdate'];
+            $info['cdate_str'] = date('Y-m-d H:i:s', $v['cdate']);
+            if ($field) {
+                foreach ($field as $v1) {
+                    $info[$v1] = $v[$v1];
+                }
+            }
+            if ($this->db->config['load'] == 'place/order') {
+                $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']);
+                    $info['info'] = '共' . intval($info['num']) . '件商品';
+                } else {
+                    $detail['id'] = $info['id'];
+                    $detail['name'] = $info['name'];
+                    $detail['pic'] = $info['pic'];
+                    $detail['sku_name'] = '';
+                    $detail['sku_id'] = 0;
+                    $detail['cash'] = $info['cash'];
+                    $detail['num'] = $info['num'];
+                    $info['detail'][] = $detail;
+                    $info['info'] = '';
+                }
+            }
+            return $info;
+        }
+    }
 }

+ 1 - 0
src/place/lib/Price.php

@@ -40,6 +40,7 @@ class Price
         }
         $result['original'] = $result['original'] * $result['num'];
         $result['value'] = $result['value'] * $result['num'];
+        $result['original'] = $this->getText($result['original'], $type);
         $result['text'] = $this->getText($result['value'], $type);
         return $result;
     }

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

@@ -30,7 +30,7 @@ class Info
 
     public function submit($info, $type = 'price')
     {
-        $sku_id = Dever::input('sku_id', 'is_numeric', '价格');
+        $sku_id = Dever::input('sku_id');
         $result = $info[$type];
         $result['id'] = $info['id'];
         $result['name'] = $info['name'];
@@ -50,8 +50,6 @@ class Info
                 $detail['id'] = $result['id'];
                 $detail['name'] = $result['name'];
                 $result['detail'][] = $detail;
-            } else {
-                Dever::error('下单失败');
             }
         }
         return $result;

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

@@ -18,7 +18,34 @@ class Order
     # 获取订单详情
     public function getView($info)
     {
-        $info['detail'] = $this->getDetail($info['id']);
+        $info['status_list'] = array
+        (
+            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;
     }
 }