超市接口

This commit is contained in:
zjf committed 2025-01-08 12:23:10 +08:00
1 parent 1e9b646752
commit c2e0d8c31d
10 files changed
+293 -176

No files matched your search

@@ -0,0 +1,52 @@
package com.bsd.pjcloud.supermarket.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "App商品 SPU 查询参数")
public class SupermarketSpuAppQueryDTO {
/**
* 商品 SPU 编号,自增
*/
// @Schema(description="商品 SPU 编号,自增")
// private Long id;
// /**
// * 货号
// */
// @Schema(description="货号")
// private String productCode;
//
// /**
// * 自编码/条码
// */
// @Schema(description="自编码/条码")
// private String barcode;
/**
* 商品名称
*/
@Schema(description="商品名称")
private String productName;
/**
* 商品分类编号
*/
@Schema(description="商品分类编号")
private Long categoryId;
/**
* 商品性质(字典)
*/
// @Schema(description="商品性质(字典)")
// private String productNature;
/**
* 商户id
*/
@Schema(description="商户id")
private Long merchantId;
}
@@ -1,158 +0,0 @@
package com.bsd.pjcloud.supermarket.vo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
@Schema(description="ad spu详情")
public class SupermarketSpuDetailsVo {
/**
* 商品 SPU 编号,自增
*/
@Schema(description="商品 SPU 编号,自增")
private Long id;
/**
* 货号
*/
@Schema(description="货号")
private String productCode;
/**
* 自编码/条码
*/
@Schema(description="自编码/条码")
private String barcode;
/**
* 商品名称
*/
@Schema(description="商品名称")
private String productName;
/**
* 单位
*/
@Schema(description="单位")
private String unit;
/**
* 商品简介
*/
@Schema(description="商品简介")
private String introduction;
/**
* 商品详情
*/
@Schema(description="商品详情")
private String description;
/**
* 商品分类编号
*/
@Schema(description="商品分类编号")
private Long categoryId;
/**
* 商品封面图
*/
@Schema(description="商品封面图")
private String picUrl;
/**
* 商品轮播图地址
数组,以逗号分隔
最多上传15张
*/
@Schema(description="商品轮播图地址")
private String sliderPicUrls;
/**
* 库存
*/
@Schema(description="总库存")
private Integer stock;
/**
* 赠送积分
*/
@Schema(description="赠送积分")
private Integer giveIntegral;
/**
* 商户编号
*/
@Schema(description="商户编号")
private Long merchantId;
/**
* 产地
*/
@Schema(description="产地")
private String origin;
/**
* 商品性质(字典)
*/
@Schema(description="商品性质(字典)")
private String productNature;
/**
* 品牌id
*/
@Schema(description="品牌id")
private Long brandId;
/**
* 货商id
*/
@Schema(description="货商id")
private Long supplierId;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
@Schema(description = "销量")
private Integer salesCount;
}
@@ -20,7 +20,6 @@ import java.time.LocalDateTime;
*/
@Data
@TenantTable
@TableName("supermarket_unit")
@Schema(description = "商品包装单位(sku)")
public class SupermarketUnitVo{
@@ -0,0 +1,57 @@
package com.bsd.pjcloud.supermarket.vo.app;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Data
@Schema(description="app Spuvo")
public class SupermarketAppSpuDetailsVo {
/**
* 商品 SPU 编号,自增
*/
@Schema(description="商品 SPU 编号")
private Long id;
/**
* 商品名称
*/
@Schema(description="商品名称")
private String productName;
/**
* 商品封面图
*/
@Schema(description="商品封面图")
private String picUrl;
/**
* 库存
*/
@Schema(description="剩余库存")
private Integer stock;
/**
* 商户编号
*/
@Schema(description="商户编号")
private Long merchantId;
@Schema(description = "销量")
private Integer salesCount;
@Schema(description = "包装单位集合(sku)")
private List<SupermarketAppUnitVo> skuList;
}
@@ -0,0 +1,54 @@
package com.bsd.pjcloud.supermarket.vo.app;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Data
@Schema(description="app Spuvo")
public class SupermarketAppSpuVo {
/**
* 商品 SPU 编号,自增
*/
@Schema(description="商品 SPU 编号")
private Long id;
/**
* 商品名称
*/
@Schema(description="商品名称")
private String productName;
/**
* 商品封面图
*/
@Schema(description="商品封面图")
private String picUrl;
/**
* 库存
*/
@Schema(description="剩余库存")
private Integer stock;
/**
* 商户编号
*/
@Schema(description="商户编号")
private Long merchantId;
@Schema(description = "销量")
private Integer salesCount;
}
@@ -0,0 +1,82 @@
package com.bsd.pjcloud.supermarket.vo.app;
import com.baomidou.mybatisplus.annotation.*;
import com.bsd.pjcloud.common.core.util.MoneyDeserializer;
import com.bsd.pjcloud.common.core.util.MoneySerializer;
import com.bsd.pjcloud.common.core.util.TenantTable;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 商品包装单位(sku)
*
* @author zjf
* @date 2024-12-26 11:06:54
*/
@Data
@TenantTable
@Schema(description = "商品包装单位(sku)")
public class SupermarketAppUnitVo {
/**
* 包装单位id
*/
@Schema(description="包装单位id")
private Long id;
/**
* 条码
*/
@Schema(description="条码")
private String barCode;
/**
* 规格
*/
@Schema(description="规格")
private String spec;
/**
* 单位
*/
@Schema(description="单位")
private String unit;
/**
* 内装数量
*/
@Schema(description="内装数量")
private Integer packageNum;
/**
* 零售价/单位分
*/
@Schema(description="零售价")
@JsonSerialize(using = MoneySerializer.class) // 分 -> 元
@JsonDeserialize(using = MoneyDeserializer.class) // 元 -> 分
private Integer retailPrice;
/**
* spuID
*/
@Schema(description="spuID")
private Long spuId;
/**
* 促销价
*/
@Schema(description="促销价")
@JsonSerialize(using = MoneySerializer.class) // 分 -> 元
@JsonDeserialize(using = MoneyDeserializer.class) // 元 -> 分
private Integer promotionPrice;
}
@@ -1,8 +1,9 @@
package com.bsd.pjcloud.supermarket.vo;
package com.bsd.pjcloud.supermarket.vo.app;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.bsd.pjcloud.supermarket.vo.SupermarketUnitVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -10,13 +11,13 @@ import java.time.LocalDateTime;
import java.util.List;
@Data
@Schema(description="app Spuvo")
public class SupermarketAppSpuVo {
@Schema(description="ad spu详情")
public class SupermarketSpuAppDetailsVo {
/**
* 商品 SPU 编号,自增
*/
@Schema(description="商品 SPU 编号,自增")
@Schema(description="商品 SPU 编号")
private Long id;
/**
@@ -156,9 +157,6 @@ public class SupermarketAppSpuVo {
@Schema(description = "辅助条码集合")
private List<SupermarketAuxiliaryCodeVo> supermarketAuxiliaryCodeEntityList;
@Schema(description = "包装对象集合")
private List<SupermarketUnitVo> supermarketUnitEntityList;
@@ -10,6 +10,7 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuAppQueryDTO;
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuQueryDTO;
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO;
import com.bsd.pjcloud.supermarket.entity.SupermarketAuxiliaryCodeEntity;
@@ -18,7 +19,7 @@ import com.bsd.pjcloud.supermarket.entity.SupermarketUnitEntity;
import com.bsd.pjcloud.supermarket.service.SupermarketAuxiliaryCodeService;
import com.bsd.pjcloud.supermarket.service.SupermarketSpuService;
import com.bsd.pjcloud.supermarket.service.SupermarketUnitService;
import com.bsd.pjcloud.supermarket.vo.SupermarketAppSpuVo;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -27,7 +28,6 @@ import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -173,6 +173,7 @@ public class SupermarketSpuController {
@PostMapping("/ad/updateSpuStock")
@Operation(summary = "更新库存" , description = "app和安卓公用" )
@SysLog("更新商品库存")
public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO){
return supermarketSpuService.updateSpuStock(updateStockReqDTO);
@@ -187,20 +188,32 @@ public class SupermarketSpuController {
* @param supermarketSpuQueryDTO 商品spu
* @return
*/
@Operation(summary = "APP机条件查询所有SPU" , description = "APP条件查询所有" )
@Operation(summary = "APP根据条件查询分页SPU" , description = "APP条件分页查询" )
@PostMapping("/app/selectListAll" )
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
public R getSupermarketSpu(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO) {
public R<List<SupermarketAppSpuVo>> getSupermarketSpu(@RequestBody SupermarketSpuAppQueryDTO supermarketSpuQueryDTO,@ParameterObject Page page) {
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(supermarketSpuQueryDTO.getMerchantId() != null, SupermarketSpuEntity::getMerchantId, supermarketSpuQueryDTO.getMerchantId());
wrapper.eq(StrUtil.isNotBlank(supermarketSpuQueryDTO.getProductCode()), SupermarketSpuEntity::getProductCode, supermarketSpuQueryDTO.getProductCode());
wrapper.eq(StrUtil.isNotBlank(supermarketSpuQueryDTO.getBarcode()), SupermarketSpuEntity::getBarcode, supermarketSpuQueryDTO.getBarcode());
// wrapper.eq(StrUtil.isNotBlank(supermarketSpuQueryDTO.getProductCode()), SupermarketSpuEntity::getProductCode, supermarketSpuQueryDTO.getProductCode());
// wrapper.eq(StrUtil.isNotBlank(supermarketSpuQueryDTO.getBarcode()), SupermarketSpuEntity::getBarcode, supermarketSpuQueryDTO.getBarcode());
wrapper.like(StrUtil.isNotBlank(supermarketSpuQueryDTO.getProductName()), SupermarketSpuEntity::getProductName, supermarketSpuQueryDTO.getProductName());
List<SupermarketSpuEntity> list = supermarketSpuService.list(wrapper);
Page pageDate = supermarketSpuService.page(page, wrapper);
List list = pageDate.getRecords();
List<SupermarketAppSpuVo> bean = BeanUtils.toBean(list, SupermarketAppSpuVo.class);
pageDate.setRecords(bean);
return R.ok(bean);
}
/**
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
* @param id
* @return
*/
@Operation(summary = "app获取spu详情" , description = "根据spu的id" )
@GetMapping("/app/SpuDetails" )
public R getSupermarketSpuAppDetailById(@RequestParam("id")Long id) {
return R.ok(supermarketSpuService.getSupermarketSpuAppDetailById(id));
}
}
@@ -52,4 +52,12 @@ public interface SupermarketSpuService extends IService<SupermarketSpuEntity> {
* @return
*/
Object getSupermarketSpuDetailById(Long id);
/**
* app端查询商品详情
* @param id
* @return
*/
Object getSupermarketSpuAppDetailById(Long id);
}
@@ -15,9 +15,10 @@ import com.bsd.pjcloud.supermarket.mapper.SupermarketSpuMapper;
import com.bsd.pjcloud.supermarket.service.SupermarketAuxiliaryCodeService;
import com.bsd.pjcloud.supermarket.service.SupermarketSpuService;
import com.bsd.pjcloud.supermarket.service.SupermarketUnitService;
import com.bsd.pjcloud.supermarket.vo.SupermarketAuxiliaryCodeVo;
import com.bsd.pjcloud.supermarket.vo.SupermarketSpuVo;
import com.bsd.pjcloud.supermarket.vo.SupermarketUnitVo;
import com.bsd.pjcloud.supermarket.vo.*;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuDetailsVo;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppUnitVo;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
@@ -160,4 +161,15 @@ public class SupermarketSpuServiceImpl extends ServiceImpl<SupermarketSpuMapper,
supermarketSpuVo.setSupermarketAuxiliaryCodeEntityList(supermarketAuxiliaryCodeVos);
return supermarketSpuVo;
}
@Override
public Object getSupermarketSpuAppDetailById(Long id) {
SupermarketSpuEntity supermarketSpuEntity = baseMapper.selectById(id);
List<SupermarketUnitEntity> supermarketUnitEntityList = supermarketUnitService.list(new LambdaQueryWrapper<SupermarketUnitEntity>().eq(SupermarketUnitEntity::getSpuId, id));
List<SupermarketUnitEntity> unitEntities = supermarketUnitEntityList.stream().filter(supermarketUnitEntity -> supermarketUnitEntity.getStatus() == 0).collect(Collectors.toList());
SupermarketAppSpuDetailsVo supermarketAppSpuVo = BeanUtils.toBean(supermarketSpuEntity, SupermarketAppSpuDetailsVo.class);
List<SupermarketAppUnitVo> supermarketAppUnitVos = BeanUtils.toBean(unitEntities, SupermarketAppUnitVo.class);
supermarketAppSpuVo.setSkuList(supermarketAppUnitVos);
return supermarketAppSpuVo;
}
}