|
@@ -13,6 +13,8 @@ import com.caimei365.commodity.service.PageService;
|
|
|
import com.caimei365.commodity.utils.AppletsLinkUtil;
|
|
|
import com.caimei365.commodity.utils.ImageUtils;
|
|
|
import com.caimei365.commodity.components.PriceUtilService;
|
|
|
+import com.caimei365.commodity.utils.MathUtil;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -22,8 +24,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -53,7 +53,7 @@ public class PageServiceImpl implements PageService {
|
|
|
* @param source 请求来源:www,crm
|
|
|
*/
|
|
|
@Override
|
|
|
- // @Cacheable(value = "getClassify", key = "#typeSort +'-'+ #source", unless = "#result == null")
|
|
|
+ @Cacheable(value = "getClassify", key = "#typeSort +'-'+ #source", unless = "#result == null")
|
|
|
public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source) {
|
|
|
List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort,source);
|
|
|
bigTypeList.forEach(bigType -> {
|
|
@@ -88,7 +88,7 @@ public class PageServiceImpl implements PageService {
|
|
|
* @param source 来源:1网站,2小程序
|
|
|
*/
|
|
|
@Override
|
|
|
- // @Cacheable(value = "instrumentData", key = "#pageId+'-'+#userId+'-'+#source", unless = "#result == null")
|
|
|
+ @Cacheable(value = "instrumentData", key = "#pageId+'-'+#userId+'-'+#source", unless = "#result == null")
|
|
|
public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
|
|
|
source = source == null ? 1 : source;
|
|
|
Map<String, Object> map = new HashMap<>(3);
|
|
@@ -115,7 +115,7 @@ public class PageServiceImpl implements PageService {
|
|
|
* @param userId 用户id
|
|
|
* @param source 来源:1网站,2小程序
|
|
|
*/
|
|
|
- //@Cacheable(value = "getHomeFloorData", key = "#userId +'-'+ #source", unless = "#result == null")
|
|
|
+ @Cacheable(value = "getHomeFloorData", key = "#userId +'-'+ #source", unless = "#result == null")
|
|
|
@Override
|
|
|
public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
|
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
@@ -272,10 +272,40 @@ public class PageServiceImpl implements PageService {
|
|
|
product.setLadderPriceFlag(price.getLadderPriceFlag());
|
|
|
product.setPromotions(price.getPromotions());
|
|
|
product.setMinBuyNumber(price.getMinBuyNumber());
|
|
|
+ product.setUserIdentity(price.getUserIdentity());
|
|
|
}
|
|
|
return ResponseJson.success(product);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 再次购买商品列表
|
|
|
+ *
|
|
|
+ * @param userId 用户Id
|
|
|
+ * @param pageNum
|
|
|
+ * @param pageSize
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, int pageNum, int pageSize) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数错误:用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<ProductItemVo> productList = pageMapper.getBuyAgainProducts(userId);
|
|
|
+ productList.forEach(product -> {
|
|
|
+ double price = product.getPrice();
|
|
|
+ double costPrice = product.getCostPrice();
|
|
|
+ double discountPrice = product.getDiscountPrice();
|
|
|
+ Integer costFlag = product.getCostCheckFlag();
|
|
|
+ // 成本大于等于复购价 或 复购价大于机构价
|
|
|
+ boolean state = (costFlag == 1 && MathUtil.compare(costPrice, discountPrice) >=0) || MathUtil.compare(discountPrice, price) >0;
|
|
|
+ product.setRepurchasePriceState(state);
|
|
|
+ // 设置商品主图及价格
|
|
|
+ priceUtilService.setProductDetails(userId, product);
|
|
|
+ });
|
|
|
+ PaginationVo<ProductItemVo> pageData = new PaginationVo<>(productList);
|
|
|
+ return ResponseJson.success(pageData);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置跳转参数
|
|
|
* @param floorContent FloorContentVo
|
|
@@ -315,11 +345,11 @@ public class PageServiceImpl implements PageService {
|
|
|
// 获取商品及价格
|
|
|
ProductItemVo product = pageMapper.getProductItemById(image.getProductId());
|
|
|
if (product != null) {
|
|
|
+ // 设置商品主图及价格
|
|
|
+ priceUtilService.setProductDetails(userId, product);
|
|
|
image.setListType(1);
|
|
|
image.setName(product.getName());
|
|
|
image.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
|
|
|
- // 设置商品价格
|
|
|
- priceUtilService.setItemPriceByUserId(product, userId);
|
|
|
image.setProduct(product);
|
|
|
if (userId != null) {
|
|
|
if (product.getUserIdentity() > 0) {
|