|
|
|
@ -28,7 +28,7 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$page = $params['p'] ? intval($params['p']) : 1;
|
|
|
|
|
$row = $params['row'] ? intval($params['row']) : 10;
|
|
|
|
|
|
|
|
|
|
$map['_string'] = '1 = 1';
|
|
|
|
|
$map['_string'] = 'game_id = relation_game_id';
|
|
|
|
|
if ($promoteId) {
|
|
|
|
|
$map['promote_id'] = intval($promoteId);
|
|
|
|
|
}
|
|
|
|
@ -43,11 +43,13 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
if ($group == 1) {
|
|
|
|
|
$query = D(self::MODEL_NAME)->field($field, true)
|
|
|
|
|
->where($map)
|
|
|
|
|
->group('relation_game_id')
|
|
|
|
|
->order('update_time desc, id desc');
|
|
|
|
|
$metaTitle = $csvTitle = '公会分成管理';
|
|
|
|
|
} else {
|
|
|
|
|
$query = M(self::MODEL_NAME . '_log', 'tab_')->field($field, true)
|
|
|
|
|
->where($map)
|
|
|
|
|
->group('relation_game_id')
|
|
|
|
|
->order('create_time desc, id desc');
|
|
|
|
|
$metaTitle = $csvTitle = '公会分成申请记录';
|
|
|
|
|
}
|
|
|
|
@ -161,7 +163,7 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$this->assign('group', $group);
|
|
|
|
|
$this->assign('records', $records);
|
|
|
|
|
$this->assign('count', $count);
|
|
|
|
|
$this->assign('gameList', getAllGameList());
|
|
|
|
|
$this->assign('gameList', getAllGameList(true));
|
|
|
|
|
$this->assign('promoteList', getPromoteByLevel(1));
|
|
|
|
|
$this->assign('statusList', self::$statusList);
|
|
|
|
|
$this->assign('reviewRule', $reviewRule);
|
|
|
|
@ -232,6 +234,7 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$save['remark'] = $params['remark'] ?? '';
|
|
|
|
|
$save['status'] = 0;
|
|
|
|
|
$save['update_time'] = $time;
|
|
|
|
|
$model = new PromoteGameRatioModel();
|
|
|
|
|
if (!empty($params['id'])) {//修改
|
|
|
|
|
$promoteGameRatio = D(self::MODEL_NAME)->find($params['id']);
|
|
|
|
|
if (empty($promoteGameRatio)) {
|
|
|
|
@ -245,13 +248,25 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$save['last_ratio'] = $promoteGameRatio['ratio'];
|
|
|
|
|
$save['last_ratio_status'] = 1;
|
|
|
|
|
}
|
|
|
|
|
$save['id'] = intval($params['id']);
|
|
|
|
|
$result = D(self::MODEL_NAME)->save($save);
|
|
|
|
|
$saveMap['relation_game_id'] = $promoteGameRatio['relation_game_id'];
|
|
|
|
|
$result = D(self::MODEL_NAME)->where($saveMap)->save($save);
|
|
|
|
|
$logResult = $result;
|
|
|
|
|
} else {
|
|
|
|
|
$result = true;
|
|
|
|
|
$logResult = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
|
$this->error('保存失败');
|
|
|
|
|
}
|
|
|
|
|
if ($logResult) {
|
|
|
|
|
$promoteGameRatioIds = D(self::MODEL_NAME)->where(array('relation_game_id' => $promoteGameRatio['relation_game_id']))->getField('id', true);
|
|
|
|
|
if (!empty($promoteGameRatioIds)) {
|
|
|
|
|
foreach ($promoteGameRatioIds as $promoteGameRatioId) {
|
|
|
|
|
$model->addLog($promoteGameRatioId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {//新增
|
|
|
|
|
if (empty($params['promote_id'])) {
|
|
|
|
|
$this->error('请选择会长账号');
|
|
|
|
@ -261,6 +276,14 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
$promoteId = intval($params['promote_id']);
|
|
|
|
|
$gameId = intval($params['game_id']);
|
|
|
|
|
$relationGameId = D('game')->where(array('id' => $gameId))->getField('relation_game_id');
|
|
|
|
|
if (empty($relationGameId)) {
|
|
|
|
|
$this->error('数据异常');
|
|
|
|
|
}
|
|
|
|
|
$gameIds = D('game')->where(array('relation_game_id' => $relationGameId))->getField('id', true);
|
|
|
|
|
if (empty($gameIds)) {
|
|
|
|
|
$this->error('数据异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promote = M('promote', 'tab_')->find($promoteId);
|
|
|
|
|
if (empty($promote) || $promote['level'] != 1) {
|
|
|
|
@ -270,36 +293,35 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$this->isWithdraw($promoteId, $save['begin_time']);
|
|
|
|
|
|
|
|
|
|
$map['promote_id'] = $promoteId;
|
|
|
|
|
$save['promote_id'] = $promoteId;
|
|
|
|
|
$save['last_turnover_ratio'] = '';
|
|
|
|
|
$save['applicant_id'] = is_login();
|
|
|
|
|
$save['create_time'] = $time;
|
|
|
|
|
M()->startTrans();
|
|
|
|
|
foreach ($gameIds as $gameId) {
|
|
|
|
|
$map['game_id'] = $gameId;
|
|
|
|
|
$promoteGameRatio = D(self::MODEL_NAME)->where($map)->find();
|
|
|
|
|
if ($promoteGameRatio) {
|
|
|
|
|
$this->error('网络异常');
|
|
|
|
|
}
|
|
|
|
|
$save['promote_id'] = $promoteId;
|
|
|
|
|
|
|
|
|
|
$save['game_id'] = $gameId;
|
|
|
|
|
$save['last_turnover_ratio'] = '';
|
|
|
|
|
$save['applicant_id'] = is_login();
|
|
|
|
|
$save['create_time'] = $time;
|
|
|
|
|
$save['relation_game_id'] = $relationGameId;
|
|
|
|
|
$result = D(self::MODEL_NAME)->add($save);
|
|
|
|
|
$logResult = $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
|
M()->rollback();
|
|
|
|
|
$this->error('保存失败');
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
if ($logResult) {
|
|
|
|
|
if (empty($params['id'])) {
|
|
|
|
|
$promoteGameRatioId = $result;
|
|
|
|
|
} else {
|
|
|
|
|
$promoteGameRatioId = $params['id'];
|
|
|
|
|
$model->addLog($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$model = new PromoteGameRatioModel();
|
|
|
|
|
$model->addLog($promoteGameRatioId);
|
|
|
|
|
}
|
|
|
|
|
M()->commit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->success('保存成功', U('lists'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$params = I('get.');
|
|
|
|
|
$id = $params['id'] ?? 0;
|
|
|
|
@ -365,8 +387,11 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$this->error('操作失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promoteGameRatioMap['id'] = ['in', $ids];
|
|
|
|
|
$relationGameIds = D(self::MODEL_NAME)->where($promoteGameRatioMap)->getField('relation_game_id', true);
|
|
|
|
|
|
|
|
|
|
$time = time();
|
|
|
|
|
$map['id'] = ['in', $ids];
|
|
|
|
|
$map['relation_game_id'] = ['in', $relationGameIds];
|
|
|
|
|
$map['status'] = 0;
|
|
|
|
|
$save['status'] = $status;
|
|
|
|
|
$save['reviewer_id'] = is_login();
|
|
|
|
@ -378,22 +403,43 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
$result = D(self::MODEL_NAME)->where($map)->save($save);
|
|
|
|
|
if ($result) {
|
|
|
|
|
$model = new PromoteGameRatioModel();
|
|
|
|
|
foreach ($ids as $id) {
|
|
|
|
|
$model->addLog($id);
|
|
|
|
|
if ($status == 1) {
|
|
|
|
|
$promoteGameRatio = D(self::MODEL_NAME)->find($id);
|
|
|
|
|
if (!empty($promoteGameRatio)) {
|
|
|
|
|
if ($promoteGameRatio['begin_time'] <= strtotime(date('Y-m-d', time()))) {
|
|
|
|
|
$promoteGameRatios = D(self::MODEL_NAME)->where(array('relation_game_id' => ['in', $relationGameIds]))->select();
|
|
|
|
|
if (!empty($promoteGameRatios)) {
|
|
|
|
|
foreach ($promoteGameRatios as $promoteGameRatio) {
|
|
|
|
|
$promoteId = $promoteGameRatio['promote_id'];
|
|
|
|
|
$promoteMap['chain'] = ['like', "/{$promoteId}/%"];
|
|
|
|
|
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
|
|
|
|
|
$promoteIds[] = $promoteId;
|
|
|
|
|
$model->addLog($promoteGameRatio['id']);
|
|
|
|
|
if ($status == 1) {
|
|
|
|
|
if ($promoteGameRatio['begin_time'] <= strtotime(date('Y-m-d', time()))) {
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
|
|
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
|
|
|
|
|
$gameIds = $gameIds ?? [-1];
|
|
|
|
|
$spendSave['selle_ratio'] = $promoteGameRatio['ratio'];
|
|
|
|
|
M('spend', 'tab_')->where($spendMap)->save($spendSave);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($ids as $id) {
|
|
|
|
|
$thisPromoteGameRatio = D(self::MODEL_NAME)->find($id);
|
|
|
|
|
if (!empty($thisPromoteGameRatio)) {
|
|
|
|
|
$promoteGameRatios = D(self::MODEL_NAME)->where(array('relation_game_id' => $thisPromoteGameRatio['relation_game_id']))->select();
|
|
|
|
|
foreach ($promoteGameRatios as $promoteGameRatio) {
|
|
|
|
|
$model->addLog($promoteGameRatio['id']);
|
|
|
|
|
if ($status == 1) {
|
|
|
|
|
if ($promoteGameRatio['begin_time'] <= strtotime(date('Y-m-d', time()))) {
|
|
|
|
|
$spendMap['promote_id'] = ['in', $promoteIds];
|
|
|
|
|
$spendMap['game_id'] = ['in', $gameIds];
|
|
|
|
|
$spendMap['game_id'] = $promoteGameRatio['relation_game_id'];
|
|
|
|
|
if ($promoteGameRatio['end_time'] > 0) {
|
|
|
|
|
$spendMap['pay_time'] = ['between', [$promoteGameRatio['begin_time'], $promoteGameRatio['end_time'] + 3600 * 24 - 1]];
|
|
|
|
|
} else {
|
|
|
|
@ -408,6 +454,7 @@ class PromoteGameRatioController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->success('操作成功');
|
|
|
|
|
} else {
|
|
|
|
|
$this->error('操作失败');
|
|
|
|
|