Account.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. $search_type = Dever::input('search_type');
  147. $option_aid = $aid;
  148. if ($search_type) {
  149. $option_aid .= '&search_type=' . $search_type;
  150. }
  151. $button[0]['btn'][] = array
  152. (
  153. 'type' => 'edit',
  154. 'link' => Dever::url('project/database/update?project=option&table=push_cash&search_option_aid='.$option_aid, 'manage'),
  155. 'name' => '发放期权',
  156. );
  157. $button[1]['btn'][] = array
  158. (
  159. 'type' => 'link',
  160. 'link' => Dever::url('project/database/list?project=option&table=bill_jiaofu&search_option_aid='.$option_aid.'', 'manage'),
  161. 'name' => '期权交付记录',
  162. );
  163. $button[1]['btn'][] = array
  164. (
  165. 'type' => 'link',
  166. 'link' => Dever::url('project/database/list?project=option&table=bill_fafang&search_option_aid='.$option_aid.'', 'manage'),
  167. 'name' => '期权发放记录',
  168. );
  169. $button[1]['btn'][] = array
  170. (
  171. 'type' => 'link',
  172. 'link' => Dever::url('project/database/list?project=option&table=bill_duifu&search_option_aid='.$option_aid.'', 'manage'),
  173. 'name' => '期权兑付记录',
  174. );
  175. $button[1]['btn'][] = array
  176. (
  177. 'type' => 'link',
  178. 'link' => Dever::url('project/database/list?project=option&table=agreement&search_option_aid='.$option_aid.'', 'manage'),
  179. 'name' => '期权合同',
  180. );
  181. }
  182. $url = Dever::url('project/database/list?project=option&table=account', 'manage');
  183. if ($search_type) {
  184. $url .= '&search_option_type=' . $search_type;
  185. }
  186. $head_btn[] = array
  187. (
  188. 'type' => 'link',
  189. 'link' => $url,
  190. 'name' => '返回上一页',
  191. );
  192. $head = array
  193. (
  194. 'name' => '基本信息',
  195. 'btn' => $head_btn,
  196. );
  197. $foot = $button;
  198. $html = Dever::show($head, $result, $foot);
  199. return $html;
  200. }
  201. private function getShowInfo($account, $config)
  202. {
  203. $result = array();
  204. $idcard_pic = '';
  205. if ($account['idcard_front']) {
  206. $idcard_pic = '<a href="'.$account['idcard_front'].'" target="_blank"><img src="'.$account['idcard_front'].'" width="150" /></a>';
  207. }
  208. if ($account['idcard_back']) {
  209. $idcard_pic .= '&nbsp;&nbsp;<a href="'.$account['idcard_back'].'" target="_blank"><img src="'.$account['idcard_back'].'" width="150" /></a>';
  210. }
  211. if ($account['email']) {
  212. $account['email'] .= '('.$config['is_email'][$account['is_email']].')';
  213. }
  214. $result = array
  215. (
  216. 'type' => 'info',
  217. 'content' => array
  218. (
  219. array
  220. (
  221. array('姓名', $account['name']),
  222. array('手机号', $account['mobile']),
  223. array('邮箱', $account['email']),
  224. ),
  225. array
  226. (
  227. array('账户类型', $config['type'][$account['type']]),
  228. array('审核状态', $config['audit'][$account['audit']]),
  229. array('账户状态', $config['status'][$account['status']]),
  230. ),
  231. ),
  232. );
  233. $result['content'][] = array
  234. (
  235. array('身份证号', $account['idcard']),
  236. array('身份证照片', $idcard_pic),
  237. );
  238. return $result;
  239. }
  240. public function setStatus_api()
  241. {
  242. $where['where_id'] = Dever::input('id');
  243. $where['status'] = Dever::input('value');
  244. Dever::db('option/account')->update($where);
  245. return 'reload';
  246. }
  247. public function daijiaofu($id)
  248. {
  249. $where['aid'] = $id;
  250. $total = Dever::db('option/bill_jiaofu')->total($where);
  251. $html = $total . '条';
  252. $cash = Dever::db('option/cash')->select(array('aid' => $id));
  253. $total = 0;
  254. if ($cash) {
  255. foreach ($cash as $k => $v) {
  256. $total += $v['daijiaofu'];
  257. }
  258. }
  259. $html .= '<br/ >' . number_format($total, 2, '.', '');
  260. return $html;
  261. }
  262. public function getCash($id)
  263. {
  264. $where['aid'] = $id;
  265. $total = Dever::db('option/bill_jiaofu')->total($where);
  266. $daijiaofu = $total . '条';
  267. $cash = Dever::db('option/cash')->select(array('aid' => $id, 'status' => 2));
  268. $total = 0;
  269. $qiquan = '';
  270. $yuanshiqiquan = '';
  271. if ($cash) {
  272. foreach ($cash as $k => $v) {
  273. $v['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
  274. $total += $v['daijiaofu'];
  275. if ($v['type'] == 1) {
  276. $qiquan .= $v['total'];
  277. $qiquan .= '<br/ >发放' . $v['fafang'];
  278. $qiquan .= '<br/ >未发' . $v['jiaofu'];
  279. $qiquan .= '<br/ >兑付' . $v['duifu'];
  280. } elseif ($v['type'] == 2) {
  281. $yuanshiqiquan .= $v['total'];
  282. $yuanshiqiquan .= '<br/ >发放' . $v['fafang'];
  283. $yuanshiqiquan .= '<br/ >未发' . $v['jiaofu'];
  284. $yuanshiqiquan .= '<br/ >兑付' . $v['duifu'];
  285. }
  286. }
  287. }
  288. $daijiaofu .= '<br/ >' . number_format($total, 2, '.', '');
  289. return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
  290. }
  291. }