Account.php 15 KB

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