dever 3 years ago
parent
commit
1cfab7ea9e

+ 28 - 2
config/base.php

@@ -53,7 +53,7 @@ $config['base'] = array
         'username' => '2934170@qq.com',
         'password' => 'ybilyxddfe521',
         'from' => array('2934170@qq.com', '厨人易料'),
-        'renzheng' => array
+        'agent' => array
         (
             'title' => '厨人易料代理商邮箱认证',
             'link' => 'agent/lib/email.act',
@@ -67,6 +67,32 @@ $config['base'] = array
 
 如果上面的链接无法点击,您也可以复制链接到您的浏览器内打开,完成邮箱认证(链接有效期一天)。',
         ),
+
+        'option' => array
+        (
+            'title' => '厨人易料期权管理系统',
+            'link' => 'option/lib/email.act',
+            'content' => '{username},您好,
+
+欢迎您使用期权管理系统,请点击以下链接,完成邮箱验证。
+
+验证后请重新打开期权管理系统,确认您的期权交付情况。
+
+【{link}】
+
+验证邮件发送日期:{date}
+
+请于7日内点击确认按钮,超过时限未确认,将失去期权获取资格。
+
+本邮件仅供期权使用人验证邮箱使用,请勿回复。
+
+
+
+本系统由ESOP服务商提供技术支持,如有疑问,请及时联系客服。
+
+
+',
+        ),
     ),
 
     # 直接使用sms组件,这部分配置废弃
@@ -74,7 +100,7 @@ $config['base'] = array
     'mobileCode' => array
     (
         # debug模式
-        'debug' => false,
+        'debug' => true,
         # 发送短信的接口
         'url' => 'https://feginesms.market.alicloudapi.com/codeNotice',
         'url' => 'https://dysmsapi.aliyuncs.com/?Action=SendSms',

+ 16 - 0
config/env/localhost/default.php

@@ -59,6 +59,22 @@ $config['database'] = array
 		'password' => isset($dc['mysql']) ? $dc['mysql']['password'] : '123456',
 		'charset' => 'utf8mb4',
 	),
+
+    # 定义历史数据库
+    'old' => array
+    (
+        'type' => 'pdo',
+        'host' => array
+        (
+            'read' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
+            'update' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
+            'create' => isset($dc['mysql']) ? $dc['mysql']['host_create'] : 'web-mysql:3306',
+        ),
+        'database' => 'chuzren1yi9liao',
+        'username' => isset($dc['mysql']) ? $dc['mysql']['username'] : 'root',
+        'password' => isset($dc['mysql']) ? $dc['mysql']['password'] : '123456',
+        'charset' => 'utf8mb4',
+    ),
 );
 
 # 缓存配置

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

@@ -23,7 +23,7 @@ class Agreement
 		if ($source == 2) {
             # 获取当前登录的uid
             $mid = Dever::load('passport/user')->check(false);
-            if (!$mid) {
+            if (!$mid || $mid <= 0) {
                 Dever::alert('请先登录');
             }
 			

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

@@ -10,7 +10,7 @@ class Email
     public function act_api()
     {
         //$signature = Dever::input('signature');
-        $signature = $_GET['signature']
+        $signature = $_GET['signature'];
         if (!$signature) {
             Dever::alert('您的验证信息已失效,请重新发送验证邮件');
         }

+ 150 - 0
service/agent/lib/Import.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace Agent\Lib;
+
+use Dever;
+
+class Import
+{
+    # 图片存放地址
+    private $img_host = 'https://cryl.yijiuguanfang.com/attachment/';
+
+    public function __construct()
+    {
+        $this->db = Dever::db('agent/test:old');
+    }
+
+    public function get_api()
+    {
+        //select count(*) as num,mobile from ims_ewei_shop_member where restatus = 0 and issuingstate = 1 and status = 1 and  prestatus = 1 and isagent = 1 group by mobile order by num desc
+        # 获取已审核通过、权益已发放的用户
+        $data = $this->db->fetchAll('select * from ims_ewei_shop_member where restatus = 0 and status = 1 and  prestatus = 1 and isagent = 1 order by id asc limit 10');
+
+        print_r($data);die;
+
+        foreach ($data as $k => $v) {
+
+            # 创建代理商
+            $where = array();
+            $member = Dever::db('agent/member')->find($v['id']);
+            if (!$member) {
+                $data = $where;
+                $data['id'] = $v['id'];
+                $data['name'] = $v['realname'];
+                $data['rdate'] = $v['agenttime'];
+                $data['avatar'] = $v['avatar'];
+                $data['username'] = $v['nickname'];
+                $data['parent_mid'] = $v['agentid'];
+                $data['role'] = $this->getRole($v['agentlevel']);
+                $data['area'] = str_replace(' ', ',', $v['datavalue']);
+                if ($v['streetvalue']) {
+                    $data['area'] .= ',' . $v['streetvalue'];
+                }
+
+                if ($v['entertype'] == 1) {
+                    $data['type'] = 1;
+                } else {
+                    $data['type'] = 2;
+                }
+
+                $data['sign'] = $v['contractsign'];
+                $data['idcard'] = $v['idnumber'];
+                if ($v['identity']) {
+                    $identity = Dever::json_decode($v['identity']);
+                    if (isset($identity[0])) {
+                        $data['idcard_front'] = $identity[0];
+                    }
+                    if (isset($identity[1])) {
+                        $data['idcard_back'] = $identity[1];
+                    }
+                }
+
+                $data['company_name'] = $v['company'];
+
+                $data['address'] = $v['province'] . $v['city'] . $v['area'] . $v['street'];
+
+                $data['cash'] = $v['credit2'];
+                $data['group_sell'] = $v['allcommission'];
+                $data['status'] = 2;
+                $data['import'] = 2;
+                
+                $mid = Dever::db('agent/member')->insert($data);
+            } else {
+                $mid = $v['id'];
+            }
+
+            if ($mid > 0) {
+                # 创建代理商订单
+                $order_where['mid'] = $mid;
+                $order_where['mobile'] = $v['mobile'];
+                $order_where['status'] = 4;
+                $order = Dever::db('agent/order')->find($order_where);
+
+                if (!$order) {
+                    $order_data = $order_where;
+                    $order_data['pay_status'] = 1;
+                    $order_data['pay_status'] = 2;
+                    $order_data['pay_type'] = 2;
+
+                    $order_id = Dever::db('agent/order')->insert($order_data);
+                }
+            }
+        }
+        print_r($data);die;
+    }
+
+    # 状态对应
+    private function getStatus($data)
+    {
+        # 完成权益发放、财务审核、初审的认为订单有效
+        if ($data['issuingstate'] == 1 && $data['status'] == 1 && $data['prestatus'] == 1) {
+            return 4;
+        } elseif ($data['status'] == 1 && $data['prestatus'] == 1) {
+            return 3;
+        } elseif ($data['prestatus'] == 1) {
+            return 2;
+        } elseif ($data['restatus'] == 1) {
+            return 5;
+        } else {
+            return 1;
+        }
+    }
+
+    # 代理商角色对应
+    private function getRole($role)
+    {
+        # key是历史数据 value是最新数据
+        $config = array
+        (
+            # 创服
+            5 => 5,
+
+            # 创客
+            4 => 6,
+
+            # 逍客
+            8 => 7,
+
+            # 城市
+            1 => 2,
+
+            # 区县
+            2 => 3,
+
+            # 街道
+            3 => 4,
+
+            # 炒菜机分享会员
+            6 => 8,
+
+            # 热敏炉分享会员
+            7 => 9,
+        );
+
+        if (isset($config[$role]) && $config[$role]) {
+            return $config[$role];
+        }
+
+        return 1;
+    }
+}

+ 6 - 0
service/agent/lib/Manage.php

@@ -56,6 +56,11 @@ class Manage
                     Dever::alert('上级代理商不能设置为自己');
                     return;
                 }
+
+                # 重置关系
+                Dever::load('invite/api')->resetRelation($mid, $parent['id']);
+
+                /*
                 # 删除之前关系
                 Dever::load('invite/api')->dropRelation($mid, $parent['id']);
                 # 获取所有下级
@@ -68,6 +73,7 @@ class Manage
 
                 # 重新设置关系
                 Dever::load('invite/api')->setRelation($mid, $parent['id']);
+                */
                 Dever::db('agent/member')->update(array('id' => $mid, 'parent_mid' => $parent['id']));
             } else {
                 Dever::alert('上级代理商还未注册或者已封禁');

+ 27 - 0
service/option/assets/manage/html/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>

+ 418 - 0
service/option/database/account.php

@@ -0,0 +1,418 @@
+<?php
+
+$status = array
+(
+    1 => '未激活',
+    2 => '正常',
+    3 => '停用',
+);
+
+$audit_manage = array
+(
+    //1 => '未开始审核',
+    //2 => '待审核',
+    3 => '审核通过',
+    4 => '审核未通过',
+);
+
+$audit = array
+(
+    1 => '未开始审核',
+    2 => '待审核',
+    3 => '审核通过',
+    4 => '审核未通过',
+);
+
+$type = array
+(
+    1 => '子账号',
+    2 => '主账号',
+);
+
+$is_email = array
+(
+    1 => '邮箱已验证',
+    2 => '邮箱未验证',
+);
+
+$is_idcard = array
+(
+    1 => '已上传',
+    2 => '未上传',
+);
+
+$is_sign = array
+(
+    1 => '已签署',
+    2 => '未签署',
+);
+
+$col = Dever::input('col');
+
+return array
+(
+    # 表名
+    'name' => 'account',
+    # 显示给用户看的名称
+    'lang' => '期权账户认证审核',
+    'order' => 100,
+    'set' => array
+    (
+        'status' => $status,
+        'type' => $type,
+        'audit' => $audit,
+        'is_email' => $is_email,
+        'is_idcard' => $is_idcard,
+        'is_sign' => $is_sign,
+    ),
+    'start' => array
+    (
+        'insert' => 'option/lib/manage.updateAccountAudit',
+    ),
+    'end' => array
+    (
+        'update' => 'option/lib/manage.updateAccount',
+    ),
+    'check' => 'mobile',
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '账号类型',
+            'default'   => '1',
+            'desc'      => '账号类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'hidden',
+            'update'    => 'radio',
+        ),
+
+        'key'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '账户索引-通过账户索引来判断同一个人',
+            'default'   => '',
+            'desc'      => '账户索引',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => 'Dever::load("option/lib/account.getInfo", {id})',
+            'list_order' => 1,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '请输入手机号',
+            'match'     => Dever::rule('mobile'),
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            //'list'      => true,
+        ),
+
+        'is_email'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '邮箱是否验证',
+            'default'   => '2',
+            'desc'      => '邮箱是否验证',
+            'match'     => 'is_numeric',
+            'option'    => $is_email,
+        ),
+
+        'email'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '邮箱',
+            'default'   => '',
+            'desc'      => '请输入邮箱',
+            'match'     => 'option||' . Dever::rule('email'),
+            //'update'    => 'text',
+        ),
+
+        'is_idcard'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '身份证资料',
+            'default'   => '2',
+            'desc'      => '身份证资料',
+            'match'     => 'is_numeric',
+            'option'    => $is_idcard,
+            //'update'    => 'radio',
+            'list'      => true,
+            'list_order' => 3,
+        ),
+
+        'idcard'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '身份证号码',
+            'default'   => '',
+            'desc'      => '身份证号码',
+            'match'     => Dever::rule('idcard'),
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'idcard_front'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证正面',
+            'default'   => '',
+            'desc'      => '身份证正面',
+            'match'     => 'option',
+            //'update'    => 'image',
+            'key'       => '8',
+            //'place'     => '660*660',
+        ),
+
+        'idcard_back'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证背面',
+            'default'   => '',
+            'desc'      => '身份证背面',
+            'match'     => 'option',
+            //'update'    => 'image',
+            'key'       => '8',
+            //'place'     => '660*660',
+        ),
+
+        'is_sign'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '合同签字',
+            'default'   => '2',
+            'desc'      => '合同签字',
+            'match'     => 'is_numeric',
+            'option'    => $is_sign,
+            //'update'    => 'radio',
+            'list'      => true,
+            'list_order' => 4,
+        ),
+
+        'sign'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '合同签字',
+            'default'   => '',
+            'desc'      => '合同签字',
+            'match'     => 'option',
+            //'update'    => 'image',
+            'key'       => '7',
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核状况',
+            'default'   => $col ? '3' : '1',
+            'desc'      => '审核状况',
+            'match'     => 'is_numeric',
+            'option'    => $audit_manage,
+            'search'    => 'select',
+            'update'    => $col ? 'radio' : false,
+            'list'      => 'Dever::load("option/lib/account.getAudit", {id})',
+            'list_order' => 5,
+            'control'   => 'audit',
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '审核备注',
+            'default'   => '',
+            'desc'      => '审核备注',
+            'match'     => 'option',
+            'update'    => $col ? 'textarea' : false,
+            'show'      => 'audit=4',
+        ),
+
+        'audit_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'match'     => 'is_numeric',
+            'desc'      => '审核时间',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            //'search'    => 'select',
+            //'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'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list_order' => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        //'insert' => false,
+        'delete' => false,
+        //'edit' => false,
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"cash&aid={id}&page_type=1"'),
+
+            'edit' => array('审核', 'audit,audit_desc', '{audit} == 2'),
+            //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin,tk_status', '{status} == 6'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getInfo' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'status' => 2,
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'type' => 'one',
+            'col' => '*',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'idcard' => 'yes',
+                'id' => array('yes', '!='),
+                'status' => 2,
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'type' => 'all',
+            'page' => array(20, 'list'),
+            'col' => '*',
+        ),
+
+        'upCash' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes', '+='),
+            ),
+        ),
+
+        'upSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes', '+='),
+                'upcol' => array('yes-sell', '+='),
+                'level_id' => 'yes',
+            ),
+        ),
+
+        'upGroupSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes', '+='),
+                'upcol' => array('yes-group_sell', '+='),
+                'level_id' => 'yes',
+            ),
+        ),
+
+        'upGroupSellOne' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'group_sell' => array('yes', '+='),
+            ),
+        ),
+
+        # 获取订单数量
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => 'yes',
+                'role' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+    ),
+);

