分页查询订单信息
This commit is contained in:
parent
2a1c93a934
commit
100464ccc6
@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,6 +47,24 @@ public class ProductOrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PayUrlConfig payUrlConfig;
|
private PayUrlConfig payUrlConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询商品列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "分页查询我的订单列表")
|
||||||
|
@GetMapping("page")
|
||||||
|
public JsonData findOrderList(@ApiParam("当前页")
|
||||||
|
@RequestParam(value = "page", defaultValue = "1") int page,
|
||||||
|
@ApiParam("显示多少条")
|
||||||
|
@RequestParam(value = "size", defaultValue = "20") int size,
|
||||||
|
@ApiParam("订单状态") @RequestParam(value = "state",required = false) String state) {
|
||||||
|
Map<String, Object> pageResult = orderService.page(page, size,state);
|
||||||
|
return JsonData.buildSuccess(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("提交订单")
|
@ApiOperation("提交订单")
|
||||||
@PostMapping("confirm")
|
@PostMapping("confirm")
|
||||||
public void confirmOrder(@ApiParam("订单对象") @RequestBody ConfirmOrderRequest confirmOrderRequest, HttpServletResponse response) {
|
public void confirmOrder(@ApiParam("订单对象") @RequestBody ConfirmOrderRequest confirmOrderRequest, HttpServletResponse response) {
|
||||||
|
@ -51,4 +51,13 @@ public interface ProductOrderService extends IService<ProductOrderDO> {
|
|||||||
*/
|
*/
|
||||||
JsonData handlerOrderCallbackMsg(ProductOrderPayTypeEnum productOrderPayTypeEnum, Map<String, String> paramsMap);
|
JsonData handlerOrderCallbackMsg(ProductOrderPayTypeEnum productOrderPayTypeEnum, Map<String, String> paramsMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询订单列表
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
* @param state
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, Object> page(int page, int size,String state);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package net.jieyuu.service.impl;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.jieyuu.component.PayFactory;
|
import net.jieyuu.component.PayFactory;
|
||||||
import net.jieyuu.config.RabbitMQConfig;
|
import net.jieyuu.config.RabbitMQConfig;
|
||||||
@ -24,20 +26,15 @@ import net.jieyuu.service.ProductOrderService;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import net.jieyuu.utils.CommonUtil;
|
import net.jieyuu.utils.CommonUtil;
|
||||||
import net.jieyuu.utils.JsonData;
|
import net.jieyuu.utils.JsonData;
|
||||||
import net.jieyuu.vo.CouponRecordVO;
|
import net.jieyuu.vo.*;
|
||||||
import net.jieyuu.vo.OrderItemVO;
|
|
||||||
import net.jieyuu.vo.PayInfoVO;
|
|
||||||
import net.jieyuu.vo.ProductOrderAddressVO;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -454,4 +451,54 @@ public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, Pro
|
|||||||
|
|
||||||
return JsonData.buildResult(BizCodeEnum.PAY_ORDER_CALLBACK_NOT_SUCCESS);
|
return JsonData.buildResult(BizCodeEnum.PAY_ORDER_CALLBACK_NOT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询订单列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
* @param state
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> page(int page, int size, String state) {
|
||||||
|
LoginUser loginUser = LoginInterceptor.threadLocal.get();
|
||||||
|
|
||||||
|
Page<ProductOrderDO> pageInfo = new Page<>(page, size);
|
||||||
|
IPage<ProductOrderDO> orderDOPage = null;
|
||||||
|
if (StringUtils.isBlank(state)) {
|
||||||
|
orderDOPage = productOrderMapper.selectPage(pageInfo, new QueryWrapper<ProductOrderDO>().eq("user_id", loginUser.getId()));
|
||||||
|
} else {
|
||||||
|
orderDOPage = productOrderMapper.selectPage(pageInfo, new QueryWrapper<ProductOrderDO>().eq("user_id", loginUser.getId()).eq("state", state));
|
||||||
|
}
|
||||||
|
// 获取订单列表
|
||||||
|
List<ProductOrderDO> productOrderDOList = orderDOPage.getRecords();
|
||||||
|
|
||||||
|
List<ProductOrderVO> productOrderVOList = productOrderDOList.stream().map(orderDO -> {
|
||||||
|
|
||||||
|
// 查询订单商品项
|
||||||
|
List<ProductOrderItemDO> itemDOList = productOrderItemMapper.selectList(new QueryWrapper<ProductOrderItemDO>().eq("product_order_id", orderDO.getId()));
|
||||||
|
|
||||||
|
// 将商品项DO转换为VO
|
||||||
|
List<OrderItemVO> itemVOList = itemDOList.stream().map(item -> {
|
||||||
|
OrderItemVO itemVO = new OrderItemVO();
|
||||||
|
BeanUtils.copyProperties(item, itemVO);
|
||||||
|
return itemVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
ProductOrderVO productOrderVO = new ProductOrderVO();
|
||||||
|
BeanUtils.copyProperties(orderDO, productOrderVO);
|
||||||
|
productOrderVO.setOrderItemList(itemVOList);
|
||||||
|
|
||||||
|
return productOrderVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
HashMap<String, Object> pageMap = new HashMap<>();
|
||||||
|
|
||||||
|
pageMap.put("total_record", orderDOPage.getTotal());
|
||||||
|
pageMap.put("total_page" , orderDOPage.getPages());
|
||||||
|
pageMap.put("current_data", productOrderVOList);
|
||||||
|
|
||||||
|
|
||||||
|
return pageMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
package net.jieyuu.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProductOrderVO {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单唯一标识
|
||||||
|
*/
|
||||||
|
private String outTradeNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NEW 未支付订单,PAY已经支付订单,CANCEL超时取消订单
|
||||||
|
*/
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单生成时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单总金额
|
||||||
|
*/
|
||||||
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单实际支付价格
|
||||||
|
*/
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付类型,微信-银行-支付宝
|
||||||
|
*/
|
||||||
|
private String payType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昵称
|
||||||
|
*/
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头像
|
||||||
|
*/
|
||||||
|
private String headImg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0表示未删除,1表示已经删除
|
||||||
|
*/
|
||||||
|
private Integer del;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单类型 DAILY普通单,PROMOTION促销订单
|
||||||
|
*/
|
||||||
|
private String orderType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址 json存储
|
||||||
|
*/
|
||||||
|
private String receiverAddress;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单项
|
||||||
|
*/
|
||||||
|
private List<OrderItemVO> orderItemList;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user