dever 3 سال پیش
والد
کامیت
6a90be67cf

+ 1 - 20
service/option/database/account.php

@@ -41,12 +41,6 @@ $is_idcard = array
     2 => '未上传',
 );
 
-$is_sign = array
-(
-    1 => '已签署',
-    2 => '未签署',
-);
-
 $col = Dever::input('col');
 
 return array
@@ -63,7 +57,6 @@ return array
         'audit' => $audit,
         'is_email' => $is_email,
         'is_idcard' => $is_idcard,
-        'is_sign' => $is_sign,
     ),
     'start' => array
     (
@@ -204,19 +197,6 @@ return array
             //'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',
@@ -240,6 +220,7 @@ return array
             'update'    => $col ? 'radio' : false,
             'list'      => 'Dever::load("option/lib/account.getAudit", {id})',
             'list_order' => 5,
+            'value'     => $col ? '3' : '1',
             'control'   => 'audit',
         ),
 

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

@@ -89,6 +89,24 @@ return array
             'list_order' => 6,
         ),
 
+        'jiaofu_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '交付的id',
+            'default'   => '',
+            'desc'      => '交付的id',
+            'match'     => 'is_string',
+        ),
+
+        'jiaofu_total'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '交付的总额',
+            'default'   => '',
+            'desc'      => '交付的总额',
+            'match'     => 'is_numeric',
+        ),
+
         'sign'     => array
         (
             'type'      => 'varchar-150',

+ 13 - 1
service/option/database/bill_duifu.php

@@ -110,7 +110,7 @@ return array
             'desc'      => '兑付价值',
             'match'     => 'is_numeric',
             //'update'    => 'text',
-            'list'      => true,
+            'list'      => '"-{cash}"',
             'list_order' => 5,
         ),
 
@@ -184,6 +184,18 @@ return array
             'list_order'  => 8,
         ),
 
+        'desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '备注说明',
+            'default'   => '',
+            'desc'      => '备注说明',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      =>  true,
+            'list_order'  => 10,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 13 - 1
service/option/database/bill_fafang.php

@@ -110,7 +110,7 @@ return array
             'desc'      => '发放价值',
             'match'     => 'is_numeric',
             //'update'    => 'text',
-            'list'      => true,
+            'list'      => '"+{cash}"',
             'list_order' => 5,
         ),
 
@@ -184,6 +184,18 @@ return array
             'list_order'  => 8,
         ),
 
+        'desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '备注说明',
+            'default'   => '',
+            'desc'      => '备注说明',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      =>  true,
+            'list_order'  => 10,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 63 - 19
service/option/database/bill_jiaofu.php

@@ -10,16 +10,22 @@ $status = array
 
 $audit = array
 (
-    1 => '正常',
-    2 => '作废',
+    1 => '未提交审核',
+    2 => '待审核',
+    3 => '审核通过',
+    4 => '审核未通过',
 );
 
 $audit_manage = array
 (
-    //1 => '正常',
-    2 => '作废',
+    //1 => '未提交审核',
+    //2 => '待审核',
+    3 => '审核通过',
+    4 => '审核未通过',
 );
 
+$col = Dever::input('col');
+
 $aid = Dever::input('search_option_aid');
 $button = array();
 if ($aid) {
@@ -80,7 +86,7 @@ return array
             'option'    => $type,
             'update'    => 'radio',
             'list'      => true,
-            'list_order'  => 6,
+            'list_order'  => 4,
         ),
 
         'aid'      => array
@@ -99,19 +105,32 @@ return array
             ),
             'list_name' => '期权账户',
             'list'      => 'Dever::load("option/lib/account.getInfo", {aid})',
-            'list_order' => 3,
+            'list_order' => 2,
         ),
 
         'cash'      => array
         (
             'type'      => 'float-11,2',
-            'name'      => '期权价值',
+            'name'      => '期权操作',
             'default'   => '0',
-            'desc'      => '期权价值',
+            'desc'      => '期权操作',
             'match'     => 'is_numeric',
             //'update'    => 'text',
-            'list'      => true,
-            'list_order' => 5,
+            'list'      => '"+{cash}"',
+            'list_order' => 3,
+        ),
+
+        'sign'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '签字',
+            'default'   => '',
+            'desc'      => '签字',
+            'match'     => 'option',
+            //'update'    => 'image',
+            'key'       => '7',
+            'list'      => '"<img src=\'{sign}\' width=\'150\'>"',
+            'list_order' => 6,
         ),
 
         'status'        => array
