|
|
@ -708,21 +708,31 @@ class ContentController extends BaseController |
|
|
// category_map(源语言栏目ID) → 目标语言栏目ID
|
|
|
// category_map(源语言栏目ID) → 目标语言栏目ID
|
|
|
$categoryMap = array_combine($categoryMapData, array_column($categories,'id')); |
|
|
$categoryMap = array_combine($categoryMapData, array_column($categories,'id')); |
|
|
|
|
|
|
|
|
// 清理目标语言已有的关联数据,防止重复插入
|
|
|
|
|
|
|
|
|
// 查找模型
|
|
|
|
|
|
$Module = new Module(); |
|
|
|
|
|
$modules = $Module->getAllCustomArrayData(['seller_id'=>$this->admin['seller_id']],'id asc','id,table')['data']; |
|
|
|
|
|
$SubContent = new SubContent(); |
|
|
|
|
|
|
|
|
|
|
|
// 清理目标语言已有的数据,防止重复插入
|
|
|
$existingTargetSubIds = Db::name('sub_content') |
|
|
$existingTargetSubIds = Db::name('sub_content') |
|
|
->where('lang', $param['to']) |
|
|
->where('lang', $param['to']) |
|
|
->where('seller_id', $this->admin['seller_id']) |
|
|
->where('seller_id', $this->admin['seller_id']) |
|
|
->column('id'); |
|
|
->column('id'); |
|
|
if (!empty($existingTargetSubIds)) { |
|
|
if (!empty($existingTargetSubIds)) { |
|
|
|
|
|
// 清理关联表
|
|
|
Db::name('category_sub_content')->where('sub_content_id', 'in', $existingTargetSubIds)->delete(); |
|
|
Db::name('category_sub_content')->where('sub_content_id', 'in', $existingTargetSubIds)->delete(); |
|
|
Db::name('tag_sub_content')->where('sub_content_id', 'in', $existingTargetSubIds)->delete(); |
|
|
Db::name('tag_sub_content')->where('sub_content_id', 'in', $existingTargetSubIds)->delete(); |
|
|
Db::name('inner_chart_sub_content')->where('sub_content_id', 'in', $existingTargetSubIds)->delete(); |
|
|
Db::name('inner_chart_sub_content')->where('sub_content_id', 'in', $existingTargetSubIds)->delete(); |
|
|
|
|
|
// 清理各模块主表
|
|
|
|
|
|
foreach($modules as $m){ |
|
|
|
|
|
Db::name($m['table'])->where([['sub_id','in',$existingTargetSubIds],['lang','=',$param['to']]])->delete(); |
|
|
|
|
|
} |
|
|
|
|
|
// 清理副表
|
|
|
|
|
|
Db::name('sub_content')->where('id', 'in', $existingTargetSubIds)->delete(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 查找模型
|
|
|
|
|
|
$Module = new Module(); |
|
|
|
|
|
$modules = $Module->getAllCustomArrayData(['seller_id'=>$this->admin['seller_id']],'id asc','id,table')['data']; |
|
|
|
|
|
$SubContent = new SubContent(); |
|
|
|
|
|
|
|
|
// 清理目标语言导航数据
|
|
|
|
|
|
Db::name('nav')->where('lang', $param['to'])->where('seller_id', $this->admin['seller_id'])->delete(); |
|
|
|
|
|
Db::name('nav_cate')->where('lang', $param['to'])->where('seller_id', $this->admin['seller_id'])->delete(); |
|
|
|
|
|
|
|
|
// 源语言sub_content_id → 目标语言sub_content_id 的映射
|
|
|
// 源语言sub_content_id → 目标语言sub_content_id 的映射
|
|
|
$subIdMap = []; |
|
|
$subIdMap = []; |
|
|
@ -739,11 +749,6 @@ class ContentController extends BaseController |
|
|
$contentIds = array_column($content,'id'); |
|
|
$contentIds = array_column($content,'id'); |
|
|
// 源语言主表内容
|
|
|
// 源语言主表内容
|
|
|
$mainContent = Db::name($module['table'])->where([['sub_id','in',$contentIds]])->select()->toArray(); |
|
|
$mainContent = Db::name($module['table'])->where([['sub_id','in',$contentIds]])->select()->toArray(); |
|
|
// 源语言主表 sub_id → 主表记录 的映射
|
|
|
|
|
|
$mainContentBySubId = []; |
|
|
|
|
|
foreach($mainContent as $mc){ |
|
|
|
|
|
$mainContentBySubId[$mc['sub_id']] = $mc; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ========== 逐条插入副表(sub_content),获取实际新ID ==========
|
|
|
// ========== 逐条插入副表(sub_content),获取实际新ID ==========
|
|
|
foreach($content as $item){ |
|
|
foreach($content as $item){ |
|
|
|