|
@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -33,8 +34,14 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
|
|
|
@Override
|
|
|
public IPage<ProductVO> page(ProductListDTO query) {
|
|
|
- Page<Product> productPage = this.page(new Page<>(query.getPage(), query.getSize()), new LambdaQueryWrapper<>());
|
|
|
+ Page<Product> productPage = this.page(new Page<>(query.getPage(), query.getSize()), new LambdaQueryWrapper<Product>()
|
|
|
+ .eq(Product::getAppId,query.getAppId()));
|
|
|
List<ProductVO> productVOS = JsonUtils.jsonStringToList(JsonUtils.getJsonString(productPage.getRecords()), ProductVO.class);
|
|
|
+ productVOS.forEach(productVO -> {
|
|
|
+ if (!ObjectUtils.isEmpty(productVO.getActivityId())) {
|
|
|
+ productVO.setActivityInfo(activityService.getActivityInfoByActivityId(productVO.getActivityId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
Page<ProductVO> page = new Page<>(query.getPage(), query.getSize());
|
|
|
page.setRecords(productVOS);
|
|
|
return page;
|
|
@@ -42,21 +49,25 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
|
|
|
@Override
|
|
|
public ProductPriceVo getProductPrice(String productId, String userId) {
|
|
|
- ProductPriceVo productPriceVo = new ProductPriceVo();
|
|
|
- BeanUtils.copyProperties(this.baseMapper.selectOne(new LambdaQueryWrapper<Product>()
|
|
|
- .select(Product::getPrice, Product::getCnyPrice, Product::getPaddleProductId)
|
|
|
- .eq(Product::getId, productId)), productPriceVo);
|
|
|
+ Product product = this.baseMapper.selectOne(new LambdaQueryWrapper<Product>()
|
|
|
+ .select(Product::getPrice, Product::getCnyPrice, Product::getPaddleProductId,Product::getActivityId)
|
|
|
+ .eq(Product::getId, productId));
|
|
|
|
|
|
-// // 判断当前产品是否有活动 获取活动的最终价格
|
|
|
-// ActivityInfoVO activityInfo = activityService.getActivityInfoByProductId(productId);
|
|
|
-// if (!ObjectUtils.isEmpty(activityInfo)) {
|
|
|
-// // 判断是否是新用户专用
|
|
|
-// if (activityInfo.getActivityTypeId() == 1) {
|
|
|
-// // 判断当前用户是否是新用户
|
|
|
-// }else {
|
|
|
-// productPriceVo.setPrice(activityInfo.getFinalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
+ ProductPriceVo productPriceVo = new ProductPriceVo();
|
|
|
+ productPriceVo.setPaddleProductId(product.getPaddleProductId());
|
|
|
+ // 判断当前产品是否有活动 获取活动的最终价格
|
|
|
+ if (!ObjectUtils.isEmpty(product.getActivityId())){
|
|
|
+ ActivityInfoVO activityInfo = activityService.getActivityInfoByActivityId(product.getActivityId());
|
|
|
+ // 判断是否是新用户专用
|
|
|
+ if (activityInfo.getActivityType() == 1){
|
|
|
+ // TODO 判断当前用户是否是新用户
|
|
|
+ productPriceVo.setPrice(BigDecimal.ONE);
|
|
|
+ productPriceVo.setCnyPrice(BigDecimal.ONE);
|
|
|
+ }else {
|
|
|
+ productPriceVo.setPrice(activityInfo.getFinalPrice());
|
|
|
+ productPriceVo.setCnyPrice(activityInfo.getFinalCnyPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
return productPriceVo;
|
|
|
}
|
|
|
|