+ 327 - 0
service/option/database/agreement.php

@@ -0,0 +1,327 @@
+<?php
+
+$status = array
+(
+    1 => '待签署',
+    2 => '有效',
+    3 => '作废',
+);
+$aid = Dever::input('search_option_aid');
+$button = array();
+if ($aid) {
+    $button = array
+    (
+        '返回上一页' => array('location', 'l=project/database/list&project=option&table=cash&page_type=1&aid=' . $aid),
+    );
+}
+return array
+(
+    # 表名
+    'name' => 'agreement',
+    # 显示给用户看的名称
+    'lang' => '合同管理',
+    'order' => 10,
+    'menu' => false,
+    'status' => $status,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'option/account-find',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '期权账户',
+            'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
+            'list_order' => 3,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '合同编号',
+            'default'   => '',
+            'desc'      => '合同编号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'agreement_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合同模板id',
+            'default'   => '',
+            'desc'      => '合同模板id',
+            'match'     => 'is_numeric',
+        ),
+
+        'agreement_name'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '合同名称',
+            'default'   => '',
+            'desc'      => '合同名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'list_order' => 6,
+        ),
+
+        'sign'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '合同签名',
+            'default'   => '',
+            'desc'      => '合同签名',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '7',
+            'list'      => '"<img src=\'{sign}\' width=\'150\'>"',
+            'list_order' => 7,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '请输入手机号',
+            'match'     => Dever::rule('mobile'),
+            'update'    => 'text',
+            'search'    => $aid ? 'hidden' : 'fulltext',
+            //'list'      => $aid ? false : true,
+            //'list_order' => 2,
+        ),
+
+        'idcard'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '身份证号码',
+            'default'   => '',
+            'desc'      => '身份证号码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'idcard_front'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证正面',
+            'default'   => '',
+            'desc'      => '身份证正面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+        ),
+
+        'idcard_back'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证背面',
+            'default'   => '',
+            'desc'      => '身份证背面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+        ),
+
+        'address'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '地址',
+            'default'   => '',
+            'desc'      => '地址',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'qdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '协议签订时间',
+            'match'     => 'is_numeric',
+            'desc'      => '协议签订时间',
+            'update'    => 'text',
+        ),
+
+        'sdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '有效期开始时间',
+            'match'     => 'is_numeric',
+            'desc'      => '有效期开始时间',
+            'update'    => 'text',
+        ),
+
+        'edate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '有效期结束时间',
+            'match'     => 'is_numeric',
+            'desc'      => '有效期结束时间',
+            'update'    => 'text',
+        ),
+
+        'udate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '更新时间',
+            'match'     => 'is_numeric',
+            'desc'      => '更新时间',
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i", {udate})',
+            'list_order' => 5,
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '合同内容',
+            'default'   => '',
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '合同状态',
+            'default'   => '1',
+            'desc'      => '合同状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'list_order' => 8,
+        ),
+
+        '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' => 4,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'button' => $button,
+        'list_button' => array
+        (
+            'new' => array('查看', '"lib/agreement.location?id={id}"', 'option'),
+            'oper' => array('作废并生成', '"option/lib/manage.dropAgreement?id={id}"', "{status} == 2"),
+            'oper1' => array('更新', '"option/lib/manage.upAgreement?id={id}"', "{status} == 2"),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'agreement_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getOld' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'agreement_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'id,aid,agreement_id,status,qdate,name,area,agreement_name',
+        ),
+    ),
+);

