新增内部公司部门查询

master
chenzhi 4 years ago
parent c36ce00b60
commit e274f863a8

@ -11,6 +11,11 @@ use User\Api\UserApi as UserApi;
*/
class StatementMangementController extends ThinkController
{
const INSIDE_COMPANY = [
"0"=>"其他",
"1"=>"市场部",
"2"=>"运营部"
];
public function lists() {
$map = [];
@ -298,20 +303,29 @@ class StatementMangementController extends ThinkController
$map .= " and rd.company_type = {$params['detail_company_type']} ";
}
// 判断公司
if (I('detail_company_id', -1) >= 0) {
$map .= " and rd.company_id = {$params['detail_company_id']} ";
// if (!empty($params['detail_company_name'])) {
// $map .= " and rd.company_name = '{$params['detail_company_name']}' ";
// }
}
if (!empty($params['detail_settlement_type'])) {
$map .= " and rd.settlement_type = {$params['detail_settlement_type']} ";
}
//按部门搜索
// if (!empty($params['detail_company_name'])) {
// $map .= " and rd.company_name like '%{$params['detail_company_name']}%' ";
// }
$selectCompanyId = true;
if(!empty($params['detail_company_type']) && $params['detail_company_type']== 3 && (I('detail_company_id', -1) >= 0)){
$detail_company_name = self::INSIDE_COMPANY[$params['detail_company_id']];
$map .= " and rd.company_name like '%{$detail_company_name}%' ";
$selectCompanyId = false;
}
if (!empty($params['detail_company_name'])) {
$map .= " and rd.company_name like '%{$params['detail_company_name']}%' ";
// 判断公司
if (I('detail_company_id', -1) >= 0 && $selectCompanyId) {
$map .= " and rd.company_id = {$params['detail_company_id']} ";
// if (!empty($params['detail_company_name'])) {
// $map .= " and rd.company_name = '{$params['detail_company_name']}' ";
// }
}
// 判断会长
@ -322,6 +336,7 @@ class StatementMangementController extends ThinkController
if (!empty($params['detail_promote_account_input'])) {
$map .= " and rd.promote_account like ('%{$params['detail_promote_account_input']}%') ";
}
// dd($map);
$result = SM('reward_record', 'tab_')->alias('r')
->field('r.id')
@ -330,6 +345,7 @@ class StatementMangementController extends ThinkController
->group('r.id')
->order('create_time DESC')
->select();
// dd(M()->getLastSql());
if ($result) {
$map = [];
@ -346,12 +362,13 @@ class StatementMangementController extends ThinkController
$list = SM('reward_record', 'tab_')->alias('r')
->field('
r.id, r.relation_game_id, r.settlement_time, r.confirm_time, r.content, r.reward_type, r.creater_id,is_verify,verify_detail,
r.id, r.relation_game_id, r.settlement_time, r.confirm_time, r.content, r.reward_type, r.creater_id,is_verify,verify_detail,IFNULL(pc.company_belong,0) company_belong,
rd.id as rid, rd.type as detail_type, rd.company_type as detail_company_type, rd.company_id as detail_company_id , rd.company_name as detail_company_name, rd.settlement_type as detail_settlement_type, rd.promote_account as detail_promote_account,rd.amount as detail_amount
')
->where($map)
->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT')
->order('create_time DESC')
->join('tab_promote_company as pc on rd.company_id =pc.id', 'LEFT')
->order('r.create_time DESC')
->select();
if ($list) {
$record = [];
@ -391,6 +408,7 @@ class StatementMangementController extends ThinkController
'company_name' => empty($item['detail_company_name']) && !empty($item['detail_company_id']) ? ($companys[$item['detail_company_type']][$item['detail_company_id']] ?? '无') : ($item['detail_company_name'] ?? '无'),
'amount' => $item['detail_type'] == RewardModel::REWARD_TYPE_PUNISH ? -$item['detail_amount'] : $item['detail_amount'],
'promote_account' => $item['detail_promote_account'] ?? '无',
'company_belong'=>$item['detail_company_type'] == 2 ? getCompanyBlong($item['company_belong']) : "无"
];
if ($item['detail_type'] == RewardModel::REWARD_TYPE_REWARD) {
$record[$item['id']]['totalReward'] += $item['detail_amount'];
@ -415,7 +433,6 @@ class StatementMangementController extends ThinkController
if(IS_SUBSITE) {
$this->assign("IS_SUBSITE",true);
}
// ksort($record);
$this->assign('list', $record);
$this->assign('promoters', array_column(SM('promote', 'tab_')->where(['level'=>1])->field('id, nickname, account')->select(), null, 'id'));
@ -944,6 +961,14 @@ class StatementMangementController extends ThinkController
$data = SM('partner', 'tab_')->field('id, partner as name')->select();
} elseif ($type == 0) {
$data = [];
} elseif ($type == 3){
$data = [];
foreach (self::INSIDE_COMPANY as $key => $value) {
$data[] = [
"id"=>$key,
"name"=>$value
];
}
} else {
$data = SM('promote_company', 'tab_')->field('id, company_name as name')->select();
}

@ -194,6 +194,7 @@
<!-- 惩罚方 -->
<th>奖惩类别</th>
<th>结算公司类型</th>
<th>结算公司归属</th>
<th style="width: 100px;">结算方</th>
<th>会长账号</th>
<th>奖惩金额</th>
@ -202,6 +203,7 @@
<!-- 奖励方 -->
<th>奖惩类别</th>
<th>结算公司类型</th>
<th>结算公司归属</th>
<th style="width: 100px;">结算方</th>
<th>会长账号</th>
<th>奖惩金额</th>
@ -277,6 +279,7 @@
<td rowspan="{$data['maxCount']}">{$data['reward_type_text']}</td>
<td rowspan="{$data['maxCount']}">惩罚方</td>
<td><?=$data['detail'][2][$i]['company_type_text'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['company_belong'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['company_name'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['promote_account'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['amount'] ?? '无'?></td>
@ -284,6 +287,7 @@
<td rowspan="{$data['maxCount']}">奖励方</td>
<td><?=$data['detail'][1][$i]['company_type_text'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['company_belong'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['company_name'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['promote_account'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['amount'] ?? '无'?></td>
@ -308,12 +312,14 @@
<?php else:?>
<tr>
<td><?=$data['detail'][2][$i]['company_type_text'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['company_belong'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['company_name'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['promote_account'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['amount'] ?? '无'?></td>
<td><?=$data['detail'][2][$i]['settlement_type_text'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['company_type_text'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['company_belong'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['company_name'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['promote_account'] ?? '无'?></td>
<td><?=$data['detail'][1][$i]['amount'] ?? '无'?></td>
@ -325,9 +331,9 @@
</volist>
</notemtpy>
<tr>
<td colspan="11" class="text-center">合计</td>
<td colspan="12" class="text-center">合计</td>
<td class="text-center" id="total_reward">-{:array_sum(array_column($list, 'totalPunish'))}</td>
<td colspan="5" class="text-center">合计</td>
<td colspan="6" class="text-center">合计</td>
<td class="text-center" id="total_punish">{:array_sum(array_column($list, 'totalReward'))}</td>
<td colspan="4" class="text-center"></td>
</tr>
@ -476,18 +482,20 @@
$('#detail_company_name').attr('disabled', true).hide();
//var companyType = $('#form-company-type').val();
// 如果公司类型为内部的时候,公司部门仅其他
if (companyType == 3) {
var companyData = "<option value='-1'>请选择公司/部门</option>";
$('#detail_company_id').html(companyData);
$('#detail_company_name').attr('disabled', false).show();
//$("#detail_company_name").attr("readonly",false)
$('#detail_company_id').change();
} else {
// if (companyType == 3) {
// var companyData = "<option value='-1'>请选择公司/部门</option>";
// $('#detail_company_id').html(companyData);
// $('#detail_company_name').attr('disabled', false).show();
// //$("#detail_company_name").attr("readonly",false)
// $('#detail_company_id').change();
// } else {
$.ajax({
url:"{:U('StatementMangement/getCompanys')}",
dataType:'JSON',
data: {'type':companyType},
success:function(response){
console.log(response)
console.log(defaultCompanyId)
var companyData = "<option value='-1'>请选择公司/部门</option>";
$.each(response.info, function(index, item){
if (defaultCompanyId == item.id) {
@ -502,7 +510,7 @@
$('#detail_company_id').change();
}
});
}
// }
}
companyTypeChange()

Loading…
Cancel
Save