@@ -131,24 +150,27 @@ return array
         (
             'type'      => 'tinyint-1',
             'name'      => '审核',
-            'default'   => '1',
+            'default'   => $col ? '3' : '1',
             'desc'      => '审核',
             'match'     => 'is_numeric',
-            'option'    => $audit_manage,
+            'option'    => $col ? $audit_manage : $audit,
             'update'    => 'radio',
             'control'   => 'audit',
+            'value'     => $col ? '3' : '1',
+            'list'      => true,
+            'list_order' => 7,
         ),
 
         'audit_desc'        => array
         (
             'type'      => 'varchar-500',
-            'name'      => '备注',
+            'name'      => '未通过审核备注',
             'default'   => '',
             'desc'      => '备注',
             'match'     => 'option',
             'update'    => 'textarea',
             'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
-            'list_order'  => 8,
+            'list_order'  => 9,
         ),
 
         'audit_date'     => array
@@ -168,7 +190,28 @@ return array
             'match'     => 'is_numeric',
             'desc'      => '操作人',
             'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#name", {audit_admin}) : "-"',
-            'list_order'  => 7,
+            'list_order'  => 5,
+        ),
+
+        'desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '备注说明',
+            'default'   => '',
+            'desc'      => '备注说明',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'list'      =>  true,
+            'list_order'  => 10,
+        ),
+
+        'qdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '确认时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
         ),
 
         'state'     => array
@@ -183,14 +226,14 @@ return array
         'cdate'     => array
         (
             'type'      => 'int-11',
-            'name'      => '处理时间',
+            'name'      => '操作时间',
             'match'     => array('is_numeric', time()),
             'desc'      => '',
             'default'   => '',
             # 只有insert时才生效
             'insert'    => true,
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
-            'list_order' => 2,
+            'list'      => 'Dever::load("option/lib/manage.getJiaofuDate", {id})',
+            'list_order' => 18,
         ),
     ),
 
@@ -204,7 +247,7 @@ return array
         (
             //'list' => array('查看详情', '"member_area&mid={id}&page_type=1"'),
 
-            'edit' => array('作废', 'audit,audit_desc', '{audit} == 1'),
+            'edit' => array('审核', 'audit,audit_desc', '{audit} == 1'),
             //'delete' => array('删除', '', '{status} == 1'),
         ),
     ),
@@ -218,6 +261,7 @@ return array
             (
                 'aid' => 'yes',
                 'type' => 'yes',
+                'audit' => 'yes',
                 'status' => 'yes',
                 'state' => 1,
             ),

+ 6 - 2
service/option/lib/Agreement.php

@@ -112,7 +112,7 @@ class Agreement
     }
 
     # 新建合同
-    public function up($account)
+    public function up($account, $ids, $total, $status = 1)
     {
         $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
         if (!$agreement) {
@@ -135,12 +135,15 @@ class Agreement
         $where['idcard_front'] = $account['idcard_front'];
         $where['idcard_back'] = $account['idcard_back'];
         $where['address'] = '';
-        $where['status'] = 2;
+        $where['status'] = $status;
         $where['udate'] = $where['cdate'] = time();
         $where['qdate'] = $qdate;
         $where['sdate'] = $sdate;
         $where['edate'] = $edate;
 
+        $where['jiaofu_id'] = $ids;
+        $where['jiaofu_total'] = $total;
+
         $method = 'content_' . $agreement['type'];
 
         if ($info) {
@@ -152,6 +155,7 @@ class Agreement
             $up['content'] = Dever::array_encode($this->$method($agreement, $account));
             $state = Dever::db('option/agreement')->insert($up);
         }
+        return $state;
     }
 
     # 更新合同内容

+ 36 - 1
service/option/lib/Cash.php

@@ -139,13 +139,16 @@ class Cash
     }
 
     # 获取日志列表