+ 242 - 0
service/option/database/bill_duifu.php

@@ -0,0 +1,242 @@
+<?php
+
+$type = Dever::db('option/cash')->config['config_type'];
+
+$status = array
+(
+    1 => '已生效',
+    2 => '未生效',
+);
+
+$audit = array
+(
+    1 => '正常',
+    2 => '作废',
+);
+
+$audit_manage = array
+(
+    //1 => '正常',
+    2 => '作废',
+);
+
+$aid = Dever::input('search_option_aid');
+$button = array();
+if ($aid) {
+    $button = array
+    (
+        '返回上一页' => array('location', 'l=project/database/list&project=option&table=cash&page_type=1&aid=' . $aid),
+    );
+}
+
+
+return array
+(
+    # 表名
+    'name' => 'bill_duifu',
+    # 显示给用户看的名称
+    'lang' => '期权兑付记录',
+    'order' => 88,
+    'end' => array
+    (
+        'update' => 'option/lib/manage.setDuifu',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '流水号',
+            'default'   => '',
+            'desc'      => '流水号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'list_order'  => 1,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '交易类型',
+            'default'   => '1',
+            'desc'      => '交易类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+            'list'      => true,
+            'list_order'  => 7,
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'option/account-find',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '期权账户',
+            'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
+            'list_order' => 3,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '兑付价值',
+            'default'   => '0',
+            'desc'      => '兑付价值',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+            'list_order' => 5,
+        ),
+
+        'yue'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '兑付后价值',
+            'default'   => '0',
+            'desc'      => '兑付后价值',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+            'list_order' => 6,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否生效',
+            'default'   => '2',
+            'desc'      => '是否生效',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'update'    => 'radio',
+            'search'    => 'hidden',
+            //'list'      => true,
+            //'list_order' => 4,
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核',
+            'default'   => '1',
+            'desc'      => '审核',
+            'match'     => 'is_numeric',
+            'option'    => $audit_manage,
+            'update'    => 'radio',
+            'control'   => 'audit',
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            'list_order'  => 9,
+        ),
+
+        'audit_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'match'     => 'is_numeric',
+            'desc'      => '审核时间',
+            'default'   => '',
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '操作人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '操作人',
+            'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#name", {audit_admin}) : "-"',
+            'list_order'  => 8,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '处理时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            'default'   => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list_order' => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'button' => $button,
+        'list_button' => array
+        (
+            //'list' => array('查看详情', '"member_area&mid={id}&page_type=1"'),
+
+            'edit' => array('作废', 'audit,audit_desc', '{audit} == 1'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'type' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
+    ),
+);

+ 242 - 0
service/option/database/bill_fafang.php

@@ -0,0 +1,242 @@
+<?php
+
+$type = Dever::db('option/cash')->config['config_type'];
+
+$status = array
+(
+    1 => '已生效',
+    2 => '未生效',
+);
+
+$audit = array
+(
+    1 => '正常',
+    2 => '作废',
+);
+
+$audit_manage = array
+(
+    //1 => '正常',
+    2 => '作废',
+);
+
+$aid = Dever::input('search_option_aid');
+$button = array();
+if ($aid) {
+    $button = array
+    (
+        '返回上一页' => array('location', 'l=project/database/list&project=option&table=cash&page_type=1&aid=' . $aid),
+    );
+}
+
+
+return array
+(
+    # 表名
+    'name' => 'bill_fafang',
+    # 显示给用户看的名称
+    'lang' => '期权发放记录',
+    'order' => 89,
+    'end' => array
+    (
+        'update' => 'option/lib/manage.setFafang',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '流水号',
+            'default'   => '',
+            'desc'      => '流水号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'list_order'  => 1,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '交易类型',
+            'default'   => '1',
+            'desc'      => '交易类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+            'list'      => true,
+            'list_order'  => 7,
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'option/account-find',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '期权账户',
+            'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
+            'list_order' => 3,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '发放价值',
+            'default'   => '0',
+            'desc'      => '发放价值',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+            'list_order' => 5,
+        ),
+
+        'yue'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '发放后价值',
+            'default'   => '0',
+            'desc'      => '发放后价值',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+            'list_order' => 6,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否生效',
+            'default'   => '2',
+            'desc'      => '是否生效',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'update'    => 'radio',
+            'search'    => 'hidden',
+            //'list'      => true,
+            //'list_order' => 4,
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核',
+            'default'   => '1',
+            'desc'      => '审核',
+            'match'     => 'is_numeric',
+            'option'    => $audit_manage,
+            'update'    => 'radio',
+            'control'   => 'audit',
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            'list_order'  => 9,
+        ),
+
+        'audit_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'match'     => 'is_numeric',
+            'desc'      => '审核时间',
+            'default'   => '',
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '操作人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '操作人',
+            'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#name", {audit_admin}) : "-"',
+            'list_order'  => 8,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '处理时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            'default'   => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list_order' => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'button' => $button,
+        'list_button' => array
+        (
+            //'list' => array('查看详情', '"member_area&mid={id}&page_type=1"'),
+
+            'edit' => array('作废', 'audit,audit_desc', '{audit} == 1'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'type' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
+    ),
+);

+ 230 - 0
service/option/database/bill_jiaofu.php

@@ -0,0 +1,230 @@
+<?php
+
+$type = Dever::db('option/cash')->config['config_type'];
+
+$status = array
+(
+    1 => '已确认',
+    2 => '未确认',
+);
+
+$audit = array
+(
+    1 => '正常',
+    2 => '作废',
+);
+
+$audit_manage = array
+(
+    //1 => '正常',
+    2 => '作废',
+);
+
+$aid = Dever::input('search_option_aid');
+$button = array();
+if ($aid) {
+    $button = array
+    (
+        '返回上一页' => array('location', 'l=project/database/list&project=option&table=cash&page_type=1&aid=' . $aid),
+    );
+}
+
+
+return array
+(
+    # 表名
+    'name' => 'bill_jiaofu',
+    # 显示给用户看的名称
+    'lang' => '期权交付记录',
+    'order' => 90,
+    'end' => array
+    (
+        'update' => 'option/lib/manage.setJiaofu',
+    ),
+    'config_audit' => $audit,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '流水号',
+            'default'   => '',
+            'desc'      => '流水号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'list_order'  => 1,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '交易类型',
+            'default'   => '1',
+            'desc'      => '交易类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+            'list'      => true,
+            'list_order'  => 6,
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'option/account-find',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '期权账户',
+            'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
+            'list_order' => 3,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '期权价值',
+            'default'   => '0',
+            'desc'      => '期权价值',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+            'list_order' => 5,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '交付确认',
+            'default'   => '2',
+            'desc'      => '交付确认',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'update'    => 'radio',
+            'list'      => true,
+            'list_order' => 4,
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核',
+            'default'   => '1',
+            'desc'      => '审核',
+            'match'     => 'is_numeric',
+            'option'    => $audit_manage,
+            'update'    => 'radio',
+            'control'   => 'audit',
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            'list_order'  => 8,
+        ),
+
+        'audit_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'match'     => 'is_numeric',
+            'desc'      => '审核时间',
+            'default'   => '',
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '操作人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '操作人',
+            'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#name", {audit_admin}) : "-"',
+            'list_order'  => 7,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '处理时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            'default'   => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list_order' => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'button' => $button,
+        'list_button' => array
+        (
+            //'list' => array('查看详情', '"member_area&mid={id}&page_type=1"'),
+
+            'edit' => array('作废', 'audit,audit_desc', '{audit} == 1'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'aid' => 'yes',
+                'type' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'type' => 'all',
+            'col' => '*',
+        ),
+    ),
+);

+ 194 - 0
service/option/database/cash.php

@@ -0,0 +1,194 @@
+<?php
+
+$type = array
+(
+    1 => '期权账户',
+    2 => '原始期权账户',
+);
+
+return array
+(
+    # 表名
+    'name' => 'cash',
+    # 显示给用户看的名称
+    'lang' => '期权账户数据',
+    'order' => 100,
+    'menu' => false,
+    'config_type' => $type,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'option/account-find',
+                'col' => 'mobile',
+                'result' => 'id',
+            ),
+            'list_name' => '姓名',
+            'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
+            'list_order' => 4,
+        ),
+
+        'daijiaofu'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '待交付额度',
+            'default'   => '0.00',
+            'desc'      => '待交付额度',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'jiaofu'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '已交付额度',
+            'default'   => '0.00',
+            'desc'      => '交付额度',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'fafang'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '发放额度',
+            'default'   => '0.00',
+            'desc'      => '发放额度',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'duifu'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '兑付额度',
+            'default'   => '0.00',
+            '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'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list_order' => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+        'page_list' => 'cash',
+    ),
+
+    'request' => array
+    (
+        'upCash_daijiaofu' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes-daijiaofu', '+='),
+            ),
+        ),
+
+        'upCash_jiaofu' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes-jiaofu', '+='),
+            ),
+        ),
+
+        'upCash_fafang' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes-fafang', '+='),
+                'jiaofu' => array('yes', '-='),
+            ),
+        ),
+
+        'upCash_duifu' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'cash' => array('yes-duifu', '+='),
+                'fafang' => array('yes', '-='),
+            ),
+        ),
+    ),
+);

