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

master
chenxiaojun 5 years ago
parent 5034cb863b
commit 410a3cda1b

@ -66,15 +66,13 @@ class PromoteGameRatioController extends ThinkController
$thisPromoteVerStatus = '未知';
$thisGameName = '未知';
$thisGameRatio = '0.00';
$thisLastRatio = $promoteGameRatio['last_ratio'];
$thisLastRatioStatus = $promoteGameRatio['last_ratio_status'];
$thisStatusText = self::$statusList[$promoteGameRatio['status']];
$thisStatusText = ($promoteGameRatio['status'] == -1) ? '<span style="color: red;">' . $thisStatusText . '</span>' : $thisStatusText;
$thisApplicant = getPromoteAccount($promoteGameRatio['applicant_id']);
$thisReviewer = $promoteGameRatio['reviewer_id'] ? getPromoteAccount($promoteGameRatio['reviewer_id']) : '待确认';
if ($promoteGameRatio['ratio'] > 0 && $promoteGameRatio['begin_time']) {
$thisBeninTime = date('Y/m/d', $promoteGameRatio['begin_time']);
} else {
$thisBeninTime = date('Y/m/d', $this->getPromoteApplyCreateTime($thisPromoteId, $thisGameId));
}
$thisBeninTime = date('Y/m/d', $promoteGameRatio['begin_time']);
$thisEndTime = $promoteGameRatio['end_time'] ? date('Y/m/d', $promoteGameRatio['end_time']) : '永久';
$validDate = $thisBeninTime . ' - ' . $thisEndTime;
if ($issetPromote) {
@ -100,7 +98,7 @@ class PromoteGameRatioController extends ThinkController
'promote_status_text' => $thisPromoteStatus,
'promote_ver_status_text' => $thisPromoteVerStatus,
'game_name' => $thisGameName,
'game_ratio' => $thisGameRatio . '%',
'last_ratio' => (($thisLastRatioStatus == 1) ? $thisLastRatio : $thisGameRatio) . '%',
'ratio' => $promoteGameRatio['ratio'] . '%',
'valid_date' => $validDate,
'remark' => $promoteGameRatio['remark'],
@ -129,8 +127,11 @@ class PromoteGameRatioController extends ThinkController
if ($_POST) {
$params = I('post.');
$time = time();
if (empty($params['begin_time'])) {
$this->error('请选择开始时间');
}
$save['ratio'] = $params['ratio'] ?? 0;
$save['begin_time'] = $params['begin_time'] ? strtotime($params['begin_time']) : 0;
$save['begin_time'] = strtotime($params['begin_time']);
$save['end_time'] = $params['end_time'] ? strtotime($params['end_time']) : 0;
$save['remark'] = $params['remark'] ?? '';
$save['status'] = 0;
@ -140,6 +141,10 @@ class PromoteGameRatioController extends ThinkController
if (empty($promoteGameRatio)) {
$this->error('参数异常');
}
if ($promoteGameRatio['status'] == 1) {
$save['last_ratio'] = $promoteGameRatio['ratio'];
$save['last_ratio_status'] = 1;
}
$save['id'] = intval($params['id']);
$result = D(self::MODEL_NAME)->save($save);
} else {//新增
@ -176,19 +181,22 @@ class PromoteGameRatioController extends ThinkController
$metaTitle = '游戏分成比例申请';
if ($id) {
$metaTitle .= '--修改';
$field = 'id, promote_id, game_id, ratio, begin_time, end_time, remark';
$map['id'] = $id;
$promoteGameRatio = D(self::MODEL_NAME)->field($field)->where($map)->find();
$promoteGameRatio = D(self::MODEL_NAME)->where($map)->find();
if (empty($promoteGameRatio)) {
$this->error('数据异常');
}
$promoteGameRatio['begin_time'] = $promoteGameRatio['begin_time'] ? date('Y-m-d', $promoteGameRatio['begin_time']) : '';
$promoteGameRatio['end_time'] = $promoteGameRatio['end_time'] ? date('Y-m-d', $promoteGameRatio['end_time']) : '';
$gameRatio = M('game', 'tab_')->where(array(['id' => $promoteGameRatio['game_id']]))->getField('ratio');
$gameRatio = ($gameRatio ?? '0.00') . '%';
if ($promoteGameRatio['last_ratio_status'] == 1) {
$lastRatio = $promoteGameRatio['last_ratio'];
} else {
$gameRatio = M('game', 'tab_')->where(array(['id' => $promoteGameRatio['game_id']]))->getField('ratio');
$lastRatio = ($gameRatio ?? '0.00') . '%';
}
$this->assign('record', $promoteGameRatio);
$this->assign('gameRatio', $gameRatio);
$this->assign('lastRatio', $lastRatio);
}
$this->assign('gameList', getAllGameList());
@ -245,20 +253,51 @@ class PromoteGameRatioController extends ThinkController
return $reviewRule;
}
public function getGameRatio()
public function getPromoteGameRatio()
{
$promoteId = I('post.promote_id', 0);
$promoteId = intval($promoteId);
$gameId = I('post.game_id', 0);
$gameId = intval($gameId);
$gameRatio = '';
$record['last_ratio'] = '';
$status = 0;
if ($promoteId || $gameId) {
if ($promoteId && $gameId) {
$map['promote_id'] = $promoteId;
$map['game_id'] = $gameId;
$record = D(self::MODEL_NAME)->where($map)->find();
if ($record) {
$status = 2;
$record['begin_time'] = date('Y-m-d', $record['begin_time']);
$record['end_time'] = empty($record['end_time']) ? '' : date('Y-m-d', $record['end_time']);
if ($record['last_ratio_status'] == 0) {
$record['last_ratio'] = $this->getGameRatio($gameId);
}
} else {
$status = 1;
$record['last_ratio'] = $this->getGameRatio($gameId);
}
} elseif ($gameId) {
$status = 1;
$record['last_ratio'] = $this->getGameRatio($gameId);
}
}
$data = [
'status' => $status,
'record' => $record,
];
$this->ajaxReturn($data);
}
public function getGameRatio($gameId)
{
$gameId = intval($gameId);
$gameRatio = '0.00';
if ($gameId) {
$map['id'] = $gameId;
$gameRatio = M('game', 'tab_')->where($map)->getField('ratio');
$gameRatio = ($gameRatio ?? '0.00') . '%';
}
$data = [
'status' => 1,
'ratio' => $gameRatio,
];
$this->ajaxReturn($data);
return $gameRatio;
}
}

