商品模块代码提交
This commit is contained in:
parent
60c382026f
commit
bc0ecd1fe6
|
|
@ -3,14 +3,12 @@ package com.czg.product.vo;
|
|||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.product.dto.ProdSkuDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格详情
|
||||
|
|
@ -107,10 +105,6 @@ public class ShopProductInfoVo implements Serializable {
|
|||
*/
|
||||
@JSONField(serialize = false)
|
||||
private LocalTime endTime;
|
||||
/**
|
||||
* 商品规格列表
|
||||
*/
|
||||
private List<ProdSkuDTO> skuList;
|
||||
|
||||
public Object getImages() {
|
||||
return JSON.parseArray(Convert.toStr(images, "[]"));
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package com.czg.product.vo;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.product.dto.ProdSkuDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 热销商品
|
||||
|
|
@ -80,6 +82,10 @@ public class ShopProductVo implements Serializable {
|
|||
* 是否热销 1-是 0-否
|
||||
*/
|
||||
private Integer isHot;
|
||||
/**
|
||||
* 商品规格列表
|
||||
*/
|
||||
private List<ProdSkuDTO> skuList;
|
||||
/**
|
||||
* 商品每周销售日 如:Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
queryWrapper.like(ShopProdUnit::getName, param.getName());
|
||||
}
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.eq(ShopProdUnit::getShopId, shopId);
|
||||
queryWrapper.and(q -> {
|
||||
q.eq(ShopProdUnit::getShopId, shopId).or(q1 -> {
|
||||
q1.eq(ShopProdUnit::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
|
||||
});
|
||||
});
|
||||
queryWrapper.orderBy(ShopProdUnit::getId, false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
|
@ -63,7 +67,12 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
@Override
|
||||
public void addShopProdUnit(ShopProdUnitDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName()).eq(ShopProdUnit::getShopId, shopId));
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName())
|
||||
.and(q -> {
|
||||
q.eq(ShopProdUnit::getShopId, shopId).or(q1 -> {
|
||||
q1.eq(ShopProdUnit::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
|
||||
});
|
||||
}));
|
||||
if (exists) {
|
||||
throw new CzgException("单位名称已存在");
|
||||
}
|
||||
|
|
@ -81,7 +90,14 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
public void updateShopProdUnit(ShopProdUnitDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName()).eq(ShopProdUnit::getShopId, shopId).ne(ShopProdUnit::getId, dto.getId()));
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName())
|
||||
.ne(ShopProdUnit::getId, dto.getId())
|
||||
.and(q -> {
|
||||
q.eq(ShopProdUnit::getShopId, shopId).or(q1 -> {
|
||||
q1.eq(ShopProdUnit::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
|
||||
});
|
||||
})
|
||||
);
|
||||
if (exists) {
|
||||
throw new CzgException("单位名称已存在");
|
||||
}
|
||||
|
|
@ -91,12 +107,26 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
|
||||
@Override
|
||||
public void deleteShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
super.remove(query().eq(ShopProdUnit::getId, id).eq(ShopProdUnit::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
UpdateChain.of(ShopProdUnit.class)
|
||||
.set(ShopProdUnit::getStatus, StatusEnum.DISABLE.value())
|
||||
|
|
@ -107,6 +137,13 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
|
||||
@Override
|
||||
public void enableShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
UpdateChain.of(ShopProdUnit.class)
|
||||
.set(ShopProdUnit::getStatus, StatusEnum.ENABLED.value())
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
|||
List<ShopProductVo> list = productMapper.selectHotsProductList(shopId);
|
||||
list.forEach(item -> {
|
||||
item.setIsSaleTime(calcIsSaleTime(item.getDays(), item.getStartTime(), item.getEndTime()));
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, item.getId()).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
|
||||
item.setSkuList(skuList);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
|
@ -71,6 +73,8 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
|||
List<ShopProductVo> productAllList = productMapper.selectGroupProductList(shopId);
|
||||
productAllList.forEach(item -> {
|
||||
item.setIsSaleTime(calcIsSaleTime(item.getDays(), item.getStartTime(), item.getEndTime()));
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, item.getId()).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
|
||||
item.setSkuList(skuList);
|
||||
});
|
||||
Map<Long, ShopProductVo> productKv = productAllList.stream().collect(Collectors.toMap(ShopProductVo::getId, shopProductVo -> shopProductVo));
|
||||
for (ShopGroupProductVo group : groupList) {
|
||||
|
|
@ -98,8 +102,6 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
|||
if (data == null) {
|
||||
throw new CzgException("商品不可售");
|
||||
}
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, data.getId()).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
|
||||
data.setSkuList(skuList);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue