123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- namespace app\index;
- class user_cash extends BaseUser
- {
- function initialize()
- {
- parent::initialize();
- $this->userId = $this->userid;
- $this->toady_count = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'today')->count();
- $this->toady_money = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'today')->sum('money');
- $this->month_count = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'month')->count();
- $this->month_money = db('user_cash')->where('status', '<>', '2')->where('user_id', $this->userId)->whereTime('create_time', 'month')->sum('money');
- }
- function cash_new()
- {
- $name = SafeRequest("name", "post");
- if (!$name) {
- reJSON('请输入你的真实姓名');
- }
- $account = SafeRequest("account", "post");
- if (!$account) {
- reJSON('请输入你的提现账号');
- }
- $money = SafeRequest("money", "post");
- if (!is_numeric($money)) {
- reJSON('请输入你的提现金额');
- }
- $type = SafeRequest("type", "post");
- $user = db('user')->where('in_userid', $this->userid)->find();
- if ($money < IN_CASH_MIN) {
- reJSON('单笔提现至少要' . IN_CASH_MIN . '元');
- }
- if ($money > $user['promote_money']) {
- reJSON('你没有那么多的佣金');
- }
- if ($money > IN_CASH_MAX) {
- reJSON('单笔提现不能大于' . IN_CASH_MAX . '元');
- }
- if (IN_CASH_DAY > 0) {
- if ($this->toady_count >= IN_CASH_DAY) {
- reJSON('你今天提现次数已达' . IN_CASH_DAY . '次上限');
- }
- }
- if (IN_CASH_DAY_MAX > 0) {
- if ($this->toady_money >= IN_CASH_DAY_MAX) {
- reJSON('你今天提现额度已达' . IN_CASH_DAY_MAX . '元上限');
- }
- if ($this->toady_money + $money > IN_CASH_DAY_MAX) {
- reJSON('你今天提现额度仅剩' . (IN_CASH_DAY_MAX - $this->toady_money) . '元');
- }
- }
- if (IN_CASH_MONTH > 0) {
- if ($this->month_count >= IN_CASH_MONTH) {
- reJSON('你本月提现次数已达' . IN_CASH_MONTH . '次上限');
- }
- }
- if (IN_CASH_MONTH_MAX > 0) {
- if ($this->month_money >= IN_CASH_MONTH_MAX) {
- reJSON('你本月提现额度已达' . IN_CASH_MONTH_MAX . '元上限');
- }
- if ($this->month_money + $money > IN_CASH_MONTH_MAX) {
- reJSON('你本月提现额度仅剩' . (IN_CASH_MONTH_MAX - $money) . '元');
- }
- }
- $data = array('user_id' => $user['in_userid'], 'account' => $account, 'name' => $name, 'money' => $money, 'type' => $type ?: 1, 'create_time' => time());
- $note = SafeRequest("note", "post");
- $note && ($data['note'] = $note);
- $res = db('user_cash')->insert($data);
- $res = $res && aclog_save($user['in_userid'], $user['promote_money'] - $money, $user['promote_money'], 'promote_money', '佣金提现');
- $res = $res && db('user')->where('in_userid', $this->userid)->dec('promote_money', $money)->update();
- reJSON($res, $res, $res ? '提现申请已受理,请耐心等待处理结果' : '提现申请受理不成功,请稍后重试');
- }
- function cancle()
- {
- $id = SafeRequest("id", "post");
- $user = db('user')->where('in_userid', $this->userid)->find();
- $clog = db('user_cash')->where('id', $id)->where('status', '<', '1')->find();
- if (!$clog || !$user) {
- reJSON('提现记录存在错误');
- }
- $res = aclog_save($user['in_userid'], $user['promote_money'] + $clog['money'], $user['promote_money'], 'promote_money', '取消提现返还');
- $res = $res && db('user')->where('in_userid', $this->userid)->inc('promote_money', $clog['money'])->update();
- $res = $res && db('user_cash')->where('id', $id)->update(array('status' => 2));
- reJSON($res, $res, $res ? '取消提现成功' : '取消提现不成功,请稍后重试');
- }
- function index()
- {
- $map = array();
- $total = db('user_cash')->where($map)->where('user_id', $this->userid)->count();
- $num = 10;
- $cpage = isset($_GET['page']) ? $_GET['page'] : 1;
- $pagenum = ceil($total / $num);
- $offset = ($cpage - 1) * $num;
- $result = db('user_cash')->where($map)->where('user_id', $this->userid)->order('id desc')->limit($offset, $num)->select();
- $start = $offset + 1;
- $end = $cpage == $pagenum ? $total : $cpage * $num;
- $next = $cpage == $pagenum ? 0 : $cpage + 1;
- $prev = $cpage == 1 ? 0 : $cpage - 1;
- $IN_CASH_TYPE = json_decode(IN_CASH_TYPE, true);
- ?> <!DOCTYPE html>
- <html lang="">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/>
- <meta name="keywords" content="<?php echo IN_KEYWORDS;?>"/>
- <meta name="description" content="<?php echo IN_DESCRIPTION;?>"/>
- <title>我的订单 - <?php echo IN_NAME;?> - 免费应用内测托管平台|iOS应用Beta测试分发|Android应用内测分发</title>
- <?php
- $this->static_();
- ?> <style>
- .table_top a {
- display: block;
- float: left;
- padding: 10px 20px;
- }
- .table_top a p.b-num {
- color: #fba208;
- font-size: 30px;
- }
- .table_top a p:first-child {
- font-size: 15px;
- font-weight: bolder;
- }
- .red {
- color: red !important;
- }
- .green {
- color: green !important;
- }
- .blue {
- color: blue !important;
- }
- .orange {
- color: orange !important;
- }
- </style>
- </head>
- <body>
- <?php
- $this->header();
- ?> <script src="/static/index/js/bootstrap-paginator.js"></script>
- <div class="user-center-wrap">
- <div class="container">
- <div class="crumbs">
- <a href="/index/user_profile">个人中心</a><span>/</span>账号信息
- </div>
- <div class="user-center1">
- <div class="row clearfix">
- <?php
- $this->user_left();
- ?> <div class="col-sm-10">
- <div class="aside-right">
- <div class="order">
- <div class="table-list-wrap">
- <div class="table-list">
- <div class="table_top">
- <a href="/index/user_cash">
- <p>佣金</p>
- <p class="b-num">
- <?php echo $this->user['promote_money'];?> </p>
- </a>
- <a href="/index/user_cash">
- <p>已提现佣金</p>
- <p class="b-num">
- <?php echo $this->user['promote_money_cash'];?> </p>
- </a>
- <?php
- if (IN_CASH && $this->user['promote_money'] > IN_CASH_MIN && isCashDate()) {
- ?> <a href="javascript:;" class="ms-btn ms-btn-primary mt3"
- id="addcode">提现</a>
- <?php
- }
- ?> </div>
- <div class="user-table">
- <div class="table-wrap">
- <div class="table-responsive">
- <table class="table">
- <tr>
- <th>ID</th>
- <th>
- 姓名
- </th>
- <th>
- 账号
- </th>
- <th>
- 提现金额
- </th>
- <th>
- 提现方式
- </th>
- <th>
- 备注
- </th>
- <th>
- 提现时间
- </th>
- <th>
- 状态
- </th>
- <th>
- 操作
- </th>
- </tr>
- <?php
- foreach ($result as $key => $value) {
- ?> <tr>
- <td>
- <?php echo $value['id'];?> </td>
- <td>
- <?php echo $value['name'];?> </td>
- <td>
- <?php echo $value['account'];?> </td>
- <td>
- <?php echo $value['money'];?> </td>
- <td>
- <?php echo array("", "银行卡", "支付宝")[$value['type']];?> </td>
- <td>
- <?php echo $value['note'];?> </td>
- <td>
- <?php echo date("Y-m-d H:i:s", $value['create_time']);?> </td>
- <td class="<?php echo array('orange', 'green', 'red', 'blue')[$value['status']];?>">
- <?php echo array('申请中', '已受理', '已取消', '已打款')[$value['status']];?> </td>
- <td>
- <?php
- if ($value['status'] < 1) {
- ?> <a href="javascript:;"
- class="table-btn color-hover"
- data-id="<?php echo $value['id'];?>"
- >取消</a>
- <?php
- }
- ?> </td>
- </tr>
- <?php
- }
- ?> </table>
- <?php
- if ($total == 0) {
- ?> <div class="text-center no-content">
- <img src="/static/index/image/icon-21.png" alt="">
- <p class="color-333 mt10">
- 暂无订单信息
- </p>
- </div>
- <?php
- }
- ?> </div>
- <?php
- if ($pagenum != 1) {
- ?> <?php
- if ($total !== 0) {
- ?> <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
- if ($cpage == 1) {
- ?><li class='active'><a>首页</a></li><?php
- } else {
- ?><li><a href='?page=1'>首页</a></li><?php
- }
- if ($prev) {
- ?><li><a href='?page=<?php echo $prev;?>'>上一页</a></li><?php
- } else {
- }
- if ($next) {
- ?><li><a href='?page=<?php echo $next;?>'>下一页</a></li><?php
- } else {
- }
- if ($cpage == $pagenum) {
- ?><li class='active'><a>尾页</a></li><?php
- } else {
- ?><li><a href='?page=<?php echo $pagenum;?>'>尾页</a></li><?php
- }
- ?></ul></div> <?php
- }
- ?> <?php
- }
- ?> </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="modal fade in" id="vipkeySC" tabindex="-1" role="dialog"
- style="display: none; padding-right: 15px;">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <center>
- <h4 class="modal-title">提现</h4></center>
- </div>
- <div class="modal-body">
- <div class="size-list">
- <form id="upload" method="post" target="post_frame" enctype="multipart/form-data">
- <div style="padding-left:30px;">
- <div style="margin-top:20px;">
- <label style="width:100px;text-align:right;">可提现金额 </label>
- <input type="text" name="max_num" disabled="disabled" id="max_num"
- style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
- value="<?php echo $this->user['promote_money'];?>">
- </div>
- </div>
- <div style="padding-left:30px;">
- <div style="margin-top:20px;">
- <label style="width:100px;text-align:right;">姓名 </label>
- <input type="text"
- style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
- placeholder="你的真实姓名(必填)" name="name">
- </div>
- </div>
- <div style="padding-left:30px;">
- <div style="margin-top:20px;">
- <label style="width:100px;text-align:right;">账号 </label>
- <input type="text"
- style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
- placeholder="银行卡号或支付宝账号(必填)" name="account">
- </div>
- </div>
- <div style="padding-left:30px;">
- <div style="margin-top:20px;">
- <label style="width:100px;text-align:right;">金额 </label>
- <input type="number"
- style="width:420px;padding-left:10px;height:35px;border:1px solid #e0e0e0;"
- placeholder="(必填)" name="money"
- oninput="value=value.replace(/[^\d]/g,'')"
- min="<?php echo IN_CASH_MIN;?>"
- max="<?php echo min($this->user['promote_money'], IN_CASH_MAX);?>">
- </div>
- </div>
- <div style="padding-left:30px;">
- <div style="margin-top:20px;">
- <label style="width:100px;text-align:right;">提现方式 </label>
- <ul class="clearfix download-way"
- style="width:420px;float:right;margin-right:10px;">
- <?php
- $active = 'icon-radio-checked';
- $type_value = 2;
- if (in_array(1, $IN_CASH_TYPE)) {
- ?> <li class="clearfix" style="float:left;">
- <span class="icon icon-radio fl <?php echo $active;?>"></span>
- <span class="fl">银行卡</span>
- </li>
- <?php
- $active = '';
- $type_value = 1;
- }
- ?> <?php
- if (in_array(2, $IN_CASH_TYPE)) {
- ?> <li class="clearfix">
- <span class="icon icon-radio fl <?php echo $active;?>"
- style="float:left;margin-left:10px;"></span>
- <span class="fl">支付宝</span>
- </li>
- <?php
- }
- ?> </ul>
- <input type="hidden" name="type" value="<?php echo $type_value;?>" id="type"/>
- </div>
- </div>
- <div style="padding-left:30px;">
- <div style="margin-top:20px;">
- <label style="width:100px;text-align:right;">备注 </label>
- <textarea name="note" maxlength="50" placeholder="可为空,50个字以内"
- style="width:420px;padding-left:10px;height:100px;border:1px solid #e0e0e0;"></textarea>
- </div>
- </div>
- </form>
- </div>
- <br><br>
- <div class="form-group" style="margin-top:10px;">
- <div class="tipPanel"
- style="margin: 10px;padding: 10px;font-size: 14px;border: 1px dotted gray;border-radius: 8px;">
- <div class="tipItem" id="codeInfo">
- <table style="width:100%">
- <tr>
- <td>
- <font color="red">每笔最低提现金额</font>:<?php echo IN_CASH_MIN;?>元
- </td>
- <td>
- <font color="red">每笔最高提现金额</font>:<?php echo IN_CASH_MAX;?>元
- </td>
- </tr>
- <tr>
- <td>
- <font color="red">每天最多提现次数</font>:<?php echo $this->toady_count;?>/<?php echo IN_CASH_DAY;?> 次
- </td>
- <td>
- <font color="red">每月最多提现次数</font>:<?php echo $this->month_count;?>/<?php echo IN_CASH_MONTH;?> 次
- </td>
- </tr>
- <tr>
- <td>
- <font color="red">每天提现额度</font>:<?php echo $this->toady_money;?>/<?php echo IN_CASH_DAY_MAX;?> 元
- </td>
- <td>
- <font color="red">每月提现额度</font>:<?php echo $this->month_money;?>/<?php echo IN_CASH_MONTH_MAX;?> 元
- </td>
- </tr>
- <tr>
- <td>
- <font color="red">每月可提现日期</font>:<?php echo IN_CASH_DATE ? str_replace('|', '或', IN_CASH_DATE) . '日' : '每天';?> </td>
- <td>
- <font color="red">每月提现结算日期</font>:<?php echo IN_CASH_CALC_DATE ? str_replace('|', '或', IN_CASH_CALC_DATE) . '日' : '每天';?> </td>
- </tr>
- </table>
- </div>
- </div>
- </div>
- <div style="text-align:right;margin-top:30px;">
- <div style="border-top:1px solid #eee;">
- <div class="text-right mt30">
- <input type="hidden" id="in_tid" value="0">
- <button type="button" class="btn btn-default" data-dismiss="modal"
- aria-label="Close"
- onclick="$('#vipkeySC').toggle();">取消
- </button>
- <button type="button" class="btn btn-primary" onclick="produce()">提交</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php
- $this->footer();
- ?> <script>
- $('#addcode,.btn-new-release').click(function () {
- $('#vipkeySC').toggle();
- });
- $('.download-way li').click(function () {
- $(this).addClass('active').siblings().removeClass('active');
- $('.download-way li span').removeClass('icon-radio-checked');
- $(this).find('.icon-radio').addClass('icon-radio-checked');
- $('#type').val($(this).index() + 1);
- });
- function produce() {
- var name = $('input[name=name]').val();
- var account = $('input[name=account]').val();
- var money = $('input[name=money]').val();
- var type = $('input[name=type]').val();
- var note = $('textarea[name=note]').val();
- $.post('/index/user_cash/cash_new', {name, account, money, type, note}, function (ret) {
- if (ret.msg) alert(ret.msg);
- if (ret.data) {
- location.reload();
- }
- }, 'json');
- }
- $('table a.table-btn').click(function () {
- var id = $(this).attr('data-id');
- $.post('/index/user_cash/cancle', {id}, function (ret) {
- if (ret.msg) alert(ret.msg);
- if (ret.data) {
- location.reload();
- }
- }, 'json');
- });
- </script>
- </body>
- </html>
- <?php
- }
- }
|