chore: release updated anxinyan version
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\support\ExpressCompanyService;
|
||||
use support\Request;
|
||||
|
||||
class ExpressCompaniesController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$enabledOnly = (int)$request->input('enabled_only', 0) === 1;
|
||||
|
||||
return api_success([
|
||||
'list' => $this->service()->list($enabledOnly),
|
||||
'default_company' => $this->service()->defaultName(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function save(Request $request)
|
||||
{
|
||||
$id = (int)$request->input('id', 0);
|
||||
|
||||
try {
|
||||
$companyId = $this->service()->save([
|
||||
'company_name' => $request->input('company_name', ''),
|
||||
'company_code' => $request->input('company_code', ''),
|
||||
'status' => $request->input('status', 'enabled'),
|
||||
'is_default' => $request->input('is_default', false),
|
||||
'sort_order' => $request->input('sort_order', 0),
|
||||
'remark' => $request->input('remark', ''),
|
||||
], $id);
|
||||
} catch (\RuntimeException $e) {
|
||||
return api_error($e->getMessage(), 422);
|
||||
} catch (\Throwable $e) {
|
||||
return api_error('快递公司保存失败', 500, [
|
||||
'detail' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
return api_success([
|
||||
'id' => $companyId,
|
||||
], $id > 0 ? '快递公司已更新' : '快递公司已创建');
|
||||
}
|
||||
|
||||
private function service(): ExpressCompanyService
|
||||
{
|
||||
return new ExpressCompanyService();
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ class ReportsController
|
||||
'r.zhongjian_report_no',
|
||||
'r.report_entry_admin_name',
|
||||
'r.report_entered_at',
|
||||
'r.trace_info_visible',
|
||||
'o.order_no',
|
||||
'p.product_name',
|
||||
'p.category_name',
|
||||
@@ -83,6 +84,7 @@ class ReportsController
|
||||
'zhongjian_report_no' => (string)($item['zhongjian_report_no'] ?? ''),
|
||||
'report_entry_admin_name' => (string)($item['report_entry_admin_name'] ?? ''),
|
||||
'report_entered_at' => (string)($item['report_entered_at'] ?? ''),
|
||||
'trace_info_visible' => (int)($item['trace_info_visible'] ?? 0) === 1,
|
||||
'product_name' => $item['product_name'] ?: (string)($productSnapshot['product_name'] ?? ''),
|
||||
'category_name' => $item['category_name'] ?: (string)($productSnapshot['category_name'] ?? ''),
|
||||
'brand_name' => $item['brand_name'] ?: (string)($productSnapshot['brand_name'] ?? ''),
|
||||
@@ -169,6 +171,7 @@ class ReportsController
|
||||
'report_entry_admin_id' => (int)($report['report_entry_admin_id'] ?? 0),
|
||||
'report_entry_admin_name' => (string)($report['report_entry_admin_name'] ?? ''),
|
||||
'report_entered_at' => (string)($report['report_entered_at'] ?? ''),
|
||||
'trace_info_visible' => (int)($report['trace_info_visible'] ?? 0) === 1,
|
||||
],
|
||||
'product_info' => $productSnapshot,
|
||||
'result_info' => $resultSnapshot,
|
||||
@@ -188,6 +191,32 @@ class ReportsController
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateTraceVisibility(Request $request)
|
||||
{
|
||||
$id = (int)$request->input('id', 0);
|
||||
if (!$id) {
|
||||
return api_error('报告 ID 不能为空', 422);
|
||||
}
|
||||
|
||||
$report = Db::name('reports')->where('id', $id)->find();
|
||||
if (!$report) {
|
||||
return api_error('报告不存在', 404);
|
||||
}
|
||||
|
||||
$visible = $this->boolInput($request->input('trace_info_visible', false));
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
Db::name('reports')->where('id', $id)->update([
|
||||
'trace_info_visible' => $visible ? 1 : 0,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
return api_success([
|
||||
'id' => $id,
|
||||
'trace_info_visible' => $visible,
|
||||
], $visible ? '追溯信息已设为显示' : '追溯信息已隐藏');
|
||||
}
|
||||
|
||||
public function saveInspection(Request $request)
|
||||
{
|
||||
$id = (int)$request->input('id', 0);
|
||||
@@ -540,6 +569,18 @@ class ReportsController
|
||||
return [];
|
||||
}
|
||||
|
||||
private function boolInput(mixed $value): bool
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_numeric($value)) {
|
||||
return (int)$value === 1;
|
||||
}
|
||||
|
||||
return in_array(strtolower(trim((string)$value)), ['1', 'true', 'yes', 'on'], true);
|
||||
}
|
||||
|
||||
private function loadReportContentMap(array $reportIds): array
|
||||
{
|
||||
if (!$reportIds) {
|
||||
|
||||
Reference in New Issue
Block a user