rabin 6 months ago
parent
commit
0a7dd44523

+ 27 - 0
src/place/api/Order.php

@@ -0,0 +1,27 @@
+<?php namespace Place\Api;
+use Dever;
+use Place;
+use Place\Lib\Main;
+use Place\Lib\Act;
+class Order extends Main
+{
+    protected $login = true;
+    protected $entry = true;
+
+    public function __construct()
+    {
+        parent::__construct();
+        $this->act = new Act('order');
+    }
+
+    public function getUserList()
+    {
+        return $this->act->getUserList(array('order_num', 'status', 'cash', 'num'));
+    }
+
+    # 查看订单详情
+    public function detail()
+    {
+        
+    }
+}

+ 1 - 1
src/place/api/Resource.php

@@ -53,7 +53,7 @@ class Resource extends Main
         $info = $this->service->getInfo($id);
         $info = Dever::load('info', $this->service->app)->submit($info);
         if ($info['status'] == 2) {
-            return Dever::load('order', 'place')->pay($info, $this->service->type, $this->service->app);
+            return $this->service->pay($info);
         } else {
             Dever::error('无权限');
         }

+ 20 - 0
src/place/api/Task.php

@@ -0,0 +1,20 @@
+<?php namespace Api\Api;
+use Dever;
+class Task
+{
+    # 定时更新
+    public function func()
+    {
+        $where['status'] = 1;
+        $where['cron_time'] = array('>', '0');
+        $data = Dever::db('app_func', 'api')->select($where);
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $account = Dever::db('account', 'api')->find(array('app_id' => $v['app_id']));
+                if ($account) {
+                    Dever::load('account', 'api')->run($account, $v);
+                }
+            }
+        }
+    }
+}

+ 1 - 1
src/place/boot.php

@@ -51,7 +51,7 @@ class Place
     public static function info($user_id, $place_id)
     {
         $user = Dever::db('user', 'sector')->find($user_id);
-        self::$info = Dever::db('info', 'place')->find($place_id, array('col' => 'name,logo,content,score as score_name,score_per,bg,type,vip_name,agent_name,money_id,uid'));
+        self::$info = Dever::db('info', 'place')->find($place_id, array('col' => 'name,logo,content,score as score_name,score_per,bg,type,vip_name,agent_name,money_id,uid,pay_account'));
         if (!self::$info) {
             Dever::error('信息有误');
         }

+ 55 - 0
src/place/lib/Account.php

@@ -0,0 +1,55 @@
+<?php namespace Place\Lib;
+use Dever;
+use Place;
+class Account
+{
+    # 下单操作
+    public function pay($order)
+    {
+        $account = Dever::input('account', 'is_string', '账户', 'wechat');
+        $env = Dever::input('env', 'is_numeric', '运行环境', 3);
+        $result = Dever::load('util', 'api')->openid($account, $env, Place::$uid);
+        if (isset($result['openid'])) {
+            $order['openid'] = $result['openid'];
+        } elseif (isset($result['link'])) {
+            return $result;
+        }
+
+        $account = 'pay_' . $account;
+        $project = 'api';
+
+        if (Place::$info['pay_account'] > 0) {
+            $info = $this->getInfo(Place::$info['pay_account']);
+            if ($info) {
+                $account = $info;
+                $project = 'place';
+                $cert = Dever::db('account_cert', 'place')->find(array('account_id' => $info['id'], 'platform_cert_id' => 2));
+                if (!$cert || ($cert && $cert['edate'] <= time())) {
+                    Dever::load('account', 'api')->run($account, 'task', array(), 1, 'run', $project);
+                }
+            }
+        }
+
+        $order['cash'] = $order['cash']*100;
+        $order['time_expire'] = time() + 3600;
+
+        return Dever::load('account', 'api')->run($account, 'order', $order, $env, 'run', $project);
+    }
+
+    # 获取账户信息
+    public function getInfo($id)
+    {
+        $info = Dever::db('account', 'place')->find($id);
+        if ($info) {
+            if ($info['type'] == 1) {
+                $key = 'pay_wechat';
+            } else {
+                Dever::error('错误信息');
+            }
+            $account = Dever::db('account', 'api')->find(array('key' => $key));
+            $info['app_id'] = $account['app_id'];
+            $info['platform_id'] = $account['platform_id'];
+            return $info;
+        }
+    }
+}

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

@@ -95,7 +95,7 @@ class Act
                         }
                     }
                     if ($v['type'] == 3) {
-                        $info['detail'] = Dever::load('order', 'place')->getDetail($v['id']);
+                        $info['detail'] = Dever::load('order', 'goods')->getDetail($v['id']);
                     }
                     $result[] = $info;
                 }
