公会分成管理--更新

master
chenxiaojun 5 years ago
commit b367b4a8d3

@ -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('promote_id, 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('promote_id, relation_game_id, create_time')
->order('create_time desc, id desc');
$metaTitle = $csvTitle = '公会分成申请记录';
}
@ -56,7 +58,10 @@ class PromoteGameRatioController extends ThinkController
}
$promoteGameRatios = $query->select();
if (I('export', 0) != 1) {
$count = D(self::MODEL_NAME)->where($map)->count();
$count = count(D(self::MODEL_NAME)->where($map)
->group('promote_id, relation_game_id')
->order('update_time desc, id desc')
->select());
}
$records = [];
@ -232,6 +237,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 +251,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 +279,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 +296,35 @@ class PromoteGameRatioController extends ThinkController
$this->isWithdraw($promoteId, $save['begin_time']);
$map['promote_id'] = $promoteId;
$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;
$result = D(self::MODEL_NAME)->add($save);
$logResult = $result;
}
if ($result === false) {
$this->error('保存失败');
} else {
if ($logResult) {
if (empty($params['id'])) {
$promoteGameRatioId = $result;
} else {
$promoteGameRatioId = $params['id'];
M()->startTrans();
foreach ($gameIds as $gameId) {
$map['game_id'] = $gameId;
$promoteGameRatio = D(self::MODEL_NAME)->where($map)->find();
if ($promoteGameRatio) {
$this->error('网络异常');
}
$model = new PromoteGameRatioModel();
$model->addLog($promoteGameRatioId);
}
$save['game_id'] = $gameId;
$save['relation_game_id'] = $relationGameId;
$result = D(self::MODEL_NAME)->add($save);
$logResult = $result;
$this->success('保存成功', U('lists'));
if ($result === false) {
M()->rollback();
$this->error('保存失败');
}
if ($logResult) {
$model->addLog($result);
}
}
M()->commit();
}
$this->success('保存成功', U('lists'));
} else {
$params = I('get.');
$id = $params['id'] ?? 0;
@ -365,8 +390,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 +406,18 @@ 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)) {
$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()))) {
$promoteId = $promoteGameRatio['promote_id'];
$promoteMap['chain'] = ['like', "/{$promoteId}/%"];
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promoteId;
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
$gameIds = $gameIds ?? [-1];
$spendMap['promote_id'] = ['in', $promoteIds];
$spendMap['game_id'] = ['in', $gameIds];
$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 {

@ -1477,7 +1477,7 @@ class QueryController extends ThinkController
$spendMap['tab_spend.pay_status'] = 1;
//获取spend表中的数据同时根据会长id进行group分类
$data = M('Spend','tab_')
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,tab_spend.game_name,SUBSTRING_INDEX(tab_spend.`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id,tab_game.ratio ")
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,tab_spend.game_name,SUBSTRING_INDEX(tab_spend.`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id,tab_game.ratio,tab_game.relation_game_id ")
->join("left join tab_promote on promote_id = tab_promote.id")
->join("left join tab_game on tab_game.id=tab_spend.game_id")
->where($spendMap)
@ -1498,7 +1498,7 @@ class QueryController extends ThinkController
$data = M()->table('('.$data.') as a')
->field("my_time,pay_amount,a.game_id,game_name,game_names,a.promote_id,a.promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account,tab_ratio.ratio as ratio,turnover_ratio,a.ratio as game_ratio")
->join("left join tab_promote on root_id = tab_promote.id")
->join("left join tab_promote_game_ratio as tab_ratio on tab_ratio.game_id = a.game_id and tab_ratio.promote_id=root_id")
->join("left join tab_promote_game_ratio as tab_ratio on tab_ratio.game_id = a.relation_game_id and tab_ratio.promote_id=root_id")
// ->join("left join tab_cp_game_ratio as game_ratio on game_ratio.game_id = a.game_id")
->page($page,$row)
->where($map)
@ -1578,14 +1578,22 @@ class QueryController extends ThinkController
$map['my_time'] = $_REQUEST['count_date'];
}
// if ($_REQUEST['device']) {
// $map['game_name'] = ['like','%'.$_REQUEST['device'].'%'];
// }
if ($_REQUEST['device']) {
$map['game_name'] = ['like','%'.$_REQUEST['device'].'%'];
// $map['tab_spend.sdk_version'] = $_REQUEST['device'];
$spendMap['tab_spend.sdk_version'] = $_REQUEST['device'];
}
$spendMap['tab_spend.pay_status'] = 1;
//获取spend表中的数据同时根据会长id进行group分类
$data = M('Spend','tab_')
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,game_name,SUBSTRING_INDEX(`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id,pay_way ")
->join("left join tab_promote on promote_id = tab_promote.id")
->where(['pay_status'=>1])
->where($spendMap)
->group("my_time,game_names,root_id,pay_way")
->order("my_time Desc")
->select(false);

@ -226,7 +226,7 @@ class WithdrawModel extends Model{
return 1;
}
//月结
//月结
public function promoteWithdrawPerMonthByPromote($promote, $initial = false, $data = [])
{
$promoteIds = $this->getPromoteChildren($promote);
@ -268,42 +268,37 @@ class WithdrawModel extends Model{
$balance = 0;
$notInGameIds = [-1];
foreach ($promoteGameRatios as $promoteGameRatio) {
$spendWhere['game_id'] = $promoteGameRatio['game_id'];
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
$notInGameIds[] = $promoteGameRatio['game_id'];
$ratio = $promoteGameRatio['ratio'];
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
if (!empty($gameIds)) {
foreach ($gameIds as $gameId) {
$spendWhere['game_id'] = $gameId;
$notInGameIds[] = $gameId;
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendWhere)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
->where($spendWhere)
->find()['balance'];
$thisBalance = $thisBalance ?? 0;
$balance = bcadd($balance, $thisBalance, 2);
$gameRatios[$gameId] = [];
$gameRatios[$gameId][] = [
'selle_ratio' => $ratio,
'default_ratio' => $promoteGameRatio['ratio'],
'sum_amount' => $sumAmount,
'begin_time' => $beginTime,
'end_time' => $endTime,
];
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendWhere)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
->where($spendWhere)
->find()['balance'];
$thisBalance = $thisBalance ?? 0;
$balance = bcadd($balance, $thisBalance, 2);
$gameRatios[$promoteGameRatio['game_id']] = [];
$gameRatios[$promoteGameRatio['game_id']][] = [
'selle_ratio' => $ratio,
'default_ratio' => $promoteGameRatio['ratio'],
'sum_amount' => $sumAmount,
'begin_time' => $beginTime,
'end_time' => $endTime,
];
}
}
@ -396,39 +391,34 @@ class WithdrawModel extends Model{
$gameRatios = [];
foreach ($promoteGameRatios as $promoteGameRatio) {
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
$spendMap['game_id'] = $promoteGameRatio['game_id'];
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
if (!empty($gameIds)) {
foreach ($gameIds as $gameId) {
$spendMap['game_id'] = $gameId;
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendMap)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
$ratio = 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
if ($ratio > 0) {
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
$balance = bcadd($balance, $thisBalance, 2);
$gameRatios[$gameId][] = [
'selle_ratio' => $ratio,
'default_ratio' => $promoteGameRatio['ratio'],
'sum_amount' => $sumAmount,
'begin_time' => date('Y-m-d', $settlementBeginTime),
'end_time' => date('Y-m-d', $settlementEndTime),
];
}
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendMap)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
$ratio = 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
if ($ratio > 0) {
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
$balance = bcadd($balance, $thisBalance, 2);
$gameRatios[$promoteGameRatio['game_id']][] = [
'selle_ratio' => $ratio,
'default_ratio' => $promoteGameRatio['ratio'],
'sum_amount' => $sumAmount,
'begin_time' => date('Y-m-d', $settlementBeginTime),
'end_time' => date('Y-m-d', $settlementEndTime),
];
}
}
}
@ -487,31 +477,26 @@ class WithdrawModel extends Model{
$balance = 0;
foreach ($promoteGameRatios as $promoteGameRatio) {
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
$spendMap['game_id'] = $promoteGameRatio['game_id'];
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
if (!empty($gameIds)) {
foreach ($gameIds as $gameId) {
$spendMap['game_id'] = $gameId;
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendMap)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
$ratio = 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
if ($ratio > 0) {
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
$balance = bcadd($balance, $thisBalance, 2);
}
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendMap)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
$ratio = 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
if ($ratio > 0) {
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
$balance = bcadd($balance, $thisBalance, 2);
}
}
}
@ -547,33 +532,28 @@ class WithdrawModel extends Model{
$balance = 0;
$notInGameIds = [-1];
foreach ($promoteGameRatios as $promoteGameRatio) {
$spendWhere['game_id'] = $promoteGameRatio['game_id'];
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
$notInGameIds[] = $promoteGameRatio['game_id'];
$ratio = $promoteGameRatio['ratio'];
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
if (!empty($gameIds)) {
foreach ($gameIds as $gameId) {
$spendWhere['game_id'] = $gameId;
$notInGameIds[] = $gameId;
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendWhere)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
->where($spendWhere)
->find()['balance'];
$thisBalance = $thisBalance ?? 0;
$balance = bcadd($balance, $thisBalance, 2);
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendWhere)
->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
foreach ($turnoverRatios as $turnoverRatio) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
->where($spendWhere)
->find()['balance'];
$thisBalance = $thisBalance ?? 0;
$balance = bcadd($balance, $thisBalance, 2);
}
}

@ -1106,10 +1106,6 @@ function getGameSelleRatioByPromote($promoteId = null, $gameId = null)
$promoteId = intval($promoteId);
$gameId = intval($gameId);
$promote = M('promote', 'tab_')->find($promoteId);
$gameId = M('game', 'tab_')->where(array('id' => $gameId))->getField('relation_game_id');
if (empty($gameId)) {
return false;
}
if (empty($promote)) {
return false;

@ -2199,10 +2199,11 @@ class DownloadController extends BaseController {
if($value1['status'] == 2) {
$value1['promotestatus'] = "冻结中";
}
$value1['account'] = substr_replace($value1['account'],'****',2);
$realname = mb_strlen($value1['real_name'],'utf-8') == 2 ? mb_substr($value1['real_name'],0,1,'utf-8').'*':mb_substr($value1['real_name'],0,1,'utf-8').'**';
$value1['real_name'] = $realname;
$value1['idcard'] = substr_replace($value1['idcard'],'************',3,12);
$value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']);
$xlsData[] = $value1;
$value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']);
$xlsData[] = $value1;
}
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
}
@ -3087,7 +3088,7 @@ class DownloadController extends BaseController {
$records[] = [
'id' => $parent['id'],
'account' => $parent['account'],
'real_name' => $parent['real_name'],
'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**',
'level' => $parent['level'],
'create_role_count' => $selfCreateRoleCountList[$parent['id']],
'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']],
@ -3109,7 +3110,7 @@ class DownloadController extends BaseController {
$records[] = [
'id' => $id,
'account' => $promote['account'],
'real_name' => $promote['real_name'],
'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**',
'level' => $promote['level'],
'create_role_count' => $createRoleCountList[$id],
'create_role_user_count' => $createRoleUserCountList[$id],

@ -529,7 +529,7 @@ class FinanceController extends BaseController
if ($withdrawId == 0) {
$this->error('参数异常');
}
$withdraw = $model->field('promote_id,status')->where(array('id' => $withdrawId))->find();
$withdraw = $model->where(array('id' => $withdrawId))->find();
if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) {
$this->error('参数异常');
}
@ -544,7 +544,18 @@ class FinanceController extends BaseController
$parameter['user_account'] = $userAccount;
$parameter['pay_order_number'] = $payOrderNumber;
$map['withdraw_id'] = $withdrawId;
if ($withdraw['settlement_type'] == 3) {
if (empty($withdraw['game_ratio'])) {
$map['_string'] = '1 = 2';
} else {
$gameRatios = json_decode($withdraw['game_ratio'], true);
$gameIds = array_keys($gameRatios);
$map['game_id'] = ['in', $gameIds];
$map['pay_time'] = ['between', [$withdraw['settlement_begin_time'], $withdraw['settlement_end_time']]];
}
} else {
$map['withdraw_id'] = $withdrawId;
}
if (!empty($gameId)) {
$map['game_id'] = $gameId;
}
@ -613,20 +624,40 @@ class FinanceController extends BaseController
if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) {
$this->error('参数异常');
}
$settlementBeginTime = $withdraw['settlement_begin_time'];
$settlementEndTime = $withdraw['settlement_end_time'];
$withdraw['create_time'] = date('Y-m-d H:i:s', $withdraw['create_time']);
$withdraw['settlement_end_time'] = date('Y-m-d H:i:s', $withdraw['settlement_end_time']);
$withdraw['status'] = FinanceController::$withdrawStatus[$withdraw['status']];
$map['withdraw_id'] = $withdrawId;
if (empty($withdraw['game_ratio'])) {
$map['_string'] = '1 = 2';
} else {
$gameRatios = json_decode($withdraw['game_ratio'], true);
$gameIds = array_keys($gameRatios);
$map['game_id'] = ['in', $gameIds];
$map['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]];
}
if ($withdraw['settlement_type'] != 3) {
$map['withdraw_id'] = $withdrawId;
}
$data = M('spend', 'tab_')
->field('game_name,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_way,sum(pay_amount) as pay_amount_all,sum(if(selle_ratio > 0,pay_amount * selle_ratio,0)) as income')
->field('game_id,game_name,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_way,sum(pay_amount) as pay_amount_all,sum(if(selle_ratio > 0,pay_amount * selle_ratio,0)) as income')
->where($map)
->group('game_id')
->order('game_id')
->select();
if (!empty($data)) {
foreach ($data as &$list) {
$list['income'] = bcdiv($list['income'], 100, 2);
$list['income'] = '0.00';
if (isset($gameRatios[$list['game_id']])) {
foreach ($gameRatios[$list['game_id']] as $gameIncome) {
$income = bcdiv(bcmul($gameIncome['sum_amount'], $gameIncome['selle_ratio'], 2), 100, 2);
$list['income'] = bcadd($list['income'], $income, 2);
}
}
}
}

@ -232,20 +232,20 @@ class PromoteController extends BaseController
$this->assign("rules", $rules);
$this->assign("rules_count", count($rules));
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
$cacheKey = "pop:rule:set";
if (!$redis->sIsMember($cacheKey, get_pid())) {
$currentTime = strtotime(date('Y-m-d'));
$weekArray = [7,1,2,3,4,5,6];
$week = $weekArray[date("w")];
$match_rules = M("document_pop_rules")
->field('id')
->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})")
->order("sort asc, id desc")
->select();
} else {
$match_rules = [];
}
// $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
// $cacheKey = "pop:rule:set";
// if (!$redis->sIsMember($cacheKey, get_pid())) {
// $currentTime = strtotime(date('Y-m-d'));
// $weekArray = [7,1,2,3,4,5,6];
// $week = $weekArray[date("w")];
// $match_rules = M("document_pop_rules")
// ->field('id')
// ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})")
// ->order("sort asc, id desc")
// ->select();
// } else {
// $match_rules = [];
// }
$this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null');
@ -972,6 +972,8 @@ class PromoteController extends BaseController
list($records, $pagination, $count) = $this->paginate($query);
foreach ($records as $key => $value) {
$realname = mb_strlen($value['real_name'],'utf-8') == 2 ? mb_substr($value['real_name'],0,1,'utf-8').'*':mb_substr($value['real_name'],0,1,'utf-8').'**';
$records[$key]['real_name'] = $realname;
$records[$key]['idcard'] = encryption($value['idcard']);
$records[$key]['mobile_phone'] = encryption($value['mobile_phone']);
}

@ -2112,7 +2112,7 @@ class QueryController extends BaseController
$records[] = [
'id' => $parent['id'],
'account' => $parent['account'],
'real_name' => $parent['real_name'],
'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**',
'level' => $parent['level'],
'create_role_count' => $selfCreateRoleCountList[$parent['id']],
'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']],
@ -2134,7 +2134,7 @@ class QueryController extends BaseController
$records[] = [
'id' => $id,
'account' => $promote['account'],
'real_name' => $promote['real_name'],
'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**',
'level' => $promote['level'],
'create_role_count' => $createRoleCountList[$id],
'create_role_user_count' => $createRoleUserCountList[$id],

@ -324,7 +324,7 @@ class SafeController extends BaseController{
$promoteInfo['personalstatus'] = true;
$promoteInfo['complanystatus'] = false;
}
if(!empty(json_decode($address))) {
if(!empty(json_decode($address)) && count(json_decode($address)) >= 2) {
$addressArr = explode(',', json_decode($address)[0]);
$promoteInfo['addressdata'] = $addressArr;
$this->assign('addr',json_decode($address)[1]);
@ -351,13 +351,16 @@ class SafeController extends BaseController{
} */
$promoteInfo = "";
$address = json_decode($rs['address'],false)[1];
$realname = mb_strlen($rs['real_name'],'utf-8') == 2 ? mb_substr($rs['real_name'],0,1,'utf-8').'*':mb_substr($rs['real_name'],0,1,'utf-8').'**';
$this->assign('addr',$address);
$this->assign('ver_status',$rs['ver_status']);
$this->assign('rs',$rs);
$this->assign('idcard',encryption($rs['idcard']));
$this->assign('real_name',$realname);
$this->assign('promoteInfo',$promoteInfo);
$this->assign('tel',$rs['mobile_phone']);
$this->assign('tel',encryption($rs['mobile_phone']));
$this->display();
}
}
public function edit() {
$id = get_pid();

@ -141,11 +141,11 @@
<th>游戏名称</th>
<th>流水</th>
<th>现金分成基数</th>
<th>现金分成比例</th>
<!-- <th>现金分成比例</th>-->
<th>平台币分成基数</th>
<th>平台币分成比例</th>
<!-- <th>平台币分成比例</th>-->
<th>绑定币分成基数</th>
<th>绑定币分成比例</th>
<!-- <th>绑定币分成比例</th>-->
<th>合作方分成金额</th>
</tr>
<if condition="true eq empty($listData) or $withdraw.status eq -1">
@ -165,19 +165,19 @@
<else/>
<td>0</td>
</if>
<td>{$vo.selle_ratio}%</td>
<!-- <td>{$vo.selle_ratio}%</td>-->
<if condition="$vo.pay_way eq 0">
<td>{$vo.pay_amount_all}</td>
<else/>
<td>0</td>
</if>
<td>{$vo.selle_ratio}%</td>
<!-- <td>{$vo.selle_ratio}%</td>-->
<if condition="$vo.pay_way eq -1">
<td>{$vo.pay_amount_all}</td>
<else/>
<td>0</td>
</if>
<td>{$vo.selle_ratio}%</td>
<!-- <td>{$vo.selle_ratio}%</td>-->
<td>{$vo.income}</td>
</tr>
</volist>

@ -134,13 +134,13 @@
<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>
<!-- <th>收益</th>-->
<th>订单状态</th>
<th>充值时间</th>
</tr>
@ -164,21 +164,21 @@
<else/>
<td>0</td>
</if>
<td>{$vo.selle_ratio}%</td>
<!-- <td>{$vo.selle_ratio}%</td>-->
<if condition="$vo.pay_way eq 0">
<td>{$vo.pay_amount}</td>
<else/>
<td>0</td>
</if>
<td>{$vo.selle_ratio}%</td>
<!-- <td>{$vo.selle_ratio}%</td>-->
<if condition="$vo.pay_way eq -1">
<td>{$vo.pay_amount}</td>
<else/>
<td>0</td>
</if>
<td>{$vo.selle_ratio}%</td>
<!-- <td>{$vo.selle_ratio}%</td>-->
<td>{$vo.pay_way_name}</td>
<td>{$vo.income}</td>
<!-- <td>{$vo.income}</td>-->
<td>{$status}</td>
<td>{$vo.pay_time}</td>
</tr>

@ -121,10 +121,10 @@
<div class="zizhi">
<div class="line_title">资质认证</div>
<div class="line_text">
真实姓名: {$rs['real_name']}
真实姓名: {$real_name}
</div>
<div class="line_text">
身份证号码: {$rs['idcard']}
身份证号码: {$idcard}
</div>
<div class="line_text">
身份证扫描: <span style="color:#449acb">已认证<span>

@ -1105,4 +1105,9 @@ ALTER TABLE `tab_promote_game_ratio`
MODIFY COLUMN `turnover_ratio` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '流水分成比例' AFTER `last_ratio_status`,
MODIFY COLUMN `last_turnover_ratio` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '上次流水分成比例';
UPDATE tab_spend SET selle_ratio = 0.00 where selle_ratio is null
UPDATE tab_spend SET selle_ratio = 0.00 where selle_ratio is null
ALTER TABLE `tab_promote_game_ratio`
ADD COLUMN `relation_game_id` int(11) NOT NULL DEFAULT 0 COMMENT '关联游戏id' AFTER `game_id`;
ALTER TABLE `tab_promote_game_ratio_log`
ADD COLUMN `relation_game_id` int(11) NOT NULL DEFAULT 0 COMMENT '关联游戏id' AFTER `game_id`;
Loading…
Cancel
Save