Merge branch 'master_hotfix_20191228' of wmtx/platform into master

修改工会统计bug
master
万盟天下 5 years ago committed by Gogs
commit 23defe8174

@ -176,6 +176,23 @@ class AjaxController extends ThinkController{
} }
$this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]); $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]);
} }
/**
* 根据公司id获取会长
*/
public function getPromotersByCompanyid($company_id = -1)
{
$company_id = I('company_id');
$data = M("Promote","tab_")->field("id,account,nickname,company_id");
if($company_id == -1){
$data = $data->where("level = '1'")->select();
}else{
$data = $data->where("company_id = '{$company_id}' and level = '1'")->select();
}
foreach ($data as &$item) {
$item['nickname'] = $item['account'] . ($item['nickname'] ? "({$item['nickname']})" : "");
}
$this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>$data]);
}
public function getPromotersByLevelOther() public function getPromotersByLevelOther()
{ {

@ -44,9 +44,10 @@ class FinancePromoteController extends AdminController
foreach($cash as $k=>$v){ foreach($cash as $k=>$v){
$senddata[$v['p_id']] = $v; $senddata[$v['p_id']] = $v;
} }
//内冲
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); //内冲
foreach($inside as $k=>$v){ $inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){
if(array_key_exists($v['p_id'],$senddata)){ if(array_key_exists($v['p_id'],$senddata)){
$senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount']; $senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount'];
}else{ }else{
@ -56,17 +57,43 @@ class FinancePromoteController extends AdminController
$senddata[$v['p_id']] = $v; $senddata[$v['p_id']] = $v;
}; };
} }
//官方渠道单算
//判断公司
$gfidlag = true;
$gfgs = true;
if (isset($_REQUEST['company_id'])) {
if($_REQUEST['company_id']!=0){
$gfgs = false;
}
}
if (isset($_REQUEST['promote_id'])) {
if($_REQUEST['promote_id'] == 0){
$gfidlag = true;
}else{
$gfidlag =false;
}
}
if($gfidlag && $gfgs){
//计算官方渠道
unset($_REQUEST['company_id']);
$_REQUEST['promote_id'] = 0;
$gfcash = self::getJoinPromoteData([],$istimeselect);
$senddata[0] = $gfcash[0];
}
if(!empty($senddata)){ if(!empty($senddata)){
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
$pmap['status']=1; if (empty($_REQUEST['company_id'])) {
if($istimeselect){ $pmap['status']=1;
$pmap['create_time'] = $istimeselect; if($istimeselect){
} $pmap['create_time'] = $istimeselect;
$admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); }
if($admininside['amount'] >0){ $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find();
$senddata[0]['inside_cash_count']= $admininside['amount']; if($admininside['amount'] >0){
$senddata[0]['inside_cash_count']= $admininside['amount'];
}
} }
} }
} }
$data = []; $data = [];
@ -79,6 +106,7 @@ class FinancePromoteController extends AdminController
foreach($senddata as $k=>$v){ foreach($senddata as $k=>$v){
if(empty($v['company_name'])) $v['company_name']= "万盟天下科技"; if(empty($v['company_name'])) $v['company_name']= "万盟天下科技";
if(empty($v['p_id'])) $v['p_id']= "0";
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0; if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0; if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0;
if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0; if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0;
@ -112,7 +140,6 @@ class FinancePromoteController extends AdminController
$size = $row; $size = $row;
$data = array_slice($data, ($arraypage - 1) * $size, $size); $data = array_slice($data, ($arraypage - 1) * $size, $size);
$this->assign('list_data', $data); $this->assign('list_data', $data);
$this->assign('all_count', $count); $this->assign('all_count', $count);
$this->meta_title = '公会统计'; $this->meta_title = '公会统计';
@ -122,7 +149,7 @@ class FinancePromoteController extends AdminController
private function getJoinPromoteData($map,$istimeselect,$type="spend") private function getJoinPromoteData($map,$istimeselect,$type="spend")
{ {
// setPowerPromoteIds($map,"s.promote_id"); // setPowerPromoteIds($map,"s.promote_id");
if ($_REQUEST['promote_id'] != '') { if (isset($_REQUEST['promote_id'])) {
if ($_REQUEST['promote_id'] == 0) { if ($_REQUEST['promote_id'] == 0) {
$map['s.promote_id'] = 0; $map['s.promote_id'] = 0;
} else { } else {
@ -134,7 +161,9 @@ class FinancePromoteController extends AdminController
} }
if (isset($_REQUEST['company_id'])) { if (isset($_REQUEST['company_id'])) {
$map['promote.company_id'] = $_REQUEST['company_id']; $map['promote.company_id'] = $_REQUEST['company_id'];
} }
if($type == "spend"){ if($type == "spend"){
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) { 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')) ); $map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
@ -142,7 +171,6 @@ class FinancePromoteController extends AdminController
if($istimeselect){ if($istimeselect){
$map['s.pay_time']=$istimeselect; $map['s.pay_time']=$istimeselect;
} }
$map['s.pay_status']=1; $map['s.pay_status']=1;
$field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, $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 = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
@ -150,26 +178,29 @@ class FinancePromoteController extends AdminController
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(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(company_id,0) company_id,company_name";
return M() return M()
->table("tab_spend s") ->table("tab_spend s")
->field($field) ->field($field)
->where($map) ->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left") ->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left") ->join("tab_promote_company company ON promote.company_id = company.id","left")
->group('p_id') ->group('p_id')
->select(); ->select();
}else{ }else{
if($istimeselect){ if($istimeselect){
$map['s.create_time']=$istimeselect; $map['s.create_time']=$istimeselect;
} }
$map['s.status']=1; $map['s.status']=1;
$map['s.source_id']=0; $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"; $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";
return M("promote_coin s","tab_") return M("promote_coin s","tab_")
->field($field) ->field($field)
->where($map) ->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left") ->join("tab_promote promote ON s.promote_id = promote.id","left")
->group('p_id') ->join("tab_promote_company company ON promote.company_id = company.id","left")
->select(); ->group('p_id')
->select();
} }
} }
@ -202,25 +233,27 @@ class FinancePromoteController extends AdminController
$senddata[$v['promote_id']] = $v; $senddata[$v['promote_id']] = $v;
} }
$inside = self::promoteUserData([],$istimeselect,"promote_coin"); $inside = self::promoteUserData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){ foreach($inside as $k=>$v){
if(array_key_exists($v['promote_id'],$senddata)){ if(array_key_exists($v['promote_id'],$senddata)){
$senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount']; $senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount'];
}else{ }else{
$v['inside_cash_count'] = $v['pay_amount']; $v['inside_cash_count'] = $v['pay_amount']-$v['back_amount'];
unset($v['pay_amount']); unset($v['pay_amount']);
$senddata[$v['promote_id']] = $v; $senddata[$v['promote_id']] = $v;
}; };
} }
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ if(!empty($senddata)){
$pmap['status']=1; if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
if($istimeselect){ $pmap['status']=1;
$pmap['create_time'] = $istimeselect; if($istimeselect){
} $pmap['create_time'] = $istimeselect;
$admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); }
if($admininside['amount'] >0){ $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find();
$senddata[0]['inside_cash_count']= $admininside['amount']; if($admininside['amount'] >0){
} $senddata[0]['inside_cash_count']= $admininside['amount'];
}
}
} }
$count = count($senddata); $count = count($senddata);
if ($_REQUEST['data_order'] != '') { if ($_REQUEST['data_order'] != '') {
@ -308,27 +341,28 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_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(company_id,0) company_id,company_name,promote_id,promote.account promote_account";
return M() return M()
->table("tab_spend s") ->table("tab_spend s")
->field($field) ->field($field)
->where($map) ->where($map)
->join("tab_promote promote ON s.promote_id = promote.id", "left") ->join("tab_promote promote ON s.promote_id = promote.id", "left")
->join("tab_promote_company company ON promote.company_id = company.id", "left") ->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id') ->group('promote_id')
->select(); ->select();
}else{ }else{
if($istimeselect){ if($istimeselect){
$map['s.create_time']=$istimeselect; $map['s.create_time']=$istimeselect;
} }
$map['s.status']=1; $map['s.status']=1;
$map['s.source_id']=0; $map['s.source_id']=0;
$map['s.type']=1; $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,
$field= "sum(num) pay_amount,promote_id"; IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account";
return M("promote_coin s","tab_") return M("promote_coin s","tab_")
->field($field) ->field($field)
->where($map) ->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left") ->join("tab_promote promote ON s.promote_id = promote.id","left")
->group('promote_id') ->join("tab_promote_company company ON promote.company_id = company.id", "left")
->select(); ->group('promote_id')
->select();
} }
# code... # code...
} }
@ -372,7 +406,7 @@ class FinancePromoteController extends AdminController
} }
$this->assign('promote_level', $level); $this->assign('promote_level', $level);
//游戏统计列表 //游戏统计列表
$data =self::gameStatisticsData($map, $row, $p); $data =self::gameStatisticsData($map, $row, $p);
if(isset($_REQUEST['export'])){ if(isset($_REQUEST['export'])){
$data =self::gameStatisticsData($map); $data =self::gameStatisticsData($map);
@ -765,9 +799,9 @@ class FinancePromoteController extends AdminController
$total_cost = $admincount["amount"]?:0; $total_cost = $admincount["amount"]?:0;
if($count >0){ if($count >0){
$admininside = M("provide_user p","tab_") $admininside = M("provide_user p","tab_")
->field("order_number,user_account,amount,balance,create_time") ->field("order_number,user_account,amount,balance,create_time")
->join("left join tab_user as u on u.id = p.user_id") ->join("left join tab_user as u on u.id = p.user_id")
->where($pmap); ->where($pmap);
if(isset($_REQUEST['export'])){ if(isset($_REQUEST['export'])){
$admininside = $admininside->select(); $admininside = $admininside->select();
@ -797,9 +831,9 @@ class FinancePromoteController extends AdminController
$map['s.status']=1; $map['s.status']=1;
$map['s.source_id']=0; $map['s.source_id']=0;
$ininsidecount = M("promote_coin s","tab_") $ininsidecount = M("promote_coin s","tab_")
->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,count(*) count") ->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,count(*) count")
->where($map) ->where($map)
->find(); ->find();
$count = $ininsidecount["count"]?:0; $count = $ininsidecount["count"]?:0;
$total_cost = ($ininsidecount["pay_amount"]-$ininsidecount["back_amount"]); $total_cost = ($ininsidecount["pay_amount"]-$ininsidecount["back_amount"]);
if ($count >0) { if ($count >0) {

@ -277,21 +277,14 @@ class PromoteController extends ThinkController
if (preg_match('/^[a-zA-Z0-9]{6,15}$/', I('post.account'))==false) { if (preg_match('/^[a-zA-Z0-9]{6,15}$/', I('post.account'))==false) {
$this->error('账号只能是6-15位字母或数字'); $this->error('账号只能是6-15位字母或数字');
} }
$promote = M("promote", "tab_")->where(array("id" => $_POST['id']))->field('id, level')->find();
$data['account'] = I('post.account'); $data['account'] = I('post.account');
$map1['id'] = array('neq',$_POST['id']);
$map1['account'] = $data['account'];
if ($this->accountExist($data['account'], $_POST['id'])) { if ($this->accountExist($data['account'], $_POST['id'])) {
$this->error('该账号已存在'); $this->error('该账号已存在');
} }
if (empty(I('company_id'))) { if (empty(I('company_id')) && $promote['level'] ==1) {
$this->error('请选择推广公司'); $this->error('请选择推广公司');
} }
$pdata = D('Promote')->where($map1)->find();
if ($pdata) {
$this->error('渠道账号已存在');
}
empty(I('post.id')) ? : $data['id'] =I('post.id'); empty(I('post.id')) ? : $data['id'] =I('post.id');
empty(I('post.password')) ? : $data['password'] =I('post.password'); empty(I('post.password')) ? : $data['password'] =I('post.password');
empty(I('post.second_pwd')) ? : $data['second_pwd'] =I('post.second_pwd'); empty(I('post.second_pwd')) ? : $data['second_pwd'] =I('post.second_pwd');
@ -317,12 +310,16 @@ class PromoteController extends ThinkController
$ba = new \Admin\Model\BusinessAffairsModel(); $ba = new \Admin\Model\BusinessAffairsModel();
$ba->update_child($ba_id['ba_id'], $_REQUEST['ba_id'], $id); $ba->update_child($ba_id['ba_id'], $_REQUEST['ba_id'], $id);
} }
if (!empty(I('company_id'))) { if (!empty(I('company_id')) && $promote['level'] ==1) {
$data['company_id'] = I('company_id'); $data['company_id'] = I('company_id');
} }
$res = M("promote", "tab_")->where(array("id"=>$_POST['id']))->save($data);
$res=M("promote", "tab_")->where(array("id"=>$_POST['id']))->save($data);
if ($res !== false) { if ($res !== false) {
if (!empty(I('company_id')) && $promote['level'] ==1) {//修改会长底下推广员的推广公司
M("promote", "tab_")->where("chain like '%/{$_POST['id']}/%'")->save([
'company_id' => I('company_id')
]);
}
$this->success("修改成功", U('lists')); $this->success("修改成功", U('lists'));
} else { } else {
$this->error("修改失败"); $this->error("修改失败");

@ -407,19 +407,24 @@
autoclose: true, autoclose: true,
pickerPosition: 'bottom-left' pickerPosition: 'bottom-left'
}) })
var promote_id = "{:I('promote_id')}"; var promote_id = "{:I('promote_id')}";
function getPromotersByLevel() { var company_id = "{:I('company_id')}";
function getPromotersByCompanyid() {
var company_id = $("#company_id option:selected").val();
if(!company_id){
company_id = -1;
}
$.ajax({ $.ajax({
url: "{:U('Ajax/getPromotersByLevel')}", url: "{:U('Ajax/getPromotersByCompanyid')}",
type: "get", type: "get",
data: { level: 1 }, data: { company_id:company_id},
dataType: 'json', dataType: 'json',
success: function (response) { success: function (response) {
str = '<option value="">请选择会长</option><option value="0"' + (promote_id && 0 == promote_id ? 'selected' : '') + '>官方渠道</option>'; str = '<option value="">请选择会长</option>';
// $.each(response.data, function(index, item){ if(company_id == 0 || company_id ==-1){
// console.log(item.id); str +='<option value="0"' + (promote_id && 0 == promote_id ? 'selected' : '') + '>官方渠道</option>';
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>'; }
// });
data = response.data; data = response.data;
for (var i in data) { for (var i in data) {
str += "<option value='" + data[i].id + "' " + (promote_id && data[i].id == promote_id ? 'selected' : '') + ">" + data[i].nickname + "</option>" str += "<option value='" + data[i].id + "' " + (promote_id && data[i].id == promote_id ? 'selected' : '') + ">" + data[i].nickname + "</option>"
@ -430,7 +435,11 @@
} }
}) })
} }
getPromotersByLevel(); getPromotersByCompanyid();
$("#company_id").change(function(){
getPromotersByCompanyid();
})
}) })

@ -382,18 +382,19 @@
pickerPosition: 'bottom-left' pickerPosition: 'bottom-left'
}) })
var promote_id = "{:I('promote_id')}"; var promote_id = "{:I('promote_id')}";
function getPromotersByLevel() { var company_id = "{:I('company_id')}";
function getPromotersByCompanyid() {
var company_id = $("#company_id option:selected").val();
if(!company_id){
company_id = -1;
}
$.ajax({ $.ajax({
url: "{:U('Ajax/getPromotersByLevel')}", url: "{:U('Ajax/getPromotersByCompanyid')}",
type: "get", type: "get",
data: { level: 1 }, data: { company_id:company_id},
dataType: 'json', dataType: 'json',
success: function (response) { success: function (response) {
str = '<option value="">请选择会长</option><option value="0"' + (promote_id && 0 == promote_id ? 'selected' : '') + '>官方渠道</option>'; str = '<option value="">请选择会长</option>';
// $.each(response.data, function(index, item){
// console.log(item.id);
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>';
// });
data = response.data; data = response.data;
for (var i in data) { for (var i in data) {
str += "<option value='" + data[i].id + "' " + (promote_id && data[i].id == promote_id ? 'selected' : '') + ">" + data[i].nickname + "</option>" str += "<option value='" + data[i].id + "' " + (promote_id && data[i].id == promote_id ? 'selected' : '') + ">" + data[i].nickname + "</option>"
@ -404,7 +405,11 @@
} }
}) })
} }
getPromotersByLevel(); getPromotersByCompanyid();
$("#company_id").change(function(){
getPromotersByCompanyid();
})
}) })

@ -180,7 +180,9 @@
<tr> <tr>
<td class="l">推广公司:</td> <td class="l">推广公司:</td>
<td class="r"> <td class="r">
<select name="company_id" id="company_id"> <select name="company_id" id="company_id"
<if condition="$data['level'] != 1">
disabled style="background:#CCCCCC" </if>>
<option value="0">请选择推广公司</option> <option value="0">请选择推广公司</option>
<volist name="companys" id="vo"> <volist name="companys" id="vo">

Loading…
Cancel
Save