dever vor 3 Jahren
Ursprung
Commit
cde149bbf5

+ 2 - 2
app/card/database/code.php

@@ -75,7 +75,7 @@ return array
 
         'total_cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '总额',
             'default'   => '0',
             'desc'      => '总额',
@@ -85,7 +85,7 @@ return array
 
         'use_cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '已使用',
             'default'   => '0',
             'desc'      => '已使用',

+ 1 - 1
service/agent/database/dh_order.php

@@ -200,7 +200,7 @@ return array
 
         'refund_cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '退款金额',
             'default'   => '0',
             'desc'      => '已退订单金额',

+ 29 - 3
service/agent/database/member.php

@@ -334,7 +334,7 @@ return array
 
         'cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '余额',
             'default'   => '0',
             'desc'      => '余额',
@@ -344,7 +344,7 @@ return array
 
         'sell'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '销售业绩-直推业绩',
             'default'   => '0',
             'desc'      => '销售业绩',
@@ -354,7 +354,7 @@ return array
 
         'group_sell'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '团队销售业绩',
             'default'   => '0',
             'desc'      => '团队销售业绩',
@@ -442,6 +442,19 @@ return array
             'col' => '*',
         ),
 
+        'upCash' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes', '+='),
+            ),
+        ),
+
         'upSell' => array
         (
             'type' => 'update',
@@ -471,5 +484,18 @@ return array
                 'level_id' => 'yes',
             ),
         ),
+
+        'upGroupSellOne' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'group_sell' => array('yes', '+='),
+            ),
+        ),
     ),
 );

+ 1 - 1
service/agent/database/member_area.php

@@ -78,7 +78,7 @@ return array
 
         'price'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '实付金额',
             'default'   => '0',
             'desc'      => '金额',

+ 5 - 5
service/agent/database/order.php

@@ -226,7 +226,7 @@ return array
 
         'f_price'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '原价',
             'default'   => '0',
             'desc'      => '原价',
@@ -236,7 +236,7 @@ return array
 
         'price'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '实付金额',
             'default'   => '0',
             'desc'      => '金额',
@@ -272,7 +272,7 @@ return array
 
         'pay_price'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '交款金额',
             'default'   => '0',
             'desc'      => '交款金额',
@@ -435,7 +435,7 @@ return array
 
         'agent_cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '代理费',
             'default'   => '0',
             'desc'      => '代理费',
@@ -445,7 +445,7 @@ return array
 
         'soft_cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '软件服务费',
             'default'   => '0',
             'desc'      => '软件服务费',

+ 2 - 2
service/agent/database/order_cash.php

@@ -71,7 +71,7 @@ return array
 
         'per'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '佣金比例-仅做展示用',
             'default'   => '0',
             'desc'      => '佣金比例',
@@ -82,7 +82,7 @@ return array
 
         'cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '金额',
             'default'   => '0',
             'desc'      => '金额',

+ 1 - 1
service/agent/database/order_process.php

@@ -106,7 +106,7 @@ return array
 
         'price'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '实付金额',
             'default'   => '0',
             'desc'      => '金额',

+ 1 - 1
service/agent/lib/Core.php

@@ -14,7 +14,7 @@ class Core
     {
         $this->uid = Dever::load('passport/user')->check(false);
         if ($this->uid <= 0) {
-            $this->uid = 1000000;
+            $this->uid = 1;
         }
         $this->checkLogin();
         if ($this->uid) {

+ 65 - 11
service/agent/lib/Member.php

@@ -88,6 +88,11 @@ class Member
      */
     public function up($order_id, $role, $type, $mid, $cash, $sell, $level_id = false, $desc = '')
     {
+        # 增加日志
+        Dever::load('bill/lib/cash')->up($mid, $type, $cash, $role, $order_id, $desc, 2);
+
+        Dever::load('bill/lib/sell')->up($mid, $type, $sell, $role, $order_id, $desc);
+
         $data['where_id'] = $mid;
         $data['cash'] = $cash;
         $data['upcol'] = $sell;
@@ -101,12 +106,6 @@ class Member
         }
         $data['clear'] = true;
         Dever::db('agent/member')->$method($data);
-
-        # 增加日志
-        Dever::load('bill/lib/cash')->up($mid, $type, $cash, $role, $order_id, $desc, 2);
-
-        Dever::load('bill/lib/sell')->up($mid, $type, $sell, $role, $order_id, 2);
-
     }
 
     /**
@@ -190,12 +189,57 @@ class Member
         );
         */
         $url = '';
+        if ($member['status'] == 5) {
+            $button[] = array
+            (
+                'type' => 'action',
+                'link' => Dever::url('lib/member.setStatus?id=' . $member['id'] . '&value=2', 'agent'),
+                'name' => '恢复账号',
+            );
+        } elseif ($member['status'] == 2) {
+            $button[] = array
+            (
+                'type' => 'action',
+                'link' => Dever::url('lib/member.setStatus?id=' . $member['id'] . '&value=5', 'agent'),
+                'name' => '禁用账号',
+            );
+        }
+        
         $button[] = array
         (
             'type' => 'action',
-            'link' => Dever::url('project/database/update?project=agent&table=member&where_id='.$member['id'].'&status=1&col=shop_id', 'manage'),
-            'name' => '禁用账号',
+            'link' => Dever::url('lib/member.setStatus?id=' . $member['id'] . '&value=5', 'agent'),
+            'name' => '设置邀请关系',
+        );
+
+        $button[] = array
+        (
+            'type' => 'edit',
+            'link' => Dever::url('project/database/update?project=bill&table=push_cash&search_option_mid='.$member['id'], 'manage'),
+            'name' => '发放资金',
         );
+
+        $button[] = array
+        (
+            'type' => 'link',
+            'link' => Dever::url('project/database/list?project=bill&table=cash&search_option_mid='.$member['id'].'', 'manage'),
+            'name' => '资金账户',
+        );
+
+        $button[] = array
+        (
+            'type' => 'edit',
+            'link' => Dever::url('project/database/update?project=bill&table=push_sell&search_option_mid='.$member['id'], 'manage'),
+            'name' => '发放业绩',
+        );
+
+        $button[] = array
+        (
+            'type' => 'link',
+            'link' => Dever::url('project/database/list?project=bill&table=sell&search_option_mid='.$member['id'].'', 'manage'),
+            'name' => '业绩查询',
+        );
+
         $head = array
         (
             'name' => '基本信息',
@@ -262,13 +306,23 @@ class Member
 
                 array
                 (
-                    array('余额', $member['cash'] . '元'),
-                    array('业绩', $member['sell'] . '元'),
-                    array('团队业绩', $member['group_sell'] . '元'),
+                    array('资金余额', '¥' . $member['cash'] . '元'),
+                    array('直推业绩', '¥' . $member['sell'] . '元'),
+                    array('团队业绩', '¥' . $member['group_sell'] . '元'),
                 ),
             ),
         );
 
         return $result;
     }
