Account.php 12 KB

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