公会分成管理--更新

master
chenxiaojun 5 years ago
commit 9a0313b763

@ -146,6 +146,10 @@ class PromoteGameRatioController extends ThinkController
if (empty($promoteGameRatio)) {
$this->error('参数异常');
}
$promoteId = $promoteGameRatio['promote_id'];
$this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据
if ($promoteGameRatio['status'] == 1) {
$save['last_ratio'] = $promoteGameRatio['ratio'];
$save['last_ratio_status'] = 1;
@ -161,6 +165,7 @@ class PromoteGameRatioController extends ThinkController
}
$promoteId = intval($params['promote_id']);
$gameId = intval($params['game_id']);
$this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据
$promote = M('promote', 'tab_')->find($promoteId);
if (empty($promote) || $promote['level'] != 1) {
@ -217,6 +222,26 @@ class PromoteGameRatioController extends ThinkController
}
}
private function isWithdraw($promoteId, $beginTime)
{
$promote = M('promote', 'tab_')->find($promoteId);
if (empty($promote)) {
$this->error("数据异常");
}
if ($promote['level'] != 1) {
$this->error("该推广员不是会长账号,无法执行此操作");
}
$withdrawMap['promote_id'] = $promoteId;
$withdrawMap['status'] = ['neq', -2];
$withdrawMap['settlement_end_time'] = ['egt', $beginTime];
$withdraw = M('withdraw', 'tab_')->where($withdrawMap)->order('create_time desc')->find();
if (!empty($withdraw) && $withdraw['status'] != -2) {
$time = date('Y-m-d', $withdraw['create_time']);
$this->error("{$time}之前的订单已经申请提现, 无法变更分成比例,请重新选择开始时间");
}
}
public function setStatus($status)
{
$params = I('post.');
@ -228,6 +253,7 @@ class PromoteGameRatioController extends ThinkController
if (empty($status) || !in_array($status, [-1, 1])) {
$this->error('操作失败');
}
$time = time();
$map['id'] = ['in', $ids];
$map['status'] = 0;
@ -240,6 +266,32 @@ class PromoteGameRatioController extends ThinkController
}
$result = D(self::MODEL_NAME)->where($map)->save($save);
if ($result) {
if ($status == 1) {
foreach ($ids as $id) {
$promoteGameRatio = D(self::MODEL_NAME)->find($id);
if (!empty($promoteGameRatio)) {
if ($promoteGameRatio['begin_time'] <= strtotime(date('Y-m-d', time()))) {
$promoteId = $promoteGameRatio['promote_id'];
$promoteMap['chain'] = ['like', "/{$promoteId}/%"];
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promoteId;
$spendMap['promote_id'] = ['in', $promoteIds];
$spendMap['game_id'] = $promoteGameRatio['game_id'];
if ($promoteGameRatio['end_time'] > 0) {
$spendMap['pay_time'] = ['between', [$promoteGameRatio['begin_time'], $promoteGameRatio['end_time'] + 3600 * 24 - 1]];
} else {
$spendMap['pay_time'] = ['egt', $promoteGameRatio['begin_time']];
}
$spendMap['pay_status'] = 1;
$spendMap['selle_status'] = 0;
$spendSave['selle_ratio'] = $promoteGameRatio['ratio'];
M('spend', 'tab_')->where($spendMap)->save($spendSave);
}
}
}
}
$this->success('操作成功');
} else {
$this->error('操作失败');

@ -112,7 +112,7 @@
<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">
<button class="submit_btn mlspacing" id="submit" type="submit" target-form="form-horizontal">
保存
</button>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
@ -203,7 +203,42 @@ $(function(){
});
}
$('submit')
$('#submit').click(function (e) {
var target = $('form').get(0).action;
var query = $('form').serialize();
var that = this;
$(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
$.post(target,query).success(function(data){
if(layer) {layer.closeAll('loading');}
if (data.status==1) {
if (data.url) {
updateAlert(data.info + ' 页面即将自动跳转~');
}else{
updateAlert(data.info);
}
setTimeout(function(){
$(that).removeClass('disabled').prop('disabled',false);
if (data.url) {
location.href=data.url;
}else if( $(that).hasClass('no-refresh')){
$('#tip').find('.tipclose').click();
}else{
location.reload();
}
},1500);
}else{
updateAlert(data.info,'tip_error');
setTimeout(function(){
$(that).removeClass('disabled').prop('disabled',false);
if (data.url) {
location.href=data.url;
}else{
$('#tip').find('.tipclose').click();
}
},3000);
}
});
});
});
</script>
</block>

Loading…
Cancel
Save