导出详情
This commit is contained in:
parent
85eecb8572
commit
fd9d7b4c61
@ -77,7 +77,7 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
||||
'progress' => 0,
|
||||
];
|
||||
|
||||
Export::create($data);
|
||||
Export::upsert($data, 'sn');
|
||||
|
||||
app(ExportRepository::class)->forgetCached();
|
||||
}
|
||||
@ -164,7 +164,7 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
||||
*/
|
||||
protected function sn(): string
|
||||
{
|
||||
return date('YmdHis') .sprintf('%04d', explode('.', microtime(true))[1]) . sprintf('%02d', rand(0, 99));
|
||||
return date('YmdHis') .sprintf('%04d', explode('.', microtime(true))[1]) . sprintf('%06d', rand(0, 999999));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ namespace App\Domains\Stats\Exports;
|
||||
|
||||
use App\Dicts;
|
||||
use App\Core\AbstractExport;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Dipper\Excel\Concerns\WithRows;
|
||||
use Dipper\Excel\Concerns\FromQuery;
|
||||
@ -73,21 +74,23 @@ class CompanyReportDetailExport extends AbstractExport implements FromQuery, Wit
|
||||
{
|
||||
$carrierOperators = app(Dicts::class)->get('carrier_operator');
|
||||
|
||||
$rows->transform(function ($item) use ($carrierOperators) {
|
||||
$array = [];
|
||||
|
||||
foreach ($rows as $item) {
|
||||
$company = app(CompanyService::class)->load($item->company_id);
|
||||
$package = app(PackageService::class)->load($item->package_id);
|
||||
$month_price = $item->unit_price / $package['service_months'];
|
||||
|
||||
return [
|
||||
$array[] = [
|
||||
$item['sim'],
|
||||
$carrierOperators[$package['carrier_operator']],
|
||||
$company['name'],
|
||||
$package['name'],
|
||||
$month_price,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return $rows;
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,8 +66,10 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
|
||||
{
|
||||
$rows = OrderService::detailTransformer($rows);
|
||||
|
||||
$rows->transform(function ($item) {
|
||||
return [
|
||||
$array = [];
|
||||
|
||||
foreach ($rows as $item) {
|
||||
$array[] = [
|
||||
$item['sim'],
|
||||
$item['company_name'],
|
||||
$item['package_name'],
|
||||
@ -77,9 +79,9 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
|
||||
$item['counts'],
|
||||
$item['order_at'],
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return $rows;
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ class CompanyReportService extends Service
|
||||
'package_id',
|
||||
'type',
|
||||
'unit_price',
|
||||
DB::raw('count(distinct sim) as counts'),
|
||||
DB::raw('count(*) as counts'),
|
||||
];
|
||||
|
||||
$query = $this->orderCardPartitionRepository->select($select)
|
||||
|
@ -44,8 +44,10 @@ class CardExport extends AbstractExport implements FromQuery, WithHeadings, With
|
||||
{
|
||||
$rows = CardService::transformer(new Collection($rows));
|
||||
|
||||
$rows->transform(function ($item) {
|
||||
return [
|
||||
$array = [];
|
||||
|
||||
foreach ($rows as $item) {
|
||||
$array[] = [
|
||||
$item['id'],
|
||||
$item['sim'],
|
||||
$item['imsi'],
|
||||
@ -59,9 +61,9 @@ class CardExport extends AbstractExport implements FromQuery, WithHeadings, With
|
||||
$item['service_start_at'],
|
||||
$item['service_end_at'],
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return $rows;
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
|
Loading…
x
Reference in New Issue
Block a user