+ 161 - 0
service/option/database/push_cash.php

@@ -0,0 +1,161 @@
+<?php
+
+$aid = Dever::input('search_option_aid');
+
+$type = array
+(
+    1 => '期权交付',
+    2 => '期权发放',
+    //3 => '期权兑付',
+    4 => '原始期权交付',
+    5 => '原始期权发放',
+    //6 => '原始期权兑付',
+);
+$status = array
+(
+    1 => '操作成功',
+    2 => '操作失败',
+);
+return array
+(
+    # 表名
+    'name' => 'push_cash',
+    # 显示给用户看的名称
+    'lang' => '发放资金',
+    'order' => 99,
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'option/lib/manage.cashUpdate',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'aid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '期权账户',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+            'value'     => $aid,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '操作类型',
+            'default'   => '1',
+            'desc'      => '操作类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+        ),
+
+        '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
+    (
+        
+    ),
+);

+ 8 - 0
service/option/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'option');
+define('DEVER_APP_LANG', '期权管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 30);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-form');
+include(DEVER_APP_PATH . '../boot.php');

+ 270 - 0
service/option/lib/Account.php

@@ -0,0 +1,270 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Account
+{
+    public function getInfo($id, $table = 'option/account')
+    {
+        if ($id < 0) {
+            return '无';
+        }
+        $account = Dever::db($table)->find($id);
+        if ($account) {
+            $string = $account['name'] . '<br />' . $account['mobile'] . '<br />' . $account['idcard'] . '<br />' . $account['email'];
+
+            if ($account['is_email'] == 1) {
+                $string .= '<br /><font style="color:blue">邮箱已验证</font>';
+            } else {
+                $string .= '<br /><font style="color:red">邮箱未验证</font>';
+            }
+            return $string;
+            
+        } else {
+            return '';
+        }
+    }
+
+    public function getAudit($id, $table = 'option/account')
+    {
+        if ($id < 0) {
+            return '无';
+        }
+        $audit = Dever::db($table)->config['set']['audit'];
+        $account = Dever::db($table)->find($id);
+        if ($account) {
+            $string = $audit[$account['audit']];
+            if ($account['audit'] == 4) {
+                $string .= '<br />原因:' . $account['audit_desc'];
+            }
+            if ($account['audit_date']) {
+                $audit_date = date('Y-m-d H:i:s', $account['audit_date']);
+                $string .= '<br />'.$audit_date;
+            }
+            return $string;
+            
+        } else {
+            return '';
+        }
+    }
+
+    /**
+     * 验证手机号
+     * @return mixed
+     */
+    public function checkMobile($mobile)
+    {
+        $rule = Dever::rule('mobile');
+
+        if (!$mobile) {
+            Dever::alert('手机号不能为空');
+        }
+        if (!preg_match($rule, $mobile)) {
+            Dever::alert('手机号码格式错误');
+        }
+
+        return $mobile;
+    }
+
+    /**
+     * 验证验证码
+     * @return mixed
+     */
+    public function checkMcode($mobile)
+    {
+        $code = Dever::input('mcode');
+        if (!$code) {
+            Dever::alert('请输入验证码');
+        }
+        $code = Dever::load('passport/reg')->mcode($mobile, $code, 1);
+        if (!$code) {
+            Dever::alert('验证码输入错误');
+        }
+    }
+
+    /**
+     * 查看详情
+     * @return mixed
+     */
+    public function show()
+    {
+        $aid = Dever::input('aid');
+        $account = Dever::db('option/account')->one($aid);
+
+        $config = Dever::db('option/account')->config['set'];
+
+        $result['账户信息'] = $this->getShowInfo($account, $config);
+
+        $button = array();
+
+        $button[0]['btn'][] = array
+        (
+            'type' => 'edit',
+            'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$account['id'].'&status=1&col=name,idcard,idcard_front,idcard_back', 'manage'),
+            'name' => '修改认证资料',
+        );
+        $url = '';
+        if ($account['status'] == 3) {
+            $button[0]['btn'][] = array
+            (
+                'type' => 'action',
+                'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=2', 'option'),
+                'name' => '恢复账号',
+            );
+        } elseif ($account['status'] == 2) {
+            $button[0]['btn'][] = array
+            (
+                'type' => 'action',
+                'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=3', 'option'),
+                'name' => '禁用账号',
+            );
+        }
+
+        $aid = $account['id'];
+        if ($account['type'] == 1) {
+            # 给主账户发期权
+            $parent = Dever::db('option/account')->find(array('type' => 2, 'key' => $account['key']));
+            if ($parent) {
+                $aid = $parent['id'];
+            } else {
+                $aid = false;
+            }
+        }
+
+        # 获取账户资金
+        $cash_type = Dever::db('option/cash')->config['config_type'];
+        $cash = Dever::db('option/cash')->select(array('aid' => $aid));
+
+        if ($cash) {
+            $table = array();
+            $table['head'] = array('账户类型', '待交付', '已交付总额', '已发放剩余', '未发放', '已兑付');
+            $table['body'] = array();
+
+            foreach ($cash as $k => $v) {
+                $total = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2);
+                //$weifafang = number_format($total-$v['fafang']-$v['duifu'], 2);
+                $table['body'][] = array
+                (
+                    $cash_type[$v['type']],
+                    $v['daijiaofu'],
+                    $total,
+                    //$v['jiaofu'],
+                    $v['fafang'],
+                    $v['jiaofu'],
+                    $v['duifu'],
+                );
+            }
+
+            $result['账户金额'] = array
+            (
+                'type' => 'table',
+                'content' => $table,
+            );
+        }
+
+        if ($aid) {
+            $button[0]['btn'][] = array
+            (
+                'type' => 'edit',
+                'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_aid='.$aid, 'manage'),
+                'name' => '发放期权',
+            );
+
+            $button[1]['btn'][] = array
+            (
+                'type' => 'link',
+                'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&search_option_aid='.$aid.'', 'manage'),
+                'name' => '期权交付记录',
+            );
+
+            $button[1]['btn'][] = array
+            (
+                'type' => 'link',
+                'link' => Dever::url('project/database/list?project=option&table=bill_fafang&search_option_aid='.$aid.'', 'manage'),
+                'name' => '期权发放记录',
+            );
+
+            $button[1]['btn'][] = array
+            (
+                'type' => 'link',
+                'link' => Dever::url('project/database/list?project=option&table=bill_duifu&search_option_aid='.$aid.'', 'manage'),
+                'name' => '期权兑付记录',
+            ); 
+        }
+
+        $url = Dever::url('project/database/list?project=option&table=account', 'manage');
+        $head_btn[] = array
+        (
+            'type' => 'link',
+            'link' => $url,
+            'name' => '返回上一页',
+        );
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => $head_btn,
+        );
+        $foot = $button;
+        $html = Dever::show($head, $result, $foot);
+
+        return $html;
+    }
+
+    private function getShowInfo($account, $config)
+    {
+        $result = array();
+
+        $idcard_pic = '';
+        if ($account['idcard_front']) {
+            $idcard_pic = '<a href="'.$account['idcard_front'].'" target="_blank"><img src="'.$account['idcard_front'].'" width="150" /></a>';
+        }
+        
+        if ($account['idcard_back']) {
+            $idcard_pic .= '&nbsp;&nbsp;<a href="'.$account['idcard_back'].'" target="_blank"><img src="'.$account['idcard_back'].'" width="150" /></a>';
+        }
+
+        if ($account['email']) {
+            $account['email'] .= '('.$config['is_email'][$account['is_email']].')';
+        }
+        $result = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('姓名', $account['name']),
+                    array('手机号', $account['mobile']),
+                    array('邮箱', $account['email']),
+                ),
+
+                array
+                (
+                    array('账户类型', $config['type'][$account['type']]),
+                    array('审核状态', $config['audit'][$account['audit']]),
+                    array('账户状态', $config['status'][$account['status']]),
+                ),
+            ),
+        );
+
+        $result['content'][] = array
+        (
+            array('身份证号', $account['idcard']),
+            array('身份证照片', $idcard_pic),
+        );
+
+        return $result;
+    }
+
+    public function setStatus_api()
+    {
+        $where['where_id'] = Dever::input('id');
+        $where['status'] = Dever::input('value');
+
+        Dever::db('option/account')->update($where);
+
+        return 'reload';
+    }
+}

+ 323 - 0
service/option/lib/Agreement.php

