实际人数
This commit is contained in:
parent
f00242cfec
commit
561e04f5b3
@ -31,6 +31,7 @@ class CompanyReportExport extends AbstractExport implements FromCollection, With
|
||||
'service_months' => $item->service_months,
|
||||
'unit_price' => $item->unit_price,
|
||||
'month_price' => $item->month_price,
|
||||
'members' => $item->members,
|
||||
'counts' => $item->counts,
|
||||
'total_price' => $item->total_price,
|
||||
'type_name' => $item->type_name,
|
||||
@ -43,6 +44,7 @@ class CompanyReportExport extends AbstractExport implements FromCollection, With
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
array_sum($orders->pluck('members')->toArray()) ?: 0,
|
||||
array_sum($orders->pluck('counts')->toArray()) ?: 0,
|
||||
array_sum($orders->pluck('total_price')->toArray()) ?: 0,
|
||||
'',
|
||||
@ -59,6 +61,7 @@ class CompanyReportExport extends AbstractExport implements FromCollection, With
|
||||
'套餐周期(月)',
|
||||
'套餐价格(元/周期)',
|
||||
'套餐单价(元/月)',
|
||||
'收费人数',
|
||||
'收费数',
|
||||
'收费总价(元)',
|
||||
'收费类型'
|
||||
|
@ -29,6 +29,7 @@ class OrderExport extends AbstractExport implements FromCollection, WithHeadings
|
||||
'package_name' => $item->package_name,
|
||||
'pay_channel_name' => $item->pay_channel_name,
|
||||
'unit_price' => $item->unit_price,
|
||||
'members' => $item->members,
|
||||
'counts' => $item->counts,
|
||||
'custom_price' => $item->custom_price,
|
||||
]);
|
||||
@ -39,6 +40,7 @@ class OrderExport extends AbstractExport implements FromCollection, WithHeadings
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
array_sum($orders->pluck('members')->toArray()) ?: 0,
|
||||
array_sum($orders->pluck('counts')->toArray()) ?: 0,
|
||||
array_sum($orders->pluck('custom_price')->toArray()) ?: 0,
|
||||
]);
|
||||
@ -53,6 +55,7 @@ class OrderExport extends AbstractExport implements FromCollection, WithHeadings
|
||||
'套餐名称',
|
||||
'支付方式',
|
||||
'单价',
|
||||
'人数',
|
||||
'数量',
|
||||
'总金额',
|
||||
];
|
||||
|
@ -41,6 +41,7 @@ class CompanyReportService extends Service
|
||||
'package_id',
|
||||
'type',
|
||||
'unit_price',
|
||||
DB::raw('count(distinct sim) as members'),
|
||||
DB::raw('CASE "type" WHEN 3 THEN SUM(counts) ELSE count(*) END AS counts'),
|
||||
];
|
||||
|
||||
|
@ -46,6 +46,12 @@ class OrderService extends Service
|
||||
*/
|
||||
public function index(array $conditions = [])
|
||||
{
|
||||
if (!$class = self::$classes[$conditions['type']]) {
|
||||
throw new NotAllowedException('统计类型不存在');
|
||||
}
|
||||
|
||||
$repository = app($class);
|
||||
|
||||
$conditions['source'] = 1;
|
||||
|
||||
$companies = $this->companyRepository->withTrashed()->get()->pluck('name', 'id')->toArray();
|
||||
@ -65,11 +71,34 @@ class OrderService extends Service
|
||||
$orders = $this->orderRepository->select($select)->withConditions($conditions)->applyConditions()
|
||||
->groupBy(['company_id', 'package_id', 'product_id', 'unit_price', 'pay_channel'])->paginate($conditions['limit']);
|
||||
|
||||
$orders->map(function ($item) use ($companies, $packages) {
|
||||
$order_ids = [];
|
||||
|
||||
foreach($orders as $order){
|
||||
$ids = str_to_array($order->order_id);
|
||||
$order_ids = array_merge($order_ids, str_to_array($order->order_id));
|
||||
}
|
||||
|
||||
$order_ids = array_unique($order_ids);
|
||||
|
||||
$members = $repository->select([
|
||||
'order_id',
|
||||
DB::raw('COUNT(distinct sim) as counts'),
|
||||
])->withConditions(['order_id' => $order_ids])->groupBy('order_id')->get()->keyBy('order_id');
|
||||
|
||||
$orders->map(function ($item) use ($companies, $packages, $members) {
|
||||
$item->unit_price = sprintf('%.02f', $item->unit_price/100);
|
||||
$item->custom_price = sprintf('%.02f', $item->custom_price/100);
|
||||
$item->company_name = $companies[$item->company_id];
|
||||
$item->package_name = $packages[$item->package_id];
|
||||
|
||||
$order_ids = str_to_array($item->order_id);
|
||||
|
||||
$item->members = 0;
|
||||
|
||||
foreach($order_ids as $id){
|
||||
$item->members += $members[$id]['counts'] ?? 0;
|
||||
}
|
||||
|
||||
$item->pay_channel_name = CommonService::namePayChannel($item->pay_channel);
|
||||
});
|
||||
|
||||
|
@ -54,6 +54,7 @@ class OrderController extends Controller
|
||||
'counts' => $item->counts,
|
||||
'total_price' => $item->total_price,
|
||||
'custom_price' => $item->custom_price,
|
||||
'shipments' => $item->shipments,
|
||||
'order_status' => $item->order_status,
|
||||
'order_status_name' => $orderStatues[$item->order_status],
|
||||
'transaction_status' => $item->transaction_status,
|
||||
|
@ -16,19 +16,22 @@ use App\Domains\Virtual\Repositories\OrderRepository;
|
||||
use App\Domains\Virtual\Repositories\CompanyRepository;
|
||||
use App\Domains\Virtual\Repositories\PackageRepository;
|
||||
use App\Domains\Virtual\Repositories\ProductRepository;
|
||||
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
|
||||
|
||||
class OrderService extends Service
|
||||
{
|
||||
protected $orderRepository;
|
||||
protected $orderCardPartitionRepository;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OrderRepository $orderRepository)
|
||||
public function __construct(OrderRepository $orderRepository, OrderCardPartitionRepository $orderCardPartitionRepository)
|
||||
{
|
||||
$this->orderRepository = $orderRepository;
|
||||
$this->orderCardPartitionRepository = $orderCardPartitionRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,12 +46,18 @@ class OrderService extends Service
|
||||
|
||||
$res = $this->orderRepository->withConditions($conditions)->applyConditions()->orderBy('order_at', 'desc')->paginate($limit);
|
||||
|
||||
$res->map(function ($item) {
|
||||
$orderShipments = $this->orderCardPartitionRepository->select([
|
||||
'order_id',
|
||||
DB::raw('SUM(counts) as counts'),
|
||||
])->withConditions($conditions)->groupBy('order_id')->get()->keyBy('order_id');
|
||||
|
||||
$res->map(function ($item) use ($orderShipments) {
|
||||
$item->company = app(CompanyService::class)->load($item->company_id);
|
||||
$item->package = app(PackageService::class)->load($item->package_id);
|
||||
$item->unit_price = sprintf('%.02f', $item->unit_price/100);
|
||||
$item->total_price = sprintf('%.02f', $item->total_price/100);
|
||||
$item->custom_price = sprintf('%.02f', $item->custom_price/100);
|
||||
$item->shipments = $orderShipments[$item->id]['counts'] ?? 0;
|
||||
});
|
||||
|
||||
return $res;
|
||||
|
@ -55,6 +55,11 @@ export default {
|
||||
key: 'month_price',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '收费人数',
|
||||
key: 'members',
|
||||
width: 130
|
||||
},
|
||||
{
|
||||
title: '收费数',
|
||||
key: 'counts',
|
||||
|
@ -51,6 +51,11 @@ export default {
|
||||
key: 'unit_price',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '人数',
|
||||
key: 'members',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '数量',
|
||||
key: 'counts',
|
||||
|
@ -67,11 +67,11 @@ export default {
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '订单卡量',
|
||||
title: '订单数量',
|
||||
key: '',
|
||||
width: 100,
|
||||
render: (h, { row, column, index }) => {
|
||||
return h('span', Number(row.counts) + ' 张');
|
||||
return h('span', Number(row.counts));
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -79,6 +79,18 @@ export default {
|
||||
key: 'custom_price',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '已排单数',
|
||||
key: '',
|
||||
width: 100,
|
||||
render: (h, { row, column, index }) => {
|
||||
let style = {};
|
||||
if (row.shipments !== row.counts) {
|
||||
style = { 'color': '#ed4014' };
|
||||
}
|
||||
return h('span', { style }, Number(row.shipments));
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '订单状态',
|
||||
key: '',
|
||||
|
2
public/js/app.20219e3f.js
Normal file
2
public/js/app.20219e3f.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/app.20219e3f.js.map
Normal file
1
public/js/app.20219e3f.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-7b1dff40.48031a60.js
Normal file
2
public/js/chunk-7b1dff40.48031a60.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-7b1dff40.48031a60.js.map
Normal file
1
public/js/chunk-7b1dff40.48031a60.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-7b1dff40.ca5cf5af.css rel=prefetch><link href=/js/chunk-00ae0766.9e6b7bf3.js rel=prefetch><link href=/js/chunk-7b1dff40.ad11022a.js rel=prefetch><link href=/css/app.36043160.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.6fe3ea07.js rel=preload as=script><link href=/js/chunk-vendors.02a4e5bc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.36043160.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.02a4e5bc.js></script><script src=/js/app.6fe3ea07.js></script></body></html>
|
||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-7b1dff40.ca5cf5af.css rel=prefetch><link href=/js/chunk-00ae0766.9e6b7bf3.js rel=prefetch><link href=/js/chunk-7b1dff40.48031a60.js rel=prefetch><link href=/css/app.36043160.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.20219e3f.js rel=preload as=script><link href=/js/chunk-vendors.02a4e5bc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.36043160.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.02a4e5bc.js></script><script src=/js/app.20219e3f.js></script></body></html>
|
Loading…
x
Reference in New Issue
Block a user