master
chenxiaojun 5 years ago
parent 631c23568d
commit 89965bd8fb

@ -38,12 +38,16 @@ class PromoteGameRatioController extends ThinkController
}
$field = 'create_time, update_time';
$promoteGameRatios = D(self::MODEL_NAME)->field($field, true)
$query = D(self::MODEL_NAME)->field($field, true)
->where($map)
->page($page, $row)
->order('update_time desc, id desc')
->select();
$count = D(self::MODEL_NAME)->where($map)->count();
->order('update_time desc, id desc');
if (I('export', 0) != 1) {
$query->page($page, $row);
}
$promoteGameRatios = $query->select();
if (I('export', 0) != 1) {
$count = D(self::MODEL_NAME)->where($map)->count();
}
$records = [];
if ($promoteGameRatios) {
@ -89,7 +93,7 @@ class PromoteGameRatioController extends ThinkController
$thisGameRatio = $thisGameRatio ?? '0.00';
}
$records[] = [
$record = [
'id' => $promoteGameRatio['id'],
'promote_id' => $promoteGameRatio['promote_id'],
'promote_account' => $thisPromoteAccount,
@ -102,22 +106,50 @@ class PromoteGameRatioController extends ThinkController
'ratio' => $promoteGameRatio['ratio'] . '%',
'valid_date' => $validDate,
'remark' => $promoteGameRatio['remark'],
'status' => $promoteGameRatio['status'],
'status_text' => $thisStatusText,
'applicant' => $thisApplicant ?? '未知',
'reviewer' => $thisReviewer ?? '未知',
];
if (I('export', 0) != 1) {
$record['status'] = $promoteGameRatio['status'];
}
$records[] = $record;
}
}
$reviewRule = $this->getReviewRule();
if (I('export', 0) == 1) {
$field = [
'promote_id' => '会长Id',
'promote_account' => '会长账号',
'promote_mobile_phone' => '手机号码',
'promote_create_time' => '注册时间',
'promote_status_text' => '状态',
'promote_ver_status_text' => '身份状态',
'game_name' => '已申请游戏',
'last_ratio' => '原分成比例',
'ratio' => '当前分成比例',
'valid_date' => '开始时间',
'remark' => '备注',
'status_text' => '分成比例审核',
'applicant' => '申请人',
'reviewer' => '确认人',
];
data2csv($records,"公会分成管理", $field);
exit;
}
$reviewRule = $this->getReviewRule();
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$this->assign('records', $records);
$this->assign('count', $count);
$this->assign('gameList', getAllGameList());
$this->assign('promoteList', getPromoteByLevel(1));
$this->assign('statusList', self::$statusList);
$this->assign('reviewRule', $reviewRule);
$this->assign('is_admin', is_administrator());
$this->meta_title = '公会分成管理';
$this->display();
}

