peng
2 天以前 92c873eda099b869e15108a79bf5223d3f0264a6
调整商品可以进行排序
9个文件已修改
53 ■■■■■ 已修改文件
consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java
@@ -124,7 +124,7 @@
    @Override
    @RetryOperation
    public void onMessage(MessageExt messageExt) {
        log.info("获取到的信息为{},获取到的标签为{}",new String(messageExt.getBody()), GoodsTagsEnum.valueOf(messageExt.getTags()).name());
        switch (GoodsTagsEnum.valueOf(messageExt.getTags())) {
            //查看商品
            case VIEW_GOODS:
@@ -408,6 +408,7 @@
        goodsIndex.setMarketEnable(goods.getMarketEnable());
        goodsIndex.setPreSaleBeginDate(goods.getPreSaleBeginDate());
        goodsIndex.setPreSaleEndDate(goods.getPreSaleEndDate());
        goodsIndex.setGoodsSort(goods.getGoodsSort());
        this.settingUpGoodsIndexOtherParam(goodsIndex);
        return goodsIndex;
    }
framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java
@@ -202,6 +202,9 @@
                        "      \"skuSource\": {\n" +
                        "        \"type\": \"long\"\n" +
                        "      },\n" +
                        "      \"goodsSort\": {\n" +
                        "        \"type\": \"long\"\n" +
                        "      },\n" +
                        "      \"goodsId\": {\n" +
                        "        \"type\": \"text\",\n" +
                        "        \"fields\": {\n" +
framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java
@@ -172,6 +172,9 @@
    private Date preSaleBeginDate;
    @ApiModelProperty(value = "抽成比例")
    private BigDecimal commission;
    @ApiModelProperty(value = "商品排序")
    private Integer goodsSort;
    public Goods() {
    }
@@ -192,6 +195,7 @@
        this.preSaleEndDate = goodsOperationDTO.getPreSaleEndDate();
        this.preSaleBeginDate = goodsOperationDTO.getPreSaleBeginDate();
        this.commission =  goodsOperationDTO.getCommission();
        this.goodsSort = goodsOperationDTO.getGoodsSort();
        if (goodsOperationDTO.getGoodsParamsDTOList() != null && goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) {
            this.params = JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList());
        }
framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java
@@ -156,6 +156,8 @@
    @DecimalMax(value = "100",message = "抽成比例必须小于100")
    @DecimalMin(value = "0",message = "抽成比例必须大于0")
    private BigDecimal commission;
    @ApiModelProperty(value = "商品排序")
    private Integer goodsSort;
    public String getGoodsName() {
        //对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤,影响很大。
framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java
@@ -1,15 +1,19 @@
package cn.lili.modules.goods.service;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.dto.GoodsSortDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.store.entity.dos.Store;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid;
import java.util.List;
/**
@@ -132,6 +136,8 @@
     * @return 更新结果
     */
    Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
    Boolean goodsSort( GoodsSortDTO req);
    /**
     * 删除商品
     *
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
@@ -18,6 +18,7 @@
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.dto.GoodsSortDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
@@ -423,6 +424,22 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean goodsSort(GoodsSortDTO req) {
        boolean result;
        //检测管理员权限
        this.checkManagerAuthority();
        LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(Goods::getGoodsSort,req.getSort());
        updateWrapper.eq(Goods::getId, req.getGoodsId());
        result = this.update(updateWrapper);
        List<String> goodsIds = new ArrayList<>();
        goodsIds.add(req.getGoodsId());
        this.updateEsGoods(goodsIds);
        return result;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    @SystemLogPoint(description = "删除商品", customerLog = "'操作对象:['+#goodsIds+']'")
    public Boolean deleteGoods(List<String> goodsIds) {
framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java
@@ -296,7 +296,8 @@
    @Field(type = FieldType.Text)
    @ApiModelProperty("商品促销活动集合JSON,key 为 促销活动类型,value 为 促销活动实体信息 ")
    private String promotionMapJson;
    @ApiModelProperty(value = "商品排序")
    private Integer goodsSort;
    public EsGoodsIndex(GoodsSku sku) {
        if (sku != null) {
framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
@@ -103,6 +103,7 @@
        NativeSearchQuery searchQuery = searchQueryBuilder.build();
        searchQuery.setTrackTotalHits(true);
        log.info("searchGoods DSL:{}", searchQuery.getQuery().toString());
        log.info("searchGoods sort:{}", searchQuery.getElasticsearchSorts().toString());
        SearchHits<EsGoodsIndex> search = restTemplate.search(searchQuery, EsGoodsIndex.class);
        return SearchHitSupport.searchPageFor(search, searchQuery.getPageable());
    }
@@ -476,7 +477,7 @@
            if (pageVo != null && CharSequenceUtil.isNotEmpty(pageVo.getOrder()) && CharSequenceUtil.isNotEmpty(pageVo.getSort())) {
                nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort(pageVo.getSort()).order(SortOrder.valueOf(pageVo.getOrder().toUpperCase())));
                nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort(pageVo.getSort()).order(SortOrder.valueOf(pageVo.getOrder().toUpperCase())).missing("_last"));
            } else {
                nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC));
            }
manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java
@@ -10,6 +10,7 @@
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.dto.GoodsSortDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
@@ -25,11 +26,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
 * 管理端,商品管理接口
@@ -115,6 +115,14 @@
        }
        throw new ServiceException(ResultCode.GOODS_UNDER_ERROR);
    }
    @DemoSite
    @PostMapping(value = "/goods/sort")
    public ResultMessage<Object> goodsSort(@RequestBody @Valid GoodsSortDTO req) {
        if (Boolean.TRUE.equals(goodsService.goodsSort(req))) {
            return ResultUtil.success();
        }
        throw  new RuntimeException("修改排序失败");
    }
    @PreventDuplicateSubmissions
    @ApiOperation(value = "管理员审核商品", notes = "管理员审核商品")