+
+    public function setStatus_api()
+    {
+        $where['where_id'] = Dever::input('id');
+        $where['status'] = Dever::input('value');
+
+        Dever::db('agent/member')->update($where);
+
+        return 'reload';
+    }
 }

+ 113 - 0
service/agent/src/My.php

@@ -381,6 +381,119 @@ class My extends Core
         return $this->data;
     }
 
+    # 获取我的资金
+    public function getCash()
+    {
+        $this->data['user'] = $this->user;
+        $this->data['type'] = Dever::db('bill/cash')->config['set']['type'];
+        $this->data['status'] = Dever::db('bill/cash')->config['set']['status'];
+
+        $where['mid'] = $this->uid;
+        $type = Dever::input('type');
+        if ($type) {
+            $where['type'] = $type;
+        }
+        $this->data['list'] = Dever::db('bill/cash')->getData($where);
+        if ($this->data['list']) {
+            foreach ($this->data['list'] as $k => $v) {
+                $this->data['list'][$k]['type_name'] = $this->data['type'][$v['type']];
+                $this->data['list'][$k]['status_name'] = $this->data['status'][$v['status']];
+                $this->data['list'][$k]['cdate'] = date('Y-m-d H:i', $v['cdate']);
+                if ($v['cash'] > 0) {
+                    $this->data['list'][$k]['cash'] = '+' . $v['cash'];
+                }
+            }
+        }
+
+        return $this->data;
+    }
+
+    public function getCashView()
+    {
+        $where['mid'] = $this->uid;
+        $where['id'] = Dever::input('id');
+        $this->data['info'] = Dever::db('bill/cash')->find($where);
+
+        $config = Dever::db('bill/cash')->config['set'];
+
+        if ($this->data['info']) {
+            $this->data['info']['type_name'] = $config['type'][$this->data['info']['type']];
+            $this->data['info']['status_name'] = $config['status'][$this->data['info']['status']];
+
+            $this->data['info']['cdate'] = date('Y-m-d H:i', $this->data['info']['cdate']);
+            if ($this->data['info']['cash'] > 0) {
+                $this->data['info']['cash'] = '+' . $this->data['info']['cash'];
+            }
+        }
+
+        return $this->data;
+    }
+
+    # 提现详情
+    public function tixianInfo()
+    {
+        $this->data['user'] = $this->user;
+        $this->data['config'] = Dever::db('setting/base')->one();
+        $this->data['config']['tax'] = $this->data['config']['tax']/100;
+        $this->data['bank'] = Dever::db('setting/bank')->select();
+
+        # 获取上次提现记录
+        $this->data['mybank'] = Dever::db('bill/tixian')->getNew(array('mid' => $this->uid));
+
+        return $this->data;
+    }
+
+    # 确定提现
+    public function tixian_commit()
+    {
+        $cash = Dever::input('cash');
+        if ($cash > $this->user['cash']) {
+            Dever::alert('您的可提现金额不足');
+        }
+        $name = Dever::input('name');
+        if (!$name) {
+            Dever::alert('姓名不能为空');
+        }
+        $bank = Dever::input('bank');
+        if (!$bank) {
+            Dever::alert('银行不能为空');
+        }
+        $bankname = Dever::input('bankname');
+        if (!$bankname) {
+            Dever::alert('开户行不能为空');
+        }
+        $card = Dever::input('card');
+        if (!$card) {
+            Dever::alert('银行卡号不能为空');
+        }
+        $ycard = Dever::input('ycard');
+        if (!$ycard) {
+            Dever::alert('确认银行卡号不能为空');
+        }
+        if ($card != $ycard) {
+            Dever::alert('银行卡号和确认银行卡号不同');
+        }
+
+        $config = Dever::db('setting/base')->one();
+        $tax = $config['tax']/100;
+        $ycash = $cash;
+        $cash = $cash - $cash*$tax;
+
+        $id = Dever::load('bill/lib/tixian')->up($this->uid, $ycash, $cash, $name, $bank, $bankname, $card);
+
+        if ($id) {
+            $cash_id = Dever::load('bill/lib/cash')->up($this->uid, 11, $ycash, $this->user['role'], $id, '提现到'.substr($card, -4).'银行卡', 1);
+
+            Dever::db('bill/tixian')->update(array('where_id' => $id, 'cash_id' => $cash_id));
+
+            $where['where_id'] = $this->uid;
+            $where['cash'] = -1*$ycash;
+            Dever::db('agent/member')->upCash($where);
+        }
+
+        return 'ok';
+    }
+
     # 修改密码
     public function setPass()
     {

+ 27 - 0
service/bill/assets/manage/html/push_cash.html

@@ -0,0 +1,27 @@
+
+<form class="layui-form form10" action="" target="f10" method="post">
+<iframe id="f10" name="f10" style="display:none;"></iframe>
+<div class="layui-form-item" id="show">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>
+</form>

+ 27 - 0
service/bill/assets/manage/html/push_sell.html

@@ -0,0 +1,27 @@
+
+<form class="layui-form form10" action="" target="f10" method="post">
+<iframe id="f10" name="f10" style="display:none;"></iframe>
+<div class="layui-form-item" id="show">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>
+</form>

+ 106 - 16
service/bill/database/cash.php

@@ -7,12 +7,20 @@ $status = array
     3 => '已作废',
 );
 
