卡详情

This commit is contained in:
邓皓元 2019-03-15 17:19:40 +08:00
parent bb7a17faff
commit 6db0d98a1c
8 changed files with 140 additions and 12 deletions

View File

@ -42,8 +42,9 @@ class OrderService extends Service
$res = $this->orderRepository->withConditions($conditions)->applyConditions()->paginate($limit);
if (!$res->isEmpty()) {
$cards = $this->orderCardPartitionRepository->selectRaw('order_id,SUM(counts) as counts')
->withConditions(['order_id', $res->pluck('id')->toArray()])->where('virtual_order_id', '<>', 0)->groupBy('order_id')->get()->pluck('counts', 'order_id')->toArray();
$cards = $this->orderCardPartitionRepository->selectRaw('order_id,SUM(counts) as counts, SUM(CASE virtual_order_id WHEN 0 THEN 0 ELSE counts END) as shipments')
->withConditions(['order_id', $res->pluck('id')->toArray()])
->groupBy('order_id')->get()->keyBy('order_id')->toArray();
}
$res->map(function ($item) use ($carrierOperators, $cards) {
@ -55,7 +56,8 @@ class OrderService extends Service
$item->carrier_operator_name = $carrierOperators[$item->carrier_operator];
$item->unit_price = sprintf('%.02f', $item->unit_price/100);
$item->total_price = sprintf('%.02f', $item->total_price/100);
$item->shipments = $cards[$item->id] ?? 0;
$item->shipments = $cards[$item->id]['shipments'] ?? 0;
$item->counts = $cards[$item->id]['counts'] ?? 0;
});
return $res->sortByDesc('order_at')->values();
@ -73,10 +75,10 @@ class OrderService extends Service
ini_set('memory_limit', '4096m');
ini_set('default_socket_timeout', -1);
$counts = $this->orderCardPartitionRepository->withConditions($conditions)->count();
$counts = $this->orderCardPartitionRepository->withConditions($conditions)->sum('counts');
if ($counts > 100000) {
throw new NotAllowedException("当前请求总卡量为{$counts}张,数据量过大,请筛选过滤后查询");
if ($counts > 50000) {
throw new NotAllowedException("当前请求数据量过大,请筛选过滤后查询");
}
$cards = $this->orderCardPartitionRepository->withVirtual($conditions)->get();

View File

@ -165,4 +165,18 @@ class OrderController extends Controller
return res(true, '重置成功');
}
/**
* 卡清单.
*
* @return \Illuminate\Http\Response
*/
public function cards()
{
$conditions = $this->request->all();
$cards = $this->orderService->cards($conditions);
return res($cards, '卡清单');
}
}

View File

@ -49,6 +49,7 @@ $router->group(['prefix' => 'virtual', 'as' => 'virtual', 'middleware' => ['admi
$router->post('/orders/update/{id}', ['as' => 'orders.update', 'uses' => 'OrderController@update']);
$router->post('/orders/destroy', ['as' => 'orders.destroy', 'uses' => 'OrderController@destroy']);
$router->post('/orders/reset', ['as' => 'orders.reset', 'uses' => 'OrderController@reset']);
$router->get('/orders/cards', ['as' => 'orders.cards', 'uses' => 'OrderController@cards']);
// 客户管理
$router->get('/cards/index', ['as' => 'cards.index', 'uses' => 'CardController@index']);

View File

@ -424,4 +424,19 @@ class OrderService extends Service
return intval($transactionNo);
}
/**
* 订单卡查询
*
* @param array $conditions
* @return void
*/
public function cards(array $conditions = [])
{
$conditions['limit'] = $conditions['limit'] ?? 20;
$cards = $this->orderCardPartitionRepository->select(['sim'])->withConditions($conditions)->orderBy('sim')->paginate($conditions['limit']);
return $cards;
}
}

View File

@ -22,6 +22,16 @@ export function show(id) {
return service.get(`api/virtual/orders/show/${id}`);
}
/**
* [cards 卡清单列表]
* @param {[type]} data [description]
* @return {[type]} [description]
*/
export function cards(data) {
return service.get('api/virtual/orders/cards', {
params: data
});
}
/**
* [create 创建订单]
* @param {[type]} data [description]

View File

@ -146,6 +146,22 @@
<div class="ui-list-content">{{data.logistics_no}}</div>
</li>
</ul>
<Divider>出库卡清单</Divider>
<Table :columns="columns" :data="cards" :loading="loading"></Table>
<Row justify="center" class="umar-tb10 ta-c">
<Page
:current="Number(page.page)"
:page-size="Number(page.limit)"
:page-size-opts="[15, 30, 60, 90]"
:total="Number(page.total)"
@on-change="changePage"
@on-page-size-change="changeLimit"
show-total
size="small"
></Page>
</Row>
</div>
</Drawer>
</template>

View File

@ -25,10 +25,8 @@ export default {
},
computed: {
filterTotal() {
return this.filterOrders.filter(el => {
return el.shipments !== el.counts;
}).reduce((acc, cur) => {
return acc + cur.counts;
return this.filterOrders.reduce((acc, cur) => {
return acc + cur.counts - cur.shipments;
}, 0);
},
total() {
@ -605,6 +603,10 @@ export default {
return item.id;
});
if (this.filterTotal > 50000) {
return this.$Message.error('当前请求数据量过大,请筛选过滤后查询');
}
this.handleSelectOrder(order_id, true);
}
}

View File

@ -1,4 +1,6 @@
export default{
import * as API from 'api/virtual/orders';
export default {
props: {
show: {
type: Boolean,
@ -14,14 +16,80 @@ export default{
watch: {
show(bool) {
this.my_show = bool;
if (bool) {
this.index(1);
}
}
},
data() {
return {
my_show: false
loading: false,
my_show: false,
page: {
total: 0,
page: 1,
limit: 15
},
columns: [
{
title: "SIM卡号",
key: "column1",
align: 'center'
},
{
title: "SIM卡号",
key: "column2",
align: 'center'
},
{
title: "SIM卡号",
key: "column3",
align: 'center'
}
],
cards: []
};
},
methods: {
index() {
let params = {
page: this.page.page,
limit: this.page.limit,
order_id: this.data.id
};
this.loading = true;
API.cards(params).then(res => {
this.loading = false;
if (res.code === 0) {
this.page.total = res.data.total;
let cards = res.data.data;
let array = [];
for (let index = 0; index < cards.length; index = index + 3) {
array.push({
column1: cards[index] ? cards[index]['sim'] : '',
column2: cards[index + 1] ? cards[index + 1]['sim'] : '',
column3: cards[index + 2] ? cards[index + 2]['sim'] : ''
});
}
this.cards = array;
console.log(this.cards);
}
});
},
changePage(page) {
this.page.page = page;
this.index();
},
changeLimit(limit) {
this.page.limit = limit;
this.changePage(1);
},
visibleChange(bool) {
this.$emit('update:show', bool);
}