新增市场结算管理

master
zhengyongxing 5 years ago
parent d1c60ed153
commit 89883d2005

@ -1793,4 +1793,19 @@ function all_pay_way_other($type=false)
$pay_way[15]=array('key'=>15,'value'=>'双乾支付-快捷');
return $pay_way;
}
function getMonthOther() {
$start = date("Y-m", strtotime("now"));
//开始月份
$range = [];
$i = 0;
do {
$month = date('Y-m', strtotime($start . ' - ' . $i . ' month'));
$range[] = $month;
$i++;
} while ($i<36);
return $range;
}
?>

@ -1000,4 +1000,87 @@ class QueryController extends ThinkController
}
}
public function marketList($p=1) {
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
$map = [];
if ($_REQUEST['promote_id']) {
$map['root_id'] = $_REQUEST['promote_id'];
}
if ($_REQUEST['game_name']) {
$map['game_names'] = $_REQUEST['game_name'];
}
if ($_REQUEST['count_date']) {
$map['my_time'] = $_REQUEST['count_date'];
}
if ($_REQUEST['device']) {
$map['game_name'] = ['like','%'.$_REQUEST['device'].'%'];
}
//获取spend表中的数据同时根据会长id进行group分类
$data = M('Spend','tab_')
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,game_name,SUBSTRING_INDEX(`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id ")
->join("left join tab_promote on promote_id = tab_promote.id")
->where(['pay_status'=>1])
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select(false);
$count = M()->table('('.$data.') as a')
->field("my_time,pay_amount,game_id,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account")
->join("left join tab_promote on root_id = tab_promote.id")
->group("my_time,game_names,root_id")
->where($map)
->order("my_time Desc")
->select(false);
//关联表获取会长账号名
$data = M()->table('('.$data.') as a')
->field("my_time,pay_amount,game_id,game_name,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account")
->join("left join tab_promote on root_id = tab_promote.id")
->page($page,$row)
->where($map)
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select();
$pagecount = M()->table('('.$count.') as a')->count();
foreach($data as $key => $value) {
$data[$key]['upstream'] = $value['pay_amount'] * 0.2;
$data[$key]['downstream'] = $value['pay_amount'] * 0.7;
$data[$key]['highquality'] = ($value['pay_amount']-$data[$key]['upstream']-$data[$key]['downstream']) * (1-0.0672);
$data[$key]['company_belong'] = $data[$key]['company_belong']?'外团':'内团';
$data[$key]['company_relation'] = $data[$key]['company_relation']?'只维护':'自主开发及维护';
}
$page = set_pagination($pagecount, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('data',$data);
$this->display();
}
}

Loading…
Cancel
Save