+$manage_status = array
+(
+    //1 => '待审核',
+    2 => '已审核',
+    3 => '已作废',
+);
+
 $type = array
 (
     1 => '直推佣金',
     2 => '市场培训费',
     3 => '代理区域分润',
     4 => '活动分佣',
+    10 => '手动发放',
     11 => '提现',
 );
 
@@ -27,6 +35,14 @@ $role = function()
 	return $array;
 };
 
+$mid = Dever::input('search_option_mid');
+$button = array();
+if ($mid) {
+    $button = array
+    (
+        '发放资金' => array('fast', '', 'push_cash&search_option_mid=' . $mid),
+    );
+}
 return array
 (
     # 表名
@@ -38,6 +54,10 @@ return array
     	'status' => $status,
     	'type' => $type,
     ),
+    'end' => array
+    (
+        'update' => 'bill/lib/manage.cashAuditUpdate',
+    ),
     'order' => 99,
     # 数据结构
     'struct' => array
@@ -57,18 +77,44 @@ return array
         'mid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '代理商',
+            'name'      => '手机号',
             'default'   => '-1',
             'desc'      => '代理商',
             'match'     => 'is_string',
             'update'    => 'text',
-            'searchs'    => array
+            'search'    => $mid ? 'hidden' : array
             (
                 'api' => 'agent/member-select',
-                'col' => 'name',
+                'col' => 'mobile',
                 'result' => 'id',
             ),
-            'list'      => 'Dever::load("agent/member-find#name", {mid})',
+            'list_name' => '手机号',
+            'list'      => 'Dever::load("agent/member-find#mobile", {mid})',
+            'list_order' => 4,
+        ),
+
+        'agent-member-name'=> array
+        (
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => true,
+            'list_order' => 3,
+        ),
+
+        'agent-member-role'=> array
+        (
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
+            'list_order' => 5,
         ),
 
         'order_num'      => array
@@ -81,7 +127,7 @@ return array
             'update'    => 'text',
             'search'    => 'fulltext',
             'list'      => true,
-            'list_order'  => -1,
+            'list_order'  => 1,
         ),
 
         'role'      => array
@@ -108,6 +154,7 @@ return array
             'update'    => 'checkbox',
             'option'    => $type,
             'list'      => true,
+            'list_order' => 7,
         ),
 
         'type_id'      => array
@@ -122,24 +169,26 @@ return array
 
         'cash'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '金额',
             'default'   => '0',
             'desc'      => '金额',
             'match'     => 'is_numeric',
             'update'    => 'text',
             'list'      => true,
+            'list_order' => 6,
         ),
 
         'yue'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '操作后余额',
             'default'   => '0',
             'desc'      => '操作后余额',
             'match'     => 'is_numeric',
             'update'    => 'text',
             'list'      => true,
+            'list_order' => 7,
         ),
 
         'status'        => array
@@ -153,17 +202,31 @@ return array
             'option'    => $status,
             'search'    => 'select',
             'list'      => true,
+            'list_name' => '交易状态',
+            'list_order' => 8,
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $manage_status,
         ),
 
         'audit_desc'      => array
         (
             'type'      => 'varchar-600',
-            'name'      => '审核说明',
-            'default'   => '-',
+            'name'      => '备注',
+            'default'   => '',
             'desc'      => '审核说明',
-            'match'     => 'is_string',
-            'update'    => 'text',
-            'list'      => true,
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            'list_order'  => 9,
         ),
 
         'desc'      => array
@@ -176,6 +239,17 @@ return array
             'update'    => 'text',
         ),
 
+        'operdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核确认时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : "-"',
+            'list_order'  => 9,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -194,7 +268,8 @@ return array
             # 只有insert时才生效
             //'insert'    => true,
             'search'    => 'date',
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
+            'list_order'  => 2,
         ),
     ),
 
@@ -203,15 +278,30 @@ return array
         'insert' => false,
         'delete' => false,
         'edit' => false,
