This commit is contained in:
lifenlong 2021-06-24 15:29:29 +08:00
commit 02becd70b2
8 changed files with 117 additions and 62 deletions

View File

@ -64,6 +64,10 @@ public class DraftGoods extends BaseEntity {
@ApiModelProperty(value = "详情") @ApiModelProperty(value = "详情")
private String intro; private String intro;
@ApiModelProperty(value = "商品移动端详情")
private String mobileIntro;
@Max(value = 99999999, message = "价格不能超过99999999") @Max(value = 99999999, message = "价格不能超过99999999")
@ApiModelProperty(value = "商品价格") @ApiModelProperty(value = "商品价格")
private Double price; private Double price;
@ -114,11 +118,6 @@ public class DraftGoods extends BaseEntity {
@ApiModelProperty(value = "是否自营") @ApiModelProperty(value = "是否自营")
private Boolean selfOperated; private Boolean selfOperated;
/**
* 商品移动端详情
*/
@ApiModelProperty(value = "商品移动端详情")
private String mobileIntro;
@ApiModelProperty(value = "商品视频") @ApiModelProperty(value = "商品视频")
private String goodsVideo; private String goodsVideo;

View File

@ -26,14 +26,24 @@ public class SpecValueVO implements Serializable {
@ApiModelProperty(value = "规格值") @ApiModelProperty(value = "规格值")
private String specValue; private String specValue;
/**
* 规格类型1图片 0 非图片
*/
@ApiModelProperty(value = "该规格是否有图片1 有 0 没有") @ApiModelProperty(value = "该规格是否有图片1 有 0 没有")
private Integer specType; private Integer specType;
/** /**
* 规格图片 * 规格图片
*/ */
@ApiModelProperty(value = "规格的图片") @ApiModelProperty(value = "规格的图片")
private List<String> specImage; private List<SpecImages> specImage;
@Data
public static class SpecImages implements Serializable {
private static final long serialVersionUID = 1816357809660916086L;
private String url;
private String name;
private String status;
}
} }

View File

@ -23,6 +23,21 @@ public interface GoodsParamsService extends IService<GoodsParams> {
*/ */
void addParams(List<GoodsParams> paramList, String goodsId); void addParams(List<GoodsParams> paramList, String goodsId);
/**
* 更新商品参数是否索引
*
* @param paramId 参数id
* @param isIndex 是否索引
*/
void updateParametersIsIndex(String paramId, Integer isIndex);
/**
* 根据参数id删除已经设置的商品参数
*
* @param paramId 参数id
*/
void deleteByParamId(String paramId);
/** /**
* 获取商品关联参数 * 获取商品关联参数
* *

View File

@ -2,7 +2,6 @@ package cn.lili.modules.goods.serviceimpl;
import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup;
import cn.lili.modules.goods.entity.dos.GoodsParams; import cn.lili.modules.goods.entity.dos.GoodsParams;
import cn.lili.modules.goods.entity.dos.Parameters;
import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO;
import cn.lili.modules.goods.entity.vos.GoodsParamsVO; import cn.lili.modules.goods.entity.vos.GoodsParamsVO;
import cn.lili.modules.goods.mapper.GoodsParamsMapper; import cn.lili.modules.goods.mapper.GoodsParamsMapper;
@ -10,9 +9,10 @@ import cn.lili.modules.goods.service.CategoryParameterGroupService;
import cn.lili.modules.goods.service.GoodsParamsService; import cn.lili.modules.goods.service.GoodsParamsService;
import cn.lili.modules.goods.service.ParametersService; import cn.lili.modules.goods.service.ParametersService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -38,8 +38,6 @@ public class GoodsParamsServiceImpl extends ServiceImpl<GoodsParamsMapper, Goods
@Autowired @Autowired
private CategoryParameterGroupService categoryParameterGroupService; private CategoryParameterGroupService categoryParameterGroupService;
@Autowired
private ParametersService parametersService;
@Override @Override
public void addParams(List<GoodsParams> paramList, String goodsId) { public void addParams(List<GoodsParams> paramList, String goodsId) {
@ -48,18 +46,41 @@ public class GoodsParamsServiceImpl extends ServiceImpl<GoodsParamsMapper, Goods
//循环添加参数 //循环添加参数
if (paramList != null) { if (paramList != null) {
for (GoodsParams param : paramList) { for (GoodsParams param : paramList) {
Parameters parameters = parametersService.getById(param.getParamId());
GoodsParams goodsParams = new GoodsParams(); GoodsParams goodsParams = new GoodsParams();
goodsParams.setGoodsId(goodsId); goodsParams.setGoodsId(goodsId);
goodsParams.setParamName(param.getParamName()); goodsParams.setParamName(param.getParamName());
goodsParams.setParamValue(param.getParamValue()); goodsParams.setParamValue(param.getParamValue());
goodsParams.setIsIndex(parameters.getIsIndex()); goodsParams.setIsIndex(param.getIsIndex());
goodsParams.setParamId(param.getId()); goodsParams.setParamId(param.getId());
this.save(goodsParams); this.save(goodsParams);
} }
} }
} }
/**
* 更新商品参数是否索引
*
* @param paramId 参数id
* @param isIndex 是否索引
*/
@Override
public void updateParametersIsIndex(String paramId, Integer isIndex) {
LambdaUpdateWrapper<GoodsParams> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(GoodsParams::getParamId, paramId);
updateWrapper.set(GoodsParams::getIsIndex, isIndex);
this.update(updateWrapper);
}
/**
* 根据参数id删除已经设置的商品参数
*
* @param paramId 参数id
*/
@Override
public void deleteByParamId(String paramId) {
this.remove(new QueryWrapper<GoodsParams>().eq("param_id", paramId));
}
@Override @Override
public List<GoodsParams> getGoodsParamsByGoodsId(String goodsId) { public List<GoodsParams> getGoodsParamsByGoodsId(String goodsId) {
return this.list(new LambdaQueryWrapper<GoodsParams>().eq(GoodsParams::getGoodsId, goodsId)); return this.list(new LambdaQueryWrapper<GoodsParams>().eq(GoodsParams::getGoodsId, goodsId));

View File

@ -11,6 +11,7 @@ import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.common.rocketmq.tags.GoodsTagsEnum; import cn.lili.common.rocketmq.tags.GoodsTagsEnum;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.config.rocketmq.RocketmqCustomProperties;
import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsParams; import cn.lili.modules.goods.entity.dos.GoodsParams;
@ -44,6 +45,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 商品sku业务层实现 * 商品sku业务层实现
@ -64,9 +66,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
//商品相册 //商品相册
@Autowired @Autowired
private GoodsGalleryService goodsGalleryService; private GoodsGalleryService goodsGalleryService;
//规格
@Autowired
private SpecificationService specificationService;
//缓存 //缓存
@Autowired @Autowired
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@ -317,33 +316,30 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
@Override @Override
public GoodsSkuVO getGoodsSkuVO(GoodsSku goodsSku) { public GoodsSkuVO getGoodsSkuVO(GoodsSku goodsSku) {
//厨师还商品
GoodsSkuVO goodsSkuVO = new GoodsSkuVO(goodsSku); GoodsSkuVO goodsSkuVO = new GoodsSkuVO(goodsSku);
//获取sku信息
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs()); JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
//用于接受sku信息
List<SpecValueVO> specValueVOS = new ArrayList<>(); List<SpecValueVO> specValueVOS = new ArrayList<>();
//用于接受sku相册
List<String> goodsGalleryList = new ArrayList<>(); List<String> goodsGalleryList = new ArrayList<>();
// for (Map.Entry<String, Object> entry : jsonObject.entrySet()) { //循环提交的sku表单
// SpecValueVO s = new SpecValueVO(); for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
// if (entry.getKey().equals("images")) { SpecValueVO specValueVO = new SpecValueVO();
// s.setSpecName(entry.getKey()); if (entry.getKey().equals("images")) {
// if (entry.getValue().toString().contains("url")) { specValueVO.setSpecName(entry.getKey());
// List<SpecValueVO.SpecImages> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class); if (entry.getValue().toString().contains("url")) {
// s.setSpecImage(specImages); List<SpecValueVO.SpecImages> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class);
// goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList()); specValueVO.setSpecImage(specImages);
// } goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList());
// } else { }
// SpecificationVO specificationVO = new SpecificationVO(); } else {
// specificationVO.setSpecName(entry.getKey()); specValueVO.setSpecName(entry.getKey());
// specificationVO.setStoreId(goodsSku.getStoreId()); specValueVO.setSpecValue(entry.getValue().toString());
// specificationVO.setCategoryPath(goodsSku.getCategoryPath()); }
// Specification specification = specificationService.addSpecification(specificationVO); specValueVOS.add(specValueVO);
// s.setSpecNameId(specification.getId()); }
// SpecValues specValues = specValuesService.getSpecValues(entry.getValue().toString(), specification.getId());
// s.setSpecValueId(specValues.getId());
// s.setSpecName(entry.getKey());
// s.setSpecValue(entry.getValue().toString());
// }
// specValueVOS.add(s);
// }
goodsSkuVO.setGoodsGalleryList(goodsGalleryList); goodsSkuVO.setGoodsGalleryList(goodsGalleryList);
goodsSkuVO.setSpecList(specValueVOS); goodsSkuVO.setSpecList(specValueVOS);
return goodsSkuVO; return goodsSkuVO;
@ -603,29 +599,34 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
List<EsGoodsAttribute> attributes = new ArrayList<>(); List<EsGoodsAttribute> attributes = new ArrayList<>();
//获取规格信息 //获取规格信息
for (Map.Entry<String, Object> m : map.entrySet()) { for (Map.Entry<String, Object> spec : map.entrySet()) {
//保存规格信息 //保存规格信息
if (m.getKey().equals("id") || m.getKey().equals("sn") || m.getKey().equals("cost") || m.getKey().equals("price") || m.getKey().equals("quantity") || m.getKey().equals("weight")) { if (spec.getKey().equals("id") || spec.getKey().equals("sn") || spec.getKey().equals("cost")
|| spec.getKey().equals("price") || spec.getKey().equals("quantity")
|| spec.getKey().equals("weight")) {
continue; continue;
} else { } else {
specMap.put(m.getKey(), m.getValue()); specMap.put(spec.getKey(), spec.getValue());
if (m.getKey().equals("images")) { if (spec.getKey().equals("images")) {
//设置规格商品缩略图 //设置规格商品缩略图
List<Map<String, String>> images = (List<Map<String, String>>) m.getValue(); List<Map<String, String>> images = (List<Map<String, String>>) spec.getValue();
if (images == null || images.isEmpty()) { if (images == null || images.isEmpty()) {
throw new ServiceException("sku图片至少为一个"); continue;
}
//设置规格商品缩略图
//如果规格没有图片则用商品图片复盖有则增加规格图片放在商品图片集合之前
if (spec.getValue() != null && StringUtils.isNotEmpty(spec.getValue().toString())) {
thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail();
small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall();
} else {
//设置商品名称
goodsName.append(" ").append(spec.getValue());
//规格简短信息
simpleSpecs.append(" ").append(spec.getValue());
} }
thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail();
small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall();
} else {
//设置商品名称
goodsName.append(" ").append(m.getValue());
//规格简短信息
simpleSpecs.append(" ").append(m.getValue());
} }
} }
} }
//设置规格信息 //设置规格信息
sku.setGoodsName(goodsName.toString()); sku.setGoodsName(goodsName.toString());
sku.setThumbnail(thumbnail); sku.setThumbnail(thumbnail);
@ -656,4 +657,4 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
public void setGoodsIndexService(EsGoodsIndexService goodsIndexService) { public void setGoodsIndexService(EsGoodsIndexService goodsIndexService) {
this.goodsIndexService = goodsIndexService; this.goodsIndexService = goodsIndexService;
} }
} }

View File

@ -4,7 +4,6 @@ import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.enums.UserEnums;
import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.DateUtil;
import cn.lili.config.properties.StatisticsProperties; import cn.lili.config.properties.StatisticsProperties;
import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.base.entity.enums.ClientTypeEnum;
import cn.lili.modules.member.entity.vo.MemberDistributionVO; import cn.lili.modules.member.entity.vo.MemberDistributionVO;
@ -52,6 +51,9 @@ public class PlatformViewDataServiceImpl extends ServiceImpl<PlatformViewDataMap
@Autowired @Autowired
private Cache cache; private Cache cache;
//平台流量统计
@Autowired
private PlatformViewDataMapper platformViewDataMapper;
@Override @Override
public Long online() { public Long online() {
@ -221,8 +223,6 @@ public class PlatformViewDataServiceImpl extends ServiceImpl<PlatformViewDataMap
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
System.out.println(DateUtil.toString(calendar.getTime().getTime(), DateUtil.STANDARD_FORMAT));
//如果是今天的统计则从redis 中拿否则从数据库中拿 //如果是今天的统计则从redis 中拿否则从数据库中拿
if (dates[0].equals(calendar.getTime())) { if (dates[0].equals(calendar.getTime())) {
if (StringUtils.isNotEmpty(queryParam.getStoreId())) { if (StringUtils.isNotEmpty(queryParam.getStoreId())) {
@ -238,7 +238,7 @@ public class PlatformViewDataServiceImpl extends ServiceImpl<PlatformViewDataMap
} else { } else {
queryWrapper.eq("store_id", -1); queryWrapper.eq("store_id", -1);
} }
return this.count(queryWrapper); return platformViewDataMapper.count(queryWrapper);
} }
} }

View File

@ -1,10 +1,11 @@
package cn.lili.controller.goods; package cn.lili.controller.goods;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.enums.ResultUtil; import cn.lili.common.enums.ResultUtil;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.ResultMessage; import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Parameters; import cn.lili.modules.goods.entity.dos.Parameters;
import cn.lili.modules.goods.service.GoodsParamsService;
import cn.lili.modules.goods.service.ParametersService; import cn.lili.modules.goods.service.ParametersService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -28,6 +29,9 @@ public class ParameterManagerController {
@Autowired @Autowired
private ParametersService parametersService; private ParametersService parametersService;
@Autowired
private GoodsParamsService goodsParamsService;
@ApiOperation(value = "添加参数") @ApiOperation(value = "添加参数")
@PostMapping @PostMapping
public ResultMessage<Parameters> save(@Valid Parameters parameters) { public ResultMessage<Parameters> save(@Valid Parameters parameters) {
@ -44,6 +48,9 @@ public class ParameterManagerController {
public ResultMessage<Parameters> update(@Valid Parameters parameters) { public ResultMessage<Parameters> update(@Valid Parameters parameters) {
if (parametersService.updateById(parameters)) { if (parametersService.updateById(parameters)) {
if (parameters.getIsIndex() != null) {
goodsParamsService.updateParametersIsIndex(parameters.getId(), parameters.getIsIndex());
}
return ResultUtil.data(parameters); return ResultUtil.data(parameters);
} }
throw new ServiceException(ResultCode.PARAMETER_UPDATE_ERROR); throw new ServiceException(ResultCode.PARAMETER_UPDATE_ERROR);
@ -54,6 +61,7 @@ public class ParameterManagerController {
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
public ResultMessage<Object> delById(@PathVariable String id) { public ResultMessage<Object> delById(@PathVariable String id) {
parametersService.removeById(id); parametersService.removeById(id);
goodsParamsService.deleteByParamId(id);
return ResultUtil.success(); return ResultUtil.success();
} }

View File

@ -7,6 +7,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -29,7 +30,7 @@ public class SpecificationStoreController {
@GetMapping(value = "/{categoryId}") @GetMapping(value = "/{categoryId}")
@ApiOperation(value = "获取分类规格") @ApiOperation(value = "获取分类规格")
public List<Specification> getSpecifications(String categoryId) { public List<Specification> getSpecifications(@PathVariable String categoryId) {
return categorySpecificationService.getCategorySpecList(categoryId); return categorySpecificationService.getCategorySpecList(categoryId);
} }