Account.php 11 KB

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