Platform orders export: include lead_id column
This commit is contained in:
@@ -1081,6 +1081,7 @@ class PlatformOrderController extends Controller
|
|||||||
$headers = [
|
$headers = [
|
||||||
'ID',
|
'ID',
|
||||||
'订单号',
|
'订单号',
|
||||||
|
'线索ID',
|
||||||
'站点',
|
'站点',
|
||||||
'套餐',
|
'套餐',
|
||||||
'订单类型',
|
'订单类型',
|
||||||
@@ -1149,6 +1150,7 @@ class PlatformOrderController extends Controller
|
|||||||
$row = [
|
$row = [
|
||||||
$order->id,
|
$order->id,
|
||||||
$order->order_no,
|
$order->order_no,
|
||||||
|
(int) (data_get($order->meta, 'platform_lead_id') ?? 0),
|
||||||
$order->merchant?->name ?? '',
|
$order->merchant?->name ?? '',
|
||||||
$order->plan_name ?: ($order->plan?->name ?? ''),
|
$order->plan_name ?: ($order->plan?->name ?? ''),
|
||||||
$order->order_type,
|
$order->order_type,
|
||||||
|
|||||||
@@ -211,5 +211,57 @@ class AdminPlatformOrderExportTest extends TestCase
|
|||||||
|
|
||||||
$this->get('/admin/platform-orders/export')
|
$this->get('/admin/platform-orders/export')
|
||||||
->assertRedirect('/admin/login');
|
->assertRedirect('/admin/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_platform_admin_can_export_platform_orders_csv_with_lead_id_column(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'export_order_lead_id_test',
|
||||||
|
'name' => '导出线索ID测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$lead = \App\Models\PlatformLead::query()->create([
|
||||||
|
'name' => 'Lead Export',
|
||||||
|
'mobile' => '13800000999',
|
||||||
|
'company' => 'Export Inc',
|
||||||
|
'status' => 'new',
|
||||||
|
]);
|
||||||
|
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_EXPORT_LEAD_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'unpaid',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 0,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'platform_lead_id' => $lead->id,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders/export?download=1&lead_id=' . $lead->id);
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$content = $res->streamedContent();
|
||||||
|
$this->assertStringContainsString('线索ID', $content);
|
||||||
|
$this->assertStringContainsString('PO_EXPORT_LEAD_0001', $content);
|
||||||
|
$this->assertStringContainsString((string) $lead->id, $content);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user