Adjust user appraisal order flow

This commit is contained in:
wushumin
2026-05-21 17:56:35 +08:00
parent cfd21b462a
commit d0c4332468
8 changed files with 163 additions and 158 deletions

View File

@@ -103,6 +103,9 @@ class AppraisalController
}
$product = Db::name('appraisal_draft_products')->where('draft_id', $draftId)->find();
if ($product) {
$product['brand_name'] = $this->resolveBrandName($product);
}
$extra = Db::name('appraisal_draft_extras')->where('draft_id', $draftId)->find();
return api_success([
@@ -140,10 +143,16 @@ class AppraisalController
]);
if ($productInfo) {
$brandId = !empty($productInfo['brand_id']) ? (int)$productInfo['brand_id'] : null;
$brandName = $this->limitText(trim((string)($productInfo['brand_name'] ?? '')), 128);
if ($brandName === '' && $brandId) {
$brandName = $this->lookupName('catalog_brands', 'name', $brandId);
}
$payload = [
'draft_id' => $draftId,
'category_id' => $productInfo['category_id'] ?? null,
'brand_id' => $productInfo['brand_id'] ?? null,
'brand_id' => $brandId,
'brand_name' => $brandName,
'color' => $productInfo['color'] ?? '',
'size_spec' => $productInfo['size_spec'] ?? '',
'serial_no' => $productInfo['serial_no'] ?? '',
@@ -305,7 +314,7 @@ class AppraisalController
'product_summary' => [
'product_name' => $this->resolveProductName($product),
'category_name' => $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null),
'brand_name' => $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null),
'brand_name' => $this->resolveBrandName($product),
'price' => $extra['purchase_price'] ?? 0,
],
'upload_summary' => [
@@ -398,8 +407,8 @@ class AppraisalController
'order_id' => $orderId,
'category_id' => $product['category_id'] ?? null,
'category_name' => $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null),
'brand_id' => $product['brand_id'] ?? null,
'brand_name' => $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null),
'brand_id' => !empty($product['brand_id']) ? (int)$product['brand_id'] : null,
'brand_name' => $this->resolveBrandName($product),
'color' => $product['color'] ?? '',
'size_spec' => $product['size_spec'] ?? '',
'serial_no' => $product['serial_no'] ?? '',
@@ -562,13 +571,27 @@ class AppraisalController
return (string)Db::name($table)->where('id', $id)->value($field);
}
private function resolveBrandName(?array $product): string
{
if (!$product) {
return '';
}
$brandName = trim((string)($product['brand_name'] ?? ''));
if ($brandName !== '') {
return $brandName;
}
return $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null);
}
private function resolveProductName(?array $product): string
{
if (!$product) {
return '';
}
$categoryName = $this->lookupName('catalog_categories', 'name', $product['category_id'] ?? null);
$brandName = $this->lookupName('catalog_brands', 'name', $product['brand_id'] ?? null);
$brandName = $this->resolveBrandName($product);
$fallbackName = trim($categoryName . ' ' . $brandName);
if ($fallbackName !== '') {
return $fallbackName;
@@ -576,6 +599,14 @@ class AppraisalController
return '';
}
private function limitText(string $value, int $maxLength): string
{
if (function_exists('mb_substr')) {
return mb_substr($value, 0, $maxLength, 'UTF-8');
}
return substr($value, 0, $maxLength);
}
private function serviceConfig(string $serviceProvider): array
{
$configs = [