My.php 10 KB

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