@@ -8,12 +8,15 @@ 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.github.yulichang.wrapper.MPJLambdaWrapper ;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper ;
import com.peanut.common.utils.PageUtils ;
import com.peanut.common.utils.Query ;
import com.peanut.config.Constants ;
import com.peanut.modules.book.dao.BuyOrderDao ;
import com.peanut.modules.book.dao.BuyOrderProductDao ;
import com.peanut.modules.book.dao.ExpressOrderDao ;
import com.peanut.modules.book.dao.ShopProductBookDao ;
import com.peanut.modules.book.entity.* ;
import com.peanut.modules.book.service.* ;
import com.peanut.modules.book.to.UserOrderDto ;
@@ -61,6 +64,9 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
@Autowired
ShopProductService shopProductService ;
@Autowired
private BookService bookService ;
@Autowired
private BuyOrderProductService buyOrderProductService ;
@@ -72,7 +78,13 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
@Autowired
private ExpressOrderDao expressOrderDao ;
@Autowired
private BuyOrderProductDao buyOrderProductDao ;
@Autowired
private ShopProductBookDao shopProductBookDao ;
@Autowired
private OssService ossService ;
@Autowired
private ShopProductBookService shopProductBookService ;
protected Logger logger = LoggerFactory . getLogger ( BuyOrderServiceImpl . class ) ;
@@ -404,7 +416,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
ShopProduct product = shopProductService . getById ( productId ) ;
//定义快递商品
ExpressCommodity commodity = new ExpressCommodity ( ) ;
commodity . setGoodsName ( product . getProductName ( ) ) ;
commodity . setGoodsName ( product . getProductName ( ) + " × " + buyOrderProduct . getQuantity ( ) ) ;
commodity . setGoodsquantity ( buyOrderProduct . getQuantity ( ) ) ;
commodity . setGoodsWeight ( ( product . getWeight ( ) . doubleValue ( ) ) / 1000 ) ;
totalWeight = totalWeight . add (
@@ -607,6 +619,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
goodsResponseVo . setProductImage ( shopProduct . getProductImages ( ) ) ;
goodsResponseVo . setProductPrice ( shopProduct . getPrice ( ) ) ;
goodsResponseVo . setQuantity ( buyOrderProduct . getQuantity ( ) ) ;
goodsResponseVo . setProductId ( shopProduct . getProductId ( ) ) ;
QueryWrapper < ExpressOrder > expressOrderQueryWrapper = new QueryWrapper < > ( ) ;
expressOrderQueryWrapper . eq ( " id " , buyOrderProduct . getExpressOrderId ( ) ) ;
ExpressOrder expressOrder = expressOrderService . getOne ( expressOrderQueryWrapper ) ;
@@ -617,6 +630,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
expressResponseVo . setPrintTemplate ( expressOrder . getPrintTemplate ( ) ) ;
}
goodsResponseVo . setExpressInfo ( expressResponseVo ) ;
//设置商品对应的具体书
List < BookEntity > bookByProductId = shopProductBookService . getBookByProductId ( buyOrderProduct . getProductId ( ) ) ;
goodsResponseVo . setBooks ( bookByProductId ) ;
goodsResponseVoList . add ( goodsResponseVo ) ;
}
responseVo . setGoodsList ( goodsResponseVoList ) ;
@@ -628,6 +646,25 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
List < Integer > collect = buyOrderProductService . getBaseMapper ( ) . selectList ( b_wrapper ) . stream ( ) . map ( BuyOrderProduct : : getExpressOrderId ) . collect ( Collectors . toList ( ) ) ;
if ( collect . size ( ) > 0 ) {
List < ExpressOrder > expressOrders = expressOrderService . getBaseMapper ( ) . selectList ( new LambdaQueryWrapper < ExpressOrder > ( ) . in ( ExpressOrder : : getId , collect ) ) ;
for ( ExpressOrder e : expressOrders ) {
MPJLambdaWrapper < BuyOrderProduct > buyOrderProductMPJLambdaWrapper = new MPJLambdaWrapper < > ( ) ;
buyOrderProductMPJLambdaWrapper . selectAll ( ShopProduct . class ) ;
buyOrderProductMPJLambdaWrapper . select ( BuyOrderProduct : : getQuantity ) ;
buyOrderProductMPJLambdaWrapper . select ( BuyOrder : : getOrderSn ) ;
buyOrderProductMPJLambdaWrapper . leftJoin ( ShopProduct . class , ShopProduct : : getProductId , BuyOrderProduct : : getProductId ) ;
buyOrderProductMPJLambdaWrapper . leftJoin ( BuyOrder . class , BuyOrder : : getOrderId , BuyOrderProduct : : getOrderId ) ;
buyOrderProductMPJLambdaWrapper . eq ( BuyOrderProduct : : getExpressOrderId , e . getId ( ) ) ;
List < ShopProduct > shopProducts = buyOrderProductDao . selectJoinList ( ShopProduct . class , buyOrderProductMPJLambdaWrapper ) ;
for ( ShopProduct s : shopProducts ) {
MPJLambdaWrapper < ShopProductBookEntity > shopProductBookEntityMPJLambdaWrapper = new MPJLambdaWrapper < > ( ) ;
shopProductBookEntityMPJLambdaWrapper . selectAll ( BookEntity . class ) ;
shopProductBookEntityMPJLambdaWrapper . leftJoin ( BookEntity . class , BookEntity : : getId , ShopProductBookEntity : : getBookId ) ;
shopProductBookEntityMPJLambdaWrapper . eq ( ShopProductBookEntity : : getProductId , s . getProductId ( ) ) ;
List < BookEntity > bookEntities = shopProductBookDao . selectJoinList ( BookEntity . class , shopProductBookEntityMPJLambdaWrapper ) ;
s . setBooks ( bookEntities ) ;
}
e . setProducts ( shopProducts ) ;
}
responseVo . setExpressOrders ( expressOrders ) ;
}