|
@@ -9,6 +9,7 @@ import com.caimei.www.pojo.JsonModel;
|
|
|
import com.caimei.www.pojo.baike.*;
|
|
|
import com.caimei.www.pojo.page.Parameter;
|
|
|
import com.caimei.www.pojo.page.ProductDetail;
|
|
|
+import com.caimei.www.pojo.page.ProductList;
|
|
|
import com.caimei.www.service.page.ProductService;
|
|
|
import com.caimei.www.utils.ImageUtil;
|
|
|
import com.caimei.www.utils.PriceUtil;
|
|
@@ -70,14 +71,14 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public JSONArray getTypeClassifyJson(Integer typeSort) {
|
|
|
- String dataUrl = coreServer+"/commodity/classify?typeSort="+typeSort+"&source=www";
|
|
|
+ String dataUrl = coreServer + "/commodity/classify?typeSort=" + typeSort + "&source=www";
|
|
|
try {
|
|
|
String classifyResult = RequestUtil.sendGet(dataUrl);
|
|
|
log.debug(classifyResult);
|
|
|
Map<String, Object> classifyMap = JSONObject.parseObject(classifyResult, Map.class);
|
|
|
return (JSONArray) classifyMap.get("data");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -89,14 +90,14 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String, Object> getTypeFloorJson(Integer pageId) {
|
|
|
- String dataUrl = coreServer+"/commodity/classify/product?pageId="+ pageId +"&source=1";
|
|
|
+ String dataUrl = coreServer + "/commodity/classify/product?pageId=" + pageId + "&source=1";
|
|
|
try {
|
|
|
String floorResult = RequestUtil.sendGet(dataUrl);
|
|
|
log.debug(floorResult);
|
|
|
Map<String, Object> floorMap = JSONObject.parseObject(floorResult, Map.class);
|
|
|
return JSONObject.parseObject(String.valueOf(floorMap.get("data")), Map.class);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -108,14 +109,14 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public JSONArray getBigTypeJson(Integer typeSort) {
|
|
|
- String dataUrl = coreServer+"/commodity/type/first?typeSort="+typeSort;
|
|
|
+ String dataUrl = coreServer + "/commodity/type/first?typeSort=" + typeSort;
|
|
|
try {
|
|
|
String classifyResult = RequestUtil.sendGet(dataUrl);
|
|
|
log.debug(classifyResult);
|
|
|
Map<String, Object> classifyMap = JSONObject.parseObject(classifyResult, Map.class);
|
|
|
return (JSONArray) classifyMap.get("data");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -127,14 +128,14 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public JSONArray getSmallTypeJson(Integer bigTypeId) {
|
|
|
- String dataUrl = coreServer+"/commodity/type/second?bigTypeId="+bigTypeId;
|
|
|
+ String dataUrl = coreServer + "/commodity/type/second?bigTypeId=" + bigTypeId;
|
|
|
try {
|
|
|
String classifyResult = RequestUtil.sendGet(dataUrl);
|
|
|
log.debug(classifyResult);
|
|
|
Map<String, Object> classifyMap = JSONObject.parseObject(classifyResult, Map.class);
|
|
|
return (JSONArray) classifyMap.get("data");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -147,14 +148,14 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public JSONArray getTinyTypeJson(Integer smallTypeId) {
|
|
|
- String dataUrl = coreServer+"/commodity/type/third?smallTypeId="+smallTypeId;
|
|
|
+ String dataUrl = coreServer + "/commodity/type/third?smallTypeId=" + smallTypeId;
|
|
|
try {
|
|
|
String classifyResult = RequestUtil.sendGet(dataUrl);
|
|
|
log.debug(classifyResult);
|
|
|
Map<String, Object> classifyMap = JSONObject.parseObject(classifyResult, Map.class);
|
|
|
return (JSONArray) classifyMap.get("data");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -166,7 +167,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public JSONObject getProductListJson(String params) {
|
|
|
- String dataUrl = coreServer+"/commodity/search/query/product/type"+params;
|
|
|
+ String dataUrl = coreServer + "/commodity/search/query/product/type" + params;
|
|
|
try {
|
|
|
String productResult = RequestUtil.sendGet(dataUrl);
|
|
|
log.debug(productResult);
|
|
@@ -174,7 +175,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
String data = (String) productMap.get("data");
|
|
|
return JSONObject.parseObject(data);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -188,7 +189,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
Map<String, Object> classifyMap = JSONObject.parseObject(classifyResult, Map.class);
|
|
|
return (JSONArray) classifyMap.get("data");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -202,7 +203,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
Map<String, Object> moreMap = JSONObject.parseObject(moreResult, Map.class);
|
|
|
return JSONObject.parseObject(String.valueOf(moreMap.get("data")), Map.class);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("try-catch:",e);
|
|
|
+ log.error("try-catch:", e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -216,9 +217,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
public List<String> getImages(Integer productId) {
|
|
|
List<String> productDetailImages = productDao.getProductDetailImages(productId);
|
|
|
List<String> strings = new ArrayList<>();
|
|
|
- if(null!=productDetailImages&&productDetailImages.size()>0){
|
|
|
- productDetailImages.forEach(p->{
|
|
|
- strings.add(ImageUtil.getImageURL("product",p,0,domain));
|
|
|
+ if (null != productDetailImages && productDetailImages.size() > 0) {
|
|
|
+ productDetailImages.forEach(p -> {
|
|
|
+ strings.add(ImageUtil.getImageURL("product", p, 0, domain));
|
|
|
});
|
|
|
}
|
|
|
return strings;
|
|
@@ -226,7 +227,26 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
@Override
|
|
|
public List<Parameter> getParams(Integer productId) {
|
|
|
- return productDao.getProductParameters(productId);
|
|
|
+ return productDao.getProductParameters(productId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ProductList> getProductLists(Integer productId) {
|
|
|
+ //取不到userId,默认游客 商品可见度默认所有人
|
|
|
+ Integer recommendType = productDao.getRecommendType(productId);
|
|
|
+ List<ProductList> list = null;
|
|
|
+ if (null != recommendType && 1 == recommendType) {
|
|
|
+ list = productDao.getProductRecommendsById(productId);
|
|
|
+ } else {
|
|
|
+ list = productDao.getAutoProductRecommends(productId);
|
|
|
+ }
|
|
|
+ if (null != list && list.size() > 0) {
|
|
|
+ list.forEach(product -> {
|
|
|
+ // 设置 图片路径
|
|
|
+ product.setImage(ImageUtil.getImageURL("product", product.getImage(), 0, domain));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|