用户订单列表
用户订单各状态下数量
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.service.BuyOrderService;
|
||||
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -8,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@@ -25,4 +26,17 @@ public class BuyOrderController {
|
||||
return R.ok().put("data",stringObjectMap);
|
||||
}
|
||||
|
||||
//用户订单列表
|
||||
@RequestMapping("/buyOrderList")
|
||||
public R buyOrderList(@RequestBody Map params){
|
||||
List<BuyOrder> list = buyOrderService.buyOrderList(params);
|
||||
return R.ok().put("data",list);
|
||||
}
|
||||
|
||||
//用户订单各状态下数量
|
||||
@RequestMapping("/getBuyOrderNumByStatus")
|
||||
public R getBuyOrderNumByStatus(@RequestBody Map params){
|
||||
List<Map<String,Object>> list = buyOrderService.getBuyOrderNumByStatus(params);
|
||||
return R.ok().put("data",list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,10 @@ public class BuyOrder implements Serializable {
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 订单来源,0疯子读书1国学众妙之门2医学吴门医述
|
||||
*/
|
||||
private Integer come;
|
||||
/**
|
||||
* 支付方式 1微信,2支付宝,3ios内购 ,4虚拟币
|
||||
*/
|
||||
|
||||
@@ -3,10 +3,14 @@ package com.peanut.modules.common.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BuyOrderService extends IService<BuyOrder> {
|
||||
|
||||
Map<String,Object> initPrepareOrder(PrepareOrderDto prepareOrderDto);
|
||||
|
||||
List<BuyOrder> buyOrderList(Map params);
|
||||
|
||||
List<Map<String,Object>> getBuyOrderNumByStatus(Map params);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BuyOrderDao;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
import com.peanut.modules.common.dao.ShopProductDao;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.BuyOrderService;
|
||||
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||
import com.peanut.modules.common.vo.UserBaseVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonBuyOrderService")
|
||||
@@ -26,7 +26,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
@Autowired
|
||||
private BuyOrderDao buyOrderDao;
|
||||
@Autowired
|
||||
private BuyOrderProductDao buyOrderProductDao;
|
||||
@Autowired
|
||||
private ShopProductDao shopProductDao;
|
||||
@Autowired
|
||||
private ExpressOrderDao expressOrderDao;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> initPrepareOrder(PrepareOrderDto prepareOrderDto) {
|
||||
@@ -52,4 +56,53 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BuyOrder> buyOrderList(Map params) {
|
||||
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrder::getUserId,params.get("userId"));
|
||||
wrapper.eq(BuyOrder::getCome,params.get("come"));
|
||||
if(StringUtils.isEmpty(params.get("orderStatus").toString())){
|
||||
Integer[] sts = {0,1,2,3};
|
||||
wrapper.in(BuyOrder::getOrderStatus,sts);
|
||||
}else{
|
||||
wrapper.eq(BuyOrder::getOrderStatus,params.get("orderStatus").toString());
|
||||
}
|
||||
wrapper.orderByDesc(BuyOrder::getCreateTime);
|
||||
List<BuyOrder> buyOrderList = this.getBaseMapper().selectList(wrapper);
|
||||
if (buyOrderList.size() > 0){
|
||||
for(BuyOrder b : buyOrderList){
|
||||
b.setUser(userDao.selectById(b.getUserId()));
|
||||
//组装商品
|
||||
List<BuyOrderProduct> buyOrderProducts = buyOrderProductDao.selectList(
|
||||
new LambdaQueryWrapper<BuyOrderProduct>().eq(BuyOrderProduct::getOrderId, b.getOrderId()));
|
||||
if (buyOrderProducts.size() > 0) {
|
||||
for (BuyOrderProduct bb : buyOrderProducts){
|
||||
bb.setProduct(shopProductDao.selectById(bb.getProductId()));
|
||||
}
|
||||
b.setProductList(buyOrderProducts);
|
||||
b.setTimestamp(b.getCreateTime().getTime()/1000);
|
||||
//获取包裹信息
|
||||
List<Integer> collect = buyOrderProductDao.selectList(new LambdaQueryWrapper<BuyOrderProduct>().eq(BuyOrderProduct::getOrderId, b.getOrderId()).gt(BuyOrderProduct::getExpressOrderId, 0))
|
||||
.stream().map(BuyOrderProduct::getExpressOrderId).collect(Collectors.toList());
|
||||
if(collect.size()>0){
|
||||
List<ExpressOrder> expressOrders = expressOrderDao.selectList(new LambdaQueryWrapper<ExpressOrder>().in(ExpressOrder::getId, collect));
|
||||
b.setExpressList(expressOrders);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return buyOrderList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String,Object>> getBuyOrderNumByStatus(Map params) {
|
||||
MPJLambdaWrapper<BuyOrder> wrapper = new MPJLambdaWrapper<BuyOrder>();
|
||||
wrapper.eq(BuyOrder::getUserId,params.get("userId"));
|
||||
wrapper.select(BuyOrder::getOrderStatus);
|
||||
wrapper.select("count(1) as num");
|
||||
wrapper.groupBy(BuyOrder::getOrderStatus);
|
||||
List<Map<String,Object>> buyOrder = buyOrderDao.selectMaps(wrapper);
|
||||
return buyOrder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user