汇总结算单管理

master
yulingwei 5 years ago
parent 47d01e0aff
commit 747bba16b0

@ -70,8 +70,15 @@ class MsgController extends ThinkController{
}
$look= $model->where(['id'=>$ids])->find();
switch($look['type']) {
case 1:
redirect("http://".$_SERVER['HTTP_HOST'] . '/admin.php?s=/Apply/and_lists/type/'.$look['sdk_version'].'/game_id/'.$look['game_id']);
break;
case 3:
redirect("http://".$_SERVER['HTTP_HOST'] . '/admin.php?s=/Settlement/sheetDetail/id/'.$look['game_id']);
break;
}

@ -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);
}

@ -58,7 +58,7 @@
<td>{$data.id}</td>
<td>
<eq name="data.status" value="2">
<a href="{:U('looktoread',array('ids'=>$data['id'],'type'=>2))}" class="msg_content_color msg_content_underline">
<a href="{:U('looktoread',array('ids'=>$data['id'],'type'=>$data['type']))}" class="msg_content_color msg_content_underline">
</eq>
{$data.content}
</a>

@ -81,7 +81,6 @@
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<p class="description_text">说明:该功能是用于录入工会所属的推广公司名称</p>
</div>
<div class="jssearch search_list fl cf">
@ -123,7 +122,18 @@
</div>
<?php if ($msg):?>
{$msg}
<div class="data_list data_game_list">
<div class="">
<table border="1">
<!-- 表头 -->
<thead>
<tr>
<th style="width:10%;min-width:150px;">{$msg}</th>
</tr>
</thead>
</table>
</div>
</div>
<?php elseif ($settlement_type == 1):?>
<span style="color: red;">上游-汇总结算单</span>
<div class="data_list data_game_list">
@ -235,7 +245,7 @@
<td rowspan="{:sizeof($item['channels'])}">{$item['bonuses']}</td>
<td rowspan="{:sizeof($item['channels'])}">{$item['total_amount']}</td>
<td rowspan="{:sizeof($item['channels'])}">{$item['settlement_contact']}</td>
<td>时间</td>
<td>{$item['time_start']} 至 {$item['time_end']}</td>
<td rowspan="{:sizeof($item['channels'])}">备注</td>
</tr>
<?php else :?>
@ -246,7 +256,7 @@
<td>{$channel['game_ratio']}%</td>
<td>{$channel['game_ratio_max']}%</td>
<td>{$channel['price']}</td>
<td>时间</td>
<td>{$item['time_start']} 至 {$item['time_end']}</td>
</tr>
<?php endif;?>
<?php endforeach;?>
@ -301,7 +311,7 @@
<td>{$channel['company_relation_name']}</td>
<td>{$channel['type_name']}</td>
<td>{$channel['relation_game_name']}</td>
<td >结算时间</td>
<td >{$item['time_start']} 至 {$item['time_end']}</td>
<td>{$channel['amount']}</td>
<td>{$channel['game_ratio']}%</td>
<td>{$channel['game_ratio_max']}%</td>
@ -320,7 +330,7 @@
<td>{$channel['company_relation_name']}</td>
<td>{$channel['type_name']}</td>
<td>{$channel['relation_game_name']}</td>
<td >结算时间</td>
<td >{$item['time_start']} 至 {$item['time_end']}</td>
<td>{$channel['amount']}</td>
<td>{$channel['game_ratio']}%</td>
<td>{$channel['game_ratio_max']}%</td>
@ -394,7 +404,7 @@
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('lists')}");
highlight_subnav("{:U('settlement/sheetList')}");
var data = {:json_encode($listData)};
$(function(){
//搜索功能

@ -197,7 +197,7 @@
<td rowspan="{:sizeof($item['channels'])}">{$item['bonuses']}</td>
<td rowspan="{:sizeof($item['channels'])}">{$item['total_amount']}</td>
<td rowspan="{:sizeof($item['channels'])}">{$item['settlement_contact']}</td>
<td>时间</td>
<td>{$item['time_start']} 至 {$item['time_end']}</td>
<td rowspan="{:sizeof($item['channels'])}">备注</td>
</tr>
<?php else :?>
@ -208,7 +208,7 @@
<td>{$channel['game_ratio']}%</td>
<td>{$channel['game_ratio_max']}%</td>
<td>{$channel['price']}</td>
<td>时间</td>
<td>{$item['time_start']} 至 {$item['time_end']}</td>
</tr>
<?php endif;?>
<?php endforeach;?>
@ -263,7 +263,7 @@
<td>{$channel['company_relation_name']}</td>
<td>{$channel['type_name']}</td>
<td>{$channel['relation_game_name']}</td>
<td >结算时间</td>
<td >{$channel['time_start']} 至 {$channel['time_end']}</td>
<td>{$channel['amount']}</td>
<td>{$channel['game_ratio']}%</td>
<td>{$channel['game_ratio_max']}%</td>
@ -282,7 +282,7 @@
<td>{$channel['company_relation_name']}</td>
<td>{$channel['type_name']}</td>
<td>{$channel['relation_game_name']}</td>
<td >结算时间</td>
<td >{$item['time_start']} 至 {$item['time_end']}</td>
<td>{$channel['amount']}</td>
<td>{$channel['game_ratio']}%</td>
<td>{$channel['game_ratio_max']}%</td>
@ -385,7 +385,7 @@
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('lists')}");
highlight_subnav("{:U('settlement/sheetList')}");
function auditSettlement(id, audit_type)
{

@ -73,6 +73,14 @@
<option value="2" <?php echo I('settlement_time_type') == 2 ? "selected" : "" ?> >月结</option>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="all_status" name="all_status" class="select_gallery">
<option value="">申请状态</option>
<option value="1" <?php echo I('all_status') == 1 ? "selected" : "" ?> >审核通过</option>
<option value="2" <?php echo I('all_status') == 2 ? "selected" : "" ?> >审核未通过</option>
<option value="3" <?php echo I('statall_statusus') == 3 ? "selected" : "" ?> >待审核</option>
</select>
</div>
<div class="input-list">
<input type="text" readonly id="create-time-start" name="create_time_start" class="" value="{:I('create_time_start')}"
placeholder="申请开始时间"/>
@ -125,7 +133,7 @@
<th>申请时间</th>
<th>申请人</th>
<th>审核状态</th>
<th>审核人</th>
<th>当前审核人</th>
<th>备注</th>
<th>操作</th>
</tr>
@ -149,7 +157,7 @@
<td>{$data.remark}</td>
<td>
<a href="{:U('settlement/sheetDetail',array('id'=>$data['id']))}">查看 </a>
<a class="ajax-get" href="{:U('Member/save_device_bans',array('id'=>$data['id']))}"></a>
<a class="ajax-get confirm" href="{:U('settlement/generateSettlementSheet',array('id'=>$data['id'], 'delete'=>1))}"></a>
</td>
</tr>
</volist>

@ -1244,7 +1244,8 @@ ALTER TABLE `tab_promote_company`
ADD COLUMN `is_sign_contact` tinyint(3) NOT NULL DEFAULT 0 COMMENT '是否签署合同:0-未签署 1-签署' AFTER `company_type`,
ADD COLUMN `company_belong` tinyint(1) UNSIGNED NOT NULL DEFAULT 3 COMMENT '工会归属0-内团1-外团 2-分发联盟 3 无' AFTER `is_sign_contact`,
ADD COLUMN `resources` VARCHAR(2000) NULL DEFAULT '' COMMENT '文档' AFTER `company_belong`;
-- 预付款预警
-- 2020-02-10 yulingwei 预付款预警
CREATE TABLE `tab_partner_divide_warn` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '公司预警表',
`partner_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '公司ID',
@ -1258,3 +1259,23 @@ CREATE TABLE `tab_partner_divide_warn` (
`operater_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作者ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
-- 2020-02-17 yulingwei 汇总结算单管理
CREATE TABLE `tab_settlement_sheet` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`orderid` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '0' COMMENT '订单ID (时间戳+adminid+4为随机数字)',
`settlement_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '结算类型 1 上游结算单 2 下游-内团结算单 3下游-外团结算单 4 下游-个人结算单',
`time_start` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '结算开始时间',
`time_end` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '结算结束时间',
`settlement_time_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '结算周期 1周结 2月结',
`settlement_sheet` json NOT NULL COMMENT '结算单',
`audit_users` json NOT NULL COMMENT '审核人员',
`remark` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '备注',
`audit_user` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '当前审核人',
`step` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '审核进度 123',
`status` tinyint(1) unsigned NOT NULL DEFAULT '3' COMMENT '订单审核状态 1审核通过 2审核未通过 3待审核通过',
`all_status` tinyint(1) unsigned NOT NULL DEFAULT '3' COMMENT '订单审核状态 1审核通过 2审核未通过 3待审核通过',
`creater_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '申请人',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Loading…
Cancel
Save