|
@@ -8,6 +8,7 @@ import com.caimei365.commodity.model.ResponseJson;
|
|
|
import com.caimei365.commodity.model.po.ProductDetailInfoPo;
|
|
|
import com.caimei365.commodity.model.po.ProductImagePo;
|
|
|
import com.caimei365.commodity.model.po.ProductParameterPo;
|
|
|
+import com.caimei365.commodity.model.search.ProductListVo;
|
|
|
import com.caimei365.commodity.model.vo.*;
|
|
|
import com.caimei365.commodity.service.PageService;
|
|
|
import com.caimei365.commodity.utils.AppletsLinkUtil;
|
|
@@ -366,6 +367,82 @@ public class PageServiceImpl implements PageService {
|
|
|
return ResponseJson.success(equipment);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 商品详情页-图片
|
|
|
+ *
|
|
|
+ * @param productId 商品Id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<List<String>> getProductDetailImages(Integer productId) {
|
|
|
+ if (productId == null) {
|
|
|
+ return ResponseJson.error("参数错误:商品Id不能为空!", null);
|
|
|
+ }
|
|
|
+ List<ProductImagePo> imageList = shopMapper.getProductImages(productId);
|
|
|
+ List<String> newList = new ArrayList<>();
|
|
|
+ if (imageList.size() > 0) {
|
|
|
+ // 设置老图片路径
|
|
|
+ imageList.forEach(image -> {
|
|
|
+ newList.add(ImageUtils.getImageURL("product", image.getImage(), 0, domain));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return ResponseJson.success(newList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品详情页-相关参数
|
|
|
+ *
|
|
|
+ * @param productId 商品Id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<List<ProductParameterPo>> getProductParameters(Integer productId) {
|
|
|
+ if (productId == null) {
|
|
|
+ return ResponseJson.error("参数错误:商品Id不能为空!", null);
|
|
|
+ }
|
|
|
+ List<ProductParameterPo> parametersList = shopMapper.getProductParameters(productId);
|
|
|
+ return ResponseJson.success(parametersList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品详情页-相关推荐
|
|
|
+ *
|
|
|
+ * @param productId 商品Id
|
|
|
+ * @param recommendType 相关推荐类型: 0自动选择, 1手动推荐
|
|
|
+ * @param userId 用户Id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<List<ProductListVo>> getProductDetailRecommends(Integer productId, Integer recommendType, Integer userId) {
|
|
|
+ // 根据用户Id查询用户身份
|
|
|
+ Integer identity = 0;
|
|
|
+ if (null != userId) {
|
|
|
+ identity = priceMapper.getIdentityByUserId(userId);
|
|
|
+ }
|
|
|
+ List<ProductListVo> list = null;
|
|
|
+ //相关推荐类型 0自动选择; 1手动推荐
|
|
|
+ if (1 == recommendType) {
|
|
|
+ list = pageMapper.getProductRecommendsById(productId);
|
|
|
+ } else {
|
|
|
+ list = pageMapper.getAutoProductRecommends(productId);
|
|
|
+ }
|
|
|
+ //使用迭代器判断删除列表中的不满足条件的商品
|
|
|
+ Iterator<ProductListVo> iterator=list.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ //多线程情况下加锁
|
|
|
+ synchronized (list){
|
|
|
+ ProductListVo product = iterator.next();
|
|
|
+ // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
|
|
|
+ // visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
|
|
|
+ boolean passFlag =identity ==1 || identity == 2 || product.getVisibility()==3 || (identity == 4 && product.getVisibility()==2);
|
|
|
+ if(!passFlag){
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ // 设置 图片路径
|
|
|
+ product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseJson.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置跳转参数
|
|
|
* @param floorContent FloorContentVo
|