@@ -109,7 +109,9 @@ class Act
         $app = Dever::config('setting')['type'][$type];
         if ($type > 0) {
             $db = Dever::db('info', $app);
-            $info = $db->find($type_id);
+            $info = $db->find($type_id, array('col' => 'id,name,pic,info'));
+            $info['pic'] = explode(',', $info['pic']);
+            $info['pic'] = $info['pic'][0] ?? '';
             return $info;
         }
     }

+ 27 - 0
src/place/lib/Callback.php

@@ -0,0 +1,27 @@
+<?php namespace Place\Lib;
+use Dever;
+use Place;
+class Callback
+{
+    # 资源支付成功
+    public function resource($place, $order_num, $type, $status, $body = array())
+    {
+        Dever::input('authorization', 'is_string', '入口码', $place);
+        $order = Dever::db('order', 'place')->find(array('type' => $type, 'order_num' => $order_num));
+        if ($order && $order['status'] == 1) {
+            if ($status == 1) {
+                $update['status'] = 5;
+                if ($type == 3) {
+                    $update['status'] = 2;
+                }
+            } else {
+                $update['status'] = 7;
+            }
+            $update['pdate'] = time();
+            $state = Dever::db('order', 'place')->update($order['id'], $update);
+            if (!$state) {
+                return '订单更新失败';
+            }
+        }
+    }
+}

+ 21 - 0
src/place/lib/Manage.php

@@ -148,4 +148,25 @@ class Manage extends Auth
         }
         return implode('<br />', $result);
     }
+
+    # 获取支付账户列表
+    public function getAccountList($uid = false)
+    {
+        $data = array
+        (
+            0 => array
+            (
+                'id' => -1,
+                'name' => '平台默认账户',
+            ),
+        );
+        if ($uid) {
+            $where['uid'] = $uid;
+        } else {
+            $extend = Dever::load('common', 'manage')->extend();
+            $where['uid'] = $extend['data_id'];
+        }
+        $data = array_merge($data, Dever::db('account', 'place')->select($where));
+        return $data;
+    }
 }

+ 0 - 113
src/place/lib/Order.php