-    public function getList($aid, $table, $status, $name)
+    public function getList($aid, $table, $status, $name, $audit = false)
     {
         $where = array();
         $where['aid'] = $aid;
         if ($status > 0) {
             $where['status'] = $status;
         }
+        if ($audit) {
+            $where['audit'] = $audit;
+        }
         $table = 'option/bill_' . $table;
         $data = Dever::db($table)->getData($where);
         if ($data) {
@@ -191,6 +194,38 @@ class Cash
         return $data;
     }
 
+    # 确认期权价值
+    public function setValue_commit($info)
+    {
+        $cash = array();
+        $state = Dever::db('option/bill_jiaofu')->update(array('status' => 1, 'where_id' => $info['id']));
+
+        if ($state) {
+            $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
+            if ($account_cash) {
+                $update['where_id'] = $account_cash['id'];
+                $update['daijiaofu'] = $account_cash['daijiaofu'] - $info['cash'];
+                $update['jiaofu'] = $account_cash['jiaofu'] + $info['cash'];
+                if ($update['daijiaofu'] < 0) {
+                    $update['daijiaofu'] = 0;
+                }
+                $update['clear'] = true;
+                Dever::db('option/cash')->update($update);
+
+                # 获取待发放数据 对之前发放的数据进行发放
+                $fafang = Dever::db('option/bill_fafang')->find(array('status' => 2, 'type' => $info['type'], 'aid' => $aid));
+                if ($fafang) {
+                    foreach ($fafang as $v) {
+                        if ($info['cash'] >= $v['cash']) {
+                            Dever::db('option/bill_fafang')->update(array('where_id' => $v['id'], 'status' => 1));
+                            $info['cash'] -= $v['cash'];
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     # 展示详情
     public function show()
     {

+ 51 - 3
service/option/lib/Manage.php

@@ -30,7 +30,10 @@ class Manage
             $update['audit_date'] = time();
             $update['audit_admin'] = $admin['id'];
             $update['where_id'] = $info['id'];
-            Dever::db('option/bill_jiaofu')->update($update);
+            $state = Dever::db('option/bill_jiaofu')->update($update);
+            if ($state && $audit == 2) {
+                Dever::load('option/lib/cash.setValue_commit', $info);
+            }
         }
     }
 
@@ -45,7 +48,21 @@ class Manage
             $update['audit_date'] = time();
             $update['audit_admin'] = $admin['id'];
             $update['where_id'] = $info['id'];
-            Dever::db('option/bill_fafang')->update($update);
+            $state = Dever::db('option/bill_fafang')->update($update);
+            if ($state && $audit == 2) {
+                # 已作废,减掉这个数据
+                $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
+                if ($account_cash) {
+                    $update['where_id'] = $account_cash['id'];
+                    $update['fafang'] = $account_cash['fafang'] - $info['cash'];
+                    $update['jiaofu'] = $account_cash['jiaofu'] + $info['cash'];
+                    if ($update['fafang'] < 0) {
+                        $update['fafang'] = 0;
+                    }
+                    $update['clear'] = true;
+                    Dever::db('option/cash')->update($update);
+                }
+            }
         }
     }
 
@@ -60,7 +77,21 @@ class Manage
             $update['audit_date'] = time();
             $update['audit_admin'] = $admin['id'];
             $update['where_id'] = $info['id'];
-            Dever::db('option/bill_duifu')->update($update);
+            $state = Dever::db('option/bill_duifu')->update($update);
+            if ($state && $audit == 2) {
+                # 已作废,恢复这个数据
+                $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
+                if ($account_cash) {
+                    $update['where_id'] = $account_cash['id'];
+                    $update['duifu'] = $account_cash['duifu'] - $info['cash'];
+                    $update['fafang'] = $account_cash['fafang'] + $info['cash'];
+                    if ($update['duifu'] < 0) {
+                        $update['duifu'] = 0;
+                    }
+                    $update['clear'] = true;
+                    Dever::db('option/cash')->update($update);
+                }
+            }
         }
     }
 
@@ -90,4 +121,21 @@ class Manage
         $data['add_audit'] = 1;
         return $data;
     }
+
+    public function getJiaofuDate($id)
+    {
+        $info = Dever::db('option/bill_jiaofu')->find($id);
+        if ($info) {
+            $html = '';
+            $html .= '处理时间:' . date('Y-m-d H:i', $info['cdate']);
+            if ($info['qdate']) {
+                $html .= '<br />确认时间:' . date('Y-m-d H:i', $info['qdate']);
+            }
+            if ($info['audit_date']) {
+                $html .= '<br />审核时间:' . date('Y-m-d H:i', $info['audit_date']);
+            }
+            return $html;
+        }
+        return '';
+    }
 }

