|
|
|
@ -75,26 +75,18 @@ class SubSpendController extends ThinkController
|
|
|
|
|
unset($_REQUEST['merchant_id']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$marketAdminId = 0;
|
|
|
|
|
$isMarketAdmin = isMarketAdmin();
|
|
|
|
|
if ($isMarketAdmin) {
|
|
|
|
|
$userAuth = session('user_auth');
|
|
|
|
|
$marketAdminId = $userAuth['uid'];
|
|
|
|
|
} else {
|
|
|
|
|
$marketAdminId = I('market_admin_id', 0);
|
|
|
|
|
}
|
|
|
|
|
if ($marketAdminId > 0) {
|
|
|
|
|
$map['market_admin_id'] = $marketAdminId;
|
|
|
|
|
} else {
|
|
|
|
|
setPowerPromoteIds($map,'promote_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['promote_id'])) {
|
|
|
|
|
$promoteId = intval($_REQUEST['promote_id']);
|
|
|
|
|
if ($promoteId == 0) {
|
|
|
|
|
if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) {
|
|
|
|
|
$promoteId = I('promote_id',-1);
|
|
|
|
|
$companyId = I('company_id',-1);
|
|
|
|
|
if ($promoteId == 0 || $companyId == 0) {
|
|
|
|
|
$map['promote_id'] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$promoteMap['chain'] = ['like', "%/$promoteId/%"];
|
|
|
|
|
if($companyId != -1){
|
|
|
|
|
$promoteMap['company_id'] = $companyId;
|
|
|
|
|
}
|
|
|
|
|
if($promoteId != -1){
|
|
|
|
|
$promoteMap['chain'] = ['like', "%/$promoteId/%"];
|
|
|
|
|
}
|
|
|
|
|
$promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true);
|
|
|
|
|
$promoteIds[] = $promoteId;
|
|
|
|
|
$map['promote_id'] = ['in', $promoteIds];
|
|
|
|
@ -116,20 +108,7 @@ class SubSpendController extends ThinkController
|
|
|
|
|
$map['game_id'] = ['in',$game_id];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) {
|
|
|
|
|
// $map1 = $map;
|
|
|
|
|
// $map1['pay_status'] = 1;
|
|
|
|
|
// } else {
|
|
|
|
|
// $map = '1 = 2';
|
|
|
|
|
// $map1 = $map;
|
|
|
|
|
// }
|
|
|
|
|
// $this->checkListOrCountAuthRestMap($map,["extend", "pay_order_number", "user_account"]);
|
|
|
|
|
D("Spend")->addSubsiteWhere($map);
|
|
|
|
|
|
|
|
|
|
$map1 = $map;
|
|
|
|
|
$map1['pay_status'] = 1;
|
|
|
|
|
$total = null_to_0(M(self::model_name,"tab_")->where($map1)->sum('pay_amount'));
|
|
|
|
|
$this->assign('total', $total);
|
|
|
|
|
$this->meta_title = $this->m_title = '游戏充值';
|
|
|
|
|
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Spend/lists', 'status' => 1])->find());
|
|
|
|
|
|
|
|
|
@ -146,6 +125,10 @@ class SubSpendController extends ThinkController
|
|
|
|
|
$value['sdk_version_name'] = $game_arr[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promoteCompany = M('promote_company','tab_')->field('id, company_name as name')->where(['status' => 1])->select();
|
|
|
|
|
array_unshift($promoteCompany,['id'=>0,'name'=>C('OFFICIEL_CHANNEL')]);
|
|
|
|
|
$this->assign('promoteCompany', $promoteCompany);
|
|
|
|
|
|
|
|
|
|
$this->assign('showMarketAdmin', session('user_auth')['show_market_admin']);
|
|
|
|
|
$this->assign('showPromote', session('user_auth')['show_promote']);
|
|
|
|
@ -163,6 +146,257 @@ class SubSpendController extends ThinkController
|
|
|
|
|
$this->assign('menubtn',$this->menuAuth($is_sub_data));
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
public function exportList()
|
|
|
|
|
{
|
|
|
|
|
$xlsName = $_REQUEST['xlsname'];
|
|
|
|
|
$startDate = empty($_REQUEST['timestart']) ? date('Y-m-d', strtotime('-6 day', time())) : $_REQUEST['timestart'];
|
|
|
|
|
$endDate = empty($_REQUEST['timeend']) ? date('Y-m-d') : $_REQUEST['timeend'];
|
|
|
|
|
|
|
|
|
|
$startTime = strtotime($startDate);
|
|
|
|
|
$endTime = strtotime($endDate) + 86399;
|
|
|
|
|
$map['pay_time'] = array('BETWEEN', array($startTime, $endTime));
|
|
|
|
|
$is_sub_data = I("issubdata",0);
|
|
|
|
|
if($is_sub_data == 1){
|
|
|
|
|
$SpendModel = M("spend","tab_",SUBSITE_DB);
|
|
|
|
|
}else{
|
|
|
|
|
$SpendModel = M("spend","tab_");
|
|
|
|
|
}
|
|
|
|
|
unset($_REQUEST['timestart']);
|
|
|
|
|
unset($_REQUEST['timeend']);
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['user_account'])) {
|
|
|
|
|
$map['user_account'] = array('like', trim($_REQUEST['user_account']));
|
|
|
|
|
unset($_REQUEST['user_account']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['spend_ip'])) {
|
|
|
|
|
$map['spend_ip'] = array('like', trim($_REQUEST['spend_ip']) . '%');
|
|
|
|
|
unset($_REQUEST['spend_ip']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_name'])) {
|
|
|
|
|
if ($_REQUEST['game_name'] == '全部') {
|
|
|
|
|
unset($_REQUEST['game_name']);
|
|
|
|
|
} else {
|
|
|
|
|
$map['game_id'] = ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')];
|
|
|
|
|
unset($_REQUEST['game_name']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['game_type']) && $_REQUEST['game_type']) {
|
|
|
|
|
$map['sdk_version'] = $_REQUEST['game_type'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['server_id'])) {
|
|
|
|
|
$map['server_id'] = $_REQUEST['server_id'];
|
|
|
|
|
unset($_REQUEST['server_id']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['pay_order_number'])) {
|
|
|
|
|
$map['pay_order_number'] = array('like', trim($_REQUEST['pay_order_number']));
|
|
|
|
|
unset($_REQUEST['pay_order_number']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['extend'])) {
|
|
|
|
|
$map['extend'] = array('like', trim($_REQUEST['extend']));
|
|
|
|
|
unset($_REQUEST['extend']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['pay_status'])) {
|
|
|
|
|
$map['pay_status'] = $_REQUEST['pay_status'];
|
|
|
|
|
unset($_REQUEST['pay_status']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['pay_way'])) {
|
|
|
|
|
if ($_REQUEST['pay_way'] == 2) {
|
|
|
|
|
$map['pay_way'] = ['in', '2,3,4'];
|
|
|
|
|
} else {
|
|
|
|
|
$map['pay_way'] = $_REQUEST['pay_way'];
|
|
|
|
|
}
|
|
|
|
|
unset($_REQUEST['pay_way']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['is_check'])) {
|
|
|
|
|
$map['is_check'] = (int)($_REQUEST['is_check']);
|
|
|
|
|
unset($_REQUEST['is_check']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['merchant_id']) {
|
|
|
|
|
$map['merchant_id'] = $_REQUEST['merchant_id'];
|
|
|
|
|
unset($_REQUEST['merchant_id']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['pay_game_status'])) {
|
|
|
|
|
$map['pay_game_status'] = $_REQUEST['pay_game_status'];
|
|
|
|
|
unset($_REQUEST['pay_game_status']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) {
|
|
|
|
|
$promoteId = I('promote_id',-1);
|
|
|
|
|
$companyId = I('company_id',-1);
|
|
|
|
|
if ($promoteId == 0 || $companyId == 0) {
|
|
|
|
|
$map['promote_id'] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
if($companyId != -1){
|
|
|
|
|
$promoteMap['company_id'] = $companyId;
|
|
|
|
|
}
|
|
|
|
|
if($promoteId != -1){
|
|
|
|
|
$promoteMap['chain'] = ['like', "%/$promoteId/%"];
|
|
|
|
|
}
|
|
|
|
|
$promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true);
|
|
|
|
|
$promoteIds[] = $promoteId;
|
|
|
|
|
$map['promote_id'] = ['in', $promoteIds];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
|
|
$sort = $data_order == 3 ? 'desc' : 'asc';
|
|
|
|
|
$order = $data_order_type . ' ' . $sort;
|
|
|
|
|
} else {
|
|
|
|
|
$order = ' pay_time desc ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (I('platform_type', 0) != 0) {
|
|
|
|
|
$sy = I('platform_type', 0) == 1 ? '=' : '<>';
|
|
|
|
|
$game_id = M("Game","tab_")->where('unique_code ' . $sy . ' ""')->getField("id",true);
|
|
|
|
|
$map['game_id'] = ['in',$game_id];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) {
|
|
|
|
|
// $map1 = $map;
|
|
|
|
|
// $map1['pay_status'] = 1;
|
|
|
|
|
// } else {
|
|
|
|
|
// $map = '1 = 2';
|
|
|
|
|
// $map1 = $map;
|
|
|
|
|
// }
|
|
|
|
|
D("Spend")->addSubsiteWhere($map);
|
|
|
|
|
$map1 = $map;
|
|
|
|
|
$map1['pay_status'] = 1;
|
|
|
|
|
$total = $SpendModel->where($map1)->sum('pay_amount');
|
|
|
|
|
// var_dump($total);die();
|
|
|
|
|
$total=$total?$total:0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$headers = [
|
|
|
|
|
'pay_order_number' => '支付订单号',
|
|
|
|
|
'extend' => 'CP订单号',
|
|
|
|
|
'pay_time' => '充值时间',
|
|
|
|
|
'payed_time' => '支付时间',
|
|
|
|
|
'user_account' => '玩家账号',
|
|
|
|
|
'game_name' => '游戏名称',
|
|
|
|
|
'sdk_version' => '设备类型',
|
|
|
|
|
'game_id' => '所属CP',
|
|
|
|
|
'promote_account' => L('Subordinate_channel'),
|
|
|
|
|
'0 as company_name' => '所属推广公司',
|
|
|
|
|
'market_admin_id' => '所属市场专员',
|
|
|
|
|
'merchant_id' => '所属商户',
|
|
|
|
|
'spend_ip' => '充值ip',
|
|
|
|
|
'server_id' => '区服ID',
|
|
|
|
|
'server_name' => '游戏区服',
|
|
|
|
|
'game_player_id' => '角色ID',
|
|
|
|
|
'game_player_name' => '角色名称',
|
|
|
|
|
'cost' => '订单金额',
|
|
|
|
|
'pay_amount' => '实付金额',
|
|
|
|
|
'pay_way' => '充值方式',
|
|
|
|
|
'pay_status' => L('Order_status'),
|
|
|
|
|
'pay_game_status' => '游戏通知状态',
|
|
|
|
|
'is_check' => '是否参与结算',
|
|
|
|
|
'promote_id' => "消费"."{$total}",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$xlsCell = array_values($headers);
|
|
|
|
|
$fields = array_keys($headers);
|
|
|
|
|
// ----获取游戏的基本信息begin
|
|
|
|
|
//获取游戏公司
|
|
|
|
|
$cpCompanyDb = M("partner","tab_")->field("id,partner")->order("id asc")->select();
|
|
|
|
|
$cpCompany = [];
|
|
|
|
|
foreach ($cpCompanyDb as $index => $cp) {
|
|
|
|
|
$cpCompany[$cp['id']]=$cp['partner'];
|
|
|
|
|
}
|
|
|
|
|
unset($cpCompanyDb);
|
|
|
|
|
//获取所有游戏
|
|
|
|
|
$gameDb = M("Game","tab_")->field("id,relation_game_name,partner_id")->order("id asc")->select();
|
|
|
|
|
$gameInfo = [];
|
|
|
|
|
foreach ($gameDb as $index => $g) {
|
|
|
|
|
$partner_name = $cpCompany[$g['partner_id']];
|
|
|
|
|
$g['partner_name'] = $partner_name;
|
|
|
|
|
$gameInfo[$g['id']]=$g;
|
|
|
|
|
}
|
|
|
|
|
unset($cpCompany);
|
|
|
|
|
unset($gameDb);
|
|
|
|
|
// ----获取游戏的基本信息end
|
|
|
|
|
|
|
|
|
|
$csvFileName = $xlsName.'.csv';
|
|
|
|
|
//设置好告诉浏览器要下载excel文件的headers
|
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
|
|
|
header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
|
|
|
|
|
header('Expires: 0');
|
|
|
|
|
header('Cache-Control: must-revalidate');
|
|
|
|
|
header('Pragma: public');
|
|
|
|
|
$fp = fopen('php://output', 'a');//打开output流
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $xlsCell);
|
|
|
|
|
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
|
|
|
|
|
|
|
|
|
|
$accessNum = $SpendModel
|
|
|
|
|
->where($map)
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$perSize = 10000;//每次查询的条数
|
|
|
|
|
$pages = ceil($accessNum / $perSize);
|
|
|
|
|
|
|
|
|
|
// var_dump($count);die();
|
|
|
|
|
for($i = 1; $i <= $pages; $i++) {
|
|
|
|
|
$xlsData = $SpendModel
|
|
|
|
|
->field($fields)
|
|
|
|
|
->where($map)
|
|
|
|
|
->limit(($i-1)*$perSize ,$perSize)
|
|
|
|
|
->order($order ? $order : 'pay_time desc')
|
|
|
|
|
->select();
|
|
|
|
|
if ($showMarketAdmin == 1) {
|
|
|
|
|
$adminUsernameList = getAdminUsernameList(array_column($xlsData, 'market_admin_id'));
|
|
|
|
|
}
|
|
|
|
|
$promoters = D('Promote')->where(['id'=>['in', array_unique(array_column($xlsData, 'promote_id'))]])->field('id, company_id')->select();
|
|
|
|
|
$promoters = $promoters ? array_column($promoters, 'company_id', 'id') : [];
|
|
|
|
|
$companys = $promoters ? M('promote_company', 'tab_')->where(['id'=>['in', array_unique(array_values($promoters))]])->field('id, company_name')->select() : [];
|
|
|
|
|
$companys = $companys ? array_column($companys, 'company_name', 'id') : [];
|
|
|
|
|
|
|
|
|
|
foreach($xlsData as $value) {
|
|
|
|
|
//游戏信息匹配
|
|
|
|
|
$thisGameInfo = $gameInfo[$value["game_id"]];
|
|
|
|
|
$value['game_name'] =$thisGameInfo['relation_game_name'];
|
|
|
|
|
$value['sdk_version'] = $value['sdk_version'] == 1 ? "安卓" : "苹果";
|
|
|
|
|
$value['game_id'] = $thisGameInfo['partner_name'];
|
|
|
|
|
|
|
|
|
|
$value['is_check'] = D("Spend")::IsCheckStr[$value['is_check']];
|
|
|
|
|
|
|
|
|
|
$value['company_name'] = $promoters[$value['promote_id']] == 0 ? C('OFFICIEL_CHANNEL') : ($companys[$promoters[$value['promote_id']]] ?? '');
|
|
|
|
|
unset($value['promote_id']);
|
|
|
|
|
$value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']);
|
|
|
|
|
if($value['pay_status'] == 1) {
|
|
|
|
|
$value['payed_time'] = date('Y-m-d H:i:s',$value['payed_time']);
|
|
|
|
|
}else {
|
|
|
|
|
$value['payed_time'] = "------";
|
|
|
|
|
}
|
|
|
|
|
$value['merchant_id'] = getMerchantName($value['merchant_id']);
|
|
|
|
|
checkEncryptionAuth($value['user_account'],'spend_lists');
|
|
|
|
|
($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
|
|
|
|
|
$value['extend'] = $value['extend'].'`';
|
|
|
|
|
$value['pay_way'] = get_pay_way($value['pay_way']);
|
|
|
|
|
$value['pay_status'] = get_info_status($value['pay_status'],9);
|
|
|
|
|
$value['pay_game_status'] = get_info_status($value['pay_game_status'],14);
|
|
|
|
|
$value['market_admin_id'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $value);
|
|
|
|
|
fputcsv($fp, $value);
|
|
|
|
|
}
|
|
|
|
|
unset($xlsData);//释放变量的内存
|
|
|
|
|
//刷新输出缓冲到浏览器
|
|
|
|
|
ob_flush();
|
|
|
|
|
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
|
|
|
|
|
}
|
|
|
|
|
fclose($fp);
|
|
|
|
|
//操作日志
|
|
|
|
|
$GetData = $_GET;
|
|
|
|
|
unset($GetData['xlsname']);
|
|
|
|
|
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U('Spend/lists',$GetData),'menu'=>'充值-游戏订单-游戏充值-导出']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function menuAuth($is_sub_data = false)
|
|
|
|
|
{
|
|
|
|
@ -403,6 +637,10 @@ class SubSpendController extends ThinkController
|
|
|
|
|
if ($page) {
|
|
|
|
|
$data['page'] = $page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$total = null_to_0($SpendModel->where($map)->where("pay_status = 1")->sum('pay_amount'));
|
|
|
|
|
$this->assign('total', $total);
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|