Account.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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='.$account['mid'].'&status=1&col=name,idcard', 'manage'),
  174. 'name' => '修改资料',
  175. );
  176. $url = '';
  177. if ($account['audit'] == 2) {
  178. $button[0]['btn'][] = array
  179. (
  180. 'type' => 'edit',
  181. 'link' => Dever::url('project/database/update?project=option&table=account&where_id='.$account['id'].'&status=1&col=audit,audit_desc', 'manage'),
  182. 'name' => '审核',
  183. );
  184. }
  185. if ($account['status'] == 3) {
  186. $button[0]['btn'][] = array
  187. (
  188. 'type' => 'action',
  189. 'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=2', 'option'),
  190. 'name' => '恢复账号',
  191. );
  192. } elseif ($account['status'] == 2) {
  193. $button[0]['btn'][] = array
  194. (
  195. 'type' => 'action',
  196. 'link' => Dever::url('lib/account.setStatus?id=' . $account['id'] . '&value=3', 'option'),
  197. 'name' => '禁用账号',
  198. );
  199. }
  200. $button[0]['btn'][] = array
  201. (
  202. 'type' => 'link',
  203. 'link' => Dever::url('project/database/list?project=option&table=agreement&search_option_aid='.$option_aid.'', 'manage'),
  204. 'name' => '期权合同',
  205. );
  206. $button[0]['btn'][] = array
  207. (
  208. 'type' => 'edit',
  209. 'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_mid='.$mid.'&search_option_aid='.$option_aid, 'manage'),
  210. 'name' => '期权价值交付与发放',
  211. );
  212. $button[1]['btn'][] = array
  213. (
  214. 'type' => 'link',
  215. 'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&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_fafang&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_duifu&search_option_aid='.$option_aid.'', 'manage'),
  228. 'name' => '期权兑付记录',
  229. );
  230. if ($search_audit == -1) {
  231. $url = Dever::url('project/database/list?project=option&table=member&search_option_main=2&search_option_aid=' . $aid, 'manage');
  232. } else {
  233. $url = Dever::url('project/database/list?project=option&table=account', 'manage');
  234. if ($search_audit) {
  235. $url .= '&search_option_audit=' . $search_audit;
  236. }
  237. }
  238. $head_btn[] = array
  239. (
  240. 'type' => 'link',
  241. 'link' => $url,
  242. 'name' => '返回上一页',
  243. );
  244. $head = array
  245. (
  246. 'name' => '基本信息',
  247. 'btn' => $head_btn,
  248. );
  249. $foot = $button;
  250. $html = Dever::show($head, $result, $foot);
  251. return $html;
  252. }
  253. private function getMemberInfo($member, $member_config)
  254. {
  255. $result = array();
  256. $result = array
  257. (
  258. 'type' => 'info',
  259. 'content' => array
  260. (
  261. array
  262. (
  263. array('账户类型', $member_config['main'][$member['main']]),
  264. array('账户索引', $member['key']),
  265. ),
  266. array
  267. (
  268. array('姓名', $member['name']),
  269. array('手机号', $member['mobile']),
  270. array('身份证号', $member['idcard']),
  271. ),
  272. ),
  273. );
  274. return $result;
  275. }
  276. public function setStatus_api()
  277. {
  278. $where['where_id'] = Dever::input('id');
  279. $where['status'] = Dever::input('value');
  280. Dever::db('option/account')->update($where);
  281. return 'reload';
  282. }
  283. public function daijiaofu($id)
  284. {
  285. $where['aid'] = $id;
  286. $total = Dever::db('option/bill_jiaofu')->total($where);
  287. $html = $total . '条';
  288. $cash = Dever::db('option/cash')->getTotal(array('aid' => $id));
  289. $total = 0;
  290. if ($cash) {
  291. foreach ($cash as $k => $v) {
  292. $total += $v['daijiaofu'];
  293. }
  294. }
  295. $html .= '<br/ >' . number_format($total, 2, '.', '');
  296. return $html;
  297. }
  298. public function getCash($id)
  299. {
  300. $where['aid'] = $id;
  301. $where['status'] = 2;
  302. $total = Dever::db('option/bill_jiaofu')->total($where);
  303. $daijiaofu = $total . '条';
  304. $cash = Dever::db('option/cash')->getTotal(array('aid' => $id, 'status' => 2));
  305. $total = 0;
  306. $qiquan = '';
  307. $yuanshiqiquan = '';
  308. if ($cash) {
  309. foreach ($cash as $k => $v) {
  310. $v['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  311. $total += $v['daijiaofu'];
  312. if ($v['type'] == 1) {
  313. $qiquan .= $v['total'];
  314. $qiquan .= '<br/ >发放' . $v['fafang'];
  315. $qiquan .= '<br/ >未发' . $v['jiaofu'];
  316. $qiquan .= '<br/ >兑付' . $v['duifu'];
  317. } elseif ($v['type'] == 2) {
  318. $yuanshiqiquan .= $v['total'];
  319. $yuanshiqiquan .= '<br/ >发放' . $v['fafang'];
  320. $yuanshiqiquan .= '<br/ >未发' . $v['jiaofu'];
  321. $yuanshiqiquan .= '<br/ >兑付' . $v['duifu'];
  322. }
  323. }
  324. }
  325. $daijiaofu .= '<br/ >' . number_format($total, 2, '.', '');
  326. if (!$qiquan) {
  327. $qiquan = '无';
  328. }
  329. if (!$yuanshiqiquan) {
  330. $yuanshiqiquan = '无';
  331. }
  332. return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
  333. }
  334. }