|
|
|
@ -19,13 +19,17 @@ class SettlementController extends ThinkController
|
|
|
|
|
if (I('creater_id')) {
|
|
|
|
|
$map['creater_id'] = I('creater_id');
|
|
|
|
|
}
|
|
|
|
|
if (I('all_status')) {
|
|
|
|
|
$map['all_status'] = I('all_status');
|
|
|
|
|
}
|
|
|
|
|
if (I('create_time_start')) {
|
|
|
|
|
$map['_string'] = "create_time >= ".strtotime(I('create_time_start'));
|
|
|
|
|
}
|
|
|
|
|
if (I('create_time_end')) {
|
|
|
|
|
$map['_string'] = "create_time <= ".strtotime(I('create_time_end'));
|
|
|
|
|
}
|
|
|
|
|
$list = M('settlement_sheet', 'tab_')->where($map)->page($p, $row)->select();
|
|
|
|
|
$login_uid = is_login();
|
|
|
|
|
$list = M('settlement_sheet', 'tab_')->where($map)->page($p, $row)->order("if (audit_user ={$login_uid}, 0,1 ) and status = 3, all_status desc, create_time desc")->select();
|
|
|
|
|
$count = M('settlement_sheet', 'tab_')->where($map)->count();
|
|
|
|
|
if (!empty($list)) {
|
|
|
|
|
foreach ($list as &$item) {
|
|
|
|
@ -79,11 +83,12 @@ class SettlementController extends ThinkController
|
|
|
|
|
// 生成结算单 月结算补点 周结不算
|
|
|
|
|
public function generateSettlementSheet($settlement_type = 0, $settlement_time_type = 0, $time_start=0, $time_end = 0, $delete=0, $id=0, $action='')
|
|
|
|
|
{
|
|
|
|
|
$msg = '';
|
|
|
|
|
$this->assign(I(''));
|
|
|
|
|
$this->assign('action', $action);
|
|
|
|
|
if ($delete) {
|
|
|
|
|
$res = M('settlement_sheet', 'tab_'->where(['id'=>$id]))->delete();
|
|
|
|
|
return $res ? $this->success('删除成功', true, true) : $this->success('删除失败', true, true);
|
|
|
|
|
$res = M('settlement_sheet', 'tab_')->where(['id'=>$id])->delete();
|
|
|
|
|
return $res ? $this->success('删除成功', '', true) : $this->success('删除失败', '', true);
|
|
|
|
|
}
|
|
|
|
|
$this->meta_title = '结算单管理';
|
|
|
|
|
if (empty($settlement_type)) {
|
|
|
|
@ -106,14 +111,19 @@ class SettlementController extends ThinkController
|
|
|
|
|
$time_start = strtotime($settlement_time);
|
|
|
|
|
$time_end = strtotime('+1 month', $time_start) - 1;
|
|
|
|
|
}
|
|
|
|
|
if ($time_end > time()) {
|
|
|
|
|
$msg = "结算结算时间无法大于当前时间";
|
|
|
|
|
}
|
|
|
|
|
if (empty($time_start) || empty($time_end)) {
|
|
|
|
|
$msg = '请选择正确的时间区间';
|
|
|
|
|
}
|
|
|
|
|
if (IS_GET) {
|
|
|
|
|
$msg = '';
|
|
|
|
|
|
|
|
|
|
// 判断结算时间是否冲突
|
|
|
|
|
|
|
|
|
|
$isExsist = M('settlement_sheet', 'tab_')->where(['settlement_type'=>$settlement_type, 'time_start'=>$time_start, 'time_end'=>$time_end, 'settlement_time_type'=>$settlement_time_type])->find();
|
|
|
|
|
if ($isExsist) {
|
|
|
|
|
$msg = "已存在此类型结算单";
|
|
|
|
|
}
|
|
|
|
|
// 生成结算单数据
|
|
|
|
|
$generate = false;
|
|
|
|
|
if (!$msg) {
|
|
|
|
@ -153,6 +163,8 @@ class SettlementController extends ThinkController
|
|
|
|
|
'fine'=>isset($reward[2]) ? $reward[2] : 0 ,
|
|
|
|
|
'channel_rate' => $item['channel_rate'], // 渠道费
|
|
|
|
|
'invoice_rate' => $item['invoice_rate'], // 税费
|
|
|
|
|
'time_start' => date('Y-m-d', $time_start),
|
|
|
|
|
'time_end' => date('Y-m-d', $time_end)
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$data = [];
|
|
|
|
@ -220,7 +232,9 @@ class SettlementController extends ThinkController
|
|
|
|
|
'bonuses'=>isset($reward[1]) ? $reward[1] : 0,
|
|
|
|
|
'fine'=>isset($reward[2]) ? $reward[2] : 0 ,
|
|
|
|
|
'settlement_contact' => $item['settlement_contact'],
|
|
|
|
|
'create_time' => time()
|
|
|
|
|
'create_time' => time(),
|
|
|
|
|
'time_start' => date('Y-m-d', $time_start),
|
|
|
|
|
'time_end' => date('Y-m-d', $time_end)
|
|
|
|
|
];
|
|
|
|
|
$list[$item['p_id']]['total_amount'] = $list[$item['p_id']]['bonuses'] - $list[$item['p_id']]['fine'];
|
|
|
|
|
}
|
|
|
|
@ -292,7 +306,9 @@ class SettlementController extends ThinkController
|
|
|
|
|
'settlement_contact' => $item['settlement_contact'],
|
|
|
|
|
'bank_card' => $item['bank_card'],
|
|
|
|
|
'bank_address' => $item['bank_address'],
|
|
|
|
|
'create_time' => time()
|
|
|
|
|
'create_time' => time(),
|
|
|
|
|
'time_start' => date('Y-m-d', $time_start),
|
|
|
|
|
'time_end' => date('Y-m-d', $time_end)
|
|
|
|
|
];
|
|
|
|
|
$list[$item['p_id']]['total_amount'] = $list[$item['p_id']]['bonuses'] - $list[$item['p_id']]['fine'];
|
|
|
|
|
}
|
|
|
|
@ -362,7 +378,16 @@ class SettlementController extends ThinkController
|
|
|
|
|
$data['time_end'] = $time_end;
|
|
|
|
|
$data['audit_users'] = json_encode($_POST['audit_users']);
|
|
|
|
|
$data['settlement_sheet'] = json_encode($_POST['settlement_sheet']);
|
|
|
|
|
$data['audit_user'] = $_POST['audit_users'][0];
|
|
|
|
|
$res = M('settlement_sheet', 'tab_')->add($data);
|
|
|
|
|
// 生成消息
|
|
|
|
|
$notice['user_id'] = $_POST['audit_users'][0];
|
|
|
|
|
$notice['content'] = "结算单汇总审核:有一个结算单待你审核,请尽快处理!";
|
|
|
|
|
$notice['type'] = 3;
|
|
|
|
|
$notice['status'] = 2;
|
|
|
|
|
$notice['create_time'] = time();
|
|
|
|
|
$notice['game_id'] = $res;
|
|
|
|
|
M('msg', 'tab_')->add($notice);
|
|
|
|
|
return $res ? $this->success('生成成功', true, true) : $this->error('生成失败', true, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -410,9 +435,26 @@ class SettlementController extends ThinkController
|
|
|
|
|
} else if ($arr_index + 1 == sizeof($info['audit_users']) && $info['status'] != 3) {
|
|
|
|
|
return $this->error('该结算单已经审核完毕', true, true);
|
|
|
|
|
}
|
|
|
|
|
$is_last = ($info['setp'] + 1 >= sizeof($info['audit_users']));
|
|
|
|
|
$update['remark'] = $remark;
|
|
|
|
|
$update['status'] = $audit_type == 1 ? 3 : 2;
|
|
|
|
|
$update['step'] = $audit_type == 1 ? $info['step'] + 1 : $info['step'];
|
|
|
|
|
$update['status'] = $audit_type == 1 ? ($is_last ? 1 : 3) : 2;
|
|
|
|
|
$update['step'] = ($audit_type == 1 && !$is_last) ? $info['step'] + 1 : $info['step'];
|
|
|
|
|
$update['audit_user'] = $login_uid;
|
|
|
|
|
if ($audit_type == 1 && $is_last) {
|
|
|
|
|
$update['all_status'] = 1;
|
|
|
|
|
} else if ($audit_type == 2) {
|
|
|
|
|
$update['all_status'] = 2;
|
|
|
|
|
}
|
|
|
|
|
// 通知审核
|
|
|
|
|
if ($update['status'] == 3 && !$is_last) {
|
|
|
|
|
$notice['user_id'] = $info['audit_users'][$info['step']];
|
|
|
|
|
$notice['content'] = "结算单汇总审核:有一个结算单待你审核,请尽快处理!";
|
|
|
|
|
$notice['type'] = 3;
|
|
|
|
|
$notice['status'] = 2;
|
|
|
|
|
$notice['create_time'] = time();
|
|
|
|
|
$notice['game_id'] = $id;
|
|
|
|
|
M('msg', 'tab_')->add($notice);
|
|
|
|
|
}
|
|
|
|
|
$upt = M('settlement_sheet', 'tab_')->where(['id'=>$id])->save($update);
|
|
|
|
|
return $upt ? $this->success('审核成功', true, true) : $this->error('审核失败', true, true);
|
|
|
|
|
}
|
|
|
|
|