@ -35,6 +35,7 @@ class QueryController extends ThinkController
$row = intval(I('row', 10));
$group = I('group', 1);
$this->assign('group', $group);
$this->assign('is_admin', is_administrator());
$promoteId = I('promote_id', 0);
if ($group == 1) {
@ -76,20 +77,23 @@ class QueryController extends ThinkController
$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)
->order("{$order} {$orderType}");
if(I('export', 0) != 1){
$query->page($page, $row);
}
$records = M()->table($query->buildSql())
->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(I('export', 0) != 1){
$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);
@ -100,24 +104,40 @@ class QueryController extends ThinkController
}
$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(I('export', 0) == 1) {
$data = [];
foreach ($records as $value) {
$data[] = [
'promote_account' => $value['promote_account'],
'game_name' => $value['game_name'],
'sum_amount' => $value['sum_amount'],
'user_num' => $value['user_num'],
'type' => 'CPS',
'selle_ratio' => $value['selle_ratio'] . '%',
'settlement_amount' => $value['settlement_amount'],
];
}
$field = [
'promote_account' => '推广员账号',
'game_name' => '游戏名称',
'sum_amount' => '总充值',
'user_num' => '总注册',
'type' => '结算模式',
'selle_ratio' => '分成比例',
'settlement_amount' => '结算金额',
];
data2csv($data,"推广结算", $field);
exit;
}
if($page) {
$this->assign('_page', $page);
}
$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 = '推广结算';
@ -150,14 +170,18 @@ class QueryController extends ThinkController
$map['settlement_type'] = $settlementType;
}
$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, settlement_type')
->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')
$query = 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, settlement_type')
->where($map)
->count();
->order('create_time desc');
if(I('export', 0) != 1){
$query->page($page, $row);
}
$records = $query->select();
if(I('export', 0) != 1){
$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']) : '--';
@ -167,9 +191,53 @@ class QueryController extends ThinkController
if ($record['status'] == -2) {
$record['status_text'] = '<span style="color: #999;">' . $record['status_text'] . '</span>';
}
$record['op_id_text'] = $this->getOpTypeText($record['op_type'], $record['op_id']);
$record['last_op_id_text'] = $this->getOpTypeText($record['last_op_type'], $record['last_op_id']);
$record['op_type_text'] = getPromoteWithdrawOpType($record['op_type']);
$record['last_op_type_text'] = getPromoteWithdrawOpType($record['last_op_type']);
$record['settlement_type_text'] = getPromoteWithdrawSettlementType($record['settlement_type']);
}
}
if(I('export', 0) == 1) {
$data = [];
foreach ($records as $value) {
$data[] = [
'promote_account' => $value['promote_account'],
'widthdraw_number' => $value['widthdraw_number'],
'sum_money' => $value['sum_money'],
'op_id_text' => $value['op_id_text'],
'op_type_text' => $value['op_type_text'],
'last_op_id_text' => $value['last_op_id_text'],
'last_op_type_text' => $value['last_op_type_text'],
'settlement_type_text' => $value['settlement_type_text'],
'settlement_begin_time' => $value['settlement_begin_time'],
'settlement_end_time' => $value['settlement_end_time'],
'create_time' => $value['create_time'],
'status_text' => promoteWithdrawStatus($value['status']),
'respond' => $value['respond'],
];
}
$field = [
'promote_account' => '推广员账号',
'widthdraw_number' => '结算单号',
'sum_money' => '结算金额',
'op_id_text' => '操作人',
'op_type_text' => '操作人类型',
'last_op_id_text' => '最后操作人',
'last_op_type_text' => '最后操作人类型',
'settlement_type_text' => '提现模式',
'settlement_begin_time' => '结算开始时间',
'settlement_end_time' => '结算截止时间',
'create_time' => '提现时间',
'status_text' => '提现状态',
'respond' => '说明',
];
data2csv($data,"推广结算", $field);
exit;
}
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
@ -179,6 +247,21 @@ class QueryController extends ThinkController
}
}
private function getOpTypeText($type, $id)
{
switch ($type) {
case 1:
return get_promote_name($id);
break;
case 2:
return getAdminNickname($id);
break;
default:
return '自动';
break;
}
}
public function settlementWithdraw()
{
$beginTime = strtotime(I('begin_time', ''));
@ -868,6 +951,7 @@ class QueryController extends ThinkController
public function withdraw()
{
$page = I('p', 1);
$map['_string'] = '1=1';
$adminid = C('USER_ADMINISTRATOR');//获取超管id
$adminmobile = M('UcenterMember')->field('mobile')->find($adminid);
$this->assign('adminmobile', $adminmobile['mobile']);
@ -891,7 +975,6 @@ class QueryController extends ThinkController
}
} else {
$map['promote_id'] = array('gt', 0);
}
$order = 'create_time desc';
@ -905,6 +988,58 @@ class QueryController extends ThinkController
}
}
}
if (I('export', 0) == 1) {
$records = D('withdraw')->field('widthdraw_number, sum_money, promote_account, op_id, op_type, last_op_id, last_op_type, settlement_type, settlement_begin_time, settlement_end_time, create_time, status, respond, audit_time')
->where($map)
->order($order)
->select();
if (!empty($records)) {
$data = [];
foreach ($records as $record) {
$record['op_id_text'] = $this->getOpTypeText($record['op_type'], $record['op_id']);
$record['last_op_id_text'] = $this->getOpTypeText($record['last_op_type'], $record['last_op_id']);
$record['op_type_text'] = getPromoteWithdrawOpType($record['op_type']);
$record['last_op_type_text'] = getPromoteWithdrawOpType($record['last_op_type']);
$record['settlement_type_text'] = getPromoteWithdrawSettlementType($record['settlement_type']);
$data[] = [
'widthdraw_number' => $record['widthdraw_number'],
'sum_money' => $record['sum_money'],
'promote_account' => $record['promote_account'],
'op_id_text' => $this->getOpTypeText($record['op_type'], $record['op_id']),
'last_op_id_text' => $this->getOpTypeText($record['last_op_type'], $record['last_op_id']),
'op_type_text' => getPromoteWithdrawOpType($record['op_type']),
'last_op_type_text' => getPromoteWithdrawOpType($record['last_op_type']),
'settlement_type_text' => getPromoteWithdrawSettlementType($record['settlement_type']),
'settlement_begin_time' => $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--',
'settlement_end_time' => date('Y-m-d H:i:s', $record['settlement_end_time']),
'create_time' => date('Y-m-d H:i:s', $record['create_time']),
'status_text' => promoteWithdrawStatus($record['status']),
'respond' => $record['respond'],
'audit_time' => $record['audit_time'] ? date('Y-m-d H:i:s', $record['audit_time']) : '--',
];
}
$field = [
'widthdraw_number' => '结算单号',
'sum_money' => '结算金额',
'promote_account' => '推广员账号',
'op_id_text' => '操作人',
'op_type_text' => '操作人类型',
'last_op_id_text' => '最后操作人',
'last_op_type_text' => '最后操作人类型',
'settlement_type_text' => '提现模式',
'settlement_begin_time' => '结算开始时间',
'settlement_end_time' => '结算截止时间',
'create_time' => '申请时间',
'status_text' => '提现状态',
'respond' => '说明',
'audit_time' => '审核时间',
];
data2csv($data,"推广结算", $field);
exit;
}
}
$model = array(
'm_name' => 'withdraw',
'order' => $order,

@ -164,6 +164,15 @@
</div>
</div>
<div class="page">
<if condition="$is_admin eq true ">
<a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
</if>
{$_page|default=''}
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
@ -334,5 +343,10 @@ function refuse() {
$(".jsgamecheckall").click(function(){
$(this).closest('.jsgamecheckallbox').siblings("#game_list").find(".jsgameid").prop("checked", this.checked);
});
$(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
})
</script>
</block>

@ -163,7 +163,7 @@
</volist>
<tr class="data_summary">
<td>汇总</td>
<td colspan="10">当页结算:{$total}元 今日结算:{$tTotal}元 昨日结算:{$yTotal}元 累计结算:{$zTotal}元</td>
<td colspan="10">累计结算:{$zTotal}元</td>
</tr>
</empty>
</tbody>
@ -197,27 +197,11 @@
<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>{:getPromoteWithdrawSettlementType($record['settlement_type'])}</td>
<td>{$record.op_id_text}</td>
<td>{$record.op_type_text}</td>
<td>{$record.last_op_id_text}</td>
<td>{$record.last_op_type_text}</td>
<td>{$record.settlement_type_text}</td>
<td>{$record.settlement_begin_time}</td>
<td>{$record.settlement_end_time}</td>
<td>{$record.create_time}</td>
@ -242,18 +226,8 @@
</div>
<div class="page">
<if condition="$is_admin eq true ">
<if condition="I('group') eq 2 or $group eq 2">
<a class="sch-btn" href="{:U('Export/expUser',array(
'id'=>15,
'promote_id'=>I('promote_id'),
'timestart'=>I('timestart'),
'timeend'=>I('timeend'),
'start'=>I('start'),
'end'=>I('end'),
'settlement_number'=>I('settlement_number'),
'xlsname'=>'结算管理_推广结算_结算记录',
))}">导出</a>
</if>
<a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1, 'group' => I('group', 1)], I('get.')))}" target="_blank">导出</a>
</if>
{$_page|default=''}
</div>
@ -514,5 +488,10 @@
});
});
});
$(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
})
</script>
</block>

@ -207,7 +207,7 @@
</empty>
<tr class="data_summary">
<td>汇总</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>
<td colspan="99">累计提现:{:null_to_0(floor($total*100)/100)}元</td>
</tr>
</tbody>
</table>
@ -215,7 +215,8 @@
</div>
<div class="page">
<if condition="$is_admin eq true ">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>12,'xlsname'=>'结算管理_推广提现',),I('get.')))}">导出</a>
<a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
</if>
{$_page|default=''}
</div>
@ -334,6 +335,11 @@
content: '/admin.php?s=/Query/withdrawDetails/id/'+id+'' //iframe的url
});
}
$(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
})
</script>
<!--打款弹出层-->
<script type="text/javascript">

Loading…
Cancel
Save