|
|
|
@ -37,27 +37,208 @@ class PartnerController extends ThinkController
|
|
|
|
|
$row = intval(I('row', 0));
|
|
|
|
|
$row = empty($row) ? 10 : $row;//每页条数
|
|
|
|
|
|
|
|
|
|
$data = $model->alias('p')
|
|
|
|
|
->field('p.id,p.partner,p.status,p.create_time,link_man,link_phone,address,company_tax_no,payee_name,
|
|
|
|
|
bank_account,opening_bank,m.nickname')
|
|
|
|
|
->join('left join sys_member as m on m.uid = p.uid')
|
|
|
|
|
//获取分页数据
|
|
|
|
|
$partners = $model->alias('p')
|
|
|
|
|
->field("p.partner,p.matche_platform,p.invoice_rate,p.settlement_type,p.bank_account,
|
|
|
|
|
p.opening_bank,p.id,p.contract_start_time,p.contract_end_time,p.remark")
|
|
|
|
|
->where($map)
|
|
|
|
|
->order('id desc')
|
|
|
|
|
->page($page, $row)
|
|
|
|
|
->order("id desc")
|
|
|
|
|
->page($page,$row)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
//获取公司id
|
|
|
|
|
$partner_ids = array_column($partners, 'id');
|
|
|
|
|
$game_map['partner_id'] = ["in",$partner_ids];
|
|
|
|
|
$games = M("game","tab_")->alias('g')
|
|
|
|
|
->field("g.game_type_name,g.relation_game_name,g.original_package_name,g.partner_id,g.id")
|
|
|
|
|
->where($game_map)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$game_ids = array_column($games, 'id');
|
|
|
|
|
$cp_game_ratio_map['game_id'] = ["in", $game_ids];
|
|
|
|
|
$cp_game_ratio_map['is_del'] = '0';
|
|
|
|
|
//获取游戏比例
|
|
|
|
|
$gameradiores = M("cp_game_ratio","tab_")
|
|
|
|
|
->alias("cg")
|
|
|
|
|
->field("cg.ratio,cg.instanceof,cg.game_id,cg.begin_total_amount")
|
|
|
|
|
->where($cp_game_ratio_map)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
// dd($cp_game_ratio_map);
|
|
|
|
|
$parseGameRadiores = array();
|
|
|
|
|
foreach ($gameradiores as $key =>$val) {
|
|
|
|
|
if ($val['begin_total_amount'] == 0) {
|
|
|
|
|
$val['name'] = '默认比例';
|
|
|
|
|
} else {
|
|
|
|
|
if($val['instanceof']=='1'){
|
|
|
|
|
$val['name']="月流水≥".$val['begin_total_amount'];
|
|
|
|
|
}else{
|
|
|
|
|
$val['name']="月流水>".$val['begin_total_amount'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$val['row'] = 1;
|
|
|
|
|
$parseGameRadiores[$val['game_id']][] = $val;
|
|
|
|
|
}
|
|
|
|
|
// dd($parseGameRadiores);
|
|
|
|
|
$parseGames = array();
|
|
|
|
|
|
|
|
|
|
foreach ($games as $key =>$val) {
|
|
|
|
|
$val['game_ratio'] = $parseGameRadiores[$val['id']];
|
|
|
|
|
if(array_key_exists($val['id'],$parseGameRadiores)){//游戏有比例
|
|
|
|
|
$row2 = array_sum(array_column($val['game_ratio'], 'row')) ;
|
|
|
|
|
$val['row'] = empty($row2) ? 1: $row2;
|
|
|
|
|
} else {
|
|
|
|
|
$val["row"] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$parseGames[$val['partner_id']][] = $val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parseData = array();
|
|
|
|
|
foreach ($partners as $key =>$value) {
|
|
|
|
|
$value['game'] = $parseGames[$value['id']];
|
|
|
|
|
$value['has_game_evidence'] = $parseGames['has_game_evidence'] ? '有' : '没有';
|
|
|
|
|
$value['is_sign_contract'] = $parseGames['is_sign_contract'] ? '是' : '否';
|
|
|
|
|
if ($value['settlement_type'] == 0) {
|
|
|
|
|
$value['settlement_type'] = '未配置';
|
|
|
|
|
} elseif ($value['settlement_type'] == 1) {
|
|
|
|
|
$value['settlement_type'] = '周结';
|
|
|
|
|
} elseif ($value['settlement_type'] == 2) {
|
|
|
|
|
$value['settlement_type'] = '月结';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$value['contract_time'] = time_format($value['contract_start_time'], 'Y/m/d') . '-' .
|
|
|
|
|
time_format($value['contract_end_time'], 'Y/m/d');
|
|
|
|
|
$row2 = array_sum(array_column($value['game'], 'row')) ;
|
|
|
|
|
$value['row'] = empty($row2) ? 1: $row2;
|
|
|
|
|
$parseData[$value['partner_id']][] = $value;
|
|
|
|
|
}
|
|
|
|
|
$parseData = array_values($parseData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 查询记录总数 */
|
|
|
|
|
$count = $model
|
|
|
|
|
->where($map)
|
|
|
|
|
->count();
|
|
|
|
|
//分页
|
|
|
|
|
$parameter['p'] = $page;
|
|
|
|
|
$parameter['row'] = $row;
|
|
|
|
|
$page = set_pagination($count, $row, $parameter);
|
|
|
|
|
if ($page) {
|
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
|
}
|
|
|
|
|
// dd($parseData[0]);
|
|
|
|
|
$this->assign('listData', $parseData[0]);
|
|
|
|
|
$this->assign('count', $count);
|
|
|
|
|
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/lists'])->find());
|
|
|
|
|
$this->meta_title = '合作方管理';
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($data)) {
|
|
|
|
|
foreach ($data as &$list) {
|
|
|
|
|
$list['status'] = ($list['status'] == 0) ? '已关闭' : '已开启';
|
|
|
|
|
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
|
|
|
|
|
//列表
|
|
|
|
|
public function lists2()
|
|
|
|
|
{
|
|
|
|
|
$model = M($this->modelName, 'tab_');
|
|
|
|
|
$map = [];
|
|
|
|
|
$id = intval(I('id', 0));
|
|
|
|
|
if (!empty($id)) {
|
|
|
|
|
$map['tab_partner.id'] = $id;
|
|
|
|
|
$parameter['id'] = $id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') {
|
|
|
|
|
$status = intval($_REQUEST['status']);
|
|
|
|
|
$map['tab_partner.status'] = $status;
|
|
|
|
|
$parameter['status'] = $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$page = intval(I('get.p', 0));
|
|
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
|
|
$row = intval(I('row', 0));
|
|
|
|
|
$row = empty($row) ? 10 : $row;//每页条数
|
|
|
|
|
|
|
|
|
|
//获取分页数据
|
|
|
|
|
$partners = $model->alias('p')
|
|
|
|
|
->field("p.partner,p.matche_platform,p.invoice_rate,p.settlement_type,p.bank_account,
|
|
|
|
|
p.opening_bank,p.id,p.contract_start_time,p.contract_end_time,p.remark")
|
|
|
|
|
->where($map)
|
|
|
|
|
->order("id desc")
|
|
|
|
|
->page($page,$row)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
//获取公司id
|
|
|
|
|
$partner_ids = implode(',', array_column($partners, 'id'));
|
|
|
|
|
$game_map['partner_id'] = ["in",$partner_ids];
|
|
|
|
|
$games = M("game","tab_")->alias('g')
|
|
|
|
|
->field("g.game_type_name,g.relation_game_name,g.original_package_name,g.partner_id,g.id")
|
|
|
|
|
->where($game_map)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$game_ids = implode(',', array_column($games, 'id'));
|
|
|
|
|
$cp_game_ratio_map['game_id'] = ["in",$game_ids];
|
|
|
|
|
//获取游戏比例
|
|
|
|
|
$gameradiores = M("cp_game_ratio","tab_")
|
|
|
|
|
->alias("cg")
|
|
|
|
|
->field("cg.ratio,cg.instanceof,cg.game_id")
|
|
|
|
|
->join("tab_game ga ON cg.game_id = ga.id")
|
|
|
|
|
->where($cp_game_ratio_map)
|
|
|
|
|
->where(['is_del' => 0])
|
|
|
|
|
->group("game_id")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$parseGameRadiores = array();
|
|
|
|
|
foreach ($gameradiores as $key =>$val) {
|
|
|
|
|
$val['row'] = 1;
|
|
|
|
|
$parseGameRadiores[$val['game_id']][] = $val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$parseGames = array();
|
|
|
|
|
|
|
|
|
|
foreach ($games as $key =>$val) {
|
|
|
|
|
$val['game_ratio'] = $parseGameRadiores[$val['id']];
|
|
|
|
|
if(array_key_exists($val['id'],$parseGameRadiores)){//游戏有比例
|
|
|
|
|
$row = array_sum(array_column($val['game_ratio'], 'row')) ;
|
|
|
|
|
$val['row'] = empty($row) ? 1: $row;
|
|
|
|
|
} else {
|
|
|
|
|
$val["row"] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$parseGames[$val['partner_id']][] = $val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parseData = array();
|
|
|
|
|
foreach ($partners as $key =>$value) {
|
|
|
|
|
$value['game'] = $parseGames[$value['id']];
|
|
|
|
|
$value['has_game_evidence'] = $parseGames['has_game_evidence'] ? '有' : '没有';
|
|
|
|
|
$value['is_sign_contract'] = $parseGames['is_sign_contract'] ? '是' : '否';
|
|
|
|
|
if ($value['settlement_type'] == 0) {
|
|
|
|
|
$value['settlement_type'] = '未配置';
|
|
|
|
|
} elseif ($value['settlement_type'] == 1) {
|
|
|
|
|
$value['settlement_type'] = '周结';
|
|
|
|
|
} elseif ($value['settlement_type'] == 2) {
|
|
|
|
|
$value['settlement_type'] = '月结';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$value['contract_time'] = time_format($value['contract_start_time'], 'Y/m/d') . '-' .
|
|
|
|
|
time_format($value['contract_end_time'], 'Y/m/d');
|
|
|
|
|
$row = array_sum(array_column($value['game'], 'row')) ;
|
|
|
|
|
$value['row'] = empty($row) ? 1: $row;
|
|
|
|
|
$parseData[$value['partner_id']][] = $value;
|
|
|
|
|
}
|
|
|
|
|
$parseData = array_values($parseData);
|
|
|
|
|
|
|
|
|
|
// dd($parseData);
|
|
|
|
|
|
|
|
|
|
/* 查询记录总数 */
|
|
|
|
|
$count = $model
|
|
|
|
|
->where($map)
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
//分页
|
|
|
|
|
$parameter['p'] = $page;
|
|
|
|
|
$parameter['row'] = $row;
|
|
|
|
@ -66,7 +247,7 @@ class PartnerController extends ThinkController
|
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assign('listData', $data);
|
|
|
|
|
$this->assign('listData', $parseData[0]);
|
|
|
|
|
$this->assign('count', $count);
|
|
|
|
|
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/lists'])->find());
|
|
|
|
|
$this->meta_title = '合作方管理';
|
|
|
|
@ -77,7 +258,6 @@ class PartnerController extends ThinkController
|
|
|
|
|
public function add()
|
|
|
|
|
{
|
|
|
|
|
if ($_POST) {
|
|
|
|
|
dd($_REQUEST);
|
|
|
|
|
$partner = I('post.partner', '');
|
|
|
|
|
$status = intval(I('post.status', 1));
|
|
|
|
|
|
|
|
|
@ -124,13 +304,13 @@ class PartnerController extends ThinkController
|
|
|
|
|
$save['contract_start_time'] = strtotime(I('contract_start_time'));
|
|
|
|
|
$save['contract_end_time'] = strtotime(I('contract_end_time'));
|
|
|
|
|
$save['channel_rate'] = I('channel_rate');
|
|
|
|
|
$save['invoice_rate'] = I('invoice_rate');
|
|
|
|
|
$save['invoice_rate'] = I('invoice_rate') ?: 0;
|
|
|
|
|
$save['is_sign_contract'] = I('is_sign_contract');
|
|
|
|
|
$save['settlement_type'] = I('settlement_type');
|
|
|
|
|
$save['has_game_evidence'] = I('has_game_evidence');
|
|
|
|
|
$save['remark'] = I('remark');
|
|
|
|
|
if (isset($save['file_info'])) {
|
|
|
|
|
$save['file_info'] = json_encode($save['file_info'],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
if (!empty(I('file_info'))) {
|
|
|
|
|
$save['file_info'] = I('file_info');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$save['uid'] = UID;
|
|
|
|
@ -170,9 +350,6 @@ class PartnerController extends ThinkController
|
|
|
|
|
if (empty(I('link_phone'))) {
|
|
|
|
|
$this->error('请输入联系电话');
|
|
|
|
|
}
|
|
|
|
|
if (!in_array($status, [0, 1]) || $id == 0) {
|
|
|
|
|
$this->error('参数异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = $model
|
|
|
|
|
->field('id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank')
|
|
|
|
@ -183,6 +360,7 @@ class PartnerController extends ThinkController
|
|
|
|
|
|
|
|
|
|
$map['partner'] = $partner;
|
|
|
|
|
$res = $model->where($map)->getField('id');
|
|
|
|
|
dd($res);
|
|
|
|
|
if ($res && $res != $id) {
|
|
|
|
|
$this->error('合作方已存在');
|
|
|
|
|
}
|
|
|
|
@ -210,6 +388,19 @@ class PartnerController extends ThinkController
|
|
|
|
|
$save['bank_account'] = I('bank_account');
|
|
|
|
|
$save['opening_bank'] = I('opening_bank');
|
|
|
|
|
|
|
|
|
|
$save['matche_platform'] = I('matche_platform');
|
|
|
|
|
$save['contract_start_time'] = strtotime(I('contract_start_time'));
|
|
|
|
|
$save['contract_end_time'] = strtotime(I('contract_end_time'));
|
|
|
|
|
$save['channel_rate'] = I('channel_rate');
|
|
|
|
|
$save['invoice_rate'] = I('invoice_rate') ?: 0;
|
|
|
|
|
$save['is_sign_contract'] = I('is_sign_contract');
|
|
|
|
|
$save['settlement_type'] = I('settlement_type');
|
|
|
|
|
$save['has_game_evidence'] = I('has_game_evidence');
|
|
|
|
|
$save['remark'] = I('remark');
|
|
|
|
|
if (!empty(I('file_info'))) {
|
|
|
|
|
$save['file_info'] = I('file_info');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$save['status'] = $status;
|
|
|
|
|
$save['last_up_time'] = $time;
|
|
|
|
|
$res = $model->save($save);
|
|
|
|
@ -223,16 +414,19 @@ class PartnerController extends ThinkController
|
|
|
|
|
$id = intval(I('get.id', 0));
|
|
|
|
|
$map['id'] = $id;
|
|
|
|
|
$data = $model
|
|
|
|
|
->field('id,partner,status,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank')
|
|
|
|
|
->find($id);
|
|
|
|
|
if (empty($data)) {
|
|
|
|
|
$this->error('数据异常', U('lists'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assign('config', $data);
|
|
|
|
|
$data['contract_start_time'] = date('Y-m-d', $data['contract_start_time']);
|
|
|
|
|
$data['contract_end_time'] = date('Y-m-d', $data['contract_end_time']);
|
|
|
|
|
// dd($data);
|
|
|
|
|
$this->assign('data', $data);
|
|
|
|
|
$action = I('action');
|
|
|
|
|
$this->assign('action', $action);
|
|
|
|
|
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/edit'])->find());
|
|
|
|
|
$this->meta_title = '编辑合作方';
|
|
|
|
|
$this->display();
|
|
|
|
|
$this->meta_title = $action ? '查看合作方' : '编辑合作方';
|
|
|
|
|
$this->display($action);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|