时间筛选快捷方式

This commit is contained in:
邓皓元 2019-03-29 10:21:11 +08:00
parent e40d67fd0c
commit 72fe7ec36c
18 changed files with 171 additions and 27 deletions

View File

@ -3,13 +3,14 @@ namespace App\Domains\Real\Services;
use App\Dicts;
use App\Core\Service;
use Illuminate\Support\Facades\Log;
use App\Exceptions\NotAllowedException;
use App\Domains\Virtual\Services\CompanyService;
use App\Domains\Virtual\Services\PackageService;
use App\Domains\Real\Repositories\OrderRepository;
use App\Domains\Real\Repositories\OrderCardPartitionRepository;
use App\Domains\Virtual\Repositories\OrderRepository as VirtualOrderRepository;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository as VirtualOrderCardPartitionRepository;
use App\Exceptions\NotAllowedException;
class OrderService extends Service
{
@ -82,12 +83,16 @@ class OrderService extends Service
$counts = $this->orderCardPartitionRepository->withConditions($conditions)->sum('counts');
if ($counts > 50000) {
if ($counts > 200000) {
throw new NotAllowedException("当前请求数据量过大,请筛选过滤后查询");
}
Log::info('1', [microtime(true)]);
$cards = $this->orderCardPartitionRepository->withVirtual($conditions)->currentModel()->get();
Log::info('2', [microtime(true)]);
$tmpCards = $cards->groupBy('virtual_order_id');
$orderIds = $tmpCards->keys()->unique()->toArray();
@ -98,13 +103,17 @@ class OrderService extends Service
unset($orderIds[$key]);
}
Log::info('3', [microtime(true)]);
$virtualOrders = [];
// 有订单的从订单中读取公司和套餐
if (!empty($orderIds)) {
$virtualOrders = app(VirtualOrderRepository::class)->withConditions(['id' => $orderIds])->get()->keyBy('id');
}
$cards->map(function ($item) use ($virtualOrders) {
Log::info('4', [microtime(true)]);
foreach ($cards as &$item) {
$item->sim = (string)$item->sim;
$item->company_id = $item->company_id ?? 0;
$item->package_id = $item->package_id ?? 0;
@ -117,7 +126,9 @@ class OrderService extends Service
$item->company_name = !$item->company_id ? '' : CompanyService::load($item->company_id)['name'] ?? '';
$item->package_name = !$item->package_id ? '' : PackageService::load($item->package_id)['name'] ?? '';
});
}
Log::info('5', [microtime(true)]);
return $cards->sortBy('sim')->sortBy('order_id')->values();
}

View File

@ -295,7 +295,7 @@ class OrderService extends Service
return;
}
$array = array_chunk($data, 10000);
$array = array_chunk($data, 1000);
foreach ($array as $value) {
DB::table($table)->upsert($value, ['sim', 'order_id', 'deleted_at']);

View File

@ -30,6 +30,37 @@ export default {
});
return date && date.valueOf() > ym;
}
},
datePickerOptionsMonth: {
shortcuts: [
{
text: '本月',
value: () => {
return [
this.moment().startOf('month').format('YYYY-MM-DD'),
this.moment().endOf('month').format('YYYY-MM-DD')
];
}
},
{
text: '前一个月',
value: () => {
return [
this.moment().subtract('1', 'months').startOf('month').format('YYYY-MM-DD'),
this.moment().subtract('1', 'months').endOf('month').format('YYYY-MM-DD')
];
}
},
{
text: '前两个月',
value: () => {
return [
this.moment().subtract('2', 'months').startOf('month').format('YYYY-MM-DD'),
this.moment().subtract('2', 'months').endOf('month').format('YYYY-MM-DD')
];
}
}
]
}
};
},

View File

@ -47,6 +47,7 @@
placement="bottom-start"
type="daterange"
v-model.trim="options.time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>

View File

