diff --git a/nxhs-common/src/main/java/cc/yunxi/common/domain/LambdaQueryWrapperX.java b/nxhs-common/src/main/java/cc/yunxi/common/domain/LambdaQueryWrapperX.java index efaf3c3..69c259d 100644 --- a/nxhs-common/src/main/java/cc/yunxi/common/domain/LambdaQueryWrapperX.java +++ b/nxhs-common/src/main/java/cc/yunxi/common/domain/LambdaQueryWrapperX.java @@ -38,6 +38,20 @@ public class LambdaQueryWrapperX extends LambdaQueryWrapper { return this; } + public LambdaQueryWrapperX existsIfPresent(String existsSql, Collection values) { + if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) { + return (LambdaQueryWrapperX) super.exists(existsSql, values); + } + return this; + } + + public LambdaQueryWrapperX existsIfPresent(String existsSql, Object... values) { + if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) { + return (LambdaQueryWrapperX) super.exists(existsSql, values); + } + return this; + } + public LambdaQueryWrapperX eqIfPresent(SFunction column, Object val) { if (ObjectUtil.isNotEmpty(val)) { return (LambdaQueryWrapperX) super.eq(column, val); diff --git a/nxhs-service/src/main/java/cc/yunxi/mapper/ProductMapper.java b/nxhs-service/src/main/java/cc/yunxi/mapper/ProductMapper.java index f123d74..8b63964 100644 --- a/nxhs-service/src/main/java/cc/yunxi/mapper/ProductMapper.java +++ b/nxhs-service/src/main/java/cc/yunxi/mapper/ProductMapper.java @@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* 废品 Mapper 接口 @@ -24,6 +26,6 @@ public interface ProductMapper extends BaseMapper { * @param productCode * @return Price */ - String getLatestPriceByProductCode(@Param("productCode") String productCode); + List getStationsByProductCode(@Param("productCode") String productCode); } diff --git a/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleOrderProductMapper.java b/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleOrderProductMapper.java index cbd7f70..311d763 100644 --- a/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleOrderProductMapper.java +++ b/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleOrderProductMapper.java @@ -20,8 +20,10 @@ public interface RecycleOrderProductMapper extends BaseMapper recycleOrderProductVOList = orderFinishVO.getOrderDetails(); LocalDateTime now = LocalDateTime.now(); + String enterpriseId = recycleOrder.getCompanyId(); recycleOrderProductVOList.forEach(rp -> { rp.setUpdateTime(now); - PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId()); + PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId(), enterpriseId); log.info("latest price product: {}", latestPriceProduct); if (ObjectUtil.isEmpty(latestPriceProduct)) { throw new BusinessLogicException("产品价格信息未公布,请联系商户!"); @@ -462,11 +464,12 @@ public class RecycleOrderServiceImpl extends ServiceImpl recycleOrderProductVOList = tmOrderFinishVO.getOrderDetails(); List recycleOrderProducts = BeanUtils.copyList(recycleOrderProductVOList, RecycleOrderProduct.class); LocalDateTime now = LocalDateTime.now(); + String enterpriseId = recycleOrder.getCompanyId(); recycleOrderProducts.forEach(rp -> { rp.setRecycleOrderId(orderId); rp.setCreatorTime(now); rp.setUpdateTime(now); - PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId()); + PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId(), enterpriseId); log.info("latest price product: {}", latestPriceProduct); if (ObjectUtil.isEmpty(latestPriceProduct)) { throw new BusinessLogicException("产品价格信息未公布,请联系商户!"); diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java index 41edb64..6567ce3 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java @@ -57,18 +57,18 @@ public class RecycleStationServiceImpl extends ServiceImpl stationList = productMapper.getStationsByProductCode(productCode); + if (ObjectUtil.isEmpty(stationList)) { return new Page<>(); } else { - List stationPriceList = new LambdaQueryChainWrapper<>(recycleStationPriceMapper) - .eq(RecycleStationPrice::getPriceId, priceId).select(RecycleStationPrice::getRecycleStationId).list(); - List stationIds = new ArrayList<>(); - for (RecycleStationPrice recycleStationPrice : stationPriceList) { - String recycleStationId = recycleStationPrice.getRecycleStationId(); - stationIds.add(recycleStationId); - } - wrapperX.inIfPresent(RecycleStation::getId, stationIds); +// List stationPriceList = new LambdaQueryChainWrapper<>(recycleStationPriceMapper) +// .eq(RecycleStationPrice::getPriceId, priceId).select(RecycleStationPrice::getRecycleStationId).list(); +// List stationIds = new ArrayList<>(); +// for (RecycleStationPrice recycleStationPrice : stationPriceList) { +// String recycleStationId = recycleStationPrice.getRecycleStationId(); +// stationIds.add(recycleStationId); +// } + wrapperX.inIfPresent(RecycleStation::getId, stationList); } } wrapperX.eqIfPresent(RecycleStation::getStationName, recycleStationQuery.getStationName()); diff --git a/nxhs-service/src/main/resources/mapper/ProductMapper.xml b/nxhs-service/src/main/resources/mapper/ProductMapper.xml index 4672fd7..20bdd1f 100644 --- a/nxhs-service/src/main/resources/mapper/ProductMapper.xml +++ b/nxhs-service/src/main/resources/mapper/ProductMapper.xml @@ -2,20 +2,22 @@ - - SELECT - c.id +-- c.id, + d.recycle_id FROM nx_product a INNER JOIN nx_price_product b ON a.id = b.product_id INNER JOIN nx_price c ON b.price_id = c.id AND c.`status` = 1 + INNER JOIN nx_price_recycle d ON c.id = d.price_id WHERE a.`code` = #{productCode} ORDER BY c.f_creator_time DESC - LIMIT 1; + LIMIT 100; diff --git a/nxhs-service/src/main/resources/mapper/RecycleOrderProductMapper.xml b/nxhs-service/src/main/resources/mapper/RecycleOrderProductMapper.xml index 1ee1f7d..a27e313 100644 --- a/nxhs-service/src/main/resources/mapper/RecycleOrderProductMapper.xml +++ b/nxhs-service/src/main/resources/mapper/RecycleOrderProductMapper.xml @@ -2,7 +2,7 @@ - +