Account.php 9.9 KB

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