@ -2,6 +2,7 @@
namespace Admin\Controller;
use Base\Tool\AggregateClient;
use mysql_xdevapi\Exception;
use User\Api\UserApi as UserApi;
use OSS\OssClient;
@ -18,6 +19,8 @@ class PromoteCompanyController extends ThinkController
{
private $modelName = 'PromoteCompany';
public $ratio = [];
public $aggregatePackageName = [];
public function _initialize()
{
$this->admininfo = $_SESSION['onethink_admin']['user_auth'];
@ -30,6 +33,7 @@ class PromoteCompanyController extends ThinkController
$is_export= false;
if (isset($_REQUEST['export']) & & $_REQUEST['export']==1){
$is_export = true;
$this->getAggregatePackage();
}
$map = [];
$promotemap=[];
@ -42,6 +46,7 @@ class PromoteCompanyController extends ThinkController
$c_id = throwPromoteIdToCompanyId($pro_id);
$map["_string"]="id in ({$c_id})";
}
//市场部权限end
if($company_name) $map['tab_promote_company.company_name'] = array('like',"%{$company_name}%");
@ -117,12 +122,24 @@ class PromoteCompanyController extends ThinkController
foreach($companyres as $k=>& $v){
$deposit = $depositList[$v['id']] ?? null;
$tmpr = D("CompanyRelation")->getCompanyRelation(2,$v['id']);
$v["settlement_type"] = $tmpr['settlement_type'];
$v["deposit_pay_type"] = $deposit ? $payTypes[$deposit['pay_type']] : '--';
$v["collection"] = $tmpr['collection'];
$v["invoice_type"] = $tmpr['invoice_type'];
$v["invoice_content"] = $tmpr['invoice_content'];
if ($tmpr['is_payment']==1) {
$v['bank_address'] = $v['ali_user'];
$v['bank_card'] = $v['ali_account'];
$v['bank_name'] = '--';
}
$v['is_payment'] = ($tmpr['is_payment']==1) ? '是' : '否';
$v["company_belong"] = getCompanyBlong($v["company_belong"]);
$v["develop_type"] = getCompanyRelation($v["develop_type"]);
$v['company_type'] = $v['company_type'] == 2 ? '个人' : '公司';
@ -169,7 +186,7 @@ class PromoteCompanyController extends ThinkController
$promotemap['p.company_id']=["in",$companyallids];
$promotemap['p.level']=1;
$promotecount = M("Promote","tab_")->alias('p')->where($promotemap)->count();
// dd($companyres);
// dd($companyres);
$this->assign('listData', $companyres);
$this->assign('count', $count);
$this->assign('promotecount', $promotecount);
@ -200,7 +217,7 @@ class PromoteCompanyController extends ThinkController
$this->meta_title = '下游推广公司';
$this->display();
}
public function index()
{
$page = intval(I('get.p', 0));
@ -393,7 +410,7 @@ class PromoteCompanyController extends ThinkController
$save = I('post.');//前端已经验证
$save['promotes'] = json_decode($save['promotes'], true);
$this->checkData($save);
$presidentDepositService = new PresidentDepositService();
@ -407,7 +424,7 @@ class PromoteCompanyController extends ThinkController
$promoteCompanyService->checkCompanyRelation($save['relation'] ?? []);
} catch (\Exception $e) {
$this->ajaxReturn(array(
'status' => 0,
'status' => 0,
'info' => $e->getMessage()
));
}
@ -506,7 +523,7 @@ class PromoteCompanyController extends ThinkController
$relation['self_company_id'] = $relation['first_company_id'];
}
}
$deposit = M('president_deposit', 'tab_')->where(['company_id' => $data['id']])->find();
$this->assign('selfCompanies', $selfCompanies);
@ -612,11 +629,11 @@ class PromoteCompanyController extends ThinkController
$promoteCompanyService->checkCompanyRelation($save['relation'] ?? []);
} catch (\Exception $e) {
$this->ajaxReturn(array(
'status' => 0,
'status' => 0,
'info' => $e->getMessage()
));
}
$save['turnover_ratio'] = $this->setTurnoverRatio($save);
$res = D("PromoteCompanyVerify")->edit_db($save);
if ($res) {
@ -685,7 +702,7 @@ class PromoteCompanyController extends ThinkController
$relationWhere = '(first_company_type=2 and first_company_id=' . $data['id'] .
') or (second_company_type=2 and second_company_id=' . $data['id'] . ')';
$relation = M('company_relation', 'tab_')->where($relationWhere)->find();
if ($relation) {
if ($relation['first_company_type'] == 2 & & $relation['first_company_id'] == $data['id']) {
$relation['collaborate_way'] = 1;
@ -1101,7 +1118,7 @@ class PromoteCompanyController extends ThinkController
$this->error('已添加过此推广公司,请联系管理尽快审核');
}
}
// if(!empty(I("contact_phone")) & & !checkPhone(I('contact_phone'))) {
// $this->error('联系电话格式不正确');
@ -1460,10 +1477,12 @@ class PromoteCompanyController extends ThinkController
}
//获取游戏基础信息
protected function getGameInfo($game_ids){
$gameinfo = [];
$dbres = M("Game","tab_")->where("relation_game_id in ($game_ids)")->field("relation_game_id,relation_game_name,game_type_name,original_package_name")->group("relation_game_id")->select();
$dbres = M("Game","tab_")->where("relation_game_id in ($game_ids)")->field("relation_game_id,relation_game_name,game_type_name,original_package_name,unique_code ")->group("relation_game_id")->select();
foreach($dbres as $k=>$v){
$v['aggregate_gamename'] = $this->aggregatePackageName[$v['unique_code']];
$gameinfo[$v['relation_game_id']] = $v;
}
return $gameinfo;
@ -1476,6 +1495,19 @@ class PromoteCompanyController extends ThinkController
}else{
return true;
}
}
}
protected function getAggregatePackage() {
$client = new AggregateClient();
$result = $client->api('aggregate-gamename', []);
$this->aggregatePackageName = $result['data'];
}
}