-
+        'button' => $button,
         'list_button' => array
         (
-            
+            'list' => array('查看详情', '"push_cash&project=bill&id={id}&page_type=1"'),
+
+            'fast' => array('审核', '"cash&where_id={id}&col=audit,audit_desc&oper_save_jump=cash&oper_table=cash&oper_parent=cash"', '{status} == 1'),
         ),
     ),
 
     'request' => array
     (
-        
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
     ),
 );

+ 141 - 0
service/bill/database/push_cash.php

@@ -0,0 +1,141 @@
+<?php
+
+$mid = Dever::input('search_option_mid');
+
+$status = array
+(
+	1 => '发放成功',
+	2 => '发放失败',
+);
+return array
+(
+    # 表名
+    'name' => 'push_cash',
+    # 显示给用户看的名称
+    'lang' => '发放资金',
+    'order' => 99,
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'bill/lib/manage.cashUpdate',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理商',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+            'value'		=> $mid,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '发放金额-金额单位为元',
+            'default'   => '',
+            'desc'      => '发放金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '资金说明',
+            'default'   => '',
+            'desc'      => '资金说明',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'admin_founder' => array
+        (
+            'type'      => 'int-11',
+            'name'      => '插入操作人',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'admin_editor' => array
+        (
+            'type'      => 'int-11',
+            'name'      => '更新操作人',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发放状态',
+            'default'   => '1',
+            'desc'      => '发放状态',
+            'match'     => 'is_numeric',
+            'update'  	=> 'hidden',
+            'option'    => $status,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
+            'list_order'  => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'page_list' => 'push_cash',
+
+        'list_button' => array
+        (
+            
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 141 - 0
service/bill/database/push_sell.php

@@ -0,0 +1,141 @@
+<?php
+
+$mid = Dever::input('search_option_mid');
+
+$status = array
+(
+	1 => '发放成功',
+	2 => '发放失败',
+);
+return array
+(
+    # 表名
+    'name' => 'push_sell',
+    # 显示给用户看的名称
+    'lang' => '发放业绩',
+    'order' => 99,
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'bill/lib/manage.sellUpdate',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理商',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+            'value'		=> $mid,
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '发放业绩金额-金额单位为元',
+            'default'   => '',
+            'desc'      => '发放业绩金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '发放说明',
+            'default'   => '',
+            'desc'      => '发放说明',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'admin_founder' => array
+        (
+            'type'      => 'int-11',
+            'name'      => '插入操作人',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'admin_editor' => array
+        (
+            'type'      => 'int-11',
+            'name'      => '更新操作人',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发放状态',
+            'default'   => '1',
+            'desc'      => '发放状态',
+            'match'     => 'is_numeric',
+            'update'  	=> 'hidden',
+            'option'    => $status,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
+            'list_order'  => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'page_list' => 'push_sell',
+
+        'list_button' => array
+        (
+            
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 94 - 22
service/bill/database/sell.php

@@ -10,6 +10,20 @@ $role = function()
 	}
 	return $array;
 };
+$mid = Dever::input('search_option_mid');
+$button = array();
+if ($mid) {
+    $button = array
+    (
+        '发放业绩' => array('fast', '', 'push_sell&search_option_mid=' . $mid),
+    );
+}
+$type = array
+(
+    1 => '直推业绩',
+    2 => '团队业绩',
+    10 => '手动发放',
+);
 
 return array
 (
@@ -18,6 +32,10 @@ return array
     # 显示给用户看的名称
     'lang' => '业绩流水',
     'order' => 90,
+    'set' => array
+    (
+        'type' => $type,
+    ),
     # 数据结构
     'struct' => array
     (
@@ -36,18 +54,44 @@ return array
         'mid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '代理商',
+            'name'      => '手机号',
             'default'   => '-1',
             'desc'      => '代理商',
             'match'     => 'is_string',
             'update'    => 'text',
-            'searchs'    => array
+            'search'    => $mid ? 'hidden' : array
             (
                 'api' => 'agent/member-select',
-                'col' => 'name',
+                'col' => 'mobile',
                 'result' => 'id',
             ),
-            'list'      => 'Dever::load("agent/member-find#name", {mid})',
+            'list_name' => '手机号',
+            'list'      => 'Dever::load("agent/member-find#mobile", {mid})',
+            'list_order' => 4,
+        ),
+
+        'agent-member-name'=> array
+        (
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => true,
+            'list_order' => 3,
+        ),
+
+        'agent-member-role'=> array
+        (
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
+            'list_order' => 5,
         ),
 
         'order_num'      => array
@@ -60,17 +104,31 @@ return array
             'update'    => 'text',
             'search'    => 'fulltext',
             'list'      => true,
+            'list_order'  => 1,
         ),
 
-        'order_id'      => array
+        'type'      => array
         (
             'type'      => 'int-11',
-            'name'      => '代理商订单id',
+            'name'      => '业绩类型',
+            'default'   => '1',
+            'desc'      => '业绩类型',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'checkbox',
+            'option'    => $type,
+            'list'      => true,
+            'list_order' => 7,
+        ),
+
+        'type_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易来源id',
             'default'   => '',
-            'desc'      => '代理商订单id',
+            'desc'      => '交易来源id',
             'match'     => 'is_string',
             'update'    => 'text',
-            'list'      => true,
         ),
 
         'role'      => array
@@ -88,24 +146,23 @@ return array
 
         'num'      => array
         (
-            'type'      => 'float-11',
-            'name'      => '直推业绩',
+            'type'      => 'float-11,2',
+            'name'      => '业绩金额',
             'default'   => '0',
-            'desc'      => '直推业绩',
+            'desc'      => '业绩',
             'match'     => 'is_numeric',
             'update'    => 'text',
             'list'      => true,
         ),
 
-        'group_num'      => array
+        'desc'      => array
         (
-            'type'      => 'float-11',
-            'name'      => '团队业绩',
-            'default'   => '0',
-            'desc'      => '团队业绩',
-            'match'     => 'is_numeric',
+            'type'      => 'varchar-600',
+            'name'      => '业绩说明',
+            'default'   => '',
+            'desc'      => '业绩说明',
+            'match'     => 'is_string',
             'update'    => 'text',
-            'list'      => true,
         ),
 
         'state'     => array
@@ -120,13 +177,14 @@ return array
         '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})',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
+            'list_order'  => 2,
         ),
     ),
 
@@ -135,15 +193,29 @@ return array
         'insert' => false,
         'delete' => false,
         'edit' => false,
+        'button' => $button,
 
         'list_button' => array
         (
-            
+            'list' => array('查看详情', '"push_sell&project=bill&id={id}&page_type=1"'),
         ),
     ),
 
     'request' => array
     (
-        
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
     ),
 );

+ 143 - 0
service/bill/database/sell_stat.php

@@ -0,0 +1,143 @@
+<?php
+return array
+(
+    # 表名
+    'name' => 'sell_stat',
+    # 显示给用户看的名称
+    'lang' => '业绩统计',
+    'order' => 79,
+    'menu' => 'agent',
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'month'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '月份',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'month',
+            'list'      => true,
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'agent/member-select',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '手机号',
+            'list'      => 'Dever::load("agent/member-find#mobile", {mid})',
+            'list_order' => 4,
+        ),
+
+        'agent-member-name'=> array
+        (
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => true,
+            'list_order' => 3,
+        ),
+
+        'agent-member-role'=> array
+        (
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
+            'list_order' => 5,
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '团队业绩',
+            'default'   => '0',
+            'desc'      => '团队业绩',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'new_num'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '新增业绩',
+            'default'   => '0',
+            'desc'      => '新增业绩',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '统计时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
+    ),
+);