@@ -0,0 +1,323 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Agreement
+{
+    private $font_size = 12;
+
+    # 查看合同
+    public function show_api()
+    {
+        $p = Dever::input('p');
+        if (!$p) {
+            Dever::alert('传入参数有误');
+        }
+        $p = Dever::json_decode(Dever::decode($p));
+        if (!$p) {
+            Dever::alert('传入参数有误');
+        }
+        $source = $p['source'];
+        if ($source == 2) {
+            # 获取当前登录的uid
+            $aid = Dever::load('passport/user')->check(false);
+            $aid = 18;
+            if (!$aid || $aid <= 0) {
+                Dever::alert('请先登录');
+            }
+            
+        } else {
+            Dever::load('manage/auth')->init();
+            $aid = false;
+        }
+        $agreement_id = $p['agreement_id'];
+        $status = $p['status'];
+        $id = $p['id'];
+
+        if ($status == 1) {
+            $info = Dever::db('option/account')->find($id);
+            $info['aid'] = $id;
+            $info['create_state'] = 2;
+        } elseif ($status == 2) {
+            $info = Dever::db('option/agreement')->find($id);
+            if (!$info) {
+                Dever::alert('未生成合同');
+            }
+            $info['create_state'] = 1;
+            $agreement_id = $info['agreement_id'];
+        }
+        $agreement = Dever::db('setting/agreement')->find($agreement_id);
+        if (!$agreement) {
+            Dever::alert('合同模板不存在');
+        }
+
+        if ($aid && $aid != $info['aid']) {
+            Dever::alert('您没有权限查看');
+        }
+
+        $method = 'pdf_' . $agreement['type'];
+        return $this->$method($agreement, $info);
+    }
+
+    # 生成跳转链接
+    public function location_api()
+    {
+        Dever::load('manage/auth')->init();
+        $id = Dever::input('id');
+        $info = Dever::db('option/agreement')->find($id);
+        $info = $this->name($info['agreement_id'], $info, 2, 3);
+
+        Dever::location($info[1]);
+    }
+
+    # 合同名称
+    public function name($agreement, $info, $status = -1, $source = 1)
+    {
+        if (is_numeric($agreement)) {
+            $agreement = Dever::db('setting/agreement')->find($agreement);
+        }
+        $name = $agreement['name'];
+        if (strstr($name, '{name}')) {
+            $name = str_replace('{name}', $info['name'], $name);
+        }
+        if (strstr($name, '{date}')) {
+            if (isset($info['sdate'])) {
+                $sdate = date('Y年m月d日', $info['sdate']);
+            } else {
+                $sdate = date('Y年m月d日');
+            }
+            $name = str_replace('{date}', $sdate, $name);
+        }
+
+        if ($status > 0) {
+            $param = array();
+            $param['source'] = $source;
+            $param['status'] = $status;
+            $param['id'] = $info['id'];
+            $param['agreement_id'] = $agreement['id'];
+            $param = Dever::encode(Dever::json_encode($param));
+            $link = Dever::url('option/lib/agreement.show?p=' . $param);
+            if ($source == 1) {
+                # 1 是未生成合同,预览
+                # 2 是已生成合同
+                $name = '<a href="'.$link.'" target="_blank">'.$name.'</a>';
+            } else {
+                return array($name, $link);
+            }
+        }
+
+        return $name;
+    }
+
+    # 新建合同
+    public function up($account)
+    {
+        $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
+        if (!$agreement) {
+            Dever::alert('协议模板不存在');
+        }
+        $qdate = time();
+        $sdate = $qdate;
+        $edate = strtotime('+3 year', $sdate);
+        $where['aid'] = $account['id'];
+        $where['agreement_id'] = $agreement['id'];
+
+        $info = Dever::db('option/agreement')->find($where);
+
+        $where['order_num'] = $this->getOrderId();
+        $where['agreement_name'] = $this->name($agreement, $account);
+        $where['sign'] = $account['sign'];
+        $where['name'] = $account['name'];
+        $where['mobile'] = $account['mobile'];
+        $where['idcard'] = $account['idcard'];
+        $where['idcard_front'] = $account['idcard_front'];
+        $where['idcard_back'] = $account['idcard_back'];
+        $where['address'] = '';
+        $where['status'] = 2;
+        $where['udate'] = $where['cdate'] = time();
+        $where['qdate'] = $qdate;
+        $where['sdate'] = $sdate;
+        $where['edate'] = $edate;
+
+        $method = 'content_' . $agreement['type'];
+
+        if ($info) {
+            $up['content'] = Dever::array_encode($this->$method($agreement, $info));
+            $up['where_id'] = $info['id'];
+            $state = Dever::db('option/agreement')->update($up);
+        } else {
+            $up = $where;
+            $up['content'] = Dever::array_encode($this->$method($agreement, $account));
+            $state = Dever::db('option/agreement')->insert($up);
+        }
+    }
+
+    # 更新合同内容
+    public function upContent($id)
+    {
+        $state = false;
+        $info = Dever::db('option/agreement')->find($id);
+        if ($info) {
+            $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
+
+            if ($agreement) {
+                $method = 'content_' . $agreement['type'];
+                $up = array();
+                $up['content'] = Dever::array_encode($this->$method($agreement, $info));
+                $up['where_id'] = $info['id'];
+                $state = Dever::db('option/agreement')->update($up);
+            }
+        }
+        return $state;
+    }
+
+    # 作废并生成
+    public function drop($id)
+    {
+        $info = Dever::db('option/agreement')->find($id);
+        if ($info) {
+            $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
+
+            if ($agreement) {
+                $state = Dever::db('option/agreement')->update(array('where_id' => $info['id'], 'status' => 3));
+                if ($state) {
+                    # 生成新的合同
+                    unset($info['id']);
+                    unset($info['cdate']);
+                    unset($info['sdate']);
+                    unset($info['edate']);
+                    unset($info['qdate']);
+                    unset($info['sign']);
+                    $member = Dever::db('option/account')->find($info['aid']);
+
+                    $info['name'] = $member['name'];
+                    $info['idcard'] = $member['idcard'];
+                    $info['mobile'] = $member['mobile'];
+
+                    $info['sign'] = '';
+                    $info['status'] = 1;
+                    Dever::db('option/agreement')->insert($info);
+                }
+            }
+        }
+    }
+
+    /**
+     * 生成订单号
+     *
+     * @return mixed
+     */
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('AG');
+        $state = Dever::db('option/agreement')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+
+    public function content($name, $content)
+    {
+        return array('name' => $name, 'content' => $content);
+    }
+
+    public function content_6($agreement, $info)
+    {
+        $content = array();
+        $content[] = $this->content('', ' 承诺人曾与中食民安(北京)科技有限公司(以下简称“中食民安”)签订《中食民安(北京)科技有限公司代理商合作协议》,为便于更好的工作,承诺人自愿成为中食民安的市场管理培训师并销售产品,为更好的开展相关工作,承诺如下:');
+
+        $content[] = $this->content('一、我知悉相关定义', '市场管理培训师(以下简称培训师):是培训和辅导其管理区域内其他代理商,在进行销售渠道的拓展、营销推广技巧、公司政策的传达和讲解的辅导后,达到提升销售额、完成业绩指标,并对其他代理商进行监督和管理的身份。');
+
+        $content[] = $this->content('二、我确认培训师与被培训人的关系', '1、培训师管理区域与《中食民安(北京)科技有限公司代理商合作协议》中授权区域保持一致。
+    2、被培训人:指每个培训师管理区域内的其他代理,被培训人以中食民安规定方式签订《中食民安(北京)科技有限公司代理商合作协议》,即视为被培训人同意成为并自愿接受培训师的培训和管理。');
+
+        $content[] = $this->content('三、培训师及被培训人的权利和义务', '1、培训师的权利
+    1)培训师的服务费,按周结算,具体服务费标准与培训内容、培训时间另行约定;
+    2)管理和被管理关系存续期间,根据实际的培训情况、政策讲解的掌握、业绩完成情况,进行综合评定,评定标准见《市场管理培训费》,完成考核的培训师在每个奖励周期相应收益(包括物质和荣誉奖励,愿意服从中食民安根据实际完成情况及市场状态等定期或不定期调整奖励内容及标准)
+    2、培训师的义务
+    1)及时传达中食民安各项新颁布的通知、公告等各类文件并将内容解读清楚;
+    2)每周不少于三次,对被培训人进行业务培训,包括社群的建立、销售技巧、销售渠道拓展、客户服务、如何办理沙龙等;
+    3)随时帮助被培训人解决实际销售中遇到的任何问题。
+    3、被培训人的义务
+    1)督促并指导被培训人按照中食民安要求进行招商活动,接受中食民安监管;
+    2)督促并指导被培训人在培训师的培训指导下,积极开拓市场,努力完成业绩。
+    ');
+
+        $content[] = $this->content('四、其它', '1、培训师与被培训人,合作过程中出现任何争议,可申请中食民安进行协调;
+    2、本承诺书作为《中食民安(北京)科技有限公司代理商合作协议》的附件,是《中食民安(北京)科技有限公司代理商合作协议》的不可分割部分,我愿意遵守。
+    ');
+
+        return $content;
+    }
+
+    # 市场管理培训师承诺书
+    public function pdf_6($agreement, $info)
+    {
+        $base = Dever::db('setting/base')->find();
+
+        if (isset($info['qdate']) && $info['qdate']) {
+            $qdate = date('Y年m月d日', $info['qdate']);
+        } else {
+            $qdate = date('Y年m月d日');
+        }
+        $name = $this->name($agreement, $info);
+
+        $pdf = Dever::load('pdf/lib/core')->init();
+        $pdf->SetTitle($name);
+        $pdf->setCellHeightRatio(1.8);
+        $pdf->setCellPaddings(10, 0, 10, 0);
+        $pdf->font(18, 'B');
+        $pdf->center('市场管理培训师承诺书');
+        $pdf->br();
+        $pdf->font($this->font_size, 'B');
+        $pdf->left('承诺人:' . $info['name']);
+        $pdf->left('身份证号:' . $info['idcard']);
+        $pdf->left('电话:' . $info['mobile']);
+        $pdf->br(2);
+
+        if (isset($info['content']) && $info['content']) {
+            $info['content'] = Dever::array_decode($info['content']);
+            foreach($info['content'] as $k => $v) {
+                $pdf->content($v['name'], $v['content'], $this->font_size);
+            }
+        } else {
+            $method = 'content_' . $agreement['type'];
+            $content = $this->$method($agreement, $info);
+
+            foreach ($content as $k => $v) {
+                $pdf->content($v['name'], $v['content'], $this->font_size);
+            }
+
+            if (isset($info['create_state']) && $info['create_state'] == 1) {
+                $up = array();
+                $up['content'] = Dever::array_encode($content);
+                $up['where_id'] = $info['id'];
+                $state = Dever::db('option/agreement')->update($up);
+            }
+        }
+
+        $pdf->center('                                                                                  承诺人:');
+        $pdf->center('                                                                                                             日期:' . $qdate);
+
+        $pic = Dever::pic($base['agreement_sign']);
+
+        $cx = $pdf->GetX();
+        $cy = $pdf->GetY();
+
+        $x = $cx - 50;
+        $y = $cy - 15;
+
+        if ($info['sign']) {
+            $info['sign'] = Dever::pic($info['sign']);
+            if (strstr($info['sign'], 'http')) {
+                $pdf->Image($info['sign'], $x, $y, 20, 20);
+            }
+        }
+
+        $pdf->out($name);
+    }
+}

