会长提现|公会分成管理--更新

master
chenxiaojun 5 years ago
parent 9105b75ddf
commit e884214546

@ -1034,4 +1034,94 @@ public function auto_rrdae(){
];
return $ret;
}
//会长提现
public function promoteWithdraw()
{
$map['level'] = 1;
$map['ver_status'] = 1;
$promotes = M('promote', 'tab_')->field('id, account, chain')->where($map)->select();
$success = 0;
$error_withdraw = 0;
$error_spend = 0;
$error_balance = 0;
if (!empty($promotes)) {
foreach ($promotes as $promote) {
$result = $this->promoteWithdrawByPromote($promote);
switch ($result) {
case -2:
$error_balance++;
break;
case -1:
$error_spend++;
break;
case 0:
$error_withdraw++;
break;
case 1:
$success++;
break;
}
}
}
echo "success{$success} error_withdraw{$error_withdraw} error_spend{$error_spend} error_balance{$error_balance}";
}
private function promoteWithdrawByPromote($promote)
{
$promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"];
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promote['id'];
$settlementEndTime = strtotime(date('Y-m-d')) - 1;
$spendMap['pay_status'] = 1;
$spendMap['selle_status'] = 0;
$spendMap['promote_id'] = ['in', $promoteIds];
$spendMap['pay_time'] = ['elt', $settlementEndTime];
$spendModel = M('spend', 'tab_');
$balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
->where($spendMap)
->find()['balance'];
$balance = bcdiv($balance, 100, 2);
if ($balance < 100) {
return -2;//余额不足
}
$thisTime = time();
$add['sum_money'] = $balance;
$add['promote_id'] = $promote['id'];
$add['promote_account'] = $promote['account'];
$add['create_time'] = $thisTime;
$add['status'] = 0;
$add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber();
$add['settlement_begin_time'] = 0;
$add['settlement_end_time'] = $settlementEndTime;
$add['spend_ids'] = '';
$add['op_id'] = 0;
$add['op_type'] = 3;
$add['last_op_id'] = $add['op_id'];
$add['last_op_type'] = 3;
M()->startTrans();//开启事物
$withdrawId = D('withdraw')->add($add);
if (!$withdrawId) {
M()->rollback();//事物回滚
return 0;//提现失败
}
$save['selle_status'] = 1;
$save['selle_time'] = $thisTime;
$save['withdraw_id'] = $withdrawId;
$res = $spendModel->where($spendMap)->save($save);
if ($res === false) {
D('withdraw')->delete($withdrawId);
M()->rollback();//事物回滚
return -1;
}
M()->commit();//事物提交
return 1;
}
}

