mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-15 10:41:54 +08:00
promotion:完善限时折扣的添加逻辑
This commit is contained in:
@@ -1,14 +1,57 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.sku;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO;
|
||||
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@Api(tags = "管理后台 - 商品 sku")
|
||||
@RestController
|
||||
@RequestMapping("/product/sku")
|
||||
@Validated
|
||||
public class ProductSkuController {
|
||||
|
||||
@Resource
|
||||
private ProductSkuService productSkuService;
|
||||
@Resource
|
||||
private ProductSpuService productSpuService;
|
||||
|
||||
@GetMapping("/get-option-list")
|
||||
@ApiOperation("获得商品 SKU 选项的列表")
|
||||
// @PreAuthorize("@ss.hasPermission('product:sku:query')")
|
||||
public CommonResult<List<ProductSkuOptionRespVO>> getSkuOptionList() {
|
||||
// 获得 SKU 列表
|
||||
List<ProductSkuDO> skus = productSkuService.getSkuList();
|
||||
if (CollUtil.isEmpty(skus)) {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
|
||||
// 获得对应的 SPU 映射
|
||||
Map<Long, ProductSpuDO> spuMap = productSpuService.getSpuMap(convertSet(skus, ProductSkuDO::getSpuId));
|
||||
// 转换为返回结果
|
||||
List<ProductSkuOptionRespVO> skuVOs = ProductSkuConvert.INSTANCE.convertList05(skus);
|
||||
skuVOs.forEach(sku -> MapUtils.findAndThen(spuMap, sku.getSpuId(),
|
||||
spu -> sku.setSpuId(spu.getId()).setSpuName(spu.getName())));
|
||||
return success(skuVOs);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel(value = "管理后台 - 商品 SKU 选项 Response VO", description = "用于前端 SELECT 选项")
|
||||
@Data
|
||||
public class ProductSkuOptionRespVO {
|
||||
|
||||
@ApiModelProperty(value = "主键", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品 SKU 名字", example = "红色")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "销售价格", required = true, example = "100", notes = "单位:分")
|
||||
private String price;
|
||||
|
||||
@ApiModelProperty(value = "库存", required = true, example = "100")
|
||||
private Integer stock;
|
||||
|
||||
// ========== 商品 SPU 信息 ==========
|
||||
|
||||
@ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1")
|
||||
private Long spuId;
|
||||
|
||||
@ApiModelProperty(value = "商品 SPU 名字", required = true, example = "iPhone 11")
|
||||
private String spuName;
|
||||
|
||||
}
|
@@ -9,7 +9,7 @@ import lombok.ToString;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 商品sku Response VO")
|
||||
@ApiModel("管理后台 - 商品 SKU Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.convert.sku;
|
||||
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuDetailRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
@@ -11,7 +12,7 @@ import org.mapstruct.factory.Mappers;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品sku Convert
|
||||
* 商品 SKU Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@@ -36,4 +37,6 @@ public interface ProductSkuConvert {
|
||||
|
||||
List<ProductSkuRespDTO> convertList04(List<ProductSkuDO> list);
|
||||
|
||||
List<ProductSkuOptionRespVO> convertList05(List<ProductSkuDO> skus);
|
||||
|
||||
}
|
||||
|
@@ -97,6 +97,7 @@ public class ProductSkuDO extends BaseDO {
|
||||
* 商品属性
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Property {
|
||||
|
||||
@@ -130,19 +131,5 @@ public class ProductSkuDO extends BaseDO {
|
||||
|
||||
}
|
||||
|
||||
// TODO ========== 待定字段:yv =========
|
||||
// TODO brokerage:一级返佣
|
||||
// TODO brokerage_two:二级返佣
|
||||
// TODO pink_price:拼团价
|
||||
// TODO pink_stock:拼团库存
|
||||
// TODO seckill_price:秒杀价
|
||||
// TODO seckill_stock:秒杀库存
|
||||
// TODO integral:需要积分
|
||||
|
||||
// TODO ========== 待定字段:cf =========
|
||||
// TODO type 活动显示排序 0=默认 1=秒 2=砍价 3=拼团
|
||||
// TODO quota 活动限购数量
|
||||
// TODO quota_show 活动限购数量显示
|
||||
|
||||
}
|
||||
|
||||
|
@@ -14,22 +14,29 @@ import java.util.List;
|
||||
public interface ProductSkuService {
|
||||
|
||||
/**
|
||||
* 删除商品sku
|
||||
* 删除商品 SKU
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteSku(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品sku
|
||||
* 获得商品 SKU 信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 商品sku
|
||||
* @return 商品 SKU 信息
|
||||
*/
|
||||
ProductSkuDO getSku(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品sku列表
|
||||
* 获得商品 SKU 列表
|
||||
*
|
||||
* @return 商品sku列表
|
||||
*/
|
||||
List<ProductSkuDO> getSkuList();
|
||||
|
||||
/**
|
||||
* 获得商品 SKU 列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 商品sku列表
|
||||
|
@@ -61,6 +61,11 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
return productSkuMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSkuDO> getSkuList() {
|
||||
return productSkuMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSkuDO> getSkuList(Collection<Long> ids) {
|
||||
return productSkuMapper.selectBatchIds(ids);
|
||||
|
@@ -9,6 +9,9 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* 商品 SPU Service 接口
|
||||
@@ -63,6 +66,16 @@ public interface ProductSpuService {
|
||||
*/
|
||||
List<ProductSpuDO> getSpuList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得商品 SPU 映射
|
||||
*
|
||||
* @param ids 编号数组
|
||||
* @return 商品 SPU 映射
|
||||
*/
|
||||
default Map<Long, ProductSpuDO> getSpuMap(Collection<Long> ids) {
|
||||
return convertMap(getSpuList(ids), ProductSpuDO::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得所有商品 SPU 列表
|
||||
*
|
||||
|
Reference in New Issue
Block a user