|
@@ -1,21 +1,15 @@
|
|
|
package com.caimei.www.service.impl;
|
|
|
|
|
|
-import com.caimei.www.pojo.JsonModel;
|
|
|
import com.caimei.www.mapper.ProductDao;
|
|
|
-import com.caimei.www.pojo.order.CartItem;
|
|
|
import com.caimei.www.pojo.page.ProductDetail;
|
|
|
-import com.caimei.www.pojo.page.ProductList;
|
|
|
-import com.caimei.www.pojo.page.Parameter;
|
|
|
-import com.caimei.www.service.CommonServiceUtil;
|
|
|
import com.caimei.www.service.ProductService;
|
|
|
-import com.caimei.www.utils.ImageUtil;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -30,8 +24,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
private String domain;
|
|
|
@Resource
|
|
|
private ProductDao productDao;
|
|
|
- @Resource
|
|
|
- private CommonServiceUtil commonServiceUtil;
|
|
|
+
|
|
|
/**
|
|
|
* 根据商品Id获取详情
|
|
|
*
|
|
@@ -59,68 +52,4 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return product;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 详情-相关推荐
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public JsonModel<List<ProductList>> getProductDetailRecommends(Integer productId, Integer recommendType) {
|
|
|
- List<ProductList> list = null;
|
|
|
- //相关推荐类型 0自动选择; 1手动推荐
|
|
|
- if (1 == recommendType) {
|
|
|
- list = productDao.getProductRecommendsById(productId);
|
|
|
- } else {
|
|
|
- list = productDao.getAutoProductRecommends(productId);
|
|
|
- }
|
|
|
- return JsonModel.success(list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 详情-相关参数
|
|
|
- *
|
|
|
- * @param productId
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public JsonModel<List<Parameter>> getProductParameters(Integer productId) {
|
|
|
- if (productId == null) { return JsonModel.error("参数异常", null);}
|
|
|
- List<Parameter> list = productDao.getProductParameters(productId);
|
|
|
- return JsonModel.success(list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 详情-图片
|
|
|
- *
|
|
|
- * @param productId
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public JsonModel<List<String>> getProductDetailImages(Integer productId) {
|
|
|
- if (productId == null) { return JsonModel.error("参数异常", null);}
|
|
|
- List<String> list = productDao.getProductDetailImages(productId);
|
|
|
- if (list.size() > 0) {
|
|
|
- // 设置价格等级 及 老图片路径
|
|
|
- list.forEach(image -> {
|
|
|
- image = ImageUtil.getImageURL("product", image, 0, domain);
|
|
|
- });
|
|
|
- }
|
|
|
- return JsonModel.success(list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 详情-价格
|
|
|
- *
|
|
|
- * @param productId
|
|
|
- * @param userId
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public JsonModel<CartItem> getProductPrice(Integer productId, Integer userId) {
|
|
|
- if (productId == null || userId == null || userId == 0) { return JsonModel.error("参数异常", null);}
|
|
|
- CartItem priceItem = productDao.getPriceItemById(productId);
|
|
|
- // 设置商品价格
|
|
|
- commonServiceUtil.setCartItemPrice(priceItem, userId);
|
|
|
- return JsonModel.success(priceItem);
|
|
|
- }
|
|
|
}
|