|
|
|
@ -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,
|
|
|
|
|