Merge branch 'feature/promote' of 47.111.118.107:/srv/git/platform into feature/promote

master
chenzhi 5 years ago
commit b4c9f60ac9

@ -1 +1 @@
{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":0,"active":0,"player":0,"money":0},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]} {"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":21},{"time":"17:00","count":10},{"time":"18:00","count":7},{"time":"19:00","count":11},{"time":"20:00","count":11},{"time":"21:00","count":8},{"time":"22:00","count":11},{"time":"23:00","count":10}],"sum":{"news":89,"active":2506,"player":378,"money":33093},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":851},{"time":"17:00","count":280},{"time":"18:00","count":142},{"time":"19:00","count":105},{"time":"20:00","count":81},{"time":"21:00","count":143},{"time":"22:00","count":420},{"time":"23:00","count":484}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":179},{"time":"17:00","count":54},{"time":"18:00","count":28},{"time":"19:00","count":24},{"time":"20:00","count":14},{"time":"21:00","count":12},{"time":"22:00","count":27},{"time":"23:00","count":40}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":"15639.00"},{"time":"17:00","count":"5328.00"},{"time":"18:00","count":"5490.00"},{"time":"19:00","count":"1178.00"},{"time":"20:00","count":"1274.00"},{"time":"21:00","count":"484.00"},{"time":"22:00","count":"2327.00"},{"time":"23:00","count":"1373.00"}]}