+ 68 - 67
service/option/src/My.php

@@ -48,60 +48,27 @@ class My extends Core
     {
         $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'];
-                        }
-                    }
+        $audit = array
+        (
+            'status' => 1,
+            'desc' => '',
+        );
+        if ($this->data['list']) {
+            foreach ($this->data['list'] as $k => $v) {
+                if ($v['audit'] == 4) {
+                    $audit['status'] = 4;
+                    $audit['desc'] = $v['audit_desc'];
+                    break;
+                } elseif ($v['audit'] == 2) {
+                    $audit['status'] = 2;
+                    break;
                 }
-                
-                return 'ok';
             }
-        } else {
-            Dever::alert('操作失败');
         }
+
+        $this->data['audit'] = $audit;
+
+        return $this->data;
     }
 
     # 获取交付列表
@@ -192,36 +159,47 @@ class My extends Core
         if ($where) {
             $where['where_id'] = $this->uid;
             $where['audit'] = 2;
+            $where['status'] = 2;
             $where['is_idcard'] = 1;
             Dever::db('option/account')->update($where);
         }
 
+        if ($where['is_email'] == 2) {
+            $code = Dever::load('passport/reg')->code(false, false);
+            $email = base64_encode($where['email']);
+            Dever::daemon('lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name'], 'option');
+        }
+
         return Dever::db('option/account')->find(array('id' => $this->uid, 'clear' => true));
     }
 
     # 确认签署
     public function act_commit()
     {
-        $where['sign'] = Dever::input('sign');
-        if (!$where['sign']) {
+        $update['sign'] = Dever::input('sign');
+        if (!$update['sign']) {
             Dever::alert('请上传签名');
         }
 
-        # 签署合同
-        $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);
-
-        $email = $this->user['email'];
-
-        $code = Dever::load('passport/reg')->code(false, false);
+        $data = Dever::load('option/lib/cash')->getList($this->uid, 'jiaofu', 2, '待交付');
+        if (!$data) {
+            Dever::alert('没有待交付的期权价值');
+        }
+        $ids = array();
+        $total = 0;
+        foreach ($data as $k => $v) {
+            $ids[] = $v['id'];
+            $total += $v['cash'];
+            $update['where_id'] = $v['id'];
+            $update['audit'] = 2;
+            $update['qdate'] = time();
+            Dever::db('option/bill_jiaofu')->update($update);
+        }
+        $ids = implode(',', $ids);
 
-        $email = base64_encode($email);
-        Dever::daemon('lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name'], 'option');
+        # 签署合同
+        $this->user['sign'] = $update['sign'];
+        Dever::load('option/lib/agreement')->up($this->user, $ids, $total);
 
         return $this->user;
     }
@@ -232,6 +210,29 @@ class My extends Core
         return 'test';
     }
 
+    # 获取我的合同
+    public function getAgreement()
+    {
+        $where['aid'] = $this->uid;
+        $this->data['list'] = Dever::db('option/agreement')->getAll($where);
+
+        if ($this->data['list']) {
+            $status = Dever::db('option/agreement')->config['status'];
+            foreach ($this->data['list'] as $k => $v) {
+                $this->data['list'][$k]['status_name'] = $status[$v['status']];
+                $this->data['list'][$k]['qdate_string'] = '';
+                if ($v['qdate']) {
+                    $this->data['list'][$k]['qdate_string'] = date('Y.m.d', $v['qdate']);
+                }
+
+                $name = Dever::load('option/lib/agreement')->name($v['agreement_id'], $v, 2, 2);
+                $this->data['list'][$k]['link'] = $name[1];
+            }
+        }
+
+        return $this->data;
+    }
+
     # 获取我的合同
     public function getAgreementView()
     {