Skip to content

Commit

Permalink
perf[litemall-admin,litemall-admin-api]: 订单页面可以查询订单时间
Browse files Browse the repository at this point in the history
  • Loading branch information
linlinjava committed Feb 13, 2020
1 parent 02a704c commit 5e0bd4c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class AdminOrderService {
@Autowired
private LogHelper logHelper;

public Object list(Integer userId, String orderSn, List<Short> orderStatusArray,
public Object list(Integer userId, String orderSn, LocalDateTime start, LocalDateTime end, List<Short> orderStatusArray,
Integer page, Integer limit, String sort, String order) {
List<LitemallOrder> orderList = orderService.querySelective(userId, orderSn, orderStatusArray, page, limit,
List<LitemallOrder> orderList = orderService.querySelective(userId, orderSn, start, end, orderStatusArray, page, limit,
sort, order);
return ResponseUtil.okList(orderList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;

@RestController
Expand Down Expand Up @@ -44,12 +46,14 @@ public class AdminOrderController {
@RequiresPermissionsDesc(menu = {"商场管理", "订单管理"}, button = "查询")
@GetMapping("/list")
public Object list(Integer userId, String orderSn,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime start,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime end,
@RequestParam(required = false) List<Short> orderStatusArray,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
return adminOrderService.list(userId, orderSn, orderStatusArray, page, limit, sort, order);
return adminOrderService.list(userId, orderSn, start, end, orderStatusArray, page, limit, sort, order);
}

/**
Expand Down
39 changes: 35 additions & 4 deletions litemall-admin/src/views/mall/order.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

<!-- 查询和其他操作 -->
<div class="filter-container">
<el-input v-model="listQuery.userId" clearable class="filter-item" style="width: 200px;" placeholder="请输入用户ID" />
<el-input v-model="listQuery.orderSn" clearable class="filter-item" style="width: 200px;" placeholder="请输入订单编号" />
<el-input v-model="listQuery.userId" clearable class="filter-item" style="width: 160px;" placeholder="请输入用户ID" />
<el-input v-model="listQuery.orderSn" clearable class="filter-item" style="width: 160px;" placeholder="请输入订单编号" />
<el-date-picker v-model="listQuery.timeArray" type="datetimerange" class="filter-item" range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" />
<el-select v-model="listQuery.orderStatusArray" multiple style="width: 200px" class="filter-item" placeholder="请选择订单状态">
<el-option v-for="(key, value) in statusMap" :key="key" :label="key" :value="value" />
</el-select>
Expand Down Expand Up @@ -159,11 +160,9 @@ const statusMap = {
101: '未付款',
102: '用户取消',
103: '系统取消',
200: '已付款团购',
201: '已付款',
202: '申请退款',
203: '已退款',
204: '已超时团购',
301: '已发货',
401: '用户收货',
402: '系统收货'
Expand All @@ -187,10 +186,38 @@ export default {
limit: 20,
id: undefined,
name: undefined,
timeArray: [],
orderStatusArray: [],
sort: 'add_time',
order: 'desc'
},
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
picker.$emit('pick', [start, end])
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
picker.$emit('pick', [start, end])
}
}]
},
statusMap,
orderDialogVisible: false,
orderDetail: {
Expand Down Expand Up @@ -221,6 +248,10 @@ export default {
checkPermission,
getList() {
this.listLoading = true
if (this.listQuery.timeArray.length === 2) {
this.listQuery.start = this.listQuery.timeArray[0]
this.listQuery.end = this.listQuery.timeArray[1]
}
listOrder(this.listQuery).then(response => {
this.list = response.data.data.list
this.total = response.data.data.total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public List<LitemallOrder> queryByOrderStatus(Integer userId, List<Short> orderS
return litemallOrderMapper.selectByExample(example);
}

public List<LitemallOrder> querySelective(Integer userId, String orderSn, List<Short> orderStatusArray, Integer page, Integer limit, String sort, String order) {
public List<LitemallOrder> querySelective(Integer userId, String orderSn, LocalDateTime start, LocalDateTime end, List<Short> orderStatusArray, Integer page, Integer limit, String sort, String order) {
LitemallOrderExample example = new LitemallOrderExample();
LitemallOrderExample.Criteria criteria = example.createCriteria();

Expand All @@ -102,6 +102,12 @@ public List<LitemallOrder> querySelective(Integer userId, String orderSn, List<S
if (!StringUtils.isEmpty(orderSn)) {
criteria.andOrderSnEqualTo(orderSn);
}
if(start != null){
criteria.andAddTimeGreaterThanOrEqualTo(start);
}
if(end != null){
criteria.andAddTimeLessThanOrEqualTo(end);
}
if (orderStatusArray != null && orderStatusArray.size() != 0) {
criteria.andOrderStatusIn(orderStatusArray);
}
Expand Down

1 comment on commit 5e0bd4c

@chengdada123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除了这4个文件更新还更新了哪里?更新之后编译了不管用。

Please sign in to comment.