@@ -1,113 +0,0 @@
-<?php namespace Place\Lib;
-use Dever;
-use Place;
-class Order
-{
-    # 下单
-    public function pay($info, $type = 1, $app)
-    {
-        $prefix = strtoupper(substr($app, 0, 2));
-        $account = Dever::input('account', 'is_string', '账户', 'wechat');
-        $env = Dever::input('env', 'is_numeric', '运行环境', 3);
-        $result = Dever::load('util', 'api')->openid($account, $env, Place::$uid);
-        if (isset($result['openid'])) {
-            Place::$user['openid'] = $result['openid'];
-        } elseif (isset($result['link'])) {
-            return $result;
-        }
-
-        if ($type == 3) {
-            $price = $info['value'];
-        } else {
-            $price = ($info['value']/Place::$info['score_per']);
-        }
-        
-        # 支付账户
-        $account = 'pay_' . $account;
-        # 下单
-        $order = array
-        (
-            'uid' => Place::$uid,
-            'openid' => Place::$user['openid'] ?? '',
-            'order_num' => Dever::load('util', 'api')->createNumber($prefix, 'place/order', array('type' => $type)),
-            'cash' => $price*100,
-            'name' => $info['name'],
-            'time_expire' => time() + 3600,
-        );
-        # 设置支付成功的回调信息,多个参数用|隔开
-        $param['notify'] = 'place/order.success|' . Dever::input('p') . '|' . $order['order_num'] . '|' . $type;
-        $data['pay'] = Dever::load('account', 'api')->run($account, 'order', $order, $env);
-        if ($data['pay']) {
-            $order['status'] = 1;
-            $order['type'] = $type;
-            $order['type_id'] = $info['id'];
-            $data['order_id'] = Dever::db('order', 'place')->insert($order);
-            $data['order_num'] = $order['order_num'];
-            if (isset($info['detail'])) {
-                $detail['type'] = $type;
-                foreach ($info['detail'] as $k => $v) {
-                    $detail['type_id'] = $v['id'];
-                    if (isset($v['sku_id'])) {
-                        $detail['sku_id'] = $v['sku_id'];
-                    }
-                    if (isset($v['sku_name'])) {
-                        $detail['sku_name'] = $v['sku_name'];
-                    }
-                    $detail['order_id'] = $data['order_id'];
-                    $detail['cash'] = $v['cash'];
-                    $detail['num'] = $v['num'];
-                    $detail['name'] = $v['name'];
-                    $detail['pic'] = $v['pic'];
-                    Dever::db('order_detail', 'place')->insert($detail);
-                }
-            }
-        }
-        return $data;
-    }
-
-    # 支付成功
-    public function success($place, $order_num, $type, $status, $body = array())
-    {
-        Dever::input('authorization', 'is_string', '入口码', $place);
-        $order = Dever::db('order', 'place')->find(array('type' => $type, 'order_num' => $order_num));
-        if ($order && $order['status'] == 1) {
-            if ($type == 3) {
-                if ($status == 1) {
-                    $update['status'] = 5;
-                } else {
-                    $update['status'] = 7;
-                }
-            } else {
-                if ($status == 1) {
-                    $update['status'] = 2;
-                } else {
-                    $update['status'] = 7;
-                }
-            }
-            
-            $update['pdate'] = time();
-            $state = Dever::db('order', 'place')->update($order['id'], $update);
-            if (!$state) {
-                return '订单更新失败';
-            }
-        }
-    }
-
-    # 获取某个资源的订单
-    public function getInfoByType($type_id, $type, $status = 5)
-    {
-        $order = Dever::db('order', 'place')->find(array('type' => $type, 'type_id' => $type_id, 'uid' => Place::$uid, 'status' => $status));
-        return $order;
-    }
-
-    # 获取某个订单的详情
-    public function getDetail($id, $type)
-    {
-        $detail = Dever::db('order_detail', 'place')->select(array('type' => $type, 'order_id' => $id));
-        $result = array();
-        if ($detail) {
-
-        }
-        return $result;
-    }
-}

+ 3 - 3
src/place/lib/Price.php

@@ -12,7 +12,7 @@ class Price
         $result['value'] = $info['price'];
         $result['button'] = $button;
         $result['list'] = array();
