|
@@ -41,25 +41,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
public ResponseJson<PageInfo<ProductVo>> productList(String name, Integer userId, Integer pageNum, Integer pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<ProductVo> productList = productMapper.findProductList(name);
|
|
|
- productList.forEach((product) -> {
|
|
|
- product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
- Integer activityId = productMapper.findActivityByProductId(product.getProductId());
|
|
|
- if (activityId != null && activityId > 0) {
|
|
|
- product.setActiveStatus(1);
|
|
|
- //活动阶梯
|
|
|
- List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
|
|
|
- if (ladderList != null && ladderList.size() > 0) {
|
|
|
- product.setPrice(ladderList.get(0).getBuyPrice());
|
|
|
- }
|
|
|
- }
|
|
|
- //税费
|
|
|
- boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
|
|
|
- if (addTaxFlag) {
|
|
|
- BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
|
|
|
- BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
|
|
|
- product.setPrice(price);
|
|
|
- }
|
|
|
- });
|
|
|
+ productList.forEach(product -> setProductDetails(product, userId));
|
|
|
PageInfo<ProductVo> pageInfo = new PageInfo<>(productList);
|
|
|
|
|
|
//搜索关键字
|
|
@@ -80,7 +62,42 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<ProductVo> productDetails(Integer productId) {
|
|
|
+ public void setProductDetails(ProductVo product, Integer userId) {
|
|
|
+ product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
+ Integer activityId = productMapper.findActivityByProductId(product.getProductId());
|
|
|
+ if (activityId != null && activityId > 0) {
|
|
|
+ product.setActiveStatus(1);
|
|
|
+ //活动阶梯
|
|
|
+ List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
|
|
|
+ if (ladderList != null && ladderList.size() > 0) {
|
|
|
+ product.setPrice(ladderList.get(0).getBuyPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer discount = productMapper.findProductDiscount(product.getProductId(), userId);
|
|
|
+ if (null != discount && discount > 0) {
|
|
|
+ product.setPrice(MathUtil.div(MathUtil.mul(product.getPrice(), discount), 100));
|
|
|
+ }
|
|
|
+ //税费
|
|
|
+ boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
|
|
|
+ if (addTaxFlag) {
|
|
|
+ BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
|
|
|
+ BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
|
|
|
+ product.setPrice(price);
|
|
|
+ }
|
|
|
+ // 正在进行的全商城商品优惠券数量
|
|
|
+ Integer allCount = productMapper.findAllProductCouponCount();
|
|
|
+ if (allCount > 0) {
|
|
|
+ product.setCouponsLogo(true);
|
|
|
+ }
|
|
|
+ // 该商品参与的正在进行的部分商品优惠券
|
|
|
+ Integer partCount = productMapper.findPartProductCounponCount(product.getProductId());
|
|
|
+ if (partCount > 0) {
|
|
|
+ product.setCouponsLogo(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<ProductVo> productDetails(Integer productId, Integer userId) {
|
|
|
ProductDetailsVo product = productMapper.findProductByProductId(productId);
|
|
|
if (product == null) {
|
|
|
//商品不存在
|
|
@@ -101,7 +118,6 @@ public class ProductServiceImpl implements ProductService {
|
|
|
split = list.toArray(new String[list.size()]);
|
|
|
}
|
|
|
product.setTagsList(split);
|
|
|
- product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
//商品图片
|
|
|
List<String> list = new ArrayList<>();
|
|
|
List<String> imageList = productMapper.findProductImages(product.getProductId());
|
|
@@ -124,30 +140,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
//相关参数
|
|
|
List<RelatedParametersVo> parametersList = productMapper.findParameters(product.getProductId());
|
|
|
product.setParametersList(parametersList);
|
|
|
-
|
|
|
- //税费
|
|
|
- boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
|
|
|
- Integer activityId = productMapper.findActivityByProductId(product.getProductId());
|
|
|
- if (activityId != null && activityId > 0) {
|
|
|
- product.setActiveStatus(1);
|
|
|
- //活动阶梯
|
|
|
- List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
|
|
|
- if (ladderList != null && ladderList.size() > 0) {
|
|
|
- product.setPrice(ladderList.get(0).getBuyPrice());
|
|
|
- for (ActivityLadderVo ladder : ladderList) {
|
|
|
- if (addTaxFlag) {
|
|
|
- BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
|
|
|
- ladder.setBuyPrice(MathUtil.add(addedValueTax, ladder.getBuyPrice()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- product.setLadderList(ladderList);
|
|
|
- }
|
|
|
- if (addTaxFlag) {
|
|
|
- BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
|
|
|
- BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
|
|
|
- product.setPrice(price);
|
|
|
- }
|
|
|
+ setProductDetails(product, userId);
|
|
|
return ResponseJson.success(product);
|
|
|
}
|
|
|
|
|
@@ -182,8 +175,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<ProductVo> productList = productMapper.findActivityProduct(userId, activityId);
|
|
|
productList.forEach(product -> {
|
|
|
- product.setActiveStatus(1);
|
|
|
- product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
+ setProductDetails(product, userId);
|
|
|
});
|
|
|
PageInfo<ProductVo> pageInfo = new PageInfo<>(productList);
|
|
|
map.put("image", image);
|
|
@@ -193,57 +185,21 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<List<FloorVo>> productFloor() {
|
|
|
+ public ResponseJson<List<FloorVo>> productFloor(Integer userId) {
|
|
|
List<FloorVo> floorList = productMapper.findAllFloor();
|
|
|
- floorList.forEach(floor->{
|
|
|
+ floorList.forEach(floor -> {
|
|
|
List<ProductVo> productList = productMapper.findFloorProductList(floor.getFloorId(), null, 6);
|
|
|
- productList.forEach((product) -> {
|
|
|
- product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
- Integer activityId = productMapper.findActivityByProductId(product.getProductId());
|
|
|
- if (activityId != null && activityId > 0) {
|
|
|
- product.setActiveStatus(1);
|
|
|
- //活动阶梯
|
|
|
- List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
|
|
|
- if (ladderList != null && ladderList.size() > 0) {
|
|
|
- product.setPrice(ladderList.get(0).getBuyPrice());
|
|
|
- }
|
|
|
- }
|
|
|
- //税费
|
|
|
- boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
|
|
|
- if (addTaxFlag) {
|
|
|
- BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
|
|
|
- BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
|
|
|
- product.setPrice(price);
|
|
|
- }
|
|
|
- });
|
|
|
+ productList.forEach(product -> setProductDetails(product, userId));
|
|
|
floor.setProductList(productList);
|
|
|
});
|
|
|
return ResponseJson.success(floorList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<PageInfo<ProductVo>> floorDetail(Integer floorId, String productName, Integer pageNum, Integer pageSize) {
|
|
|
+ public ResponseJson<PageInfo<ProductVo>> floorDetail(Integer floorId, Integer userId, String productName, Integer pageNum, Integer pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<ProductVo> productList = productMapper.findFloorProductList(floorId, productName, null);
|
|
|
- productList.forEach((product) -> {
|
|
|
- product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
|
|
|
- Integer activityId = productMapper.findActivityByProductId(product.getProductId());
|
|
|
- if (activityId != null && activityId > 0) {
|
|
|
- product.setActiveStatus(1);
|
|
|
- //活动阶梯
|
|
|
- List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
|
|
|
- if (ladderList != null && ladderList.size() > 0) {
|
|
|
- product.setPrice(ladderList.get(0).getBuyPrice());
|
|
|
- }
|
|
|
- }
|
|
|
- //税费
|
|
|
- boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
|
|
|
- if (addTaxFlag) {
|
|
|
- BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
|
|
|
- BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
|
|
|
- product.setPrice(price);
|
|
|
- }
|
|
|
- });
|
|
|
+ productList.forEach(product -> setProductDetails(product, userId));
|
|
|
PageInfo<ProductVo> pageInfo = new PageInfo<>(productList);
|
|
|
return ResponseJson.success(pageInfo);
|
|
|
}
|