+ 333 - 0
service/bill/database/tixian.php

@@ -0,0 +1,333 @@
+<?php
+
+$status = array
+(
+    1 => '待发放',
+    2 => '已发放',
+);
+
+$cash_status = array
+(
+    1 => '待审核',
+    2 => '已审核',
+    3 => '已作废',
+);
+
+$manage_status = array
+(
+    //1 => '待发放',
+    2 => '已发放',
+);
+
+$mid = Dever::input('search_option_mid');
+return array
+(
+    # 表名
+    'name' => 'tixian',
+    # 显示给用户看的名称
+    'lang' => '提现管理',
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+    'end' => array
+    (
+        'update' => 'bill/lib/manage.tixianAuditUpdate',
+    ),
+    'order' => 80,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => $mid ? 'hidden' : array
+            (
+                'api' => 'agent/member-select',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '手机号',
+            'list'      => 'Dever::load("agent/member-find#mobile", {mid})',
+            'list_order' => 4,
+        ),
+
+        'agent-member-name'=> array
+        (
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => true,
+            'list_order' => 3,
+        ),
+
+        'agent-member-role'=> array
+        (
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+            'list'      => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
+            'list_order' => 5,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '流水号',
+            'default'   => '',
+            'desc'      => '流水号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'list_order'  => 1,
+        ),
+
+        'ycash'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '提现金额',
+            'default'   => '0',
+            'desc'      => '金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+            'list_order' => 6,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '实际提现金额',
+            'default'   => '0',
+            'desc'      => '提现金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+            'list_order' => 7,
+        ),
+
+        'yue'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '提现后余额',
+            'default'   => '0',
+            'desc'      => '提现后余额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+            'list_order' => 8,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'bank'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '银行',
+            'default'   => '',
+            'desc'      => '银行',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'bankname'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '开户行',
+            'default'   => '',
+            'desc'      => '开户行',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'card'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '卡号',
+            'default'   => '',
+            'desc'      => '卡号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'cash_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '资金表id',
+            'default'   => '',
+            'desc'      => '资金表id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'bill-cash-status'=> array
+        (
+            'name'      => '交易状态',
+            'default'   => '',
+            'desc'      => '交易状态',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('cash_id', 'id'),
+            'list'      => true,
+            'option'	=> $cash_status,
+            'list_order' => 9,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发放状态',
+            'default'   => '1',
+            'desc'      => '发放状态',
+            'match'     => 'is_numeric',
+            'update'  	=> 'hidden',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'list_order' => 10,
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $manage_status,
+        ),
+
+        'audit_desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '审核说明',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            'list_order'  => 12,
+        ),
+
+        'pic'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '凭证',
+			'default' 	=> '',
+			'desc' 		=> '请选择凭证',
+			'match' 	=> 'option',
+			'update'	=> 'images',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+        'operdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发放时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : "-"',
+            'list_order'  => 11,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i", {cdate})',
+            'list_order'  => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"push_cash&project=bill&id={cash_id}&page_type=1"'),
+
+            'fast' => array('发放', '"tixian&where_id={id}&col=audit,audit_desc,pic&oper_save_jump=tixian&oper_table=tixian&oper_parent=tixian"', '{status} == 1 && "{bill-cash-status}" == 2'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
+
+        'getNew' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'mid' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'type' => 'one',
+            'col' => '*',
+        ),
+    ),
+);

