Account.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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_front'].'" 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. /**
  79. * 验证手机号
  80. * @return mixed
  81. */
  82. public function checkMobile($mobile)
  83. {
  84. $rule = Dever::rule('mobile');
  85. if (!$mobile) {
  86. Dever::alert('手机号不能为空');
  87. }
  88. if (!preg_match($rule, $mobile)) {
  89. Dever::alert('手机号码格式错误');
  90. }
  91. return $mobile;
  92. }
  93. /**
  94. * 验证验证码
  95. * @return mixed
  96. */
  97. public function checkMcode($mobile)
  98. {
  99. $code = Dever::input('mcode');
  100. if (!$code) {
  101. Dever::alert('请输入验证码');
  102. }
  103. $code = Dever::load('passport/reg')->mcode($mobile, $code, 1);
  104. if (!$code) {
  105. Dever::alert('验证码输入错误');
  106. }
  107. }
  108. /**
  109. * 查看详情
  110. * @return mixed
  111. */
  112. public function show()
  113. {
  114. $aid = Dever::input('aid');
  115. $mid = Dever::input('mid');
  116. if ($mid) {
  117. $member = Dever::db('option/member')->one($mid);
  118. $aid = $member['aid'];
  119. }
  120. $account = Dever::db('option/account')->one($aid);
  121. if (!$mid) {
  122. $member = Dever::db('option/member')->one($account['mid']);
  123. }
  124. $config = Dever::db('option/account')->config['set'];
  125. $member_config = Dever::db('option/member')->config['set'];
  126. $result['账户信息'] = $this->getMemberInfo($member, $member_config);
  127. $search_stype = Dever::input('search_stype');
  128. $option_aid = $aid;
  129. if ($search_stype) {
  130. $option_aid .= '&search_stype=' . $search_stype;
  131. }
  132. if ($member['main'] == 1) {
  133. $idcard_front = $idcard_back = '';
  134. if ($account['idcard_front']) {
  135. $idcard_front = '<a href="'.$account['idcard_front'].'" target="_blank"><img src="'.$account['idcard_front'].'" width="150" /></a>';
  136. }
  137. if ($account['idcard_back']) {
  138. $idcard_back = '&nbsp;&nbsp;<a href="'.$account['idcard_back'].'" target="_blank"><img src="'.$account['idcard_back'].'" width="150" /></a>';
  139. }
  140. if ($account['email']) {
  141. $account['email'] .= '('.$config['is_email'][$account['is_email']].')';
  142. }
  143. $table = array();
  144. $table['head'] = array('账户状态', '审核状态', '邮箱认证', '身份证正面', '身份证反面');
  145. $table['body'] = array();
  146. $table['body'][] = array
  147. (
  148. $config['status'][$account['status']],
  149. $config['audit'][$account['audit']],
  150. $account['email'],
  151. $idcard_front,
  152. $idcard_back,
  153. );
  154. $result['审核信息'] = array
  155. (
  156. 'type' => 'table',
  157. 'content' => $table,
  158. );
  159. # 获取账户资金
  160. $cash_type = Dever::db('option/cash')->config['config_type'];
  161. $cash = Dever::db('option/cash')->getTotal(array('aid' => $aid));
  162. if ($cash) {
  163. $table = array();
  164. $table['head'] = array('账户类型', '待交付', '已交付总额', '已发放剩余', '未发放', '已兑付');
  165. $table['body'] = array();
  166. foreach ($cash as $k => $v) {
  167. $total = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  168. //$weifafang = number_format($total-$v['fafang']-$v['duifu'], 2);
  169. $table['body'][] = array
  170. (
  171. $cash_type[$v['type']],
  172. $v['daijiaofu'],
  173. $total,
  174. //$v['jiaofu'],
  175. $v['fafang'],
  176. $v['jiaofu'],
  177. $v['duifu'],
  178. );
  179. }
  180. $result['账户金额'] = array
  181. (
  182. 'type' => 'table',
  183. 'content' => $table,
  184. );
  185. }
  186. }
  187. $button = array();
  188. $button[0]['btn'][] = array
  189. (
  190. 'type' => 'edit',
  191. 'link' => Dever::url('project/database/update?project=option&table=member&where_id='.$mid.'&status=1&col=name,idcard', 'manage'),
  192. 'name' => '修改资料',
  193. );
  194. $button[0]['btn'][] = array
  195. (
  196. 'type' => 'edit',
  197. 'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$aid.'&status=1&col=email,send_email', 'manage'),
  198. 'name' => '修改邮箱',
  199. );
  200. $url = '';
  201. if ($account['audit'] == 2) {
  202. $button[0]['btn'][] = array
  203. (
  204. 'type' => 'edit',
  205. 'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$aid.'&status=1&col=audit,audit_desc', 'manage'),
  206. 'name' => '审核',
  207. );
  208. }
  209. if ($account['status'] == 3) {
  210. $button[0]['btn'][] = array
  211. (
  212. 'type' => 'action',
  213. 'link' => Dever::url('lib/account.setStatus?id=' . $aid . '&value=2', 'option'),
  214. 'name' => '恢复账号',
  215. );
  216. } elseif ($account['status'] == 2) {
  217. $button[0]['btn'][] = array
  218. (
  219. 'type' => 'action',
  220. 'link' => Dever::url('lib/account.setStatus?id=' . $aid . '&value=3', 'option'),
  221. 'name' => '禁用账号',
  222. );
  223. }
  224. $button[0]['btn'][] = array
  225. (
  226. 'type' => 'link',
  227. 'link' => Dever::url('project/database/list?project=option&table=agreement&search_option_aid='.$option_aid.'', 'manage'),
  228. 'name' => '期权合同',
  229. );
  230. $button[0]['btn'][] = array
  231. (
  232. 'type' => 'edit',
  233. 'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_mid='.$mid.'&search_option_aid='.$option_aid . '&type=1', 'manage'),
  234. 'name' => '期权价值交付',
  235. );
  236. $button[0]['btn'][] = array
  237. (
  238. 'type' => 'edit',
  239. 'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_mid='.$mid.'&search_option_aid='.$option_aid . '&type=2', 'manage'),
  240. 'name' => '期权价值发放',
  241. );
  242. $button[1]['btn'][] = array
  243. (
  244. 'type' => 'link',
  245. 'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&search_option_aid='.$option_aid.'', 'manage'),
  246. 'name' => '期权交付记录',
  247. );
  248. $button[1]['btn'][] = array
  249. (
  250. 'type' => 'link',
  251. 'link' => Dever::url('project/database/list?project=option&table=bill_fafang&search_option_aid='.$option_aid.'', 'manage'),
  252. 'name' => '期权发放记录',
  253. );
  254. $button[1]['btn'][] = array
  255. (
  256. 'type' => 'link',
  257. 'link' => Dever::url('project/database/list?project=option&table=bill_duifu&search_option_aid='.$option_aid.'', 'manage'),
  258. 'name' => '期权兑付记录',
  259. );
  260. if ($search_stype == -2) {
  261. $url = Dever::url('project/database/list?project=option&table=member&search_option_main=2&search_option_aid=' . $aid, 'manage');
  262. } else {
  263. $url = Dever::url('project/database/list?project=option&table=account', 'manage');
  264. if ($search_stype) {
  265. $url .= '&search_option_stype=' . $search_stype;
  266. }
  267. }
  268. $head_btn[] = array
  269. (
  270. 'type' => 'link',
  271. 'link' => $url,
  272. 'name' => '返回上一页',
  273. );
  274. $head = array
  275. (
  276. 'name' => '基本信息',
  277. 'btn' => $head_btn,
  278. );
  279. $foot = $button;
  280. $html = Dever::show($head, $result, $foot);
  281. return $html;
  282. }
  283. private function getMemberInfo($member, $member_config)
  284. {
  285. $result = array();
  286. $result = array
  287. (
  288. 'type' => 'info',
  289. 'content' => array
  290. (
  291. array
  292. (
  293. array('账户类型', $member_config['main'][$member['main']]),
  294. array('账户索引', $member['key']),
  295. ),
  296. array
  297. (
  298. array('姓名', $member['name']),
  299. array('手机号', $member['mobile']),
  300. array('身份证号', $member['idcard']),
  301. ),
  302. ),
  303. );
  304. return $result;
  305. }
  306. public function setStatus_api()
  307. {
  308. $where['where_id'] = Dever::input('id');
  309. $where['status'] = Dever::input('value');
  310. Dever::db('option/account')->update($where);
  311. return 'reload';
  312. }
  313. public function daijiaofu($id)
  314. {
  315. $where['aid'] = $id;
  316. $total = Dever::db('option/bill_jiaofu')->total($where);
  317. $html = $total . '条';
  318. $cash = Dever::db('option/cash')->getTotal(array('aid' => $id));
  319. $total = 0;
  320. if ($cash) {
  321. foreach ($cash as $k => $v) {
  322. $total += $v['daijiaofu'];
  323. }
  324. }
  325. $html .= '<br/ >' . number_format($total, 2, '.', '');
  326. return $html;
  327. }
  328. public function getCash($id)
  329. {
  330. $where['aid'] = $id;
  331. $where['status'] = 2;
  332. $total = Dever::db('option/bill_jiaofu')->total($where);
  333. $daijiaofu = $total . '条';
  334. $cash = Dever::db('option/cash')->getTotal(array('aid' => $id, 'status' => 2));
  335. $total = 0;
  336. $qiquan = '';
  337. $yuanshiqiquan = '';
  338. if ($cash) {
  339. foreach ($cash as $k => $v) {
  340. $v['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  341. $total += $v['daijiaofu'];
  342. if ($v['type'] == 1) {
  343. $qiquan .= $v['total'];
  344. $qiquan .= '<br/ >发放' . $v['fafang'];
  345. $qiquan .= '<br/ >未发' . $v['jiaofu'];
  346. $qiquan .= '<br/ >兑付' . $v['duifu'];
  347. } elseif ($v['type'] == 2) {
  348. $yuanshiqiquan .= $v['total'];
  349. $yuanshiqiquan .= '<br/ >发放' . $v['fafang'];
  350. $yuanshiqiquan .= '<br/ >未发' . $v['jiaofu'];
  351. $yuanshiqiquan .= '<br/ >兑付' . $v['duifu'];
  352. }
  353. }
  354. }
  355. $daijiaofu .= '<br/ >' . number_format($total, 2, '.', '');
  356. if (!$qiquan) {
  357. $qiquan = '无';
  358. }
  359. if (!$yuanshiqiquan) {
  360. $yuanshiqiquan = '无';
  361. }
  362. return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
  363. }
  364. }