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