@ -46,7 +46,14 @@
</li>
<li class="handle-item w-350">
<DatePicker :editable="false" placeholder="请选择时间" placement="bottom-start" type="daterange" v-model.trim="other.time"></DatePicker>
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"
v-model.trim="other.time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>
</ul>
@ -70,11 +77,23 @@
<span @click="handleSelectAll(false)" class="clear">清空</span>
</Alert>
<Table :columns="table_titles" :data="list_data?list_data.data:[]" @on-selection-change="selectionChange" ref="table"></Table>
<Table
:columns="table_titles"
:data="list_data?list_data.data:[]"
@on-selection-change="selectionChange"
ref="table"
></Table>
</div>
<div class="page-turn-wrap" v-if="list_data && list_data.data.length">
<Page :current="Number(list_data.current_page)" :page-size="Number(list_data.per_page)" :total="Number(list_data.total)" @on-change="index" show-elevator show-total></Page>
<Page
:current="Number(list_data.current_page)"
:page-size="Number(list_data.per_page)"
:total="Number(list_data.total)"
@on-change="index"
show-elevator
show-total
></Page>
</div>
</div>
</template>

View File

@ -27,13 +27,29 @@
<div class="search-wrap" v-show="search.show">
<ul class="handle-wraper">
<li class="handle-item w-250">
<AutoComplete @on-search="handleCompleteCompanies" icon="ios-search" placeholder="企业名称" v-model.trim="options.name">
<Option :key="item.id" :value="item.name" v-for="item in completeHandledCompanies">{{ item.name }}</Option>
<AutoComplete
@on-search="handleCompleteCompanies"
icon="ios-search"
placeholder="企业名称"
v-model.trim="options.name"
>
<Option
:key="item.id"
:value="item.name"
v-for="item in completeHandledCompanies"
>{{ item.name }}</Option>
</AutoComplete>
</li>
<li class="handle-item w-250">
<DatePicker :editable="false" placeholder="请选择时间" placement="bottom-start" type="daterange" v-model.trim="options.time"></DatePicker>
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"
v-model.trim="options.time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>
</ul>
@ -51,16 +67,32 @@
</div>
<div class="page-list-wrap">
<Table :columns="columns" :data="data" :height="page.limit > 12 ? 610 : ''" ref="table" stripe>
<Table
:columns="columns"
:data="data"
:height="page.limit > 12 ? 610 : ''"
ref="table"
stripe
>
<template class="table-footer" slot="footer">
<colgroup class="table-footer-colgroup"></colgroup>
<thead class="ivu-table">
<tr>
<th><div class="ivu-table-cell">总计</div></th>
<th><div class="ivu-table-cell"></div></th>
<th><div class="ivu-table-cell">{{stats.total}}</div></th>
<th><div class="ivu-table-cell">{{stats.counts}}</div></th>
<th><div class="ivu-table-cell">{{stats.renewed_counts}}</div></th>
<th>
<div class="ivu-table-cell">总计</div>
</th>
<th>
<div class="ivu-table-cell"></div>
</th>
<th>
<div class="ivu-table-cell">{{stats.total}}</div>
</th>
<th>
<div class="ivu-table-cell">{{stats.counts}}</div>
</th>
<th>
<div class="ivu-table-cell">{{stats.renewed_counts}}</div>
</th>
<th v-if="page.limit > 12" rowspan="1"></th>
</tr>
</thead>

View File

