优化商品显示逻辑

售后价格判断
This commit is contained in:
lifenlong 2021-07-23 19:44:46 +08:00
parent 66e9a4f4cc
commit 2c8ac59628
11 changed files with 67 additions and 65 deletions

View File

@ -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, "申请退款金额错误"),
/**
* 投诉

View File

@ -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<Category> {
/**
* 获取分类名称列表
*
* @param queryWrapper 查询条件
* @return 分类名称列表
*/
@Select("SELECT name FROM li_category ${ew.customSqlSegment} ")
List<String> getNamesByIds(@Param(Constants.WRAPPER) Wrapper<Category> queryWrapper);
}

View File

@ -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<Goods> {
@ -52,7 +48,6 @@ public interface GoodsService extends IService<Goods> {
* @param goodsOperationDTO 商品查询条件
* @param goodsId 商品ID
*/
@CacheEvict(key = "#goodsId")
void editGoods(GoodsOperationDTO goodsOperationDTO, String goodsId);
/**
@ -61,7 +56,6 @@ public interface GoodsService extends IService<Goods> {
* @param goodsId 商品id
* @return 商品VO
*/
@Cacheable(key = "#goodsId")
GoodsVO getGoodsVO(String goodsId);
/**

View File

@ -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<GoodsSku> {
*/
Map<String, Object> getGoodsSkuDetail(String goodsId, String skuId);
/**
* 根据商品分组商品sku及其规格信息
*
* @param goodsId 商品id
* @return 分组后的商品sku及其规格信息
*/
List<GoodsSkuSpecVO> groupBySkuAndSpec(String goodsId);
/**
* 批量从redis中获取商品SKU信息
*

View File

@ -144,9 +144,8 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
*/
@Override
public List<String> getCategoryNameByIds(List<String> ids) {
LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(Category::getId, ids);
return this.baseMapper.getNamesByIds(queryWrapper);
List<String> categoryVOS = categoryTree().stream().filter(item -> ids.contains(item.getId())).map(Category::getName).collect(Collectors.toList());
return categoryVOS;
}
@Override

View File

@ -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<GoodsMapper, Goods> implements GoodsService {
@ -153,6 +157,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> 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<GoodsMapper, Goods> implements
}
@Override
@Cacheable(key = "#goodsId")
public GoodsVO getGoodsVO(String goodsId) {
//查询商品信息
Goods goods = this.getById(goodsId);

View File

@ -97,10 +97,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
/**
* 商品
*/
@Autowired
private GoodsService goodsService;
/**
* 商品索引
*/
@Autowired
private EsGoodsIndexService goodsIndexService;
@Override
@ -204,14 +206,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
@Override
public Map<String, Object> getGoodsSkuDetail(String goodsId, String skuId) {
Map<String, Object> 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<GoodsSkuMapper, GoodsSku> 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<GoodsSkuMapper, GoodsSku> 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<GoodsSkuMapper, GoodsSku> i
return map;
}
@Override
public List<GoodsSkuSpecVO> groupBySkuAndSpec(String goodsId) {
List<GoodsSkuVO> goodsListByGoodsId = this.getGoodsListByGoodsId(goodsId);
List<GoodsSkuSpecVO> 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<GoodsSkuMapper, GoodsSku> 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<GoodsSkuMapper, GoodsSku> i
}
}
@Autowired
public void setGoodsService(GoodsService goodsService) {
this.goodsService = goodsService;
/**
* 根据商品分组商品sku及其规格信息
*
* @param goodsSkuVOList 商品VO列表
* @return 分组后的商品sku及其规格信息
*/
private List<GoodsSkuSpecVO> groupBySkuAndSpec(List<GoodsSkuVO> goodsSkuVOList) {
List<GoodsSkuSpecVO> 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;
}
}

View File

@ -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<AfterSaleMapper, AfterSale
public AfterSale review(String afterSaleSn, String serviceStatus, String remark, Double actualRefundPrice) {
//根据售后单号获取售后单
AfterSale afterSale = OperationalJudgment.judgment(this.getBySn(afterSaleSn));
afterSale.setActualRefundPrice(actualRefundPrice);
//判断为待审核的售后服务
if (!afterSale.getServiceStatus().equals(AfterSaleStatusEnum.APPLY.name())) {
throw new ServiceException(ResultCode.AFTER_SALES_DOUBLE_ERROR);
}
//判断退款金额与付款金额是否正确,退款金额不能小于付款金额
if (NumberUtil.compare(afterSale.getFlowPrice(), actualRefundPrice) == -1) {
throw new ServiceException(ResultCode.AFTER_SALES_PRICE_ERROR);
}
afterSale.setActualRefundPrice(actualRefundPrice);
//判断审核状态
//如果售后类型为退款审核状态为已通过并且退款方式为原路退回售后单状态为已完成

View File

@ -14,7 +14,7 @@ public enum AfterSaleStatusEnum {
APPLY("申请中"),
PASS("已通过"),
REFUSE("已拒绝"),
BUYER_RETURN("买家退货,待卖家收货"),
BUYER_RETURN("待卖家收货"),
SELLER_CONFIRM("卖家确认收货"),
SELLER_TERMINATION("卖家终止售后"),
BUYER_CANCEL("买家取消售后"),

View File

@ -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;
@ -80,7 +81,7 @@ public class AfterSaleManagerController {
@ApiImplicitParam(name = "remark", value = "备注", paramType = "query"),
@ApiImplicitParam(name = "actualRefundPrice", value = "实际退款金额", paramType = "query")
})
@PutMapping(value = "/review/{afterSaleSn}")
@PutMapping(value = "/confirm/{afterSaleSn}")
public ResultMessage<AfterSale> 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<StoreAfterSaleAddressDTO> getStoreAfterSaleAddress(@NotNull(message = "售后单号") @PathVariable("sn") String sn) {
return ResultUtil.data(afterSaleService.getStoreAfterSaleAddressDTO(sn));
}
}

View File

@ -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<StoreAfterSaleAddressDTO> getStoreAfterSaleAddress(@NotNull(message = "售后单号") @PathVariable("sn") String sn) {
return ResultUtil.data(afterSaleService.getStoreAfterSaleAddressDTO(sn));
}
}