You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
6.4 KiB
PHP
196 lines
6.4 KiB
PHP
<?php
|
|
// 公司关系绑定
|
|
namespace Admin\Controller;
|
|
|
|
class CompanyRelationController extends AdminController
|
|
{
|
|
public $admininfo;
|
|
public $DBModel;
|
|
public $DBlogModel;
|
|
public $OpAuthList=[];
|
|
public $Status = [
|
|
"-2"=>"管理员拒绝",
|
|
"-1"=>"市场部拒绝",
|
|
"0"=>"待审核",
|
|
"1"=>"市场部通过",
|
|
"2"=>"管理员通过"
|
|
];
|
|
public $CompanyType = [
|
|
"0"=>"己方公司",
|
|
"1"=>"上游cp公司",
|
|
"2"=>"联运下游渠道公司"
|
|
];
|
|
public function _initialize()
|
|
{
|
|
$this->admininfo = $_SESSION['onethink_admin']['user_auth'];
|
|
$this->DBlogModel = M("company_relation_log","tab_");
|
|
$this->DBModel = M("company_relation","tab_");
|
|
parent::_initialize();
|
|
}
|
|
//生效列表
|
|
public function index()
|
|
{
|
|
|
|
}
|
|
//审核列表
|
|
public function lists()
|
|
{
|
|
|
|
$this->display();
|
|
}
|
|
|
|
public function marketAgree(){
|
|
|
|
}
|
|
public function marketRefuse(){
|
|
|
|
}
|
|
public function adminRefuse(){
|
|
|
|
}
|
|
//管理员成功
|
|
public function adminAgree(){
|
|
|
|
}
|
|
|
|
public function addRelation()
|
|
{
|
|
if ($_POST) {
|
|
$params = I('post.');
|
|
if ($params['first_company_type'] == $params['second_company_type']) {
|
|
$this->error('合作甲乙双方不能是同类型公司');
|
|
}
|
|
if ($params['first_company_type']!=0 && $params['second_company_type']!=0) {
|
|
$this->error('合作甲乙双方必须有个是己方公司');
|
|
}
|
|
$params['remark'] = $params['remark'] ?? '';
|
|
$params['status'] = 0;
|
|
$params['verify_log']=json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s")]);
|
|
//判断已有未审核
|
|
$where = "
|
|
(
|
|
(first_company_type ='{$params['first_company_type']}' and first_company_id = '{$params['first_company_id']}')
|
|
OR
|
|
(first_company_type ='{$params['second_company_type']}' and first_company_id = '{$params['second_company_id']}')
|
|
)
|
|
AND
|
|
(
|
|
(second_company_type ='{$params['first_company_type']}' and second_company_id = '{$params['first_company_id']}')
|
|
OR
|
|
(second_company_type ='{$params['second_company_type']}' and second_company_id = '{$params['second_company_id']}')
|
|
)
|
|
AND
|
|
status < 2
|
|
";
|
|
$hasdb = $this->DBlogModel->field("count(id) count")->where($where)->find()['count'];
|
|
if($hasdb > 0){
|
|
$this->error('当前甲乙双方已有审批单,请直接搜索后修改');
|
|
}
|
|
$id = $this->DBlogModel->add($params);
|
|
addOperationLog(['op_type'=>0,'key'=>$id,'op_name'=>'新增','url'=>U('lists')]);
|
|
$this->ajaxReturn(["msg"=>"添加成功","code"=>1,"url"=>U("lists")]);
|
|
|
|
} else {
|
|
$this->assign('companyType',$this->CompanyType);
|
|
$this->display();
|
|
}
|
|
}
|
|
public function editRelation()
|
|
{
|
|
|
|
}
|
|
public function delRelation()
|
|
{
|
|
|
|
}
|
|
public function getCompanyList($type)
|
|
{
|
|
if($type ==''){
|
|
$this->success([],'',true);
|
|
}
|
|
$companyInfo = [];
|
|
if($type == 0){
|
|
//己方公司
|
|
$companyInfo = M("CompanyInfo","tab_")->field("id,partner company_name,link_man,link_phone")->where("status='1'")->select();
|
|
}
|
|
if($type == 1){
|
|
//上游
|
|
$companyInfo = M("Partner","tab_")->field("id,partner company_name,company_type,link_man,link_phone")->where("status='1'")->select();
|
|
}
|
|
if($type == 2){
|
|
//下游游
|
|
$companyInfo = M("PromoteCompany","tab_")->field("id,company_belong,company_name,company_type,settlement_contact link_man,contact_phone link_phone")->where("status='1'")->select();
|
|
}
|
|
foreach($companyInfo as $k=>&$v){
|
|
if(isset($v['company_belong'])){
|
|
$v['company_belong'] = getCompanyBlong($v['company_belong']);
|
|
}
|
|
if(isset($v['company_type'])){
|
|
$v['company_type'] = ($v['company_type'] == 1 ?"公司" :'个人');
|
|
}
|
|
if(isset($v['link_phone']) && $v['link_phone']==0){
|
|
$v['link_phone'] = '';
|
|
}
|
|
}
|
|
$this->success($companyInfo,'',true);
|
|
}
|
|
public function menuAuth()
|
|
{
|
|
$addurl = U("addRelation");
|
|
$mentBtn = [
|
|
"addRelation"=>"<a class='butn' href='{$addurl}'>新增推广游戏分成</a>",
|
|
"marketAgree"=>"<a class='butn' id='marketAgree'>市场部审批通过</a>",
|
|
"marketRefuse"=>"<a class='butn' id='marketRefuse' style='background-color: red;'>市场部审核拒绝</a>",
|
|
"adminAgree"=>"<a class='butn' id='adminAgree'>管理员审核通过</a>",
|
|
"adminRefuse"=>"<a class='butn' id='marketRefuse' style='background-color: red;'>管理员审核拒绝</a>"
|
|
];
|
|
$resarr = [];
|
|
foreach ($mentBtn as $k => $v) {
|
|
if(IS_ROOT){
|
|
$resarr[] = $v;
|
|
}else{
|
|
if(in_array($k,$this->OpAuthList)){
|
|
$resarr[] = $v;
|
|
}
|
|
}
|
|
}
|
|
return $resarr;
|
|
}
|
|
public function OpAuth($info)
|
|
{
|
|
$id = $info['id'];
|
|
//原始列表
|
|
$opBtn = [
|
|
"editRelation"=>"<a class='confirm editRelation' data-id='{$id}'>编辑</a>",
|
|
"delRelation"=>"<a class='confirm delRelation' data-id='{$id}' style='color: red;'>删除</a>",
|
|
];
|
|
//操作对应菜单
|
|
|
|
if($info['status'] == 2){
|
|
$optist = [];
|
|
}else{
|
|
$optist = ["editRatio","delRatio"];
|
|
}
|
|
//
|
|
$resarr = [];
|
|
foreach ($optist as $k => $v) {
|
|
if(IS_ROOT){
|
|
$resarr[] = $opBtn[$v];
|
|
}else{
|
|
if(in_array($v,$this->OpAuthList)){
|
|
$resarr[] = $opBtn[$v];
|
|
}
|
|
}
|
|
}
|
|
return $resarr;
|
|
}
|
|
|
|
public function error($data)
|
|
{
|
|
header('Content-Type:application/json; charset=utf-8');
|
|
$data =json_encode(['msg'=>$data,"code"=>4000],JSON_UNESCAPED_UNICODE);
|
|
exit($data);
|
|
}
|
|
|
|
|
|
} |