| | |
| | | package com.sinata.rest.modular.mall.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.sinata.rest.common.ApiUtils; |
| | | import com.sinata.rest.modular.mall.controller.vo.VoGoods; |
| | | import com.sinata.rest.modular.mall.controller.vo.VoGoodsDetail; |
| | | import com.sinata.rest.modular.mall.controller.vo.VoGoodsSpec; |
| | | import com.sinata.rest.modular.mall.controller.vo.VoGoodsSpecSet; |
| | | import com.sinata.rest.modular.mall.model.MallGoods; |
| | | import com.sinata.rest.modular.mall.model.MallGoodsSku; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.function.Function; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | Page page = new Page<VoGoods>(current, size); |
| | | // 查询商品信息 |
| | | List<VoGoods> list = goodsService.listGoods(EnumMallGoodsGroupType.GOODS.index, merchantId, goodsName, firstClassifyId, null, type, sortType, page); |
| | | Map<Integer, BigDecimal> minPriceSale = goodsSkuService.queryPlatMinSalePrice(null).stream() |
| | | .collect(Collectors.toMap(MallGoodsSku::getGoodsId, MallGoodsSku::getPriceSale)); |
| | | return ApiUtils.returnOK( |
| | | list.stream() |
| | | .map(o -> { |
| | | BigDecimal money = minPriceSale.get(o.getId()); |
| | | o.setTagList(mallTagService.getTagListByGoodsId(mallTags, o.getTagIds())); |
| | | o.setPriceSale(Optional.ofNullable(money).orElse(o.getPriceSale())); |
| | | return o; |
| | | }) |
| | | .collect(Collectors.toList()) |
| | |
| | | @ApiOperation(value = "推广商品") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "userId", value = "用户ID", defaultValue = "1", dataType = "Int", paramType = "query", required = true), |
| | | @ApiImplicitParam(name = "cityCode", value = "城市code", defaultValue = "1", dataType = "String", paramType = "query", required = true), |
| | | @ApiImplicitParam(name = "cityCode", value = "城市code", dataType = "String", paramType = "query", required = true), |
| | | @ApiImplicitParam(name = "current", value = "当前页数", defaultValue = "1", dataType = "Int", required = true, paramType = "query"), |
| | | @ApiImplicitParam(name = "size", value = "每页条数", defaultValue = "20", dataType = "Int", required = true, paramType = "query"), |
| | | }) |
| | |
| | | }) |
| | | public ApiUtils<VoGoodsDetail> detail(@PathVariable("id") Integer id) { |
| | | VoGoodsDetail o = goodsService.goodsDetail(id, null); |
| | | List<MallGoodsSku> skuList = goodsSkuService.queryPlatMinSalePrice(null); |
| | | Map<Integer, BigDecimal> minPriceSale = skuList.stream() |
| | | .collect(Collectors.toMap(MallGoodsSku::getGoodsId, MallGoodsSku::getPriceSale)); |
| | | Map<Integer, BigDecimal> minPriceMember = skuList.stream() |
| | | .collect(Collectors.toMap(MallGoodsSku::getGoodsId, MallGoodsSku::getPriceMember)); |
| | | if (o != null) { |
| | | BigDecimal money = minPriceSale.get(o.getId()); |
| | | BigDecimal minMemberMoney = minPriceMember.get(o.getId()); |
| | | o.setTagList(mallTagService.getTagListByGoodsId(null, o.getTagIds())); |
| | | o.setPriceSale(Optional.ofNullable(money).orElse(o.getPriceSale())); |
| | | o.setPriceMember(Optional.ofNullable(minMemberMoney).orElse(o.getPriceMerchant())); |
| | | } |
| | | return ApiUtils.returnOK(o); |
| | | } |
| | |
| | | @ApiOperation(value = "获取商品适用门店") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "商品ID", dataType = "Int", defaultValue = "1", paramType = "path"), |
| | | @ApiImplicitParam(name = "cityCode", value = "城市code", dataType = "Int", defaultValue = "1", paramType = "query") |
| | | @ApiImplicitParam(name = "cityCode", value = "城市code", dataType = "Int", paramType = "query") |
| | | }) |
| | | public ApiUtils<List<MemMerchant>> merchant(@PathVariable("id") Integer id, String cityCode) { |
| | | MallGoods goods = goodsService.getById(id); |