dever 4 years ago
parent
commit
c07034afc0
6 changed files with 326 additions and 48 deletions
  1. 9 7
      database/info.php
  2. 172 33
      database/order.php
  3. 15 1
      database/store.php
  4. 34 3
      lib/Info.php
  5. 78 0
      lib/Manage.php
  6. 18 4
      lib/Pay.php

+ 9 - 7
database/info.php

@@ -33,7 +33,7 @@ $shape = array
 	3 => '功能道具',
 );
 
-$type = array
+$platform = array
 (
 	1 => '自营',
 	2 => '淘宝',
@@ -64,7 +64,9 @@ $config = array
 	'lang' => '商品列表',
 	'order' => 200,
 	'auto' => 10000000,
-	'config_type' => $type,
+	'config_platform' => $platform,
+	'config_mode' => $mode,
+	'config_shape' => $shape,
 
 	'end' => array
 	(
@@ -112,15 +114,15 @@ $config = array
 			//'edit'		=> true,
 		),
 
-		'type'		=> array
+		'platform'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '类型',
+			'name' 		=> '平台',
 			'default' 	=> '1',
-			'desc' 		=> '类型',
+			'desc' 		=> '平台',
 			'match' 	=> 'is_numeric',
 			'update'	=> 'radio',
-			'option'	=> $type,
+			'option'	=> $platform,
 			'control'	=> 'type',
 		),
 
@@ -561,7 +563,7 @@ $config = array
                 'id' => 'yes',
             ),
             'type' => 'one',
-            'col' => 'id,name,category,brand_id,shop_id,pic_cover,pic,sell_num+sell_add_num as sell_num,content,type,price_type,price,s_price,num,link,code,mode,goods_area',
+            'col' => 'id,name,category,brand_id,shop_id,pic_cover,pic,sell_num+sell_add_num as sell_num,content,platform,price_type,price,s_price,num,link,code,mode,goods_area',
         ),
 	),
 );

+ 172 - 33
database/order.php

@@ -1,5 +1,14 @@
 <?php
 $system_source = Dever::config('base')->system_source;
+$mode = Dever::db('goods/info')->config['config_mode'];
+$shape = Dever::db('goods/info')->config['config_shape'];
+$platform = Dever::db('goods/info')->config['config_platform'];
+$confirm = array
+(
+	1 => '未确认',
+	2 => '已确认',
+);
+$status = Dever::config('base', 'pay')->pay['status'];
 $config = array
 (
 	# 表名
@@ -7,7 +16,7 @@ $config = array
 	# 显示给用户看的名称
 	'lang' => '商品订单',
 	'order' => 300,
-	'menu' => false,
+	'auto' => 1000000,
 
 	# 数据结构 不同的字段放这里
 	'struct' => array
@@ -29,7 +38,7 @@ $config = array
             'default'   => '0',
             'desc'      => '请选择用户',
             'match'     => 'is_numeric',
-            'update'    => 'text',
+            //'update'    => 'text',
             //'search'  => 'select',
             'search'    => array
             (
@@ -37,7 +46,9 @@ $config = array
                 'col' => 'username',
                 'result' => 'id',
             ),
-            'list'      => '{parent_uid} > 0 ? Dever::load("passport/user-one#username", {parent_uid}) : "无邀请人"',
+            'list_name'	=> '订单详情',
+            'list'		=> 'Dever::load("goods/manage.order", {id})',
+            //'list'      => '{parent_uid} > 0 ? Dever::load("passport/user-one#username", {parent_uid}) : "无邀请人"',
         ),
 
 		'uid'       => array
@@ -47,7 +58,7 @@ $config = array
             'default'   => '0',
             'desc'      => '请选择用户',
             'match'     => 'is_numeric',
-            'update'    => 'text',
+            //'update'    => 'text',
             //'search'  => 'select',
             'search'    => array
             (
@@ -55,7 +66,7 @@ $config = array
                 'col' => 'username',
                 'result' => 'id',
             ),
-            'list'      => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+            //'list'      => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
         ),
 
         'type' 		=> array
@@ -65,7 +76,7 @@ $config = array
 			'default' 	=> '',
 			'desc' 		=> '所属数据源',
 			'match' 	=> 'is_string',
-			'list'		=> true,
+			//'list'		=> true,
 		),
 		
 		'type_id' 		=> array
@@ -74,8 +85,8 @@ $config = array
 			'name' 		=> '数据源id',
 			'default' 	=> '',
 			'desc' 		=> '数据源id',
-			'match' 	=> 'is_numeric',
-			'list'		=> true,
+			//'match' 	=> 'is_numeric',
+			//'list'		=> true,
 		),
 
 		'info_id'		=> array