+ 188 - 2
service/bill/lib/Cash.php

@@ -11,6 +11,9 @@ class Cash
         $member = Dever::db('agent/member')->find(array('id' => $mid, 'clear' => true));
         if ($member['status'] <= 2) {
         	$where['mid'] = $mid;
+            if ($type == 11) {
+                $cash = -1*$cash;
+            }
         	$where['type'] = $type;
         	$where['type_id'] = $type_id;
         	$where['clear'] = true;
@@ -18,14 +21,20 @@ class Cash
         	if (!$info) {
         		$data = $where;
         		$data['order_num'] = $this->getOrderId();
-        		$data['yue'] = $member['cash'];
+        		$data['yue'] = $member['cash'] + $cash;
         		$data['cash'] = $cash;
         		$data['role'] = $role;
         		$data['desc'] = $desc;
         		$data['status'] = $status;
-        		Dever::db('bill/cash')->insert($data);
+                if ($status == 2) {
+                    $data['operdate'] = time();
+                }
+        		return Dever::db('bill/cash')->insert($data);
         	}
+            return $info['id'];
         }
+
+        return false;
     }
 
     /**
@@ -43,4 +52,181 @@ class Cash
             return $this->getOrderId();
         }
     }
+
+    # 展示详情
+    public function show()
+    {
+        $id = Dever::input('id');
+
+        $config = Dever::db('bill/cash')->config['set'];
+
+        $info = Dever::db('bill/cash')->one($id);
+
+        $status = $config['status'][$info['status']];
+
+        $type = $config['type'][$info['type']];
+
+        $member = Dever::db('agent/member')->find($info['mid']);
+        $role = Dever::db('setting/role')->one($member['role']);
+        $level = Dever::db('setting/level')->one($member['level_id']);
+
+        if ($member['shop_id']) {
+            $shop = Dever::db('shop/info')->one($member['shop_id']);
+        } else {
+            $shop['id'] = -1;
+            $shop['name'] = '无';
+        }
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+        if ($info['operdate']) {
+            $opertime = date('Y-m-d H:i', $info['operdate']);
+        } else {
+            $opertime = '';
+        }
+
+        $result = array();
+
+        $result['代理商信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('代理商', $member['name'] . ' ' . $member['mobile']),
+                    array('代理角色', $role['name'] . ($level ? '('.$level['name'].')' : '')),
+                    array('所属店铺', $shop['name']),
+                ),
+
+                array
+                (
+                    array('资金余额', '¥' . $member['cash'] . '元'),
+                    array('直推业绩', '¥' . $member['sell'] . '元'),
+                    array('团队业绩', '¥' . $member['group_sell'] . '元'),
+                ),
+            ),
+        );
+
+        $result['交易信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('流水号', $info['order_num']),
+                    array('交易时间', $cdate),
+                    array('交易类型', $type),
+                ),
+
+                array
+                (
+                    array('交易金额', '¥' . $info['cash'] . '元'),
+                    array('交易后账户余额', '¥' . $info['yue'] . '元'),
+                    array('交易说明', $info['desc']),
+                ),
+            )
+        );
+
+        $result['审核信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('审核时间', $opertime),
+                    array('审核状态', $status),
+                    array('备注', $info['audit_desc']),
+                ),
+            )
+        );
+        
+        # 提现信息
+
+        $button = array();
+        if ($info['status'] == 1) {
+            $button[] = array
+            (
+                'type' => 'edit',
+                'link' => Dever::url('project/database/update?project=bill&table=cash&where_id='.$info['id'].'&col=audit,audit_desc&oper_save_jump=cash&oper_table=cash&oper_parent=cash', 'manage'),
+                'name' => '审核',
+            );
+        }
+        if ($info['type'] == 11) {
+            $tixian = Dever::db('bill/tixian')->find($info['type_id']);
+            if ($tixian) {
+
+                if ($info['status'] == 2 && $tixian['status'] == 1) {
+                    $button[] = array
+                    (
+                        'type' => 'edit',
+                        'link' => Dever::url('project/database/update?project=bill&table=tixian&where_id='.$tixian['id'].'&col=audit,audit_desc,pic&oper_save_jump=tixian&oper_table=tixian&oper_parent=tixian', 'manage'),
+                        'name' => '发放',
+                    );
+                }
+
+                $bank = Dever::db('setting/bank')->find($tixian['bank']);
+                $result['提现信息'] = array
+                (
+                    'type' => 'info',
+                    'content' => array
+                    (
+                        array
+                        (
+                            array('银行名称', $bank['name']),
+                            array('开户行', $tixian['bankname']),
+                        ),
+
+                        array
+                        (
+                            array('姓名', $tixian['name']),
+                            array('卡号', $tixian['card']),
+                        ),
+                    )
+                );
+
+                if ($tixian['status'] == 2) {
+                    if ($tixian['operdate']) {
+                        $opertime = date('Y-m-d H:i', $tixian['operdate']);
+                    } else {
+                        $opertime = '';
+                    }
+                    $pic = '';
+                    if ($tixian['pic']) {
+                        $temp = explode(',', $tixian['pic']);
+                        foreach ($temp as $k => $v) {
+                            $pic .= '<a href="'.Dever::pic($v).'" target="_blank"><img src="'.Dever::pic($v).'" width="150" /></a>';
+                        }
+                    }
+                    $result['发放信息'] = array
+                    (
+                        'type' => 'info',
+                        'content' => array
+                        (
+                            array
+                            (
+                                array('发放时间', $opertime),
+                                array('备注', $tixian['audit_desc']),
+                            ),
+                            array
+                            (
+                                array('凭证', $pic),
+                            ),
+                        )
+                    );
+                }
+                
+            }
+        }
+
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => $button,
+        );
+        $html = Dever::show($head, $result);
+
+        return $html;
+    }
 }

+ 14 - 0
service/bill/lib/Cron.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace Bill\Lib;
+
+use Dever;
+
+class Cron
+{
+    public function sell()
+    {
+    	# 按月份统计团队业绩
+        
+    }
+}

+ 93 - 0
service/bill/lib/Manage.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace Bill\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function cashUpdate($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $mid = Dever::param('mid', $data);
+        $cash = Dever::param('cash', $data);
+        $desc = Dever::param('desc', $data);
+        if ($mid && $cash && $desc) {
+        	$member = Dever::db('agent/member')->find($mid);
+        	if ($member && $member['status'] == 2) {
+        		Dever::load('bill/lib/cash')->up($mid, 10, $cash, $member['role'], $id, $desc, 2);
+        		$where['where_id'] = $mid;
+        		$where['cash'] = $cash;
+        		Dever::db('agent/member')->upCash($where);
+        	} else {
+        		Dever::db('bill/push_cash')->update(array('where_id' => $id, 'status' => 2));
+        		Dever::alert('代理商未审核通过,发放失败');
+        	}
+        }
+    }
+
+    public function cashAuditUpdate($id, $name, $data)
+    {
+    	Dever::config('base')->hook = true;
+        $audit = Dever::param('audit', $data);
+        if ($audit > 1) {
+        	if ($audit == 2) {
+	        	Dever::db('bill/cash')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time()));
+	        	$info = Dever::db('bill/cash')->find($id);
+	        	if ($info && $info['type'] <= 10) {
+	        		$where['where_id'] = $info['mid'];
+	        		$where['cash'] = $info['cash'];
+	        		Dever::db('agent/member')->upCash($where);
+	        	}
+	        } else {
+	        	Dever::db('bill/cash')->update(array('where_id' => $id, 'status' => 3, 'operdate' => time()));
+	        	$info = Dever::db('bill/cash')->find($id);
+	        	if ($info && $info['type'] == 11) {
+	        		$tixian = Dever::db('bill/tixian')->find($info['type_id']);
+	        		$where['where_id'] = $info['mid'];
+	        		$where['cash'] = -1*$tixian['ycash'];
+	        		Dever::db('agent/member')->upCash($where);
+	        	}
+	        }
+        }
+    }
+
+    public function tixianAuditUpdate($id, $name, $data)
+    {
+    	Dever::config('base')->hook = true;
+        $audit = Dever::param('audit', $data);
+        if ($audit > 1) {
+        	$info = Dever::db('bill/cash')->find(array('type' => 11, 'type_id' => $id));
+        	if (!$info) {
+        		Dever::alert('系统错误');
+        	}
+        	if ($audit == 2) {
+	        	Dever::db('bill/tixian')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time()));
+	        	if ($info && $info['status'] == 1) {
+	        		Dever::db('bill/cash')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time()));
+	        	}
+	        }
+        }
+    }
+
+    public function sellUpdate($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $mid = Dever::param('mid', $data);
+        $num = Dever::param('num', $data);
+        $desc = Dever::param('desc', $data);
+        if ($mid && $num && $desc) {
+        	$member = Dever::db('agent/member')->find($mid);
+        	if ($member && $member['status'] == 2) {
+        		Dever::load('bill/lib/sell')->up($mid, 2, $num, $member['role'], $id, $desc);
+        		$where['where_id'] = $mid;
+        		$where['group_sell'] = $num;
+        		$where['sell'] = $num;
+        		Dever::db('agent/member')->upGroupSellOne($where);
+        	} else {
+        		Dever::db('bill/push_sell')->update(array('where_id' => $id, 'status' => 2));
+        		Dever::alert('代理商未审核通过,发放失败');
+        	}
+        }
+    }
+}

+ 96 - 27
service/bill/lib/Sell.php

@@ -6,37 +6,29 @@ use Dever;
 
 class Sell
 {
-    public function up($mid, $type, $cash, $role, $type_id)
+    public function up($mid, $type, $num, $role, $type_id, $desc)
     {
         $member = Dever::db('agent/member')->find(array('id' => $mid, 'clear' => true));
         if ($member['status'] <= 2) {
-        	$where['mid'] = $mid;
-        	$where['order_id'] = $type_id;
-        	$where['clear'] = true;
-        	$info = Dever::db('bill/sell')->find($where);
-        	if (!$info) {
-        		$data = $where;
-        		$data['order_num'] = $this->getOrderId();
-        		if ($type == 1) {
-        			$data['num'] = $cash;
-        		} else {
-        			$data['group_num'] = $cash;
-        		}
-        		
-        		$data['role'] = $role;
-        		Dever::db('bill/sell')->insert($data);
-        	} else {
-        		$data = array();
-        		$data['where_id'] = $info['id'];
-        		if ($type == 1) {
-        			$data['num'] = $cash;
-        		} else {
-        			$data['group_num'] = $cash;
-        		}
-        		
-        		Dever::db('bill/sell')->update($data);
-        	}
+            $desc = explode(',', $desc);
+            $desc = $desc[0];
+            $where['mid'] = $mid;
+            $where['type'] = $type;
+            $where['type_id'] = $type_id;
+            $where['clear'] = true;
+            $info = Dever::db('bill/sell')->find($where);
+            if (!$info) {
+                $data = $where;
+                $data['order_num'] = $this->getOrderId();
+                $data['num'] = $num;
+                $data['role'] = $role;
+                $data['desc'] = $desc;
+                return Dever::db('bill/sell')->insert($data);
+            }
+            return $info['id'];
         }
+
+        return false;
     }
 
     /**
@@ -54,4 +46,81 @@ class Sell
             return $this->getOrderId();
         }
     }
+
+    # 展示详情
+    public function show()
+    {
+        $id = Dever::input('id');
+
+        $config = Dever::db('bill/sell')->config['set'];
+
+        $info = Dever::db('bill/sell')->one($id);
+
+        $type = $config['type'][$info['type']];
+
+        $member = Dever::db('agent/member')->find($info['mid']);
+        $role = Dever::db('setting/role')->one($member['role']);
+        $level = Dever::db('setting/level')->one($member['level_id']);
+
+        if ($member['shop_id']) {
+            $shop = Dever::db('shop/info')->one($member['shop_id']);
+        } else {
+            $shop['id'] = -1;
+            $shop['name'] = '无';
+        }
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+
+        $result = array();
+
+        $result['代理商信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('代理商', $member['name'] . ' ' . $member['mobile']),
+                    array('代理角色', $role['name'] . ($level ? '('.$level['name'].')' : '')),
+                    array('所属店铺', $shop['name']),
+                ),
+
+                array
+                (
+                    array('资金余额', '¥' . $member['cash'] . '元'),
+                    array('直推业绩', '¥' . $member['sell'] . '元'),
+                    array('团队业绩', '¥' . $member['group_sell'] . '元'),
+                ),
+            ),
+        );
+
+        $result['业绩信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('流水号', $info['order_num']),
+                    array('交易时间', $cdate),
+                    array('业绩类型', $type),
+                ),
+
+                array
+                (
+                    array('业绩金额', '¥' . $info['num'] . '元'),
+                    array('业绩说明', $info['desc']),
+                ),
+            )
+        );
+
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => array(),
+        );
+        $html = Dever::show($head, $result);
+
+        return $html;
+    }
 }

+ 46 - 0
service/bill/lib/Tixian.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace Bill\Lib;
+
+use Dever;
+
+class Tixian
+{
+    public function up($mid, $ycash, $cash, $name, $bank, $bankname, $card)
+    {
+        $member = Dever::db('agent/member')->find(array('id' => $mid, 'clear' => true));
+        if ($member['status'] <= 2) {
+        	$cash = -1*$cash;
+        	$ycash = -1*$ycash;
+        	$data['mid'] = $mid;
+    		$data['order_num'] = $this->getOrderId();
+    		$data['yue'] = $member['cash'] + $ycash;
+    		$data['ycash'] = $ycash;
+    		$data['cash'] = $cash;
+    		$data['name'] = $name;
+    		$data['bank'] = $bank;
+    		$data['bankname'] = $bankname;
+    		$data['card'] = $card;
+            $data['status'] = 1;
+    		return Dever::db('bill/tixian')->insert($data);
+        }
+
+        return false;
+    }
+
+    /**
+     * 生成订单号
+     *
+     * @return mixed
+     */
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('C');
+        $state = Dever::db('bill/cash')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+}

