Account.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <?php
  2. namespace Option\Lib;
  3. use Dever;
  4. class Account
  5. {
  6. public function getIdcard($id)
  7. {
  8. if ($id < 0) {
  9. return '无';
  10. }
  11. $account = Dever::db('option/account')->find($id);
  12. if ($account && $account['is_idcard'] == 1) {
  13. $html = '';
  14. $table = array();
  15. if ($account['idcard_front']) {
  16. $table['<img src="'.$account['idcard_front'].'" width="100">'] = '<img src="'.$account['idcard_back'].'" width="100">';
  17. }
  18. $html .= Dever::table($table);
  19. return $html;
  20. } else {
  21. return '未上传';
  22. }
  23. }
  24. public function getInfo($id)
  25. {
  26. if ($id < 0) {
  27. return '无';
  28. }
  29. $account = Dever::db('option/account')->find($id);
  30. if ($account) {
  31. return Dever::load('option/lib/member')->getInfo($account['mid']);
  32. } else {
  33. return '';
  34. }
  35. }
  36. public function getEmail($id)
  37. {
  38. if ($id < 0) {
  39. return '无';
  40. }
  41. $account = Dever::db('option/account')->find($id);
  42. if ($account) {
  43. $string = $account['email'];
  44. if ($string) {
  45. $string .= '<br />';
  46. }
  47. if ($account['is_email'] == 1) {
  48. $string .= '<font style="color:blue">已验证</font>';
  49. } else {
  50. $string .= '<font style="color:red">未验证</font>';
  51. }
  52. return $string;
  53. } else {
  54. return '';
  55. }
  56. }
  57. public function getAudit($id, $table = 'option/account')
  58. {
  59. if ($id < 0) {
  60. return '无';
  61. }
  62. $audit = Dever::db($table)->config['set']['audit'];
  63. $account = Dever::db($table)->find($id);
  64. if ($account) {
  65. $string = $audit[$account['audit']];
  66. if ($account['audit'] == 4) {
  67. $string .= '<br />原因:' . $account['audit_desc'];
  68. }
  69. if ($account['audit_date']) {
  70. $audit_date = date('Y-m-d H:i:s', $account['audit_date']);
  71. $string .= '<br />'.$audit_date;
  72. }
  73. return $string;
  74. } else {
  75. return '';
  76. }
  77. }
  78. public function getAgreementStatus($id, $table = 'option/agreement')
  79. {
  80. if ($id < 0) {
  81. return '无';
  82. }
  83. $audit = Dever::db($table)->config['audit'];
  84. $agreement = Dever::db($table)->find(array('aid' => $id));
  85. if ($agreement) {
  86. $string = $audit[$agreement['audit']];
  87. if ($agreement['audit'] == 4) {
  88. $string .= '<br />原因:' . $agreement['audit_desc'];
  89. }
  90. if ($agreement['audit_date']) {
  91. $audit_date = date('Y-m-d H:i:s', $agreement['audit_date']);
  92. $string .= '<br />'.$audit_date;
  93. }
  94. return $string;
  95. } else {
  96. return '未签署';
  97. }
  98. }
  99. /**
  100. * 验证手机号
  101. * @return mixed
  102. */
  103. public function checkMobile($mobile)
  104. {
  105. $rule = Dever::rule('mobile');
  106. if (!$mobile) {
  107. Dever::alert('手机号不能为空');
  108. }
  109. if (!preg_match($rule, $mobile)) {
  110. Dever::alert('手机号码格式错误');
  111. }
  112. return $mobile;
  113. }
  114. /**
  115. * 验证验证码
  116. * @return mixed
  117. */
  118. public function checkMcode($mobile)
  119. {
  120. $code = Dever::input('mcode');
  121. if (!$code) {
  122. Dever::alert('请输入验证码');
  123. }
  124. $code = Dever::load('passport/reg')->mcode($mobile, $code, 1);
  125. if (!$code) {
  126. Dever::alert('验证码输入错误');
  127. }
  128. }
  129. /**
  130. * 查看详情
  131. * @return mixed
  132. */
  133. public function show()
  134. {
  135. $aid = Dever::input('aid');
  136. $mid = Dever::input('mid');
  137. if ($mid) {
  138. $member = Dever::db('option/member')->one($mid);
  139. $aid = $member['aid'];
  140. }
  141. $account = Dever::db('option/account')->one($aid);
  142. if (!$mid) {
  143. $member = Dever::db('option/member')->one($account['mid']);
  144. }
  145. $config = Dever::db('option/account')->config['set'];
  146. $member_config = Dever::db('option/member')->config['set'];
  147. $result['账户信息'] = $this->getMemberInfo($member, $member_config);
  148. $search_auth = Dever::input('search_auth');
  149. $option_aid = $aid;
  150. if ($search_auth) {
  151. $option_aid .= '&search_auth=' . $search_auth;
  152. }
  153. if ($member['main'] == 1) {
  154. $idcard_front = $idcard_back = '';
  155. if ($account['idcard_front']) {
  156. $idcard_front = '<a href="'.$account['idcard_front'].'" target="_blank"><img src="'.$account['idcard_front'].'" width="150" /></a>';
  157. }
  158. if ($account['idcard_back']) {
  159. $idcard_back = '&nbsp;&nbsp;<a href="'.$account['idcard_back'].'" target="_blank"><img src="'.$account['idcard_back'].'" width="150" /></a>';
  160. }
  161. if ($account['email']) {
  162. $account['email'] .= '('.$config['is_email'][$account['is_email']].')';
  163. }
  164. $table = array();
  165. $table['head'] = array('账户状态', '审核状态', '邮箱认证', '身份证正面', '身份证反面');
  166. $table['body'] = array();
  167. $table['body'][] = array
  168. (
  169. $config['status'][$account['status']],
  170. $config['audit'][$account['audit']],
  171. $account['email'],
  172. $idcard_front,
  173. $idcard_back,
  174. );
  175. $result['审核信息'] = array
  176. (
  177. 'type' => 'table',
  178. 'content' => $table,
  179. );
  180. # 获取账户资金
  181. $cash_type = Dever::db('option/cash')->config['config_type'];
  182. $cash = Dever::db('option/cash')->getTotal(array('aid' => $aid));
  183. if ($cash) {
  184. $table = array();
  185. $table['head'] = array('账户类型', '待交付', '已交付总额', '已发放剩余', '未发放', '已兑付');
  186. $table['body'] = array();
  187. foreach ($cash as $k => $v) {
  188. $total = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  189. //$weifafang = number_format($total-$v['fafang']-$v['duifu'], 2);
  190. $table['body'][] = array
  191. (
  192. $cash_type[$v['type']],
  193. $v['daijiaofu'],
  194. $total,
  195. //$v['jiaofu'],
  196. $v['fafang'],
  197. $v['jiaofu'],
  198. $v['duifu'],
  199. );
  200. }
  201. $result['账户金额'] = array
  202. (
  203. 'type' => 'table',
  204. 'content' => $table,
  205. );
  206. }
  207. }
  208. $button = array();
  209. $button[0]['btn'][] = array
  210. (
  211. 'type' => 'edit',
  212. 'link' => Dever::url('project/database/update?project=option&table=member&where_id='.$mid.'&status=1&col=name,idcard', 'manage'),
  213. 'name' => '修改资料',
  214. );
  215. $button[0]['btn'][] = array
  216. (
  217. 'type' => 'edit',
  218. 'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$aid.'&status=1&col=email,send_email', 'manage'),
  219. 'name' => '修改邮箱',
  220. );
  221. $url = '';
  222. if ($account['audit'] == 2) {
  223. $button[0]['btn'][] = array
  224. (
  225. 'type' => 'edit',
  226. 'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$aid.'&status=1&col=audit,audit_desc', 'manage'),
  227. 'name' => '审核',
  228. );
  229. }
  230. if ($account['status'] == 3) {
  231. $button[0]['btn'][] = array
  232. (
  233. 'type' => 'action',
  234. 'link' => Dever::url('lib/account.setStatus?id=' . $aid . '&value=2', 'option'),
  235. 'name' => '恢复账号',
  236. );
  237. } elseif ($account['status'] == 2) {
  238. $button[0]['btn'][] = array
  239. (
  240. 'type' => 'action',
  241. 'link' => Dever::url('lib/account.setStatus?id=' . $aid . '&value=3', 'option'),
  242. 'name' => '禁用账号',
  243. );
  244. }
  245. $button[0]['btn'][] = array
  246. (
  247. 'type' => 'link',
  248. 'link' => Dever::url('project/database/list?project=option&table=agreement&search_option_aid='.$option_aid.'', 'manage'),
  249. 'name' => '期权合同',
  250. );
  251. // $button[0]['btn'][] = array
  252. // (
  253. // 'type' => 'edit',
  254. // 'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_mid='.$mid.'&search_option_aid='.$option_aid . '&type=1', 'manage'),
  255. // 'name' => '期权价值交付',
  256. // );
  257. // $button[0]['btn'][] = array
  258. // (
  259. // 'type' => 'edit',
  260. // 'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_mid='.$mid.'&search_option_aid='.$option_aid . '&type=2', 'manage'),
  261. // 'name' => '期权价值发放',
  262. // );
  263. $button[1]['btn'][] = array
  264. (
  265. 'type' => 'link',
  266. 'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&search_option_aid='.$option_aid.'', 'manage'),
  267. 'name' => '期权交付记录',
  268. );
  269. $button[1]['btn'][] = array
  270. (
  271. 'type' => 'link',
  272. 'link' => Dever::url('project/database/list?project=option&table=bill_fafang&search_option_aid='.$option_aid.'', 'manage'),
  273. 'name' => '期权发放记录',
  274. );
  275. $button[1]['btn'][] = array
  276. (
  277. 'type' => 'link',
  278. 'link' => Dever::url('project/database/list?project=option&table=bill_duifu&search_option_aid='.$option_aid.'', 'manage'),
  279. 'name' => '期权兑付记录',
  280. );
  281. if ($search_auth == -1) {
  282. $url = Dever::url('project/database/list?project=option&table=member&search_option_main=2&search_option_aid=' . $aid, 'manage');
  283. } else {
  284. $url = Dever::url('project/database/list?project=option&table=account', 'manage');
  285. if ($search_auth) {
  286. $url .= '&search_option_dever_auth=' . $search_auth;
  287. }
  288. }
  289. $head_btn[] = array
  290. (
  291. 'type' => 'link',
  292. 'link' => $url,
  293. 'name' => '返回上一页',
  294. );
  295. $head = array
  296. (
  297. 'name' => '基本信息',
  298. 'btn' => $head_btn,
  299. );
  300. $foot = $button;
  301. $html = Dever::show($head, $result, $foot);
  302. return $html;
  303. }
  304. private function getMemberInfo($member, $member_config)
  305. {
  306. $result = array();
  307. $result = array
  308. (
  309. 'type' => 'info',
  310. 'content' => array
  311. (
  312. array
  313. (
  314. array('账户类型', $member_config['main'][$member['main']]),
  315. array('账户索引', $member['key']),
  316. ),
  317. array
  318. (
  319. array('姓名', $member['name']),
  320. array('手机号', $member['mobile']),
  321. array('身份证号', $member['idcard']),
  322. ),
  323. ),
  324. );
  325. return $result;
  326. }
  327. public function setStatus_api()
  328. {
  329. $where['where_id'] = Dever::input('id');
  330. $where['status'] = Dever::input('value');
  331. Dever::db('option/account')->update($where);
  332. return 'reload';
  333. }
  334. public function daijiaofu($id)
  335. {
  336. $where['aid'] = $id;
  337. $total = Dever::db('option/bill_jiaofu')->total($where);
  338. $html = $total . '条';
  339. $cash = Dever::db('option/cash')->getTotal(array('aid' => $id));
  340. $total = 0;
  341. if ($cash) {
  342. foreach ($cash as $k => $v) {
  343. $total += $v['daijiaofu'];
  344. }
  345. }
  346. $html .= '<br/ >' . number_format($total, 2, '.', '');
  347. return $html;
  348. }
  349. public function getCash($id)
  350. {
  351. $where['aid'] = $id;
  352. $where['status'] = 2;
  353. $total = Dever::db('option/bill_jiaofu')->total($where);
  354. $daijiaofu = $total . '条';
  355. $daijiaofu_qiquan = 0;
  356. $daijiaofu_yuanshiqiquan = 0;
  357. $cash = Dever::db('option/cash')->getTotal(array('aid' => $id, 'status' => 2));
  358. $total = 0;
  359. $qiquan = '';
  360. $yuanshiqiquan = '';
  361. if ($cash) {
  362. foreach ($cash as $k => $v) {
  363. $v['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  364. $total += $v['daijiaofu'];
  365. if ($v['type'] == 1) {
  366. $daijiaofu_qiquan += $v['daijiaofu'];
  367. $qiquan .= $v['total'];
  368. $qiquan .= '<br/ >发放' . $v['fafang'];
  369. $qiquan .= '<br/ >未发' . $v['jiaofu'];
  370. $qiquan .= '<br/ >兑付' . $v['duifu'];
  371. } elseif ($v['type'] == 2) {
  372. $daijiaofu_yuanshiqiquan += $v['daijiaofu'];
  373. $yuanshiqiquan .= $v['total'];
  374. $yuanshiqiquan .= '<br/ >发放' . $v['fafang'];
  375. $yuanshiqiquan .= '<br/ >未发' . $v['jiaofu'];
  376. $yuanshiqiquan .= '<br/ >兑付' . $v['duifu'];
  377. }
  378. }
  379. }
  380. $daijiaofu .= '<br/ >' . number_format($daijiaofu_qiquan, 2, '.', '') . '<br/ >' . number_format($daijiaofu_yuanshiqiquan, 2, '.', '');
  381. if (!$qiquan) {
  382. $qiquan = '无';
  383. }
  384. if (!$yuanshiqiquan) {
  385. $yuanshiqiquan = '无';
  386. }
  387. return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
  388. }
  389. }