管理后台>推广员>结算管理>公会分成管理--更新

master
chenxiaojun 5 years ago
parent 0fba64c6f1
commit 10665cc869

@ -706,16 +706,20 @@ function getPromoteAccount($promoteId)
return M('promote', 'tab_')->where($map)->getField('account');
}
//获取推广员列表 $level 0-全部
function getPromoteByLevel($level = 0)
//获取推广员列表 $level 0-全部 $companyId 推广公司 0-全部
function getPromoteByLevel($level = 0, $companyId = 0)
{
$field = 'id, account, real_name';
if ($level) {
$map['_string'] = '1 = 1';
if ($level > 0) {
$map['level'] = $level;
$promotes = M('promote', 'tab_')->field($field)->where($map)->select();
} else {
$promotes = M('promote', 'tab_')->field($field)->select();
}
if ($companyId > 0) {
$map['company_id'] = $companyId;
}
$promotes = M('promote', 'tab_')->field($field)->where($map)->select();
return $promotes;
}

@ -22,22 +22,44 @@ class PromoteGameRatioController extends ThinkController
{
$params = I('get.');
$group = $params['group'] ?? 1;
$companyId = $params['company_id'] ?? 0;
$companyBelong = $params['company_belong'] ?? '';
$promoteId = $params['promote_id'] ?? 0;
$gameId = $params['game_id'] ?? 0;
$gameTypeId = $params['game_type_id'] ?? 0;
$status = $params['status'] ?? '';
$page = $params['p'] ? intval($params['p']) : 1;
$row = $params['row'] ? intval($params['row']) : 10;
$map['_string'] = 'game_id = relation_game_id';
$where['_string'] = '1 = 1';
if ($companyId || ($companyBelong !== '' && in_array($companyBelong, [0, 1]))) {
$promoteMap['_string'] = '1 = 1';
if ($companyId) {
$promoteMap['company_id'] = $companyId;
}
if ($companyBelong !== '' && in_array($companyBelong, [0, 1])) {
$promoteMap['company_belong'] = $companyBelong;
}
$promoteIds = D('promote')->where($promoteMap)->getField('id', true);
$promoteIds = $promoteIds ?? [-1];
$where['promote_id'] = ['in', $promoteIds];
}
if ($promoteId) {
$map['promote_id'] = intval($promoteId);
}
if ($gameTypeId) {
$gameIds = D('game')->where(['game_type_id' => $gameTypeId])->getField('id', true);
$gameIds = $gameIds ?? [-1];
$where['game_id'] = ['in', $gameIds];
}
if ($gameId) {
$map['game_id'] = intval($gameId);
}
if ($status !== '') {
$map['status'] = intval($status);
}
$map['_complex'] = $where;
$field = 'create_time, update_time';
if ($group == 1) {
@ -68,8 +90,8 @@ class PromoteGameRatioController extends ThinkController
if ($promoteGameRatios) {
$promoteIds = array_column($promoteGameRatios, 'promote_id');
$gameIds = array_column($promoteGameRatios, 'game_id');
$promoteFiled = 'id, account, mobile_phone, create_time, status, ver_status';
$gameFiled = 'id, relation_game_name, ratio';
$promoteFiled = 'id, account, mobile_phone, create_time, status, ver_status, company_id, company_belong';
$gameFiled = 'id, relation_game_name, ratio, game_type_name';
$promotes = M('promote', 'tab_')->where(array('id' => ['in', $promoteIds]))->getField($promoteFiled, true);
$games = M('game', 'tab_')->where(array('id' => ['in', $gameIds]))->getField($gameFiled, true);
@ -83,14 +105,22 @@ class PromoteGameRatioController extends ThinkController
$thisPromoteCreateTime = '未知';
$thisPromoteStatus = '待审核';
$thisPromoteVerStatus = '未知';
$thisCompanyName = '未知';
$thisCompanyBelong = '未知';
$thisGameTypeName = '未知';
$thisGameName = '未知';
$thisGameRatio = '0.00%';
$thisLastRatio = $promoteGameRatio['last_ratio'] . '%';
$thisLastTurnoverRatio = $promoteGameRatio['last_turnover_ratio'] ? json_decode($promoteGameRatio['last_turnover_ratio'], true) : [];
$thisLastRatio = $thisLastTurnoverRatio ? "{$thisLastRatio} - " . $thisLastTurnoverRatio[count($thisLastTurnoverRatio) - 1]['ratio'] . '%' : $thisLastRatio;
$thisRatio = $promoteGameRatio['ratio'] . '%';
$thisTurnoverRatio = $promoteGameRatio['turnover_ratio'] ? json_decode($promoteGameRatio['turnover_ratio'], true) : [];
$thisRatio = $thisTurnoverRatio ? "{$thisRatio} - " . $thisTurnoverRatio[count($thisTurnoverRatio) - 1]['ratio'] . '%' : $thisRatio;
$thisTurnoverRatios = $promoteGameRatio['turnover_ratio'] ? json_decode($promoteGameRatio['turnover_ratio'], true) : [];
$thisRatioDtl = "默认:{$promoteGameRatio['ratio']}%";
if ($thisTurnoverRatios) {
$thisIntervalClosedStatusText = ($promoteGameRatio['interval_closed_status'] == 1 ? '≥' : '>');
foreach ($thisTurnoverRatios as $thisTurnoverRatio) {
$thisRatioDtl .= "<br>月流水{$thisIntervalClosedStatusText}{$thisTurnoverRatio['turnover']},比例:{$thisTurnoverRatio['ratio']}%";
}
}
$thisLastRatioStatus = $promoteGameRatio['last_ratio_status'];
$thisStatusText = self::$statusList[$promoteGameRatio['status']];
$thisStatusText = ($promoteGameRatio['status'] == -1) ? '<span style="color: red;">' . $thisStatusText . '</span>' : $thisStatusText;
@ -106,11 +136,14 @@ class PromoteGameRatioController extends ThinkController
$thisPromoteStatus = get_info_status($promotes[$thisPromoteId]['status'], 3);
$thisPromoteStatus = $thisPromoteStatus ?? '待审核';
$thisPromoteVerStatus = getPromoteVerStatus($promotes[$thisPromoteId]['ver_status'], 2);
$thisCompanyName = getPromoteCompanyName($promotes[$thisPromoteId]['company_id']);
$thisCompanyBelong = $promotes[$thisPromoteId]['company_belong'] == 1 ? '外团' : '内团';
}
if ($issetGame) {
$thisGameName = $games[$thisGameId]['relation_game_name'];
$thisGameRatio = $games[$thisGameId]['ratio'];
$thisGameRatio = ($thisGameRatio ?? '0.00') . '%';
$thisGameTypeName = $games[$thisGameId]['game_type_name'];
}
$record = [
@ -121,9 +154,12 @@ class PromoteGameRatioController extends ThinkController
'promote_create_time' => $thisPromoteCreateTime,
'promote_status_text' => $thisPromoteStatus,
'promote_ver_status_text' => $thisPromoteVerStatus,
'company_name' => $thisCompanyName,
'company_belong' => $thisCompanyBelong,
'game_name' => $thisGameName,
'game_type_name' => $thisGameTypeName,
'last_ratio' => (($thisLastRatioStatus == 1 || $group != 1) ? $thisLastRatio : $thisGameRatio),
'ratio' => $thisRatio,
'ratio_dtl' => $thisRatioDtl,
'valid_date' => $validDate,
'remark' => $promoteGameRatio['remark'],
'status_text' => $thisStatusText,
@ -158,16 +194,20 @@ class PromoteGameRatioController extends ThinkController
exit;
}
$gameTypelist = getGameTypes();
$companys = getPromoteCompanys();
$reviewRule = $this->getReviewRule();
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$this->assign('companys', $companys);
$this->assign('gameTypeList', $gameTypelist);
$this->assign('group', $group);
$this->assign('records', $records);
$this->assign('count', $count);
$this->assign('gameList', getAllGameList(true));
$this->assign('promoteList', getPromoteByLevel(1));
$this->assign('promoteList', getPromoteByLevel(1, intval(I('company_id', 0))));
$this->assign('statusList', self::$statusList);
$this->assign('reviewRule', $reviewRule);
$this->assign('is_admin', is_administrator());
@ -231,6 +271,7 @@ class PromoteGameRatioController extends ThinkController
}
}
$save['interval_closed_status'] = ($params['interval_closed_status'] ? ($params['interval_closed_status'] == 1 ? 1 : 2) : 1);
$save['ratio'] = $params['ratio'] ?? 0;
$save['begin_time'] = strtotime($params['begin_time']);
$save['end_time'] = $params['end_time'] ? (strtotime('+1 month', strtotime($params['end_time'])) - 1) : 0;
@ -243,8 +284,8 @@ class PromoteGameRatioController extends ThinkController
if (empty($promoteGameRatio)) {
$this->error('参数异常');
}
if ($promoteGameRatio['status'] == -1 || $save['begin_time'] != $promoteGameRatio['begin_time'] || $save['end_time'] != $promoteGameRatio['end_time'] || $save['ratio'] != $promoteGameRatio['ratio'] || $save['remark'] != $promoteGameRatio['remark'] || $save['turnover_ratio'] != $promoteGameRatio['turnover_ratio']) {
$this->isWithdraw($promoteGameRatio['promote_id'], $save['begin_time']);
if ($promoteGameRatio['status'] == -1 || $save['interval_closed_status'] != $promoteGameRatio['interval_closed_status'] || $save['begin_time'] != $promoteGameRatio['begin_time'] || $save['end_time'] != $promoteGameRatio['end_time'] || $save['ratio'] != $promoteGameRatio['ratio'] || $save['remark'] != $promoteGameRatio['remark'] || $save['turnover_ratio'] != $promoteGameRatio['turnover_ratio']) {
$this->isWithdraw($promoteGameRatio['promote_id'], $save['begin_time'], $save['end_time']);
if ($promoteGameRatio['status'] == 1) {
$save['last_turnover_ratio'] = $promoteGameRatio['turnover_ratio'];
@ -293,7 +334,7 @@ class PromoteGameRatioController extends ThinkController
$this->error('参数异常');
}
$this->isWithdraw($promoteId, $save['begin_time']);
$this->isWithdraw($promoteId, $save['begin_time'], $save['end_time']);
$map['promote_id'] = $promoteId;
$save['promote_id'] = $promoteId;
@ -329,6 +370,7 @@ class PromoteGameRatioController extends ThinkController
$params = I('get.');
$id = $params['id'] ?? 0;
$id = intval($id);
$companyId = 0;
$metaTitle = '游戏分成比例申请';
if ($id) {
$metaTitle .= '--修改';
@ -347,18 +389,30 @@ class PromoteGameRatioController extends ThinkController
$lastRatio = ($gameRatio ?? '0.00') . '%';
}
$companyId = $promoteGameRatio['company_id'];
$promoteGameRatio['company_id'] = D('promote')->where(['id' => $promoteGameRatio['promote_id']])->getField('company_id');
$this->assign('record', $promoteGameRatio);
$this->assign('lastRatio', $lastRatio);
}
$companys = getPromoteCompanys();
$this->assign('companys', $companys);
$this->assign('gameList', getAllGameList(true));
$this->assign('promoteList', getPromoteByLevel(1));
$this->assign('promoteList', getPromoteByLevel(1, $companyId));
$this->meta_title = $metaTitle;
$this->display();
}
}
private function isWithdraw($promoteId, $beginTime)
public function getPromotes()
{
$level = 1;
$companyId = intval(I('company_id', 0));
$promotes = getPromoteByLevel($level, $companyId);
$this->ajaxReturn($promotes);
}
private function isWithdraw($promoteId, $beginTime, $endTime)
{
$promote = M('promote', 'tab_')->find($promoteId);
if (empty($promote)) {
@ -370,11 +424,38 @@ class PromoteGameRatioController extends ThinkController
$withdrawMap['promote_id'] = $promoteId;
$withdrawMap['status'] = ['neq', -2];
if (empty($endTime)) {
$withdrawWhere['settlement_begin_time'] = ['egt', $beginTime];
$withdrawWhere['settlement_end_time'] = ['egt', $beginTime];
} else {
$withdrawWhere['settlement_begin_time'] = ['between', [$beginTime, $endTime]];
$withdrawWhere['settlement_end_time'] = ['between', [$beginTime, $endTime]];
}
$withdrawWhere['_logic'] = 'or';
$withdrawMap['_complex'] = $withdrawWhere;
$withdrawMap['settlement_begin_time'] = ['egt', $beginTime];
$withdraw = M('withdraw', 'tab_')->where($withdrawMap)->order('create_time desc')->find();
if (!empty($withdraw) && $withdraw['status'] != -2) {
$time = date('Y-m', $beginTime);
$this->error("{$time}月已有订单申请提现, 无法变更分成比例,请重新选择开始时间");
$withdraws = M('withdraw', 'tab_')->field('settlement_begin_time, settlement_end_time')
->where($withdrawMap)
->order('settlement_begin_time asc, settlement_end_time asc')
->select();
if (!empty($withdraws)) {
$times = [];
$text = '';
foreach ($withdraws as $withdraw) {
$settlementBeginTime = !empty($withdraw['settlement_begin_time']) ? date('Y-m', $withdraw['settlement_begin_time']) : '';
$settlementEndTime = date('Y-m', $withdraw['settlement_end_time']);
if ($settlementBeginTime && !in_array($settlementBeginTime, $times)) {
$times[] = $settlementBeginTime;
$text .= "{$settlementBeginTime}月、";
}
if (!in_array($settlementEndTime, $times)) {
$times[] = $settlementEndTime;
$text .= "{$settlementEndTime}月、";
}
}
$text = rtrim($text, '、');
$text .= '已有订单申请提现, 无法变更分成比例,请重新选择开始时间';
$this->error($text);
}
}

@ -81,8 +81,26 @@
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark">*</i>会长账号</td>
<td class="l"><i class="mustmark">*</i>推广公司</td>
<td class="r">
<select name="company_id" id="company_id" class="select_gallery" <notempty name="record">disabled</notempty>>
<option value="">推广公司</option>
<empty name="record">
<volist name="companys" id="vo">
<option value="{$vo.id}">{$vo.company_name}</option>
</volist>
<else/>
<volist name="companys" id="vo">
<option value="{$vo.id}" <if condition="$vo['id'] eq $record['company_id']">selected</if> >{$vo.company_name}</option>
</volist>
</empty>
</select>
<span class="notice-text"></span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>会长账号:</td>
<td class="r promote_id">
<select name="promote_id" id="promote_id" class="select_gallery" <notempty name="record">disabled</notempty>>
<option value="">会长账号</option>
<empty name="record">
@ -123,6 +141,25 @@
<span class="notice-text"></span>
</td>
</tr>
<tr>
<td class="l">月流水类型:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label>
<input class="interval_closed_status" type="radio" value="1" name="interval_closed_status"
<if condition="empty($record) or $record['interval_closed_status'] eq 1">
checked="checked"
</if>>大于等于
</label>
<label>
<input class="interval_closed_status" type="radio" value="2" name="interval_closed_status"
<if condition="!empty($record) and $record['interval_closed_status'] eq 2">
checked="checked"
</if>>大于
</label>
</span>
</td>
</tr>
<tr>
<td class="l">现分成比例:</td>
<td class="r table_radio">
@ -139,7 +176,13 @@
<div class="list-ratio">
<empty name="record['turnover_ratio']">
<div class="li-ratio">
<label>月流水大于等于:</label>
<label class="interval_closed_status_text">
<if condition="empty($record) or $record['interval_closed_status'] eq 1">
月流水大于等于:
<else/>
月流水大于:
</if>
</label>
<div class="turnover">
<input type="text" class="txt" name="turnover[]" value="" placeholder="" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')" style="width: 100px;margin-right: 10px;">
<span></span>
@ -156,7 +199,13 @@
<else/>
<volist name="record['turnover_ratio']" key="key" id="vo">
<div class="li-ratio">
<label>月流水大于等于:</label>
<label class="interval_closed_status_text">
<if condition="empty($record) or $record['interval_closed_status'] eq 1">
月流水大于等于:
<else/>
月流水大于:
</if>
</label>
<div class="turnover">
<input type="text" class="txt" name="turnover[]" value="{$vo['turnover']|default=''}" placeholder="" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')" style="width: 100px;margin-right: 10px;">
<span></span>
@ -240,6 +289,8 @@ highlight_subnav('{:U('PromoteGameRatio/lists')}');
$(".select_gallery").select2();
$(function(){
var intervalClosedStatusText = '月流水大于等于:';
$('.time').datetimepicker({
format: 'yyyy-mm',
language: "zh-CN",
@ -259,6 +310,30 @@ $(function(){
promoteGameRatioData.end_time = '';
promoteGameRatioData.remark = '';
$('#company_id').change(function (e) {
var companyId = parseInt($(this).val());
$.ajax({
type: 'post',
url: "{:U('getPromotes')}",
dataType: 'json',
data: {'company_id': companyId},
success: function (data) {
var html = '<option value="" selected>会长账号</option>';
if (data.length > 0) {
for (let i = 0;i < data.length;i++) {
html += '<option value="' + data[i]['id'] + '">' + data[i]['account'] + '(' + data[i]['real_name'] + ')' + '</option>';
}
}
$('#promote_id').html(html);
$('#promote_id').select2();
getPromoteGameRatio();
},
error: function (result) {
console.log(result);
}
});
});
$('#ratio, #begin_time, #end_time, #remark').change(function () {
var val = $(this).val();
var elementIdName = $(this).attr('id');
@ -266,13 +341,14 @@ $(function(){
});
$('#promote_id, #game_id').change(function () {
var promoteId = parseInt($('#promote_id').val());
var gameId = parseInt($('#game_id').val());
getPromoteGameRatio(promoteId, gameId);
getPromoteGameRatio();
});
function getPromoteGameRatio(promoteId, gameId)
function getPromoteGameRatio()
{
var promoteId = parseInt($('#promote_id').val());
var gameId = parseInt($('#game_id').val());
$.ajax({
type: 'post',
url: "{:U('getPromoteGameRatio')}",
@ -299,6 +375,25 @@ $(function(){
});
}
$('.interval_closed_status').change(function (e) {
var intervalClosedStatus = parseInt($("input[name=interval_closed_status]:checked").val());
var html = '';
switch (intervalClosedStatus) {
case 1:
html = '月流水大于等于:';
break;
case 2:
html = '月流水大于:';
break;
}
intervalClosedStatusText = html;
$('.interval_closed_status_text').text(html);
});
$('input[name=interval_closed_status]').change(function (e) {
});
$('#submit').click(function (e) {
var target = $('form').get(0).action;
var query = $('form').serialize();
@ -340,7 +435,7 @@ $(function(){
var delBtn = $('.iconfont-btn-del');
var html = '';
html += '<div class="li-ratio">';
html += '<label>月流水大于等于:</label>';
html += '<label class="interval_closed_status_text">' + intervalClosedStatusText + '</label>';
html += '<div class="turnover">';
html += '<input type="text" class="txt" name="turnover[]" value="" placeholder="" onKeyUp="value=value.replace(/[^\\w\\.\\/]/ig, \'\')" style="width: 100px;margin-right: 10px;">';
html += '<span></span>';

@ -72,6 +72,21 @@
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="company_id" name="company_id" class="select_gallery" >
<option value="">推广公司</option>
<volist name="companys" id="vo">
<option value="{$vo.id}">{$vo.company_name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="company_belong" name="company_belong" class="select_gallery" >
<option value="">内外团</option>
<option value="0" <if condition="0 eq I('company_belong', '') and '' nheq I('company_belong', '')">selected</if>>内团</option>
<option value="1" <if condition="1 eq I('company_belong', '')">selected</if>>外团</option>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" >
<option value="">推广员账号</option>
@ -80,6 +95,14 @@
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="game_type_id" name="game_type_id" class="select_gallery" >
<option value="">游戏类型</option>
<volist name="gameTypeList" id="vo">
<option value="{$vo.id}" <if condition="$vo.id eq I('game_type_id')">selected</if> >{$vo.type_name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="game_id" name="game_id" class="select_gallery" >
<option value="">游戏名称</option>
@ -88,7 +111,7 @@
</volist>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<div class="input-list input-list-promote search_label_rehab">
<select id="status" name="status" class="select_gallery" >
<option value="">审核状态</option>
<?php foreach ($statusList as $key => $status) :?>
@ -117,9 +140,12 @@
<th>注册时间</th>
<th>状态</th>
<th>身份状态</th>
<th>推广公司</th>
<th>工会归属</th>
<th>已申请游戏</th>
<th>游戏类型</th>
<th>原分成比例</th>
<th>当前分成比例</th>
<th>公会阶梯比例详细信息</th>
<th>开始时间</th>
<th>备注</th>
<th>分成比例审核</th>
@ -153,9 +179,16 @@
<td>{$record.promote_create_time}</td>
<td>{$record.promote_status_text}</td>
<td>{$record.promote_ver_status_text}</td>
<td>{$record.company_name}</td>
<td>{$record.company_belong}</td>
<td>{$record.game_name}</td>
<td>{$record.game_type_name}</td>
<td>{$record.last_ratio}</td>
<td>{$record.ratio}</td>
<td style="line-height: 16px;text-indent: 0;">
<div style="text-align: left;width: 90%;margin-left: 5%;margin-top: 10px;margin-bottom: 10px;">
{$record.ratio_dtl}
</div>
</td>
<td>{$record.valid_date}</td>
<td>{$record.remark}</td>
<td>{$record.status_text}</td>

@ -1455,3 +1455,21 @@ function getPromoteWithdrawSettlementType($type = null)
return Admin\Model\WithdrawModel::$settlementTypeList;
}
}
//获取推广公司列表
function getPromoteCompanys()
{
return M('promote_company', 'tab_')->field('id, company_name')->where(['status' => 1])->select();
}
function getPromoteCompanyName($companyId)
{
$companyName = M('promote_company', 'tab_')->where(['id' => $companyId])->getField('company_name');
return $companyName ?? '未知';
}
function getGameTypes()
{
return M('game_type', 'tab_')->field('id, type_name')->where(['status' => 1])->select();
}

@ -1101,3 +1101,7 @@ ADD COLUMN `can_view_recharge` tinyint(1) NOT NULL default 0 COMMENT '是否显
ALTER TABLE `tab_promote_belong`
ADD COLUMN `can_view_recharge` tinyint(1) NOT NULL default 0 COMMENT '是否显示充值数据 0否 1是';
-- 2020-02-03
ALTER TABLE `tab_promote_game_ratio`
ADD COLUMN `interval_closed_status` tinyint(3) NOT NULL DEFAULT 1 COMMENT '区间闭合状态1-闭合 2-不闭合' AFTER `last_turnover_ratio`;
Loading…
Cancel
Save