@@ -85,8 +96,30 @@ $config = array
 			'default' 	=> '',
 			'desc' 		=> '商品ID',
 			'match' 	=> 'is_numeric',
-			'update'	=> 'text',
-			'list'		=> true,
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'platform'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '平台',
+			'default' 	=> '1',
+			'desc' 		=> '平台',
+			'match' 	=> 'is_numeric',
+			'option'	=> $platform,
+			'search'	=> 'select',
+		),
+
+		'shape'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '形态',
+			'default' 	=> '1',
+			'desc' 		=> '形态',
+			'match' 	=> 'is_numeric',
+			'option'	=> $shape,
+			'search'	=> 'select',
 		),
 
 		'sku_id'		=> array
@@ -96,8 +129,8 @@ $config = array
 			'default' 	=> '',
 			'desc' 		=> '商品SKUID',
 			'match' 	=> 'is_numeric',
-			'update'	=> 'text',
-			'list'		=> true,
+			//'update'	=> 'text',
+			//'list'		=> true,
 		),
 
 		'order_id'		=> array
@@ -107,8 +140,9 @@ $config = array
 			'default' 	=> '',
 			'desc' 		=> '订单id',
 			'match' 	=> 'is_string',
-			'update'	=> 'text',
-			'list'		=> true,
+			'search'	=> 'text',
+			//'update'	=> 'text',
+			//'list'		=> true,
 		),
 
 		'name'		=> array
@@ -118,19 +152,20 @@ $config = array
 			'default' 	=> '',
 			'desc' 		=> '商品名称',
 			'match' 	=> 'is_string',
-			'update'	=> 'text',
-			'list'		=> true,
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
 		),
 
 		'cash'		=> array
 		(
-			'type' 		=> 'varchar-100',
+			'type' 		=> 'decimal-10,2',
 			'name' 		=> '价格',
 			'default' 	=> '',
 			'desc' 		=> '价格',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-			'list'		=> true,
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
 		),
 
 		'num'		=> array
@@ -139,9 +174,90 @@ $config = array
 			'name' 		=> '数量',
 			'default' 	=> '',
 			'desc' 		=> '数量',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'mode'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '配送方式',
+			'default' 	=> '-1',
+			'desc' 		=> '配送方式',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'select',
+			'option'	=> $mode,
+		),
+
+		'username'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系人',
+			'default' 	=> '',
+			'desc' 		=> '详细地址',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'mobile'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系电话',
+			'default' 	=> '',
+			'desc' 		=> '联系电话',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'area_id'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '地区',
+			'default' 	=> '',
+			'desc' 		=> '地区',
 			'match' 	=> 'is_string',
-			'update'	=> 'text',
+			'search'	=> 'linkage',
+			//'update'	=> 'linkage',
+			'option'	=> Dever::url('api.get', 'area'),
+			//'show'		=> 'mode=1',
+			//'list'		=> 'Dever::load("area/api.string", "{area_id}")',
+		),
+
+		'address'		=> array
+		(
+			'type' 		=> 'varchar-1000',
+			'name' 		=> '详细地址',
+			'default' 	=> '',
+			'desc' 		=> '详细地址',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'store_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '自提点',
+			'default' 	=> '',
+			'desc' 		=> '自提点',
+			'match' 	=> 'option',
+		),
+
+		'confirm'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '确认收货',
+			'default' 	=> '1',
+			'desc' 		=> '确认收货',
+			'match' 	=> 'is_numeric',
+			'option'	=> $confirm,
 			'list'		=> true,
+			'edit'		=> true,
 		),
 
 		'freight_id'		=> array
@@ -151,31 +267,37 @@ $config = array
 			'default' 	=> '',
 			'desc' 		=> '运费模板',
 			'match' 	=> 'is_string',
-			'update'	=> 'text',
 		),
 
 		'freight_price'		=> array
 		(
-			'type' 		=> 'varchar-100',
+			'type' 		=> 'decimal-10,2',
 			'name' 		=> '运费',
 			'default' 	=> '',
 			'desc' 		=> '运费',
-			'match' 	=> 'is_string',
+			'match' 	=> 'option',
+		),
+
+		'price'		=> array
+		(
+			'type' 		=> 'decimal-10,2',
+			'name' 		=> '最终付款价格',
+			'default' 	=> '',
+			'desc' 		=> '最终付款价格',
+			'match' 	=> 'option',
 			'update'	=> 'text',
-			'list'		=> true,
 		),
 
 		'system_source'     => array
         (
             'type'      => 'tinyint-1',
-            'name'      => '所属平台',
+            'name'      => '所属终端',
             'default'   => '1',
-            'desc'      => '所属平台',
+            'desc'      => '所属终端',
             'match'     => 'is_numeric',
             'option'    => $system_source,
-            'update'    => 'radio',
+            //'update'    => 'radio',
             'search'    => 'select',
-            'list'      => true,
         ),
 
 		'status'		=> array