@ -19,6 +19,9 @@
.tabcon1711 .form_unit {
margin-left: 2px;
}
.tabcon1711 .mustmark {
margin-left:-7px;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
@ -35,7 +38,7 @@
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>会长账号:</td>
<td class="l"><i class="mustmark">*</i>会长账号:</td>
<td class="r">
<select name="promote_id" id="promote_id" class="select_gallery" <notempty name="record">disabled</notempty>>
<option value="">会长账号</option>
@ -53,7 +56,7 @@
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>已申请游戏:</td>
<td class="l"><i class="mustmark">*</i>已申请游戏:</td>
<td class="r">
<select id="game_id" name="game_id" class="select_gallery" <notempty name="record">disabled</notempty>>
<option value="">游戏名称</option>
@ -73,25 +76,25 @@
<tr>
<td class="l">原分成比例:</td>
<td class="r table_radio">
<span class="form_radio table_btn" id="game_ratio" style="color: red;">{$gameRatio|default=''}</span>
<span class="form_radio table_btn" id="last_ratio" style="color: red;">{$lastRatio|default=''}</span>
<span class="notice-text"></span>
</td>
</tr>
<tr>
<td class="l">现分成比例:</td>
<td class="r table_radio">
<input type="text" class="txt" name="ratio" value="{$record.ratio|default='0.00'}" placeholder="" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')">
<input type="text" class="txt" name="ratio" id="ratio" value="{$record.ratio|default='0.00'}" placeholder="" onKeyUp="value=value.replace(/[^\w\.\/]/ig,'')">
<span class="form_unit">%</span>
<span class="notice-text">当前需要修改成的分成比例</span>
</td>
</tr>
<tr>
<td class="l">开始时间:</td>
<td class="l"><i class="mustmark">*</i>开始时间:</td>
<td class="r table_radio">
<div style="float: left;">
<input type="text" class="txt time" name="begin_time" placeholder="开始时间" value="{$record['begin_time']|default=''}">
<input type="text" class="txt time" name="begin_time" id="begin_time" placeholder="开始时间" value="{$record['begin_time']|default=''}">
-
<input type="text" class="txt time" name="end_time" placeholder="结束时间" value="{$record['end_time']|default=''}">
<input type="text" class="txt time" name="end_time" id="end_time" placeholder="结束时间" value="{$record['end_time']|default=''}">
</div>
<span class="notice-text">结束时间不填则默认永久。</span>
</td>
@ -99,14 +102,14 @@
<tr>
<td class="l">备注:</td>
<td class="r table_radio">
<textarea type="text" name="remark" class="txt_area">{$record['remark']|default=''}</textarea>
<textarea type="text" name="remark" id="remark" class="txt_area">{$record['remark']|default=''}</textarea>
<span class="notice-text"></span>
</td>
</tr>
</tbody>
</table>
</div>
<input type="hidden" name="id" value="{$record['id']|default=''}" />
<input type="hidden" name="id" id="id" value="{$record['id']|default=''}" />
<div class="form-item cf">
<button class="submit_btn ajax-post mlspacing" id="submit" type="submit" target-form="form-horizontal">
@ -154,26 +157,48 @@ $(function(){
});
showTab();
$('#game_id').change(function () {
var gameId = parseInt($(this).val());
getGameRatio(gameId);
var promoteGameRatioData = {};
promoteGameRatioData.ratio = '0.00';
promoteGameRatioData.begin_time = '';
promoteGameRatioData.end_time = '';
promoteGameRatioData.remark = '';
$('#ratio, #begin_time, #end_time, #remark').change(function () {
var val = $(this).val();
var elementIdName = $(this).attr('id');
promoteGameRatioData[elementIdName] = val;
});
$('#promote_id, #game_id').change(function () {
var promoteId = parseInt($('#promote_id').val());
var gameId = parseInt($('#game_id').val());
getPromoteGameRatio(promoteId, gameId);
});
function getGameRatio(gameId) {
function getPromoteGameRatio(promoteId, gameId)
{
$.ajax({
type: "post",
url: "{:U('getGameRatio')}",
dataType: "json",
data: {'game_id': gameId},
type: 'post',
url: "{:U('getPromoteGameRatio')}",
dataType: 'json',
data: {'promote_id': promoteId, 'game_id': gameId},
success: function (data) {
if (data.status == 1) {
$('#game_ratio').text(data.ratio);
var record = data.record;
if (data.status == 2) {
$('#ratio').val(record.ratio);
$('#last_ratio').text(record.last_ratio);
$('#begin_time').val(record.begin_time);
$('#end_time').val(record.end_time);
$('#remark').val(record.remark);
$('#id').val(record.id);
} else {
console.log(data);
// $('#ratio').val(promoteGameRatioData.ratio);
$('#last_ratio').text(record.last_ratio);
// $('#begin_time').val(promoteGameRatioData.begin_time);
// $('#end_time').val(promoteGameRatioData.end_time);
// $('#remark').val(promoteGameRatioData.remark);
$('#id').val('');
}
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
}

@ -146,7 +146,7 @@
<td>{$record.promote_status_text}</td>
<td>{$record.promote_ver_status_text}</td>
<td>{$record.game_name}</td>
<td>{$record.game_ratio}</td>
<td>{$record.last_ratio}</td>
<td>{$record.ratio}</td>
<td>{$record.valid_date}</td>
<td>{$record.remark}</td>

@ -1070,12 +1070,54 @@ function is_check_account($account){
return $data['game_name'];
}
//获取游戏cp比例
function get_game_selle_ratio($game_id=null,$field='id'){
$map[$field]=$game_id;
$data=M('game','tab_')->where($map)->find();
if(empty($data)){return '';}
function get_game_selle_ratio($game_id = null, $field = 'id')
{
$map[$field] = $game_id;
$data = M('game', 'tab_')->where($map)->find();
if (empty($data)) {
return '';
}
return $data['ratio'];
}
//获取游戏cp比例
function getGameSelleRatio($gameId = null, $promoteId = null, $field = 'id')
{
$promoteGameRatio = getGameSelleRatioByPromote($promoteId, $gameId);
if ($promoteGameRatio === false) {
$map[$field] = $gameId;
$data = M('game', 'tab_')->where($map)->find();
if (empty($data)) {
return 0;
}
return $data['ratio'];
} else {
return $promoteGameRatio;
}
}
//获取推广员设置的游戏cp比例
function getGameSelleRatioByPromote($promoteId = null, $gameId = null)
{
if (empty($promoteId) || empty($gameId)) {
return false;
}
$map['promote_id'] = intval($promoteId);
$map['game_id'] = intval($gameId);
$promoteGameRatio = M('promote_game_ratio', 'tab_')->where($map)->find();
if (empty($promoteGameRatio) || $promoteGameRatio['status'] != 1) {
return false;
}
if ($promoteGameRatio['begin_time'] > time()) {
return false;
}
if (!empty($promoteGameRatio['end_time']) && $promoteGameRatio['end_time'] < time()) {
return false;
}
return $promoteGameRatio['ratio'];
}
/**
* [获取管理员昵称]

@ -783,6 +783,8 @@ CREATE TABLE `tab_promote_game_ratio` (
`promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
`ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '分成比例',
`last_ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '上次的分成比例',
`last_ratio_status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '上次的分成比例状态0-未设置 1-已设置',
`begin_time` int(10) NOT NULL DEFAULT '0' COMMENT '开始时间',
`end_time` int(10) NOT NULL DEFAULT '0' COMMENT '过期时间',
`remark` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '备注',
@ -794,7 +796,7 @@ CREATE TABLE `tab_promote_game_ratio` (
`update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `promote_id` (`promote_id`,`game_id`,`status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
-- 超级签统计菜单
INSERT INTO `sys_menu`( `title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`) VALUES ('游戏统计', 137, 0, 'SuperStatistical/index', 0, '', '财务管理', 0, 1);

Loading…
Cancel
Save