Account.php 12 KB

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