@ -162,63 +162,69 @@ class PromoteService {
$coinRecordService = new PromoteCoinRecordService(); $coinRecordService = new PromoteCoinRecordService();
$promoteCoinService = new PromoteCoinService(); $promoteCoinService = new PromoteCoinService();
$toPromoteId = $task['to_promote_id'];
$fromPromoteId = $task['from_promote_id'];
$balanceCoinMode = $task['balance_coin_mode']; $balanceCoinMode = $task['balance_coin_mode'];
$toPromote = D('promote')->where(['id' => $toPromoteId])->find(); $toPromote = M('promote', 'tab_')->where(['id' => $task['to_promote_id']])->find();
$fromPromote = D('promote')->where(['id' => $fromPromoteId])->find(); $fromPromote = M('promote', 'tab_')->where(['id' => $task['from_promote_id']])->find();
$topPromote = $this->getTopPromote($fromPromote); $topPromote = $this->getTopPromote($fromPromote);
$status = $this->shiftRemoveCoin($fromPromote, $task);
$status = $this->shiftRemoveCoin($fromPromote, $topPromote, $task);
// 测试
// $model->rollback();
if (!$status) { if (!$status) {
$model->rollback(); $model->rollback();
return ['status' => false, 'msg' => '系统异常2']; return ['status' => false, 'msg' => '系统异常, 处理推广员平台币失败'];
} }
$promote = new PromoteModel(); $firstMap = ['parent_id' => $fromPromote['id']];
$updateData = [ $secondMap = ['chain' => ['like', $fromPromote['chain'] . $fromPromote['id'] . '/%']];
'parent_id' => $toPromote['id'] if ($task['shift_ids'] != '') {
]; $shiftIds = json_decode($task['shift_ids'], true) ?? [];
$updateData = [ $firstMap['id'] = ['in', $shiftIds];
'chain' => ['exp', 'replace(chain,\''.$fromPromote['chain'].'\',\''. $toPromote['chain'].'\')'] $secondMap['id'] = ['in', $shiftIds];
];
if ($fromPromote['grand_id'] == 0) {
$status = $promote->where('parent_id=' . $fromPromoteId)->save($updateData);
} else {
$status = $promote->where('id=' . $fromPromoteId)->save($updateData);
} }
$status = M('promote', 'tab_')->where($firstMap)->save(['parent_id' => $toPromote['id']]);
if (!$status) { if (!$status) {
$model->rollback(); $model->rollback();
return ['status' => false, 'msg' => '系统异常1']; return ['status' => false, 'msg' => '系统异常,修改推广员上级失败'];
}
$status = M('promote', 'tab_')->where($secondMap)->save(['chain' => $toPromote['chain'] . $toPromote['id'] . '/']);
if (!$status) {
$model->rollback();
return ['status' => false, 'msg' => '系统异常修改推广员CHAIN失败'];
} }
$status1 = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1]); $status1 = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1]);
if (!$status1) { if (!$status1) {
$model->rollback(); $model->rollback();
return ['status' => false, 'msg' => '系统异常3']; return ['status' => false, 'msg' => '系统异常,修改迁移任务状态失败'];
} }
$model->commit(); $model->commit();
return ['status' => true, 'msg' => '推广帐号迁移成功']; return ['status' => true, 'msg' => '推广帐号迁移成功'];
} }
public function shiftRemoveCoin($promote, $topPromote, $task) public function shiftRemoveCoin($promote, $task)
{ {
$shiftIds = null;
if ($task['shift_ids'] != '') {
$shiftIds = json_decode($task['shift_ids'], true) ?? [];
}
$topPromote = $this->getTopPromote($promote);
$coinRecordService = new PromoteCoinRecordService(); $coinRecordService = new PromoteCoinRecordService();
$promoteCoinService = new PromoteCoinService(); $promoteCoinService = new PromoteCoinService();
$topBalanceCoin = $this->getBalanceCoin($topPromote['id'], 0); $topBalanceCoin = $this->getBalanceCoin($topPromote['id'], 0);
$topBalancePlus = 0; $topBalancePlus = 0;
$promotes = D('promote')->field(['id', 'balance_coin'])->where(['parent_id' => $promote['id']])->select(); $map = ['chain' => $promote['chain'] . $chain['id'] . '/%'];
$ids = array_column($promotes, 'id'); if ($shiftIds != null) {
$map['id'] = ['in', $shiftIds];
}
$subPromotes = M('promote', 'tab_')->field(['id', 'balance_coin'])->where($map)->select();
$ids = array_column($subPromotes, 'id');
$ids[] = $promote['id']; $ids[] = $promote['id'];
$promoteCoins = []; $promoteCoins = [];
$balances = M('PromoteBalanceCoin', 'tab_')->where(['promote_id' => ['in', $ids]])->select(); $balances = M('PromoteBalanceCoin', 'tab_')->where(['promote_id' => ['in', $ids]])->select();
@ -306,8 +312,6 @@ class PromoteService {
$toPromote = D('promote')->where(['id' => $toPromoteId])->find(); $toPromote = D('promote')->where(['id' => $toPromoteId])->find();
$fromPromote = D('promote')->where(['id' => $fromPromoteId])->find(); $fromPromote = D('promote')->where(['id' => $fromPromoteId])->find();
// $promote = new PromoteModel();
// $promote->where('parent_id=' . $fromPromoteId)->save(['parent_id' => $toPromoteId]);
$user1 = new UserModel(); $user1 = new UserModel();
$users = $user1->field(['id', 'account', 'nickname'])->where('promote_id=' . $fromPromoteId)->select(); $users = $user1->field(['id', 'account', 'nickname'])->where('promote_id=' . $fromPromoteId)->select();

@ -0,0 +1,17 @@
<?php
namespace Home\Controller;
use OT\DataDictionary;
use User\Api\PromoteApi;
use Base\Repository\PromoteRepository;
use Base\Repository\SpendRepository;
use Base\Repository\UserRepository;
/**
* 财务管理
*/
class FinanceController extends BaseController
{
}

@ -938,7 +938,6 @@ class PromoteController extends BaseController
list($records, $pagination, $count) = $this->paginate($query); list($records, $pagination, $count) = $this->paginate($query);
$ids = array_column($records, 'id'); $ids = array_column($records, 'id');
$parentIds = array_column($records, 'parent_id');
$countList = []; $countList = [];
$playerList = []; $playerList = [];
@ -949,10 +948,10 @@ class PromoteController extends BaseController
$playerList = M('user_play', 'tab_')->field(['count(*)' => 'count', 'promote_id' => 'promote_id'])->where(['promote_id' => ['in', $ids]])->group('promote_id')->select(); $playerList = M('user_play', 'tab_')->field(['count(*)' => 'count', 'promote_id' => 'promote_id'])->where(['promote_id' => ['in', $ids]])->group('promote_id')->select();
$shiftList = M('shift_task', 'sys_')->field(['count(*)' => 'count', 'from_promote_id' => 'from_promote_id'])->where(['status' => 0, 'type' => 1, 'promote_id' => ['in', $ids]])->group('from_promote_id')->select(); $shiftList = M('shift_task', 'sys_')->field(['count(*)' => 'count', 'from_promote_id' => 'from_promote_id'])->where(['status' => 0, 'type' => 1, 'promote_id' => ['in', $ids]])->group('from_promote_id')->select();
$shiftPlayerList = M('shift_task', 'sys_')->field(['count(*)' => 'count', 'from_promote_id' => 'from_promote_id'])->where(['status' => 0, 'type' => 2, 'promote_id' => ['in', $ids]])->group('from_promote_id')->select(); $shiftPlayerList = M('shift_task', 'sys_')->field(['count(*)' => 'count', 'from_promote_id' => 'from_promote_id'])->where(['status' => 0, 'type' => 2, 'promote_id' => ['in', $ids]])->group('from_promote_id')->select();
$countList = array_column($countList, 'parent_id'); $hasChildList = array_column($countList, 'parent_id');
$playerList = array_column($playerList, 'promote_id'); $hasPlayerList = array_column($playerList, 'promote_id');
$shiftList = array_column($shiftList, 'from_promote_id'); $hasShiftList = array_column($shiftList, 'from_promote_id');
$shiftPlayerList = array_column($shiftPlayerList, 'from_promote_id'); $hasShiftPlayerList = array_column($shiftPlayerList, 'from_promote_id');
} }
if ($promoteType == 0) { if ($promoteType == 0) {
@ -964,10 +963,10 @@ class PromoteController extends BaseController
} }
$this->assign('promoteTypeName', $promoteTypeName); $this->assign('promoteTypeName', $promoteTypeName);
$this->assign('countList', $countList); $this->assign('hasChildList', $hasChildList);
$this->assign('playerList', $playerList); $this->assign('hasPlayerList', $hasPlayerList);
$this->assign('shiftList', $shiftList); $this->assign('hasShiftList', $hasShiftList);
$this->assign('shiftPlayerList', $shiftPlayerList); $this->assign('hasShiftPlayerList', $hasShiftPlayerList);
$this->assign('count', $count); $this->assign('count', $count);
$this->assign('pagination', $pagination); $this->assign('pagination', $pagination);
$this->assign('records', $records); $this->assign('records', $records);
@ -2291,6 +2290,26 @@ class PromoteController extends BaseController
$this->display(); $this->display();
} }
} }
public function getSubPromotes()
{
$level = I('level', 0);
$promoteId = I('promote_id', 0);
$promote = $this->getLoginPromote();
if ($promoteId > 0) {
$promote = M('promote', 'tab_')->where(['id' => $promoteId])->find();
}
$map = ['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']];
if ($level > 0) {
$map['level'] = $level;
}
$promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where($map)->select();
$this->ajaxReturn([
'status' => 1,
'msg' => '成功',
'data' => ['promotes' => $promotes]
]);
}
} }

