diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 1f8b41fd6..95b4ff4b3 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -201,6 +201,7 @@ public enum ResultCode { AFTER_SALES_LOGISTICS_ERROR(33005, "物流公司错误,请重新选择"), AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"), RETURN_MONEY_OFFLINE_BANK_ERROR(33007, "当账号类型为银行转账时,银行信息不能为空"), + AFTER_SALES_PRICE_ERROR(33004, "申请退款金额错误"), /** * 投诉 diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/CategoryMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/CategoryMapper.java index 2610fb346..f6f837ee7 100644 --- a/framework/src/main/java/cn/lili/modules/goods/mapper/CategoryMapper.java +++ b/framework/src/main/java/cn/lili/modules/goods/mapper/CategoryMapper.java @@ -1,13 +1,7 @@ package cn.lili.modules.goods.mapper; import cn.lili.modules.goods.entity.dos.Category; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.toolkit.Constants; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; /** @@ -18,13 +12,4 @@ import java.util.List; */ public interface CategoryMapper extends BaseMapper { - /** - * 获取分类名称列表 - * - * @param queryWrapper 查询条件 - * @return 分类名称列表 - */ - @Select("SELECT name FROM li_category ${ew.customSqlSegment} ") - List getNamesByIds(@Param(Constants.WRAPPER) Wrapper queryWrapper); - } diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java index 0c9d21347..f38cc1d2c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java @@ -8,9 +8,6 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.vos.GoodsVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import java.util.List; @@ -20,7 +17,6 @@ import java.util.List; * @author pikachu * @since 2020-02-23 16:18:56 */ -@CacheConfig(cacheNames = "{goods}") public interface GoodsService extends IService { @@ -52,7 +48,6 @@ public interface GoodsService extends IService { * @param goodsOperationDTO 商品查询条件 * @param goodsId 商品ID */ - @CacheEvict(key = "#goodsId") void editGoods(GoodsOperationDTO goodsOperationDTO, String goodsId); /** @@ -61,7 +56,6 @@ public interface GoodsService extends IService { * @param goodsId 商品id * @return 商品VO */ - @Cacheable(key = "#goodsId") GoodsVO getGoodsVO(String goodsId); /** diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java index 8e455c252..4f16dc1fc 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java @@ -5,7 +5,6 @@ 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.GoodsSkuStockDTO; -import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -82,14 +81,6 @@ public interface GoodsSkuService extends IService { */ Map getGoodsSkuDetail(String goodsId, String skuId); - /** - * 根据商品分组商品sku及其规格信息 - * - * @param goodsId 商品id - * @return 分组后的商品sku及其规格信息 - */ - List groupBySkuAndSpec(String goodsId); - /** * 批量从redis中获取商品SKU信息 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index 33c9d44c5..fee5e73c2 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java @@ -144,9 +144,8 @@ public class CategoryServiceImpl extends ServiceImpl i */ @Override public List getCategoryNameByIds(List ids) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.in(Category::getId, ids); - return this.baseMapper.getNamesByIds(queryWrapper); + List categoryVOS = categoryTree().stream().filter(item -> ids.contains(item.getId())).map(Category::getName).collect(Collectors.toList()); + return categoryVOS; } @Override diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 3679103fb..6caf43549 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -46,6 +46,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -61,6 +64,7 @@ import java.util.List; */ @Service @Transactional(rollbackFor = Exception.class) +@CacheConfig(cacheNames = "{goods}") public class GoodsServiceImpl extends ServiceImpl implements GoodsService { @@ -153,6 +157,7 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override + @CachePut(key = "#goodsId") public void editGoods(GoodsOperationDTO goodsOperationDTO, String goodsId) { Goods goods = new Goods(goodsOperationDTO); goods.setId(goodsId); @@ -176,6 +181,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Cacheable(key = "#goodsId") public GoodsVO getGoodsVO(String goodsId) { //查询商品信息 Goods goods = this.getById(goodsId); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 571f87048..b4fdb9ed3 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -97,10 +97,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl i /** * 商品 */ + @Autowired private GoodsService goodsService; /** * 商品索引 */ + @Autowired private EsGoodsIndexService goodsIndexService; @Override @@ -204,14 +206,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override public Map getGoodsSkuDetail(String goodsId, String skuId) { Map map = new HashMap<>(16); + //获取商品VO + GoodsVO goodsVO = goodsService.getGoodsVO(goodsId); + //从缓存拿商品Sku GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); - GoodsVO goodsVO = goodsService.getGoodsVO(goodsId); - if (goodsVO == null || !goodsVO.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) - || !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name()) - || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { - throw new ServiceException(ResultCode.GOODS_NOT_EXIST); - } + //如果规格为空则使用商品ID进行查询 if (goodsSku == null) { skuId = goodsVO.getSkuList().get(0).getId(); @@ -221,11 +221,20 @@ public class GoodsSkuServiceImpl extends ServiceImpl i throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } } + + //商品为空||商品下架||商品未审核通过||商品删除,则提示:商品已下架 + if (goodsVO == null || goodsVO.getMarketEnable().equals(GoodsStatusEnum.DOWN.name()) + || !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name()) + || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); + } + //获取当前商品的索引信息 EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); if (goodsIndex == null) { goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); } + //商品规格 GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku); @@ -240,7 +249,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i map.put("categoryName", categoryService.getCategoryNameByIds(Arrays.asList(split))); //获取规格信息 - map.put("specs", this.groupBySkuAndSpec(goodsSkuDetail.getGoodsId())); + map.put("specs", this.groupBySkuAndSpec(goodsVO.getSkuList())); map.put("promotionMap", goodsIndex.getPromotionMap()); //获取参数信息 @@ -257,20 +266,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i return map; } - @Override - public List groupBySkuAndSpec(String goodsId) { - List goodsListByGoodsId = this.getGoodsListByGoodsId(goodsId); - List skuSpecVOList = new ArrayList<>(); - for (GoodsSkuVO goodsSkuVO : goodsListByGoodsId) { - GoodsSkuSpecVO specVO = new GoodsSkuSpecVO(); - specVO.setSkuId(goodsSkuVO.getId()); - specVO.setSpecValues(goodsSkuVO.getSpecList()); - specVO.setQuantity(goodsSkuVO.getQuantity()); - skuSpecVOList.add(specVO); - } - return skuSpecVOList; - } - /** * 更新商品sku状态 * @@ -341,7 +336,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override public GoodsSkuVO getGoodsSkuVO(GoodsSku goodsSku) { - //厨师还商品 + //初始化商品 GoodsSkuVO goodsSkuVO = new GoodsSkuVO(goodsSku); //获取sku信息 JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs()); @@ -677,13 +672,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } } - @Autowired - public void setGoodsService(GoodsService goodsService) { - this.goodsService = goodsService; + /** + * 根据商品分组商品sku及其规格信息 + * + * @param goodsSkuVOList 商品VO列表 + * @return 分组后的商品sku及其规格信息 + */ + private List groupBySkuAndSpec(List goodsSkuVOList) { + + List skuSpecVOList = new ArrayList<>(); + for (GoodsSkuVO goodsSkuVO : goodsSkuVOList) { + GoodsSkuSpecVO specVO = new GoodsSkuSpecVO(); + specVO.setSkuId(goodsSkuVO.getId()); + specVO.setSpecValues(goodsSkuVO.getSpecList()); + specVO.setQuantity(goodsSkuVO.getQuantity()); + skuSpecVOList.add(specVO); + } + return skuSpecVOList; } - @Autowired - public void setGoodsIndexService(EsGoodsIndexService goodsIndexService) { - this.goodsIndexService = goodsIndexService; - } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java index dc7c16274..4ccd21f1e 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.order.serviceimpl; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.aop.syslog.annotation.SystemLogPoint; @@ -181,12 +182,17 @@ public class AfterSaleServiceImpl extends ServiceImpl review(@NotNull(message = "请选择售后单") @PathVariable String afterSaleSn, @NotNull(message = "请审核") String serviceStatus, String remark, @@ -89,4 +90,10 @@ public class AfterSaleManagerController { return ResultUtil.data(afterSaleService.review(afterSaleSn, serviceStatus, remark,actualRefundPrice)); } + @ApiOperation(value = "获取商家售后收件地址") + @ApiImplicitParam(name = "sn", value = "售后单号", required = true, paramType = "path") + @GetMapping(value = "/getStoreAfterSaleAddress/{sn}") + public ResultMessage getStoreAfterSaleAddress(@NotNull(message = "售后单号") @PathVariable("sn") String sn) { + return ResultUtil.data(afterSaleService.getStoreAfterSaleAddressDTO(sn)); + } } diff --git a/seller-api/src/main/java/cn/lili/controller/trade/AfterSaleStoreController.java b/seller-api/src/main/java/cn/lili/controller/trade/AfterSaleStoreController.java index e12e9c4d7..668e4e4eb 100644 --- a/seller-api/src/main/java/cn/lili/controller/trade/AfterSaleStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/trade/AfterSaleStoreController.java @@ -6,6 +6,7 @@ import cn.lili.modules.order.order.entity.dos.AfterSale; import cn.lili.modules.order.order.entity.vo.AfterSaleSearchParams; import cn.lili.modules.order.order.entity.vo.AfterSaleVO; import cn.lili.modules.order.order.service.AfterSaleService; +import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO; import cn.lili.modules.system.entity.vo.Traces; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; @@ -88,4 +89,11 @@ public class AfterSaleStoreController { return ResultUtil.data(afterSaleService.deliveryTraces(sn)); } + @ApiOperation(value = "获取商家售后收件地址") + @ApiImplicitParam(name = "sn", value = "售后单号", required = true, paramType = "path") + @GetMapping(value = "/getStoreAfterSaleAddress/{sn}") + public ResultMessage getStoreAfterSaleAddress(@NotNull(message = "售后单号") @PathVariable("sn") String sn) { + return ResultUtil.data(afterSaleService.getStoreAfterSaleAddressDTO(sn)); + } + }