+ 370 - 0
service/option/lib/Cash.php

@@ -0,0 +1,370 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Cash
+{
+    private function getInfo($type, $cash)
+    {
+        if ($type > 3) {
+            $cash_type = 2;
+        } else {
+            $cash_type = 1;
+        }
+        if ($type == 1 || $type == 4) {
+            $table = 'jiaofu';
+            $prefix = 'J';
+        } elseif ($type == 2 || $type == 5) {
+            $table = 'fafang';
+            $prefix = 'F';
+        } elseif ($type == 3 || $type == 6) {
+            $table = 'duifu';
+            $prefix = 'D';
+            $cash = -1*$cash;
+        }
+
+        return array($table, $cash, $cash_type, $prefix);
+    }
+
+    public function resetParent($uid, $parent)
+    {
+        # 获取所有下级
+        $child = $this->getChild($uid, false);
+        if ($child) {
+            foreach ($child as $k => $v) {
+                if ($v['level'] > 1) {
+                    $this->update(array('id' => $v['id']), array('uid' => $parent));
+                }
+            }
+        }
+        return $this->delete(array('to_uid' => $uid, 'level' => 1), array('uid' => $parent));
+    }
+
+    public function up($aid, $type, $cash, $desc, $alert = true)
+    {
+        if ($cash == 0) {
+            return;
+        }
+        $account = Dever::db('option/account')->find(array('id' => $aid, 'clear' => true));
+        if ($account['status'] <= 2) {
+            list($table, $cash, $cash_type, $prefix) = $this->getInfo($type, $cash);
+            $where = array();
+            $where['clear'] = true;
+            $where['aid'] = $aid;
+            $where['type'] = $cash_type;
+            $info = false;
+            if (!$info) {
+                $data = $where;
+                $data['order_num'] = $this->getOrderId($table, $prefix);
+                $col = $table;
+
+                $cash_info = Dever::db('option/cash')->find($where);
+                if (!$cash_info) {
+                    Dever::db('option/cash')->insert($where);
+                    $cash_info = Dever::db('option/cash')->find($where);
+                }
+                if ($table == 'fafang') {
+                    $data['yue'] = $cash_info[$col] + $cash;
+                    $data['status'] = 1;
+                    if ($cash_info['jiaofu'] < $cash) {
+                        if ($alert) {
+                            Dever::alert('交付期权价值不足发放');
+                        } else {
+                            $data['status'] = 2;
+                        }
+                    }
+                } elseif ($table == 'duifu') {
+                    $data['yue'] = $cash_info[$col] + $cash;
+                    $data['status'] = 1;
+                    if ($cash_info['fafang'] < $cash) {
+                        if ($alert) {
+                            Dever::alert('发放期权价值不足兑付');
+                        } else {
+                            $data['status'] = 2;
+                        }
+                    }
+                } else {
+                    $col = 'dai' . $table;
+                    $data['status'] = 2;
+                }
+                
+                $data['cash'] = $cash;
+                $data['desc'] = $desc;
+                $data['clear'] = true;
+                $state = Dever::db('option/bill_' . $table)->insert($data);
+
+                if ($state && $cash_info) {
+                    # 更新余额
+                    $update = array();
+                    $update['where_id'] = $cash_info['id'];
+                    $update['set_cash'] = $cash;
+                    $update['clear'] = true;
+                    $method = 'upCash_' . $col;
+                    if ($table == 'fafang') {
+                        $update['jiaofu'] = $cash;
+                        if ($data['status'] == 2) {
+                            $update['jiaofu'] = 0;
+                        }
+                    } elseif ($table == 'duifu') {
+                        $update['fafang'] = $cash;
+                        if ($data['status'] == 2) {
+                            $update['fafang'] = 0;
+                        }
+                    }
+                    Dever::db('option/cash')->$method($update);
+                }
+            }
+            return $state;
+        }
+
+        return false;
+    }
+
+    /**
+     * 生成订单号
+     *
+     * @return mixed
+     */
+    public function getOrderId($table, $prefix)
+    {
+        $where['order_num'] = Dever::order($prefix);
+        $state = Dever::db('option/bill_' . $table)->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId($table, $prefix);
+        }
+    }
+
+    # 获取日志列表
+    public function getList($aid, $table, $status, $name)
+    {
+        $where = array();
+        $where['aid'] = $aid;
+        if ($status > 0) {
+            $where['status'] = $status;
+        }
+        $table = 'option/bill_' . $table;
+        $data = Dever::db($table)->getData($where);
+        if ($data) {
+            $audit = Dever::db($table)->config['config_audit'];
+            foreach ($data as $k => $v) {
+                $data[$k] = $this->getOne($v, $name, $audit);
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取日志详情
+    public function getView($id, $aid, $table, $name)
+    {
+        if (!$id) {
+            Dever::alert('参数错误');
+        }
+        $where = array();
+        $where['id'] = $id;
+        $where['aid'] = $aid;
+        $table = 'option/bill_' . $table;
+        $data = Dever::db($table)->find($where);
+        if ($data) {
+            $audit = Dever::db($table)->config['config_audit'];
+            $data = $this->getOne($data, $name, $audit);
+        }
+
+        return $data;
+    }
+
+    # 获取详情
+    private function getOne($data, $name, $audit)
+    {
+        if ($data['type'] == 1) {
+            $data['type_name'] = $name . '期权';
+        } else {
+            $data['type_name'] = $name . '原始期权';
+        }
+        
+        $data['audit_name'] = $audit[$data['audit']];
+        $data['cdate_string'] = date('Y-m-d H:i', $data['cdate']);
+        return $data;
+    }
+
+    # 展示详情
+    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;
+    }
+}

+ 36 - 0
service/option/lib/Core.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Core
+{
+    protected $uid = -1;
+    protected $use = array();
+    public $data = array();
+
+    public function __construct()
+    {
+        $this->uid = Dever::load('passport/user')->check(false);
+        if ($this->uid <= 0) {
+            $this->uid = 18;
+        }
+        $this->checkLogin();
+        if ($this->uid) {
+            $this->user = Dever::db('option/account')->find($this->uid);
+            //$this->user['idcard'] = '';
+        }
+
+        if ($this->user) {
+            $this->user['uid'] = $this->user['id'];
+        }
+    }
+
+    public function checkLogin()
+    {
+        if (!$this->uid || $this->uid <= 0) {
+            Dever::alert('请先登录', -2);
+        }
+    }
+}

+ 92 - 0
service/option/lib/Email.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Email
+{
+    # 修改邮箱
+    public function act_api()
+    {
+        //$signature = Dever::input('signature');
+        $signature = $_GET['signature'];
+        if (!$signature) {
+            Dever::alert('您的验证信息已失效,请重新发送验证邮件');
+        }
+
+        $signature = Dever::decode($signature);
+        $temp = explode('|||', $signature);
+        $code = $temp[2];
+
+        $state = Dever::load('passport/reg')->code($code);
+        if (!$state) {
+            Dever::alert('您的验证信息已失效,请重新发送验证邮件');
+        }
+
+        $check = Dever::db('option/account')->find(array('email' => $temp[1]));
+
+        if (!$check) {
+            Dever::alert('您的验证信息已失效,请重新发送验证邮件');
+        }
+
+        $where['where_id'] = $temp[0];
+        //$where['email'] = $temp[1];
+        $where['is_email'] = 1;
+
+        Dever::db('option/account')->update($where);
+
+        echo '您的邮件:'.$temp[1].',已经验证成功。请登录期权管理系统查询。';die;
+    }
+
+    public function renzheng()
+    {
+        $email = Dever::input('email');
+        $username = Dever::input('username');
+        $code = Dever::input('code');
+        $aid = Dever::input('aid');
+        $email = base64_decode($email);
+        $config = Dever::config('base', 'project')->email['option'];
+        $title = $config['title'];
+        $content = $config['content'];
+
+        $signature = Dever::encode($aid . '|||' . $email . '|||' . $code);
+
+        $link = Dever::url($config['link'] . '?signature=' . $signature);
+        $date = date('Y-m-d H:i:s');
+        $content = str_replace('{link}', $link, $content);
+        $content = str_replace('{username}', $username, $content);
+        $content = str_replace('{date}', $date, $content);
+        $this->send($email, $username, $title, $content);
+    }
+
+    public function send($email, $username, $title, $content)
+    {
+        $config = Dever::config('base', 'project')->email;
+
+        Dever::apply('src/PHPMailer', 'email');
+        Dever::apply('src/Exception', 'email');
+        Dever::apply('src/SMTP', 'email');
+        $mail = new \PHPMailer\PHPMailer\PHPMailer();
+
+        $mail->isSMTP();
+        //$mail->SMTPDebug = 2;
+        $mail->CharSet = 'UTF-8';
+        $mail->Host = $config['smtp'];
+        $mail->Port = 465;
+        $mail->SMTPSecure = 'ssl';
+        $mail->SMTPAuth = true;
+        $mail->Username = $config['username'];
+        $mail->Password = $config['password'];
+        $mail->setFrom($config['from'][0], $config['from'][1]);
+        $mail->addAddress($email, $username);
+        $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?=";
+        $mail->Body = $content;
+        //$mail->addAttachment($file);
+        if (!$mail->send()) {
+            Dever::alert("Mailer Error: " . $mail->ErrorInfo);
+        } else {
+            return 'ok';
+        }
+    }
+}

+ 42 - 0
service/option/lib/Import.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+include('/share/lib/php/dever_package/excel/src/PHPExcel.php');
+
+class Import
+{
+    public function get_api()
+    {
+        $file = Dever::data() . 'qiquan.xlsx';
+
+        $data = Dever::excelImport($file, 1, 5, 'excel');
+
+        # 主账户表
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $state = preg_match(Dever::rule('mobile'), $v['C']);
+                if ($state) {
+                    $where['key'] = $v['A'];
+                    $where['mobile'] = $v['C'];
+
+                    $info = Dever::db('option/account')->find($where);
+                    $update = $where;
+                    $update['idcard'] = $v['D'];
+                    $update['name'] = $v['B'];
+                    $update['type'] = $v['E'] ? 2 : 1;
+                    if (!$info) {
+                        $update['audit'] = 1;
+                        Dever::db('option/account')->insert($update);
+                    } else {
+                        $update['where_id'] = $info['id'];
+                        Dever::db('option/account')->update($update);
+                    }
+                }
+            }
+        }
+        return 'ok';
+    }
+}

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

