chore: prepare release build
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\support\AppraisalEvidenceService;
|
||||
use app\support\MessageDispatcher;
|
||||
use app\support\EnterpriseWebhookService;
|
||||
use app\support\WarehouseService;
|
||||
@@ -10,6 +11,8 @@ use support\think\Db;
|
||||
|
||||
class OrdersController
|
||||
{
|
||||
private const MANUAL_ENTRY_SOURCE = 'manual_entry';
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$keyword = trim((string)$request->input('keyword', ''));
|
||||
@@ -56,6 +59,7 @@ class OrdersController
|
||||
|
||||
$warehouseStatusFilters = [
|
||||
'warehouse_active',
|
||||
'warehouse_pending_inbound',
|
||||
'warehouse_in_transit',
|
||||
'warehouse_received',
|
||||
'warehouse_pending_return',
|
||||
@@ -77,6 +81,9 @@ class OrdersController
|
||||
];
|
||||
if ($status === 'warehouse_in_transit') {
|
||||
$query->where('o.order_status', 'pending_shipping');
|
||||
} elseif ($status === 'warehouse_pending_inbound') {
|
||||
$query->where('o.order_status', 'pending_shipping')
|
||||
->where('o.source_channel', self::MANUAL_ENTRY_SOURCE);
|
||||
} elseif ($status === 'warehouse_received') {
|
||||
$query->whereIn('o.order_status', array_values(array_diff($warehouseActiveStatuses, ['pending_shipping', 'report_published'])));
|
||||
} elseif ($status === 'warehouse_pending_return') {
|
||||
@@ -99,8 +106,9 @@ class OrdersController
|
||||
$orderIds = array_map('intval', array_column($rows, 'id'));
|
||||
$sendTrackingMap = $this->latestLogisticsMap($orderIds, 'send_to_center');
|
||||
$returnTrackingMap = $this->latestLogisticsMap($orderIds, 'return_to_user');
|
||||
$transferFlowMap = $this->latestTransferFlowMap($orderIds);
|
||||
|
||||
$list = array_map(function (array $item) use ($sendTrackingMap, $returnTrackingMap) {
|
||||
$list = array_map(function (array $item) use ($sendTrackingMap, $returnTrackingMap, $transferFlowMap) {
|
||||
$orderId = (int)$item['id'];
|
||||
$sendTrackingNo = $sendTrackingMap[$orderId]['tracking_no'] ?? '';
|
||||
$sendTrackingStatus = $sendTrackingMap[$orderId]['tracking_status'] ?? '';
|
||||
@@ -108,7 +116,8 @@ class OrdersController
|
||||
(string)$item['order_status'],
|
||||
$sendTrackingNo,
|
||||
$sendTrackingStatus,
|
||||
(string)($item['display_status'] ?? '')
|
||||
(string)($item['display_status'] ?? ''),
|
||||
(string)($item['source_channel'] ?? '')
|
||||
);
|
||||
|
||||
return [
|
||||
@@ -130,6 +139,7 @@ class OrdersController
|
||||
$returnTrackingMap[$orderId]['tracking_no'] ?? '',
|
||||
$returnTrackingMap[$orderId]['tracking_status'] ?? '',
|
||||
),
|
||||
'internal_tag_no' => $transferFlowMap[$orderId]['internal_tag_no'] ?? '',
|
||||
'warehouse_bucket' => $warehouseBucket,
|
||||
'warehouse_bucket_text' => $this->warehouseOrderBucketText($warehouseBucket),
|
||||
'estimated_finish_time' => $item['estimated_finish_time'],
|
||||
@@ -154,6 +164,7 @@ class OrdersController
|
||||
$list = array_values(array_filter($list, function (array $item) use ($status) {
|
||||
if ($status === 'warehouse_active') {
|
||||
return in_array($item['warehouse_bucket'], [
|
||||
'warehouse_pending_inbound',
|
||||
'warehouse_in_transit',
|
||||
'warehouse_received',
|
||||
'warehouse_pending_return',
|
||||
@@ -206,6 +217,10 @@ class OrdersController
|
||||
->where('logistics_type', 'return_to_user')
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$transferFlow = Db::name('order_transfer_flows')
|
||||
->where('order_id', $id)
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$timeline = Db::name('order_timelines')
|
||||
->where('order_id', $id)
|
||||
->order('occurred_at', 'asc')
|
||||
@@ -268,6 +283,7 @@ class OrdersController
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
$inboundAttachments = $this->inboundAttachments($id, $request);
|
||||
$returnLogisticsNodes = [];
|
||||
if ($returnLogistics) {
|
||||
$returnLogisticsNodes = Db::name('order_logistics_nodes')
|
||||
@@ -352,6 +368,9 @@ class OrdersController
|
||||
)),
|
||||
] : null,
|
||||
'timeline' => $timeline,
|
||||
'transfer_flow' => $transferFlow ? [
|
||||
'internal_tag_no' => (string)($transferFlow['internal_tag_no'] ?? ''),
|
||||
] : null,
|
||||
'logistics_info' => $sendLogistics ? [
|
||||
'express_company' => $sendLogistics['express_company'],
|
||||
'tracking_no' => $sendLogistics['tracking_no'],
|
||||
@@ -377,6 +396,7 @@ class OrdersController
|
||||
'node_location' => $item['node_location'],
|
||||
], $logisticsNodes),
|
||||
] : null,
|
||||
'inbound_attachments' => $inboundAttachments,
|
||||
'return_logistics' => $returnLogistics ? [
|
||||
'express_company' => $returnLogistics['express_company'],
|
||||
'tracking_no' => $returnLogistics['tracking_no'],
|
||||
@@ -907,6 +927,440 @@ class OrdersController
|
||||
return api_success(['id' => $id], '已标记用户签收');
|
||||
}
|
||||
|
||||
public function createManualOrder(Request $request)
|
||||
{
|
||||
$serviceProvider = $this->normalizeServiceProvider((string)$request->input('service_provider', 'anxinyan'));
|
||||
$productInput = $this->requestArray($request, 'product_info');
|
||||
$extraInput = $this->requestArray($request, 'extra_info');
|
||||
$returnAddressInput = $this->requestArray($request, 'return_address');
|
||||
$materialsInput = $request->input('materials', []);
|
||||
$materials = is_array($materialsInput) ? $materialsInput : [];
|
||||
|
||||
$categoryId = (int)($productInput['category_id'] ?? 0);
|
||||
$brandId = (int)($productInput['brand_id'] ?? 0);
|
||||
$productName = trim((string)($productInput['product_name'] ?? ''));
|
||||
$consignee = trim((string)($returnAddressInput['consignee'] ?? ''));
|
||||
$mobile = trim((string)($returnAddressInput['mobile'] ?? ''));
|
||||
$province = trim((string)($returnAddressInput['province'] ?? ''));
|
||||
$city = trim((string)($returnAddressInput['city'] ?? ''));
|
||||
$district = trim((string)($returnAddressInput['district'] ?? ''));
|
||||
$detailAddress = trim((string)($returnAddressInput['detail_address'] ?? ''));
|
||||
|
||||
if ($serviceProvider === '') {
|
||||
return api_error('服务类型不正确', 422);
|
||||
}
|
||||
if ($categoryId <= 0 || $brandId <= 0 || $productName === '') {
|
||||
return api_error('请完整填写品类、品牌和商品名称', 422);
|
||||
}
|
||||
if ($consignee === '' || $mobile === '' || $province === '' || $city === '' || $district === '' || $detailAddress === '') {
|
||||
return api_error('请完整填写寄回收件信息', 422);
|
||||
}
|
||||
|
||||
$category = Db::name('catalog_categories')->where('id', $categoryId)->find();
|
||||
if (!$category) {
|
||||
return api_error('品类不存在', 422);
|
||||
}
|
||||
$brand = Db::name('catalog_brands')->where('id', $brandId)->find();
|
||||
if (!$brand) {
|
||||
return api_error('品牌不存在', 422);
|
||||
}
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$serviceConfig = $this->serviceConfig($serviceProvider);
|
||||
$orderNo = $this->generateOrderNo();
|
||||
$appraisalNo = $this->generateAppraisalNo();
|
||||
$estimated = date('Y-m-d H:i:s', strtotime(sprintf('+%d hours', (int)$serviceConfig['sla_hours'])));
|
||||
$operatorId = (int)$request->header('x-admin-id', 0) ?: null;
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$user = $this->resolveManualOrderUser($consignee, $mobile, $now);
|
||||
$addressId = $this->ensureUserAddress((int)$user['id'], [
|
||||
'consignee' => $consignee,
|
||||
'mobile' => $mobile,
|
||||
'province' => $province,
|
||||
'city' => $city,
|
||||
'district' => $district,
|
||||
'detail_address' => $detailAddress,
|
||||
], $now);
|
||||
|
||||
$orderId = (int)Db::name('orders')->insertGetId([
|
||||
'order_no' => $orderNo,
|
||||
'appraisal_no' => $appraisalNo,
|
||||
'user_id' => (int)$user['id'],
|
||||
'service_mode' => 'physical',
|
||||
'service_provider' => $serviceProvider,
|
||||
'payment_status' => 'paid',
|
||||
'order_status' => 'pending_shipping',
|
||||
'display_status' => '待入库',
|
||||
'estimated_finish_time' => $estimated,
|
||||
'source_channel' => self::MANUAL_ENTRY_SOURCE,
|
||||
'source_customer_id' => '',
|
||||
'pay_amount' => (float)$serviceConfig['price'],
|
||||
'paid_at' => $now,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
Db::name('order_products')->insert([
|
||||
'order_id' => $orderId,
|
||||
'category_id' => $categoryId,
|
||||
'category_name' => (string)$category['name'],
|
||||
'brand_id' => $brandId,
|
||||
'brand_name' => (string)$brand['name'],
|
||||
'color' => trim((string)($productInput['color'] ?? '')),
|
||||
'size_spec' => trim((string)($productInput['size_spec'] ?? '')),
|
||||
'serial_no' => trim((string)($productInput['serial_no'] ?? '')),
|
||||
'product_name' => $productName,
|
||||
'product_cover' => '',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
Db::name('order_extras')->insert([
|
||||
'order_id' => $orderId,
|
||||
'purchase_channel' => trim((string)($extraInput['purchase_channel'] ?? '')),
|
||||
'purchase_price' => (float)($extraInput['purchase_price'] ?? 0),
|
||||
'purchase_date' => null,
|
||||
'usage_status' => trim((string)($extraInput['usage_status'] ?? '')),
|
||||
'condition_desc' => trim((string)($extraInput['condition_desc'] ?? '')),
|
||||
'has_accessories' => 0,
|
||||
'accessories_json' => json_encode([], JSON_UNESCAPED_UNICODE),
|
||||
'remark' => trim((string)($extraInput['remark'] ?? '')),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
Db::name('order_return_addresses')->insert([
|
||||
'order_id' => $orderId,
|
||||
'user_address_id' => $addressId,
|
||||
'consignee' => $consignee,
|
||||
'mobile' => $mobile,
|
||||
'province' => $province,
|
||||
'city' => $city,
|
||||
'district' => $district,
|
||||
'detail_address' => $detailAddress,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
$shippingTarget = (new WarehouseService())->bindOrderTarget($orderId, $serviceProvider, $categoryId, [
|
||||
'province' => $province,
|
||||
'city' => $city,
|
||||
'district' => $district,
|
||||
'detail_address' => $detailAddress,
|
||||
]);
|
||||
|
||||
$this->insertManualOrderMaterials($orderId, $materials, $now);
|
||||
|
||||
Db::name('appraisal_tasks')->insert([
|
||||
'order_id' => $orderId,
|
||||
'task_stage' => 'first_review',
|
||||
'service_provider' => $serviceProvider,
|
||||
'status' => 'pending',
|
||||
'assignee_id' => null,
|
||||
'assignee_name' => '未分配',
|
||||
'started_at' => null,
|
||||
'submitted_at' => null,
|
||||
'sla_deadline' => $estimated,
|
||||
'is_overtime' => 0,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
Db::name('order_timelines')->insertAll([
|
||||
[
|
||||
'order_id' => $orderId,
|
||||
'node_code' => 'manual_created',
|
||||
'node_text' => '补录订单已创建',
|
||||
'node_desc' => '后台已补录订单资料,等待仓管入库。',
|
||||
'operator_type' => 'admin',
|
||||
'operator_id' => $operatorId,
|
||||
'occurred_at' => $now,
|
||||
'created_at' => $now,
|
||||
],
|
||||
[
|
||||
'order_id' => $orderId,
|
||||
'node_code' => 'pending_inbound',
|
||||
'node_text' => '待入库',
|
||||
'node_desc' => sprintf('可使用订单号或鉴定单号匹配入库,目标仓库:%s。', $shippingTarget['warehouse_name'] ?: '鉴定中心'),
|
||||
'operator_type' => 'system',
|
||||
'operator_id' => null,
|
||||
'occurred_at' => $now,
|
||||
'created_at' => $now,
|
||||
],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return api_error('补录订单创建失败', 500, ['detail' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
return api_success([
|
||||
'order_id' => $orderId,
|
||||
'order_no' => $orderNo,
|
||||
'appraisal_no' => $appraisalNo,
|
||||
'user_id' => (int)$user['id'],
|
||||
'next_status' => 'pending_shipping',
|
||||
], '补录订单已创建');
|
||||
}
|
||||
|
||||
public function manualOrderMeta(Request $request)
|
||||
{
|
||||
$categories = Db::name('catalog_categories')
|
||||
->field(['id', 'name', 'code', 'is_enabled', 'supported_service_types'])
|
||||
->where('is_enabled', 1)
|
||||
->order('sort_order', 'asc')
|
||||
->select()
|
||||
->toArray();
|
||||
$brands = Db::name('catalog_brands')
|
||||
->alias('b')
|
||||
->leftJoin('catalog_brand_categories cbc', 'cbc.brand_id = b.id')
|
||||
->field([
|
||||
'b.id',
|
||||
'b.name',
|
||||
'b.en_name',
|
||||
'b.code',
|
||||
'b.is_enabled',
|
||||
'b.supported_service_types',
|
||||
'GROUP_CONCAT(DISTINCT cbc.category_id) AS category_ids',
|
||||
])
|
||||
->where('b.is_enabled', 1)
|
||||
->group('b.id')
|
||||
->order('b.sort_order', 'asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return api_success([
|
||||
'categories' => array_map(fn (array $item) => [
|
||||
'id' => (int)$item['id'],
|
||||
'name' => (string)$item['name'],
|
||||
'code' => (string)$item['code'],
|
||||
'supported_service_types' => $this->decodeJsonArray($item['supported_service_types'] ?? null),
|
||||
], $categories),
|
||||
'brands' => array_map(fn (array $item) => [
|
||||
'id' => (int)$item['id'],
|
||||
'name' => (string)$item['name'],
|
||||
'en_name' => (string)($item['en_name'] ?? ''),
|
||||
'code' => (string)($item['code'] ?? ''),
|
||||
'category_ids' => $this->decodeIntList($item['category_ids'] ?? ''),
|
||||
'supported_service_types' => $this->decodeJsonArray($item['supported_service_types'] ?? null),
|
||||
], $brands),
|
||||
]);
|
||||
}
|
||||
|
||||
public function uploadManualOrderFile(Request $request)
|
||||
{
|
||||
try {
|
||||
return api_success((new AppraisalEvidenceService())->upload($request));
|
||||
} catch (\Throwable $e) {
|
||||
return api_error($e->getMessage(), 422);
|
||||
}
|
||||
}
|
||||
|
||||
private function inboundAttachments(int $orderId, Request $request): array
|
||||
{
|
||||
$logs = Db::name('order_transfer_flow_logs')
|
||||
->where('order_id', $orderId)
|
||||
->where('action_code', 'inbound_received')
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$attachments = [];
|
||||
foreach ($logs as $log) {
|
||||
$payload = $this->decodeJsonObject($log['payload_json'] ?? null);
|
||||
foreach ($this->decodeJsonArray($payload['inbound_attachments'] ?? []) as $item) {
|
||||
if (is_array($item)) {
|
||||
$attachments[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$normalized = (new AppraisalEvidenceService())->normalize($attachments, $request);
|
||||
|
||||
return array_values(array_filter($normalized, function (array $item) {
|
||||
return in_array((string)($item['file_type'] ?? ''), ['image', 'video'], true);
|
||||
}));
|
||||
}
|
||||
|
||||
private function decodeJsonArray(mixed $value): array
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return array_values($value);
|
||||
}
|
||||
if (is_string($value) && $value !== '') {
|
||||
$decoded = json_decode($value, true);
|
||||
return is_array($decoded) ? array_values($decoded) : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function decodeJsonObject(mixed $value): array
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_string($value) && $value !== '') {
|
||||
$decoded = json_decode($value, true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function decodeIntList(mixed $value): array
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return array_values(array_filter(array_map('intval', $value), fn (int $item) => $item > 0));
|
||||
}
|
||||
if (!is_string($value) || trim($value) === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(array_filter(array_map('intval', explode(',', $value)), fn (int $item) => $item > 0));
|
||||
}
|
||||
|
||||
private function requestArray(Request $request, string $key): array
|
||||
{
|
||||
$value = $request->input($key, []);
|
||||
return is_array($value) ? $value : [];
|
||||
}
|
||||
|
||||
private function normalizeServiceProvider(string $serviceProvider): string
|
||||
{
|
||||
$serviceProvider = trim($serviceProvider);
|
||||
return in_array($serviceProvider, ['anxinyan', 'zhongjian'], true) ? $serviceProvider : '';
|
||||
}
|
||||
|
||||
private function serviceConfig(string $serviceProvider): array
|
||||
{
|
||||
$configs = [
|
||||
'anxinyan' => ['price' => 99.00, 'sla_hours' => 48],
|
||||
'zhongjian' => ['price' => 199.00, 'sla_hours' => 72],
|
||||
];
|
||||
|
||||
return $configs[$serviceProvider] ?? $configs['anxinyan'];
|
||||
}
|
||||
|
||||
private function generateOrderNo(): string
|
||||
{
|
||||
do {
|
||||
$orderNo = 'AXY' . date('YmdHis') . mt_rand(100, 999);
|
||||
} while (Db::name('orders')->where('order_no', $orderNo)->find());
|
||||
|
||||
return $orderNo;
|
||||
}
|
||||
|
||||
private function generateAppraisalNo(): string
|
||||
{
|
||||
do {
|
||||
$appraisalNo = 'AXY-APP-' . date('Ymd') . '-' . mt_rand(1000, 9999);
|
||||
} while (Db::name('orders')->where('appraisal_no', $appraisalNo)->find());
|
||||
|
||||
return $appraisalNo;
|
||||
}
|
||||
|
||||
private function resolveManualOrderUser(string $consignee, string $mobile, string $now): array
|
||||
{
|
||||
$user = Db::name('users')
|
||||
->where('mobile', $mobile)
|
||||
->whereNull('deleted_at')
|
||||
->find();
|
||||
if ($user) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
$userId = (int)Db::name('users')->insertGetId([
|
||||
'nickname' => $consignee,
|
||||
'avatar' => '',
|
||||
'mobile' => $mobile,
|
||||
'password' => '',
|
||||
'status' => 'enabled',
|
||||
'last_login_at' => null,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
return Db::name('users')->where('id', $userId)->find();
|
||||
}
|
||||
|
||||
private function ensureUserAddress(int $userId, array $address, string $now): int
|
||||
{
|
||||
$existing = Db::name('user_addresses')
|
||||
->where('user_id', $userId)
|
||||
->where('consignee', (string)$address['consignee'])
|
||||
->where('mobile', (string)$address['mobile'])
|
||||
->where('province', (string)$address['province'])
|
||||
->where('city', (string)$address['city'])
|
||||
->where('district', (string)$address['district'])
|
||||
->where('detail_address', (string)$address['detail_address'])
|
||||
->find();
|
||||
if ($existing) {
|
||||
return (int)$existing['id'];
|
||||
}
|
||||
|
||||
$hasDefault = Db::name('user_addresses')
|
||||
->where('user_id', $userId)
|
||||
->where('is_default', 1)
|
||||
->find();
|
||||
|
||||
return (int)Db::name('user_addresses')->insertGetId([
|
||||
'user_id' => $userId,
|
||||
'consignee' => (string)$address['consignee'],
|
||||
'mobile' => (string)$address['mobile'],
|
||||
'province' => (string)$address['province'],
|
||||
'city' => (string)$address['city'],
|
||||
'district' => (string)$address['district'],
|
||||
'detail_address' => (string)$address['detail_address'],
|
||||
'is_default' => $hasDefault ? 0 : 1,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
|
||||
private function insertManualOrderMaterials(int $orderId, array $materials, string $now): void
|
||||
{
|
||||
$evidenceService = new AppraisalEvidenceService();
|
||||
foreach ($materials as $index => $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
$files = $evidenceService->normalize($item['files'] ?? [], null, true);
|
||||
if (!$files) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$orderUploadId = (int)Db::name('order_upload_items')->insertGetId([
|
||||
'order_id' => $orderId,
|
||||
'template_id' => null,
|
||||
'item_code' => trim((string)($item['item_code'] ?? 'manual_material_' . ($index + 1))),
|
||||
'item_name' => trim((string)($item['item_name'] ?? '补录资料')),
|
||||
'is_required' => !empty($item['is_required']) ? 1 : 0,
|
||||
'source_type' => 'initial',
|
||||
'status' => 'uploaded',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
foreach ($files as $file) {
|
||||
Db::name('order_upload_files')->insert([
|
||||
'order_upload_item_id' => $orderUploadId,
|
||||
'file_id' => (string)($file['file_id'] ?? ''),
|
||||
'file_url' => ltrim((string)($file['file_url'] ?? ''), '/'),
|
||||
'thumbnail_url' => ltrim((string)($file['thumbnail_url'] ?? ''), '/'),
|
||||
'quality_status' => 'uploaded',
|
||||
'quality_message' => '',
|
||||
'uploaded_by_user_id' => null,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function trackingStatusText(string $status, string $logisticsType = 'send_to_center'): string
|
||||
{
|
||||
if ($logisticsType === 'return_to_user') {
|
||||
@@ -984,14 +1438,45 @@ class OrdersController
|
||||
return $map;
|
||||
}
|
||||
|
||||
private function latestTransferFlowMap(array $orderIds): array
|
||||
{
|
||||
$orderIds = array_values(array_unique(array_filter(array_map('intval', $orderIds))));
|
||||
if (!$orderIds) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = Db::name('order_transfer_flows')
|
||||
->whereIn('order_id', $orderIds)
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$orderId = (int)($row['order_id'] ?? 0);
|
||||
if ($orderId > 0 && !isset($map[$orderId])) {
|
||||
$map[$orderId] = [
|
||||
'internal_tag_no' => (string)($row['internal_tag_no'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
private function warehouseOrderBucket(
|
||||
string $orderStatus,
|
||||
string $sendTrackingNo = '',
|
||||
string $sendTrackingStatus = '',
|
||||
string $displayStatus = ''
|
||||
string $displayStatus = '',
|
||||
string $sourceChannel = ''
|
||||
): string
|
||||
{
|
||||
if ($orderStatus === 'pending_shipping') {
|
||||
if ($sourceChannel === self::MANUAL_ENTRY_SOURCE && $sendTrackingNo === '') {
|
||||
return 'warehouse_pending_inbound';
|
||||
}
|
||||
|
||||
$hasSubmittedTracking = $sendTrackingNo !== '' && $sendTrackingStatus !== 'received';
|
||||
$hasSubmittedDisplayStatus = in_array($displayStatus, ['已提交运单', '用户已提交运单'], true)
|
||||
&& $sendTrackingStatus !== 'received';
|
||||
@@ -1020,6 +1505,7 @@ class OrdersController
|
||||
private function warehouseOrderBucketText(string $bucket): string
|
||||
{
|
||||
return match ($bucket) {
|
||||
'warehouse_pending_inbound' => '待入库',
|
||||
'warehouse_in_transit' => '在途',
|
||||
'warehouse_received' => '已入仓',
|
||||
'warehouse_pending_return' => '待寄回',
|
||||
@@ -1041,10 +1527,13 @@ class OrdersController
|
||||
'enterprise_order' => 'enterprise_push',
|
||||
'customer_push' => 'enterprise_push',
|
||||
'large_customer_push' => 'enterprise_push',
|
||||
'manual' => self::MANUAL_ENTRY_SOURCE,
|
||||
'manual_order' => self::MANUAL_ENTRY_SOURCE,
|
||||
'manual_entry' => self::MANUAL_ENTRY_SOURCE,
|
||||
];
|
||||
$sourceChannel = $aliases[$sourceChannel] ?? $sourceChannel;
|
||||
|
||||
return in_array($sourceChannel, ['mini_program', 'h5', 'enterprise_push'], true) ? $sourceChannel : '';
|
||||
return in_array($sourceChannel, ['mini_program', 'h5', 'enterprise_push', self::MANUAL_ENTRY_SOURCE], true) ? $sourceChannel : '';
|
||||
}
|
||||
|
||||
private function sourceChannelText(string $sourceChannel): string
|
||||
@@ -1053,6 +1542,7 @@ class OrdersController
|
||||
'mini_program' => '小程序',
|
||||
'h5' => 'H5',
|
||||
'enterprise_push' => '大客户推送订单',
|
||||
self::MANUAL_ENTRY_SOURCE => '后台补录订单',
|
||||
default => '未知渠道',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user