-        $order = Dever::load('order', 'place')->getInfoByType($info['id'], $type);
+        $order = Dever::db('order', 'place')->find(array('type' => $type, 'type_id' => $info['id'], 'uid' => Place::$uid, 'status' => 5));
         if ($order) {
             $result['value'] = $order['cash'];
         } else {
@@ -83,11 +83,11 @@ class Price
     {
         $result = array();
         # 获取会员价
-        if (isset($vip[Place::$user['vip_id']])) {
+        if ($vip && isset($vip[Place::$user['vip_id']])) {
             $price = $vip[Place::$user['vip_id']][1];
         }
         # 获取代理价
-        if (isset($agent[Place::$user['agent_id']])) {
+        if ($agent && isset($agent[Place::$user['agent_id']])) {
             $agent_price = $agent[Place::$user['agent_id']][1];
             if ($agent_price < $price) {
                 $price = $agent_price;

+ 50 - 1
src/place/lib/Resource.php

@@ -69,6 +69,52 @@ class Resource
         return $this->handleInfo($info);
     }
 
+    # 下单
+    public function pay_commit(){}
+    public function pay($info)
+    {
+        $order = array();
+        $order['uid'] = Place::$uid;
+        $order['name'] = $info['name'];
+        $prefix = strtoupper(substr($this->app, 0, 2));
+        if ($this->type == 3) {
+            $order['cash'] = $info['value'];
+        } else {
+            $order['cash'] = ($info['value']/Place::$info['score_per']);
+        }
+        $order['order_num'] = Dever::load('util', 'api')->createNumber($prefix, 'place/order');
+        $order['notify'] = 'place/callback.resource|' . Dever::input('p') . '|' . $order['order_num'] . '|' . $this->type;
+
+        $data['pay'] = Dever::load('account', 'place')->pay($order);
+        if ($data['pay'] && empty($data['pay']['link'])) {
+            $order['status'] = 1;
+            $order['type'] = $this->type;
+            $order['type_id'] = $info['id'];
+            $data['order_id'] = Dever::db('order', 'place')->insert($order);
+            $data['order_num'] = $order['order_num'];
+            if (isset($info['detail'])) {
+                $detail['order_id'] = $data['order_id'];
+                foreach ($info['detail'] as $k => $v) {
+                    $detail['type'] = $this->type;
+                    $detail['type_id'] = $v['id'];
+                    if (isset($v['sku_id'])) {
+                        $detail['sku_id'] = $v['sku_id'];
+                    }
+                    if (isset($v['sku_name'])) {
+                        $detail['sku_name'] = $v['sku_name'];
+                    }
+                    $detail['pic'] = $v['pic'];
+                    $detail['cash'] = $v['cash'];
+                    $detail['num'] = $v['num'];
+                    $detail['name'] = $v['name'];
+                    $detail['pic'] = $v['pic'];
+                    Dever::db('order_detail', 'place')->insert($detail);
+                }
+            }
+        }
+        return $data;
+    }
+
     # 同步资源,关联资源
     public function relation($place_id, $data, $relation)
     {
@@ -191,8 +237,9 @@ class Resource
     private function handleInfo($info)
     {
         $info = Dever::load('info', $this->app)->getInfo($info);
+        $info['pic'] = explode(',', $info['pic']);
         $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
-        if (Place::$user['client_id'] > 0) {
+        if (Place::$uid && Place::$user['client_id'] > 0) {
             $info['client'] = Dever::load('client', 'place')->get($info, $this->app, $this->type, '进货');
         }
         $info['price'] = Dever::load('price', 'place')->get($info, $this->app, $this->type, '下载');
@@ -211,6 +258,8 @@ class Resource
                 }
             }
             $info['content'] = htmlspecialchars_decode($info['content']);
+        } else {
+            $info['pic'] = $info['pic'][0] ?? '';
         }
         return $info;
     }

+ 11 - 28
src/place/lib/Vip.php

@@ -90,6 +90,8 @@ class Vip
     public function getResourcePrice($price, $info_id, $app, $type)
     {
         $result = array();
+        $result['list'] = array();
+        $result['alone'] = array();
         if ($info = $this->info) {
             $type_id = $this->type . '_id';
             $table = $this->type . '_price';
@@ -171,33 +173,14 @@ class Vip
         }
 
         $prefix = strtoupper(substr($this->type, 0, 2));
-        $account = Dever::input('account', 'is_string', '账户', 'wechat');
-        $env = Dever::input('env', 'is_numeric', '运行环境', 3);
-        $result = Dever::load('util', 'api')->openid($account, $env, Place::$uid);
-        if (isset($result['openid'])) {
-            Place::$user['openid'] = $result['openid'];
-        } elseif (isset($result['link'])) {
-            return $result;
-        }
-
-        $price = $info['price'];
-        
-        # 支付账户
-        $account = 'pay_' . $account;
-        # 下单
-        $order = array
-        (
-            'uid' => Place::$uid,
-            'openid' => Place::$user['openid'] ?? '',
-            'order_num' => Dever::load('util', 'api')->createNumber($prefix, 'place/'.$this->type.'_order'),
-            'cash' => $price*100,
-            'name' => $info['name'],
-            'time_expire' => time() + 3600,
-        );
-        # 设置支付成功的回调信息,多个参数用|隔开
-        $param['notify'] = 'place/'.$this->type.'.success|' . Dever::input('p') . '|' . $order['order_num'];
-        $data['pay'] = Dever::load('account', 'api')->run($account, 'order', $order, $env);
-        if ($data['pay']) {
+        $order = array();
+        $order['uid'] = Place::$uid;
+        $order['name'] = $info['name'];
+        $order['cash'] = $info['price'];
+        $order['order_num'] = Dever::load('util', 'api')->createNumber($prefix, 'place/'.$this->type.'_order');
+        $order['notify'] = 'place/'.$this->type.'.success|' . Dever::input('p') . '|' . $order['order_num'];
+        $data['pay'] = Dever::load('account', 'place')->pay($order);
+        if ($data['pay'] && empty($data['pay']['link'])) {
             $order['status'] = 1;
             $order[$this->type.'_id'] = $info['id'];
             $data['order_id'] = Dever::db($this->type . '_order', 'place')->insert($order);
@@ -207,7 +190,7 @@ class Vip
     }
 
     # 支付成功
-    public function success($place, $order_num, $type, $status, $body = array())
+    public function success($place, $order_num, $status, $body = array())
     {
         Dever::input('authorization', 'is_string', '入口码', $place);
         $order = Dever::db($this->type.'_order', 'place')->find(array('order_num' => $order_num));

+ 78 - 0
src/place/manage/account.php

@@ -0,0 +1,78 @@
+<?php
+$id = Dever::input('id');
+$show = false;
+$account_setting = array();
+if ($id) {
+    $account = Dever::load('account', 'place')->getInfo($id);
+    $setting = Dever::db('platform_setting', 'api')->select(array('platform_id' => $account['platform_id']));
+    if ($setting) {
+        $show = true;
+        foreach ($setting as $k => $v) {
+            $account_setting[] = array('platform_setting_name' => $v['name'], 'platform_setting_id' => $v['id'], 'value' => '');
+        }
+    }
+}
+$extend = Dever::load('common', 'manage')->extend();
+$uid = $extend['data_id'];
+return array
+(
+    'list' => array
+    (
+        'where' => array('uid' => $uid),
+        'field'      => array
+        (
+            'id',
+            'name',
+            'type',
+            'cdate',
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', array('field' => 'uid,name,type','uid' => $uid)),
+        ),
+        'data_button' => array
+        (
+            '设置' => array('edit', 'uid,name,place/account_setting'),
+            '证书' => array('route', array
+            (
+                'path' => 'sector_place/account_cert',
+                'param' => array
+                (
+                    'set' => array('account_id' => 'id', 'menu' => 'sector_place/account', 'parent' => 'sector_place/account'),
+                ),
+            )),
+        ),
+        'search' => array
+        (
+            'name',
+            'type',
+        ),
+    ),
+    'update' => array
+    (
+        'field'    => array
+        (
+            'uid' => array
+            (
+                'type' => 'hidden',
+            ),
+            'name' => array
+            (
+                'rules' => true,
+            ),
+            'type' => array
+            (
+                'type' => 'radio',
+                'rules' => true,
+                'desc' => '【保存后不能更改】',
+            ),
+            'place/account_setting' => array
+            (
+                'show' => $show,
+                'name' => '参数配置',
+                'where'  => array('account_id' => 'id'),
+                'default' => $account_setting,
+            ),
+        ),
+    ),
+);

+ 66 - 0
src/place/manage/account_cert.php

@@ -0,0 +1,66 @@
+<?php
+$account_id = Dever::input('set')['account_id'] ?? 0;
+if (!$account_id) {
+    $account_id = Dever::input('field')['account_id'] ?? 0;
+}
+$account = Dever::load('account', 'place')->getInfo($account_id);
+return array
+(
+    'list' => array
+    (
+        'where' => array('account_id' => $account_id),
+        'field'      => array
+        (
+            'id',
+            'platform_cert_id' => array
+            (
+                'show' => 'Dever::call("api/app.getCertName", "{platform_cert_id}")',
+            ),
+            'number',
+            'cdate',
+        ),
+        'data_button' => array
+        (
+            '编辑' => array('fastedit', array('account_id' => $account_id)),
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', array('account_id' => $account_id)),
+        ),
+        'search' => array
+        (
+            'account_id' => 'hidden',
+            'number',
+        ),
+    ),
+    'update' => array
+    (
+        'desc' => '微信支付的平台证书会自动同步',
+        'field'    => array
+        (
+            'account_id' => 'hidden',
+            'platform_cert_id' => array
+            (
+                'rules' => true,
+                'type' => 'select',
+                'option'     => 'Dever::call("api/app.getCert", '.$account['platform_id'].')',
+                //'remote' => 'api/manage.getCertName',
+                //'remote_default' => false,
+            ),
+            'number' => array
+            (
+                'rules' => true,
+            ),
+            'public' => array
+            (
+                //'rules' => true,
+                'type' => 'textarea',
+            ),
+            'private' => array
+            (
+                //'rules' => true,
+                'type' => 'textarea',
+            ),
+        ),
+    ),
+);

+ 26 - 0
src/place/manage/account_setting.php

@@ -0,0 +1,26 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'platform_setting_id' => 'hidden',
+            'platform_setting_name' => array
+            (
+                'name' => '参数名',
+                'type' => 'show',
+                'default' => 'Dever::call("api/platform_setting-find", "{platform_setting_id}")["name"]',
+                //'disable' => true,
+                //'option'     => 'Dever::call("api/app.getSetting", '.$account['platform_id'].')',
+                //'remote' => 'api/manage.getSettingName',
+                //'remote_default' => false,
+            ),
+            'value' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+        ),
+    ),
+);

+ 17 - 0
src/place/manage/core.php

@@ -20,6 +20,23 @@ return array
             'sort'      => '1',
         ),
 
+        'account' => array
+        (
+            'parent'    => 'sector_place',
+            'name'      => '支付账户',
+            'icon'      => 'contacts-line',
+            'sort'      => '2',
+        ),
+
+        'account_cert' => array
+        (
+            'parent'    => 'sector_place',
+            'name'      => '账户证书',
+            'icon'      => 'contacts-line',
+            'sort'      => '3',
+            'show'      => 3,
+        ),
+
         # 客户
         'member_manage' => array
         (

+ 3 - 1
src/place/manage/info.php

@@ -10,6 +10,7 @@ $config['update']['field']['place/resource'] = array
 );
 
 $data = Dever::load('manage', 'place')->getPlaceTree();
+$id = $data[0]['children'][0]['id'];
 $uid = $data[0]['children'][0]['uid'];
 $user = Dever::db('user', 'sector')->find($uid);
 if ($user['channel'] == 1) {
@@ -39,10 +40,11 @@ $config['update']['column'] = array
     //'add' => '新增',
     'key' => 'id',
     'data' => $data,
-    'active' => 1,
+    'active' => $id,
     'where' => 'id',
     'hidden' => true,
 );
+$config['update']['field']['pay_account']['option'] = 'Dever::call("place/manage.getAccountList", '.$uid.')';
 return array
 (
     'source' => 'place/info',

+ 6 - 1
src/place/manage/place.php

@@ -39,7 +39,7 @@ return array
         'tab' => array
         (
             '基本信息' => 'uid,name,code,password,price,logo,bg,content',
-            '支付设置' => 'money_id,score,score_per',
+            '支付设置' => 'pay_account,money_id,score,score_per',
         ),
         'field'    => array
         (
@@ -56,6 +56,11 @@ return array
                 //'rules' => true,
                 'desc' => '设置身份码之后,用户将可以通过身份码快速进入,身份码不能重复',
             ),
+            'pay_account' => array
+            (
+                'type' => 'select',
+                'option'    => 'Dever::call("place/manage.getAccountList")',
+            ),
             'money_id' => array
             (
                 'tips' => '设置支付使用的货币',

+ 31 - 0
src/place/table/account.php

@@ -0,0 +1,31 @@
+<?php
+return array
+(
+    'name' => '支付账户管理',
+    'partition' => 'Dever::call("manage/common.system", array(false, false))',
+    'struct' => array
+    (
+        'name'      => array
+        (
+            'type'      => 'varchar(32)',
+            'name'      => '账户名称',
+        ),
+
+        'uid' => array
+        (
+            'name'      => '用户ID',
+            'type'      => 'int(11)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '微信支付',
+            ),
+        ),
+    ),
+);

+ 45 - 0
src/place/table/account_cert.php

@@ -0,0 +1,45 @@
+<?php
+
+return array
+(
+    'name' => '账户证书设置',
+    'order' => 'edate desc, id asc',
+    'struct' => array
+    (
+        'account_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '账户',
+        ),
+
+        'platform_cert_id' => array
+        (
+            'name'      => '证书名',
+            'type'      => 'int(11)',
+        ),
+
+        'number' => array
+        (
+            'name'      => '证书序列号',
+            'type'      => 'varchar(100)',
+        ),
+
+        'public' => array
+        (
+            'name'      => '公钥内容',
+            'type'      => 'varchar(3000)',
+        ),
+
+        'private' => array
+        (
+            'name'      => '私钥内容',
+            'type'      => 'varchar(3000)',
+        ),
+
+        'edate' => array
+        (
+            'name'      => '过期时间',
+            'type'      => 'int(11)',
+        ),
+    ),
+);

+ 27 - 0
src/place/table/account_setting.php

@@ -0,0 +1,27 @@
+<?php
+
+return array
+(
+    'name' => '账户设置',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'account_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '账户',
+        ),
+
+        'platform_setting_id' => array
+        (
+            'name'      => '参数名',
+            'type'      => 'int(11)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '参数值',
+            'type'      => 'varchar(3000)',
+        ),
+    ),
+);

+ 45 - 0
src/place/table/cash_log.php

@@ -0,0 +1,45 @@
+<?php
+return array
+(
+    'name' => '资金日志表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'store' => 'log',
+    'struct' => array
+    (
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ),
+        
+        'desc'       => array
+        (
+            'type'      => 'varchar(50)',
+            'name'      => '描述',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'value'         => array
+            (
+                1 => '入账',
+                2 => '出账',
+            ),
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal(11,2)',
+            'name'      => '金额',
+        ),
+
+        'yue'      => array
+        (
+            'type'      => 'decimal(11,2)',
+            'name'      => '操作后余额',
+        ),
+    ),
+);

