数据迁移

master
chenzhi 4 years ago
parent 26ccc9c450
commit bffc9a32f1

@ -13,13 +13,34 @@ class OldCountController extends \Think\Controller
* 新的游戏比例后的数据迁移
* 重复执行将会叠加数据,请勿重复执行
*/
// public function PromoteToCompanyRatioInit()
// {
// //获取旧数据
// $oldres = M("promote_game_ratio","tab_")->field("promote_id,relation_game_id,ratio,turnover_ratio,begin_time,end_time")->group("promote_id,relation_game_id")->select();
// dd($oldres);
// }
public function PromoteToCompanyRatioInit()
{
//获取旧数据
$oldres = M("promote_game_ratio","tab_")->field("promote_id,relation_game_id,ratio,turnover_ratio,begin_time,end_time")->group("promote_id,relation_game_id")->select();
$adddata = [];
$CompanyGameRatio = M("company_game_ratio","tab_");
foreach ($oldres as $k => &$v) {
$comoany_id = $this->promoteIdToCompanyId($v['promote_id']);
unset($v['promote_id']);
$v['company_id'] = $comoany_id ;
$adddata[$comoany_id] = $v;
}
foreach($adddata as $k => &$v){
$map = [
"company_id"=>$v['company_id'],
"relation_game_id"=>$v['relation_game_id']
];
$cres = $CompanyGameRatio->where($map)->find();
if(empty($cres)){
$CompanyGameRatio->add($v);
}
}
echo "PromoteToCompanyRatioInit success";
}
protected function promoteIdToCompanyId($promote_id)
{
return M("promote","tab_")->field("company_id")->where("id='{$promote_id}'")->find()['company_id'];
}
/**
* 财务分类汇总统计旧数据聚合

Loading…
Cancel
Save