@@ -185,6 +307,10 @@ $config = array
 			'default' 	=> '1',
 			'desc' 		=> '订单状态',
 			'match' 	=> 'is_numeric',
+			//'update'	=> 'radio',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'      => true,
 		),
 
 		'state'		=> array
@@ -196,23 +322,36 @@ $config = array
 			'match' 	=> 'is_numeric',
 		),
 
+		'pay_time'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '付款时间',
+            'default'   => '',
+            'desc'      => '付款时间',
+            'match'     => 'option',
+            'search'	=> 'date',
+            'list'      => '"{pay_time}" ? date("Y-m-d H:i:s", {pay_time}) : ""',
+            //'update'    => 'date',
+            //'callback'  => 'maketime',
+        ),
+
 		'cdate'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '发布时间',
+			'name' 		=> '申请时间',
 			'match' 	=> array('is_numeric', time()),
 			'desc' 		=> '',
 			# 只有insert时才生效
 			'insert'	=> true,
-			//'search'	=> 'date',
-			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+			'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 		),
 	),
 
 	'manage' => array
     (
         'insert' => false,
-        'edit' => false,
+        //'edit' => false,
         'delete' => false,
     ),
 

+ 15 - 1
database/store.php

@@ -107,6 +107,20 @@ return array
 
     'request' => array
     (
-        
+        # 列表
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'category' => 'yes',
+                'area' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'limit' => '0,10',
+            'col' => '*',
+        ),
     )
 );

+ 34 - 3
lib/Info.php

@@ -265,6 +265,37 @@ class Info
         return $info;
     }
 
+    # 获取自提信息
+    public function storeInfo($goods_id, $area_id = '')
+    {
+        $info = Dever::db($this->table_info)->getOne($goods_id);
+        if (!$info) {
+            return array();
+        }
+        $array = explode(',', $info['category']);
+        $cate = $store = array();
+        $total = count($array);
+        $total -= 1;
+        # 用户所在地理位置 
+        if ($area_id) {
+            $where['area'] = $area_id;
+        }
+        foreach ($array as $k => $v) {
+            $cate[$k] = $v;
+            if ($k < $total) {
+                $cate[] = '-1';
+            }
+            $where['category'] = $cate;
+
+            $data = Dever::db('goods/store')->state($where);
+            if ($data) {
+                $store += $data;
+            }
+        }
+
+        return $store;
+    }
+
     # 获取基本信息
     public function getInfo($id, $attr = true, $order = 'view_reorder', $user = array())
     {
@@ -336,7 +367,7 @@ class Info
             $info['price']['max'] = array();
         }
 
-        $info['type_name'] = Dever::db('goods/info')->config['config_type'][$info['type']];
+        $info['platform_name'] = Dever::db('goods/info')->config['config_platform'][$info['platform']];
        
         if (isset($info['cdate']) && $info['cdate']) {
             $info['cdate_string'] = Dever::mdate($info['cdate'], 2);
@@ -345,7 +376,7 @@ class Info
         $info = $this->getInfoLink($info);
 
         $info['freight'] = 0;
-        if ($info['type'] == 1) {
+        if ($info['platform'] == 1) {
             # 获取运费
             $info['freight'] = $this->freight($info, $info['price']['min']['price'], $user);
         }
@@ -389,7 +420,7 @@ class Info
             }
 
             if ($freight['type'] == 2) {
-                $freight['price'] = $goods_price*($price/100);
+                $freight['price'] = $goods_price*$num*($price/100);
             } else {
                 $freight['price'] = $price;
             }

+ 78 - 0
lib/Manage.php

@@ -150,6 +150,84 @@ class Manage
         return Dever::table($table);
     }
 
