|
|
|
@ -1786,8 +1786,70 @@ public function releaseSourceFromDetail($mainListId, $mainInfo = null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 没有可转移的共享项目:不修改 useDetailJson,正常释放逻辑释放全部
|
|
|
|
// 没有可转移的共享项目:不修改 useDetailJson,正常释放逻辑释放全部
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// currentCount <= remainingMax,按实际占用量正常释放全部
|
|
|
|
// currentCount <= remainingMax,不释放,将占位合并到新持有者
|
|
|
|
// 不修改 useDetailJson,让正常释放逻辑处理
|
|
|
|
$newHolder = DB::table('s_list')
|
|
|
|
|
|
|
|
->join('s_check_item', 's_list.entrust', '=', 's_check_item.item_name')
|
|
|
|
|
|
|
|
->where('s_list.reg_num', $mainInfo->reg_num)
|
|
|
|
|
|
|
|
->where('s_list.roster_id', $mainInfo->roster_id)
|
|
|
|
|
|
|
|
->where('s_list.id', '!=', $mainListId)
|
|
|
|
|
|
|
|
->where('s_list.list_status', 1)
|
|
|
|
|
|
|
|
->where('s_check_item.is_share_slot', 1)
|
|
|
|
|
|
|
|
->select('s_list.id')
|
|
|
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log::info('[YuYueDebug] else 转移-新持有者查询', [
|
|
|
|
|
|
|
|
'mainListId' => $mainListId,
|
|
|
|
|
|
|
|
'entrust' => $mainInfo->entrust,
|
|
|
|
|
|
|
|
'newHolderId' => $newHolder ? $newHolder->id : 'null',
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($newHolder) {
|
|
|
|
|
|
|
|
// 读取新持有者当前 detail,合并当前项目的占位
|
|
|
|
|
|
|
|
$newHolderJson = DB::table('s_list')->where('id', $newHolder->id)->value('appointment_use_plan_detail');
|
|
|
|
|
|
|
|
$newHolderDetail = json_decode($newHolderJson, true) ?: [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log::info('[YuYueDebug] else 转移-合并前', [
|
|
|
|
|
|
|
|
'newHolderId' => $newHolder->id,
|
|
|
|
|
|
|
|
'newHolderDetail' => $newHolderDetail,
|
|
|
|
|
|
|
|
'cancelDetail' => $useDetails,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($useDetails as $d) {
|
|
|
|
|
|
|
|
$found = false;
|
|
|
|
|
|
|
|
foreach ($newHolderDetail as &$nd) {
|
|
|
|
|
|
|
|
if ($nd['roster_detail_count_id'] == $d['roster_detail_count_id']) {
|
|
|
|
|
|
|
|
$nd['count'] += (int)($d['count'] ?? 0);
|
|
|
|
|
|
|
|
$found = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$found) {
|
|
|
|
|
|
|
|
$newHolderDetail[] = [
|
|
|
|
|
|
|
|
'roster_detail_count_id' => $d['roster_detail_count_id'],
|
|
|
|
|
|
|
|
'count' => (int)($d['count'] ?? 0)
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log::info('[YuYueDebug] else 转移-合并后', [
|
|
|
|
|
|
|
|
'newHolderId' => $newHolder->id,
|
|
|
|
|
|
|
|
'newHolderDetail' => $newHolderDetail,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB::table('s_list')
|
|
|
|
|
|
|
|
->where('id', $newHolder->id)
|
|
|
|
|
|
|
|
->update(['appointment_use_plan_detail' => json_encode($newHolderDetail)]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新后读回确认
|
|
|
|
|
|
|
|
$afterUpdate = DB::table('s_list')->where('id', $newHolder->id)->value('appointment_use_plan_detail');
|
|
|
|
|
|
|
|
Log::info('[YuYueDebug] else 转移-更新后读回', [
|
|
|
|
|
|
|
|
'newHolderId' => $newHolder->id,
|
|
|
|
|
|
|
|
'写入值' => json_encode($newHolderDetail),
|
|
|
|
|
|
|
|
'读回值' => $afterUpdate,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 不修改 useDetailJson,但返回 true 阻止正常释放逻辑
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// remainingMax == 0:正常释放全部
|
|
|
|
// remainingMax == 0:正常释放全部
|
|
|
|
|