Account.php 17 KB

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