+    /**
+     * 显示订单信息
+     *
+     * @return mixed
+     */
+    public function order($id)
+    {
+        $info = Dever::db('goods/order')->one($id);
+        if ($info) {
+            $table['编号'] = $info['id'];
+            $table['订单号'] = $info['order_id'];
+            $config = Dever::db('goods/info')->config;
+            $table['平台'] = $config['platform'];
+            $table['形态'] = $config['shape'];
+            if ($info['type'] == 'collection') {
+                $user = Dever::load('user/lib/info')->get($info['uid'], $info['type_id']);
+            } else {
+                $user = Dever::load('passport/api')->info($info['uid']);
+            }
+            
+            $table['购买人'] = $user['username'] . '('.$user['mobile'].')';
+
+            if ($info['parent_uid']) {
+                if ($info['type'] == 'collection') {
+                    $user = Dever::load('user/lib/info')->get($info['parent_uid'], $info['type_id']);
+                } else {
+                    $user = Dever::load('passport/api')->info($info['parent_uid']);
+                }
+                
+                $table['邀请人'] = $user['username'] . '('.$user['mobile'].')';
+            }
+
+            $table['商品名'] = $info['name'];
+            if ($info['sku_id']) {
+                $sku = Dever::db('goods/info_sku')->one($info['sku_id']);
+            }
+
+            $table['总价'] = $info['price'] . '元';
+            $table['单价'] = $info['cash'] . '元';
+            $table['数量'] = $info['num'];
+
+            if ($info['mode'] > 0) {
+                $mode = $config['config_mode'];
+                $mode = $mode[$info['mode']];
+                $table['配送方式'] = $mode;
+
+                if ($info['area_id']) {
+                    $info['address'] = Dever::load('area/api')->string($info['area_id'], '') . $info['address'];
+                }
+
+                if ($info['address'] && $info['mode'] == 1) {
+                    $table['配送地址'] = $info['address'];
+                    $table['联系人'] = $info['username'];
+                    $table['联系电话'] = $info['mobile'];
+                    $table['运费'] = $info['freight_price'];
+                    if ($info['confirm'] == 1) {
+                        $table['自提码'] = '未提';
+                    } else {
+                        $table['自提码'] = '已提';
+                    }
+                }
+
+                if ($info['store_id'] && $info['mode'] == 2) {
+                    $store = Dever::db('goods/store')->one($info['store_id']);
+                    $table['自提点'] = $store['name'];
+                    $table['自提码'] = $info['id'];
+                    if ($info['confirm'] == 1) {
+                        $table['自提码'] = '未提';
+                    } else {
+                        $table['自提码'] = '已提';
+                    }
+                }
+            }
+        }
+
+        return Dever::table($table);
+    }
+
     private function attrInfo($info)
     {
         $table = array();

+ 18 - 4
lib/Pay.php

@@ -9,7 +9,7 @@ use Dever;
 class Pay
 {
     # 发起支付
-	public function action($parent_uid, $user, $id, $sku, $num, $address_id, $system_source, $type = false, $type_id = false)
+	public function action($parent_uid, $user, $id, $sku, $num, $mode, $store_id, $system_source, $type = false, $type_id = false)
     {
         if (!$user) {
             Dever::alert('错误的用户信息');
@@ -28,16 +28,29 @@ class Pay
         }
         $order_data['type'] = $type;
         $order_data['type_id'] = $type_id;
+        $order_data['name'] = $goods['name'];
         $order_data['uid'] = $uid;
         $order_data['status'] = 1;
         $order_data['info_id'] = $goods['id'];
         $order_data['sku_id'] = $sku;
-        $order_data['address_id'] = $address_id;
-        $order_data['name'] = $goods['name'];
+        $order_data['mode'] = $mode;
+        $order_data['platform'] = $goods['platform'];
+        $order_data['shape'] = $goods['shape'];
+        $order_data['area_id'] = $user['area_id'];
+        $order_data['address'] = $user['address'];
+        $order_data['username'] = $user['address_contact'];
+        $order_data['mobile'] = $user['address_mobile'];
+
+        $order_data['store_id'] = $store_id;
         $order_data['cash'] = $goods['price'];
         $order_data['freight_id'] = $goods['freight_id'];
         $order_data['freight_price'] = $goods['freight_price'];
         $order_data['num'] = $num;
+        $price = $order_data['cash'] * $order_data['num'];
+        if ($mode == 1) {
+            $price += $order_data['freight_price'];
+        }
+        $order_data['price'] = $price;
         $order_data['system_source'] = $system_source;
         $order_data['order_id'] = $this->getOrderId();
         print_r($order_data);die;
@@ -54,7 +67,7 @@ class Pay
             'system_source' => $system_source,
             'uid' => $uid,
             'name' => $order_data['name'],
-            'cash' => $order_data['cash'] * $order_data['num'],
+            'cash' => $price,
             'product_id' => $goods['id'],
             'order_id' => $order_data['order_id'],
         );
@@ -127,6 +140,7 @@ class Pay
 
             $update['status'] = $status;
             $update['where_id'] = $order['id'];
+            $update['pay_time'] = time();
             Dever::db('goods/order')->update($update);
         }