@ -13,7 +13,8 @@
</div> </div>
<div class="trunk-content article"> <div class="trunk-content article">
<div class="trunk-search clearfix"> <div class="trunk-search clearfix">
<form action="{:U('Promote/mychlid',array('row'=>I('get.row')))}" method="post" enctype="multipart/form-data"> <form action="{:U('Promote/children',array('row'=>I('get.row')))}" method="post" enctype="multipart/form-data">
<input type="hidden" name="promote_type" value="{:I('promote_type', 0)}">
<div class="form-group fl normal_space"> <div class="form-group fl normal_space">
<a href="{:U('Promote/addPromote', ['promote_type' => I('promote_type', 0)])}" class="submit btn"><i class="add_qudao"></i><span>添加{$promoteTypeName}</span></a> <a href="{:U('Promote/addPromote', ['promote_type' => I('promote_type', 0)])}" class="submit btn"><i class="add_qudao"></i><span>添加{$promoteTypeName}</span></a>
</div> </div>
@ -137,9 +138,6 @@
<div class="form-item"> <div class="form-item">
<select name="to_promote_id" class="reselect select_gallery" style="width: 220px;" > <select name="to_promote_id" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择推广账号</option> <option value="0">请选择推广账号</option>
<volist name="promotes" id="promote">
<option ba-id="{$promote.id}" value="{$promote.id}">{$promote.account}</option>
</volist>
</select> </select>
</div> </div>
</div> </div>
@ -176,9 +174,6 @@
<div class="form-item"> <div class="form-item">
<select name="to_promote_id" class="reselect select_gallery" style="width: 220px;" > <select name="to_promote_id" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择推广账号</option> <option value="0">请选择推广账号</option>
<volist name="subPromotes" id="promote">
<option ba-id="{$promote.id}" value="{$promote.id}">{$promote.account}</option>
</volist>
</select> </select>
</div> </div>
</div> </div>
@ -205,6 +200,30 @@
$(function(){ $(function(){
$(".select_gallery").select2(); $(".select_gallery").select2();
var promoteType = $('input[name=promote_type]').val()
var level = 0
if (promoteType == 0) {
level = 2
} else if (promoteType == 1) {
level = 3
} else if (promoteType == 2) {
level = 4
}
$.ajax({
url: "{:U('Promote/getSubPromotes')}",
data: {level: level},
type: 'post',
dataType: 'json',
success: function(response) {
var options = '<option value="0">请选择推广账号</option>'
for (var i in response.data.promotes) {
var promote = response.data.promotes[i]
options += '<option value="' + promote.id + '">' + promote.account + '(' + promote.real_name + ')' + '</option>'
}
$('select[name=to_promote_id]').html(options)
}
})
$('#shift-player-order-time').datetimepicker({ $('#shift-player-order-time').datetimepicker({
format: 'yyyy-mm-dd', format: 'yyyy-mm-dd',
language:"zh-CN", language:"zh-CN",
@ -379,6 +398,7 @@ $(function(){
} }
}) })
$('.shift-player-btn').on({ $('.shift-player-btn').on({
click: function() { click: function() {
var box = $('#shift-player-box') var box = $('#shift-player-box')

Loading…
Cancel
Save