123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?php
- namespace Option\Src;
- use Dever;
- use Option\Lib\Core;
- class My extends Core
- {
- public function test()
- {
- $id = Dever::input('id');
- $email = Dever::input('email');
- $account = Dever::db('option/account')->find($id);
- if ($account && $account['email']) {
- if ($email) {
- $account['email'] = $email;
- }
- $member = Dever::db('option/member')->find($account['mid']);
- $code = Dever::load('passport/reg')->code(false, false);
- $email = base64_encode($account['email']);
- return Dever::load('option/lib/email.renzheng?aid='.$account['id'].'&email=' . $email . '&code=' . $code . '&username=' . $member['name']);
- }
- }
- /**
- * 获取基本信息
- *
- * @return mixed
- */
- public function getInfo()
- {
- $this->data['user'] = $this->user;
- $this->data['cash'] = Dever::db('option/cash')->getTotal(array('aid' => $this->uid));
- $jiaofu = Dever::db('option/bill_jiaofu')->find(array('status' => 2, 'aid' => $this->uid));
- $this->data['jiaofu_state'] = 2;
- if ($jiaofu) {
- $this->data['jiaofu_state'] = 1;
- }
- $agreement = Dever::db('option/agreement')->find(array('aid' => $this->uid, 'audit' => 3));
- $this->data['agreement_state'] = 2;
- if ($agreement) {
- $this->data['agreement_state'] = 1;
- }
- $agreement = Dever::db('option/agreement')->getOne(array('aid' => $this->uid));
- $audit = array
- (
- 'status' => 1,
- 'desc' => '',
- 'date' => date('Y.m.d H:i'),
- );
- $this->data['audit'] = $audit;
- $total = 0;
- $cash_type = Dever::load('option/lib/manage')->getQiquan($this->user['company_id']);
- if ($this->data['cash']) {
- foreach ($this->data['cash'] as $k => $v) {
- $this->data['cash'][$k]['type_name'] = $cash_type[$v['type']]['name'] . '交付价值';
- $total += $v['daijiaofu'];
- $this->data['cash'][$k]['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
- if ($this->data['cash'][$k]['total'] <= 0) {
- unset($this->data['cash'][$k]);
- }
- }
- $this->data['cash'] = array_slice($this->data['cash'], 0);
- }
- if ($agreement) {
- if ($agreement['audit'] == 3 && $total > 0) {
- $audit['status'] = 1;
- $audit['desc'] = '';
- } else {
- $audit['status'] = $agreement['audit'];
- $audit['desc'] = $agreement['audit_desc'];
- }
- }
-
- return $this->data;
- }
- # 待交付期权列表
- public function getValue()
- {
- $this->data['list'] = Dever::db('option/cash')->getTotal(array('aid' => $this->uid));
- $agreement = Dever::db('option/agreement')->getOne(array('aid' => $this->uid));
- $audit = array
- (
- 'status' => 1,
- 'desc' => '',
- 'date' => date('Y.m.d H:i'),
- );
- $date = 0;
- $total = $qiquan = $yuanshi = 0;
- $cash_type = Dever::load('option/lib/manage')->getQiquan($this->user['company_id']);
- if ($this->data['list']) {
- foreach ($this->data['list'] as $k => $v) {
- $this->data['list'][$k]['type_name'] = '待交付' . $cash_type[$v['type']]['name'];
- if ($v['daijiaofu_date'] > $date) {
- $date = $v['daijiaofu_date'];
- }
- $total += $v['daijiaofu'];
- # 这里之后再改
- if ($v['type'] == 1 || $v['type'] == 3) {
- $qiquan += $v['daijiaofu'];
- } else {
- $yuanshi += $v['daijiaofu'];
- }
- }
- }
- if ($date) {
- $audit['date'] = date('Y.m.d H:i', $date);
- }
- if ($agreement) {
- if ($agreement['audit'] == 3 && $total > 0) {
- $audit['status'] = 1;
- $audit['desc'] = '';
- } else {
- $audit['status'] = $agreement['audit'];
- $audit['desc'] = $agreement['audit_desc'];
- }
- }
-
- $total = number_format($total, 2, '.', '');
- $this->data['audit'] = $audit;
- $name = Dever::load('option/lib/agreement')->name(false, $this->user, 1, 2, $date, $total, $qiquan, $yuanshi);
- $this->data['agreement_link'] = $name[1];
- return $this->data;
- }
- # 获取交付列表
- 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['idcard_path'] = Dever::input('idcard_path');
- if($where['idcard_path']){
- $idcard_path = (array)json_decode($where['idcard_path']);
- if($idcard_path['face']){
- $rest = (array)$idcard_path['face'];
- if($this->user['name'] != $rest['name'] || $this->user['idcard'] != $rest['idNumber']){
- Dever::alert('姓名或身份证号不匹配');
- }
- }
- if($idcard_path['back']){
- $rest = (array)$idcard_path['back'];
- $date = explode('-',$rest['validPeriod']);
- if($date[1] && $date[1]!='长期'){
- $cdate = strtotime(str_replace('.','-',$date[1]));
- if(time()>=$cdate){
- 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['status'] = 2;
- $where['is_idcard'] = 1;
- $where['up_date'] = time();
- Dever::db('option/account')->update($where);
- Dever::db('option/member')->update(array('where_id' => $this->user['mid'], 'idcard_bind' => 1));
- }
- if (isset($where['is_email']) && $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');
- Dever::load('option/lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name']);
- }
- return Dever::db('option/account')->find(array('id' => $this->uid, 'clear' => true));
- }
- # 确认签署
- public function act_commit()
- {
- Dever::config('base')->hook = true;
- $update['sign'] = Dever::input('sign');
- if (!$update['sign']) {
- Dever::alert('请上传签名');
- }
- $data = Dever::db('option/cash')->select(array('aid' => $this->uid));
- if (!$data) {
- Dever::alert('没有待交付的期权价值');
- }
- $date = 0;
- $total = 0;
- $qiquan = 0;
- $yuanshi = 0;
- if ($data) {
- foreach ($data as $k => $v) {
- if ($v['daijiaofu_date'] > $date) {
- $date = $v['daijiaofu_date'];
- }
- $total += $v['daijiaofu'];
- # 这里之后再改,影响较大,合同表需要重构
- if ($v['type'] == 1 || $v['type'] == 3) {
- $qiquan += $v['daijiaofu'];
- } else {
- $yuanshi += $v['daijiaofu'];
- }
- }
- }
- $total = number_format($total, 2, '.', '');
- # 签署合同
- $this->user['sign'] = $update['sign'];
- $agreement_id = Dever::load('option/lib/agreement')->up($this->user, $date, $total, $qiquan, $yuanshi);
- return $this->user;
- }
- # 获取期权协议内容
- public function getAgreementContent()
- {
- return 'test';
- }
- # 获取我的合同
- public function getAgreement()
- {
- $where['aid'] = $this->uid;
- $where['audit'] = 3;
- $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()
- {
- $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;
- }
- }
|