user_cash.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. </head>
  139. <body>
  140. <?php
  141. $this->header();
  142. ?> <script src="/static/index/js/bootstrap-paginator.js"></script>
  143. <div class="user-center-wrap">
  144. <div class="container">
  145. <div class="crumbs">
  146. <a href="/index/user_profile">个人中心</a><span>/</span>账号信息
  147. </div>
  148. <div class="user-center1">
  149. <div class="row clearfix">
  150. <?php
  151. $this->user_left();
  152. ?> <div class="col-sm-10">
  153. <div class="aside-right">
  154. <div class="order">
  155. <div class="table-list-wrap">
  156. <div class="table-list">
  157. <div class="table_top">
  158. <a href="/index/user_cash">
  159. <p>佣金</p>
  160. <p class="b-num">
  161. <?php echo $this->user['promote_money'];?> </p>
  162. </a>
  163. <a href="/index/user_cash">
  164. <p>已提现佣金</p>
  165. <p class="b-num">
  166. <?php echo $this->user['promote_money_cash'];?> </p>
  167. </a>
  168. <?php
  169. if (IN_CASH && $this->user['promote_money'] > IN_CASH_MIN && isCashDate()) {
  170. ?> <a href="javascript:;" class="ms-btn ms-btn-primary mt3"
  171. id="addcode">提现</a>
  172. <?php
  173. }
  174. ?> </div>
  175. <div class="user-table">
  176. <div class="table-wrap">
  177. <div class="table-responsive">
  178. <table class="table">
  179. <tr>
  180. <th>ID</th>
  181. <th>
  182. 姓名
  183. </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. </tr>
  206. <?php
  207. foreach ($result as $key => $value) {
  208. ?> <tr>
  209. <td>
  210. <?php echo $value['id'];?> </td>
  211. <td>
  212. <?php echo $value['name'];?> </td>
  213. <td>
  214. <?php echo $value['account'];?> </td>
  215. <td>
  216. <?php echo $value['money'];?> </td>
  217. <td>
  218. <?php echo array("", "银行卡", "支付宝")[$value['type']];?> </td>
  219. <td>
  220. <?php echo $value['note'];?> </td>
  221. <td>
  222. <?php echo date("Y-m-d H:i:s", $value['create_time']);?> </td>
  223. <td class="<?php echo array('orange', 'green', 'red', 'blue')[$value['status']];?>">
  224. <?php echo array('申请中', '已受理', '已取消', '已打款')[$value['status']];?> </td>
  225. <td>
  226. <?php
  227. if ($value['status'] < 1) {
  228. ?> <a href="javascript:;"
  229. class="table-btn color-hover"
  230. data-id="<?php echo $value['id'];?>"
  231. >取消</a>
  232. <?php
  233. }
  234. ?> </td>
  235. </tr>
  236. <?php
  237. }
  238. ?> </table>
  239. <?php
  240. if ($total == 0) {
  241. ?> <div class="text-center no-content">
  242. <img src="/static/index/image/icon-21.png" alt="">
  243. <p class="color-333 mt10">
  244. 暂无订单信息
  245. </p>
  246. </div>
  247. <?php
  248. }
  249. ?> </div>
  250. <?php
  251. if ($pagenum != 1) {
  252. ?> <?php
  253. if ($total !== 0) {
  254. ?> <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
  255. if ($cpage == 1) {
  256. ?><li class='active'><a>首页</a></li><?php
  257. } else {
  258. ?><li><a href='?page=1'>首页</a></li><?php
  259. }
  260. if ($prev) {
  261. ?><li><a href='?page=<?php echo $prev;?>'>上一页</a></li><?php
  262. } else {
  263. }
  264. if ($next) {
  265. ?><li><a href='?page=<?php echo $next;?>'>下一页</a></li><?php
  266. } else {
  267. }
  268. if ($cpage == $pagenum) {
  269. ?><li class='active'><a>尾页</a></li><?php
  270. } else {
  271. ?><li><a href='?page=<?php echo $pagenum;?>'>尾页</a></li><?php
  272. }
  273. ?></ul></div> <?php
  274. }
  275. ?> <?php
  276. }
  277. ?> </div>
  278. </div>
  279. </div>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. <div class="modal fade in" id="vipkeySC" tabindex="-1" role="dialog"
  289. style="display: none; padding-right: 15px;">
  290. <div class="modal-dialog" role="document">
  291. <div class="modal-content">
  292. <div class="modal-header">
  293. <center>
  294. <h4 class="modal-title">提现</h4></center>
  295. </div>
  296. <div class="modal-body">
  297. <div class="size-list">
  298. <form id="upload" method="post" target="post_frame" enctype="multipart/form-data">
  299. <div style="padding-left:30px;">
  300. <div style="margin-top:20px;">
  301. <label style="width:100px;text-align:right;">可提现金额&nbsp;&nbsp;</label>
  302. <input type="text" name="max_num" disabled="disabled" id="max_num"
  303. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  304. value="<?php echo $this->user['promote_money'];?>">
  305. </div>
  306. </div>
  307. <div style="padding-left:30px;">
  308. <div style="margin-top:20px;">
  309. <label style="width:100px;text-align:right;">姓名&nbsp;&nbsp;</label>
  310. <input type="text"
  311. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  312. placeholder="你的真实姓名(必填)" name="name">
  313. </div>
  314. </div>
  315. <div style="padding-left:30px;">
  316. <div style="margin-top:20px;">
  317. <label style="width:100px;text-align:right;">账号&nbsp;&nbsp;</label>
  318. <input type="text"
  319. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  320. placeholder="银行卡号或支付宝账号(必填)" name="account">
  321. </div>
  322. </div>
  323. <div style="padding-left:30px;">
  324. <div style="margin-top:20px;">
  325. <label style="width:100px;text-align:right;">金额&nbsp;&nbsp;</label>
  326. <input type="number"
  327. style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
  328. placeholder="(必填)" name="money"
  329. oninput="value=value.replace(/[^\d]/g,'')"
  330. min="<?php echo IN_CASH_MIN;?>"
  331. max="<?php echo min($this->user['promote_money'], IN_CASH_MAX);?>">
  332. </div>
  333. </div>
  334. <div style="padding-left:30px;">
  335. <div style="margin-top:20px;">
  336. <label style="width:100px;text-align:right;">提现方式&nbsp;&nbsp;</label>
  337. <ul class="clearfix download-way"
  338. style="width:420px;float:right;margin-right:10px;">
  339. <?php
  340. $active = 'icon-radio-checked';
  341. $type_value = 2;
  342. if (in_array(1, $IN_CASH_TYPE)) {
  343. ?> <li class="clearfix" style="float:left;">
  344. <span class="icon icon-radio fl <?php echo $active;?>"></span>
  345. <span class="fl">银行卡</span>
  346. </li>
  347. <?php
  348. $active = '';
  349. $type_value = 1;
  350. }
  351. ?> <?php
  352. if (in_array(2, $IN_CASH_TYPE)) {
  353. ?> <li class="clearfix">
  354. <span class="icon icon-radio fl <?php echo $active;?>"
  355. style="float:left;margin-left:10px;"></span>
  356. <span class="fl">支付宝</span>
  357. </li>
  358. <?php
  359. }
  360. ?> </ul>
  361. <input type="hidden" name="type" value="<?php echo $type_value;?>" id="type"/>
  362. </div>
  363. </div>
  364. <div style="padding-left:30px;">
  365. <div style="margin-top:20px;">
  366. <label style="width:100px;text-align:right;">备注&nbsp;&nbsp;</label>
  367. <textarea name="note" maxlength="50" placeholder="可为空,50个字以内"
  368. style="width:420px;padding-left:10px;height:100px;border:1px solid #e0e0e0;"></textarea>
  369. </div>
  370. </div>
  371. </form>
  372. </div>
  373. <br><br>
  374. <div class="form-group" style="margin-top:10px;">
  375. <div class="tipPanel"
  376. style="margin: 10px;padding: 10px;font-size: 14px;border: 1px dotted gray;border-radius: 8px;">
  377. <div class="tipItem" id="codeInfo">
  378. <table style="width:100%">
  379. <tr>
  380. <td>
  381. <font color="red">每笔最低提现金额</font>:<?php echo IN_CASH_MIN;?>元
  382. </td>
  383. <td>
  384. <font color="red">每笔最高提现金额</font>:<?php echo IN_CASH_MAX;?>元
  385. </td>
  386. </tr>
  387. <tr>
  388. <td>
  389. <font color="red">每天最多提现次数</font>:<?php echo $this->toady_count;?>/<?php echo IN_CASH_DAY;?> 次
  390. </td>
  391. <td>
  392. <font color="red">每月最多提现次数</font>:<?php echo $this->month_count;?>/<?php echo IN_CASH_MONTH;?> 次
  393. </td>
  394. </tr>
  395. <tr>
  396. <td>
  397. <font color="red">每天提现额度</font>:<?php echo $this->toady_money;?>/<?php echo IN_CASH_DAY_MAX;?> 元
  398. </td>
  399. <td>
  400. <font color="red">每月提现额度</font>:<?php echo $this->month_money;?>/<?php echo IN_CASH_MONTH_MAX;?> 元
  401. </td>
  402. </tr>
  403. <tr>
  404. <td>
  405. <font color="red">每月可提现日期</font>:<?php echo IN_CASH_DATE ? str_replace('|', '或', IN_CASH_DATE) . '日' : '每天';?> </td>
  406. <td>
  407. <font color="red">每月提现结算日期</font>:<?php echo IN_CASH_CALC_DATE ? str_replace('|', '或', IN_CASH_CALC_DATE) . '日' : '每天';?> </td>
  408. </tr>
  409. </table>
  410. </div>
  411. </div>
  412. </div>
  413. <div style="text-align:right;margin-top:30px;">
  414. <div style="border-top:1px solid #eee;">
  415. <div class="text-right mt30">
  416. <input type="hidden" id="in_tid" value="0">
  417. <button type="button" class="btn btn-default" data-dismiss="modal"
  418. aria-label="Close"
  419. onclick="$('#vipkeySC').toggle();">取消
  420. </button>
  421. <button type="button" class="btn btn-primary" onclick="produce()">提交</button>
  422. </div>
  423. </div>
  424. </div>
  425. </div>
  426. </div>
  427. </div>
  428. </div>
  429. <?php
  430. $this->footer();
  431. ?> <script>
  432. $('#addcode,.btn-new-release').click(function () {
  433. $('#vipkeySC').toggle();
  434. });
  435. $('.download-way li').click(function () {
  436. $(this).addClass('active').siblings().removeClass('active');
  437. $('.download-way li span').removeClass('icon-radio-checked');
  438. $(this).find('.icon-radio').addClass('icon-radio-checked');
  439. $('#type').val($(this).index() + 1);
  440. });
  441. function produce() {
  442. var name = $('input[name=name]').val();
  443. var account = $('input[name=account]').val();
  444. var money = $('input[name=money]').val();
  445. var type = $('input[name=type]').val();
  446. var note = $('textarea[name=note]').val();
  447. $.post('/index/user_cash/cash_new', {name, account, money, type, note}, function (ret) {
  448. if (ret.msg) alert(ret.msg);
  449. if (ret.data) {
  450. location.reload();
  451. }
  452. }, 'json');
  453. }
  454. $('table a.table-btn').click(function () {
  455. var id = $(this).attr('data-id');
  456. $.post('/index/user_cash/cancle', {id}, function (ret) {
  457. if (ret.msg) alert(ret.msg);
  458. if (ret.data) {
  459. location.reload();
  460. }
  461. }, 'json');
  462. });
  463. </script>
  464. </body>
  465. </html>
  466. <?php
  467. }
  468. }