@@ -0,0 +1,93 @@
+<?php
+
+namespace Option\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function updateAccount($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $update = array();
+        $audit = Dever::param('audit', $data);
+        $info = Dever::db('option/account')->one($id);
+        if ($audit > 2 && $info) {
+            $update['audit_date'] = time();
+            $update['where_id'] = $info['id'];
+            Dever::db('option/account')->update($update);
+        }
+    }
+
+    public function setJiaofu($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $update = array();
+        $audit = Dever::param('audit', $data);
+        $info = Dever::db('option/bill_jiaofu')->one($id);
+        if ($audit > 1 && $info) {
+            $admin = Dever::load('manage/auth.info');
+            $update['audit_date'] = time();
+            $update['audit_admin'] = $admin['id'];
+            $update['where_id'] = $info['id'];
+            Dever::db('option/bill_jiaofu')->update($update);
+        }
+    }
+
+    public function setFafang($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $update = array();
+        $audit = Dever::param('audit', $data);
+        $info = Dever::db('option/bill_fafang')->one($id);
+        if ($audit > 1 && $info) {
+            $admin = Dever::load('manage/auth.info');
+            $update['audit_date'] = time();
+            $update['audit_admin'] = $admin['id'];
+            $update['where_id'] = $info['id'];
+            Dever::db('option/bill_fafang')->update($update);
+        }
+    }
+
+    public function setDuifu($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $update = array();
+        $audit = Dever::param('audit', $data);
+        $info = Dever::db('option/bill_duifu')->one($id);
+        if ($audit && $audit > 1 && $info) {
+            $admin = Dever::load('manage/auth.info');
+            $update['audit_date'] = time();
+            $update['audit_admin'] = $admin['id'];
+            $update['where_id'] = $info['id'];
+            Dever::db('option/bill_duifu')->update($update);
+        }
+    }
+
+    public function cashUpdate($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $aid = Dever::param('aid', $data);
+        $type = Dever::param('type', $data);
+        $cash = Dever::param('cash', $data);
+        $desc = Dever::param('desc', $data);
+        if ($aid && $type && $cash && $desc) {
+            $account = Dever::db('option/account')->find($aid);
+            if ($account && $account['status'] <= 2) {
+                Dever::load('option/lib/cash')->up($aid, $type, $cash, $desc);
+                $where['where_id'] = $aid;
+                $where['cash'] = $cash;
+                Dever::db('agent/member')->upCash($where);
+            } else {
+                Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
+                Dever::alert('期权账户已停用或者未审核,操作失败');
+            }
+        }
+    }
+
+    public function updateAccountAudit($id, $name, $data)
+    {
+        $data['add_audit'] = 1;
+        return $data;
+    }
+}

+ 92 - 0
service/option/src/Auth.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace Option\Src;
+
+use Dever;
+
+class Auth
+{
+    /**
+     * 验证码登录
+     *
+     * @return mixed
+     */
+    public function login()
+    {
+        return $this->checkLogin(2);
+    }
+
+    /**
+     * 获取手机验证码
+     * @return mixed
+     */
+    public function getLoginMcode()
+    {
+        return $this->checkLogin(1);
+    }
+
+    # 检测登录信息
+    private function checkLogin($state = 1)
+    {
+        $mobile = Dever::load('option/lib/account')->checkMobile(Dever::input('mobile'));
+        $user = Dever::db('option/account')->find(array('mobile' => $mobile));
+        if (!$user) {
+            Dever::alert('手机号不正确');
+        }
+
+        if ($user) {
+
+            if ($user['status'] > 2) {
+                Dever::alert('该账号已停用');
+            }
+
+            if ($user['type'] == 1) {
+                Dever::alert('该账号已建立期权账户');
+            }
+
+            if ($state == 1) {
+                $code = Dever::load('passport/reg')->mcode($mobile);
+
+                $msg = '验证码已发送至您的手机,请注意查收,十分钟之内有效';
+                $debug = Dever::config('base', 'project')->mobileCode['debug'];
+                if ($debug) {
+                    $msg .= '::' . $code;
+                }
+                return $msg;
+            } else {
+                $idcard = Dever::input('idcard');
+                if ($user['idcard'] != $idcard) {
+                    Dever::alert('身份证号不正确');
+                }
+
+                Dever::load('option/lib/account')->checkMcode($mobile);
+                $data = Dever::load('passport/reg')->getSign($user['id']);
+
+                if ($user['status'] == 1) {
+                    $data['status'] = 1;
+                } else {
+                    $data['status'] = 2;
+                }
+
+                return $data;
+            }
+        } else {
+            Dever::alert('该用户还未存在期权数据');
+        }
+    }
+
+    # 获取验证码是否正确
+    public function checkMcode()
+    {
+        $mobile = Dever::input('mobile');
+        $code = Dever::input('mcode');
+        if (!$code) {
+            Dever::alert('请输入验证码');
+        }
+        $code = Dever::load('passport/reg')->mcode($mobile, $code, 2);
+        if (!$code) {
+            Dever::alert('验证码输入错误');
+        }
+        return 'ok';
+    }
+}

