My.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <?php
  2. namespace Option\Src;
  3. use Dever;
  4. use Option\Lib\Core;
  5. class My extends Core
  6. {
  7. public function test()
  8. {
  9. $id = Dever::input('id');
  10. $email = Dever::input('email');
  11. $account = Dever::db('option/account')->find($id);
  12. if ($account && $account['email']) {
  13. if ($email) {
  14. $account['email'] = $email;
  15. }
  16. $member = Dever::db('option/member')->find($account['mid']);
  17. $code = Dever::load('passport/reg')->code(false, false);
  18. $email = base64_encode($account['email']);
  19. return Dever::load('option/lib/email.renzheng?aid='.$account['id'].'&email=' . $email . '&code=' . $code . '&username=' . $member['name']);
  20. }
  21. }
  22. /**
  23. * 获取基本信息
  24. *
  25. * @return mixed
  26. */
  27. public function getInfo()
  28. {
  29. $this->data['user'] = $this->user;
  30. $this->data['cash'] = Dever::db('option/cash')->getTotal(array('aid' => $this->uid));
  31. $jiaofu = Dever::db('option/bill_jiaofu')->find(array('status' => 2, 'aid' => $this->uid));
  32. $this->data['jiaofu_state'] = 2;
  33. if ($jiaofu) {
  34. $this->data['jiaofu_state'] = 1;
  35. }
  36. $agreement = Dever::db('option/agreement')->find(array('aid' => $this->uid, 'audit' => 3));
  37. $this->data['agreement_state'] = 2;
  38. if ($agreement) {
  39. $this->data['agreement_state'] = 1;
  40. }
  41. $agreement = Dever::db('option/agreement')->getOne(array('aid' => $this->uid));
  42. $audit = array
  43. (
  44. 'status' => 1,
  45. 'desc' => '',
  46. 'date' => date('Y.m.d H:i'),
  47. );
  48. $this->data['audit'] = $audit;
  49. $total = 0;
  50. $cash_type = Dever::load('option/lib/manage')->getQiquan($this->user['company_id']);
  51. if ($this->data['cash']) {
  52. foreach ($this->data['cash'] as $k => $v) {
  53. $this->data['cash'][$k]['type_name'] = $cash_type[$v['type']]['name'] . '交付价值';
  54. $total += $v['daijiaofu'];
  55. $this->data['cash'][$k]['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  56. if ($this->data['cash'][$k]['total'] <= 0) {
  57. unset($this->data['cash'][$k]);
  58. }
  59. }
  60. $this->data['cash'] = array_slice($this->data['cash'], 0);
  61. }
  62. if ($agreement) {
  63. if ($agreement['audit'] == 3 && $total > 0) {
  64. $audit['status'] = 1;
  65. $audit['desc'] = '';
  66. } else {
  67. $audit['status'] = $agreement['audit'];
  68. $audit['desc'] = $agreement['audit_desc'];
  69. }
  70. }
  71. return $this->data;
  72. }
  73. # 待交付期权列表
  74. public function getValue()
  75. {
  76. $this->data['list'] = Dever::db('option/cash')->getTotal(array('aid' => $this->uid));
  77. $agreement = Dever::db('option/agreement')->getOne(array('aid' => $this->uid));
  78. $audit = array
  79. (
  80. 'status' => 1,
  81. 'desc' => '',
  82. 'date' => date('Y.m.d H:i'),
  83. );
  84. $date = 0;
  85. $total = $qiquan = $yuanshi = 0;
  86. $cash_type = Dever::load('option/lib/manage')->getQiquan($this->user['company_id']);
  87. if ($this->data['list']) {
  88. foreach ($this->data['list'] as $k => $v) {
  89. $this->data['list'][$k]['type_name'] = '待交付' . $cash_type[$v['type']]['name'];
  90. if ($v['daijiaofu_date'] > $date) {
  91. $date = $v['daijiaofu_date'];
  92. }
  93. $total += $v['daijiaofu'];
  94. # 这里之后再改
  95. if ($v['type'] == 1 || $v['type'] == 3) {
  96. $qiquan += $v['daijiaofu'];
  97. } else {
  98. $yuanshi += $v['daijiaofu'];
  99. }
  100. }
  101. }
  102. if ($date) {
  103. $audit['date'] = date('Y.m.d H:i', $date);
  104. }
  105. if ($agreement) {
  106. if ($agreement['audit'] == 3 && $total > 0) {
  107. $audit['status'] = 1;
  108. $audit['desc'] = '';
  109. } else {
  110. $audit['status'] = $agreement['audit'];
  111. $audit['desc'] = $agreement['audit_desc'];
  112. }
  113. }
  114. $total = number_format($total, 2, '.', '');
  115. $this->data['audit'] = $audit;
  116. $name = Dever::load('option/lib/agreement')->name(false, $this->user, 1, 2, $date, $total, $qiquan, $yuanshi);
  117. $this->data['agreement_link'] = $name[1];
  118. return $this->data;
  119. }
  120. # 获取交付列表
  121. public function getJiaofu()
  122. {
  123. $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'jiaofu', 1, '交付');
  124. return $this->data;
  125. }
  126. # 获取交付详情
  127. public function getJiaofuView()
  128. {
  129. $id = Dever::input('id');
  130. $this->data['info'] = Dever::load('option/lib/cash')->getView($id, $this->uid, 'jiaofu', '交付');
  131. return $this->data;
  132. }
  133. # 获取发放列表
  134. public function getFafang()
  135. {
  136. $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'fafang', 1, '发放');
  137. return $this->data;
  138. }
  139. # 获取发放详情
  140. public function getFafangView()
  141. {
  142. $id = Dever::input('id');
  143. $this->data['info'] = Dever::load('option/lib/cash')->getView($id, $this->uid, 'fafang', '发放');
  144. return $this->data;
  145. }
  146. # 获取兑付列表
  147. public function getDuifu()
  148. {
  149. $this->data['list'] = Dever::load('option/lib/cash')->getList($this->uid, 'duifu', 1, '兑付');
  150. return $this->data;
  151. }
  152. # 获取兑付详情
  153. public function getDuifuView()
  154. {
  155. $id = Dever::input('id');
  156. $this->data['info'] = Dever::load('option/lib/cash')->getView($id, $this->uid, 'duifu', '兑付');
  157. return $this->data;
  158. }
  159. # 修改资料
  160. public function setInfo()
  161. {
  162. $where = array();
  163. /*
  164. $where['name'] = Dever::input('name');
  165. if (!$where['name']) {
  166. Dever::alert('请输入姓名');
  167. }
  168. $where['idcard'] = Dever::input('idcard');
  169. if (!$where['idcard']) {
  170. Dever::alert('请输入身份证号');
  171. }*/
  172. $where['idcard_front'] = Dever::input('idcard_front');
  173. if (!$where['idcard_front']) {
  174. Dever::alert('请上传身份证正面照片');
  175. }
  176. $where['idcard_back'] = Dever::input('idcard_back');
  177. if (!$where['idcard_back']) {
  178. Dever::alert('请上传身份证背面照片');
  179. }
  180. $where['idcard_path'] = Dever::input('idcard_path');
  181. if($where['idcard_path']){
  182. $idcard_path = (array)json_decode($where['idcard_path']);
  183. if($idcard_path['face']){
  184. $rest = (array)$idcard_path['face'];
  185. if($this->user['name'] != $rest['name'] || $this->user['idcard'] != $rest['idNumber']){
  186. Dever::alert('姓名或身份证号不匹配');
  187. }
  188. }
  189. if($idcard_path['back']){
  190. $rest = (array)$idcard_path['back'];
  191. $date = explode('-',$rest['validPeriod']);
  192. if($date[1] && $date[1]!='长期'){
  193. $cdate = strtotime(str_replace('.','-',$date[1]));
  194. if(time()>=$cdate){
  195. Dever::alert('身份证背面已过期');
  196. }
  197. }
  198. }
  199. }
  200. $where['email'] = Dever::input('email');
  201. if (!$where['email']) {
  202. Dever::alert('请填写邮箱');
  203. }
  204. $check = Dever::db('option/account')->find(array('email' => $where['email']));
  205. if ($check && $check['id'] != $this->uid) {
  206. Dever::alert('邮箱已被验证,请重新填写');
  207. }
  208. if ($where['email'] != $this->user['email']) {
  209. $where['is_email'] = 2;
  210. }
  211. if ($where) {
  212. $where['where_id'] = $this->uid;
  213. $where['audit'] = 2;
  214. $where['status'] = 2;
  215. $where['is_idcard'] = 1;
  216. $where['up_date'] = time();
  217. Dever::db('option/account')->update($where);
  218. Dever::db('option/member')->update(array('where_id' => $this->user['mid'], 'idcard_bind' => 1));
  219. }
  220. if (isset($where['is_email']) && $where['is_email'] == 2) {
  221. $code = Dever::load('passport/reg')->code(false, false);
  222. $email = base64_encode($where['email']);
  223. //Dever::daemon('lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name'], 'option');
  224. Dever::load('option/lib/email.renzheng?aid='.$this->uid.'&email=' . $email . '&code=' . $code . '&username=' . $this->user['name']);
  225. }
  226. return Dever::db('option/account')->find(array('id' => $this->uid, 'clear' => true));
  227. }
  228. # 确认签署
  229. public function act_commit()
  230. {
  231. Dever::config('base')->hook = true;
  232. $update['sign'] = Dever::input('sign');
  233. if (!$update['sign']) {
  234. Dever::alert('请上传签名');
  235. }
  236. $data = Dever::db('option/cash')->select(array('aid' => $this->uid));
  237. if (!$data) {
  238. Dever::alert('没有待交付的期权价值');
  239. }
  240. $date = 0;
  241. $total = 0;
  242. $qiquan = 0;
  243. $yuanshi = 0;
  244. if ($data) {
  245. foreach ($data as $k => $v) {
  246. if ($v['daijiaofu_date'] > $date) {
  247. $date = $v['daijiaofu_date'];
  248. }
  249. $total += $v['daijiaofu'];
  250. # 这里之后再改,影响较大,合同表需要重构
  251. if ($v['type'] == 1 || $v['type'] == 3) {
  252. $qiquan += $v['daijiaofu'];
  253. } else {
  254. $yuanshi += $v['daijiaofu'];
  255. }
  256. }
  257. }
  258. $total = number_format($total, 2, '.', '');
  259. # 签署合同
  260. $this->user['sign'] = $update['sign'];
  261. $agreement_id = Dever::load('option/lib/agreement')->up($this->user, $date, $total, $qiquan, $yuanshi);
  262. return $this->user;
  263. }
  264. # 获取期权协议内容
  265. public function getAgreementContent()
  266. {
  267. return 'test';
  268. }
  269. # 获取我的合同
  270. public function getAgreement()
  271. {
  272. $where['aid'] = $this->uid;
  273. $where['audit'] = 3;
  274. $this->data['list'] = Dever::db('option/agreement')->getAll($where);
  275. if ($this->data['list']) {
  276. $status = Dever::db('option/agreement')->config['status'];
  277. foreach ($this->data['list'] as $k => $v) {
  278. $this->data['list'][$k]['status_name'] = $status[$v['status']];
  279. $this->data['list'][$k]['qdate_string'] = '';
  280. if ($v['qdate']) {
  281. $this->data['list'][$k]['qdate_string'] = date('Y.m.d', $v['qdate']);
  282. }
  283. $name = Dever::load('option/lib/agreement')->name($v['agreement_id'], $v, 2, 2);
  284. $this->data['list'][$k]['link'] = $name[1];
  285. }
  286. }
  287. return $this->data;
  288. }
  289. # 获取我的合同
  290. public function getAgreementView()
  291. {
  292. $where['aid'] = $this->uid;
  293. $where['id'] = Dever::input('id');
  294. $this->data['info'] = array();
  295. if ($where['id']) {
  296. $status = Dever::db('option/agreement')->config['status'];
  297. $this->data['info'] = Dever::db('option/agreement')->find($where);
  298. if ($this->data['info']) {
  299. $this->data['info']['status_name'] = $status[$this->data['info']['status']];
  300. $this->data['info']['qdate_string'] = '';
  301. if ($this->data['info']['qdate']) {
  302. $this->data['info']['qdate_string'] = date('Y.m.d', $this->data['info']['qdate']);
  303. }
  304. $name = Dever::load('option/lib/agreement')->name($this->data['info']['agreement_id'], $this->data['info'], 2, 2);
  305. $this->data['info']['link'] = $name[1];
  306. }
  307. }
  308. return $this->data;
  309. }
  310. }