feat: update appraisal return address and test packaging assets
This commit is contained in:
@@ -18,6 +18,7 @@ class OrdersController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$keyword = trim((string)$request->input('keyword', ''));
|
||||
$externalOrderNo = trim((string)$request->input('external_order_no', ''));
|
||||
$trackingNo = trim((string)$request->input('tracking_no', ''));
|
||||
$userMobile = trim((string)$request->input('user_mobile', ''));
|
||||
$status = trim((string)$request->input('status', ''));
|
||||
@@ -30,10 +31,12 @@ class OrdersController
|
||||
$query = Db::name('orders')
|
||||
->alias('o')
|
||||
->leftJoin('order_products p', 'p.order_id = o.id')
|
||||
->leftJoin('enterprise_customer_order_refs ecor', 'ecor.order_id = o.id')
|
||||
->field([
|
||||
'o.id',
|
||||
'o.order_no',
|
||||
'o.appraisal_no',
|
||||
'ecor.external_order_no',
|
||||
'o.service_provider',
|
||||
'o.order_status',
|
||||
'o.display_status',
|
||||
@@ -64,6 +67,12 @@ class OrdersController
|
||||
});
|
||||
}
|
||||
|
||||
if ($externalOrderNo !== '') {
|
||||
$query->whereRaw('ecor.external_order_no LIKE :external_order_no', [
|
||||
'external_order_no' => "%{$externalOrderNo}%",
|
||||
]);
|
||||
}
|
||||
|
||||
if ($trackingNo !== '') {
|
||||
$query->whereRaw(
|
||||
"EXISTS (SELECT 1 FROM order_logistics ol WHERE ol.order_id = o.id AND ol.logistics_type IN ('send_to_center', 'return_to_user') AND ol.tracking_no LIKE :tracking_no)",
|
||||
@@ -155,6 +164,7 @@ class OrdersController
|
||||
'id' => $orderId,
|
||||
'order_no' => $item['order_no'],
|
||||
'appraisal_no' => $item['appraisal_no'],
|
||||
'external_order_no' => (string)($item['external_order_no'] ?? ''),
|
||||
'product_name' => $item['product_name'] ?: '待完善物品信息',
|
||||
'category_name' => $item['category_name'] ?: '',
|
||||
'brand_name' => $item['brand_name'] ?: '',
|
||||
@@ -255,6 +265,7 @@ class OrdersController
|
||||
->where('order_id', $id)
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$enterpriseOrderRef = Db::name('enterprise_customer_order_refs')->where('order_id', $id)->find();
|
||||
$timeline = Db::name('order_timelines')
|
||||
->where('order_id', $id)
|
||||
->order('occurred_at', 'asc')
|
||||
@@ -343,6 +354,7 @@ class OrdersController
|
||||
'id' => (int)$order['id'],
|
||||
'order_no' => $order['order_no'],
|
||||
'appraisal_no' => $order['appraisal_no'],
|
||||
'external_order_no' => (string)($enterpriseOrderRef['external_order_no'] ?? ''),
|
||||
'service_provider' => $order['service_provider'],
|
||||
'service_provider_text' => $order['service_provider'] === 'zhongjian' ? '中检鉴定' : '实物鉴定',
|
||||
'price_package_name' => (string)($order['price_package_name'] ?? ''),
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace app\controller\app;
|
||||
|
||||
use app\support\ContentService;
|
||||
use app\support\FileStorageService;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
|
||||
@@ -9,11 +11,19 @@ class CatalogController
|
||||
{
|
||||
public function categories(Request $request)
|
||||
{
|
||||
$categoryVisuals = $this->categoryVisualMap($request);
|
||||
$list = Db::name('catalog_categories')
|
||||
->field(['id AS category_id', 'name AS category_name', 'code AS category_code'])
|
||||
->where('is_enabled', 1)
|
||||
->order('sort_order', 'asc')
|
||||
->select()
|
||||
->map(function ($item) use ($categoryVisuals) {
|
||||
$codeKey = $this->categoryMatchKey((string)$item['category_code']);
|
||||
$nameKey = $this->categoryMatchKey((string)$item['category_name']);
|
||||
$item['image_url'] = $categoryVisuals['code:' . $codeKey] ?? $categoryVisuals['name:' . $nameKey] ?? '';
|
||||
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
|
||||
return api_success(['list' => $list]);
|
||||
@@ -39,4 +49,45 @@ class CatalogController
|
||||
]);
|
||||
}
|
||||
|
||||
private function categoryVisualMap(Request $request): array
|
||||
{
|
||||
$items = (new ContentService())->getHomeConfig()['category_visuals'] ?? [];
|
||||
if (!is_array($items)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$storage = new FileStorageService();
|
||||
foreach ($items as $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$imageUrl = trim((string)($item['image_url'] ?? ''));
|
||||
if ($imageUrl === '') {
|
||||
continue;
|
||||
}
|
||||
$imageUrl = $storage->normalizeUrl($imageUrl, $request);
|
||||
|
||||
$categoryCode = $this->categoryMatchKey((string)($item['category_code'] ?? ''));
|
||||
if ($categoryCode !== '') {
|
||||
$map['code:' . $categoryCode] = $imageUrl;
|
||||
}
|
||||
|
||||
$categoryName = $this->categoryMatchKey((string)($item['category_name'] ?? ''));
|
||||
if ($categoryName !== '') {
|
||||
$map['name:' . $categoryName] = $imageUrl;
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
private function categoryMatchKey(string $value): string
|
||||
{
|
||||
$value = trim($value);
|
||||
$normalized = preg_replace('/[\s\p{Cf}]+/u', '', $value);
|
||||
|
||||
return strtolower($normalized ?? $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,34 @@ class OrdersController
|
||||
return api_success($result, '运单已提交');
|
||||
}
|
||||
|
||||
public function saveReturnAddress(Request $request)
|
||||
{
|
||||
try {
|
||||
$auth = (new EnterpriseOpenApiAuthService())->authenticate($request);
|
||||
} catch (\Throwable $e) {
|
||||
return api_error($e->getMessage(), 401);
|
||||
}
|
||||
|
||||
$payload = json_decode($request->rawBody(), true);
|
||||
if (!is_array($payload)) {
|
||||
return api_error('请求体必须是合法 JSON 对象', 422);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = (new EnterpriseOrderService())->saveReturnAddress($auth['customer'], $payload);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return api_error($e->getMessage(), 422);
|
||||
} catch (\RuntimeException $e) {
|
||||
return api_error($e->getMessage(), 404);
|
||||
} catch (\Throwable $e) {
|
||||
return api_error('寄回地址保存失败', 500, [
|
||||
'detail' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
return api_success($result, '寄回地址已保存');
|
||||
}
|
||||
|
||||
public function servicePricePackages(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user