Merge pull request '首页逻辑实现' (#7) from main-cx into main
Reviewed-on: #7
This commit is contained in:
@@ -3,12 +3,7 @@ package com.buy507.mall.portal.controller;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.buy507.mall.common.api.CommonResult;
|
import com.buy507.mall.common.api.CommonResult;
|
||||||
import com.buy507.mall.model.PmsProduct;
|
import com.buy507.mall.model.PmsProduct;
|
||||||
@@ -96,4 +91,30 @@ public class HomeController {
|
|||||||
return CommonResult.success(productSku);
|
return CommonResult.success(productSku);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取会员专区商品")
|
||||||
|
@RequestMapping(value = "/getVipProductList", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult<List<PmsProduct>> getVipProductList(){
|
||||||
|
List<PmsProduct> productList = homeService.getVipProductList();
|
||||||
|
return CommonResult.success(productList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取积分专区商品")
|
||||||
|
@RequestMapping(value = "/getPointProductList", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult<List<PmsProduct>> getPointProductList(){
|
||||||
|
List<PmsProduct> productList = homeService.getPointProductList();
|
||||||
|
return CommonResult.success(productList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取积分兑换专区")
|
||||||
|
@RequestMapping(value = "/getPointExchangeProductList", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult<List<PmsProduct>> getPointExchangeProductList(){
|
||||||
|
List<PmsProduct> productList = homeService.getPointExchangeProductList();
|
||||||
|
return CommonResult.success(productList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,4 +40,34 @@ public interface HomeDao {
|
|||||||
* 获取所有商品信息按销量排序
|
* 获取所有商品信息按销量排序
|
||||||
*/
|
*/
|
||||||
List<PmsProduct> getAllPioductList();
|
List<PmsProduct> getAllPioductList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取会员专区
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getProductVipStatus(@Param("offset") Integer offset,@Param("limit") Integer limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取积分专区
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getProductpointSareaStatus(@Param("offset") Integer offset,@Param("limit") Integer limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取积分兑换专区
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getProductpointsExchangeStatus(@Param("offset") Integer offset,@Param("limit") Integer limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取会员专区详情
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getVipStatusList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获取积分专区商品
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getPointStatusList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获取积分兑换专区商品
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getPointExchangeProductList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ public class HomeContentResult {
|
|||||||
private List<PmsProduct> hotProductList;
|
private List<PmsProduct> hotProductList;
|
||||||
//推荐专题
|
//推荐专题
|
||||||
private List<CmsSubject> subjectList;
|
private List<CmsSubject> subjectList;
|
||||||
|
//会员专区
|
||||||
|
private List<PmsProduct> vipProductList;
|
||||||
|
//积分专区
|
||||||
|
private List<PmsProduct> pointsAreaProductList;
|
||||||
|
//积分兑换专区
|
||||||
|
private List<PmsProduct> pointsExchangeProductList;
|
||||||
//查询所有商品按销量排序
|
//查询所有商品按销量排序
|
||||||
private List<PmsProduct> allProductList;
|
private List<PmsProduct> allProductList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,21 @@ public interface HomeService {
|
|||||||
* @param productId
|
* @param productId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取会员专区商品
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<PmsProduct> getVipProductList();
|
||||||
|
|
||||||
ProductDetailResult getProductInfo(Long productId);
|
ProductDetailResult getProductInfo(Long productId);
|
||||||
|
|
||||||
ProductSkuResult getProductSku(Long productId, String sp1, String sp2, String sp3);
|
ProductSkuResult getProductSku(Long productId, String sp1, String sp2, String sp3);
|
||||||
|
|
||||||
List<PmsProduct> getProductList(Long brandId, Long categoryId, String sortType, Integer pageSize, Integer pageNum);
|
List<PmsProduct> getProductList(Long brandId, Long categoryId, String sortType, Integer pageSize, Integer pageNum);
|
||||||
|
|
||||||
|
List<PmsProduct> getPointProductList();
|
||||||
|
|
||||||
|
List<PmsProduct> getPointExchangeProductList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,8 +118,9 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
//获取秒杀信息
|
//获取秒杀信息
|
||||||
result.setHomeFlashPromotion(getHomeFlashPromotion());
|
result.setHomeFlashPromotion(getHomeFlashPromotion());
|
||||||
|
|
||||||
List<PmsProduct> newProductList = homeDao.getNewProductList(0, 4);
|
List<PmsProduct> VipProductList = homeDao.getProductVipStatus(0, 4);
|
||||||
List<PmsProduct> hotProductList = homeDao.getHotProductList(0, 4);
|
List<PmsProduct> PointAreaProductList = homeDao.getProductpointSareaStatus(0, 4);
|
||||||
|
List<PmsProduct> pointsExchangeProductList = homeDao.getProductpointsExchangeStatus(0, 4);
|
||||||
List<PmsProduct> allProductList = homeDao.getAllPioductList();
|
List<PmsProduct> allProductList = homeDao.getAllPioductList();
|
||||||
|
|
||||||
//根据会员等级显示不同的商品价格
|
//根据会员等级显示不同的商品价格
|
||||||
@@ -127,10 +128,13 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
if (member != null) {
|
if (member != null) {
|
||||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||||
if (discount != null) {
|
if (discount != null) {
|
||||||
for(PmsProduct product : newProductList) {
|
for (PmsProduct product : VipProductList) {
|
||||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
}
|
||||||
for(PmsProduct product : hotProductList) {
|
for (PmsProduct product : PointAreaProductList) {
|
||||||
|
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}
|
||||||
|
for (PmsProduct product : pointsExchangeProductList) {
|
||||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
}
|
||||||
for (PmsProduct product : allProductList) {
|
for (PmsProduct product : allProductList) {
|
||||||
@@ -139,10 +143,12 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取新品推荐
|
//获取会员商品
|
||||||
result.setNewProductList(newProductList);
|
result.setVipProductList(VipProductList);
|
||||||
//获取人气推荐
|
//获取积分专区商品
|
||||||
result.setHotProductList(hotProductList);
|
result.setPointsAreaProductList(PointAreaProductList);
|
||||||
|
//获取积分兑换商品
|
||||||
|
result.setPointsExchangeProductList(pointsExchangeProductList);
|
||||||
//获取推荐专题
|
//获取推荐专题
|
||||||
//result.setSubjectList(homeDao.getRecommendSubjectList(0,4));
|
//result.setSubjectList(homeDao.getRecommendSubjectList(0,4));
|
||||||
//获取上次所有商品,按销量排序
|
//获取上次所有商品,按销量排序
|
||||||
@@ -180,6 +186,29 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获取会员专区商品
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PmsProduct> getVipProductList() {
|
||||||
|
return homeDao.getVipStatusList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获取积分专区商品
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PmsProduct> getPointProductList() {
|
||||||
|
return homeDao.getPointStatusList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获取积分兑换专区
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PmsProduct> getPointExchangeProductList() {
|
||||||
|
return homeDao.getPointExchangeProductList();
|
||||||
|
}
|
||||||
private ProductCategoryOptions recursionCategory(PmsProductCategory category, List<PmsProductCategory> list) {
|
private ProductCategoryOptions recursionCategory(PmsProductCategory category, List<PmsProductCategory> list) {
|
||||||
List<ProductCategoryOptions> childList = new ArrayList<>();
|
List<ProductCategoryOptions> childList = new ArrayList<>();
|
||||||
// 为每一个父节点增加子树(List形式,没有则为空的list)
|
// 为每一个父节点增加子树(List形式,没有则为空的list)
|
||||||
@@ -292,6 +321,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取商品详情
|
//获取商品详情
|
||||||
@Override
|
@Override
|
||||||
public ProductDetailResult getProductInfo(Long productId) {
|
public ProductDetailResult getProductInfo(Long productId) {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.buy507.mall.portal.service.impl;
|
|||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alipay.api.AlipayApiException;
|
||||||
|
import com.alipay.api.internal.util.AlipaySignature;
|
||||||
import com.buy507.mall.common.api.CommonResult;
|
import com.buy507.mall.common.api.CommonResult;
|
||||||
import com.buy507.mall.common.util.MD5Util;
|
import com.buy507.mall.common.util.MD5Util;
|
||||||
import com.buy507.mall.mapper.*;
|
import com.buy507.mall.mapper.*;
|
||||||
@@ -43,9 +45,6 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import com.alipay.api.internal.util.AlipaySignature;
|
|
||||||
import com.alipay.api.AlipayApiException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 前台订单管理Service
|
* 前台订单管理Service
|
||||||
*/
|
*/
|
||||||
@@ -748,7 +747,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|||||||
return CommonResult.validateFailed("未查询到商品信息");
|
return CommonResult.validateFailed("未查询到商品信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
PmsProduct product = new PmsProduct();
|
PmsProduct product = productMapper.selectByPrimaryKey(skuStock.getProductId());
|
||||||
|
|
||||||
// 判断商品是否属于积分兑换区
|
// 判断商品是否属于积分兑换区
|
||||||
boolean isPointsExchangeStatus = product.getPointsExchangeStatus() == 1;
|
boolean isPointsExchangeStatus = product.getPointsExchangeStatus() == 1;
|
||||||
|
|||||||
@@ -61,11 +61,6 @@
|
|||||||
WHERE
|
WHERE
|
||||||
hp.recommend_status = 1
|
hp.recommend_status = 1
|
||||||
AND p.publish_status = 1
|
AND p.publish_status = 1
|
||||||
AND (
|
|
||||||
p.vip_status = 1 OR
|
|
||||||
p.points_area_status = 1 OR
|
|
||||||
p.points_exchange_status = 1
|
|
||||||
)
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
hp.sort DESC
|
hp.sort DESC
|
||||||
LIMIT #{offset}, #{limit};
|
LIMIT #{offset}, #{limit};
|
||||||
@@ -84,4 +79,55 @@
|
|||||||
LIMIT #{offset}, #{limit};
|
LIMIT #{offset}, #{limit};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getProductVipStatus" resultType="com.buy507.mall.model.PmsProduct">
|
||||||
|
SELECT p.*
|
||||||
|
FROM
|
||||||
|
pms_product
|
||||||
|
WHERE
|
||||||
|
vip_status = 1
|
||||||
|
LIMIT #{offset}, #{limit};
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getProductpointSareaStatus" resultType="com.buy507.mall.model.PmsProduct">
|
||||||
|
SELECT p.*
|
||||||
|
FROM
|
||||||
|
pms_product
|
||||||
|
WHERE
|
||||||
|
points_area_status = 1
|
||||||
|
LIMIT #{offset}, #{limit};
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getProductpointsExchangeStatus" resultType="com.buy507.mall.model.PmsProduct">
|
||||||
|
|
||||||
|
SELECT p.*
|
||||||
|
FROM
|
||||||
|
pms_product
|
||||||
|
WHERE
|
||||||
|
points_exchange_status = 1
|
||||||
|
LIMIT #{offset}, #{limit};
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getVipStatusList" resultType="com.buy507.mall.model.PmsProduct">
|
||||||
|
SELECT p.*
|
||||||
|
FROM
|
||||||
|
pms_product
|
||||||
|
WHERE
|
||||||
|
vip_status = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getPointStatusList" resultType="com.buy507.mall.model.PmsProduct">
|
||||||
|
SELECT p.*
|
||||||
|
FROM
|
||||||
|
pms_product
|
||||||
|
WHERE
|
||||||
|
points_area_status = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getPointExchangeProductList" resultType="com.buy507.mall.model.PmsProduct">
|
||||||
|
SELECT p.*
|
||||||
|
FROM
|
||||||
|
pms_product
|
||||||
|
WHERE
|
||||||
|
points_exchange_status = 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user