提交代码

dev
胡锐 6 months ago
parent 882250b483
commit 24f0edf86b
  1. 11
      order/src/main/java/com/order/controller/OrderController.java
  2. 9
      service/src/main/java/com/hfkj/common/utils/PageUtil.java
  3. 7
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  4. 24
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java

@ -7,6 +7,7 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.ResponseData;
@ -29,6 +30,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -143,7 +145,14 @@ public class OrderController {
param.put("orderStatus", orderStatus);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(orderService.getUserOrderList(param)));
PageInfo<BsOrder> pageInfo = new PageInfo<>(orderService.getOrderList(param));
PageInfo<OrderModel> objectPageInfo = PageUtil.PageInfo2PageInfoVo(pageInfo);
List<OrderModel> orderModelList = new ArrayList<>();
for (BsOrder order : pageInfo.getList()) {
orderModelList.add(orderService.getDetail(order.getOrderNo()));
}
objectPageInfo.setList(orderModelList);
return ResponseMsgUtil.success(objectPageInfo);
} catch (Exception e) {
log.error("error!",e);

@ -1,5 +1,6 @@
package com.hfkj.common.utils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import java.util.List;
@ -95,4 +96,12 @@ public class PageUtil {
return pageInfo;
}
public static <P, V> PageInfo<V> PageInfo2PageInfoVo(PageInfo<P> pageInfoPo) {
// 创建Page对象,实际上是⼀个ArrayList类型的集合
Page<V> page = new Page<>(pageInfoPo.getPageNum(), pageInfoPo.getPageSize());
page.setTotal(pageInfoPo.getTotal());
return new PageInfo<>(page);
}
}

@ -76,11 +76,4 @@ public interface BsOrderService {
*/
List<BsOrder> getOrderList(Map<String,Object> param);
/**
* 查询用户订单列表
* @param param
* @return
*/
List<OrderModel> getUserOrderList(Map<String,Object> param);
}

@ -425,8 +425,11 @@ public class BsOrderServiceImpl implements BsOrderService {
BsOrderExample example = new BsOrderExample();
BsOrderExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(MapUtils.getString(param, "order"))) {
criteria.andOrderNoLike("%"+MapUtils.getString(param, "order")+"%");
if (MapUtils.getLong(param, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "orderNo"))) {
criteria.andOrderNoLike("%"+MapUtils.getString(param, "orderNo")+"%");
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "userPhone"))) {
criteria.andUserPhoneLike("%"+MapUtils.getString(param, "userPhone")+"%");
@ -469,21 +472,4 @@ public class BsOrderServiceImpl implements BsOrderService {
return orderMapper.selectByExample(example);
}
@Override
public List<OrderModel> getUserOrderList(Map<String, Object> param) {
BsOrderExample example = new BsOrderExample();
BsOrderExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(MapUtils.getString(param, "order"))) {
criteria.andOrderNoLike("%"+MapUtils.getString(param, "order")+"%");
}
example.setOrderByClause("create_time desc");
List<OrderModel> orderModelList = new ArrayList<>();
List<BsOrder> orderList = orderMapper.selectByExample(example);
for (BsOrder order : orderList) {
orderModelList.add(getDetail(order.getOrderNo()));
}
return orderModelList;
}
}

Loading…
Cancel
Save