提交 8d20c041 作者: xiaowang

Merge branch 'develop'

......@@ -18,4 +18,4 @@ patches:
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/pms
newTag: 46346bc6755293aa41fd29fc40bb9aad22dff098
newTag: 689c742b34953b8aca245a80a0f9e66793ad5389
......@@ -2,10 +2,9 @@ package com.mmc.pms.controller.mall;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.controller.BaseController;
import com.mmc.pms.entity.mall.MallGoodsDO;
import com.mmc.pms.entity.mall.ProductBrowseDO;
import com.mmc.pms.model.mall.GoodsListVO;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.mall.RecommendVO;
import com.mmc.pms.model.mall.UavCartDTO;
import com.mmc.pms.model.qo.mall.PriceStockQO;
import com.mmc.pms.model.sale.qo.MallGoodsInfoQO;
......@@ -71,10 +70,11 @@ public class AppMallGoodsController extends BaseController {
public ResultBody<MallGoodsVO> listMallGoodsBySearch(@ApiParam("商品查询条件QO") @RequestBody MallGoodsInfoQO param, HttpServletRequest request) {
return ResultBody.success(mallGoodsService.listMallGoodsBySearch(param, this.getUserLoginInfoFromRedis(request)));
}
@ApiOperation(value = "商品浏览排行榜")
@PostMapping("browseMallGoods")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsVO.class)})
public ResultBody<MallGoodsVO> browseMallGoods(@RequestBody MallGoodsDO mallGoodsDO, ProductBrowseDO productBrowseDO, HttpServletRequest request){
return appMallGoodsService.browseMallGoods(mallGoodsDO,productBrowseDO,this.getUserLoginInfoFromRedis(request));
@ApiOperation(value = "推荐商品")
@GetMapping("recommend")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecommendVO.class)})
public ResultBody<RecommendVO> recommend() {
return appMallGoodsService.recommend();
}
}
......@@ -57,4 +57,6 @@ public interface CategoryDao {
Integer selectSubMallGoods(Integer id);
Integer selectPrimary(Integer id);
List<CategoryPrimaryDO> selectPrimaryListByIds(List<Integer> ids);
}
......@@ -66,4 +66,6 @@ public interface MallGoodsDao {
void updateSpecAttrValue(SpecAttrVO attrVO);
int getMallGoodsCount();
List<MallGoodsDO> recommendMallGoods();
}
......@@ -71,7 +71,7 @@ public class MallGoodsDO implements Serializable {
private Integer sort;
/**
* 商品热度
* */
*/
private Integer hot;
private Integer priceShow;
......@@ -82,6 +82,8 @@ public class MallGoodsDO implements Serializable {
private Integer deleted;
private Integer recommend;
private String url;
private Integer type;
private Integer imgId;
......@@ -99,14 +101,16 @@ public class MallGoodsDO implements Serializable {
this.goodsLabel = mallGoodsVO.getGoodsLabel();
this.labelShow = mallGoodsVO.getLabelShow();
this.priceShow = mallGoodsVO.getPriceShow();
this.recommend = mallGoodsVO.getRecommend() == null ? 0 : mallGoodsVO.getRecommend();
this.goodsDetails = mallGoodsVO.getGoodsDetails();
this.hot = mallGoodsVO.getHot();
}
public MallGoodsVO buildMallGoodsVO() {
return MallGoodsVO.builder().id(id).userAccountId(userAccountId).tradeName(tradeName).description(description)
.categoryPrimaryId(categoryPrimaryId).categorySubId(categorySubId).shelfStatus(shelfStatus).priceShow(priceShow)
.goodsLabel(goodsLabel).labelShow(labelShow).createTime(createTime).goodsDetails(goodsDetails).build();
return MallGoodsVO.builder().id(id).userAccountId(userAccountId).tradeName(tradeName)
.description(description).categoryPrimaryId(categoryPrimaryId).categorySubId(categorySubId)
.shelfStatus(shelfStatus).priceShow(priceShow).goodsLabel(goodsLabel).labelShow(labelShow)
.createTime(createTime).goodsDetails(goodsDetails).recommend(recommend).build();
}
public MallGoodsVO buildListMallGoodsVO() {
......@@ -116,7 +120,7 @@ public class MallGoodsDO implements Serializable {
goodsResourcesVO.setUrl(url);
goodsResourcesVO.setType(type);
resourcesList.add(goodsResourcesVO);
return MallGoodsVO.builder().id(id).userAccountId(userAccountId).tradeName(tradeName).resourcesList(resourcesList)
return MallGoodsVO.builder().id(id).userAccountId(userAccountId).recommend(recommend).tradeName(tradeName).resourcesList(resourcesList)
.categoryPrimaryId(categoryPrimaryId).labelShow(labelShow).goodsLabel(goodsLabel).categorySubId(categorySubId)
.shelfStatus(shelfStatus).createTime(createTime).description(description).priceShow(priceShow).build();
}
......
......@@ -63,6 +63,9 @@ public class MallGoodsVO implements Serializable {
@ApiModelProperty(value = "标签是否显示 0否 1是")
private Integer labelShow;
@ApiModelProperty(value = "是否推荐 0否 1是")
private Integer recommend;
@ApiModelProperty(value = "规格")
@NotEmpty(message = "规格不能为空", groups = {Update.class, Create.class})
private List<SpecAttrVO> specAttrList;
......
package com.mmc.pms.model.mall;
import com.mmc.pms.model.category.dto.CategoryPrimaryDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @Author LW
* @date 2023/10/17 14:03
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class RecommendVO implements Serializable {
private CategoryPrimaryDTO categoryPrimaryDTO;
private List<MallGoodsVO> mallGoodsList;
}
......@@ -32,6 +32,9 @@ public class MallGoodsInfoQO {
@ApiModelProperty(value = "商品状态 0:下架 1:上架")
private Integer shelfStatus;
@ApiModelProperty(value = "是否推荐 0:否 1:是")
private Integer recommend;
@ApiModelProperty(value = "页码", required = true, example = "1")
@NotNull(
message = "页码不能为空",
......
package com.mmc.pms.service.mall;
import com.mmc.pms.auth.dto.LoginSuccessDTO;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.entity.mall.MallGoodsDO;
import com.mmc.pms.entity.mall.ProductBrowseDO;
import com.mmc.pms.model.mall.GoodsListVO;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.mall.RecommendVO;
import com.mmc.pms.model.mall.UavCartDTO;
import com.mmc.pms.model.qo.mall.PriceStockQO;
......@@ -25,5 +23,6 @@ public interface AppMallGoodsService {
List<UavCartDTO> listPriceStock(List<PriceStockQO> priceStockQOS);
ResultBody<MallGoodsVO> browseMallGoods(MallGoodsDO mallGoodsDO, ProductBrowseDO productBrowseDO, LoginSuccessDTO userLoginInfoFromRedis);
ResultBody<RecommendVO> recommend();
}
package com.mmc.pms.service.mall.impl;
import com.mmc.pms.auth.dto.LoginSuccessDTO;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.dao.category.CategoryDao;
import com.mmc.pms.dao.mall.AppMallGoodsDao;
import com.mmc.pms.dao.mall.MallGoodsDao;
import com.mmc.pms.entity.category.CategoryPrimaryDO;
import com.mmc.pms.entity.mall.MallGoodsDO;
import com.mmc.pms.entity.mall.PriceStockDO;
import com.mmc.pms.entity.mall.ProductBrowseDO;
import com.mmc.pms.model.category.dto.CategoryPrimaryDTO;
import com.mmc.pms.model.mall.GoodsListVO;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.mall.RecommendVO;
import com.mmc.pms.model.mall.UavCartDTO;
import com.mmc.pms.model.qo.mall.PriceStockQO;
import com.mmc.pms.service.mall.AppMallGoodsService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
......@@ -31,6 +33,10 @@ import java.util.stream.Collectors;
public class AppMallGoodsServiceImpl implements AppMallGoodsService {
@Resource
private AppMallGoodsDao appMallGoodsDao;
@Resource
private MallGoodsDao mallGoodsDao;
@Resource
private CategoryDao categoryDao;
@Override
public ResultBody<MallGoodsVO> queryBrandGoods(Integer userAccountId) {
......@@ -91,18 +97,28 @@ public class AppMallGoodsServiceImpl implements AppMallGoodsService {
}
@Override
@Transactional
public ResultBody<MallGoodsVO> browseMallGoods(MallGoodsDO mallGoodsDO, ProductBrowseDO productBrowseDO, LoginSuccessDTO userLoginInfoFromRedis) {
//获取当前用户id
Integer userAccountId = userLoginInfoFromRedis.getUserAccountId();
//记录查看商品的用户id
productBrowseDO.setUserId(userAccountId);
if(productBrowseDO.getUserId() != null){
Integer hot = mallGoodsDO.getHot();
hot++;
public ResultBody<RecommendVO> recommend() {
// 获取所有属于推荐的商品
List<MallGoodsDO> mallGoodsList = mallGoodsDao.recommendMallGoods();
if (mallGoodsList.size() == 0) {
return ResultBody.success();
}
return null;
List<RecommendVO> recommendList = new ArrayList<>();
// 获取所有一级分类
List<Integer> categoryPrimaryIdList = mallGoodsList.stream().map(MallGoodsDO::getCategoryPrimaryId).distinct().collect(Collectors.toList());
// 根据一级分类的id进行分组
Map<Integer, List<MallGoodsDO>> goodMap = mallGoodsList.stream().collect(Collectors.groupingBy(MallGoodsDO::getCategoryPrimaryId));
// 根据一级分类集合查询分类信息
List<CategoryPrimaryDO> categoryPrimaryList = categoryDao.selectPrimaryListByIds(categoryPrimaryIdList);
List<CategoryPrimaryDTO> primaryList = categoryPrimaryList.stream()
.map(CategoryPrimaryDO::buildCategoryPrimaryDTO).collect(Collectors.toList());
primaryList.forEach(categoryPrimaryDTO -> {
List<MallGoodsDO> goodsDOList = goodMap.get(categoryPrimaryDTO.getId());
RecommendVO recommendVO = new RecommendVO();
recommendVO.setCategoryPrimaryDTO(categoryPrimaryDTO);
recommendVO.setMallGoodsList(goodsDOList.stream().map(MallGoodsDO::buildListMallGoodsVO).collect(Collectors.toList()));
recommendList.add(recommendVO);
});
return ResultBody.success(recommendList);
}
}
......@@ -225,5 +225,20 @@
from mall_goods
where category_primary_id = #{id}
</select>
<select id="selectPrimaryListByIds" resultType="com.mmc.pms.entity.category.CategoryPrimaryDO">
select id,
`name`,
description,
create_time,
icon,
sort
from category_primary
<where>
<foreach collection="list" item="item" open="id in (" close=")" separator=",">
#{item}
</foreach>
</where>
order by sort desc, update_time desc, create_time desc
</select>
</mapper>
......@@ -14,6 +14,7 @@
mg.user_account_id,
mg.goods_label,
mg.label_show,
mg.recommend,
mg.category_sub_id,
mg.goods_label,
img.id as imgId, img.url,
......@@ -74,7 +75,7 @@
<result column="url" property="url"/>
<result column="is_deleted" property="deleted"/>
<result column="shelf_status" property="shelfStatus"/>
<collection property="priceStockDOS" ofType="com.mmc.pms.entity.mall.PriceStockDO" >
<collection property="priceStockDOS" ofType="com.mmc.pms.entity.mall.PriceStockDO">
<id column="productSpecId" property="id"/>
<result column="product_spec" property="productSpec"/>
<result column="sku_image" property="skuImage"/>
......
......@@ -15,10 +15,12 @@
label_show,
goods_details,
user_account_id,
recommend,
price_show,
sort)
values ( #{goodsNo}, #{tradeName}, #{description}, #{categoryPrimaryId}, #{categorySubId}
, #{shelfStatus}, #{goodsLabel}, #{labelShow}, #{goodsDetails}, #{userAccountId}, #{priceShow}, #{sort})
, #{shelfStatus}, #{goodsLabel}, #{labelShow}, #{goodsDetails}
, #{userAccountId}, #{recommend}, #{priceShow}, #{sort})
</insert>
<insert id="batchInsertMallGoodsResources">
......@@ -69,7 +71,8 @@
goods_label = #{mallGoodsDO.goodsLabel},
label_show = #{mallGoodsDO.labelShow},
goods_details = #{mallGoodsDO.goodsDetails},
price_show = #{mallGoodsDO.priceShow}
price_show = #{mallGoodsDO.priceShow},
recommend = #{mallGoodsDO.recommend}
WHERE id = #{mallGoodsDO.id}
</update>
<update id="updateMallGoodsSort">
......@@ -158,6 +161,7 @@
goods_details,
user_account_id,
price_show,
recommend,
sort,
create_time
FROM mall_goods
......@@ -192,6 +196,9 @@
<if test="shelfStatus != null">
and shelf_status = #{shelfStatus}
</if>
<if test="recommend != null">
and recommend = #{recommend}
</if>
</where>
</select>
<select id="listMallGoods" resultType="com.mmc.pms.entity.mall.MallGoodsDO">
......@@ -205,6 +212,7 @@
mg.user_account_id,
mg.description,
mg.price_show,
mg.recommend,
img.id as imgId,
img.url,
img.type
......@@ -226,6 +234,9 @@
<if test="shelfStatus != null">
and mg.shelf_status = #{shelfStatus}
</if>
<if test="recommend != null">
and mg.recommend = #{recommend}
</if>
</where>
ORDER BY
mg.shelf_status DESC , mg.sort DESC,mg.create_time DESC
......@@ -266,4 +277,24 @@
FROM mall_goods
WHERE is_deleted = 0
</select>
<select id="recommendMallGoods" resultType="com.mmc.pms.entity.mall.MallGoodsDO">
SELECT mg.id,
mg.trade_name,
mg.shelf_status,
mg.create_time,
mg.category_primary_id,
mg.category_sub_id,
mg.user_account_id,
mg.description,
mg.price_show,
mg.recommend,
img.id as imgId,
img.url,
img.type
FROM mall_goods mg
INNER JOIN mall_goods_resources img ON mg.id = img.mall_goods_id
AND img.type = 0
where mg.is_deleted = 0
and mg.recommend = 1
</select>
</mapper>
......@@ -37,3 +37,4 @@ data-filter:
- /pms/company-inspection/listInspectionPriceUnit
- /pms/lease/goods/feignLeaseGoodsInfoByAddressId
- /pms/industry/listIndustry
- /pms/app/goods/recommend
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论