+ 5 - 0
service/bill/template/manage/push_cash.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'bill/lib/cash.show')
+->display();

+ 5 - 0
service/bill/template/manage/push_sell.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'bill/lib/sell.show')
+->display();

+ 10 - 0
service/setting/database/base.php

@@ -45,6 +45,16 @@ return array
             'update'    => 'text',
         ),
 
+        'tax'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '提现手续费-输入10就是10%',
+            'default'   => '8',
+            'desc'      => '提现手续费',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
 		'desc'      => array
         (
             'type'      => 'text-255',

+ 3 - 3
service/setting/database/level.php

@@ -60,7 +60,7 @@ return array
 
         'target'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '目标额-成为该等级的团队业绩总数,以万为单位',
             'default'   => '0',
             'desc'      => '目标额',
@@ -71,7 +71,7 @@ return array
 
         'value'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '补贴额-补贴团队政策,这里以百分比为单位,如输入10,就是每次推广分润10%',
             'default'   => '0',
             'desc'      => '补贴额',
@@ -82,7 +82,7 @@ return array
 
         'target_value'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '奖励额-总业绩的百分比奖励,这里以百分比为单位,如输入10,就是总业绩10%奖励',
             'default'   => '0',
             'desc'      => '奖励额',

+ 2 - 2
service/setting/database/role.php

@@ -106,7 +106,7 @@ return array
 
         'price'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '代理价格-以元为单位',
             'default'   => '0',
             'desc'      => '代理价格',
@@ -128,7 +128,7 @@ return array
 
         'profit'      => array
         (
-            'type'      => 'float-11',
+            'type'      => 'float-11,2',
             'name'      => '收益-区域内门店利润百分比,这里直接输入数字即可,如输入10,就是10%',
             'default'   => '0',
             'desc'      => '收益',