@ -27,14 +27,32 @@
<div class="search-wrap" v-show="search.show">
<ul class="handle-wraper">
<li class="handle-item w-250">
<AutoComplete @on-search="handleCompleteCompanies" icon="ios-search" placeholder="企业名称" v-model.trim="options.company_name">
<Option :key="item.id" :value="item.name" v-for="item in completeHandledCompanies">{{ item.name }}</Option>
<AutoComplete
@on-search="handleCompleteCompanies"
icon="ios-search"
placeholder="企业名称"
v-model.trim="options.company_name"
>
<Option
:key="item.id"
:value="item.name"
v-for="item in completeHandledCompanies"
>{{ item.name }}</Option>
</AutoComplete>
</li>
<li class="handle-item w-250">
<AutoComplete @on-search="handleCompletePackages(type)" icon="ios-search" placeholder="套餐名称" v-model.trim="options.package_name">
<Option :key="item.id" :value="item.name" v-for="item in completeHandledPackages">{{ item.name }}</Option>
<AutoComplete
@on-search="handleCompletePackages(type)"
icon="ios-search"
placeholder="套餐名称"
v-model.trim="options.package_name"
>
<Option
:key="item.id"
:value="item.name"
v-for="item in completeHandledPackages"
>{{ item.name }}</Option>
</AutoComplete>
</li>
@ -49,7 +67,14 @@
<ul class="handle-wraper">
<li class="handle-item w-250">
<DatePicker :editable="false" placeholder="请选择时间" placement="bottom-start" type="daterange" v-model.trim="options.time"></DatePicker>
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"
v-model.trim="options.time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>
<li class="f-r">
@ -65,7 +90,13 @@
</div>
<div class="page-list-wrap">
<Table :columns="columns" :data="data" :height="page.limit > 12 ? 610 : ''" ref="table" stripe>
<Table
:columns="columns"
:data="data"
:height="page.limit > 12 ? 610 : ''"
ref="table"
stripe
>
<template class="table-footer" slot="footer">
<colgroup class="table-footer-colgroup"></colgroup>
<thead class="ivu-table" v-show="data.length">

View File

@ -70,6 +70,7 @@
placement="bottom-start"
type="daterange"
v-model.trim="params.activated_time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>
</ul>
@ -103,6 +104,7 @@
placement="bottom-start"
type="daterange"
v-model.trim="params.time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>

View File

@ -43,6 +43,7 @@
placeholder="请选择时间"
placement="bottom-start"
type="daterange"
:options="datePickerOptionsMonth"
v-model.trim="params.time"
></DatePicker>
</li>

View File

@ -82,6 +82,7 @@
placement="bottom-start"
type="daterange"
v-model.trim="params.time"
:options="datePickerOptionsMonth"
></DatePicker>
</li>
</ul>

View File

@ -26,7 +26,7 @@ export default {
computed: {
filterTotal() {
return this.filterOrders.reduce((acc, cur) => {
return acc + cur.counts - cur.shipments;
return acc + cur.counts;
}, 0);
},
total() {
@ -752,7 +752,7 @@ export default {
return item.id;
});
if (this.filterTotal > 50000) {
if (this.filterTotal > 200000) {
return this.$Message.error('当前请求数据量过大,请筛选过滤后查询');
}

View File

@ -137,10 +137,17 @@ export default {
});
if (this.groupIndex === '0_0') {
if (this.type !== 1) {
return this.$Message.error('暂不支持续费包及加油包转销售');
}
// 卡不在VD上转销售
this.params.sign = 1;
this.post();
} else if (this.params.company_id !== this.group[0].company_id) {
if (this.type !== 1) {
return this.$Message.error('暂不支持续费包及加油包改企业');
}
// 改企业的
this.params.sign = 2;
this.$Modal.confirm({
@ -224,7 +231,7 @@ export default {
}
}
if (typeof (this.params.carrier_operator) === 'number') {
if (typeof(this.params.carrier_operator) === 'number') {
packages = packages.filter(item => {
return item.carrier_operator === this.params.carrier_operator;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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-63ee4df4.78afaf5b.css rel=prefetch><link href=/css/chunk-996b1e80.5cadf3d0.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-63ee4df4.c7a4bc29.js rel=prefetch><link href=/js/chunk-996b1e80.d3b45e46.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.7394310b.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.7394310b.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-62dbcbb5.8d1ff736.css rel=prefetch><link href=/css/chunk-996b1e80.5cadf3d0.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-62dbcbb5.c847744d.js rel=prefetch><link href=/js/chunk-996b1e80.d3b45e46.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.5eb18560.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.5eb18560.js></script></body></html>