超市在线商城

This commit is contained in:
zjf committed 2025-06-11 18:47:24 +08:00
1 parent cb0dfd7b24
commit 24c47b2f7d
7 files changed
+205 -49

No files matched your search

@@ -2,33 +2,27 @@ package com.bsd.pjcloud.supermarket.vo;
import com.baomidou.mybatisplus.annotation.*;
import com.bsd.pjcloud.supermarket.entity.SmErpAuxiliaryCodeEntity;
import com.bsd.pjcloud.supermarket.entity.SmErpUnitEntity;
import com.bsd.pjcloud.supermarket.vo.sm.smspu.app.SmErpUnitAppVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 在线商城 商品数据
* app在线商城 商品列表数据
*/
@Data
public class OnlineShopVo {
private Long categoryId;
private String categoryName;
private List<SmSpuVo> smSpuVos;
@Data
class SmSpuVo {
/**
* 线上SPU 编号,自增
*/
@Schema(description="线上SPU 编号,自增")
private Long id;
@Schema(description="线上SPU 编号,自增")
private Long id;
/**
* 库存商品id
@@ -50,19 +44,6 @@ public class OnlineShopVo {
@Schema(description="商品轮播图地址")
private String sliderPicUrls;
/**
* 排序字段
*/
@Schema(description="排序字段")
private Integer sort;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 销量
@@ -70,7 +51,68 @@ public class OnlineShopVo {
@Schema(description="销量")
private Integer salesCount;
}
/**
* 货号
*/
@Schema(description="货号")
private String productCode;
/**
* 自编码/条码
*/
@Schema(description="自编码/条码")
private String barcode;
/**
* 商品名称
*/
@Schema(description="商品名称")
private String productName;
/**
* 商品简介
*/
@Schema(description="商品简介")
private String introduction;
/**
* 商品封面图
*/
@Schema(description="商品封面图")
private String picUrl;
/**
* 库存
*/
@Schema(description="库存")
private Double stock;
/**
* 商品性质(字典)
*/
@Schema(description="商品性质(字典)")
private String productNature;
/**
* 货商id
*/
@Schema(description="货商id")
private Long supplierName;
@Schema(description = "包装对象集合对象")
private List<SmErpUnitAppVo> smErpUnitEntityList;
}
@@ -0,0 +1,74 @@
package com.bsd.pjcloud.supermarket.vo.sm.smspu.app;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
@Schema(description = "移动端商品列表包装对象vo")
public class SmErpUnitAppVo {
/**
* 包装单位id
*/
@Schema(description="包装单位id")
private Long id;
/**
* 条码
*/
@Schema(description="条码")
private String barCode;
/**
* 规格
*/
@Schema(description="规格")
private String spec;
/**
* 单位
*/
@Schema(description="单位")
private String unit;
/**
* 状态(0正常,1停销)
*/
@Schema(description="状态(0正常,1停销)")
private Integer status;
/**
* 内装数量
*/
@Schema(description="内装数量")
private Integer packageNum;
/**
* 零售价/单位分
*/
@Schema(description="零售价/单位分")
private Integer retailPrice;
/**
* spuID
*/
@Schema(description="spuID")
private Long spuId;
/**
* 促销价
*/
@Schema(description="促销价")
private Integer promotionPrice;
@Schema(description = "是否是基础库存,默认0否,1是")
private Boolean isBase;
}
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
@@ -160,31 +161,48 @@ public class SmSpuController {
*/
@Operation(summary = "APP在线商城数据查询",description = "通过商户id获取该商户下的在线商品数据")
@GetMapping("/app/onlineShopList")
public R<List<OnlineShopVo>> getOnlineShopList(@RequestParam("merchantId")Long merchantId) {
public R<IPage<OnlineShopVo>> getOnlineShopList(@RequestParam("categoryId")Long categoryId,@ParameterObject Page page) {
List<SmSpuEntity> list=smSpuService.getOnlineShopList(merchantId);
IPage<OnlineShopVo> onlineShopList = smSpuService.getOnlineShopList(categoryId, page);
return R.ok();
return R.ok(onlineShopList);
}
/**
* 获取商户下所有的在线商品,并且获取分类
* 获取商户下所有获取分类
* @return
*/
@Operation(summary = "APP在线商城数据查询",description = "通过商户id获取该商户下的在线商品数据")
@Operation(summary = "APP在线商城分类数据查询",description = "获取商户下所有获取分类通过商户id")
@GetMapping("/app/onlineCategoryList")
public R<List<SmErpCategorySimpleVo>> getOnlineCategoryList(@RequestParam("merchantId")Long merchantId) {
R<MchManageVo> byId = remoteMchService.getById(merchantId);
MchManageVo data = byId.getData();
if (Objects.isNull(data)){
return R.failed("商户不存在");
}
Long deptId = data.getDeptId();
// R<MchManageVo> byId = remoteMchService.getById(merchantId);
// MchManageVo data = byId.getData();
// if (Objects.isNull(data)){
// return R.failed("商户不存在");
// }
// Long deptId = data.getDeptId();
//
// List<SmErpCategoryEntity> categoryEntities = smErpCategoryService.list(Wrappers.<SmErpCategoryEntity>lambdaQuery().eq(SmErpCategoryEntity::getDeptId, deptId));
// List<SmErpCategorySimpleVo> bean = BeanUtils.toBean(categoryEntities, SmErpCategorySimpleVo.class);
LambdaQueryWrapper<SmSpuEntity> eq = new LambdaQueryWrapper<SmSpuEntity>()
.eq(SmSpuEntity::getMerchantId, merchantId)
//上架数据 0
.eq(SmSpuEntity::getStatus, "0");
List<SmSpuEntity> list = smSpuService.list(eq);
List<Long> erpSpuIds = list.stream().map(smSpuEntity -> smSpuEntity.getErpSpuId()).collect(Collectors.toList());
List<SmErpCategoryEntity> categoryEntities = smErpCategoryService.list(Wrappers.<SmErpCategoryEntity>lambdaQuery().eq(SmErpCategoryEntity::getDeptId, deptId));
LambdaQueryWrapper<SmErpSpuEntity> smErpSpuEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
smErpSpuEntityLambdaQueryWrapper.in(SmErpSpuEntity::getId, erpSpuIds);
List<SmErpSpuEntity> erpSpuEntities = smErpSpuService.list(smErpSpuEntityLambdaQueryWrapper);
List<Long> categoryIds= erpSpuEntities.stream().map(smErpSpuEntity -> smErpSpuEntity.getCategoryId()).collect(Collectors.toList());
LambdaQueryWrapper<SmErpCategoryEntity> smErpCategoryEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
smErpCategoryEntityLambdaQueryWrapper.in(SmErpCategoryEntity::getId, categoryIds);
List<SmErpCategoryEntity> categoryEntities = smErpCategoryService.list(smErpCategoryEntityLambdaQueryWrapper);
List<SmErpCategorySimpleVo> bean = BeanUtils.toBean(categoryEntities, SmErpCategorySimpleVo.class);
return R.ok(bean);
}
@@ -7,11 +7,14 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuAppQueryDTO;
import com.bsd.pjcloud.supermarket.entity.SmSpuEntity;
import com.bsd.pjcloud.supermarket.vo.OnlineShopVo;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
import com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpPageScopeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SmSpuMapper extends PjcloudBaseMapper<SmSpuEntity> {
@@ -33,4 +36,13 @@ public interface SmSpuMapper extends PjcloudBaseMapper<SmSpuEntity> {
* @return
*/
IPage<SupermarketAppSpuVo> getAppPage(Page page, @Param("supermarketSpuQueryDTO")SupermarketSpuAppQueryDTO supermarketSpuQueryDTO);
/**
* 移动端分页获取线上商品数据
* @param categoryId
* @param page
* @return
*/
IPage<OnlineShopVo> getOnlineShopList(@Param("categoryId") Long categoryId, Page page);
}
@@ -1,10 +1,12 @@
package com.bsd.pjcloud.supermarket.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuAppQueryDTO;
import com.bsd.pjcloud.supermarket.entity.SmSpuEntity;
import com.bsd.pjcloud.supermarket.vo.OnlineShopVo;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
import java.util.List;
@@ -20,9 +22,9 @@ public interface SmSpuService extends IService<SmSpuEntity> {
Object getAppPage(Page page, SupermarketSpuAppQueryDTO supermarketSpuQueryDTO);
/**
* 查询该商户下的所有在线商品数据
* @param merchantId
* 查询该分类下的所有在线商品数据
* @param categoryId
* @return
*/
List<SmSpuEntity> getOnlineShopList(Long merchantId);
IPage<OnlineShopVo> getOnlineShopList(Long categoryId, Page page);
}
@@ -13,6 +13,7 @@ import com.bsd.pjcloud.supermarket.mapper.SmErpSpuMapper;
import com.bsd.pjcloud.supermarket.mapper.SmErpUnitMapper;
import com.bsd.pjcloud.supermarket.mapper.SmSpuMapper;
import com.bsd.pjcloud.supermarket.service.SmSpuService;
import com.bsd.pjcloud.supermarket.vo.OnlineShopVo;
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
import com.bsd.pjcloud.supermarket.vo.sm.smspu.SmErpPageScopeVo;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
@@ -50,14 +51,9 @@ public class SmSpuServiceImpl extends ServiceImpl<SmSpuMapper, SmSpuEntity> impl
}
@Override
public List<SmSpuEntity> getOnlineShopList(Long merchantId) {
LambdaQueryWrapper<SmSpuEntity> eq = new LambdaQueryWrapper<SmSpuEntity>()
.eq(SmSpuEntity::getMerchantId, merchantId)
//上架数据 0
.eq(SmSpuEntity::getStatus, "0");
List<SmSpuEntity> list = baseMapper.selectList(eq);
public IPage<OnlineShopVo> getOnlineShopList(Long categoryId, Page page) {
List<Long> erpSpuIds= list.stream().map(smSpuEntity -> smSpuEntity.getErpSpuId()).collect(Collectors.toList());
IPage<OnlineShopVo> list = baseMapper.getOnlineShopList(categoryId,page);
return list;
}
@@ -53,4 +53,16 @@
</if>
</where>
</select>
<select id="getOnlineShopList" resultType="com.bsd.pjcloud.supermarket.vo.OnlineShopVo">
SELECT esp.id as erp_spu_id,esp.product_code,esp.barcode,esp.product_name,esp.category_id,
esp.pic_url,esp.sort,esp.status,esp.merchant_id,esp.dept_id,
sp.create_time,sp.id,sp.slider_pic_urls,
eca.name as category_name
FROM `sm_spu` sp
LEFT JOIN sm_erp_spu esp
on sp.erp_spu_id = esp.id
LEFT JOIN sm_erp_category eca
on esp.category_id = eca.id
WHERE esp.status = 0 and sp.merchant_id=${categoryId}
</select>
</mapper>