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