|
@@ -1,5 +1,6 @@
|
|
package com.caimei365.commodity.service.impl;
|
|
package com.caimei365.commodity.service.impl;
|
|
|
|
|
|
|
|
+import com.caimei365.commodity.components.PriceUtilService;
|
|
import com.caimei365.commodity.mapper.PageMapper;
|
|
import com.caimei365.commodity.mapper.PageMapper;
|
|
import com.caimei365.commodity.mapper.PriceMapper;
|
|
import com.caimei365.commodity.mapper.PriceMapper;
|
|
import com.caimei365.commodity.mapper.ProductTypeMapper;
|
|
import com.caimei365.commodity.mapper.ProductTypeMapper;
|
|
@@ -8,13 +9,11 @@ import com.caimei365.commodity.model.ResponseJson;
|
|
import com.caimei365.commodity.model.po.ProductDetailInfoPo;
|
|
import com.caimei365.commodity.model.po.ProductDetailInfoPo;
|
|
import com.caimei365.commodity.model.po.ProductImagePo;
|
|
import com.caimei365.commodity.model.po.ProductImagePo;
|
|
import com.caimei365.commodity.model.po.ProductParameterPo;
|
|
import com.caimei365.commodity.model.po.ProductParameterPo;
|
|
-import com.caimei365.commodity.model.vo.ProductRepairVo;
|
|
|
|
import com.caimei365.commodity.model.search.ProductListVo;
|
|
import com.caimei365.commodity.model.search.ProductListVo;
|
|
import com.caimei365.commodity.model.vo.*;
|
|
import com.caimei365.commodity.model.vo.*;
|
|
import com.caimei365.commodity.service.PageService;
|
|
import com.caimei365.commodity.service.PageService;
|
|
import com.caimei365.commodity.utils.AppletsLinkUtil;
|
|
import com.caimei365.commodity.utils.AppletsLinkUtil;
|
|
import com.caimei365.commodity.utils.ImageUtils;
|
|
import com.caimei365.commodity.utils.ImageUtils;
|
|
-import com.caimei365.commodity.components.PriceUtilService;
|
|
|
|
import com.caimei365.commodity.utils.MathUtil;
|
|
import com.caimei365.commodity.utils.MathUtil;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -49,6 +48,7 @@ public class PageServiceImpl implements PageService {
|
|
private PriceUtilService priceUtilService;
|
|
private PriceUtilService priceUtilService;
|
|
@Resource
|
|
@Resource
|
|
private ProductTypeMapper productTypeMapper;
|
|
private ProductTypeMapper productTypeMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取分类列表
|
|
* 获取分类列表
|
|
*
|
|
*
|
|
@@ -58,21 +58,21 @@ public class PageServiceImpl implements PageService {
|
|
@Override
|
|
@Override
|
|
@Cacheable(value = "getCommodityClassify", key = "#typeSort +'-'+ #source", unless = "#result == null")
|
|
@Cacheable(value = "getCommodityClassify", key = "#typeSort +'-'+ #source", unless = "#result == null")
|
|
public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source) {
|
|
public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source) {
|
|
- List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort,source);
|
|
|
|
|
|
+ List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort, source);
|
|
bigTypeList.forEach(bigType -> {
|
|
bigTypeList.forEach(bigType -> {
|
|
String caiMeiImage = ImageUtils.getImageURL("caiMeiImage", null, 0, domain);
|
|
String caiMeiImage = ImageUtils.getImageURL("caiMeiImage", null, 0, domain);
|
|
- bigType.setWwwIcon(StringUtils.isEmpty(bigType.getWwwIcon())?caiMeiImage:bigType.getWwwIcon());
|
|
|
|
- bigType.setCrmIcon(StringUtils.isEmpty(bigType.getCrmIcon())?caiMeiImage:bigType.getCrmIcon());
|
|
|
|
|
|
+ bigType.setWwwIcon(StringUtils.isEmpty(bigType.getWwwIcon()) ? caiMeiImage : bigType.getWwwIcon());
|
|
|
|
+ bigType.setCrmIcon(StringUtils.isEmpty(bigType.getCrmIcon()) ? caiMeiImage : bigType.getCrmIcon());
|
|
List<SmallTypeVo> smallTypeList = productTypeMapper.getSmallTypeList(bigType.getBigTypeId(), source);
|
|
List<SmallTypeVo> smallTypeList = productTypeMapper.getSmallTypeList(bigType.getBigTypeId(), source);
|
|
if (!CollectionUtils.isEmpty(smallTypeList)) {
|
|
if (!CollectionUtils.isEmpty(smallTypeList)) {
|
|
smallTypeList.forEach(smallType -> {
|
|
smallTypeList.forEach(smallType -> {
|
|
- smallType.setWwwIcon(StringUtils.isEmpty(smallType.getWwwIcon())?caiMeiImage:smallType.getWwwIcon());
|
|
|
|
- smallType.setCrmIcon(StringUtils.isEmpty(smallType.getCrmIcon())?caiMeiImage:smallType.getCrmIcon());
|
|
|
|
|
|
+ smallType.setWwwIcon(StringUtils.isEmpty(smallType.getWwwIcon()) ? caiMeiImage : smallType.getWwwIcon());
|
|
|
|
+ smallType.setCrmIcon(StringUtils.isEmpty(smallType.getCrmIcon()) ? caiMeiImage : smallType.getCrmIcon());
|
|
List<TinyTypeVo> tinyTypeList = productTypeMapper.getTinyTypeList(smallType.getSmallTypeId(), source);
|
|
List<TinyTypeVo> tinyTypeList = productTypeMapper.getTinyTypeList(smallType.getSmallTypeId(), source);
|
|
if (!CollectionUtils.isEmpty(tinyTypeList)) {
|
|
if (!CollectionUtils.isEmpty(tinyTypeList)) {
|
|
tinyTypeList.forEach(tinyType -> {
|
|
tinyTypeList.forEach(tinyType -> {
|
|
- tinyType.setWwwIcon(StringUtils.isEmpty(tinyType.getWwwIcon())?caiMeiImage:tinyType.getWwwIcon());
|
|
|
|
- tinyType.setCrmIcon(StringUtils.isEmpty(tinyType.getCrmIcon())?caiMeiImage:tinyType.getCrmIcon());
|
|
|
|
|
|
+ tinyType.setWwwIcon(StringUtils.isEmpty(tinyType.getWwwIcon()) ? caiMeiImage : tinyType.getWwwIcon());
|
|
|
|
+ tinyType.setCrmIcon(StringUtils.isEmpty(tinyType.getCrmIcon()) ? caiMeiImage : tinyType.getCrmIcon());
|
|
});
|
|
});
|
|
smallType.setTinyTypeList(tinyTypeList);
|
|
smallType.setTinyTypeList(tinyTypeList);
|
|
}
|
|
}
|
|
@@ -103,7 +103,7 @@ public class PageServiceImpl implements PageService {
|
|
setFloorLinkType(floorContent);
|
|
setFloorLinkType(floorContent);
|
|
floor.setFloorContent(floorContent);
|
|
floor.setFloorContent(floorContent);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
|
|
- setFloorImageProduct(userId, floorImageList);
|
|
|
|
|
|
+ setFloorImageProduct(userId, floorImageList, source);
|
|
floor.setFloorImageList(floorImageList);
|
|
floor.setFloorImageList(floorImageList);
|
|
}
|
|
}
|
|
map.put("typeSort", typeSort);
|
|
map.put("typeSort", typeSort);
|
|
@@ -136,7 +136,7 @@ public class PageServiceImpl implements PageService {
|
|
floorIterator.remove();
|
|
floorIterator.remove();
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- setFloorImageProduct(userId, floorImageList);
|
|
|
|
|
|
+ setFloorImageProduct(userId, floorImageList, source);
|
|
floor.setFloorImageList(floorImageList);
|
|
floor.setFloorImageList(floorImageList);
|
|
}
|
|
}
|
|
map.put("homePageFloor", homePageFloor);
|
|
map.put("homePageFloor", homePageFloor);
|
|
@@ -162,6 +162,7 @@ public class PageServiceImpl implements PageService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 首页基础数据(小程序)
|
|
* 首页基础数据(小程序)
|
|
|
|
+ *
|
|
* @param source 来源 : 1 网站 ; 2 小程序
|
|
* @param source 来源 : 1 网站 ; 2 小程序
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@@ -225,7 +226,7 @@ public class PageServiceImpl implements PageService {
|
|
if (StringUtils.isNotBlank(page.getHeadLink())) {
|
|
if (StringUtils.isNotBlank(page.getHeadLink())) {
|
|
Integer linkType = AppletsLinkUtil.getLinkType(page.getHeadLink());
|
|
Integer linkType = AppletsLinkUtil.getLinkType(page.getHeadLink());
|
|
page.setLinkType(linkType);
|
|
page.setLinkType(linkType);
|
|
- page.setLinkParam(AppletsLinkUtil.getLinkParam(linkType,page.getHeadLink()));
|
|
|
|
|
|
+ page.setLinkParam(AppletsLinkUtil.getLinkParam(linkType, page.getHeadLink()));
|
|
}
|
|
}
|
|
List<PageFloorVo> floorList = pageMapper.getFloorByPageId(pageId, source);
|
|
List<PageFloorVo> floorList = pageMapper.getFloorByPageId(pageId, source);
|
|
for (PageFloorVo floor : floorList) {
|
|
for (PageFloorVo floor : floorList) {
|
|
@@ -233,7 +234,7 @@ public class PageServiceImpl implements PageService {
|
|
setFloorLinkType(floorContent);
|
|
setFloorLinkType(floorContent);
|
|
floor.setFloorContent(floorContent);
|
|
floor.setFloorContent(floorContent);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
|
|
- setFloorImageProduct(userId, floorImageList);
|
|
|
|
|
|
+ setFloorImageProduct(userId, floorImageList, source);
|
|
floor.setFloorImageList(floorImageList);
|
|
floor.setFloorImageList(floorImageList);
|
|
}
|
|
}
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
@@ -257,7 +258,7 @@ public class PageServiceImpl implements PageService {
|
|
FloorContentVo floorContent = pageMapper.getFloorContentById(floorId);
|
|
FloorContentVo floorContent = pageMapper.getFloorContentById(floorId);
|
|
setFloorLinkType(floorContent);
|
|
setFloorLinkType(floorContent);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floorId, source);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floorId, source);
|
|
- setFloorImageProduct(userId, floorImageList);
|
|
|
|
|
|
+ setFloorImageProduct(userId, floorImageList, source);
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
map.put("floorContent", floorContent);
|
|
map.put("floorContent", floorContent);
|
|
map.put("floorImageList", floorImageList);
|
|
map.put("floorImageList", floorImageList);
|
|
@@ -279,7 +280,7 @@ public class PageServiceImpl implements PageService {
|
|
FloorContentVo floorContent = pageMapper.getFloorContentByCentreId(centreId);
|
|
FloorContentVo floorContent = pageMapper.getFloorContentByCentreId(centreId);
|
|
setFloorLinkType(floorContent);
|
|
setFloorLinkType(floorContent);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(centreId, source);
|
|
List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(centreId, source);
|
|
- setFloorImageProduct(userId, floorImageList);
|
|
|
|
|
|
+ setFloorImageProduct(userId, floorImageList, source);
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
map.put("floorContent", floorContent);
|
|
map.put("floorContent", floorContent);
|
|
map.put("floorImageList", floorImageList);
|
|
map.put("floorImageList", floorImageList);
|
|
@@ -300,7 +301,7 @@ public class PageServiceImpl implements PageService {
|
|
product = new ProductDetailVo();
|
|
product = new ProductDetailVo();
|
|
product.setValidFlag(0);
|
|
product.setValidFlag(0);
|
|
}
|
|
}
|
|
- boolean validFlag = 2 != product.getProductCategory() && 2 == product.getValidFlag() && (product.getStock()== null || product.getStock() == 0);
|
|
|
|
|
|
+ boolean validFlag = 2 != product.getProductCategory() && 2 == product.getValidFlag() && (product.getStock() == null || product.getStock() == 0);
|
|
if (validFlag) {
|
|
if (validFlag) {
|
|
//已上架但库存为0的正常商品,设置为已售罄商品
|
|
//已上架但库存为0的正常商品,设置为已售罄商品
|
|
product.setValidFlag(4);
|
|
product.setValidFlag(4);
|
|
@@ -422,12 +423,12 @@ public class PageServiceImpl implements PageService {
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
List<ProductItemVo> productList = pageMapper.getBuyAgainProducts(userId);
|
|
List<ProductItemVo> productList = pageMapper.getBuyAgainProducts(userId);
|
|
productList.forEach(product -> {
|
|
productList.forEach(product -> {
|
|
- double price = product.getPrice()!=null?product.getPrice():0d;
|
|
|
|
- double costPrice = product.getCostPrice()!=null?product.getCostPrice():0d;
|
|
|
|
- double discountPrice = product.getDiscountPrice()!=null?product.getDiscountPrice():0d;
|
|
|
|
|
|
+ double price = product.getPrice() != null ? product.getPrice() : 0d;
|
|
|
|
+ double costPrice = product.getCostPrice() != null ? product.getCostPrice() : 0d;
|
|
|
|
+ double discountPrice = product.getDiscountPrice() != null ? product.getDiscountPrice() : 0d;
|
|
Integer costFlag = product.getCostCheckFlag();
|
|
Integer costFlag = product.getCostCheckFlag();
|
|
// 成本大于等于复购价 或 复购价大于机构价
|
|
// 成本大于等于复购价 或 复购价大于机构价
|
|
- boolean state = (costFlag == 1 && MathUtil.compare(costPrice, discountPrice) >=0) || MathUtil.compare(discountPrice, price) >0;
|
|
|
|
|
|
+ boolean state = (costFlag == 1 && MathUtil.compare(costPrice, discountPrice) >= 0) || MathUtil.compare(discountPrice, price) > 0;
|
|
product.setRepurchasePriceState(state);
|
|
product.setRepurchasePriceState(state);
|
|
// 设置商品主图及价格
|
|
// 设置商品主图及价格
|
|
priceUtilService.setProductDetails(userId, product);
|
|
priceUtilService.setProductDetails(userId, product);
|
|
@@ -547,7 +548,9 @@ public class PageServiceImpl implements PageService {
|
|
Integer identity = 0;
|
|
Integer identity = 0;
|
|
if (null != userId && userId > 0) {
|
|
if (null != userId && userId > 0) {
|
|
identity = priceMapper.getIdentityByUserId(userId);
|
|
identity = priceMapper.getIdentityByUserId(userId);
|
|
- if (null == identity){identity = 0;}
|
|
|
|
|
|
+ if (null == identity) {
|
|
|
|
+ identity = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
List<ProductListVo> list = null;
|
|
List<ProductListVo> list = null;
|
|
//相关推荐类型 0自动选择(默认); 1手动推荐
|
|
//相关推荐类型 0自动选择(默认); 1手动推荐
|
|
@@ -556,13 +559,13 @@ public class PageServiceImpl implements PageService {
|
|
} else {
|
|
} else {
|
|
list = pageMapper.getProductRecommendsById(productId);
|
|
list = pageMapper.getProductRecommendsById(productId);
|
|
}
|
|
}
|
|
- if (null != list && list.size()>0) {
|
|
|
|
|
|
+ if (null != list && list.size() > 0) {
|
|
// identity: 0个人,1协销,2会员机构,3供应商,4普通机构
|
|
// identity: 0个人,1协销,2会员机构,3供应商,4普通机构
|
|
// visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
|
|
// visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
|
|
// boolean passFlag = identity ==1 || identity == 2 || product.getVisibility()==3 || (identity == 4 && product.getVisibility()==2);
|
|
// boolean passFlag = identity ==1 || identity == 2 || product.getVisibility()==3 || (identity == 4 && product.getVisibility()==2);
|
|
try {
|
|
try {
|
|
Integer finalIdentity = identity;
|
|
Integer finalIdentity = identity;
|
|
- list.removeIf(product -> (null == product || null == product.getVisibility() || !(finalIdentity == 1 || finalIdentity == 2 || product.getVisibility()==3 || (finalIdentity == 4 && product.getVisibility()==2))));
|
|
|
|
|
|
+ list.removeIf(product -> (null == product || null == product.getVisibility() || !(finalIdentity == 1 || finalIdentity == 2 || product.getVisibility() == 3 || (finalIdentity == 4 && product.getVisibility() == 2))));
|
|
list.forEach(product -> {
|
|
list.forEach(product -> {
|
|
// 设置 图片路径
|
|
// 设置 图片路径
|
|
product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
|
|
product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
|
|
@@ -591,7 +594,7 @@ public class PageServiceImpl implements PageService {
|
|
// 维修详情
|
|
// 维修详情
|
|
repair = pageMapper.getMaintenanceById(maintenanceId);
|
|
repair = pageMapper.getMaintenanceById(maintenanceId);
|
|
}
|
|
}
|
|
- if (null == repair){
|
|
|
|
|
|
+ if (null == repair) {
|
|
return ResponseJson.error("无效的链接!", null);
|
|
return ResponseJson.error("无效的链接!", null);
|
|
}
|
|
}
|
|
List<String> imageList = new ArrayList<>();
|
|
List<String> imageList = new ArrayList<>();
|
|
@@ -640,6 +643,7 @@ public class PageServiceImpl implements PageService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置跳转参数
|
|
* 设置跳转参数
|
|
|
|
+ *
|
|
* @param floorContent FloorContentVo
|
|
* @param floorContent FloorContentVo
|
|
*/
|
|
*/
|
|
private void setFloorLinkType(FloorContentVo floorContent) {
|
|
private void setFloorLinkType(FloorContentVo floorContent) {
|
|
@@ -665,7 +669,7 @@ public class PageServiceImpl implements PageService {
|
|
/**
|
|
/**
|
|
* 设置楼层相关图片的商品信息
|
|
* 设置楼层相关图片的商品信息
|
|
*/
|
|
*/
|
|
- private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList) {
|
|
|
|
|
|
+ private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList, Integer source) {
|
|
Iterator<FloorImageVo> iterator = floorImageList.iterator();
|
|
Iterator<FloorImageVo> iterator = floorImageList.iterator();
|
|
while (iterator.hasNext()) {
|
|
while (iterator.hasNext()) {
|
|
FloorImageVo image = iterator.next();
|
|
FloorImageVo image = iterator.next();
|
|
@@ -699,6 +703,9 @@ public class PageServiceImpl implements PageService {
|
|
iterator.remove();
|
|
iterator.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //优惠券标识
|
|
|
|
+ Boolean couponsLogo = setCouponsLogo(userId, image.getProductId(), source);
|
|
|
|
+ product.setCouponsLogo(couponsLogo);
|
|
} else {
|
|
} else {
|
|
iterator.remove();
|
|
iterator.remove();
|
|
}
|
|
}
|
|
@@ -707,4 +714,53 @@ public class PageServiceImpl implements PageService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 优惠券标识是否显示
|
|
|
|
+ *
|
|
|
|
+ * @param userId 机构用户id
|
|
|
|
+ * @param productId 商品id
|
|
|
|
+ * @param source 来源 : 1 网站 ; 2 小程序
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean setCouponsLogo(Integer userId, Integer productId, Integer source) {
|
|
|
|
+ boolean couponsLogo = false;
|
|
|
|
+ ProductItemVo product = pageMapper.getProductItemById(productId);
|
|
|
|
+ List<CouponVo> couponList = pageMapper.findAllCoupon(userId);
|
|
|
|
+ if (couponList != null && couponList.size() > 0) {
|
|
|
|
+ for (CouponVo coupon : couponList) {
|
|
|
|
+ if (coupon.getCouponType() == 4 || coupon.getCouponType() == 2) {
|
|
|
|
+ //用户券与用户专享券
|
|
|
|
+ couponsLogo = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (coupon.getCouponType() == 0) {
|
|
|
|
+ if (coupon.getProductType() == 1) {
|
|
|
|
+ //活动券-全商城商品
|
|
|
|
+ couponsLogo = true;
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ //活动券-指定商品
|
|
|
|
+ List<Integer> productIds = pageMapper.findAllProductId(coupon.getCouponId(), source);
|
|
|
|
+ if (productIds.contains(productId)) {
|
|
|
|
+ couponsLogo = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (coupon.getCouponType() == 3 && product.getShopId().equals(coupon.getShopId())) {
|
|
|
|
+ //店铺券
|
|
|
|
+ couponsLogo = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (coupon.getCouponType() == 1 && product.getCommodityType().equals(coupon.getCategoryType())) {
|
|
|
|
+ //品类券
|
|
|
|
+ couponsLogo = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return couponsLogo;
|
|
|
|
+ }
|
|
}
|
|
}
|