Account.php 13 KB

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