+ 7 - 0
src/place/table/info.php

@@ -109,6 +109,13 @@ return array
             ),
         ),
 
+        'pay_account' => array
+        (
+            'name'      => '支付账户',
+            'type'      => 'tinyint(1)',
+            'default'   => -1,
+        ),
+
         'status' => array
         (
             'name'      => '状态',

+ 7 - 1
src/place/table/order_detail.php

@@ -1,7 +1,7 @@
 <?php
 return array
 (
-    'name' => '支付订单明细表',
+    'name' => '资源支付订单明细表',
     'partition' => 'Dever::call("manage/common.system", array(false, true, "place/info.funcType"))',
     'struct' => array
     (
@@ -35,6 +35,12 @@ return array
             'name'      => '名称',
         ),
 
+        'pic' => array
+        (
+            'name'      => '图片',
+            'type'      => 'varchar(150)',
+        ),
+
         'sku_name'      => array
         (
             'type'      => 'varchar(200)',

+ 1 - 1
src/place/table/order_refund.php

@@ -1,7 +1,7 @@
 <?php
 return array
 (
-    'name' => '退款单表',
+    'name' => '资源退款单表',
     'partition' => 'Dever::call("manage/common.system", array(false, true, "place/info.funcType"))',
     'struct' => array
     (

+ 1 - 1
src/place/table/order_stat.php

@@ -2,7 +2,7 @@
 return array
 (
     'name' => '订单日统计表',
-    'partition' => 'Dever::call("manage/common.system")',
+    'partition' => 'Dever::call("manage/common.system", array(false, true, "place/info.funcType"))',
     'order' => 'id desc',
     'struct' => array
     (

+ 5 - 0
src/resource/goods/lib/Cart.php

@@ -115,6 +115,11 @@ class Cart
                     if (isset($v['sku']['info']['name'])) {
                         $v['sku_name'] = $v['sku']['info']['name'];
                     }
+                    if (isset($v['sku']['info']['pic']) && $v['sku']['info']['pic']) {
+                        $v['pic'] = $v['sku']['info']['pic'];
+                    } else {
+                        $v['pic'] = $v['pic'][0];
+                    }
                     if (!$result['id']) {
                         $result['id'] = $v['id'];
                     }

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

@@ -30,6 +30,8 @@ class Info
 
     public function submit($info, $type = 'price')
     {
+        $sku_id = Dever::input('sku_id', 'is_numeric', '价格');
+        $sku_num = Dever::input('sku_num', 'is_numeric', '数量', 1);
         $result = $info[$type];
         $result['id'] = $info['id'];
         $result['name'] = $info['name'];
@@ -37,7 +39,22 @@ class Info
             $result['text'] = '专享商品,升级会员可购买';
         } else {
             $result['status'] = 2;
-            $result['sku'] = Dever::load('sku', 'api')->getList(array('info_id' => $info['id']), Dever::input('sku_id'), 'goods');
+            $result['sku'] = Dever::load('sku', 'api')->getList(array('info_id' => $info['id']), $sku_id, 'goods');
+            if ($result['sku']['info']) {
+                $detail = $result['sku']['info'];
+                if (!$detail['pic']) {
+                    $detail['pic'] = $info['pic'][0];
+                }
+                $detail['num'] = $sku_num;
+                $detail['cash'] = $result['sku']['info']['value'];
+                $detail['sku_id'] = $detail['id'];
+                $detail['sku_name'] = $detail['name'];
+                $detail['id'] = $result['id'];
+                $detail['name'] = $result['name'];
+                $result['detail'][] = $detail;
+            } else {
+                Dever::error('下单失败');
+            }
         }
         return $result;
     }

+ 12 - 0
src/resource/goods/lib/Order.php

@@ -0,0 +1,12 @@
+<?php namespace Goods\Lib;
+use Dever;
+use Place;
+class Order
+{
+    # 获取某个订单的详情
+    public function getDetail($id)
+    {
+        $result = Dever::db('order_detail', 'place')->select(array('type' => 3, 'order_id' => $id));
+        return $result;
+    }
+}