recover
This commit is contained in:
@@ -82,6 +82,13 @@ public class BuyOrderController {
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) throws Exception {
|
||||
PageUtils page = buyOrderService.list(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.util.Map;
|
||||
*/
|
||||
public interface BuyOrderService extends IService<BuyOrder> {
|
||||
|
||||
PageUtils list(Map<String, Object> params) throws Exception;
|
||||
|
||||
PageUtils getMyOrderList(Map<String, Object> params);
|
||||
|
||||
//更新订单状态
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.peanut.modules.book.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.config.Constants;
|
||||
@@ -27,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -57,6 +60,53 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public PageUtils list(Map<String, Object> params) throws Exception {
|
||||
|
||||
IPage<BuyOrder> page;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String startTime = null;
|
||||
String endTime = null;
|
||||
if (params.containsKey("startTime")) {
|
||||
startTime = sdf.format(Long.parseLong(params.get("startTime").toString()));
|
||||
endTime = sdf.format(Long.parseLong(params.get("endTime").toString()));
|
||||
}
|
||||
if (ObjectUtils.isEmpty(params.get("orderStatus"))) {
|
||||
ExcludeEmptyQueryWrapper<BuyOrder> queryWrapper = new ExcludeEmptyQueryWrapper<>();
|
||||
Query<BuyOrder> query = new Query<>();
|
||||
page = query.getPage(params);
|
||||
queryWrapper.eq("user_phone", params.get("key"));
|
||||
queryWrapper.or().like("order_sn", params.get("key"));
|
||||
queryWrapper.or().like("shipping_user", params.get("key"));
|
||||
queryWrapper.apply(startTime != null, "date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')", startTime);
|
||||
queryWrapper.apply(endTime != null, "date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", endTime).orderByDesc("create_time");
|
||||
page = this.page(page, queryWrapper);
|
||||
} else {
|
||||
page = this.page(
|
||||
new Query<BuyOrder>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<BuyOrder>().eq("order_status", params.get("orderStatus")).eq("user_phone", params.get("key"))
|
||||
.or().like("order_sn", params.get("key")).or().like("shipping_user", params.get("key"))
|
||||
.apply(startTime != null, "date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')", startTime)
|
||||
.apply(endTime != null, "date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", endTime).orderByDesc("create_time")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
List<BuyOrder> records = page.getRecords();
|
||||
for (BuyOrder record : records) {
|
||||
Integer userId = record.getUserId();
|
||||
MyUserEntity myUserEntity = myUserService.getById(userId);
|
||||
if (!ObjectUtils.isEmpty(myUserEntity)) {
|
||||
record.setUserName(myUserEntity.getName());
|
||||
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", record.getOrderId())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils getMyOrderList(Map<String, Object> params) {
|
||||
|
||||
Reference in New Issue
Block a user