旧数据脚本

master
chenzhi 4 years ago
parent 94cbae1924
commit 5894324ca8

@ -10,12 +10,45 @@ namespace Admin\Controller;
class OldCountController extends \Think\Controller
{
/**
* 公会关系迁移
* company_relation
* 公会关系及游戏迁移
* 1. 迁移 公会company_relation到公司
* 2. 游戏 game_ids
* 3. 同步公司develop_type到公会
*/
public function changeOldCompanyRelation()
{
//默认设为
$Promote = M("Promote","tab_");
$PromoteCompany = M("promote_company","tab_");
$p_res = $Promote->field("id,account,game_ids,company_relation,company_id")->where("level = 1")->group("company_id")->select();
foreach ($p_res as $k => $v) {
if($v['id'] < 1) continue;
$savedata =[ "id"=>$v['company_id'] ];
if($v['company_relation'] == 1){
$savedata['develop_type'] = 3;
}else{
$savedata['develop_type'] = 2;
}
$savedata['game_ids'] = $this->changeGameidToRelationGameid($v['game_ids']);
$PromoteCompany->save($savedata);
$p_data = [
"company_relation"=>$savedata['develop_type']
];
$Promote->where("company_id = {$v['company_id']}")->save($p_data);
}
echo "changeOldCompanyRelation success";
}
protected function changeGameidToRelationGameid($ids,$type=false)
{
$rid = M('game', 'tab_')->field('relation_game_id')->where(["id"=>["in",$ids]])->group("relation_game_id")->select();
if($type){
return array_column($rid,'relation_game_id');
}else{
return implode(",",array_column($rid,'relation_game_id'));
}
}
/**

Loading…
Cancel
Save