@ -1243,6 +1243,10 @@ class FinanceController extends ThinkController
$nowTime = date('Y-m-d');
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initEndTime = date('Y-m-d', time());
$sort = $_REQUEST['sort'];
if (empty($sort)) {
$sort = 13;
}
if(!empty($_REQUEST['user_account'])) {
$map['account'] = $_REQUEST['user_account'];
$map0['account'] = $_REQUEST['user_account'];
@ -1266,11 +1270,70 @@ class FinanceController extends ThinkController
$map['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
}
$datas = M('user', 'tab_')
->field('id, account')
->where($map0)
->page($page,$row)
->select();
$order = 'id desc';
if ($sort == 1) {
$order = 'spendvalue desc';
}
if ($sort == 2) {
$order = 'deposit desc';
}
if ($sort == 3 || $sort == 5) {
$order = 'spendvalue desc';
}
if ($sort == 4) {
$order = 'spendvalue asc';
}
if ($sort == 6) {
$order = 'deposit desc';
}
if ($sort == 7) {
$order = 'deposit asc';
}
if ($sort == 9) {
$order = 'promoteCoin desc';
}
if ($sort == 10) {
$order = 'promoteCoin asc';
}
if ($sort == 11) {
$order = 'id asc';
}
if ($sort == 12) {
$order = 'id desc';
}
$this->assign('sorting', $sort);
$map5['v.pay_type'] = 1;
$map5['v.create_time'] = $map['create_time'];
$map5[] = ['u.id = v.user_id'] ;
$map6[] = ['u.id = v.user_id'];
$map6['v.pay_type'] = 2;
$map6['v.create_time'] = $map['create_time'];
$map7[] = ['u.id = v.user_id'];
$map7['v.pay_type'] = 3;
$map7['v.create_time'] = $map['create_time'];
$valueQuery5 = M('value_detail_log', 'tab_')->alias('v')->field('sum(abs(v.value)) as spend_value')
->where($map5)->buildSql();
$valueQuery6 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value')
->where($map6)->buildSql();
$valueQuery7 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value')
->where($map7)->buildSql();
$datas = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin")->where($map0)->page($page,$row)->order($order)->group('u.id')->select();
// var_dump($datas);die();
// $datas = M('user', 'tab_')
// ->field('id, account')
// ->where($map0)
// ->page($page,$row)
// ->order('id desc')
// ->select();
$count = M('user', 'tab_')
->field('id, account')
->where($map)
@ -1285,30 +1348,38 @@ class FinanceController extends ThinkController
$account = $data['account'];
$allDatas[$key]['user_id'] = $id;
$allDatas[$key]['user_account'] = $account;
$map5['user_id'] = $id;
$map5['pay_type'] = 1;
$map5['create_time'] = $map['create_time'];
$spend = M('value_detail_log', 'tab_')->where($map5)->sum('value');
// $map5['user_id'] = $id;
// $map5['pay_type'] = 1;
// $map5['create_time'] = $map['create_time'];
// $spend = M('value_detail_log', 'tab_')->where($map5)->sum('value');
$spend = $data['spendvalue'];
if(empty($spend)) {
$spend = '0.00';
}else {
$spend = number_format(abs($spend),2,'.','');
}
$map6['user_id'] = $id;
$map6['pay_type'] = 2;
$map6['create_time'] = $map['create_time'];
$deposit = M('value_detail_log', 'tab_')->where($map6)->sum('value');
// $map6['user_id'] = $id;
// $map6['pay_type'] = 2;
// $map6['create_time'] = $map['create_time'];
// $deposit = M('value_detail_log', 'tab_')->where($map6)->sum('value');
$deposit = $data['deposit'];
if(empty($deposit)) {
$deposit = '0.00';
}
$map7['user_id'] = $id;
$map7['pay_type'] = 3;
$map7['create_time'] = $map['create_time'];
$promoteCoin = M('value_detail_log', 'tab_')->where($map7)->sum('value');
// $map7['user_id'] = $id;
// $map7['pay_type'] = 3;
// $map7['create_time'] = $map['create_time'];
// $promoteCoin = M('value_detail_log', 'tab_')->where($map7)->sum('value');
$promoteCoin = $data['promoteCoin'];
if(empty($promoteCoin)) {
$promoteCoin = '0.00';
}
$restValue = $data['restValue'];
if(empty($restValue)) {
$restValue = '0.00';
}
// $allDatas[$key]['bind_balance'] = $bind_balance;
$allDatas[$key]['rest_value'] = $deposit - $spend ;
$allDatas[$key]['spend_amount'] = $spend;
$allDatas[$key]['deposit_amount'] = $deposit;
$allDatas[$key]['coin_amount'] = $promoteCoin;