v1.0.12: 企业/人员/媒体去删除入口;企业/人员加产品入口;企业详情去产品品类/关联联系人;编辑企业改Tab卡(工商信息/财务信息/资质认证)
This commit is contained in:
+38
-5
@@ -19,7 +19,9 @@ if ($id <= 0) {
|
||||
|
||||
$data = extractFields(COMPANY_FIELDS);
|
||||
unset($data['display_name']); // 显示名称不允许通过编辑接口置空/改名,如需改名请走完整字段
|
||||
if (empty($data)) {
|
||||
$hasFinancials = array_key_exists('financials', $_POST);
|
||||
$hasCertifications = array_key_exists('certifications', $_POST);
|
||||
if (empty($data) && !$hasFinancials && !$hasCertifications) {
|
||||
Response::error('没有需要更新的字段', 400);
|
||||
}
|
||||
|
||||
@@ -32,9 +34,40 @@ if (!$old) {
|
||||
Response::error('企业不存在');
|
||||
}
|
||||
|
||||
[$sets, $params] = buildUpdate($data);
|
||||
$params[] = $id;
|
||||
$pdo->prepare("UPDATE companies SET $sets WHERE id = ?")->execute($params);
|
||||
if (!empty($data)) {
|
||||
[$sets, $params] = buildUpdate($data);
|
||||
$params[] = $id;
|
||||
$pdo->prepare("UPDATE companies SET $sets WHERE id = ?")->execute($params);
|
||||
}
|
||||
|
||||
logCurrent('update', 'company', 'companies', $id, ['before' => $old, 'after' => $data]);
|
||||
// 财务信息 / 资质认证(可选,整表替换)
|
||||
if ($hasFinancials || $hasCertifications) {
|
||||
$pdo->beginTransaction();
|
||||
try {
|
||||
if ($hasFinancials) {
|
||||
$financials = json_decode($_POST['financials'], true);
|
||||
if (!is_array($financials)) {
|
||||
$pdo->rollBack();
|
||||
Response::error('财务信息格式错误', 400);
|
||||
}
|
||||
saveCompanyFinancials($pdo, $id, $financials);
|
||||
}
|
||||
if ($hasCertifications) {
|
||||
$certs = json_decode($_POST['certifications'], true);
|
||||
if (!is_array($certs)) {
|
||||
$pdo->rollBack();
|
||||
Response::error('资质认证格式错误', 400);
|
||||
}
|
||||
saveCompanyCertifications($pdo, $id, $certs);
|
||||
}
|
||||
$pdo->commit();
|
||||
} catch (Exception $e) {
|
||||
$pdo->rollBack();
|
||||
Response::error('关联信息保存失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
logCurrent('update', 'company', 'companies', $id, ['before' => $old, 'after' => $data]);
|
||||
}
|
||||
Response::success(null, '更新成功');
|
||||
|
||||
Reference in New Issue
Block a user