解决冲突

master
chenzhi 5 years ago
commit bc75da8c14

@ -2470,5 +2470,137 @@ function getAvailableBalance($promote_id=0,$game_id=0,$server_id='') {
}
function getMarketGroupIds()
{
return ['11', '12'];
}
function getAdmins()
{
return M('ucenter_member', 'sys_')->select();
}
function getMarketAdmins()
{
$ids = getMarketGroupIds();
$adminIds = M('auth_group_access', 'sys_')->where(['group_id' => ['in', $ids]])->getField('uid', true);
return M('ucenter_member', 'sys_')->where(['id' => ['in', $adminIds]])->select();
}
function getMarketAdminsByPromoteIds($promoteIds)
{
if (count($promoteIds) == 0) {
return [];
}
$promotes = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => ['in', $promoteIds]])->select();
$resultMap = [];
foreach ($promotes as $promote) {
if ($promote['chain'] == '/') {
$resultMap[$promote['id']] = ['top_id' => $promote['id']];
} else {
$item = explode('/', trim($promote['chain'], '/'));
$resultMap[$promote['id']] = ['top_id' => $item[0]];
}
}
if (count($promotes) == 0) {
return [];
}
$topPromotes = M('promote', 'tab_')->field(['id', 'admin_id'])->where(['id' => ['in', array_column($resultMap, 'top_id')]])->select();
$topAdminMap = [];
foreach ($topPromotes as $topPromote) {
$topAdminMap[$topPromote['id']] = $topPromote['admin_id'];
}
$admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', array_column($topPromotes, 'admin_id')]])->select();
$admins = index_by_column('id', $admins);
foreach ($resultMap as &$row) {
$adminId = $topAdminMap[$row['top_id']] ?? 0;
$admin = $admins[$adminId] ?? null;
$row['admin'] = $admin;
}
return $resultMap;
}
function getAdminUsernameList(array $ids)
{
if (count($ids) == 0) {
return [];
}
$admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', $ids]])->select();
$items = [];
foreach ($admins as $admin) {
$items[$admin['id']] = $admin['username'];
}
return $items;
}
function isMarketLeader()
{
$authGroup = M('sys_auth_group')->where(['title'=>'市场总监'])->find();
if (!$authGroup) {
return false;
}
$userAuth = session('user_auth');
$adminIds = M('auth_group_access', 'sys_')->where(['group_id' => $authGroup['id']])->getField('uid', true);
return in_array($userAuth['uid'], $adminIds);
}
function isMarketAdmin()
{
$ids = getMarketGroupIds();
$userAuth = session('user_auth');
$adminIds = M('auth_group_access', 'sys_')->where(['group_id' => ['in', $ids]])->getField('uid', true);
return in_array($userAuth['uid'], $adminIds);
}
function getPromoteIdsByTopIds($ids)
{
if (count($ids) == 0) {
return [];
}
$idsExp = implode(',', $ids);
$map = array();
$where['SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,"/",2),"/",-1)'] = array('exp',"IN({$idsExp})");
$where['id'] = array('in', $ids);//会长本身
$where['_logic'] = 'or';
$map['_complex'] = $where;
$result = M('promote', 'tab_')->field('id')->where($map)->getField('id', true);
return $result;
}
function getCompanyDevelopTypes()
{
return [
1 => '自主开发',
2 => '自主开发及维护',
3 => '只维护'
];
}
?>
function getCompanyDevelopTypeText($type)
{
return getCompanyDevelopTypes()[$type] ?? '无';
}
function withMarketAdminCondition($map, $searchMarketAdminId = 0)
{
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
}
if ($adminId == 0) {
$adminId = $searchMarketAdminId > 0 ? $searchMarketAdminId : 0;
}
if ($adminId) {
$topPromoteIds = M('promote', 'tab_')->where(['admin_id' => $adminId, 'level' => 1])->getField('id', true);
$promoteIds = getPromoteIdsByTopIds($topPromoteIds);
if (count($promoteIds) == 0) {
$promoteIds = [-1];
}
$map['promote_id'] = ['in', $promoteIds];
}
return $map;
}

@ -975,7 +975,7 @@ function getModuleControllerAuth()
$group = $_SESSION['onethink_admin']['user_group_id'];
//获取全部权限列表
$ruleList = M("AuthGroup")->field("rules")->where("id='{$group}'")->find()['rules'];
//获取所有含有规则的数据
$mc = MODULE_NAME."/".CONTROLLER_NAME;
$authlist = M("AuthRule")->field('name')->where("name like '{$mc}%' AND id in ($ruleList)")->select();
@ -987,3 +987,37 @@ function getModuleControllerAuth()
return $Auth;
}
function PromoteStatistics($orderNo) {
$spend = M("spend","tab_")
->field("promote_id,promote_account,pay_time,pay_amount")
->where(array('pay_order_number'=>$orderNo))
->find();
$start = strtotime(date("Ymd",$spend['pay_time']));
$statisticsData = M("promote_statistics","tab_")
->where(['promote_id'=>$spend['promote_id'],'time'=>$start])
->find();
$statisticsData['count']?$statisticsData['count']:$statisticsData['count']=0;
$insert['promote_id'] = $spend['promote_id'];
$insert['promote_account'] = $spend['promote_account'];
$insert['count'] = $spend['pay_amount']?(($spend['pay_amount']*100)+$statisticsData['count']):0;
$insert['time'] = $start;
if ($statisticsData) {
M("promote_statistics","tab_")
->where(['promote_id'=>$spend['promote_id'],'time'=>$start])
->save($insert);
} else {
M("promote_statistics","tab_")->add($insert);
}
}