@ -62,7 +62,7 @@ class PromoteGameRatioController extends ThinkController
$thisPromoteAccount = '未知';
$thisPromoteMobilePhone = '未知';
$thisPromoteCreateTime = '未知';
$thisPromoteStatus = '未知';
$thisPromoteStatus = '待审核';
$thisPromoteVerStatus = '未知';
$thisGameName = '未知';
$thisGameRatio = '0.00';
@ -79,9 +79,9 @@ class PromoteGameRatioController extends ThinkController
$thisPromoteAccount = $promotes[$thisPromoteId]['account'];
$thisPromoteMobilePhone = $promotes[$thisPromoteId]['mobile_phone'];
$thisPromoteCreateTime = date('Y-m-d H:i:s', $promotes[$thisPromoteId]['create_time']);
$thisPromoteStatus = get_status_title($promotes[$thisPromoteId]['status']);
$thisPromoteStatus = $thisPromoteStatus ?? '未知';
$thisPromoteVerStatus = getPromoteVerStatus($promotes[$thisPromoteId]['status'], 2);
$thisPromoteStatus = get_info_status($promotes[$thisPromoteId]['status'], 3);
$thisPromoteStatus = $thisPromoteStatus ?? '待审核';
$thisPromoteVerStatus = getPromoteVerStatus($promotes[$thisPromoteId]['ver_status'], 2);
}
if ($issetGame) {
$thisGameName = $games[$thisGameId]['game_name'];
@ -146,16 +146,19 @@ class PromoteGameRatioController extends ThinkController
if (empty($promoteGameRatio)) {
$this->error('参数异常');
}
if ($promoteGameRatio['status'] == -1 || $save['begin_time'] != $promoteGameRatio['begin_time'] || $save['end_time'] != $promoteGameRatio['end_time'] || $save['ratio'] != $promoteGameRatio['ratio'] || $save['remark'] != $promoteGameRatio['remark']) {
$promoteId = $promoteGameRatio['promote_id'];
$this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据
$promoteId = $promoteGameRatio['promote_id'];
$this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据
if ($promoteGameRatio['status'] == 1) {
$save['last_ratio'] = $promoteGameRatio['ratio'];
$save['last_ratio_status'] = 1;
if ($promoteGameRatio['status'] == 1) {
$save['last_ratio'] = $promoteGameRatio['ratio'];
$save['last_ratio_status'] = 1;
}
$save['id'] = intval($params['id']);
$result = D(self::MODEL_NAME)->save($save);
} else {
$result = true;
}
$save['id'] = intval($params['id']);
$result = D(self::MODEL_NAME)->save($save);
} else {//新增
if (empty($params['promote_id'])) {
$this->error('请选择会长账号');

@ -2,7 +2,9 @@
namespace Admin\Controller;
use Home\Controller\FileController;
use User\Api\UserApi as UserApi;
use Admin\Model\WithdrawModel;
/**
* 推广查询控制器
@ -10,164 +12,369 @@ use User\Api\UserApi as UserApi;
*/
class QueryController extends ThinkController
{
public function settlement($p = 0)
//生成提现单号
public function produceWithdrawNumber()
{
$prefix = 'WD_';
$number = '';
while (true) {
$randomNum = rand(10, 99);
$number = $prefix . time() . $randomNum;
$map['widthdraw_number'] = $number;
$res = M('withdraw', 'tab_')->where($map)->getField('id');
if (!$res) {
break;
}
}
return $number;
}
public function settlement($p = 0)
{
$page = intval(I('p', 1)); //默认显示第一页数据
$row = intval(I('row', 10));
$group = I('group', 1);
$this->assign('group', $group);
if (isset($_REQUEST['total_status'])) {
unset($_REQUEST['total_status']);
}
$this->m_title = '推广结算';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find());
$promoteId = I('promote_id', 0);
if ($group == 1) {
if ($_REQUEST['unum'] == 2) {
$order = 'unum';
$order_type = SORT_ASC;
} else if ($_REQUEST['unum'] == 1) {
$order = 'unum';
$order_type = SORT_DESC;
}
if ($_REQUEST['spay_amount'] == 2) {
$order = 'spay_amount';
$order_type = SORT_ASC;
} else if ($_REQUEST['spay_amount'] == 1) {
$order = 'spay_amount';
$order_type = SORT_DESC;
}
$model = array(
'title' => '渠道结算',
'template_list' => 'settlement',
'order' => $order,
'order_type' => $order_type//0倒序 1 正序
);
$start = $_REQUEST['timestart'];
$end = $_REQUEST['timeend'];
if (I('group') != '') {
if ($start == '' || $end == '' && $_REQUEST['promote_account'] == '') {
$this->error('结算周期、所属渠道不能为空!', '', 1);
if (empty($promoteId)) {
$this->display();
} else {
$promoteIds = M('promote', 'tab_')->where(['chain' => ['like', "/{$promoteId}/%"]])->getField('id', true);
$promoteIds[] = $promoteId;
$beginTime = I('timestart', get_lastweek_name(7));
$endTime = I('timeend', get_lastweek_name(1));
$sortBy = I('sort_by', '');
$sortColumn = I('sort_column', '');
$order = 'tab_spend.pay_time';
$orderType = 'desc';
if (in_array($sortColumn, ['user_num', 'sum_amount'])) {
$order = $sortColumn;
}
if ($start == '' || $end == '') {
$this->error('请选择结算周期!', '', 1);
if ($sortBy == 1) {
$orderType = 'desc';
} elseif ($sortBy == 2) {
$orderType = 'asc';
}
if ($_REQUEST['promote_account'] == '') {
$this->error('请选择渠道!', '', 1);
$beginTime = strtotime($beginTime);
$endTime = strtotime($endTime) + 3600 * 24 - 1;
$spendMap['tab_spend.pay_status'] = 1;
$spendMap['tab_spend.selle_status'] = 0;
$spendMap['tab_spend.pay_time'] = ['between', [$beginTime, $endTime]];
$spendMap['tab_spend.promote_id'] = ['in', $promoteIds];
$spendField = 'tab_spend.promote_account, tab_spend.game_name, sum(tab_spend.pay_amount) as sum_amount, tab_spend.selle_ratio, sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount';
$userMap['tab_user.promote_id'] = ['in', $promoteIds];
$userMap['_string'] = 'tab_user.promote_id = tab_spend.promote_id';
$userField = M('user', 'tab_')->field('count(tab_user.id) as user_num')
->where($userMap)
->buildSql();
$field = "{$spendField}, {$userField} as user_num";
$query = M('spend', 'tab_')->field($field)
->where($spendMap)
->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id')
->order("{$order} {$orderType}")
->page($page, $row)
->buildSql();
$records = M()->table($query)
->alias('record')
->select();
$countQuery = M('spend', 'tab_')->field('tab_spend.id')
->where($spendMap)
->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id')
->buildSql();
$count = M()->table($countQuery)
->alias('tab_spend')
->count();
$page = set_pagination($count, $row);
if (!empty($records)) {
$promote = M('promote', 'tab_')->find($promoteId);
foreach ($records as &$record) {
$record['promote_account'] = $promote['account'] ?? '未知';
$record['settlement_amount'] = bcdiv($record['settlement_amount'], 100, 2);
}
}
}
$smap['tab_spend.pay_status'] = 1;
//判断是否结算绑币
if ($_REQUEST['bind_coin'] == 0) {
$smap['tab_spend.pay_way'] = array('neq', -1);
}
$this->meta_title = '渠道结算列表';
$this->assign('setdate', date("Y-m-d", strtotime("-1 day")));
$this->assign('is_admin', is_administrator());
if ($start && $end) {
if ((strtotime($end) + 24 * 60 * 60 - 1) < strtotime($start)) {
$this->error('时间选择不正确!', U('Query/settlement'), '');
}
$umap['register_time'] = array('BETWEEN', array(strtotime($start), strtotime($end) + 24 * 60 * 60 - 1));
if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') {
$umap['fgame_id'] = get_game_id($_REQUEST['game_name']);
$smap['tab_spend.game_id'] = get_game_id($_REQUEST['game_name']);
$totalField = 'sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount';
$total = array_sum(array_column($records, 'settlement_amount'));//当页
$zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//累计
$zTotal = bcdiv($zTotal, 100 ,2);
unset($spendMap['tab_spend.pay_time']);
$spendMap['_string'] = 'tab_spend.pay_time' . total(1);
$tTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//今日
$tTotal = bcdiv($tTotal, 100 ,2);
$spendMap['_string'] = 'tab_spend.pay_time' . total(5);
$yTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//昨日
$yTotal = bcdiv($yTotal, 100 ,2);
if($page) {
$this->assign('_page', $page);
}
if (isset($_REQUEST['promote_account']) && $_REQUEST['promote_account'] != '') {
$allid = get_subordinate_promote_($_REQUEST['promote_account']);
$allid[] = $_REQUEST['promote_account'];
$umap['tab_user.promote_account'] = array('in', $allid);
$smap['tab_spend.promote_account'] = array('in', $allid);
} else {
$this->error('未选择渠道!', '', 1);
}
$umap['is_check'] = 1;
$umap['settle_check'] = 0;
$smap['pay_time'] = array('BETWEEN', array(strtotime($start), strtotime($end) + 24 * 60 * 60 - 1));
$smap['is_check'] = 1;
$smap['settle_check'] = 0;
//为数据权限添加
setPowerPromoteIds($umap, 'tab_user.promote_id');
setPowerPromoteIds($smap, 'tab_spend.promote_id');
$map['umap'] = $umap;
$map['smap'] = $smap;
$user = A('Settlement', 'Event');
$user->settlement($model, $p, $map);
} else {
$this->assign('records', $records);
$this->assign('total', $total);
$this->assign('tTotal', $tTotal);
$this->assign('yTotal', $yTotal);
$this->assign('zTotal', $zTotal);
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find());
$this->m_title = '推广结算';
$this->display();
}
}
if ($group == 2) {
if (isset($_REQUEST['stimestart']) && isset($_REQUEST['stimeend'])) {
$map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['stimestart']), strtotime($_REQUEST['stimeend']) + 24 * 60 * 60 - 1));
} elseif (isset($_REQUEST['stimestart'])) {
$map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['stimestart']), time()));
} elseif (isset($_REQUEST['stimeend'])) {
$map['create_time'] = array('LT', (strtotime($_REQUEST['stimeend']) + 24 * 60 * 60 - 1));
} elseif ($group == 2) {
$map['_string'] = '1 = 1';
$createTime = strtotime(I('create_time', ''));
$withdrawNumber = I('widthdraw_number', '');
$status = intval(I('status', ''));
$opType = intval(I('op_type', 0));
if ($createTime) {
$createTimeEnd = $createTime + 3600 * 24 - 1;
$map['create_time'] = ['between', [$createTime, $createTimeEnd]];
}
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
$map['starttime'] = ['GT', strtotime($_REQUEST['timestart'])];
$map['endtime'] = ['LT', strtotime($_REQUEST['timeend']) + 24 * 60 * 60];
} elseif (isset($_REQUEST['timestart'])) {
$map['starttime'] = ['GT', strtotime($_REQUEST['timestart'])];
} elseif (isset($_REQUEST['timeend'])) {
$map['endtime'] = ['LT', strtotime($_REQUEST['timeend']) + 24 * 60 * 60];
if ($promoteId) {
$map['promote_id'] = $promoteId;
}
if (isset($_REQUEST['game_name'])) {
if ($_REQUEST['game_name'] == '全部') {
unset($_REQUEST['game_name']);
} else {
$map['game_name'] = $_REQUEST['game_name'];
}
if ($withdrawNumber) {
$map['widthdraw_number'] = ['like', "{$withdrawNumber}%"];
}
if (isset($_REQUEST['promote_account'])) {
if ($_REQUEST['promote_account'] == '全部') {
unset($_REQUEST['promote_account']);
} else {
$map['promote_account'] = $_REQUEST['promote_account'];
if (isset($_REQUEST['status'])) {
$map['status'] = $status;
}
if ($opType) {
$map['op_type'] = $opType;
}
$records = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond')
->where($map)
->order('create_time desc')
->page($page, $row)
->select();
$count = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond')
->where($map)
->count();
if (!empty($records)) {
foreach ($records as &$record) {
$record['settlement_begin_time'] = $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--';
$record['settlement_end_time'] = date('Y-m-d H:i:s', $record['settlement_end_time']);
$record['create_time'] = date('Y-m-d H:i:s', $record['create_time']);
$record['status_text'] = promoteWithdrawStatus($record['status']);
if ($record['status'] == -2) {
$record['status_text'] = '<span style="color: #999;">' . $record['status_text'] . '</span>';
}
}
}
if (!empty($_REQUEST['settlement_number'])) {
$map['settlement_number'] = $_REQUEST['settlement_number'];
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$this->assign('records', $records);
$this->display();
}
}
$map['developers'] = 0;
public function settlementWithdraw()
{
$beginTime = strtotime(I('begin_time', ''));
$endTime = strtotime(I('end_time', ''));
$promoteId = intval(I('promote_id', 0));
if ($beginTime == 0 || $endTime == 0) {
$data['status'] = 0;
$data['msg'] = '时间参数错误';
$this->ajaxReturn($data);
}
if ($beginTime > $endTime) {
$data['status'] = 0;
$data['msg'] = '开始时间必须小于等于结束时间';
$this->ajaxReturn($data);
}
if ($promoteId == 0) {
$data['status'] = 0;
$data['msg'] = '请选择会长账号';
$this->ajaxReturn($data);
}
$model = array(
'm_name' => 'settlement',
'fields' => array(
'settlement_number',
'starttime', 'endtime',
'promote_id', 'promote_account',
'sum(total_money) as total_money',
'sum(total_number) as total_number',
'sum(sum_money) as sum_money',
'bind_coin_status',
'create_time'),
'group' => 'promote_id,starttime,endtime,create_time,bind_coin_status',
'order' => 'create_time desc ',
'title' => '结算账单',
'template_list' => 'settlement',
);
//为数据权限添加
setPowerPromoteIds($map);
$map1 = $map;
$promote = M('promote', 'tab_')->find($promoteId);
if (empty($promote)) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
if ($promote['level'] != 1) {
$data['status'] = 0;
$data['msg'] = '非会长账号,无法执行此操作';
$this->ajaxReturn($data);
}
if ($promote['ver_status'] != 1) {
$data['status'] = 0;
$data['msg'] = '该会长未通过资质认证审核,暂时无法提现';
$this->ajaxReturn($data);
}
$endTime += 3600 * 24 - 1;
$spendModel = M('spend', 'tab_');
$map['chain'] = ['like', $promote['chain'] . $promote['id'] . '/%'];
$promoteIds = M('promote', 'tab_')->where($map)->getField('id', true);
$promoteIds[] = $promote['id'];
$promoteIds = implode(',', $promoteIds);
$map = [];
$map['pay_status'] = 1;
$map['selle_status'] = 0;
$map['promote_id'] = ['in', $promoteIds];
$map['pay_time'] = ['between', [$beginTime, $endTime]];
$balance = $spendModel->field("sum(pay_amount * selle_ratio) as balance")
->where($map)
->find()['balance'];
$balance = bcdiv($balance, 100, 2);
if ($balance < 100) {
$data['status'] = 0;
$data['msg'] = '累计结算低于100元无法提现';
$this->ajaxReturn($data);
}
$spendIds = $spendModel->where($map)->getField('id', true);
if (empty($spendIds)) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$thisTime = time();
$add['sum_money'] = $balance;
$add['promote_id'] = $promote['id'];
$add['promote_account'] = $promote['account'];
$add['create_time'] = $thisTime;
$add['status'] = 0;
$add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber();
$add['settlement_begin_time'] = $beginTime;
$add['settlement_end_time'] = $endTime;
$add['spend_ids'] = '';
$add['op_id'] = is_login();
$add['op_type'] = 2;
$add['last_op_id'] = $add['op_id'];
$add['last_op_type'] = 2;
M()->startTrans();//开启事物
$withdrawId = M('withdraw', 'tab_')->add($add);
if (!$withdrawId) {
M()->rollback();//事物回滚
$data['status'] = 0;
$data['msg'] = '提现失败';
$this->ajaxReturn($data);
}
$map = [];
$map['id'] = ['in', $spendIds];
$save['selle_status'] = 1;
$save['selle_time'] = $thisTime;
$save['withdraw_id'] = $withdrawId;
$res = $spendModel->where($map)->save($save);
if ($res === false) {
M('withdraw', 'tab_')->delete($withdrawId);
M()->rollback();//事物回滚
$data['status'] = 0;
$data['msg'] = '提现失败';
$this->ajaxReturn($data);
}
M()->commit();//事物提交
$data['status'] = 1;
$data['msg'] = '提现成功';
$this->ajaxReturn($data);
}
public function renewReview()
{
$id = intval(I('id', 0));
$data = M('withdraw', 'tab_')->find($id);
if (empty($data) || $data['status'] != -1) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$ztotal = null_to_0(D('settlement')->where($map1)->sum('sum_money*10000') / 10000);
$this->assign('ztotal', $ztotal);
$ttotal = null_to_0(D('settlement')->where('create_time' . total(1))->sum('sum_money*10000') / 10000);
$this->assign('ttotal', $ttotal);
$ytotal = null_to_0(D('settlement')->where('create_time' . total(5))->sum('sum_money*10000') / 10000);
$this->assign('ytotal', $ytotal);
$user = A('Bill', 'Event');
$save['id'] = $id;
$save['status'] = 0;
$save['last_up_update_time'] = time();
$save['last_op_id'] = is_login();
$save['last_op_type'] = 2;
$res = M('withdraw', 'tab_')->save($save);
if ($res === false) {
$data['status'] = 0;
$data['msg'] = '提交失败';
} else {
$data['status'] = 1;
$data['msg'] = '提交成功';
}
$this->ajaxReturn($data);
}
$user->money_list($model, $p, $map);
public function cancelWithdraw()
{
$id = intval(I('id', 0));
$data = M('withdraw', 'tab_')->find($id);
if (empty($data) || !in_array($data['status'], [-1, 0])) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$spendMap['withdraw_id'] = $id;
$spendIds = M('Spend', 'tab_')->where($spendMap)->getField('id', true);
if (empty($spendIds)) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$spendIds = implode(',', $spendIds);
$time = time();
$withdrawSave['id'] = $id;
$withdrawSave['status'] = -2;
$withdrawSave['spend_ids'] = $spendIds;
$withdrawSave['last_up_update_time'] = $time;
$withdrawSave['last_op_id'] = is_login();
$withdrawSave['last_op_type'] = 2;
M('withdraw', 'tab_')->startTrans();//开启事物
$withdrawRes = M('withdraw', 'tab_')->save($withdrawSave);
if ($withdrawRes === false) {
M('withdraw', 'tab_')->rollback();//事物回滚
$data['status'] = 0;
$data['msg'] = '撤销失败';
$this->ajaxReturn($data);
}
$spendSave['selle_status'] = 0;
$spendSave['withdraw_id'] = 0;
$spendRes = M('spend', 'tab_')->where($spendMap)->save($spendSave);
if ($spendRes === false) {
M('withdraw', 'tab_')->rollback();//事物回滚
$data['status'] = 0;
$data['msg'] = '撤销失败';
} else {
M('withdraw', 'tab_')->commit();//事物提交
$data['status'] = 1;
$data['msg'] = '撤销成功';
}
$this->ajaxReturn($data);
}
public function downloadProve()
{
$id = intval(I('id', 0));
if ($id) {
$withdraw = M('withdraw', 'tab_')->find($id);
if (empty($withdraw) || $withdraw['status'] != 2 || !$withdraw['transfer_proof']) {
$this->error('网络异常');
}
$file = new FileController();
$file->download($withdraw['transfer_proof']);
} else {
$this->error('参数异常');
}
}
public function cpsettlement($p = 0)
@ -664,6 +871,9 @@ class QueryController extends ThinkController
if (isset($_REQUEST['ti_status'])) {
$map['status'] = $_REQUEST['ti_status'];
}
if (isset($_REQUEST['op_type'])) {
$map['op_type'] = $_REQUEST['op_type'];
}
if (isset($_REQUEST['promote_account'])) {
if ($_REQUEST['promote_account'] == '全部') {
unset($_REQUEST['promote_account']);

@ -15,6 +15,10 @@ use Think\Model;
*/
class WithdrawModel extends Model{
const OP_TYPE_PROMOTE = 1;
const OP_TYPE_ADMIN = 2;
const OP_TYPE_AUTO = 3;
/**
* 构造函数
* @param string $name 模型名称
@ -28,8 +32,11 @@ class WithdrawModel extends Model{
parent::__construct($name, $tablePrefix, $connection);
}
public static $opTypeList = [
self::OP_TYPE_PROMOTE => '推广员',
self::OP_TYPE_ADMIN => '管理员',
self::OP_TYPE_AUTO => '自动',
];
/*
* 开发者提现未处理列表
@ -102,4 +109,20 @@ class WithdrawModel extends Model{
}
//生成提现单号
public function produceWithdrawNumber()
{
$prefix = 'WD_';
$number = '';
while (true) {
$randomNum = rand(10, 99);
$number = $prefix . time() . $randomNum;
$map['widthdraw_number'] = $number;
$res = $this->where($map)->getField('id');
if (!$res) {
break;
}
}
return $number;
}
}

@ -30,98 +30,89 @@
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<ul class="tabnav1711 fr jstabnav">
<li class="<eq name='group' value='1'>current</eq>"><a href="{:U('settlement')}">推广结算</a></li>
<li class="<eq name='group' value='2'>current</eq>" ><a href="{:U('settlement?group=2')}">结算记录</a></li>
</ul>
<h3 class="page_title">推广结算</h3>
<if condition="$group eq 1">
<p class="description_text">说明:此功能是针对推广员下面的用户注册充值进行结算,充值数据是指消费到游戏的所有订单记录</p>
<else/>
<p class="description_text">说明:此功能是查看所有的推广员结算记录</p>
</if>
<div class="fr">
<a <if condition="$group eq 1"> class="tabchose" </if> href="{:U('settlement?group=1')}">推广结算</a>
<a <if condition="$group eq 2"> class="tabchose" </if> href="{:U('settlement?group=2')}">结算记录</a>
</div>
<h3 class="page_title">推广结算</h3>
<if condition="$group eq 1">
<p class="description_text">说明:此功能是查看所有的会长未提现订单,并可进行后台提现</p>
<else/>
<p class="description_text">说明:此功是查看并管理混服申请的功能</p>
</if>
</div>
<div class="cf top_nav_list">
<if condition="I('group',1) eq 1">
<div class="infomation information1711">
<div>
<span>参与结算设置:</span>
<label>
<input type="radio" class="inp_radio" value="0" name="bind_coin" <if condition="I('bind_coin',0) eq 0">checked="checked"</if>> 排除绑币
</label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label>
<input type="radio" class="inp_radio" value="1" name="bind_coin" <if condition="I('bind_coin',0) eq 1">checked="checked"</if>> 包含绑币
</label>
</div>
<div style="line-height: 30px;">
<p>注意①:推广结算只结算消费到游戏的所有订单记录。(系统默认全部排除绑币,可视情况自行勾选)</p>
<p>注意②:包含绑币勾选请慎重,由于玩家账户部分绑币的来源属于后台发放或者会长代充等,涉及到成本盈亏,是否参与推广员结算请考虑清楚!</p>
<p>注意③:推广结算时间请按规律时间统一结算,否则时间不统一容易导致个别游戏在统一时间内无法结算。(结算时间只可选到前一天)</p>
</div>
</div>
</if>
<!-- 高级搜索 -->
<if condition="I('group') eq 1 or $group eq 1">
<empty name="model.extend">
<div class="fl button_list">
<div class="tools">
<a class=" ajax-post " target-form="ids" url="{:U('generatesettlementAll?model='.$model['id'],array('ids'=>$data['id'],'bind_coin'=>I('bind_coin',0),'game_name'=>I('game_name'),'promote_account'=>I('promote_account'),'timestart'=>I('timestart'),'timeend'=>I('timeend'),'cooperation'=>I('cooperation'),'bill_number'=>I('bill_number')))}"><span class="button_icon button_icon14"></span>批量结算</a>
</div>
</div>
</empty>
</if>
<div class="fl button_list">
<div class="tools">
<if condition="I('group') eq 1 or $group eq 1">
<a id="withdraw"><span class="button_icon button_icon10"></span>提 现</a>
</if>
</div>
</div>
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<if condition="I('group') eq 1 or $group eq 1">
<div class="input-list">
<input type="text" id="time-start" name="timestart" autocomplete="off" class="" <if condition="$Think.get.timestart eq '' and $Think.get.group neq 2">value="{:get_lastweek_name(7)}" <else/> value="{:I('timestart')}" </if>placeholder="结算周期起始时间" />
-
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" id="time-end" name="timeend" autocomplete="off" class="" <if condition="$Think.get.timeend eq '' and $Think.get.group neq 2">value="{:get_lastweek_name(1)}" <else/> value="{:I('timeend')}" </if> placeholder="结算周期结束时间" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
<input type="text" id="time-start" name="timestart" autocomplete="off" class="" value="{:I('timestart', get_lastweek_name(7))}" placeholder="充值起始时间" />
-
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" id="time-end" name="timeend" autocomplete="off" class="" value="{:I('timeend', get_lastweek_name(1))}" placeholder="充值结束时间" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" style="width:120px;">
<option value="">推广员账号</option>
<volist name=":get_all_toppromote()" id="vo">
<option promote-id="{$vo.id}" value="{$vo.account}">{$vo.account}</option>
</volist>
<input type="hidden" id="promote_account" name="promote_account" value="{:I('promote_account')}"></input>
</select>
</if>
<if condition="I('group') eq 2 or $group eq 2">
<div class="input-list">
<input type="text" id="create_time" name="create_time" class="" value="{:I('create_time', '')}" placeholder="提现时间" />
</div>
<input type="hidden" name="" value="" class="sortBy">
<if condition="I('group') eq 1 or $group eq 1">
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="searchlayer" url="{:U('Query/settlement?group=1','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div>
</if>
<if condition="I('group') eq 2 or $group eq 2">
<div class="input-list">
<input type="text" id="stime-start" name="stimestart" class="" value="{:I('stimestart')}" placeholder="结算开始时间" />
-
<div class="input-append date" id="sdatetimepicker" style="display:inline-block">
<input type="text" id="stime-end" name="stimeend" class="" value="{:I('stimeend')}" placeholder="结算结束时间" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/settlement?group=2','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div>
</if>
</if>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" style="width:120px;">
<option value="">会长账号</option>
<volist name=":get_promote_list_by_id()" id="vo">
<option promote-id="{$vo.id}" value="{$vo.id}">{$vo.account}</option>
</volist>
</select>
</div>
<input type="hidden" id="sort_by" name="sort_by" value="{:I('sort_by', '')}" class="sortBy">
<input type="hidden" id="sort_column" name="sort_column" value="{:I('sort_column', '')}" class="sortBy">
<if condition="I('group') eq 1 or $group eq 1">
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/settlement?group=1','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div>
</if>
<if condition="I('group') eq 2 or $group eq 2">
<div class="input-list">
<input type="text" name="widthdraw_number" class="" value="{:I('widthdraw_number')}" placeholder="提现单号">
</div>
<div class="input-list">
<select name="status" class="select_gallery">
<option value="">提现状态</option>
<?php foreach (promoteWithdrawStatus() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<select name="op_type" class="select_gallery">
<option value="">操作人类型</option>
<?php foreach (getPromoteWithdrawOpType() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/settlement?group=2','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div>
</if>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
@ -130,21 +121,13 @@
<!-- 表头 -->
<thead>
<tr>
<th>
<input class="check-all" type="checkbox">
</th>
<th >结算周期</th>
<th >推广员账号</th>
<th >游戏名称</th>
<th ><a class="paixu" data-order='spay_amount'>总充值</a></th>
<th ><a class="paixu" data-order='unum'>总注册</a></th>
<th >结算模式</th>
<th >分成比例</th>
<th >注册单价</th>
<th >结算金额</th>
<th >状态</th>
<!-- <th >操作</th> -->
<th >推广员账号</th>
<th >游戏名称</th>
<th ><a class="paixu" data-order='sum_amount'>总充值</a></th>
<th ><a class="paixu" data-order='user_num'>总注册</a></th>
<th >结算模式</th>
<th >分成比例</th>
<th >结算金额</th>
</tr>
</thead>
<!-- 列表 -->
@ -154,211 +137,94 @@
.data-table tbody td{border-right:1px solid #DDDDDD;}
.d_list .drop-down ul {z-index:999;}
</style>
<empty name ="list_data">
<empty name ="records">
<td colspan="12" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="list_data" id="data">
<tr>
<td class="allch">
<input class="ids" type="checkbox" data-val="{$data['id']}," value="CPS,{$data['ratio']},{$data['money']},{$data['unum']},{$data['spay_amount']},{$data['game_id']}" name="ids[]">
</td>
<td >{:I('timestart')}&nbsp;&nbsp;{:I('timeend')}</td>
<td >{:get_promote_name($data['pid'])}</td>
<td class="game_id" val="{$data['game_id']}">{:get_game_name($data['game_id'])}</td>
<td class="recharge cps">{$data['spay_amount']|default=0}</td>
<td class="number cpa">{$data['unum']|default=0}</td>
<td class="cooperation">
<div style="width: 110px;margin: 0 auto;">
<div class="d_list" >
<div class="drop-down limitwidth3 cooperwrap" >
<span class="sort-txt" data="CPS" >
<span class="cooperation_mode">CPS</span>
</span>
<i class="arrow arrow-down"></i>
<ul class="nav-list hidden">
<li><a href="javascript:;" value="CPS" ><span class="cooperation_mode">CPS</span></a></li>
<li><a href="javascript:;" value="CPA" ><span class="cooperation_mode no">CPA</span></a></li>
</ul>
</div>
</div>
</div>
</td>
<td class="ratio cp">
<span><notempty name="data.ratio">{$data.ratio}<else />0</notempty></span>%
<a href="javascript:;" id="ratiobtn" data-coom="CPS" data-notice="请输入1-100的数字,如:30即为30%" class="cpbtn">修改</a>
</td>
<td class="price cp">
<span><notempty name="data.money">{$data.money}<else />0</notempty></span>
<a href="javascript:;" id="ratiobtn" data-coom="CPA" data-notice="请输入数字" class="cpbtn">修改</a>
</td>
<td class="money">
{:round($data['spay_amount'] * $data['ratio']/100,2)}
</td>
<if condition="get_settlement(I('timestart'),I('timeend'),$data['pid'],$data['game_id']) eq true">
<td>已结算</td>
<else/>
<td>可结算</td>
</if>
</tr>
<volist name="records" id="record">
<tr>
<td>{$record.promote_account}</td>
<td>{$record.game_name}</td>
<td>{$record['sum_amount']|default=0}</td>
<td>{$record['user_num']|default=0}</td>
<td class="cooperation">CPS</td>
<td>{$record['selle_ratio']|default=0}%</td>
<td class="money">
{$record['settlement_amount']}
</td>
</tr>
</volist>
<tr class="data_summary">
<td>汇总</td>
<td colspan="10">当页结算:{$total}元 今日结算:{$tTotal}元 昨日结算:{$yTotal}元 累计结算:{$zTotal}元</td>
</tr>
</empty>
</tbody>
</table>
<script>
function pop(text,classname) {
classname = classname?classname:'';
updateAlert(text,classname);
setTimeout(function(){
//$('#top-alert').find('button').click();
$('#tip').find('.tipclose').click();
},1500);
}
$('.cooperwrap').hover(function(){
$(this).find('.nav-list').removeClass('hidden');
},function(){
$(this).find('.nav-list').addClass('hidden');
});
$('.cooperwrap .nav-list li').find('a').each(function(){
var that = $(this).closest('.cooperwrap'),top = $(this).closest('.cooperation');
$(this).click(function(){
var text = $(this).text(),val=$(this).attr('value');
that.find('.sort-txt').text(text).attr('data',val);
that.find('.nav-list').addClass('hidden');
var ratio = top.siblings('.ratio').find('span').text(),
price = top.siblings('.price').find('span').text(),
unum = top.siblings('.cpa').text(),
spay_amount = top.siblings('.cps').text(),
game_id = top.siblings('.game_id').attr('val'),
ids = top.siblings('.allch').find('.ids'),money=0;
val = text+','+ratio+','+price+','+unum+','+spay_amount+','+game_id+',';
ids.attr('value',val);
if (text == 'CPS') {
money = Math.round(ratio * top.siblings('.recharge').text())/100;
} else {
money = price * top.siblings('.number').text();
}
;
if (isNaN(money)) {money=0;}
top.siblings('.money').text(money);
})
});
$('.cpbtn').on('click',function() {
var that = this,placeholder = $(that).data('notice'),cp = $.trim($(that).data('coom'));
html = '<div class="noticemsg " >';
html += '<div class="noticemain"><div class="noticeinput"><input placeholder="'+placeholder+'" type="text" class="txt" ></div>'
html += '<div class="noticebtn cpn"><a href="javascript:;">确定</a></div></div></div>';
$('body').append(html);
$('.noticebtn a').on('click',function() {
var val = $.trim($('.noticeinput input').val()),closeste = $(that).closest('.cp');
if (val) {
if (!/^\d+(\.\d{2})?$/.test(val)) {pop('请输入正确的数字');return false;}
$(that).siblings('span').text(val);
var money = closeste.siblings('.money').text(),
cooperation = $.trim(closeste.siblings('.cooperation').find('.sort-txt').text());
if (cooperation === cp) {
money = val * closeste.siblings('.'+(cp.toLowerCase())).text();
}
switch(cp){
case 'CPS':
if (cooperation === cp) {
money = Math.round(money)/100;
}
ratio = val;
price = closeste.siblings('.price').find('span').text();
break;
case 'CPA':
price = val;
ratio = closeste.siblings('.ratio').find('span').text();
break;
}
if (isNaN(money)) {money=0;}
closeste.siblings('.money').text(money);
ids = closeste.siblings('.allch').find('.ids');
unum = closeste.siblings('.cpa').text();
spay_amount = closeste.siblings('.cps').text();
game_id = closeste.siblings('.game_id').attr('val');
val = cooperation+','+ratio+','+price+','+unum+','+spay_amount+','+game_id+',';
ids.attr('value',val);
}
$(this).closest('.noticemsg').remove();
});
$('.noticeinput input').keyup(function(event) {
if (event.keyCode == 13) {
$('.noticebtn a').click();
}
});
});
$('.confirmbtn').on('click',function() {
var that = $(this),closeste = that.closest('.op'),
cooperation = $.trim(closeste.siblings('.cooperation').find('.sort-txt').text()),
ratio = closeste.siblings('.ratio').find('span').text(),
price = closeste.siblings('.price').find('span').text(),
url = $(this).data('val'),index = url.lastIndexOf('.html');
if (index > 0)
url = url.substring(0,index)+'/cooperation/'+cooperation+'/cps_ratio/'+ratio+'/cpa_price/'+price+'.html';
else
url = url+'/cooperation/'+cooperation+'/cps_ratio/'+ratio+'/cpa_price/'+price+'.html';
$(this).siblings('.settlementbtn').attr('url',url).click();
});
</script>
</if>
<if condition="$group eq 2">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>推广员账号</th>
<th>结算周期</th>
<th>结算单号</th>
<th>总充值</th>
<th>总注册</th>
<th>结算金额</th>
<th>结算范畴</th>
<th>结算时间</th>
<th>详情</th>
<th>推广员账号</th>
<th>结算单号</th>
<th>结算金额</th>
<th>操作人</th>
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>结算开始时间</th>
<th>结算截止时间</th>
<th>提现时间</th>
<th>提现状态</th>
<th>说明</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<volist name="list_data" id="data">
<volist name="records" id="record">
<tr>
<td>
<if condition="$is_admin eq true ">
{:get_promote_name($data['promote_id'])}
<else />
{:encryptStr(get_promote_name($data['promote_id']))}
</if>
</td>
<td>{$data.starttime|date='Y-m-d',###}至{$data.endtime|date='Y-m-d',###}</td>
<td>{$data.settlement_number}</td>
<td>{$data.total_money}</td>
<td>{$data.total_number}</td>
<td>
<span class="money_color">{$data.sum_money}</span>
</td>
<td>{:get_bind_coin_status($data['bind_coin_status'])}</td>
<td>
{$data.create_time|date='Y-m-d',###}
</td>
<td>
<a href="javascript:" onclick="detailsInfo({$data['promote_id']},{$data['create_time']})">查看</a>
</td>
<td>{$record.promote_account}</td>
<td>{$record.widthdraw_number}</td>
<td>{$record.sum_money}</td>
<td>
<if condition="$record.op_type eq 1">
{:get_promote_name($record['op_id'])}
<elseif condition="$record.op_type eq 2"/>
{:getAdminNickname($record['op_id'])}
<else/>
自动
</if>
</td>
<td>{:getPromoteWithdrawOpType($record['op_type'])}</td>
<td>
<if condition="$record.last_op_type eq 1">
{:get_promote_name($record['last_op_id'])}
<elseif condition="$record.last_op_type eq 2"/>
{:getAdminNickname($record['last_op_id'])}
<else/>
自动
</if>
</td>
<td>{:getPromoteWithdrawOpType($record['last_op_type'])}</td>
<td>{$record.settlement_begin_time}</td>
<td>{$record.settlement_end_time}</td>
<td>{$record.create_time}</td>
<td>{$record.status_text}</td>
<td>{$record.respond}</td>
<td>
<if condition="$record['status'] eq 2">
<a href="{:U('downloadProve', ['id'=>$record['id']])}">汇款证明</a>
<elseif condition="$record['status'] eq -1"/>
<span class="renew-review" data-id="{$record['id']}" style="color: #0bb20c;cursor: pointer;">重新审核</span>
</if>
<if condition="$record['status'] eq -1 or $record['status'] eq 0">
<span class="cancel-withdraw" data-id="{$record['id']}" style="color: red;cursor: pointer;">撤销提现</span>
</if>
</td>
</tr>
</volist>
<tr class="data_summary">
<td>汇总</td>
<td colspan="10">当页结算:{$total}元 今日结算:{$ttotal}元 昨日结算:{$ytotal}元 累计结算:{$ztotal}元</td>
</tr>
</tbody>
</table>
</if>
@ -369,7 +235,7 @@
<if condition="I('group') eq 2 or $group eq 2">
<a class="sch-btn" href="{:U('Export/expUser',array(
'id'=>15,
'promote_account'=>I('promote_account'),
'promote_id'=>I('promote_id'),
'timestart'=>I('timestart'),
'timeend'=>I('timeend'),
'start'=>I('start'),
@ -403,71 +269,30 @@
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript">
<script>
<volist name = ":I('get.')" id = "vo">
Think.setValue('{$key}', "{$vo}");
</volist>
$(".select_gallery").select2();
$(".input-list-promote").click(function(){
$('#select2-promote_id-container').text('推广员账号');
$("#promote_account").val('');
$("#promote_accountt").val('');
});
$("#promote_id").change(function() {
$("#promote_account").val($("#promote_id option:selected").val());
$("#promote_accountt").val($("#promote_id option:selected").attr('promote-id'));
});
$(".input-list-game").click(function(){
$('#select2-game_id-container').text('请选择游戏');
$("#game_name").val('');
$("#game_namee").val('');
});
$("#game_id").change(function() {
$("#game_name").val($("#game_id option:selected").val());
$("#game_namee").val($("#game_id option:selected").attr('game-id'));
});
</script>
<script type="text/javascript">
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('Query/settlement')}");
if('{$Think.get.game_name}'!=''){
$('#select2-game_id-container').text('{$Think.get.game_name}');
}
if('{$Think.get.promote_account}'!=''){
$('#select2-promote_id-container').text('{$Think.get.promote_account}');
}
Think.setValue('row','{:I("row",10)}');
$(function(){
$("#searchlayer").click(function(){
var url = $(this).attr('url');
that=$('.top_nav_list');//jssearch
var query = that.find('input').serialize();
if(that.find('#promote_account').val()==''){
layer.msg('请选择推广员',
{time: 1000,
});exit;
};
starttime=that.find('#time-start').val();
endtime=that.find('#time-end').val();
checkEndTime(starttime,endtime);
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//搜索功能
$("#search").click(function(){
var starttime = $.trim($('#time-start').val());
var endtime = $.trim($('#time-end').val());
if((starttime && !endtime) || (!starttime && endtime)) {layer.msg('请完整选择结算周期时间');return false;}
if (starttime && endtime && starttime > endtime) {layer.msg('开始时间必须小于等于结束时间');return false;}
var url = $(this).attr('url');
var query = $('.top_nav_list').find('input').serialize();
var promoteId = $('#promote_id').val();
var group = parseInt("{$group}");
if (promoteId == '' && group === 1) {
layer.msg('请选择推广员', {time: 1000});
return false;
}
query += "&"+$('.top_nav_list').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
@ -476,74 +301,35 @@
}else{
url += '?' + query;
}
var start = $("#stime-start").val();
var end = $("#stime-end").val();
if (start !='' && end != ''){
if (Date.parse(start) > Date.parse(end)){
layer.msg('开始时间必须小于等于结束时间');
return false;
}
}
window.location.href = url;
});
function checkEndTime(startTime,endTime){
if(startTime==''){
layer.msg('请选择起始时间',
{time: 1000,
});;exit;
}
if(endTime==''){
layer.msg('请选择结束时间',
{time: 1000,
});;exit;
}
var start=new Date(startTime.replace("-", "/").replace("-", "/"));
var end=new Date(endTime.replace("-", "/").replace("-", "/"));
if(end<start){
layer.msg('结束时间要小于起始时间',
{time: 1000,
});;exit;
}
}
$(".paixu").click(function(){
var that=$(this);
$data_order=that.attr('data-order');
$order_type='{$userarpu_order}';
if($order_type==''||$order_type=='4'){
$(".sortBy").attr('name','data_order');
val='3,'+$data_order;
$(".sortBy").attr('value',val);
$("#searchlayer").click();
}else if($order_type=='3'){
$(".sortBy").attr('name','data_order');
val='4,'+$data_order;
$(".sortBy").attr('value',val);
$("#searchlayer").click();
var that = $(this);
var sortBy = $('#sort_by');
var sortColumn = $('#sort_column');
var dataOrder = that.attr('data-order');
var orderType = parseInt(sortBy.val());
if (dataOrder === sortColumn.val()) {
if (orderType === 1) {
orderType = 2;
} else {
orderType = 1;
}
} else {
orderType = 1;
}
sortBy.val(orderType);
sortColumn.val(dataOrder);
$("#search").click();
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#searchlayer").click();
}
});
//点击排序
$('.list_sort').click(function(){
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if(ids.length > 0){
var str = new Array();
ids.each(function(){
str.push($(this).val());
});
param = str.join(',');
}
if(url != undefined && url != ''){
window.location.href = url.replace(".html","") + '/ids/' + param;
$("#search").click();
}
});
var date="{$setdate}";
@ -569,7 +355,7 @@
scrollInput:false,
endDate:date
})
$('#stime-start').datetimepicker({
$('#create_time').datetimepicker({
format: 'yyyy-mm-dd',
language:"zh-CN",
minView:2,
@ -579,78 +365,8 @@
scrollInput:false,
endDate:date
});
$('#sdatetimepicker').datetimepicker({
format: 'yyyy-mm-dd',
language:"zh-CN",
minView:2,
autoclose:true,
scrollMonth:false,
scrollTime:false,
scrollInput:false,
pickerPosition:'bottom-left',
endDate:date
})
$('#game').on('click',function(event) {
var navlist = $(this).find('.nav-list');
if (navlist.hasClass('hidden')) {
navlist.removeClass('hidden');
$(this).find('.sort-txt').focus().val('');
} else {
navlist.addClass('hidden');
}
$(document).one('click', function(){
navlist.addClass('hidden');
});
event.stopPropagation();
});
$('#game .sort-txt').on('keyup',function(event) {
var val = $.trim($(this).val()).toLowerCase();
$('#game').siblings('input').val(val);
});
$('#game .nav-list').find("a").each(function(){
var that = $('#game');
$(this).click(function(){
var text = $.trim($(this).text()).toLowerCase();
that.find('.sort-txt').val(text);
that.siblings('input').val(text);
})
});
$('#promote').on('click',function(event) {
var navlist = $(this).find('.nav-list');
if (navlist.hasClass('hidden')) {
navlist.removeClass('hidden');
$(this).find('.sort-txt').focus().val('');
} else {
navlist.addClass('hidden');
}
$(document).one('click', function(){
navlist.addClass('hidden');
});
event.stopPropagation();
});
$('#promote .sort-txt').on('keyup',function(event) {
var val = $.trim($(this).val()).toLowerCase();
$('#promote').siblings('input').val(val);
});
$('#promote .nav-list').find("a").each(function(){
var that = $('#promote');
$(this).click(function(){
var text = $.trim($(this).text()).toLowerCase();
that.find('.sort-txt').val(text);
that.siblings('input').val(text);
})
});
})
function detailsInfo(promote_id,create_time){
layer.open({
type: 2,
@ -661,5 +377,108 @@
content: '/admin.php?s=/Query/details/promote_id/'+promote_id+'/create_time/'+ create_time //iframe的url
});
}
$('#withdraw').click(function (e) {
var beginTime = $('#time-start').val();
var endTime = $('#time-end').val();
var promoteId = parseInt($('#promote_id').val());
var balance = parseFloat("{$zTotal}");
var msg = "收益结算时间:" + $('#time-start').val() + " 至 " + $('#time-end').val();
msg += "<br>";
msg += "提现金额:{$zTotal}元";
if (Date.parse(beginTime) / 1000 > Date.parse(endTime) / 1000) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
if (promoteId <= 0) {
layer.msg('请选择会长账号');
return false;
}
if (balance < 100) {
layer.msg('累计结算低于100元无法提现', {icon: 5});
return false;
}
layer.confirm(msg, {
title: '信息',
btn: ['提交', '取消'],
}, function (index) {
layer.close(index);
layer.load(0, {shade: [0.7, '#393D49']}, {shadeClose: true});
$.ajax({
type: 'post',
url: '{:U("settlementWithdraw")}',
dataType: 'json',
data: {'begin_time': beginTime, 'end_time': endTime, 'promote_id': promoteId},
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg, {icon: 1});
setTimeout(function(){
window.location.reload();
},2000);
} else {
layer.msg(data.msg, {icon: 5});
}
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
});
});
$('.renew-review').click(function () {
var id = parseInt($(this).attr('data-id'));
$.ajax({
type: 'post',
url: '{:U("renewReview")}',
dataType: 'json',
data: {id:id},
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg, {icon: 1});
setTimeout(function(){
window.location.reload();
},2000);
} else {
layer.msg(data.msg, {icon: 5});
}
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
});
$('.cancel-withdraw').click(function () {
var id = parseInt($(this).attr('data-id'));
var msg = "确定要撤销提现吗?";
layer.confirm(msg, {
title: '提示',
btn: ['确定', '取消'],
}, function () {
$.ajax({
type: 'post',
url: '{:U("cancelWithdraw")}',
dataType: 'json',
data: {id:id},
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg, {icon: 1});
setTimeout(function(){
window.location.reload();
},2000);
} else {
layer.msg(data.msg, {icon: 5});
}
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
});
});
</script>
</block>

@ -78,13 +78,21 @@
<input type="text" name="widthdraw_number" class="" value="{:I('widthdraw_number')}" placeholder="提现单号">
</div>
<div class="input-list">
<select name="ti_status">
<select name="ti_status" class="select_gallery">
<option value="">提现状态</option>
<?php foreach (promoteWithdrawStatus() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<select name="op_type" class="select_gallery">
<option value="">操作人类型</option>
<?php foreach (getPromoteWithdrawOpType() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/withdraw','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
@ -106,9 +114,15 @@
<input class="check-all" type="checkbox">
</th>
<th>提现单号</th>
<th ><a class="paixu" data-order='sum_money'>提现金额</a></th>
<th><a class="paixu" data-order='sum_money'>提现金额</a></th>
<th>推广员账号</th>
<th ><a class="paixu" data-order='create_time'>申请时间</a></th>
<th>操作人</th>
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>结算开始时间</th>
<th>结算截止时间</th>
<th><a class="paixu" data-order='create_time'>申请时间</a></th>
<th>提现状态</th>
<th>说明</th>
<th>审核时间</th>
@ -142,8 +156,30 @@
{:encryptStr(get_promote_name($data['promote_id']))}
</if>
</td>
<td>
<if condition="$data.op_type eq 1">
{:get_promote_name($data['op_id'])}
<elseif condition="$data.op_type eq 2"/>
{:getAdminNickname($data['op_id'])}
<else/>
自动
</if>
</td>
<td>{:getPromoteWithdrawOpType($data['op_type'])}</td>
<td>
<if condition="$data.last_op_type eq 1">
{:get_promote_name($data['last_op_id'])}
<elseif condition="$data.last_op_type eq 2"/>
{:getAdminNickname($data['last_op_id'])}
<else/>
自动
</if>
</td>
<td>{:getPromoteWithdrawOpType($data['last_op_type'])}</td>
<td><notempty name="data.settlement_begin_time">{$data.settlement_begin_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>
<td><notempty name="data.settlement_end_time">{$data.settlement_end_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>
<td><notempty name="data.create_time">{$data.create_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>
<td>{:promoteWithdrawStatus($data['status'])}</td>
<td><span <if condition="$data['status'] == -2">style="color: #999;"</if>>{:promoteWithdrawStatus($data['status'])}</span></td>
<td>{$data.respond}</td>
<td><notempty name="data.audit_time">{$data.audit_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>
<td>
@ -161,7 +197,7 @@
</empty>
<tr class="data_summary">
<td>汇总</td>
<td colspan="11">当页提现:{:null_to_0(array_sum(array_column(arrayPromoteWithdrawStatus('status','',$list_data),'sum_money')))}元 今日提现:{:null_to_0(floor($ttotal*100)/100)}元 昨日提现:{:null_to_0(floor($ytotal*100)/100)}元 累计提现:{:null_to_0(floor($total*100)/100)}元</td>
<td colspan="99">当页提现:{:null_to_0(array_sum(array_column(arrayPromoteWithdrawStatus('status','',$list_data),'sum_money')))}元 今日提现:{:null_to_0(floor($ttotal*100)/100)}元 昨日提现:{:null_to_0(floor($ytotal*100)/100)}元 累计提现:{:null_to_0(floor($total*100)/100)}元</td>
</tr>
</tbody>
</table>

@ -1430,6 +1430,7 @@ if (!function_exists('dd')) {
function promoteWithdrawStatus($status = null)
{
$statusData = [
-2 => '已撤销',
-1 => '审核未通过',
0 => '待审核',
1 => '汇款中',
@ -1443,3 +1444,22 @@ function promoteWithdrawStatus($status = null)
return $statusData;
}
//获取提现操作人类型
function getPromoteWithdrawOpType($opType = null)
{
if ($opType) {
return Admin\Model\WithdrawModel::$opTypeList[$opType] ?? '未知';
} else {
return Admin\Model\WithdrawModel::$opTypeList;
}
}
//获取管理员账号
function getAdminNickname($adminId)
{
$adminId = intval($adminId);
if ($adminId) {
return M('member')->where(array('id' => $adminId))->getField('nickname');
}
return '未知';
}

@ -284,6 +284,7 @@ class FinanceController extends BaseController
//提现
public function withdraw()
{
$this->error('无法执行此操作');
//是否是会长
$this->purview();
//验证安全密码
@ -414,7 +415,7 @@ class FinanceController extends BaseController
}
}
$data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond,transfer_proof')
$data = $model->field('id, widthdraw_number, create_time, settlement_begin_time, settlement_end_time, sum_money, status, respond, transfer_proof, op_id, op_type, last_op_id, last_op_type')
->where($map)
->order('id desc')
->page($page, $row)
@ -426,8 +427,13 @@ class FinanceController extends BaseController
if (!empty($data)) {
foreach ($data as &$list) {
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
$list['settlement_begin_time'] = $list['settlement_begin_time'] ? date('Y-m-d H:i:s', $list['settlement_begin_time']) : '--';
$list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']);
$list['status_name'] = FinanceController::$withdrawStatus[$list['status']];
$list['op_id'] = $this->getOpIdByType($list['op_id'], $list['op_type']);
$list['last_op_id'] = $this->getOpIdByType($list['last_op_id'], $list['last_op_type']);
$list['op_type'] = getPromoteWithdrawOpType($list['op_type']);
$list['last_op_type'] = getPromoteWithdrawOpType($list['last_op_type']);
switch ($list['status']) {
case -2:
$list['status_name'] = '<span style="color: #bbbaba;">' . $list['status_name'] . '</span>';
@ -454,6 +460,23 @@ class FinanceController extends BaseController
$this->display();
}
private function getOpIdByType($opId, $opType)
{
switch ($opType) {
case 1:
$opId = get_promote_name($opId);
break;
case 2:
$opId = getAdminNickname($opId);
break;
case 3:
$opId = '自动';
break;
}
return $opId;
}
//提现明细
public function withdrawDtl()
{
@ -584,6 +607,7 @@ class FinanceController extends BaseController
//审核拒绝 重新审核
public function renewReview()
{
$this->error('无法执行此操作');
//是否是会长
$this->purview();
//验证安全密码
@ -624,6 +648,7 @@ class FinanceController extends BaseController
//撤销提现
public function cancelWithdraw()
{
$this->error('无法执行此操作');
//是否是会长
$this->purview();
//验证安全密码

@ -35,7 +35,7 @@
</ul>
</div>
<div style="margin-top: 2.4vh;">
<button class="withdraw" id="withdraw">提现</button>
<!-- <button class="withdraw" id="withdraw">提现</button>-->
</div>
<div class="page-list promote-index-list promote-index-list-news">
<div class="trunk-title-main"><span>{$meta_title}</span></div>

@ -149,7 +149,12 @@
<tr class="odd">
<th>提现订单</th>
<th>提现日期</th>
<th>结算开始日期</th>
<th>结算截止日期</th>
<th>操作人</th>
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>收益金额</th>
<th>实际提现金额</th>
<th>提现状态</th>
@ -168,7 +173,12 @@
<tr class="num2">
<td>{$vo.widthdraw_number}</td>
<td>{$vo.create_time}</td>
<td>{$vo.settlement_begin_time}</td>
<td>{$vo.settlement_end_time}</td>
<td>{$vo.op_id}</td>
<td>{$vo.op_type}</td>
<td>{$vo.last_op_id}</td>
<td>{$vo.last_op_type}</td>
<td>{$vo.sum_money}</td>
<td>{$vo.sum_money}</td>
<td>{$vo.status_name}</td>
@ -178,11 +188,11 @@
<if condition="$vo['status'] eq 2">
<a data-href="{:U('download/Remittancecer',['id'=>$vo['id']])}" class="ajax-get">汇款证明</a>
<elseif condition="$vo['status'] eq -1"/>
<span class="renew-review" data-id="{$vo['id']}" style="color: #0bb20c;cursor: pointer;">重新审核</span>
<!-- <span class="renew-review" data-id="{$vo['id']}" style="color: #0bb20c;cursor: pointer;">重新审核</span>-->
</if>
<a href="{:U('settlementOrder', array('id'=>$vo['id']))}">结算单</a>
<if condition="$vo['status'] eq -1 or $vo['status'] eq 0">
<span class="cancel-withdraw" data-id="{$vo['id']}" style="color: red;cursor: pointer;">撤销提现</span>
<!-- <span class="cancel-withdraw" data-id="{$vo['id']}" style="color: red;cursor: pointer;">撤销提现</span>-->
</if>
</td>
</tr>

@ -915,4 +915,16 @@ ADD COLUMN `beta_url` varchar(150) NOT NULL DEFAULT '' COMMENT 'Beta链接';
-- 游戏支付方式渠道配置
ALTER TABLE `tab_game`
ADD COLUMN `pay_config` varchar(255) NOT NULL COMMENT '支付渠道 wx 微信 zfb 支付宝 quick 快捷 (gf 官方 sq 双乾';
ADD COLUMN `pay_config` varchar(255) NOT NULL COMMENT '支付渠道 wx 微信 zfb 支付宝 quick 快捷 (gf 官方 sq 双乾';
-- 2019-12-30
-- 会长管理后台提现 cxj
ALTER TABLE `tab_withdraw`
ADD COLUMN `settlement_begin_time` int(10) NOT NULL DEFAULT 0 COMMENT '结算开始时间' AFTER `old_promote_account`;
ALTER TABLE `tab_withdraw`
ADD COLUMN `op_id` int(11) NOT NULL DEFAULT 0 COMMENT '操作id';
ALTER TABLE `tab_withdraw`
ADD COLUMN `op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '操作人1-推广员 2-管理员 3-自动';
ALTER TABLE `tab_withdraw`
ADD COLUMN `last_op_id` int(11) NOT NULL DEFAULT 0 COMMENT '最后操作人id',
ADD COLUMN `last_op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '最后操作人1-推广员 2-管理员 3-自动';
Loading…
Cancel
Save