|
|
@ -374,11 +374,38 @@ class StatementMangementController extends ThinkController
|
|
|
|
->where($withdrawMap)
|
|
|
|
->where($withdrawMap)
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$statement = M('statement','tab_')
|
|
|
|
|
|
|
|
->field('ext_field')
|
|
|
|
|
|
|
|
->where(['ext_field'=>['like','%,%']])
|
|
|
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$withdrawData = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($statement as $key => $value) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$handleData = explode(',',$value['ext_field']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($handleData as $hk => $hv) {
|
|
|
|
|
|
|
|
array_push($withdrawData,$hv);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
$data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
|
|
|
|
|
|
|
|
$data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array($value['widthdraw_number'],$withdrawData)) {
|
|
|
|
|
|
|
|
unset($data[$key]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->assign('withdraw_data',$data);
|
|
|
|
$this->assign('withdraw_data',$data);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['withdraw']) {
|
|
|
|
if ($_REQUEST['withdraw']&&$data) {
|
|
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
|
|
|
@ -497,8 +524,272 @@ class StatementMangementController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
public function savePersonOrder() {
|
|
|
|
public function savePersonOrder() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// dump($_POST);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['statement_info'] = $_POST['statement_info'];
|
|
|
|
|
|
|
|
$data['first_party_info'] = json_encode([]);
|
|
|
|
|
|
|
|
$data['second_party_info'] = $_POST['second_party_info'];
|
|
|
|
|
|
|
|
$data['statement_begin_time'] = strtotime($_POST['time_start']);
|
|
|
|
|
|
|
|
$data['statement_end_time'] = strtotime($_POST['time_end']);
|
|
|
|
|
|
|
|
$data['create_time'] = time();
|
|
|
|
|
|
|
|
$data['statement_money'] = 0;
|
|
|
|
|
|
|
|
$data['pay_amount'] = 0;
|
|
|
|
|
|
|
|
$data['ext_field'] = '';
|
|
|
|
|
|
|
|
$data['company_name'] = '个人结账单';
|
|
|
|
|
|
|
|
$data['statement_type'] = 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($data['second_party_info'] == '[]' || $data['statement_info'] == '[]') {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'数据错误']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$statement_info = json_decode($data['statement_info'],true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($statement_info as $key => $value) {
|
|
|
|
|
|
|
|
$data['statement_money'] += $value['sum_amount'];
|
|
|
|
|
|
|
|
$data['pay_amount'] += $value['real_amount'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$second_party_info = json_decode($data['second_party_info'],true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($second_party_info as $key => $value) {
|
|
|
|
|
|
|
|
$data['ext_field'] = $data['ext_field'].$value['widthdraw_number'].',';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$is_exist = M('statement','tab_')->where(['ext_field'=>$data['ext_field'],'statement_type'=>2])->find();
|
|
|
|
|
|
|
|
if ($is_exist) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'请勿重复添加']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$is_save = M('statement','tab_')->add($data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($is_save) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'生成成功']);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'生成失败']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function PersonOrderEdit() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['time_start'] || $_REQUEST['time_end'] ) {
|
|
|
|
|
|
|
|
$withdrawMap = [];
|
|
|
|
|
|
|
|
if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) {
|
|
|
|
|
|
|
|
$withdrawMap['settlement_begin_time'] = ['egt',strtotime($_REQUEST['time_start'])];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) {
|
|
|
|
|
|
|
|
$withdrawMap['settlement_end_time'] = ['elt',strtotime($_REQUEST['time_end'])];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['time_start']&&$_REQUEST['time_end']) {
|
|
|
|
|
|
|
|
$withdrawMap['settlement_begin_time'] = ['egt',strtotime($_REQUEST['time_start'])];
|
|
|
|
|
|
|
|
$withdrawMap['settlement_end_time'] = ['elt',strtotime($_REQUEST['time_end'])];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = M('withdraw',"tab_")
|
|
|
|
|
|
|
|
->field("widthdraw_number,settlement_begin_time,settlement_end_time,settlement_type,promote_account")
|
|
|
|
|
|
|
|
->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id')
|
|
|
|
|
|
|
|
->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field")
|
|
|
|
|
|
|
|
->where("tab_promote_belong.company_type=2")
|
|
|
|
|
|
|
|
->where($withdrawMap)
|
|
|
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
// dump($data);die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $statement = M('statement','tab_')
|
|
|
|
|
|
|
|
// ->field('ext_field')
|
|
|
|
|
|
|
|
// ->where(['ext_field'=>['like','%,%']])
|
|
|
|
|
|
|
|
// ->select();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// $withdrawData = [];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// foreach($statement as $key => $value) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// $handleData = explode(',',$value['ext_field']);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// foreach ($handleData as $hk => $hv) {
|
|
|
|
|
|
|
|
// array_push($withdrawData,$hv);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
|
|
|
|
|
|
|
|
// $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (in_array($value['widthdraw_number'],$withdrawData)) {
|
|
|
|
|
|
|
|
// unset($data[$key]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
|
|
|
|
|
|
|
|
// $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assign('withdraw_data',$data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($_REQUEST['withdraw']&&$data) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['widthdraw_number'] = ['in',$_REQUEST['withdraw']];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = M('withdraw','tab_')
|
|
|
|
|
|
|
|
->field("tab_withdraw.id,pc.company_name,pc.id as cid,tab_withdraw.promote_id,tab_withdraw.promote_account,username,'个人' as type,game_ratio
|
|
|
|
|
|
|
|
,mobile_phone,real_name,tab_promote.bank_card,account_openin,tab_promote.address,bank_account")
|
|
|
|
|
|
|
|
->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id')
|
|
|
|
|
|
|
|
->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field")
|
|
|
|
|
|
|
|
->join("left join tab_promote on tab_promote.id=tab_promote_belong.promote_id")
|
|
|
|
|
|
|
|
->join("left join tab_promote_company as pc on pc.id = tab_promote.company_id")
|
|
|
|
|
|
|
|
->join("left join sys_ucenter_member on sys_ucenter_member.id=tab_promote.admin_id")
|
|
|
|
|
|
|
|
->where("tab_promote_belong.company_type=2")
|
|
|
|
|
|
|
|
->where($map)
|
|
|
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$game_ratio = [];
|
|
|
|
|
|
|
|
foreach($data as $dkey => &$dval) {
|
|
|
|
|
|
|
|
$gameStr = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rowspan = 0;
|
|
|
|
|
|
|
|
$dval['rowspan'] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dval['game_ratio'] = json_decode($dval['game_ratio'],true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_array($dval['game_ratio'])) {
|
|
|
|
|
|
|
|
foreach ($dval['game_ratio'] as $key => &$value) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($value as $k => &$v) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $v['game_id'] = $key;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$v['game_name'] = substr(get_gamename($key),0,strpos(get_gamename($key), '('));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!in_array($v['game_name'],$gameStr)) {
|
|
|
|
|
|
|
|
array_push($gameStr,$v['game_name']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// var_dump($key);
|
|
|
|
|
|
|
|
if (!$game_ratio[$v['game_name']]) {
|
|
|
|
|
|
|
|
$game_ratio[$v['game_name']] = $v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
$game_ratio[$v['game_name']]['sum_amount'] += $v['sum_amount'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($value[$k]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$value) {
|
|
|
|
|
|
|
|
unset($dval['game_ratio'][$key]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($dval['game_ratio'] as $key => $val) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$val[0]['reward'] = 0;
|
|
|
|
|
|
|
|
$val[0]['forfeit'] = 0;
|
|
|
|
|
|
|
|
$startTime = strtotime($val[0]['begin_time']);
|
|
|
|
|
|
|
|
$endTime = strtotime($val[0]['end_time']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rewardData = M('reward_record','tab_')
|
|
|
|
|
|
|
|
->field("sum(tab_reward_record.money) as money,reward_type,relation_game_name")
|
|
|
|
|
|
|
|
->join("left join (select * from tab_game group by relation_game_id)tab_game on tab_reward_record.relation_game_id=tab_game.relation_game_id")
|
|
|
|
|
|
|
|
->where(['company_type'=>2,'relation_game_name'=>['like',"%{$val[0]['game_name']}%"],'reward_time'=>['between',[$startTime,$endTime]]])
|
|
|
|
|
|
|
|
->group('reward_type')
|
|
|
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($rewardData as $rk => $rv) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($rv['reward_type'] == 1) {
|
|
|
|
|
|
|
|
$val[0]['reward'] = $rv['money'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$val[0]['forfeit'] = $rv['money'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($val as $k => &$v) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($game_ratio[$v['game_name']]) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$v['sum_amount'] = number_format($v['sum_amount'] + $game_ratio[$v['game_name']]['sum_amount'],2,'.','');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//计算结算金额
|
|
|
|
|
|
|
|
$val[0]['real_amount'] = number_format($val[0]['sum_amount'] * ($val[0]['selle_ratio']/100)+$val[0]['reward']-$val[0]['forfeit'],2,'.','');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rowspan++;
|
|
|
|
|
|
|
|
unset($dval['game_ratio'][$key]);
|
|
|
|
|
|
|
|
array_push($dval['game_ratio'],$val[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dval['rowspan'] = $rowspan;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assign('data',$data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function savePersonOrderEdit() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['statement_info'] = $_POST['statement_info'];
|
|
|
|
|
|
|
|
$data['first_party_info'] = json_encode([]);
|
|
|
|
|
|
|
|
$data['second_party_info'] = $_POST['second_party_info'];
|
|
|
|
|
|
|
|
$data['statement_begin_time'] = strtotime($_POST['time_start']);
|
|
|
|
|
|
|
|
$data['statement_end_time'] = strtotime($_POST['time_end']);
|
|
|
|
|
|
|
|
$data['create_time'] = time();
|
|
|
|
|
|
|
|
$data['statement_money'] = 0;
|
|
|
|
|
|
|
|
$data['pay_amount'] = 0;
|
|
|
|
|
|
|
|
$data['ext_field'] = '';
|
|
|
|
|
|
|
|
$data['company_name'] = '个人结账单';
|
|
|
|
|
|
|
|
$data['statement_type'] = 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($data['second_party_info'] == '[]' || $data['statement_info'] == '[]') {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'数据错误']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$statement_info = json_decode($data['statement_info'],true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($statement_info as $key => $value) {
|
|
|
|
|
|
|
|
$data['statement_money'] += $value['sum_amount'];
|
|
|
|
|
|
|
|
$data['pay_amount'] += $value['real_amount'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$second_party_info = json_decode($data['second_party_info'],true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($second_party_info as $key => $value) {
|
|
|
|
|
|
|
|
$data['ext_field'] = $data['ext_field'].$value['widthdraw_number'].',';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['ext_field'] = rtrim($data['ext_field'], ",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$is_save = M('statement','tab_')->where(['id'=>$_REQUEST['withdraw_id']])->save($data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($is_save) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'msg'=>'修改成功']);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'修改失败']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|