123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <?php
- namespace Option\Lib;
- use Dever;
- class Manage
- {
- public function updateMember($id, $name, $data)
- {
- Dever::config('base')->hook = true;
- $where['id'] = $id;
- $where['clear'] = true;
- $info = Dever::db('option/member')->find($where);
- if ($info) {
- if ($info['main'] == 1) {
- $update['mid'] = $id;
- $account = Dever::db('option/account')->one($update);
- if (!$account) {
- $update['audit'] = 1;
- $aid = Dever::db('option/account')->insert($update);
- } else {
- $aid = $account['id'];
- }
- Dever::db('option/member')->update(array('where_id' => $info['id'], 'aid' => $aid));
- }
- $main = Dever::db('option/member')->getMain(array('key' => $info['key']));
- if ($main && $main['aid']) {
- $where = array();
- $where['option_key'] = $info['key'];
- $where['set_aid'] = $main['aid'];
- Dever::db('option/member')->updates($where);
- }
- }
- }
- public function updateAccount($id, $name, $data)
- {
- Dever::config('base')->hook = true;
- $update = array();
- $audit = Dever::param('audit', $data);
- $send_email = Dever::param('send_email', $data);
- $email = Dever::param('email', $data);
- $info = Dever::db('option/account')->one($id);
- if ($info) {
- if ($audit && $audit > 2) {
- $update['audit_date'] = time();
- $update['where_id'] = $info['id'];
- Dever::db('option/account')->update($update);
- }
- if ($send_email == 2 && $email && $email != $info['email']) {
- $update = array();
- $update['is_email'] = 2;
- $update['where_id'] = $info['id'];
- Dever::db('option/account')->update($update);
- if ($send_email == 2) {
- $member = Dever::db('option/account')->one($info['mid']);
- if ($member) {
- $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=' . $member['name'], 'option');
- }
- }
- }
- }
- }
-
- public function setAgreement($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_commit', $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);
- $mid = Dever::param('mid', $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, $mid, $type, $cash, $desc);
- } else {
- Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
- Dever::alert('期权账户已停用或者未审核,操作失败');
- }
- }
- }
- public function getDate($id)
- {
- $info = Dever::db('option/agreement')->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 '';
- }
- public function upAgreement_api()
- {
- $id = Dever::input('id');
- if ($id) {
- Dever::load('option/lib/agreement')->upContent($id);
- }
-
- return 'reload';
- }
- public function dropAgreement_api()
- {
- $id = Dever::input('id');
- if ($id) {
- Dever::load('option/lib/agreement')->drop($id);
- }
-
- return 'reload';
- }
- public function checkMember($id, $name, $data)
- {
- $main = Dever::param('main', $data);
- $key = Dever::param('key', $data);
- if (!$key) {
- Dever::alert('请传入账户索引');
- }
- if ($main == 2) {
- $main = Dever::db('option/member')->getMain(array('key' => $key));
- if (!$main) {
- Dever::alert('请先创建主账号');
- }
- } elseif ($main == 1) {
- $main = Dever::db('option/member')->getMain(array('key' => $key));
- if ($main) {
- Dever::alert('已存在主账号');
- }
- }
- }
- }
|