+ 258 - 0
service/option/src/My.php

@@ -0,0 +1,258 @@
+<?php
+
+namespace Option\Src;
+
+use Dever;
+use Option\Lib\Core;
+
+class My extends Core
+{
+    /**
+     * 获取基本信息
+     *
+     * @return mixed
+     */
+    public function getInfo()
+    {
+        $this->data['user'] = $this->user;
+
+        $this->data['cash'] = Dever::db('option/cash')->select(array('aid' => $this->uid));
+
+        $jiaofu = Dever::db('option/bill_jiaofu')->find(array('status' => 2, 'aid' => $this->uid));
+
+        $this->data['state'] = 1;
+        if ($jiaofu) {
+            $this->data['state'] = 2;
+        }
+        if ($this->data['cash']) {
+            foreach ($this->data['cash'] as $k => $v) {
+                if ($v['type'] == 1) {
+                    $this->data['cash'][$k]['type_name'] = '期权交付价值';
+                } else {
+                    $this->data['cash'][$k]['type_name'] = '原始期权交付价值';
+                }
+                $this->data['cash'][$k]['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2);
+            }
+        }
+        $agreement = Dever::db('option/agreement')->find(array('aid' => $this->uid));
+        if ($agreement) {
+            $name = Dever::load('option/lib/agreement')->name($agreement['agreement_id'], $agreement, 2, 2);
+            $this->data['agreement_link'] = $name[1];
+        }
+        
+        return $this->data;
+    }
+
+    # 待交付期权列表
+    public function getValue()
+    {
+        $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'jiaofu', 2, '待交付');
+
+        return $this->data;
+    }
+
+    # 确认期权价值
+    public function setValue_commit()
+    {
+        $id = Dever::input('id');
+        if (!$id) {
+            Dever::alert('错误的期权交付记录');
+        }
+
+        $info = Dever::db('option/bill_jiaofu')->find($id);
+
+        if (!$info) {
+            Dever::alert('错误的期权交付记录');
+        }
+
+        if ($info['aid'] != $this->uid) {
+            Dever::alert('错误的期权交付记录');
+        }
+
+        if ($info['status'] != 2) {
+            Dever::alert('已确认该交付记录');
+        }
+
+        $state = Dever::db('option/bill_jiaofu')->update(array('status' => 1, 'where_id' => $id));
+
+        if ($state) {
+            $cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $this->uid));
+            if ($cash) {
+                $update['where_id'] = $cash['id'];
+                $update['daijiaofu'] = $cash['daijiaofu'] - $info['cash'];
+                $update['jiaofu'] = $cash['jiaofu'] + $info['cash'];
+                if ($update['daijiaofu'] < 0) {
+                    $update['daijiaofu'] = 0;
+                }
+                Dever::db('option/cash')->update($update);
+
+                # 获取待发放数据 对之前发放的数据进行发放
+                $fafang = Dever::db('option/bill_fafang')->find(array('status' => 2, 'aid' => $this->uid));
+                if ($fafang) {
+                    foreach ($fafang as $k => $v) {
+                        if ($info['cash'] >= $v['cash']) {
+                            Dever::db('option/bill_fafang')->update(array('where_id' => $v['id'], 'status' => 1));
+                            $info['cash'] -= $v['cash'];
+                        }
+                    }
+                }
+                
+                return 'ok';
+            }
+        } else {
+            Dever::alert('操作失败');
+        }
+    }
+
+    # 获取交付列表
+    public function getJiaofu()
+    {
+        $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'jiaofu', 1, '交付');
+
+        return $this->data;
+    }
+
+    # 获取交付详情
+    public function getJiaofuView()
+    {
+        $id = Dever::input('id');
+        $this->data['info'] = Dever::load('option/lib/cash')->getView($id, $this->uid, 'jiaofu', '交付');
+
+        return $this->data;
+    }
+
+    # 获取发放列表
+    public function getFafang()
+    {
+        $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'fafang', 1, '发放');
+
+        return $this->data;
+    }
+
+    # 获取发放详情
+    public function getFafangView()
+    {
+        $id = Dever::input('id');
+        $this->data['info'] = Dever::load('option/lib/cash')->getView($id, $this->uid, 'fafang', '发放');
+
+        return $this->data;
+    }
+
+    # 获取兑付列表
+    public function getDuifu()
+    {
+        $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'duifu', 1, '兑付');
+
+        return $this->data;
+    }
+
+    # 获取兑付详情
+    public function getDuifuView()
+    {
+        $id = Dever::input('id');
+        $this->data['info'] = Dever::load('option/lib/cash')->getView($id, $this->uid, 'duifu', '兑付');
+
+        return $this->data;
+    }
+
+    # 修改资料
+    public function setInfo()
+    {
+        $where = array();
+        /*
+        $where['name'] = Dever::input('name');
+        if (!$where['name']) {
+            Dever::alert('请输入姓名');
+        }
+        $where['idcard'] = Dever::input('idcard');
+        if (!$where['idcard']) {
+            Dever::alert('请输入身份证号');
+        }*/
+        $where['idcard_front'] = Dever::input('idcard_front');
+        if (!$where['idcard_front']) {
+            Dever::alert('请上传身份证正面照片');
+        }
+        $where['idcard_back'] = Dever::input('idcard_back');
+        if (!$where['idcard_back']) {
+            Dever::alert('请上传身份证背面照片');
+        }
+
+        $where['email'] = Dever::input('email');
+        if (!$where['email']) {
+            Dever::alert('请填写邮箱');
+        }
+        $check = Dever::db('option/account')->find(array('email' => $where['email']));
+        if ($check && $check['id'] != $this->uid) {
+            Dever::alert('邮箱已被验证,请重新填写');
+        }
+        if ($where['email'] != $this->user['email']) {
+            $where['is_email'] = 2;
+        }
+
+        if ($where) {
+            $where['where_id'] = $this->uid;
+            $where['audit'] = 2;
+            $where['is_idcard'] = 1;
+            Dever::db('option/account')->update($where);
+        }
+
+        return Dever::db('option/account')->find(array('id' => $this->uid, 'clear' => true));
+    }
+
+    # 确认签署
+    public function act_commit()
+    {
+        $where['sign'] = Dever::input('sign');
+        if (!$where['sign']) {
+            Dever::alert('请上传签名');
+        }
+
+        $email = $this->user['email'];
+
+        $code = Dever::load('passport/reg')->code(false, false);
+
+        $email = base64_encode($email);
+        Dever::daemon('lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name'], 'option');
+
+        # 签署合同
+        $this->user['sign'] = $where['sign'];
+        Dever::load('option/lib/agreement')->up($this->user);
+
+        $where['where_id'] = $this->uid;
+        $where['status'] = 2;
+        $where['is_sign'] = 1;
+        Dever::db('option/account')->update($where);
+
+        return $this->user;
+    }
+
+    # 获取期权协议内容
+    public function getAgreementContent()
+    {
+        return 'test';
+    }
+
+    # 获取我的合同
+    public function getAgreementView()
+    {
+        $where['aid'] = $this->uid;
+        $where['id'] = Dever::input('id');
+        $this->data['info'] = array();
+        if ($where['id']) {
+            $status = Dever::db('option/agreement')->config['status'];
+            $this->data['info'] = Dever::db('option/agreement')->find($where);
+            if ($this->data['info']) {
+                $this->data['info']['status_name'] = $status[$this->data['info']['status']];
+                $this->data['info']['qdate_string'] = '';
+                if ($this->data['info']['qdate']) {
+                    $this->data['info']['qdate_string'] = date('Y.m.d', $this->data['info']['qdate']);
+                }
+                
+                $name = Dever::load('option/lib/agreement')->name($this->data['info']['agreement_id'], $this->data['info'], 2, 2);
+                $this->data['info']['link'] = $name[1];
+            }
+        }
+
+        return $this->data;
+    }
+}

+ 5 - 0
service/option/template/manage/cash.php

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

+ 3 - 0
service/setting/database/agreement.php

@@ -13,6 +13,7 @@ $type = array
     //3 => '软件服务合同',
     4 => '市场管理培训师承诺书',
     5 => '5000合同',
+    6 => '期权合同',
 );
 
 return array
@@ -99,6 +100,8 @@ return array
             '3,"市场管理培训师承诺书.pdf", 4, 1,' . DEVER_TIME,
 
             '4,"5000合同.pdf", 5, 1,' . DEVER_TIME,
+
+            '5,"期权合同.pdf", 6, 1,' . DEVER_TIME,
         ),
     ),