@ -10,6 +10,8 @@ use Base\Tool\TaskClient;
use Base\Service\PromoteService;
use GuzzleHttp\Client;
use think\Db;
use Base\Task\Task;
use Base\Service\MarketService;
class ConsoleController extends Think {
@ -92,6 +94,60 @@ class ConsoleController extends Think {
}
}
public function runTask($queue = 'common', $count = 10)
{
Printer::export($queue);
Printer::export($count);
try {
$task = new Task($queue);
$task->run($count);
Printer::export('运行完成');
} catch (\Exception $e) {
Printer::export($e->getMessage());
}
}
public function addTask()
{
/* $id = M('market_shift', 'tab_')->add([
'from_id' => 1,
'to_id' => 2,
'split_time' => 0,
'created_time' => time()
]);
$params = [
'market_shift_id' => $id
]; */
for ($i=0; $i<50; $i++) {
Task::add('test', ['value' => $i]);
}
}
public function initMarketAdmin()
{
$marketService = new MarketService();
$promoteService = new PromoteService();
$promotes = M('promote', 'tab_')->field(['id', 'admin_id', 'account', 'chain', 'level'])
->where(['level' => 1, 'admin_id' => ['gt', 0], 'company_belong' => ['in', [1, 2]]])
->select();
foreach ($promotes as $promote) {
Printer::export('处理会长: ' . $promote['account']);
$subPromotes = $promoteService->getAllChildren($promote, 0, ['id']);
$promoteIds = [$promote['id']];
$promoteIds = array_merge(array_column($subPromotes, 'id'), $promoteIds);
$marketService->shiftSpend($promoteIds, 0, $promote['admin_id']);
$marketService->shiftDeposit($promoteIds, 0, $promote['admin_id']);
}
}
public function initPromoteAdmin()
{
$promotes = M('promote', 'tab_')->field(['id', 'chain', 'level', 'admin_id'])->where(['level' => 1, 'admin_id' => ['gt', 0]])->select();
foreach ($promotes as $promote) {
M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->save(['admin_id' => $promote['admin_id']]);
}
}
public function modifyLoginRepair()
{
$this->modifyLogin(1569686400);

@ -64,8 +64,8 @@ class ExportController extends Controller
// array('play_ip', "最后登录ip"),
// );
$xlsCell = array(
"创建时间","玩家账号", "游戏名称","游戏区服", L('Game_area_clothing'), "角色ID", "角色名", "游戏等级","所属推广员",
"最后登录时间", '最后登录ip',
"创建时间","玩家账号", "游戏名称","游戏区服", L('Game_area_clothing'), "角色ID", "角色名", "游戏等级","推广员ID", "所属推广员",
"最后登录时间", '最后登录ip','所属市场专员'
);
if (isset($_REQUEST['game_name'])) {
$map['game_name'] = ['like', trim($_REQUEST['game_name'])."%"];
@ -92,6 +92,8 @@ class ExportController extends Controller
unset($_REQUEST['role_name']);
}
$map = withMarketAdminCondition($map, I('market_admin_id', 0));
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
@ -147,13 +149,15 @@ class ExportController extends Controller
for($i = 1; $i <= $pages; $i++) {
$xlsData = M('user_play_info', 'tab_')
->field("create_time,user_account,game_name,server_id,server_name,role_id,role_name,role_level,promote_account,play_time,play_ip")
->field("create_time,user_account,game_name,server_id,server_name,role_id,role_name,role_level,promote_id,promote_account,play_time,play_ip")
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->order('play_time desc')
->select();
$adminList = getMarketAdminsByPromoteIds(array_column($xlsData, 'promote_id'));
foreach($xlsData as $value) {
$value['market_admin_username'] = isset($adminList[$value['promote_id']]) && $adminList[$value['promote_id']]['admin'] ? $adminList[$value['promote_id']]['admin']['username'] : '无';
($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
$value['create_time'] = date("Y-m-d H:i:s",$value['create_time']);
$value['play_time'] = date("Y-m-d H:i:s",$value['play_time']);
@ -1127,6 +1131,17 @@ class ExportController extends Controller
unset($_REQUEST['pay_game_status']);
}
$marketAdminId = I('market_admin_id', 0);
if ($marketAdminId) {
$map['market_admin_id'] = $marketAdminId;
}
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$map['market_admin_id'] = $userAuth['uid'];
}
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
@ -1174,7 +1189,7 @@ class ExportController extends Controller
$xlsCell = array(
"支付订单号","CP订单号", "充值时间","支付时间", "玩家账号", "游戏名称", L('Subordinate_channel'), '所属推广公司', "充值ip","区服ID", "游戏区服",
"支付订单号","CP订单号", "充值时间","支付时间", "玩家账号", "游戏名称", L('Subordinate_channel'), "所属推广公司", "所属市场专员", "充值ip","区服ID", "游戏区服",
"角色ID","角色名称", "订单金额", "实付金额", "充值方式", L('Order_status'), "游戏通知状态", "消费"."{$total}"
);
@ -1206,13 +1221,14 @@ class ExportController extends Controller
// ->join($tab_promote_join)
// ->order('pay_time DESC')
// ->select();
->field('pay_order_number,extend,pay_time,payed_time,user_account,game_name,promote_account, 0 as company_name, spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status, promote_id')
->field('pay_order_number,extend,pay_time,payed_time,user_account,game_name,promote_account, 0 as company_name,market_admin_id,spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status, promote_id')
// ->join('tab_promote on tab_promote.id = tab_spend.promote_id', 'left')
// ->join('tab_promote_company on tab_promote_company.id and tab_promote.company_id', 'left')
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->order($order ? $order : 'pay_time desc')
->select();
$adminUsernameList = getAdminUsernameList(array_column($xlsData, 'market_admin_id'));
$promoters = D('Promote')->where(['id'=>['in', array_unique(array_column($xlsData, 'promote_id'))]])->field('id, company_id')->select();
$promoters = $promoters ? array_column($promoters, 'company_id', 'id') : [];
$companys = $promoters ? M('promote_company', 'tab_')->where(['id'=>['in', array_unique(array_values($promoters))]])->field('id, company_name')->select() : [];
@ -1234,6 +1250,7 @@ class ExportController extends Controller
$value['pay_way'] = get_pay_way($value['pay_way']);
$value['pay_status'] = get_info_status($value['pay_status'],9);
$value['pay_game_status'] = get_info_status($value['pay_game_status'],14);
$value['market_admin_id'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
mb_convert_variables('GBK', 'UTF-8', $value);
fputcsv($fp, $value);
}

@ -59,7 +59,6 @@ class FinancePromoteController extends AdminController
$senddata[$v['p_id']] = $v;
};
}
//官方渠道单算
//判断公司
$gfidlag = true;
@ -76,6 +75,15 @@ class FinancePromoteController extends AdminController
$nwtflag = false;
}
}
if(isset($_REQUEST['admin_id'])){
if($_REQUEST['admin_id']!=0){
$nwtflag = false;
}
}
$isMarketAdmin = isMarketAdmin();
if(I('admin_id', 0) != 0 || $isMarketAdmin){
$nwtflag = false;
}
if (isset($_REQUEST['promote_id'])) {
if($_REQUEST['promote_id'] == 0){
$gfidlag = true;
@ -83,6 +91,10 @@ class FinancePromoteController extends AdminController
$gfidlag =false;
}
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$nwtflag = false;
}
// dd($gfidlag && $gfgs && $nwtflag);
if($gfidlag && $gfgs && $nwtflag){
//计算官方渠道
@ -110,7 +122,17 @@ class FinancePromoteController extends AdminController
"bind_coin_count"=>0,
"inside_cash_count"=>0,
);
$promotes = [];
if (count($senddata) > 0) {
$promoteIds = array_column($senddata, 'p_id');
if ($promoteIds) {
$promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', $promoteIds]])->select();
}
}
$promotes = index_by_column('id', $promotes);
$adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id'));
foreach($senddata as $k=>$v){
$promote = $promotes[$v['p_id']] ?? null;
$v['company_belong'] = $v['company_belong'] ?:0;
$v['company_belong'] = getCompanyBlong($v['company_belong']);
if(empty($v['company_name'])) $v['company_name']= $this->COMPANY_NAME;
@ -121,6 +143,8 @@ class FinancePromoteController extends AdminController
if(!array_key_exists('inside_cash_count',$v)) $v['inside_cash_count']=0;
$v['promote_account'] = get_promote_name($v['p_id']);
($v['promote_account']=='官方渠道')?($v['promote_account']=C('OFFICIEL_CHANNEL')):'';
$v['admin_username'] = $adminUsernames[$promote['admin_id']] ?? '无';
$v['develop_type_text'] = getCompanyDevelopTypeText($v['develop_type']);
$v['inside_cash_count'] = number_format($v['inside_cash_count'],2,'.','');
$v['allcount'] = number_format($v['cash_count']-0+$v['balance_coin_count']+$v['bind_coin_count'],2,'.','');
$count['cash_count'] += $v['cash_count'];
@ -140,7 +164,9 @@ class FinancePromoteController extends AdminController
data2csv($data,'公会统计',array(
"company_name"=>"推广公司",
"promote_account"=>"会长渠道",
"company_belong"=>"内外团",
"admin_username"=>"所属市场专员",
"company_belong"=>"团体类型",
"develop_type_text"=>"开发类型",
"cash_count"=>"游戏现金金额",
"balance_coin_count"=>"平台币直充支出",
"bind_coin_count"=>"内充支出",
@ -207,9 +233,32 @@ class FinancePromoteController extends AdminController
}
if (isset($_REQUEST['company_belong'])) {
$map['promote.company_belong'] = $_REQUEST['company_belong'];
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0];
}
if (!empty(I('develop_type'))) {
$map['company.develop_type'] = I('develop_type');
}
$adminId = 0;
$havingPids = [];
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
if ($adminId > 0) {
$havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
}
if($type == "spend"){
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
@ -223,31 +272,52 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count,
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_id,0) company_id,company_name,IFNULL(promote.company_belong,0) company_belong";
return M()
IFNULL(company_id,0) company_id,company_name,develop_type,IFNULL(promote.company_belong,0) company_belong";
$query = M()
->table("tab_spend s use index(promote_time)")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left")
->group('p_id')
->select();
->group('p_id');
if (count($havingPids) > 0) {
$query->having('p_id in (' . implode(',', $havingPids) . ')');
}
return $query->select();
}else{
if($istimeselect){
$map['s.create_time']=$istimeselect;
}
$adminId = 0;
$havingPids = [];
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
if ($adminId > 0) {
$havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
}
$map['s.status']=1;
$map['s.source_id']=0;
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,IFNULL(if(substring_index(substring_index(`chain`,'/',2),'/',-1)='',
s.promote_id,substring_index(substring_index(`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_id,0) company_id,company_name,IFNULL(promote.company_belong,0) company_belong";
return M("promote_coin s","tab_")
$query = M("promote_coin s","tab_")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left")
->group('p_id')
->select();
->group('p_id');
if (count($havingPids) > 0) {
$query->having('p_id in (' . implode(',', $havingPids) . ')');
}
return $query->select();
}
}
@ -320,8 +390,19 @@ class FinancePromoteController extends AdminController
"bind_coin_count"=>0,
"inside_cash_count"=>0,
);
foreach($senddata as $k=>$v){
$marketAdmins = [];
if (count($senddata) > 0) {
$promoteIds = array_column($senddata, 'promote_id');
if (count($promoteIds)) {
$marketAdmins = getMarketAdminsByPromoteIds($promoteIds);
}
}
foreach($senddata as $k=>$v){
$promote = $promotes[$v['promote_id']] ?? null;
$v['admin_username'] = isset($marketAdmins[$v['promote_id']]) && $marketAdmins[$v['promote_id']]['admin'] ? $marketAdmins[$v['promote_id']]['admin']['username'] : '无';
$v['develop_type_text'] = getCompanyDevelopTypeText($v['develop_type']);
$v['company_belong'] = getCompanyBlong($v['company_belong']);
if(empty($v['company_name'])) $v['company_name']= $this->COMPANY_NAME;
if(empty($v['promote_account'])) $v['promote_account']= C('OFFICIEL_CHANNEL');
@ -355,7 +436,9 @@ class FinancePromoteController extends AdminController
data2csv($data,'渠道统计',array(
"company_name"=>"推广公司",
"promote_account"=>"推广员账号",
"company_belong"=>"内外团",
"admin_username"=>"所属市场专员",
"company_belong"=>"团体类型",
"develop_type_text"=>"开发类型",
"cash_count"=>"游戏现金金额",
"balance_coin_count"=>"平台币直充支出",
"bind_coin_count"=>"内充支出",
@ -381,41 +464,92 @@ class FinancePromoteController extends AdminController
$map['promote.company_id'] = $_REQUEST['company_id'];
}
if ($type == "spend") {
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
}
if($istimeselect){
$map['s.pay_time']=$istimeselect;
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['s.market_admin_id'] = ['gt', 0];
$map['promote.admin_id'] = ['gt', 0];
}
if ($adminId) {
$map['s.market_admin_id'] = $adminId;
}
$map['s.pay_status']=1;
// dd($map);
$field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL(promote.company_belong,0) company_belong";
return M()
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,develop_type,IFNULL(promote.company_belong,0) company_belong";
$query = M()
->table("tab_spend s use index(promote_time)")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id", "left")
->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id')
->select();
->group('promote_id');
$havingPids = [];
if ($adminId > 0) {
$topIds = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = getPromoteIdsByTopIds($topIds);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
$query->having('promote_id in (' . implode(',', $havingPids) . ')');
}
return $query->select();
}else{
if($istimeselect){
$map['s.create_time']=$istimeselect;
}
$map['s.status']=1;
$map['s.source_id']=0;
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0];
}
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL(promote.company_belong,0) company_belong";
return M("promote_coin s","tab_")
$query = M("promote_coin s","tab_")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id')
->select();
->group('promote_id');
$havingPids = [];
if ($adminId > 0) {
$topIds = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = getPromoteIdsByTopIds($topIds);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
$query->having('promote_id in (' . implode(',', $havingPids) . ')');
}
return $query->select();
}
}
/**
@ -440,6 +574,14 @@ class FinancePromoteController extends AdminController
} elseif (isset($_REQUEST['time_end'])) {
$map['s.pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399];
}
if (!empty(I('develop_type'))) {
$map['develop_type'] = I('develop_type');
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['promote.admin_id'] = ['gt', 0];
$map['s.market_admin_id'] = ['gt', 0];
}
//获取推广员
$title = '';
@ -455,7 +597,18 @@ class FinancePromoteController extends AdminController
}else {
$data =self::gameStatisticsData($map, $row, $p);
}
$promotes = [];
if (count($data) > 0) {
$promoteIds = array_column($data, 'p_id');
if (count($promoteIds) > 0) {
$promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', $promoteIds]])->select();
}
}
$promotes = index_by_column('id', $promotes);
$adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id'));
foreach ($data as $key => &$value) {
$promote = $promotes[$value['p_id']] ?? null;
$value['cash_count']?:0;
$value['balance_coin_count']?:0;
$value['inside_cash_count']?:0;
@ -463,6 +616,9 @@ class FinancePromoteController extends AdminController
$value['company_belong'] =getCompanyBlong($value['company_belong']);
($value['account']=='官方渠道')?($value['account']=C('OFFICIEL_CHANNEL')):'';
$value['admin_username'] = $adminUsernames[$promote['admin_id']] ?? '无';
$value['develop_type_text'] = getCompanyDevelopTypeText($value['develop_type']);
$value['game_name'] =clearGameNameType($value['game_name']);
$value['sdk_version'] =getGameTypeName($value['sdk_version']);
@ -481,7 +637,9 @@ class FinancePromoteController extends AdminController
data2csv($data,$title, array(
"company_name"=>"推广公司",
"account"=>"会长账号",
"admin_username"=>"所属市场专员",
"company_belong"=>"团体类型",
"develop_type_text"=>"开发类型",
"game_name"=>"游戏",
"sdk_version"=>"设备",
"cash_count"=>"游戏现金金额",
@ -540,6 +698,35 @@ class FinancePromoteController extends AdminController
$map['pay_order_number'] = $_REQUEST['pay_order_number'];
}
$adminId = 0;
$havingPids = [];
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
$isMarketLeader = isMarketLeader();
if ($isMarketLeader) {
$map['market_admin_id'] = ['gt', 0];
}
if ($adminId > 0) {
$map['market_admin_id'] = $adminId;
}
/* if (!empty(I('develop_type'))) {
$map['company.develop_type'] = I('develop_type');
}
if (!empty(I('admin_id'))) {
$map['market_admin_id'] = I('admin_id');
} */
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type']) || isset($_REQUEST['partner_id'])) {
$map["game_id"] = array("in",implode(',', array_column(getGameidByPartnerNameType($_REQUEST['partner_id'],$_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
}
@ -579,7 +766,7 @@ class FinancePromoteController extends AdminController
if (!empty(I('user_nickname'))) {
$map['game_player_name'] = array('like',I("user_nickname").'%');
}
$field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,user_nickname,game_name,sdk_version,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way";
$field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,user_nickname,game_name,sdk_version,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way,market_admin_id";
$group = "";
$order = "pay_time DESC";
if(isset($_REQUEST['export'])){
@ -587,10 +774,17 @@ class FinancePromoteController extends AdminController
}else {
$data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row);
}
$marketAdmins = [];
if (count($data) > 0) {
$marketAdmins = getAdminUsernameList(array_column($data, 'market_admin_id'));
}
foreach($data as $key => $value) {
$data[$key]['pay_way'] = getPayType($value['pay_way']);
$data[$key]['game_name'] =clearGameNameType($data[$key]['game_name']);
$data[$key]['sdk_version'] =getGameTypeName($data[$key]['sdk_version']);
$data[$key]['market_admin_username'] = $marketAdmins[$value['market_admin_id']] ?? '无';
($data[$key]['promote_account']=='官方渠道')?($data[$key]['promote_account']=C('OFFICIEL_CHANNEL')):'';
if (isset($_REQUEST['export'])) {
@ -598,6 +792,7 @@ class FinancePromoteController extends AdminController
}
}
if (isset($_REQUEST['export'])) {
$GetData = $_GET;
@ -611,6 +806,7 @@ class FinancePromoteController extends AdminController
"game_name"=>"游戏名称",
"sdk_version"=>"设备名称",
"promote_account"=>"所属推广员",
"market_admin_username"=>"所属市场专员",
"spend_ip"=>"充值ip",
"server_name"=>"游戏区服",
"game_player_name"=>"角色名称",
@ -653,7 +849,7 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count,
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_name,'{$this->COMPANY_NAME}') company_name,IFNULL(promote.company_belong,0) company_belong")
IFNULL(company_name,'{$this->COMPANY_NAME}') company_name,develop_type,IFNULL(promote.company_belong,0) company_belong")
->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left")
@ -664,6 +860,22 @@ class FinancePromoteController extends AdminController
if ($row != 0) {
$query = $query->page($page,$row);
}
$adminId = 0;
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$adminId = $userAuth['uid'];
} else {
if (!empty(I('admin_id'))) {
$adminId = I('admin_id');
}
}
$havingPids = [];
if ($adminId > 0) {
$havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
$havingPids = count($havingPids) > 0 ? $havingPids : [0];
$query->having('p_id in (' . implode(',', $havingPids) . ')');
}
$data = $query->select(false);
$data = M()
->table("(".$data.") a")
@ -681,7 +893,9 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count");
if ($join) {
$query = $query->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id');
->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id')
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left");
}
$data = $query->where(['s.pay_status' => 1])
->where($map)
@ -990,6 +1204,19 @@ class FinancePromoteController extends AdminController
}
$title .= (getCompanyBlong($_REQUEST['company_belong'])."-");
}
if (!empty(I('develop_type'))) {
$map['company.develop_type'] = I('develop_type');
if(I('develop_type') != 0){
$gfflg = false;
}
}
if (!empty(I('admin_id'))) {
if(I('admin_id') != 0){
$gfflg = false;
}
}
if (isset($_REQUEST['promote_id'])) {
if($ptype){
$pmap = false;//取消非特异推广员检索

@ -0,0 +1,242 @@
<?php
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
use Base\Service\PresidentDepositService;
use Base\Task\Task;
/**
* 市场
*/
class MarketController extends ThinkController
{
public function rebindRecords()
{
$page = I('p', 1);
$row = I('row', 10);
$companyId = I('company_id', 0);
$promoteId = I('promote_id', 0);
$conditions = [];
$promoteIds = [];
if ($promoteId !== 0) {
$promoteIds = [$promoteId];
}
if ($companyId !== 0) {
$companyPromoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true);
if (count($companyPromoteIds) > 0) {
$promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds;
$promoteIds[] = 0;
} else {
$promoteIds = [0];
}
}
if (count($promoteIds)) {
$conditions['promote_id'] = ['in', $promoteIds];
}
$query = M('market_shift', 'tab_')->where($conditions);
$countQuery = clone $query;
$items = $query->order('id desc')->page($page, $row)->select();
$count = $countQuery->count();
$recordPromotes = [];
$recordCompanys = [];
if (count($items) > 0) {
$recordPromotes = M('promote', 'tab_')->field(['id', 'account', 'company_id'])->where(['id' => ['in', array_column($items, 'promote_id')]])->select();
$recordCompanyIds = array_column($recordPromotes, 'company_id');
if (count($recordCompanyIds) > 0) {
$recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select();
}
$adminIds = array_merge(array_column($items, 'from_id'), array_column($items, 'to_id'));
$recordAdmins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', $adminIds]])->select();
$recordPromotes = index_by_column('id', $recordPromotes);
$recordCompanys = index_by_column('id', $recordCompanys);
$recordAdmins = index_by_column('id', $recordAdmins);
}
$companyTypes = [
0 => '内团',
1 => '外团',
2 => '外团-分发联盟',
3 => '无'
];
$statusList = [
0 => '待处理',
1 => '处理成功',
2 => '处理失败',
3 => '已取消'
];
$records = [];
foreach ($items as $item) {
$records[] = [
'id' => $item['id'],
'promote_account' => $recordPromotes[$item['promote_id']]['account'],
'company_name' => $recordCompanys[$recordPromotes[$item['promote_id']]['company_id']]['company_name'],
'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$item['promote_id']]['company_id']]['company_belong']],
'remark' => $item['remark'],
'from_username' => $recordAdmins[$item['from_id']]['username'],
'to_username' => $recordAdmins[$item['to_id']]['username'],
'split_time' => $item['split_time'] == 0 ? '全部' : date('Y-m-d H:i:s', $item['split_time']),
'created_time' => date('Y-m-d H:i:s', $item['created_time']),
'status_text' => $statusList[$item['status']],
'status' => $item['status']
];
}
$companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->where(['company_belong' => ['in', [1, 2]]])->select();
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$this->assign('records', $records);
$this->assign('companys', $companys);
$this->display();
}
public function rebind()
{
$this->meta_title = '新增换绑';
$id = I('id', 0);
$companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->where(['company_belong' => ['in', [1, 2]]])->select();
$marketAdmins = getMarketAdmins();
$this->assign('companys', $companys);
$this->assign('marketAdmins', $marketAdmins);
$this->display('rebind');
}
public function save()
{
$records = I('records', []);
if (count($records) == 0) {
$this->ajaxReturn([
'status' => 0,
'message' => '未提交换绑数据'
]);
}
$status = true;
$message = '';
foreach ($records as $record) {
if ($record['from_id'] == $record['to_id']) {
$status = false;
$message = '含有原市场专员与新市场专员相同数据,不可转换。';
break;
}
}
if (!$status) {
$this->ajaxReturn([
'status' => 0,
'message' => $message
]);
}
$hasRecord = M('market_shift', 'tab_')->where(['promote_id' => ['in', array_column($records, 'promote_id')], 'status' => 0])->find();
if ($hasRecord) {
$this->ajaxReturn([
'status' => 0,
'message' => '该会长含有未完成的市场换绑任务,请稍后再申请。'
]);
}
$userAuth = session('user_auth');
foreach ($records as $record) {
$item = [
'promote_id' => $record['promote_id'],
'from_id' => $record['from_id'],
'to_id' => $record['to_id'],
'split_time' => strtotime($record['split_time']),
'remark' => $record['remark'],
'creator_id' => $userAuth['uid'],
'created_time' => time()
];
$id = M('market_shift', 'tab_')->add($item);
if ($id) {
Task::add('market-shift', ['market_shift_id' => $id]);
}
}
$this->ajaxReturn([
'status' => 1,
'message' => '提交成功,等待后台处理'
]);
}
public function delete()
{
$id = I('id', 0);
M('market_shift', 'tab_')->where(['id' => $id])->delete();
addOperationLog([
'op_type' => 2,
'key' => $id,
'op_name' => '删除市场换绑记录',
'url' => U('Market/delete', ['id' => $id]),
'menu' => '推广员-推广员管理-市场换绑-删除市场换绑记录'
]);
$this->ajaxReturn([
'status' => 1,
'message' => '删除成功'
]);
}
public function cancel()
{
$id = I('id', 0);
$shift = M('market_shift', 'tab_')->where(['id' => $id])->find();
if ($shift['status'] != 0) {
$this->ajaxReturn([
'status' => 0,
'message' => '该换绑非待处理状态,不可取消'
]);
}
addOperationLog([
'op_type' => 2,
'key' => $id,
'op_name' => '取消市场换绑记录',
'url' => U('Market/delete', ['id' => $id]),
'menu' => '推广员-推广员管理-市场换绑-取消市场换绑记录'
]);
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 3]);
$this->ajaxReturn([
'status' => 1,
'message' => '取消成功'
]);
}
public function getPromotesByCompany()
{
$companyId = I('company_id', 0);
$promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])
->where(['level' => 1, 'company_id' => $companyId, 'admin_id' => ['gt', 0]])
->select();
$marketAdmins = index_by_column('id', getAdmins());
$records = [];
foreach ($promotes as $promote) {
$admin = isset($marketAdmins[$promote['admin_id']]) ? $marketAdmins[$promote['admin_id']] : null;
$records[] = [
'id' => $promote['id'],
'account' => $promote['account'],
'admin_id' => $promote['admin_id'],
'admin_username' => $admin ? $admin['username'] : '',
];
}
$this->ajaxReturn([
'status' => 1,
'message' => '获取成功',
'data' => [
'promotes' => $records
]
]);
}
}

@ -78,7 +78,8 @@ class MemberController extends ThinkController
$map['tab_user.is_repeat'] = $_REQUEST['is_repeat'];
$is_repeat = true;
}
$isMarketAdmin = isMarketAdmin();
$map = withMarketAdminCondition($map, I('market_admin_id', 0));
if (isset($_REQUEST['status'])) {
$map['lock_status'] = $_REQUEST['status'];
@ -134,8 +135,8 @@ class MemberController extends ThinkController
$this->checkListOrCountAuthRestMap($map,["tab_user.id","tab_user.account","tab_user.device_number"]);
//计算用户列表
$data = M("user","tab_")
->field("tab_user.id,`device_number`,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,
`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(ss.pay_amount,0) AS recharge_total,tab_user.is_repeat")
->field("tab_user.id,`device_number`,`age_status`,tab_user.account,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,
`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(ss.pay_amount,0) AS recharge_total,tab_user.is_repeat,promote.admin_id")
->where($map)
->group("tab_user.id")
->order($order);
@ -154,6 +155,7 @@ class MemberController extends ThinkController
");
}
$data->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left");
$data->join("tab_promote AS promote ON promote.id = tab_user.promote_id", "left");
if(!isset($_REQUEST['export'])){
$data ->page($page, $row);
@ -176,6 +178,7 @@ class MemberController extends ThinkController
if(empty($viplevel)) {$viplevel = false;}
}
$adminList = getMarketAdminsByPromoteIds(array_column($data, 'promote_id'));
foreach ($data as $k => &$v) {
$v['register_type'] = get_registertype($v['register_type']);
@ -206,10 +209,11 @@ class MemberController extends ThinkController
$v['lock_status'] = get_info_status($v['lock_status'],4);
$v['check_status'] = $v['check_status']==1 ? "正常" :"拉黑";
$v['is_repeat'] = $v['is_repeat']==1 ? "是" :"否";
$v['market_admin_username'] = isset($adminList[$v['promote_id']]) && $adminList[$v['promote_id']]['admin'] ? $adminList[$v['promote_id']]['admin']['username'] : '无';
}
$field = array(
"id"=>"账号ID","account"=>"玩家账号","promote_account"=>"所属推广员","balance"=>"账户平台币","recharge_total"=>"累计充值","gold_coin"=>"金币",
"id"=>"账号ID","account"=>"玩家账号","promote_account"=>"所属推广员","market_admin_username"=>"所属市场专员","balance"=>"账户平台币","recharge_total"=>"累计充值","gold_coin"=>"金币",
"small_count"=>"小号","vip_level"=>"VIP等级","register_type"=>"注册方式","register_time"=>"注册时间","register_ip"=>"注册IP","login_time"=>"最后登录时间",
"device_number"=>"设备号","is_repeat"=>"去重数据","lock_remark"=>"锁定备注","lock_status"=>"账号状态","check_status"=>"拉黑状态"
);
@ -223,9 +227,12 @@ class MemberController extends ThinkController
));
data2csv($data,"玩家_玩家列表",$field);
}
// foreach ($data as $key=>&$value ) {
// ($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
// }
$adminList = getMarketAdminsByPromoteIds(array_column($data, 'promote_id'));
foreach ($data as $key=>&$value ) {
($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
$value['market_admin_username'] = isset($adminList[$value['promote_id']]) && $adminList[$value['promote_id']]['admin'] ? $adminList[$value['promote_id']]['admin']['username'] : '无';
}
//计算总人数
if($is_repeat){
$field ="count(*) user_count,IFNULL(sum(ss.pay_amount), 0) recharge_total";
@ -250,6 +257,7 @@ class MemberController extends ThinkController
");
}
$user_count->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left");
$user_count->join("tab_promote AS promote ON promote.id = tab_user.promote_id", "left");
$userDbRes = $user_count->find();
if($is_repeat){
$user_count =$userDbRes['user_count'];
@ -266,6 +274,8 @@ class MemberController extends ThinkController
$no_repeat_count = $userDbRes['no_repeat_count'];
}
$this->assign('isMarketAdmin', $isMarketAdmin);
$this->assign('marketAdmins', getMarketAdmins());
$this->assign('repeat_count',$repeat_count);
$this->assign('no_repeat_count',$no_repeat_count);

@ -633,16 +633,25 @@ class PlatformController extends ThinkController
$map['s.server_id'] = $_REQUEST['server_id'];
unset($_REQUEST['server_id']);
}
}
$data = M('promote', 'tab_')->alias('tp1')
->field('tp1.account as promote_account,tp1.id,
}
if (isset($_REQUEST['game_name'])||isset($_REQUEST['promote_id'])) {
$data = M('promote', 'tab_')->alias('tp1')
->field('tp1.account as promote_account,tp1.id,
floor(sum(pay_amount)*100) as count')
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
->join("tab_spend as s on tp2.id = s.promote_id", 'left')
->where($map)
->group('tp1.id')
->order('count desc')
->select();
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left')
->where($map)
->group('tp1.id')
->order('count desc')
->select();
} else {
$statisticsMap['time'] =$map['pay_time'];
$data = M('promote_statistics', 'tab_')->field("promote_account,promote_id as id,sum(count) count")->where($statisticsMap)->group("promote_id")->select();
}
// var_dump($data);die();
//今日/本周/本月不变
$tmap = $map;
if(isset($map['pay_time'])){

@ -351,6 +351,18 @@ class PromoteCompanyController extends ThinkController
$savedata = array(
"company_belong"=>$save['company_belong']
);
// 权限跟随
$authGroup = M('sys_auth_group')->where(['title'=>'市场总监'])->find();
$subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->getField('id', true);
$dataPresident = explode(',', $authGroup['data_president']);
if ($save['company_belong'] == 1 || $save['company_belong'] == 2) {
$dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds));
} else {
$dataPresident = array_diff($dataPresident, $subPromoteIds);
}
M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>implode(',', $dataPresident)]);
M("Promote","tab_")->where("company_id = '{$company_id}'")->save($savedata);
}
addOperationLog(['op_type'=>1,'key'=>$_POST['company_name'],'op_name'=>'编辑推广公司','url'=>U('PromoteCompany/lists'),'menu'=>'推广员-推广员管理-推广公司管理-编辑推广公司']);

@ -123,7 +123,7 @@ class RepairController extends ThinkController {
*/
public function noticePayed($orderNo, $second, $type) {
$auth = session('user_auth');
if (IS_AJAX) {
if ($type != 'spend' && $type != 'deposit') {
$this->ajaxReturn(['status'=>0,'msg'=>'参数有误']);
@ -161,8 +161,12 @@ class RepairController extends ThinkController {
$game = new GameApi();
$result=$game->game_pay_notify($param,1);
$spend = M($tab, "tab_");
if($result == "success"){
$rr = $spend->where(array('pay_order_number'=>$orderNo))->save(array('pay_game_status'=>1));
PromoteStatistics($orderNo);
if ($rr !== false) {
$cpFlag = 1;
M($tab, 'tab_')->commit();
@ -171,6 +175,7 @@ class RepairController extends ThinkController {
$this->ajaxReturn(array('status'=>1,'msg'=>'补单失败.'));
}
}else{
PromoteStatistics($orderNo);
M($tab, 'tab_')->commit();
}
} else { // deposit

@ -72,6 +72,17 @@ class SpendController extends ThinkController
unset($_REQUEST['pay_game_status']);
}
$marketAdminId = I('market_admin_id', 0);
if ($marketAdminId) {
$map['market_admin_id'] = $marketAdminId;
}
$isMarketAdmin = isMarketAdmin();
if ($isMarketAdmin) {
$userAuth = session('user_auth');
$map['market_admin_id'] = $userAuth['uid'];
}
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
@ -125,10 +136,14 @@ class SpendController extends ThinkController
$data = D(self::model_name)->lists($_GET["p"], $map, $order);
$adminUsernameList = getAdminUsernameList(array_column($data['data'], 'market_admin_id'));
foreach ($data['data'] as $key=>&$value ) {
($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
$value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
}
$this->assign('isMarketAdmin', $isMarketAdmin);
$this->assign('marketAdmins', getMarketAdmins());
$this->assign('startDate', $startDate);
$this->assign('endDate', $endDate);
$this->assign('list_data', $data['data']);

@ -9,6 +9,7 @@
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
use function GuzzleHttp\Psr7\str;
/**
* 后台首页控制器
@ -533,4 +534,196 @@ class TimingController extends AdminController {
}
public function setPromoteStatistics() {
echo "-------------------------------------------------------------\n";
$startTime = strtotime("20190829");
if (I("start_time")=="yesterday") {
$startTime = strtotime(date("Y-m-d",strtotime("-1 day")));
}
$endTime = time();
if (I("start_time")) {
$startTime = strtotime(I("start_time"));
}
if (I("end_time")) {
$endTime = strtotime(I("end_time"));
}
if ($endTime < $startTime) {
echo "错误,开始时间不得大于结束时间";die();
}
for($start = $startTime;$start<$endTime;$start=$start+86400) {
$map['pay_time'] = ['between', array($start, $start+86399)];
$map['tp1.chain'] = '/';
$map['pay_status'] = 1;
$map['promote_id'] = array('egt', 0);
$data = M('promote', 'tab_')->alias('tp1')
->field('tp1.account as promote_account,tp1.id as promote_id,floor(sum(pay_amount)*100) as count')
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
->join("tab_spend as s on tp2.id = s.promote_id", 'left')
->where($map)
->group('tp1.id')
->order('count desc')
->select();
foreach($data as $key => $value) {
$insert['promote_id'] = $value['promote_id'];
$insert['promote_account'] = $value['promote_account'];
$insert['count'] = $value['count']?$value['count']:0;
$insert['time'] = $start;
$statisticsData = M("promote_statistics","tab_")
->where(['promote_id'=>$value['promote_id'],'time'=>$start])
->find();
$date = date("Y-m-d",$start);
if ($statisticsData) {
M("promote_statistics","tab_")
->where(['promote_id'=>$value['promote_id'],'time'=>$start])
->save($insert);
echo "更新{$value['promote_account']}在{$date}充值:{$value['count']}\n";
} else {
M("promote_statistics","tab_")->add($insert);
echo "新增{$value['promote_account']}在{$date}充值:{$value['count']}\n";
}
}
}
echo "-------------------------------------------------------------\n";
}
public function shiftPromoteStatistics() {
$data = M("shift_task")->where(['status'=>0,'type'=>2])->select();
$promote_data = [];
foreach ($data as $key => $value) {
$promote_data[] = $value['from_promote_id'];
$promote_data[] = $value['to_promote_id'];
}
$promote_data=array_unique($promote_data);
sort($promote_data);
$chain_data = M("promote","tab_")
->field("id")
->where(['chain'=>'/','id'=>['in',$promote_data]])
->select();
$chain_data = array_column($chain_data,'id');
$chain_data_secord = M("promote","tab_")
->field("substring_index(chain, '/', 2) as id")
->where(['id'=>['in',$promote_data]])
->select();
$chain_data_secord = array_column($chain_data_secord,'id');
foreach($chain_data_secord as $k=>$v){
if($v == '/'){
unset($chain_data_secord[$k]);
}
$chain_data_secord[$k] = substr($chain_data_secord[$k],1,strlen($v));
if ($chain_data_secord[$k] == false) {
unset($chain_data_secord[$k]);
}
// var_dump(strlen($chain_data_secord[$k]));
}
$data = [];
$data = array_merge(array_unique($chain_data),array_unique($chain_data_secord));
$this->PromoteStatistics($data);
// dump($data);
// dump(array_unique($chain_data_secord));
}
public function PromoteStatistics($promote) {
echo "-------------------------------------------------------------\n";
$startTime = strtotime("20190829");
$endTime = time();
if (I("start_time")) {
$startTime = strtotime(I("start_time"));
}
if ($promote) {
$map['tp2.id'] = ['in',$promote];
}
if (I("end_time")) {
$endTime = strtotime(I("end_time"));
}
if ($endTime < $startTime) {
echo "错误,开始时间不得大于结束时间";die();
}
for($start = $startTime;$start<$endTime;$start=$start+86400) {
$map['pay_time'] = ['between', array($start, $start+86399)];
$map['tp1.chain'] = '/';
$map['pay_status'] = 1;
$map['promote_id'] = array('egt', 0);
$data = M('promote', 'tab_')->alias('tp1')
->field('tp1.account as promote_account,tp1.id as promote_id,floor(sum(pay_amount)*100) as count')
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
->join("tab_spend as s on tp2.id = s.promote_id", 'left')
->where($map)
->group('tp1.id')
->order('count desc')
->select();
foreach($data as $key => $value) {
$insert['promote_id'] = $value['promote_id'];
$insert['promote_account'] = $value['promote_account'];
$insert['count'] = $value['count']?$value['count']:0;
$insert['time'] = $start;
$statisticsData = M("promote_statistics","tab_")
->where(['promote_id'=>$value['promote_id'],'time'=>$start])
->find();
$date = date("Y-m-d",$start);
if ($statisticsData) {
M("promote_statistics","tab_")
->where(['promote_id'=>$value['promote_id'],'time'=>$start])
->save($insert);
echo "更新{$value['promote_account']}在{$date}充值:{$value['count']}\n";
} else {
M("promote_statistics","tab_")->add($insert);
echo "新增{$value['promote_account']}在{$date}充值:{$value['count']}\n";
}
}
}
echo "-------------------------------------------------------------\n";
}
}

@ -665,17 +665,18 @@ class UserController extends AdminController
$map['role_id'] = trim($_REQUEST['role_id']);
unset($_REQUEST['role_id']);
}
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
// if ($promoteRoot) {
$isMarketAdmin = isMarketAdmin();
$map = withMarketAdminCondition($map, I('market_admin_id', 0));
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
// if ($promoteRoot) {
// $map['promote_id'] =array('in',$promoteRoot);
// } else if(!$promoteRoot&&$data_empower_type!=1){
// $map['id'] = array('lt',1);
// }
// $map['id'] = array('lt',1);
// }
setPowerPromoteIds($map,'promote_id');
if (isset($_REQUEST['promote_id'])) {
$queryStr = '';
if ($_REQUEST['promote_id'] == 0) {
@ -691,7 +692,7 @@ class UserController extends AdminController
$map['sdk_version'] = trim($_REQUEST['game_type']);
unset($_REQUEST['game_type']);
}
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
$map['create_time'] = ['between', [strtotime(I('time_start')), strtotime(I('time_end')) + 86399]];
} elseif (isset($_REQUEST['time_start'])) {
@ -699,20 +700,24 @@ class UserController extends AdminController
} elseif (isset($_REQUEST['time_end'])) {
$map['create_time'] = ['LT', strtotime(I('time_end')) + 86399];
}
empty(I('user_account')) || $map['user_account'] = ['like', "%" . I('user_account') . "%"];
$this->checkListOrCountAuthRestMap($map,["role_id", "role_name", "user_account"]);
$list = $this->lists(M('user_play_info', 'tab_'), $map, 'play_time desc');
$adminList = getMarketAdminsByPromoteIds(array_column($list, 'promote_id'));
foreach ($list as $key=>&$value ) {
($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
$value['market_admin_username'] = isset($adminList[$value['promote_id']]) && $adminList[$value['promote_id']]['admin'] ? $adminList[$value['promote_id']]['admin']['username'] : '无';
}
$this->assign('list', $list);
$this->meta_title = '角色数据';
$this->m_title = '角色查询';
$this->assign('isMarketAdmin', $isMarketAdmin);
$this->assign('marketAdmins', getMarketAdmins());
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/rolelist', 'status' => 1])->find());
$this->assign("is_admin",is_administrator());
$show_data_power = (is_administrator()|| session('user_auth')['show_data']);

@ -128,6 +128,23 @@
</volist>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="admin_id" name="admin_id" class="select_gallery" style="width:120px;">
<option value="">请选择市场专员</option>
<?php foreach(getMarketAdmins() as $item):?>
<option value="<?=$item['id']?>" <?php if($item['id'] == I('admin_id')):?>selected<?php endif;?>><?=$item['username']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="develop_type" name="develop_type" class="select_gallery" style="width:120px;">
<option value="">请选择开发类型</option>
<?php foreach(getCompanyDevelopTypes() as $key => $value):?>
<option value="<?=$key?>" <?php if($key == I('develop_type')):?>selected<?php endif;?>><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="game_name" name="game_name" class="select_gallery" >
<option value="">游戏名称</option>
@ -177,8 +194,9 @@
<tr>
<th>推广公司</th>
<th>会长账号</th>
<th>所属市场专员</th>
<th>团体类型</th>
<th>开发类型</th>
<th >游戏</th>
<th >设备</th>
@ -210,7 +228,9 @@
<tr>
<td >{$data.company_name}</td>
<td >{$data.account}</td>
<td>{$data['admin_username']}</td>
<td >{$data.company_belong}</td>
<td>{$data['develop_type_text']}</td>
<td >{$data.game_name}</td>
<td >{$data.sdk_version}</td>
<td >{$data.cash_count}</td>
@ -225,7 +245,7 @@
</tr>
</volist>
<tr>
<td colspan="5" ><span>总计</span></td>
<td colspan="7" ><span>总计</span></td>
<td ><span><if condition="$sumCash neq ''">{$sumCash}<else/>0</if></span></td>
<td><if condition="$sumBalance neq ''">{$sumBalance}<else/>0</if></td>
<td><if condition="$sumInside neq ''">{$sumInside}<else/>0</if></td>

@ -94,7 +94,14 @@
<option value="0" <?php if ($_POST['promote_id'] == 0):?>selected<?php endif;?>>{:C('OFFICIEL_CHANNEL')}</option>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="admin_id" name="admin_id" class="select_gallery" style="width:120px;">
<option value="">请选择市场专员</option>
<?php foreach(getMarketAdmins() as $item):?>
<option value="<?=$item['id']?>" <?php if($item['id'] == I('admin_id')):?>selected<?php endif;?>><?=$item['username']?></option>
<?php endforeach;?>
</select>
</div>
<input type="hidden" name="promote_type" value="{$_GET['promote_type']}"/>
<input type="hidden" name="company_id" value="{$_GET['company_id']}"/>
<input type="hidden" name="company_belong" value="{$_GET['company_belong']}"/>
@ -167,7 +174,7 @@
<th >设备名称</th>
<th >所属推广员</th>
<th >所属市场专员</th>
<th >充值ip</th>
<th >游戏区服</th>
@ -190,7 +197,7 @@
</style>
<if condition = "empty($data)">
<tr>
<td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>
<td colspan="15" class="text-center">aOh! 暂时还没有内容!</td>
</tr>
</if>
<notemtpy name = "data">
@ -202,6 +209,7 @@
<td >{$data.game_name}</td>
<td >{$data.sdk_version}</td>
<td >{$data.promote_account}</td>
<td >{$data.market_admin_username}</td>
<td >{$data.spend_ip}</td>
<td >{$data.server_name}</td>
<td >{$data.game_player_name}</td>
@ -212,7 +220,7 @@
</volist>
<tr>
<td ><span>总计</span></td>
<td colspan="11" ><span><if condition="$sumAll neq ''">累计充值:{$sumAll}<else/>0</if>
<td colspan="12" ><span><if condition="$sumAll neq ''">累计充值:{$sumAll}<else/>0</if>
(现金金额:{$sumCash} 平台币:{$sumBalance} 绑币:{$sumInside}
</span></td>
</tr>

@ -119,6 +119,24 @@
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="admin_id" name="admin_id" class="select_gallery" style="width:120px;">
<option value="">请选择市场专员</option>
<?php foreach(getMarketAdmins() as $item):?>
<option value="<?=$item['id']?>" <?php if($item['id'] == I('admin_id')):?>selected<?php endif;?>><?=$item['username']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="develop_type" name="develop_type" class="select_gallery" style="width:120px;">
<option value="">请选择开发类型</option>
<?php foreach(getCompanyDevelopTypes() as $key => $value):?>
<option value="<?=$key?>" <?php if($key == I('develop_type')):?>selected<?php endif;?>><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<input type="text" readonly id="time_start" name="time_start" class="" value="{:I('time_start')}"
placeholder="开始时间" />
@ -165,8 +183,9 @@
<tr>
<th>推广公司</th>
<th>会长渠道</th>
<th>所属市场专员</th>
<th>内外团</th>
<th>开发类型</th>
<th class="tooltip"><a class="paixu" data-order='cash_count'>
<if condition="$userarpu_order eq 4 and $userarpu_order_type eq 'cash_count'">游戏现金金额▲
<elseif condition="$userarpu_order eq 3 and $userarpu_order_type eq 'cash_count'" />
@ -215,8 +234,9 @@
<tr>
<td>{$data.company_name}</td>
<td>{$data['promote_account']}</td>
<td>{$data['admin_username']}</td>
<td>{$data['company_belong']}</td>
<td>{$data['develop_type_text']}</td>
<td>{$data.cash_count}</td>
<td class="coin-detail" data-pay_type="0" style="color: #0066cc;cursor: pointer" data-url="{:U('FinancePromote/gameCoinDetail',array_merge(I('get.'),['pay_way'=>0,'promote_type'=>1,'promote_id'=>$data['p_id'],p=>1,row=>10]))}">
{$data.balance_coin_count}
@ -248,7 +268,7 @@
</volist>
</empty>
<tr class="data_summary" style="text-align: center;">
<td colspan="3" style="text-align: center;">汇总:</td>
<td colspan="5" style="text-align: center;">汇总:</td>
<td style="text-align: center;">{$all_count['cash_count']}</td>
<td style="text-align: center;">{$all_count['balance_coin_count']}</td>
<td style="text-align: center;">{$all_count['bind_coin_count']}</td>

@ -109,6 +109,23 @@
<option value="UC" <?php if ($_POST['promote_id'] == 'UC'):?>selected<?php endif;?>>UC用户</option>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="admin_id" name="admin_id" class="select_gallery" style="width:120px;">
<option value="">请选择市场专员</option>
<?php foreach(getMarketAdmins() as $item):?>
<option value="<?=$item['id']?>" <?php if($item['id'] == I('admin_id')):?>selected<?php endif;?>><?=$item['username']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-server search_label_rehab">
<select id="develop_type" name="develop_type" class="select_gallery" style="width:120px;">
<option value="">请选择开发类型</option>
<?php foreach(getCompanyDevelopTypes() as $key => $value):?>
<option value="<?=$key?>" <?php if($key == I('develop_type')):?>selected<?php endif;?>><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<input type="text" readonly id="time_start" name="time_start" class="" value="{:I('time_start')}"
placeholder="开始时间" />
@ -157,7 +174,9 @@
<tr>
<th>推广公司</th>
<th>推广员账号</th>
<th>内外团</th>
<th>所属市场专员</th>
<th>团体类型</th>
<th>开发类型</th>
<th class="tooltip"><a class="paixu" data-order='cash_count'>
<if condition="$userarpu_order eq 4 and $userarpu_order_type eq 'cash_count'">游戏现金金额▲
@ -206,8 +225,9 @@
<tr>
<td>{$data.company_name}</td>
<td>{$data['promote_account']}</td>
<td>{$data['admin_username']}</td>
<td>{$data['company_belong']}</td>
<td>{$data['develop_type_text']}</td>
<td>{$data.cash_count}</td>
<td>{$data.balance_coin_count}</td>
<td>{$data.bind_coin_count}</td>
@ -222,7 +242,7 @@
</volist>
</empty>
<tr class="data_summary">
<td colspan="2" style="text-align: center;">汇总:</td>
<td colspan="4" style="text-align: center;">汇总:</td>
<td style="text-align: center;">---</td>
<td style="text-align: center;">{$all_count['cash_count']}</td>
<td style="text-align: center;">{$all_count['balance_coin_count']}</td>

@ -0,0 +1,365 @@
<extend name="Public/base" />
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link href="__STATIC__/icons_alibaba/iconfont.css" rel="stylesheet">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="__STATIC__/provincecityarea/AreaData_min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<style>
.tabcon1711 input.time {
width: 150px;
}
#form .txt_area {
width: 300px;
height: 150px;
}
.tabcon1711 .form_unit {
margin-left: 2px;
}
.tabcon1711 .mustmark {
margin-left:-7px;
}
.list-ratio {
display: table;
}
.list-ratio .li-ratio {
display: flex;
margin-bottom: 20px;
align-items: center;
}
.list-ratio .li-ratio .turnover, .list-ratio .li-ratio .turnover-ratio {
position: relative;
}
.list-ratio .li-ratio .turnover span, .list-ratio .li-ratio .turnover-ratio .error-message {
color: red;
position: absolute;
left: 0;
top: 30px;
white-space: nowrap;
display: none;
}
.iconfont-btn {
cursor: pointer;
}
.iconfont-style {
font-size: 18px;
color: #fff;
border-radius: 4px;
border: 0;
padding: 5px;
margin-left: 10px;
}
.iconfont-selected {
background-color: #0A9AF2;
}
.iconfont-selected:hover {
background-color: #03a9f4;
}
.iconfont-unselected {
background-color: #999;
}
.iconfont-unselected:hover {
background-color: #ababab;
}
.tabcon1711 .submit_btn.small-btn {
float: none;
line-height: 25px;
width: 50px;
height: 25px;
font-size: 12px;
padding: 0px 8px 0px 0px;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<!-- <p class="description_text">说明:此功是创建推广员时所需填写信息</p>-->
</div>
<!-- 标签页导航 -->
<div class="tab-wrap">
<div class="tab-content tabcon1711">
<!-- 表单 -->
<form id="form" method="post" class="form-horizontal" style="margin-bottom: 40px;">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark">*</i>推广公司:</td>
<td class="r">
<select name="company_id" id="company-select" class="select_gallery">
<option value="">请选择推广公司</option>
<?php foreach($companys as $company):?>
<option value="<?=$company['id']?>" <?php if($company['id'] == $promote['company_id']):?>selected<?php endif;?>><?=$company['company_name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>会长:</td>
<td class="r">
<select name="promote_id" id="promote-select" class="select_gallery">
<option value="">请选择会长</option>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>原市场专员:</td>
<td class="r">
<span id="from-market-name" class="form_radio table_btn" style="color: red;">--</span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>新市场专员:</td>
<td class="r">
<select name="to_id" id="market-select" class="select_gallery">
<option value="">请选择新市场专员</option>
<?php foreach($marketAdmins as $admin):?>
<option value="<?=$admin['id']?>"><?=$admin['username']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l">订单切分时间:</td>
<td class="r">
<input type="text" id="split_time" name="split_time" class="time" value="" autocomplete="off" placeholder="请选择订单切分时间" style="width: 200px"/>
</td>
</tr>
<tr>
<td class="l">备注:</td>
<td class="r">
<textarea name="" id="remark" cols="30" rows="10"></textarea>
</td>
</tr>
</tbody>
</table>
</div>
<input type="hidden" name="id" id="id" value="{$record.id}" />
<div class="form-item cf">
<button class="submit_btn mlspacing" id="add-item" type="button" target-form="form-horizontal" style="margin-top: 10px;">
新增
</button>
</div>
</form>
<div class="data_list">
<div class="">
<table id="record-table">
<!-- 表头 -->
<thead>
<tr>
<th>推广公司</th>
<th>会长账号</th>
<th>内外团</th>
<th>原市场专员</th>
<th>新市场专员</th>
<th>订单切分时间</th>
<th>备注</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
</tbody>
</table>
</div>
</div>
<div style="margin-top: 30px; height: 35px; width: 100%;">
<a class="submit_btn" href="javascript:;" id="submit" style="margin: 0px auto; margin-left: 208px; ">全部提交</a>
</div>
</div>
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="Promote/lists/type/1">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('Market/rebindRecords')}");
$(".select_gallery").select2();
$(function(){
$('.time').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
autoclose: true,
scrollMonth: false,
scrollTime: false,
scrollInput: false,
startView: 'month',
minView:'month',
maxView:'month',
});
showTab();
var promoteIds = []
$('#company-select').on({
change: function() {
var companyId = $(this).val()
getPromotesByCompany(companyId, function(promotes) {
var html = '<option value="">请选择会长</option>'
for (var key in promotes) {
html += '<option value="' +
promotes[key].id +
'" data-admin-id="' +
promotes[key].admin_id +
'" data-admin-username="' +
promotes[key].admin_username +
'">' + promotes[key].account + '</option>'
}
$('#promote-select').html(html)
$('#promote-select').select2()
})
}
})
$('#promote-select').on({
change: function() {
var promoteOption = $("#promote-select option:selected");
var fromMarketUsername = promoteOption.attr('data-admin-username')
var fromMarketId = promoteOption.attr('data-admin-id')
$('#from-market-name').text(fromMarketUsername)
$('#from-market-name').attr('data-id', fromMarketId)
}
})
function getPromotesByCompany(companyId, callback) {
$.ajax({
url: '{:U("getPromotesByCompany")}',
type: 'get',
dataType: 'json',
data: {company_id: companyId},
success: function(result) {
if (result.status == 1) {
callback(result.data.promotes)
} else {
layer.msg(result.message)
}
}
})
}
$('#add-item').on({
click: function () {
var companyOption = $("#company-select option:selected");
var companyId = companyOption.val()
var companyName = companyOption.text()
var promoteOption = $("#promote-select option:selected");
var promoteId = promoteOption.val()
var promoteName = promoteOption.text()
var marketOption = $("#market-select option:selected");
var marketId = marketOption.val()
var marketName = marketOption.text()
var splitTime = $('#split_time').val()
var remark = $('#remark').val()
var fromId = $('#from-market-name').attr('data-id')
if (companyId == '') {
return layer.msg('请选择推广公司')
}
if (promoteId == '') {
return layer.msg('请选择会长')
}
if (marketId == '') {
return layer.msg('请新市场专员')
}
if (promoteIds.includes(promoteId)) {
return layer.msg('该会长已添加')
}
var data = {
company_id: companyId,
promote_id: promoteId,
from_id: fromId,
to_id: marketId,
split_time: splitTime,
remark: remark,
}
disabledPromote(promoteId)
promoteIds.push(promoteId)
console.log(promoteIds)
var html = '<tr data-post=' + JSON.stringify(data) + '><td>' + companyName + '</td>' +
'<td class="promote-item" data-id="' + promoteId + '">' + promoteName + '</td>' +
'<td>' + 'ssb' + '</td>' +
'<td>' + $('#from-market-name').text() + '</td>' +
'<td>' + marketName + '</td>' +
'<td>' + splitTime + '</td>' +
'<td>' + remark + '</td>' +
'<td><a class="delete-btn">删除</a></td>' +
'</tr>';
$('#record-table').find('tbody').append(html);
}
})
$('#record-table').on('click', '.delete-btn', function() {
var tr = $(this).parents('tr').eq(0)
tr.remove()
var promoteId = tr.find('.promote-item').attr('data-id')
var index = promoteIds.indexOf(promoteId)
console.log(promoteId)
console.log(index)
if (index !== -1) {
promoteIds.splice(index, 1)
}
console.log(promoteIds)
undisabledPromote(promoteId)
})
function disabledPromote(promoteId) {
var promoteOption = $("#promote-select").children('option').each(function() {
if ($(this).val() == promoteId) {
$(this).attr('disabled', true)
$('#promote-select').select2()
}
})
}
function undisabledPromote(promoteId) {
var promoteOption = $("#promote-select").children('option').each(function() {
if ($(this).val() == promoteId) {
$(this).attr('disabled', false)
$('#promote-select').select2()
}
})
}
$('#submit').click(function (e) {
var records = []
$('#record-table').find('tbody').children('tr').each(function() {
records.push(JSON.parse($(this).attr('data-post')))
})
$.ajax({
url: '{:U("save")}',
type: 'post',
dataType: 'json',
data: {records: records},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = '{:U("rebindRecords")}'
}, 200)
} else {
layer.msg(result.message)
}
}
})
});
});
</script>
</block>

@ -0,0 +1,265 @@
<extend name="Public/base"/>
<block name="css">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" href="__CSS__/promote.css" type="text/css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<style>
.select2-container--default .select2-selection--single {
color: #000;
resize: none;
border-width: 1px;
border-style: solid;
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
height:28px;border-radius:3px;font-size:12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height:35px;
line-height:28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height:26px;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
height:26px;line-height:26px;font-size:12px;
}
.select2-results__option[aria-selected] {font-size:12px;}
.textarea-style {
width: 200px;
height: 80px;
border-radius: 5px;
padding: 5px;
}
.mustmark {
color: #FF0000;
font-style: normal;
margin: 0 3px;
}
</style>
</block>
<block name="body">
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script type="text/javascript" src="__JS__/jquery.form.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script src="__STATIC__/md5.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">市场换绑</h3>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="company_select" name="company_id" class="select_gallery" style="width:200px;">
<option value="">请选择公司</option>
<?php foreach($companys as $company):?>
<option value="<?=$company['id']?>"><?=$company['company_name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote-select" name="promote_id" class="select_gallery" style="width:120px;">
<option value="">请选择会长</option>
<volist name=":get_promote_list_by_id()" id="vo">
<option value="{$vo.id}">{$vo.account}</option>
</volist>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Market/rebindRecords')}">搜索</a>
<a class="sch-btn" href="{:U('Market/rebind')}">添加</a>
<!-- <a class="sch-btn" href="javascript:;" id="batch-delete-btn">删除</a> -->
</div>
<!-- <div class="input-list">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>12,),I('get.')))}">导出</a>
</div> -->
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>推广公司</th>
<th>会长账号</th>
<th>内外团</th>
<th>原市场专员</th>
<th>新市场专员</th>
<th>备注</th>
<th>订单切分时间</th>
<th>状态</th>
<th>换绑操作时间</th>
<!-- <th>操作</th> -->
</tr>
</thead>
<!-- 列表 -->
<tbody>
<empty name ="records">
<td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="records" id="data">
<tr data-id="<?=$data['id']?>">
<td>{$data.company_name}</td>
<td>{$data.promote_account}</td>
<td>{$data.company_belong}</td>
<td>{$data.from_username}</td>
<td>{$data.to_username}</td>
<td>{$data.remark}</td>
<td>{$data.split_time}</td>
<td>{$data.status_text}</td>
<td>{$data.created_time}</td>
<!-- <td>
<div class="partakebtn">
<a class="delete-btn">删除</a>
<?php if($data['status'] == 0):?>
<a class="cancel-btn">取消</a>
<?php endif;?>
</div>
</td> -->
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<!-- <a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a> -->
</if>
{$_page|default=''}
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="Query/withdraw">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
<script src="__STATIC__/jquery.cookie.js" charset="utf-8"></script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('Market/rebindRecords')}");
$(function(){
//搜索功能
$("#search").click(function(){
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&"+$('.jssearch').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
})
$('#batch-delete-btn').on({
click: function() {
var ids = getIds();
$.ajax({
url: '{:U("batchDelete")}',
type: 'post',
dataType: 'json',
data: {ids: ids},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
})
}
})
function getIds() {
var ids = [];
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
}
$('.delete-btn').on({
click: function() {
var id = $(this).parents('tr').eq(0).attr('data-id');
$.ajax({
url: '{:U("delete")}',
type: 'post',
dataType: 'json',
data: {id: id},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
})
}
})
$('.cancel-btn').on({
click: function() {
var id = $(this).parents('tr').eq(0).attr('data-id');
$.ajax({
url: '{:U("cancel")}',
type: 'post',
dataType: 'json',
data: {id: id},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
})
}
})
});
/* $(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
}) */
</script>
</block>

@ -160,6 +160,16 @@
<option value="UC" <?php if ($_POST['promote_id'] == 'UC'):?>selected<?php endif;?>>UC用户</option>
</select>
</div>
<?php if(!$isMarketAdmin):?>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="market_admin_id" style="color:#444" class="select_gallery" id="market_admin_id">
<option value="0">所属市场专员</option>
<?php foreach($marketAdmins as $marketAdmin):?>
<option value="<?=$marketAdmin['id']?>" <?php if ($_POST['market_admin_id'] == $marketAdmin['id']):?>selected<?php endif;?>><?=$marketAdmin['username']?></option>
<?php endforeach;?>
</select>
</div>
<?php endif;?>
<div class="input-list">
<input type="text" name="device_number" class="" placeholder="设备号" value="{:I('device_number')}"/>&nbsp;
</div>
@ -202,6 +212,7 @@
<th>玩家账号</th>
</if>
<th>所属推广员</th>
<th>所属市场专员</th>
<th>
<a class="paixu" data-order="{:I('balance_status',1)}" name="balance_status">
@ -244,7 +255,7 @@
<!-- 列表 -->
<tbody>
<empty name ="list_data">
<td colspan="18" class="text-center">aOh! 暂时还没有内容!</td>
<td colspan="19" class="text-center">aOh! 暂时还没有内容!</td>
<else/>
<volist name="list_data" id="data">
<tr>
@ -284,6 +295,7 @@
</empty>
</if>
</td>
<td >{$data.market_admin_username}</td>
<td >{$data.balance}</td>
<td >{$data.recharge_total}</td>
<td >{$data.gold_coin|default='0.00'}</td>

@ -122,6 +122,16 @@
<option value="">请选择推广员</option>
</select>
</div>
<?php if(!$isMarketAdmin):?>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="market_admin_id" style="color:#444" class="select_gallery" id="market_admin_id">
<option value="0">所属市场专员</option>
<?php foreach($marketAdmins as $marketAdmin):?>
<option value="<?=$marketAdmin['id']?>" <?php if ($_POST['market_admin_id'] == $marketAdmin['id']):?>selected<?php endif;?>><?=$marketAdmin['username']?></option>
<?php endforeach;?>
</select>
</div>
<?php endif;?>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list search_item">
@ -151,6 +161,7 @@
<th>玩家账号</th>
<th>游戏名称</th>
<th>所属推广员</th>
<th>所属市场专员</th>
<th>充值ip</th>
<th>区服ID</th>
<th>游戏区服</th>
@ -170,7 +181,7 @@
<!-- 列表 -->
<tbody>
<empty name="list_data">
<td colspan="18" class="text-center">aOh! 暂时还没有内容!</td>
<td colspan="19" class="text-center">aOh! 暂时还没有内容!</td>
<else/>
<volist name="list_data" id="data">
<tr>
@ -215,6 +226,7 @@
<!-- {:get_promote_account($data['promote_id'])}-->
</eq>
</td>
<td >{$data.market_admin_username}</td>
<td>{$data.spend_ip}</td>
<empty name='data.server_name'>
<td>— —</td>
@ -272,7 +284,7 @@
<if condition="$rule_count_check">
<tr class="data_summary">
<td>汇总</td>
<td colspan="17">
<td colspan="18">
当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))}
<!-- 今日充值:{$ttotal}-->
<!-- 昨日充值:{$ytotal}-->

@ -108,6 +108,16 @@
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<?php if(!$isMarketAdmin):?>
<div class="input-list search_item input-list-gamenoticestatus">
<select name="market_admin_id" style="color:#444" class="select_gallery" id="market_admin_id">
<option value="0">所属市场专员</option>
<?php foreach($marketAdmins as $marketAdmin):?>
<option value="<?=$marketAdmin['id']?>" <?php if ($_POST['market_admin_id'] == $marketAdmin['id']):?>selected<?php endif;?>><?=$marketAdmin['username']?></option>
<?php endforeach;?>
</select>
</div>
<?php endif;?>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('rolelist',array('row'=>I('row')))}">搜索</a>
</div>
@ -127,6 +137,7 @@
<th class="">角色名</th>
<th class="">游戏等级</th>
<th class="">所属推广员</th>
<th class="">所属市场专员</th>
<th class="">最后登录时间</th>
<th class="">最后登录IP</th>
<!-- <th class="">操作</th> -->
@ -161,13 +172,14 @@
{$data.promote_account|encryptStr}
</if>
</td>
<td >{$data.market_admin_username}</td>
<td><?= date('Y-m-d H:i:s', $data['play_time']) ?></td>
<td>{$data.play_ip}</td>
<!-- <td><a class="ajax-get" href="{:U('user_update',['ids'=>$data['id']])}">更新</a></td> -->
</tr>
</volist>
<else/>
<td colspan="9" class="text-center">aOh! 暂时还没有内容!</td>
<td colspan="12" class="text-center">aOh! 暂时还没有内容!</td>
</notempty>
</tbody>
</table>
@ -182,6 +194,7 @@
'role_name'=>I('role_name'),
'promote_level'=>I('promote_level'),
'promote_id'=>I('promote_id'),
'market_admin_id'=>I('market_admin_id'),
'game_type'=>I('game_type'),
'xlsname'=>'玩家_角色查询',
'time_start'=>I('time_start'),

@ -374,4 +374,175 @@ class SpendRepository
{
// return M('spend', 'tab_')->field($columns)->where($map);
}
public function achievement()
{
$time = I('time', date('Y-m-d'));
if (!empty($time)) {
$defaultTime = $time;
} else {
$defaultTime = date('Y-m-d', time());
}
$sdkVersion = I('sdk_version', 0);
$relationGameId = I('relation_game_id', 0);
$serverId = I('server_id', 0);
$parentId = I('parent_id', 0);
$promoteId = I('promote_id', 0);
$status = I('status', 0);
$searchLevel = 0;
$searchLevelName = '';
$currentDisplay = '';
$prevParentId = 0;
$promoteService = new PromoteService();
$loginPromote = $this->getLoginPromote();
$parent = null;
if ($parentId > 0) {
$parent = M('promote', 'tab_')->where(['id' => $parentId])->find();
$currentDisplay = $promoteService->getLevelName($parent['level']) . '推广';
$prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id'];
} else {
$parent = $loginPromote;
$currentDisplay = '自己';
}
$searchLevel = $parent['level'] + 1;
$searchLevelName = $promoteService->getLevelName($searchLevel);
$games = get_promote_serach_game();
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select();
$map = ['parent_id' => $parent['id']];
if ($promoteId > 0) {
$map['id'] = $promoteId;
}
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map);
list($promotes, $pagination, $count) = $this->paginate($query);
$ids = array_column($promotes, 'id');
$rows = [];
if (count($ids) > 0) {
$rows = M('promote', 'tab_')
->field(['id', 'chain'])
->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]])
->select();
}
$basicPromotes = [];
foreach ($ids as $id) {
foreach ($rows as $row) {
$needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/';
if (strpos($row['chain'], $needChain) !== false) {
$basicPromotes[$row['id']] = $id;
}
}
}
$params = [
'isContainSubs' => true,
'basicPromotes' => $basicPromotes,
];
if ($relationGameId != 0 || $sdkVersion != 0) {
$gameIds = gameSearch($relationGameId, $sdkVersion);
$params['game_id'] = ['in', $gameIds];
}
if ($serverId > 0) {
$params['server_id'] = $serverId;
}
if ($status > 0) {
$params['lock_status'] = $status;
}
list($beginTime, $endTime) = $this->getBetweenTime($time);
$params['begin_time'] = $beginTime;
$params['end_time'] = $endTime;
$timeout = 0;
$records = [];
if (intval($endTime - $beginTime) / (24 * 3600) <= 7) {
$promoteRepository = new PromoteRepository();
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params);
$newCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds($ids, $params);
// $newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params);
$newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params);
$loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params);
$rechargeCountList = [];
$rechargeUserCountList = [];
$rechargeAmountList = [];
if ($this->canViewUserRecharge) {
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
}
$promoteService = new PromoteService();
if (I('p', 1) == 1) {
$selfParams = $params;
$selfParams['isContainSubs'] = false;
$selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams);
$selfCreateRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds([$parent['id']], $selfParams);
$selfNewCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds([$parent['id']], $selfParams);
// $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams);
$selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams);
$selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams);
$record = [
'id' => $parent['id'],
'account' => $parent['account'],
'promote_group' => $promoteService->getGroupNameByChain($parent['chain'], $parent['id']),
'real_name' => hideRealName($parent['real_name']),
'level' => $parent['level'],
'create_role_count' => $selfCreateRoleCountList[$parent['id']],
'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']],
'new_create_role_user_count' => $selfNewCreateRoleUserCountList[$parent['id']],
// 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']],
'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']],
'login_user_count' => $selfLoginUserCountList[$parent['id']],
'current_display' => $currentDisplay,
];
if ($this->canViewUserRecharge) {
$selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams);
$selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams);
$selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams);
$record['recharge_count'] = $selfRechargeCountList[$parent['id']];
$record['recharge_user_count'] = $selfRechargeUserCountList[$parent['id']];
$record['recharge_amount'] = $selfRechargeAmountList[$parent['id']]['ban_coin'] + $selfRechargeAmountList[$parent['id']]['coin'] + $selfRechargeAmountList[$parent['id']]['cash'];
$record['recharge_by_ban_coin'] = $selfRechargeAmountList[$parent['id']]['ban_coin'];
$record['recharge_by_coin'] = $selfRechargeAmountList[$parent['id']]['coin'];
$record['recharge_by_cash'] = $selfRechargeAmountList[$parent['id']]['cash'];
}
$records[] = $record;
}
foreach ($promotes as $promote) {
$id = $promote['id'];
$record = [
'id' => $id,
'account' => $promote['account'],
'promote_group' => $promoteService->getGroupNameByChain($promote['chain'], $promote['id']),
'real_name' => hideRealName($promote['real_name']),
'level' => $promote['level'],
'create_role_count' => $createRoleCountList[$id],
'create_role_user_count' => $createRoleUserCountList[$id],
'new_create_role_user_count' => $newCreateRoleUserCountList[$id],
// 'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id],
'new_create_role_ip_count' => $newCreateRoleIpCountList[$id],
'login_user_count' => $loginUserCountList[$id],
'current_display' => '',
];
if ($this->canViewUserRecharge) {
$record['recharge_count'] = $rechargeCountList[$id];
$record['recharge_user_count'] = $rechargeUserCountList[$id];
$record['recharge_amount'] = $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash'];
$record['recharge_by_ban_coin'] = $rechargeAmountList[$id]['ban_coin'];
$record['recharge_by_coin'] = $rechargeAmountList[$id]['coin'];
$record['recharge_by_cash'] = $rechargeAmountList[$id]['cash'];
}
$records[] = $record;
}
} else {
$timeout = 1;
}
}

@ -0,0 +1,88 @@
<?php
namespace Base\Service;
use Base\Facade\Request;
class MarketService
{
public function shift($marketShift)
{
$fromId = $marketShift['from_id'];
$promoteId = $marketShift['promote_id'];
$toId = $marketShift['to_id'];
$time = $marketShift['split_time'] == 0 ? null : $marketShift['split_time'];
$promote = M('promote', 'tab_')->field(['chain', 'id', 'level', 'admin_id'])->where(['id' => $promoteId, 'admin_id' => $fromId])->find();
if (!$promote) {
throw new \Exception('会长不存在');
}
if ($promote['level'] != 1) {
throw new \Exception('该账号非会长');
}
if ($fromId == $toId) {
throw new \Exception('原市场专员与新市场专员相同,不可转换。');
}
if ($promote['admin_id'] == $toId) {
throw new \Exception('新市场专员与现市场专员相同,不可转换。');
}
$promotes = (new PromoteService)->getAllChildren($promote, 0, ['id']);
$promoteIds = [$promote['id']];
$promoteIds = array_merge(array_column($promotes, 'id'), $promoteIds);
$this->shiftPromote($promote, $fromId, $toId);
$this->shiftSpend($promoteIds, $fromId, $toId, $time);
$this->shiftDeposit($promoteIds, $fromId, $toId, $time);
}
public function shiftPromote($promote, $fromId, $toId, $time = null)
{
$map = [];
$map['id'] = $promote['id'];
$map['admin_id'] = $fromId;
M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]);
M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->save(['admin_id' => $toId]);
$authGroup = M('auth_group', 'sys_')->where(['title'=>'市场总监'])->find();
$dataPresident = explode(',', $authGroup['data_president']);
if (!in_array($promote['id'], $dataPresident)) {
M('auth_group', 'sys_')->where(['title'=>'市场总监'])->save(['data_president' => $authGroup['data_president'] . ',' . $promote['id']]);
}
}
public function shiftSpend($promoteIds, $fromId, $toId, $time = null)
{
$map = [];
$map['promote_id'] = ['in', $promoteIds];
$map['market_admin_id'] = $fromId;
if ($time) {
$map['pay_time'] = ['egt', $time];
}
$count = M('spend', 'tab_')->where($map)->count();
$limit = 500;
$pageCount = ceil($count/$limit);
for ($page = 0; $page <= $pageCount; $page ++) {
M('spend', 'tab_')->where($map)->limit($limit)->save(['market_admin_id' => $toId]);
}
M('spend', 'tab_')->where($map)->save(['market_admin_id' => $toId]);
}
public function shiftDeposit($promoteIds, $fromId, $toId, $time = null)
{
$map = [];
$map['promote_id'] = ['in', $promoteIds];
$map['market_admin_id'] = $fromId;
if ($time) {
$map['create_time'] = ['egt', $time];
}
$count = M('deposit', 'tab_')->where($map)->count();
$limit = 500;
$pageCount = ceil($count/$limit);
for ($page = 0; $page <= $pageCount; $page ++) {
M('deposit', 'tab_')->where($map)->limit($limit)->save(['market_admin_id' => $toId]);
}
M('deposit', 'tab_')->where($map)->save(['market_admin_id' => $toId]);
}
}

@ -0,0 +1,8 @@
<?php
namespace Base\Service;
use Base\Facade\Request;
class PaymentService
{
}

@ -954,7 +954,7 @@ class PromoteService {
'bank_card' => $params['bank_card'],
'parent_id' => $parent ? $parent['id'] : 0,
'parent_name' => $parent ? $parent['account'] : C('OFFICIEL_CHANNEL'),
'admin_id' => $params['admin_id'] ?? 0,
'admin_id' => $parent && $parent['admin_id'] > 0 ? $parent['admin_id'] : ($params['admin_id'] ?? 0),
'company_id' => $params['company_id'] ?? 0,
'invite_code' => $params['invite_code'] ?? '',
'create_time' => time(),

@ -0,0 +1,21 @@
<?php
namespace Base\Task;
/**
* 任务基类
* @author elf<360197197@qq.com>
*/
class BaseTask
{
public $params;
public function __construct($params = [])
{
$this->params = $params;
}
public function run()
{
}
}

@ -0,0 +1,31 @@
<?php
namespace Base\Task;
use Base\Service\MarketService;
/**
* 任务处理
* @author elf<360197197@qq.com>
*/
class MarketShiftTask extends BaseTask
{
public function run()
{
$id = $this->params['market_shift_id'];
$record = M('market_shift', 'tab_')->where(['id' => $id])->find();
if (!$record) {
throw new \Exception('换绑记录不存在');
}
if ($record['status'] != 0) {
throw new \Exception('换绑记录状态错误');
}
try {
$marketService = new MarketService();
$marketService->shift($record);
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 1]);
} catch (\Exception $e) {
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 2]);
throw new \Exception($e->getMessage());
}
}
}

@ -0,0 +1,96 @@
<?php
namespace Base\Task;
/**
* 任务处理
* @author elf<360197197@qq.com>
*/
class Task
{
public static $types = [
'market-shift' => '\Base\Task\MarketShiftTask',
'test' => '\Base\Task\TestTask',
];
public static $queues = [
'common' => ['test'],
'market-shift' => ['market-shift']
];
public $queue;
public $tasks;
public function __construct($queue = 'common')
{
$this->queue = $queue;
}
public function run($count = 1)
{
$map = ['status' => 0];
if (!isset(self::$queues[$this->queue])) {
throw new \Exception('无此队列');
}
$types = self::$queues[$this->queue];
if (count($types) > 0) {
$map['type'] = ['in', $types];
} else {
throw new \Exception('暂无任务');
}
$this->tasks = M('tasks', 'tab_')->where($map)->limit($count)->select();
if (count($this->tasks) == 0) {
throw new \Exception('暂无任务');
}
$this->updateTasks(['status' => 1, 'start_time' => time()]);
foreach ($this->tasks as $task) {
$class = $this->getTypeClass($task);
if (is_null($class) || !class_exists($class)) {
$this->updateTask($task, ['status' => 3, 'end_time' => time(), 'result' => '任务处理类不存在']);
continue;
}
try {
$params = json_decode($task['params'], true);
$obj = new $class($params);
$obj->run();
$this->updateTask($task, ['status' => 2, 'end_time' => time(), 'result' => '处理成功']);
} catch (\Exception $e) {
$this->updateTask($task, ['status' => 3, 'end_time' => time(), 'result' => $e->getMessage()]);
}
}
}
public function getTypeClass($task)
{
if (!isset(self::$types[$task['type']])) {
return null;
}
return self::$types[$task['type']];
}
private function updateTask($task, $data)
{
M('tasks', 'tab_')->where(['id' => $task['id']])->save($data);
}
private function updateTasks($data)
{
$ids = array_column($this->tasks, 'id');
M('tasks', 'tab_')->where(['id' => ['in', $ids]])->save($data);
}
public static function add($type, $params = [])
{
if (!isset(self::$types[$type])) {
return false;
}
$record = [
'type' => $type,
'params' => json_encode($params),
'created_time' => time()
];
return M('tasks', 'tab_')->add($record);
}
}

@ -0,0 +1,17 @@
<?php
namespace Base\Task;
use Base\Service\MarketService;
/**
* 任务处理
* @author elf<360197197@qq.com>
*/
class TestTask extends BaseTask
{
public function run()
{
echo '测试' . $this->params['value'] . '执行成功';
echo PHP_EOL;
}
}

@ -0,0 +1,63 @@
<?php
namespace Base\Tool;
use GuzzleHttp\Client;
class ServiceClient
{
const SUCCESS = '0000';
protected $client;
public function __construct()
{
$this->client = new Client([
'base_uri' => C('SERVICE_URL'),
'timeout' => 10.0,
]);
}
protected function post($uri, $data)
{
$response = $this->client->post($uri, [
'verify' => false,
'form_params' => $data
]);
$result = (string)$response->getBody();
return json_decode($result, true);
}
public function sendSmsCode(string $mobile, string $clientIp)
{
$options = ['type' => 'code', 'client_ip' => $clientIp];
return $this->sendSms($mobile, $options);
}
public function sendSmsContent(string $mobile, string $content)
{
$options = ['type' => 'content', 'content' => $content];
return $this->sendSms($mobile, $options);
}
public function sendSmsBatch(array $mobiles, string $content)
{
$options = ['type' => 'batch', 'content' => $content];
return $this->sendSms($mobiles, $options);
}
private function sendSms($mobile, array $options)
{
return $this->post('/message/sms-send', ['mobile' => $mobile, 'options' => $options]);
}
public function checkSms($mobile, $code)
{
return $this->post('/message/sms-check', ['mobile' => $mobile, 'code' => $code]);
}
public function registerEvent($userId, $source)
{
return $this->post('/game-event/register', ['user_id' => $userId, 'source' => $source]);
}
}

@ -2018,6 +2018,35 @@ ADD UNIQUE INDEX `userid_type`(`user_id`, `type`) COMMENT '用户id与类型唯
ALTER TABLE `tab_promote`
ADD COLUMN `withdraw_show` tinyint(2) NOT NULL DEFAULT 0 COMMENT '推广员提现查看权限 1 有 0 无' AFTER `group_remark`,
ADD COLUMN `withdraw_done` tinyint(2) NOT NULL DEFAULT 0 COMMENT '推广员提现查看权限 1 有 0 无' AFTER `withdraw_show`;
CREATE TABLE `tab_tasks` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(20) COLLATE utf8mb4_bin NOT NULL COMMENT '类型',
`params` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '参数',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态 0 待处理 1 处理中 2 处理成功 3 处理失败 ',
`result` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '处理结果',
`start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '处理开始时间',
`end_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '处理结束时间',
`created_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `tab_market_shift` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`promote_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '会长ID',
`from_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '原市场专员ID',
`to_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '市场专员ID',
`split_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '切割时间',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态 0 待处理 1 处理成功 2 处理失败 ',
`remark` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '备注',
`creator_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建者',
`created_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
ALTER TABLE `tab_deposit` add column `market_admin_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '市场专员ID' after promote_account;
ALTER TABLE `tab_spend` add column `market_admin_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '市场专员ID' after promote_account;
--
ALTER TABLE `tab_promote_company`
ADD COLUMN `service_agreement_show` int(11) UNSIGNED NOT NULL DEFAULT 1 COMMENT '展示状态 1展示 2不展示',
@ -2042,5 +2071,3 @@ INSERT INTO `tab_service_agreement` (`id`, `name`, `content`, `status`, `creator
ALTER TABLE `tab_company_info`
ADD COLUMN `ali_account` varchar(128) NULL COMMENT '支付宝账号' AFTER `last_up_time`,
ADD COLUMN `fax_ratio` varchar(20) NULL COMMENT '开票税率' AFTER `ali_account`;

Loading…
Cancel
Save