"管理员拒绝",
"-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"=>"新增推广游戏分成",
"marketAgree"=>"市场部审批通过",
"marketRefuse"=>"市场部审核拒绝",
"adminAgree"=>"管理员审核通过",
"adminRefuse"=>"管理员审核拒绝"
];
$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"=>"编辑",
"delRelation"=>"删除",
];
//操作对应菜单
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);
}
}