user_cash.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\index;
  4. class user_cash extends BaseUser
  5. {
  6. function initialize()
  7. {
  8. parent::initialize();
  9. $this->userId = $this->userid;
  10. $this->toady_count = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'today')->count();
  11. $this->toady_money = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'today')->sum('money');
  12. $this->month_count = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'month')->count();
  13. $this->month_money = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'month')->sum('money');
  14. }
  15. function cash_new()
  16. {
  17. $name = SafeRequest("name", "post");
  18. if (!$name) {
  19. reJSON('请输入你的真实姓名');
  20. }
  21. $account = SafeRequest("account", "post");
  22. if (!$account) {
  23. reJSON('请输入你的提现账号');
  24. }
  25. $money = SafeRequest("money", "post");
  26. if (!is_numeric($money)) {
  27. reJSON('请输入你的提现金额');
  28. }
  29. $type = SafeRequest("type", "post");
  30. $user = db('user')->where('in_userid', $this->userid)->find();
  31. if ($money < IN_CASH_MIN) {
  32. reJSON('单笔提现至少要' . IN_CASH_MIN . '元');
  33. }
  34. if ($money > $user['promote_money']) {
  35. reJSON('你没有那么多的佣金');
  36. }
  37. if ($money > IN_CASH_MAX) {
  38. reJSON('单笔提现不能大于' . IN_CASH_MAX . '元');
  39. }
  40. if (IN_CASH_DAY > 0) {
  41. if ($this->toady_count >= IN_CASH_DAY) {
  42. reJSON('你今天提现次数已达' . IN_CASH_DAY . '次上限');
  43. }
  44. }
  45. if (IN_CASH_DAY_MAX > 0) {
  46. if ($this->toady_money >= IN_CASH_DAY_MAX) {
  47. reJSON('你今天提现额度已达' . IN_CASH_DAY_MAX . '元上限');
  48. }
  49. if ($this->toady_money + $money > IN_CASH_DAY_MAX) {
  50. reJSON('你今天提现额度仅剩' . (IN_CASH_DAY_MAX - $this->toady_money) . '元');
  51. }
  52. }
  53. if (IN_CASH_MONTH > 0) {
  54. if ($this->month_count >= IN_CASH_MONTH) {
  55. reJSON('你本月提现次数已达' . IN_CASH_MONTH . '次上限');
  56. }
  57. }
  58. if (IN_CASH_MONTH_MAX > 0) {
  59. if ($this->month_money >= IN_CASH_MONTH_MAX) {
  60. reJSON('你本月提现额度已达' . IN_CASH_MONTH_MAX . '元上限');
  61. }
  62. if ($this->month_money + $money > IN_CASH_MONTH_MAX) {
  63. reJSON('你本月提现额度仅剩' . (IN_CASH_MONTH_MAX - $money) . '元');
  64. }
  65. }
  66. $data = array('user_id' => $user['in_userid'], 'account' => $account, 'name' => $name, 'money' => $money, 'type' => $type ?: 1, 'create_time' => time());
  67. $note = SafeRequest("note", "post");
  68. $note && ($data['note'] = $note);
  69. $res = db('user_cash')->insert($data);
  70. $res = $res && aclog_save($user['in_userid'], $user['promote_money'] - $money, $user['promote_money'], 'promote_money', '佣金提现');
  71. $res = $res && db('user')->where('in_userid', $this->userid)->dec('promote_money', $money)->update();
  72. reJSON($res, $res, $res ? '提现申请已受理,请耐心等待处理结果' : '提现申请受理不成功,请稍后重试');
  73. }
  74. function cancle()
  75. {
  76. $id = SafeRequest("id", "post");
  77. $user = db('user')->where('in_userid', $this->userid)->find();
  78. $clog = db('user_cash')->where('id', $id)->where('status', '<', '1')->find();
  79. if (!$clog || !$user) {
  80. reJSON('提现记录存在错误');
  81. }
  82. $res = aclog_save($user['in_userid'], $user['promote_money'] + $clog['money'], $user['promote_money'], 'promote_money', '取消提现返还');
  83. $res = $res && db('user')->where('in_userid', $this->userid)->inc('promote_money', $clog['money'])->update();
  84. $res = $res && db('user_cash')->where('id', $id)->update(array('status' => 2));
  85. reJSON($res, $res, $res ? '取消提现成功' : '取消提现不成功,请稍后重试');
  86. }
  87. function index()
  88. {
  89. $map = array();
  90. $total = db('user_cash')->where($map)->where('user_id', $this->userid)->count();
  91. $num = 10;
  92. $cpage = isset($_GET['page']) ? $_GET['page'] : 1;
  93. $pagenum = ceil($total / $num);
  94. $offset = ($cpage - 1) * $num;
  95. $result = db('user_cash')->where($map)->where('user_id', $this->userid)->order('id desc')->limit($offset, $num)->select();
  96. $start = $offset + 1;
  97. $end = $cpage == $pagenum ? $total : $cpage * $num;
  98. $next = $cpage == $pagenum ? 0 : $cpage + 1;
  99. $prev = $cpage == 1 ? 0 : $cpage - 1;
  100. $IN_CASH_TYPE = json_decode(IN_CASH_TYPE, true);
  101. ?> <!DOCTYPE html>
  102. <html lang="">
  103. <head>
  104. <meta charset="utf-8">
  105. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/>
  106. <meta name="keywords" content="<?php echo IN_KEYWORDS;?>"/>
  107. <meta name="description" content="<?php echo IN_DESCRIPTION;?>"/>
  108. <title>我的订单 - <?php echo IN_NAME;?> - 免费应用内测托管平台|iOS应用Beta测试分发|Android应用内测分发</title>
  109. <?php
  110. $this->static_();
  111. ?> <style>
  112. .table_top a {
  113. display: block;
  114. float: left;
  115. padding: 10px 20px;
  116. }
  117. .table_top a p.b-num {
  118. color: #fba208;
  119. font-size: 30px;
  120. }
  121. .table_top a p:first-child {
  122. font-size: 15px;
  123. font-weight: bolder;
  124. }
  125. .red {
  126. color: red !important;
  127. }
  128. .green {
  129. color: green !important;
  130. }
  131. .blue {
  132. color: blue !important;
  133. }
  134. .orange {
  135. color: orange !important;
  136. }
  137. </style>
  138. <link rel="stylesheet" href="/css/jcq.css">
  139. </head>
  140. <body>
  141. <?php
  142. $this->header();
  143. ?> <script src="/static/index/js/bootstrap-paginator.js"></script>
  144. <div class="user-center-wrap">
  145. <div class="container">
  146. <div class="crumbs">
  147. <a href="/index/user_profile">个人中心</a><span>/</span>账号信息
  148. </div>
  149. <div class="user-center1">
  150. <div class="row clearfix">
  151. <?php
  152. $this->user_left();
  153. ?> <div class="col-sm-10">
  154. <div class="aside-right">
  155. <div class="order">
  156. <div class="table-list-wrap" style="background-color: transparent; box-shadow:none; padding:0;">
  157. <div class="table-list">
  158. <div class="table_top j-top clearfix">
  159. <a href="/index/user_cash">
  160. <p>佣金</p>
  161. <p class="b-num">
  162. <?php echo $this->user['promote_money'];?> </p>
  163. </a>
  164. <a href="/index/user_cash">
  165. <p>已提现佣金</p>
  166. <p class="b-num">
  167. <?php echo $this->user['promote_money_cash'];?> </p>
  168. </a>
  169. <?php
  170. if (IN_CASH && $this->user['promote_money'] > IN_CASH_MIN && isCashDate()) {
  171. ?>
  172. <a href="javascript:;" class="ms-btn ms-btn-primary mt3 tx-j" style="margin-left: 25px;"
  173. id="addcode">提现</a>
  174. <?php
  175. }
  176. ?>
  177. </div>
  178. <div class="user-table table-list-body">
  179. <div class="table-wrap">
  180. <div class="table-responsive">
  181. <table class="table">
  182. <tr>
  183. <th>ID</th>
  184. <th>
  185. 姓名
  186. </th>
  187. <th>
  188. 账号
  189. </th>
  190. <th>
  191. 提现金额
  192. </th>
  193. <th>
  194. 提现方式
  195. </th>
  196. <th>
  197. 备注
  198. </th>
  199. <th>
  200. 提现时间
  201. </th>
  202. <th>
  203. 状态
  204. </th>
  205. <th>
  206. 操作
  207. </th>
  208. </tr>
  209. <?php
  210. foreach ($result as $key => $value) {
  211. ?> <tr>
  212. <td>
  213. <?php echo $value['id'];?> </td>
  214. <td>
  215. <?php echo $value['name'];?> </td>
  216. <td>
  217. <?php echo $value['account'];?> </td>
  218. <td>
  219. <?php echo $value['money'];?> </td>
  220. <td>
  221. <?php echo array("", "银行卡", "支付宝")[$value['type']];?> </td>
  222. <td>
  223. <?php echo $value['note'];?> </td>
  224. <td>
  225. <?php echo date("Y-m-d H:i:s", $value['create_time']);?> </td>
  226. <td class="<?php echo array('orange', 'green', 'red', 'blue')[$value['status']];?>">
  227. <?php echo array('申请中', '已受理', '已取消', '已打款')[$value['status']];?> </td>
  228. <td>
  229. <?php
  230. if ($value['status'] < 1) {
  231. ?> <a href="javascript:;"
  232. class="table-btn color-hover"
  233. data-id="<?php echo $value['id'];?>"
  234. >取消</a>
  235. <?php
  236. }
  237. ?> </td>
  238. </tr>
  239. <?php
  240. }
  241. ?> </table>
  242. <?php
  243. if ($total == 0) {
  244. ?> <div class="text-center no-content">
  245. <img src="/static/index/image/icon-21.png" alt="">
  246. <p class="color-333 mt10">
  247. 暂无订单信息
  248. </p>
  249. </div>
  250. <?php
  251. }
  252. ?> </div>
  253. <?php
  254. if ($pagenum != 1) {
  255. ?> <?php
  256. if ($total !== 0) {
  257. ?> <div style="text-align: center"><ul id="pager" class="pagination"><li><a>共<b><?php echo $total;?></b>条记录</b> <?php echo $cpage;?>/<?php echo $pagenum;?></a></li><?php
  258. if ($cpage == 1) {
  259. ?><li class='active'><a>首页</a></li><?php
  260. } else {
  261. ?><li><a href='?page=1'>首页</a></li><?php
  262. }
  263. if ($prev) {
  264. ?><li><a href='?page=<?php echo $prev;?>'>上一页</a></li><?php
  265. } else {
  266. }
  267. if ($next) {
  268. ?><li><a href='?page=<?php echo $next;?>'>下一页</a></li><?php
  269. } else {
  270. }
  271. if ($cpage == $pagenum) {
  272. ?><li class='active'><a>尾页</a></li><?php
  273. } else {
  274. ?><li><a href='?page=<?php echo $pagenum;?>'>尾页</a></li><?php
  275. }
  276. ?></ul></div> <?php
  277. }
  278. ?> <?php
  279. }
  280. ?> </div>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. </div>
  291. <div class="modal fade in" id="vipkeySC" tabindex="-1" role="dialog"
  292. style="display: none; padding-right: 15px;">
  293. <div class="modal-dialog" role="document">
  294. <div class="modal-content">
  295. <div class="modal-header">
  296. <center>
  297. <h4 class="modal-title">提现</h4></center>
  298. </div>
  299. <div class="modal-body">
  300. <div class="size-list">
  301. <form id="upload" method="post" target="post_frame" enctype="multipart/form-data">
  302. <div style="padding-left:30px;">
  303. <div style="margin-top:20px;">
  304. <label class="j-label-open" style="width:100px;text-align:right;">可提现金额&nbsp;&nbsp;</label>
  305. <input class="j-label-text" type="text" name="max_num" disabled="disabled" id="max_num"
  306. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  307. value="<?php echo $this->user['promote_money'];?>">
  308. </div>
  309. </div>
  310. <div style="padding-left:30px;">
  311. <div style="margin-top:20px;">
  312. <label class="j-label-open" style="width:100px;text-align:right;">姓名&nbsp;&nbsp;</label>
  313. <input class="j-label-text" type="text"
  314. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  315. placeholder="你的真实姓名(必填)" name="name">
  316. </div>
  317. </div>
  318. <div style="padding-left:30px;">
  319. <div style="margin-top:20px;">
  320. <label class="j-label-open" style="width:100px;text-align:right;">账号&nbsp;&nbsp;</label>
  321. <input class="j-label-text" type="text"
  322. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  323. placeholder="银行卡号或支付宝账号(必填)" name="account">
  324. </div>
  325. </div>
  326. <div style="padding-left:30px;">
  327. <div style="margin-top:20px;">
  328. <label class="j-label-open" style="width:100px;text-align:right;">金额&nbsp;&nbsp;</label>
  329. <input class="j-label-text-je" type="number"
  330. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  331. placeholder="(必填)" name="money"
  332. oninput="value=value.replace(/[^\d]/g,'')"
  333. min="<?php echo IN_CASH_MIN;?>"
  334. max="<?php echo min($this->user['promote_money'], IN_CASH_MAX);?>">
  335. </div>
  336. </div>
  337. <div style="padding-left:30px;">
  338. <div style="margin-top:20px;">
  339. <label class="j-label-open" style="width:100px;text-align:right;">提现方式&nbsp;&nbsp;</label>
  340. <ul class="clearfix download-way j-label-text-je"
  341. style="width:420px;float:right;margin-right:10px;">
  342. <?php
  343. $active = 'icon-radio-checked';
  344. $type_value = 2;
  345. if (in_array(1, $IN_CASH_TYPE)) {
  346. ?> <li class="clearfix" style="float:left;">
  347. <span class="icon icon-radio fl <?php echo $active;?>"></span>
  348. <span class="fl">银行卡</span>
  349. </li>
  350. <?php
  351. $active = '';
  352. $type_value = 1;
  353. }
  354. ?> <?php
  355. if (in_array(2, $IN_CASH_TYPE)) {
  356. ?> <li class="clearfix">
  357. <span class="icon icon-radio fl <?php echo $active;?>"
  358. style="float:left;margin-left:10px;"></span>
  359. <span class="fl">支付宝</span>
  360. </li>
  361. <?php
  362. }
  363. ?> </ul>
  364. <input type="hidden" name="type" value="<?php echo $type_value;?>" id="type"/>
  365. </div>
  366. </div>
  367. <div style="padding-left:30px;">
  368. <div style="margin-top:20px;">
  369. <label class="j-label-open" style="width:100px;text-align:right;">备注&nbsp;&nbsp;</label>
  370. <textarea name="note" maxlength="50" placeholder="可为空,50个字以内"
  371. class="j-label-text" style="width:420px;padding-left:10px;height:100px;border:1px solid #e0e0e0;"></textarea>
  372. </div>
  373. </div>
  374. </form>
  375. <div class="form-group" style="margin-top:10px;">
  376. <div class="tipPanel"
  377. style="margin: 10px;padding: 10px;font-size: 14px;border: 1px dotted gray;border-radius: 8px;">
  378. <div class="tipItem" id="codeInfo">
  379. <table style="width:100%">
  380. <tr>
  381. <td>
  382. <font color="red">每笔最低提现金额</font>:<?php echo IN_CASH_MIN;?>元
  383. </td>
  384. <td>
  385. <font color="red">每笔最高提现金额</font>:<?php echo IN_CASH_MAX;?>元
  386. </td>
  387. </tr>
  388. <tr>
  389. <td>
  390. <font color="red">每天最多提现次数</font>:<?php echo $this->toady_count;?>/<?php echo IN_CASH_DAY;?> 次
  391. </td>
  392. <td>
  393. <font color="red">每月最多提现次数</font>:<?php echo $this->month_count;?>/<?php echo IN_CASH_MONTH;?> 次
  394. </td>
  395. </tr>
  396. <tr>
  397. <td>
  398. <font color="red">每天提现额度</font>:<?php echo $this->toady_money;?>/<?php echo IN_CASH_DAY_MAX;?> 元
  399. </td>
  400. <td>
  401. <font color="red">每月提现额度</font>:<?php echo $this->month_money;?>/<?php echo IN_CASH_MONTH_MAX;?> 元
  402. </td>
  403. </tr>
  404. <tr>
  405. <td>
  406. <font color="red">每月可提现日期</font>:<?php echo IN_CASH_DATE ? str_replace('|', '或', IN_CASH_DATE) . '日' : '每天';?> </td>
  407. <td>
  408. <font color="red">每月提现结算日期</font>:<?php echo IN_CASH_CALC_DATE ? str_replace('|', '或', IN_CASH_CALC_DATE) . '日' : '每天';?> </td>
  409. </tr>
  410. </table>
  411. </div>
  412. </div>
  413. </div>
  414. </div>
  415. <div style="text-align:right;margin-top:30px;">
  416. <div style="border-top:1px solid #eee;">
  417. <div class="text-right mt30">
  418. <input type="hidden" id="in_tid" value="0">
  419. <button type="button" class="btn btn-default" data-dismiss="modal"
  420. aria-label="Close"
  421. onclick="$('#vipkeySC').toggle();">取消
  422. </button>
  423. <button type="button" class="btn btn-primary" style="background: #2168fb; border-color: #2168fb;" onclick="produce()">提交</button>
  424. </div>
  425. </div>
  426. </div>
  427. </div>
  428. </div>
  429. </div>
  430. </div>
  431. <?php
  432. $this->footer();
  433. ?> <script>
  434. $('#addcode,.btn-new-release').click(function () {
  435. $('#vipkeySC').toggle();
  436. });
  437. $('.download-way li').click(function () {
  438. $(this).addClass('active').siblings().removeClass('active');
  439. $('.download-way li span').removeClass('icon-radio-checked');
  440. $(this).find('.icon-radio').addClass('icon-radio-checked');
  441. $('#type').val($(this).index() + 1);
  442. });
  443. function produce() {
  444. var name = $('input[name=name]').val();
  445. var account = $('input[name=account]').val();
  446. var money = $('input[name=money]').val();
  447. var type = $('input[name=type]').val();
  448. var note = $('textarea[name=note]').val();
  449. $.post('/index/user_cash/cash_new', {name, account, money, type, note}, function (ret) {
  450. if (ret.msg) alert(ret.msg);
  451. if (ret.data) {
  452. location.reload();
  453. }
  454. }, 'json');
  455. }
  456. $('table a.table-btn').click(function () {
  457. var id = $(this).attr('data-id');
  458. $.post('/index/user_cash/cancle', {id}, function (ret) {
  459. if (ret.msg) alert(ret.msg);
  460. if (ret.data) {
  461. location.reload();
  462. }
  463. }, 'json');
  464. });
  465. </script>
  466. </body>
  467. </html>
  468. <?php
  469. }
  470. }