| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 | <?phpnamespace 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 setAgreement_commit($id, $name, $data)    {        Dever::config('base')->hook = true;        $update = array();        $audit = Dever::param('audit', $data);        $info = Dever::db('option/agreement')->one($id);        if ($audit > 1 && $info) {            $admin = Dever::load('manage/auth.info');            $update['audit_date'] = time();            $update['audit_admin'] = $admin['id'];            if ($audit == 3) {                $update['status'] = 2;            }                        $update['where_id'] = $info['id'];            $state = Dever::db('option/agreement')->update($update);            if ($state && $audit == 3) {                Dever::load('option/lib/cash.setValue', $info);            }        }    }    # 交付审核 已废弃    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'];            $state = Dever::db('option/bill_jiaofu')->update($update);            if ($state && $audit == 3) {                Dever::load('option/lib/cash.setValue_commit', $info);            }        }    }    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'];            $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);                }            }        }    }    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'];            $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);                }            }        }    }    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;    }    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 '';    }}
 |