diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/ProductConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/ProductConstant.java index 084a9170..f5051b99 100644 --- a/hiver-core/src/main/java/cc/hiver/core/common/constant/ProductConstant.java +++ b/hiver-core/src/main/java/cc/hiver/core/common/constant/ProductConstant.java @@ -11,4 +11,6 @@ public interface ProductConstant { */ Integer[] DEL_FLAG = {0, 1, 2}; + String[] SERCHCATEGORY = {"bidian", "tuijian"}; + } diff --git a/hiver-core/src/main/java/cc/hiver/core/common/utils/PageUtil.java b/hiver-core/src/main/java/cc/hiver/core/common/utils/PageUtil.java index 4e877ba8..62d22e6b 100644 --- a/hiver-core/src/main/java/cc/hiver/core/common/utils/PageUtil.java +++ b/hiver-core/src/main/java/cc/hiver/core/common/utils/PageUtil.java @@ -32,12 +32,10 @@ public class PageUtil { * @return */ public static Pageable initPage(PageVo page) { - Pageable pageable = null; int pageNumber = page.getPageNumber(); int pageSize = page.getPageSize(); - String sort = page.getSort(); - String order = page.getOrder(); + // 1. 基础分页参数校验 if (pageNumber < 1) { pageNumber = 1; } @@ -47,19 +45,53 @@ public class PageUtil { if (pageSize > 100) { pageSize = 100; } - if (StrUtil.isNotBlank(sort)) { - Sort.Direction d; - if (StrUtil.isBlank(order)) { - d = Sort.Direction.DESC; - } else { - d = Sort.Direction.valueOf(order.toUpperCase()); - } - Sort s = Sort.by(d, sort); - pageable = PageRequest.of(pageNumber - 1, pageSize, s); + + // 2. 构建排序对象 (Sort) + Sort sort = Sort.unsorted(); // 初始化为空排序 + + // --- 处理 sortOrder --- + if (StrUtil.isNotBlank(page.getSortOrder())) { + String orderStr = page.getOrderOrder(); + Sort.Direction direction = StrUtil.isBlank(orderStr) + ? Sort.Direction.DESC + : Sort.Direction.valueOf(orderStr.toUpperCase()); + sort = sort.and(Sort.by(direction, page.getSortOrder())); + } + + // --- 处理 sortScore --- + if (StrUtil.isNotBlank(page.getSortScore())) { + String orderStr = page.getOrderScore(); + Sort.Direction direction = StrUtil.isBlank(orderStr) + ? Sort.Direction.DESC + : Sort.Direction.valueOf(orderStr.toUpperCase()); + sort = sort.and(Sort.by(direction, page.getSortScore())); + } + + // --- 处理 sortSale --- + if (StrUtil.isNotBlank(page.getSortSale())) { + String orderStr = page.getOrderSale(); + Sort.Direction direction = StrUtil.isBlank(orderStr) + ? Sort.Direction.DESC + : Sort.Direction.valueOf(orderStr.toUpperCase()); + sort = sort.and(Sort.by(direction, page.getSortSale())); + } + + // --- 处理原有主排序 (sort + order) --- + if (StrUtil.isNotBlank(page.getSort())) { + String orderStr = page.getOrder(); + Sort.Direction direction = StrUtil.isBlank(orderStr) + ? Sort.Direction.DESC + : Sort.Direction.valueOf(orderStr.toUpperCase()); + sort = sort.and(Sort.by(direction, page.getSort())); + } + + // 3. 生成 Pageable + // 注意:PageRequest 的页码是从 0 开始的,所以 pageNumber - 1 + if (sort.isSorted()) { + return PageRequest.of(pageNumber - 1, pageSize, sort); } else { - pageable = PageRequest.of(pageNumber - 1, pageSize); + return PageRequest.of(pageNumber - 1, pageSize); } - return pageable; } /** diff --git a/hiver-core/src/main/java/cc/hiver/core/common/vo/PageVo.java b/hiver-core/src/main/java/cc/hiver/core/common/vo/PageVo.java index a7a79696..eaec85ee 100644 --- a/hiver-core/src/main/java/cc/hiver/core/common/vo/PageVo.java +++ b/hiver-core/src/main/java/cc/hiver/core/common/vo/PageVo.java @@ -25,4 +25,22 @@ public class PageVo implements Serializable { @ApiModelProperty(value = "排序方式 asc/desc") private String order; + + @ApiModelProperty(value = "排序字段 评分") + private String sortScore; + + @ApiModelProperty(value = "排序方式 asc/desc") + private String orderScore; + + @ApiModelProperty(value = "排序字段 销量") + private String sortSale; + + @ApiModelProperty(value = "排序方式 asc/desc") + private String orderSale; + + @ApiModelProperty(value = "排序字段 排名") + private String sortOrder; + + @ApiModelProperty(value = "排序方式 asc/desc") + private String orderOrder; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java index abb04491..8e332d6c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java @@ -80,6 +80,8 @@ public class ProductController { //product.setShopId(shopId); // 新增的默认为已上架 product.setDelFlag(CommonConstant.DEL_FLAG_TRUE); + product.setIsMust(CommonConstant.DATA_TYPE_ALL); + product.setIsPush(CommonConstant.DATA_TYPE_ALL); // 处理前台的错误传参 if("[]".equals(product.getCustomerCategoryRule()) || "null".equals(product.getCustomerCategoryRule())){ product.setCustomerCategoryRule(""); @@ -238,6 +240,34 @@ public class ProductController { } } + @RequestMapping(value = "/isPush", method = RequestMethod.POST) + @ApiOperation("根据货品id设为推荐货品") + public Result isPush(@RequestParam("id")String id, @RequestParam("isPush")Integer isPush) { + final UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("is_push", isPush); + updateWrapper.eq("id", id); + final boolean result = productService.update(updateWrapper); + if (result) { + return ResultUtil.success("设置成功"); + } else { + return ResultUtil.error("设置失败"); + } + } + + @RequestMapping(value = "/isMust", method = RequestMethod.POST) + @ApiOperation("根据货品id设为必点货品") + public Result isMust(@RequestParam("id")String id, @RequestParam("isMust")Integer isMust) { + final UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("is_must", isMust); + updateWrapper.eq("id", id); + final boolean result = productService.update(updateWrapper); + if (result) { + return ResultUtil.success("设置成功"); + } else { + return ResultUtil.error("设置失败"); + } + } + /** * 根据货品id批量下架货品 * @@ -356,8 +386,17 @@ public class ProductController { @RateLimiter(name = "getShareList", ipLimit = true) public Result> getShareList(@RequestBody ProductPageQuery productPageQuery) { // shopId从缓存中设置 - final String shopId = securityUtil.getShopId(); - productPageQuery.setShopId(shopId); + /*final String shopId = securityUtil.getShopId(); + productPageQuery.setShopId(shopId);*/ + if(productPageQuery.getCategoryId() != null){ + if(productPageQuery.getCategoryId().equals(ProductConstant.SERCHCATEGORY[0])){ + productPageQuery.setIsMust(ProductConstant.DEL_FLAG[1]); + productPageQuery.setCategoryId(null); + }else if(productPageQuery.getCategoryId().equals(ProductConstant.SERCHCATEGORY[1])){ + productPageQuery.setIsPush(ProductConstant.DEL_FLAG[1]); + productPageQuery.setCategoryId(null); + } + } final IPage result = productService.getShareList(productPageQuery); return new ResultUtil>().setData(result); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java index 66da2e4c..69f88cd1 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java @@ -31,11 +31,14 @@ import cc.hiver.mall.entity.ShopArea; import cc.hiver.mall.entity.ShopUser; import cc.hiver.mall.invitelog.service.InviteLogService; import cc.hiver.mall.pojo.dto.ShopRevenue; +import cc.hiver.mall.pojo.query.ProductPageQuery; +import cc.hiver.mall.pojo.vo.ProductPageVO; import cc.hiver.mall.pojo.vo.QueryShopRevenueVO; import cc.hiver.mall.service.ShopAreaService; import cc.hiver.mall.service.ShopService; import cc.hiver.mall.service.ShopUserService; import cn.hutool.core.text.CharSequenceUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -45,6 +48,7 @@ import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -206,6 +210,29 @@ public class ShopController { public Result> getByCondition(Shop shop, PageVo pageVo) { final Page page = shopService.findByCondition(shop, PageUtil.initPage(pageVo)); + + final List shopIdList = new ArrayList<>(); + page.getContent().forEach(e -> { + shopIdList.add(e.getId()); + }); + //查询推荐商品 + final ProductPageQuery productPageQuery = new ProductPageQuery(); + productPageQuery.setShopIdList(shopIdList); + productPageQuery.setIsPush(ShopUserConstant.SHOP_ADMIN_COST[1]); + IPage productList = shopService.getShareList(productPageQuery); + + page.getContent().forEach(e -> { + final List products = new ArrayList<>(); + if(productList.getRecords().size() > 0){ + productList.getRecords().forEach(productPageVO -> { + if (e.getId().equals(productPageVO.getShopId())) { + products.add(productPageVO); + } + }); + } + + e.setProducts(products); + }); return new ResultUtil>().setData(page); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductGroupBuyPriceMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductGroupBuyPriceMapper.java index 9381c99e..c578febe 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductGroupBuyPriceMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductGroupBuyPriceMapper.java @@ -2,6 +2,7 @@ package cc.hiver.mall.dao.mapper; import cc.hiver.mall.entity.ProductGroupBuyPrice; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -15,4 +16,6 @@ public interface ProductGroupBuyPriceMapper extends BaseMapper getByProductIds(@Param("productIds") List productIds); + } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ShopMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ShopMapper.java index f07a90f5..46b8b447 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ShopMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ShopMapper.java @@ -16,4 +16,6 @@ public interface ShopMapper extends BaseMapper { * @return */ List findByUserId(@Param("userId") String userId); + + List getShopSaleCounts(@Param("shopIdList") List shopIdList); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java index e4ce90f8..a74bddbc 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java @@ -123,10 +123,10 @@ public class Product implements Serializable { private Date salesWeek; @ApiModelProperty(value = "开始售卖时间") - private Date sellBeginTime; + private String sellBeginTime; @ApiModelProperty(value = "结束售卖时间") - private Date sellEndTime; + private String sellEndTime; @ApiModelProperty(value = "打印条码(自己制作的)") private String printBarcode; @@ -134,6 +134,15 @@ public class Product implements Serializable { @ApiModelProperty(value = "库存预警") private Integer tailWarn; + @ApiModelProperty(value = "起售数量") + private Integer startPayNum; + + @ApiModelProperty(value = "是否为加料 0否 1是") + private Integer isMoreBuy; + + @ApiModelProperty(value = "餐盒费") + private BigDecimal lunchBox; + @ApiModelProperty(value = "入库状态:0:待入库(未维护对应的采购价信息);1:已入库;新增商品时为已入库") private Integer inStorageStatus = 1; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Shop.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Shop.java index e8a7bd8f..ba7e42b8 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Shop.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Shop.java @@ -17,6 +17,7 @@ package cc.hiver.mall.entity; import cc.hiver.core.base.HiverBaseEntity; import cc.hiver.core.vo.UserVo; +import cc.hiver.mall.pojo.vo.ProductPageVO; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -116,6 +117,16 @@ public class Shop extends HiverBaseEntity { @ApiModelProperty(value = "店铺对应店员") private List users; + @Transient + @TableField(exist = false) + @ApiModelProperty(value = "店铺推荐商品") + private List products; + + @Transient + @TableField(exist = false) + @ApiModelProperty(value = "已售单量") + private Integer saleCounts; + @ApiModelProperty(value = "支付宝账号") private String aliAccount; @@ -149,6 +160,12 @@ public class Shop extends HiverBaseEntity { @ApiModelProperty(value = "是否为品牌店铺1是 0不是") private Integer isbrandflag; + @ApiModelProperty(value = "排名") + private Integer shoprank; + + @ApiModelProperty(value = "销量") + private Integer saleCount; + @ApiModelProperty(value = "副标题") private String subtitle; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java index 5141139c..b420defa 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java @@ -34,6 +34,9 @@ public class ShopArea extends HiverBaseEntity { @ApiModelProperty(value = "圈层名称") private String title; + @ApiModelProperty(value = "1 是食堂") + private Integer isCanteen; + @ApiModelProperty(value = "父id") @Column(nullable = false) private String parentId; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java index bb8f90ea..b710415b 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java @@ -49,6 +49,9 @@ public class ProductPageQuery extends HiverBasePageQuery { @ApiModelProperty("货号") private String productSn; + @ApiModelProperty("根据店铺id集合查询推款商品") + private List shopIdList; + @ApiModelProperty("供应商id") private String supplierId; @@ -81,4 +84,13 @@ public class ProductPageQuery extends HiverBasePageQuery { @ApiModelProperty("盘点id") private String checkStockId; + + @ApiModelProperty(value = "是否为加料 0否 1是") + private Integer isMoreBuy; + + @ApiModelProperty(value = "是否为推荐 0不是 1是") + private Integer isPush; + + @ApiModelProperty(value = "是否为必点 0不是 1是") + private Integer isMust; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java index f66658e9..8e9d9fb9 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java @@ -16,6 +16,7 @@ limitations under the License. package cc.hiver.mall.pojo.vo; import cc.hiver.mall.checkstock.vo.CheckStockAttributeVo; +import cc.hiver.mall.entity.ProductGroupBuyPrice; import cc.hiver.mall.productpicture.entity.ProductPicture; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; @@ -111,11 +112,17 @@ public class ProductPageVO { @ApiModelProperty(value = "销售周期") private Date salesWeek; + @ApiModelProperty(value = "起售数量") + private Integer startPayNum; + + @ApiModelProperty(value = "餐盒费") + private BigDecimal lunchBox; + @ApiModelProperty(value = "开始售卖时间") - private Date sellBeginTime; + private String sellBeginTime; @ApiModelProperty(value = "结束售卖时间") - private Date sellEndTime; + private String sellEndTime; @ApiModelProperty(value = "打印条码(自己制作的)") private String printBarcode; @@ -149,6 +156,12 @@ public class ProductPageVO { @ApiModelProperty(value = "商品购买数量") private Integer buyCount; + @ApiModelProperty(value = "是否为加料 0否 1是") + private Integer isMoreBuy; + @ApiModelProperty(value = "盘点明细") private List checkStockAttributeVos; + + @ApiModelProperty(value = "商品拼团信息") + private List productGroupBuyPrices; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductVo.java index 2fd100d2..99997655 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductVo.java @@ -87,10 +87,10 @@ public class ProductVo extends HiverBaseEntity { private Date salesWeek; @ApiModelProperty(value = "开始售卖时间") - private Date sellBeginTime; + private String sellBeginTime; @ApiModelProperty(value = "结束售卖时间") - private Date sellEndTime; + private String sellEndTime; @ApiModelProperty(value = "打印条码(自己制作的)") private String printBarcode; @@ -98,6 +98,15 @@ public class ProductVo extends HiverBaseEntity { @ApiModelProperty(value = "库存预警") private Integer tailWarn; + @ApiModelProperty(value = "起售数量") + private Integer startPayNum; + + @ApiModelProperty(value = "餐盒费") + private BigDecimal lunchBox; + + @ApiModelProperty(value = "是否为加料 0否 1是") + private Integer isMoreBuy; + @ApiModelProperty(value = "入库状态:0:待入库(未维护对应的采购价信息);1:已入库;新增商品时为已入库") private Integer inStorageStatus = 1; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopService.java index aa731f27..f79374a8 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopService.java @@ -18,7 +18,10 @@ package cc.hiver.mall.service; import cc.hiver.core.base.HiverBaseService; import cc.hiver.mall.entity.Shop; import cc.hiver.mall.pojo.dto.ShopRevenue; +import cc.hiver.mall.pojo.query.ProductPageQuery; +import cc.hiver.mall.pojo.vo.ProductPageVO; import cc.hiver.mall.pojo.vo.QueryShopRevenueVO; +import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -66,4 +69,8 @@ public interface ShopService extends HiverBaseService { List getAllShopByCustomer(String userId); Map getShopRebateBalance(); + + List getShopSaleCounts(List shopIdList); + + IPage getShareList(ProductPageQuery productPageQuery); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductGroupBuyPriceService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductGroupBuyPriceService.java index d343d327..bb500dd8 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductGroupBuyPriceService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductGroupBuyPriceService.java @@ -12,4 +12,6 @@ public interface ProductGroupBuyPriceService extends IService selectByProductId(String productId); void deleteByProductId(String productId); + + List getByProductIds(List productIds); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ProductShareServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ProductShareServiceImpl.java index 7a563354..b3024772 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ProductShareServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ProductShareServiceImpl.java @@ -4,6 +4,7 @@ import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.entity.User; import cc.hiver.mall.dao.ProductShareDao; +import cc.hiver.mall.entity.ProductGroupBuyPrice; import cc.hiver.mall.entity.Share; import cc.hiver.mall.entity.Shop; import cc.hiver.mall.pojo.query.ProductPageQuery; @@ -14,6 +15,7 @@ import cc.hiver.mall.productpicture.entity.ProductPicture; import cc.hiver.mall.productpicture.service.ProductPictureService; import cc.hiver.mall.service.ProductShareService; import cc.hiver.mall.service.ShopService; +import cc.hiver.mall.service.mybatis.ProductGroupBuyPriceService; import cc.hiver.mall.service.mybatis.ProductService; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.commons.lang3.StringUtils; @@ -39,6 +41,9 @@ public class ProductShareServiceImpl implements ProductShareService { @Autowired private ProductPictureService productPictureService; + @Autowired + private ProductGroupBuyPriceService productGroupBuyPriceService; + /** * 新增分享链接 * @@ -101,9 +106,12 @@ public class ProductShareServiceImpl implements ProductShareService { for (ProductPageVO record : shareList.getRecords()) { productIds.add(record.getId()); } + if(!productIds.isEmpty()){ // 封装商品子图 final List productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIds); + //封装拼团信息 + final List productGroupBuyPrices = productGroupBuyPriceService.getByProductIds(productIds); // 将productPictureByProductIds封装为map,key为商品id,value为实体 final Map> productPictureMap = new HashMap<>(); for (ProductPicture productPictureByProductId : productPictureByProductIds) { @@ -121,6 +129,24 @@ public class ProductShareServiceImpl implements ProductShareService { shareList.getRecords().forEach(productPageVO -> { productPageVO.setProductPictures(productPictureMap.get(productPageVO.getId())); }); + + // 将productPictureByProductIds封装为map,key为商品id,value为实体 + final Map> productGroupBuyPriceMap = new HashMap<>(); + for (ProductGroupBuyPrice productGroupBuyPriceByProductId : productGroupBuyPrices) { + if (productPictureMap.containsKey(productGroupBuyPriceByProductId.getProductId())) { + final String productId = productGroupBuyPriceByProductId.getProductId(); + final List productGroupBuyPrice = productGroupBuyPriceMap.get(productId); + productGroupBuyPrice.add(productGroupBuyPriceByProductId); + } else { + final List productGroupBuyPrice = new ArrayList<>(); + productGroupBuyPrice.add(productGroupBuyPriceByProductId); + productGroupBuyPriceMap.put(productGroupBuyPriceByProductId.getProductId(),productGroupBuyPrice); + } + } + // 封装到实体中去。 + shareList.getRecords().forEach(productPageVO -> { + productPageVO.setProductGroupBuyPrices(productGroupBuyPriceMap.get(productPageVO.getId())); + }); } shareVO.setShareList(shareList); return shareVO; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopServiceImpl.java index 9cd91817..ae07aa7f 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopServiceImpl.java @@ -17,15 +17,26 @@ package cc.hiver.mall.serviceimpl; import cc.hiver.core.base.HiverBaseDao; import cc.hiver.core.common.utils.SecurityUtil; +import cc.hiver.core.common.utils.StringUtils; import cc.hiver.mall.dao.ShopDao; +import cc.hiver.mall.dao.mapper.ProductMapper; import cc.hiver.mall.dao.mapper.SaleMapper; +import cc.hiver.mall.dao.mapper.ShopMapper; import cc.hiver.mall.deductlog.service.DeductLogService; +import cc.hiver.mall.entity.ProductGroupBuyPrice; import cc.hiver.mall.entity.Shop; import cc.hiver.mall.invitelog.service.InviteLogService; import cc.hiver.mall.pojo.dto.ShopRevenue; +import cc.hiver.mall.pojo.query.ProductPageQuery; +import cc.hiver.mall.pojo.vo.ProductPageVO; import cc.hiver.mall.pojo.vo.QueryShopRevenueVO; +import cc.hiver.mall.productpicture.entity.ProductPicture; +import cc.hiver.mall.productpicture.service.ProductPictureService; import cc.hiver.mall.service.ShopService; +import cc.hiver.mall.service.mybatis.ProductGroupBuyPriceService; +import cc.hiver.mall.utils.DateUtil; import cn.hutool.core.text.CharSequenceUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -64,6 +75,18 @@ public class ShopServiceImpl implements ShopService { @Autowired private DeductLogService deductLogService; + @Autowired + private ShopMapper shopMapper; + + @Autowired + private ProductMapper productMapper; + + @Autowired + private ProductPictureService productPictureService; + + @Autowired + private ProductGroupBuyPriceService productGroupBuyPriceService; + @Override public HiverBaseDao getRepository() { return shopDao; @@ -77,15 +100,19 @@ public class ShopServiceImpl implements ShopService { public Predicate toPredicate(Root root, CriteriaQuery cq, CriteriaBuilder cb) { final Path ShopNameField = root.get("shopName"); final Path regionField = root.get("regionId"); + final Path shopAreaField = root.get("shopArea"); - final List list = new ArrayList<>(); + final List list = new ArrayList<>(); if (CharSequenceUtil.isNotBlank(Shop.getShopName())) { list.add(cb.like(ShopNameField, '%' + Shop.getShopName() + '%')); } if (CharSequenceUtil.isNotBlank(Shop.getRegionId())) { list.add(cb.equal(regionField, Shop.getRegionId())); } + if (CharSequenceUtil.isNotBlank(Shop.getShopArea())) { + list.add(cb.equal(shopAreaField, Shop.getShopArea())); + } final Predicate[] arr = new Predicate[list.size()]; @@ -140,4 +167,63 @@ public class ShopServiceImpl implements ShopService { return resultMap; } + @Override + public List getShopSaleCounts(List shopIdList) { + return shopMapper.getShopSaleCounts(shopIdList); + } + + public IPage getShareList(ProductPageQuery productPageQuery) { + if (StringUtils.isNotEmpty(productPageQuery.getEndDate())) { + // 加一天 + productPageQuery.setEndDate(DateUtil.addDay(productPageQuery.getEndDate(), 1)); + } + final com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize()); + final List list = productMapper.getShareList(page, productPageQuery); + // 获取商品子图 + final List productIdList = new ArrayList<>(); + for (ProductPageVO productPageVO : list) { + productIdList.add(productPageVO.getId()); + + } + + if (!productIdList.isEmpty()) { + //封装拼团信息 + final List productGroupBuyPrices = productGroupBuyPriceService.getByProductIds(productIdList); + // 获取子图 + final List productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList); + final Map> productPictureMap = new HashMap<>(); + for (ProductPicture productPictureByProductId : productPictureByProductIds) { + if (productPictureMap.containsKey(productPictureByProductId.getProductId())) { + productPictureMap.get(productPictureByProductId.getProductId()).add(productPictureByProductId); + } else { + final List productPictureList = new ArrayList<>(); + productPictureList.add(productPictureByProductId); + productPictureMap.put(productPictureByProductId.getProductId(), productPictureList); + } + } + final Map> productGroupBuyPriceMap = new HashMap<>(); + for (ProductGroupBuyPrice productGroupBuyPrice : productGroupBuyPrices) { + if (productGroupBuyPriceMap.containsKey(productGroupBuyPrice.getProductId())) { + productGroupBuyPriceMap.get(productGroupBuyPrice.getProductId()).add(productGroupBuyPrice); + } else { + final List productGroupBuyPriceList = new ArrayList<>(); + productGroupBuyPriceList.add(productGroupBuyPrice); + productGroupBuyPriceMap.put(productGroupBuyPrice.getProductId(), productGroupBuyPriceList); + } + } + + for (ProductPageVO productPageVO : list) { + final String productId = productPageVO.getId(); + if (productPictureMap.containsKey(productId)) { + productPageVO.setProductPictures(productPictureMap.get(productId)); + } + if (productGroupBuyPriceMap.containsKey(productId)) { + productPageVO.setProductGroupBuyPrices(productGroupBuyPriceMap.get(productId)); + } + } + } + page.setRecords(list); + return page; + } + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductGroupBuyPriceServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductGroupBuyPriceServiceImpl.java index aec111d8..0e1e0cfb 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductGroupBuyPriceServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductGroupBuyPriceServiceImpl.java @@ -33,4 +33,9 @@ public class ProductGroupBuyPriceServiceImpl extends ServiceImpl getByProductIds(List productIds) { + return productGroupBuyPriceMapper.getByProductIds(productIds); + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java index 0f2f6093..2f1dff66 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java @@ -81,6 +81,8 @@ public class ProductServiceImpl extends ServiceImpl impl } if (!productIdList.isEmpty()) { + //封装拼团信息 + final List productGroupBuyPrices = productGroupBuyPriceService.getByProductIds(productIdList); // 获取子图 final List productPictureByProductIds = productPictureService.getProductPictureByProductIds(productIdList); final Map> productPictureMap = new HashMap<>(); @@ -93,11 +95,25 @@ public class ProductServiceImpl extends ServiceImpl impl productPictureMap.put(productPictureByProductId.getProductId(), productPictureList); } } + final Map> productGroupBuyPriceMap = new HashMap<>(); + for (ProductGroupBuyPrice productGroupBuyPrice : productGroupBuyPrices) { + if (productGroupBuyPriceMap.containsKey(productGroupBuyPrice.getProductId())) { + productGroupBuyPriceMap.get(productGroupBuyPrice.getProductId()).add(productGroupBuyPrice); + } else { + final List productGroupBuyPriceList = new ArrayList<>(); + productGroupBuyPriceList.add(productGroupBuyPrice); + productGroupBuyPriceMap.put(productGroupBuyPrice.getProductId(), productGroupBuyPriceList); + } + } + for (ProductPageVO productPageVO : list) { final String productId = productPageVO.getId(); if (productPictureMap.containsKey(productId)) { productPageVO.setProductPictures(productPictureMap.get(productId)); } + if (productGroupBuyPriceMap.containsKey(productId)) { + productPageVO.setProductGroupBuyPrices(productGroupBuyPriceMap.get(productId)); + } } // 获取商品均色均码的库存数 final List stockList = stockService.getDefaultStockCount(productIdList); diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductCategoryMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductCategoryMapper.xml index 9f0325e6..4c637e61 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductCategoryMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductCategoryMapper.xml @@ -300,9 +300,6 @@ + select + + from t_product_group_buy_price + where product_id in + + #{listItem} + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml index 80b8bfba..971d37cf 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml @@ -34,8 +34,11 @@ - - + + + + + @@ -101,7 +104,8 @@ id, create_by, create_time, del_flag, update_by, update_time, product_name, unit, shop_id, category_id,attr_id, attribute_list, supplier_id,supplier_name, product_sn, barcode, price, purchase_price,commission, wholesale_price, product_picture, product_video, product_intro, sales_week, print_barcode, - tail_warn,in_storage_status,customer_category_rule, attribute_list_price, is_push, is_must, order_filed, sell_begin_time, sell_end_time + tail_warn,in_storage_status,customer_category_rule, attribute_list_price, is_push, + is_must, order_filed, sell_begin_time, sell_end_time, start_pay_num, lunch_box, is_more_buy select @@ -32,11 +33,11 @@ insert into t_shop_area (id, create_by, create_time, del_flag, update_by, update_time, is_parent, parent_id, sort_order, - status, title) + status, title,is_canteen) values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{isParent,jdbcType=BIT}, #{parentId,jdbcType=VARCHAR}, #{sortOrder,jdbcType=DECIMAL}, - #{status,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}) + #{status,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR},#{isCanteen,jdbcType=INTEGER}) insert into t_shop_area @@ -74,6 +75,9 @@ title, + + is_canteen, + @@ -109,6 +113,9 @@ #{title,jdbcType=VARCHAR}, + + #{isCanteen,jdbcType=VARCHAR}, + @@ -144,6 +151,9 @@ title = #{title,jdbcType=VARCHAR}, + + is_canteen = #{isCanteen,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -158,7 +168,8 @@ parent_id = #{parentId,jdbcType=VARCHAR}, sort_order = #{sortOrder,jdbcType=DECIMAL}, status = #{status,jdbcType=INTEGER}, - title = #{title,jdbcType=VARCHAR} + title = #{title,jdbcType=VARCHAR}, + is_canteen = #{isCanteen,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ShopMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ShopMapper.xml index 9a20479f..06e85e49 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ShopMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ShopMapper.xml @@ -36,9 +36,11 @@ - + + + @@ -47,7 +49,7 @@ id, create_by, create_time, del_flag, update_by, update_time, shop_name, shop_owner_id, shop_manger_id, region, region_id, shop_area, shop_area_title, shop_type, shop_type_title, shop_address, year_fee, charge_time, start_time, end_time, status, remark, business_district_level, contact_phone, shop_icon, defaulted, ali_account, ali_name, -rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop_score,isbrandflag,subtitle +rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop_score,isbrandflag,subtitle,shoprank,sale_count remark @@ -68,11 +70,11 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop insert into t_shop (id, create_by, create_time, del_flag, update_by, update_time, shop_name, shop_owner_id, shop_manger_id, region, region_id, shop_area, shop_area_title, shop_type, shop_type_title, shop_address, year_fee, charge_time, start_time, end_time, status, remark, business_district_level, contact_phone, shop_icon, defaulted, ali_account, ali_name, - rebate_amount, attr_id, printing_method, shop_images, shop_lename, shop_lecard, shop_score, isbrandflag, subtitle) + rebate_amount, attr_id, printing_method, shop_images, shop_lename, shop_lecard, shop_score, isbrandflag, subtitle,shoprank, sale_count) values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{shopName,jdbcType=VARCHAR}, #{shopOwnerId,jdbcType=VARCHAR}, #{shopMangerId,jdbcType=VARCHAR}, #{region,jdbcType=VARCHAR}, #{regionId,jdbcType=VARCHAR}, #{shopArea,jdbcType=VARCHAR}, #{shopAreaTitle,jdbcType=VARCHAR}, #{shopType,jdbcType=VARCHAR}, #{shopTypeTitle,jdbcType=VARCHAR}, #{shopAddress,jdbcType=VARCHAR}, #{yearFee,jdbcType=VARCHAR}, #{chargeTime,jdbcType=VARCHAR}, #{startTime,jdbcType=VARCHAR}, #{endTime,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{remark,jdbcType=LONGVARCHAR}, #{businessDistrictLevel,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, #{shopIcon,jdbcType=VARCHAR}, #{defaulted,jdbcType=INTEGER}, #{aliAccount,jdbcType=VARCHAR}, #{aliName,jdbcType=VARCHAR}, - #{rebateAmount,jdbcType=VARCHAR}, #{attrId,jdbcType=VARCHAR}, #{printingMethod,jdbcType=VARCHAR}, #{shopImages,jdbcType=VARCHAR}, #{shopLename,jdbcType=VARCHAR}, #{shopLecard,jdbcType=VARCHAR}, #{shopScore,jdbcType=VARCHAR}, #{isbrandflag,jdbcType=INTEGER}, #{subtitle,jdbcType=VARCHAR}) + #{rebateAmount,jdbcType=VARCHAR}, #{attrId,jdbcType=VARCHAR}, #{printingMethod,jdbcType=VARCHAR}, #{shopImages,jdbcType=VARCHAR}, #{shopLename,jdbcType=VARCHAR}, #{shopLecard,jdbcType=VARCHAR}, #{shopScore,jdbcType=DECIMAL}, #{isbrandflag,jdbcType=INTEGER}, #{subtitle,jdbcType=VARCHAR}, #{shoprank,jdbcType=INTEGER}, #{saleCount,jdbcType=INTEGER}) insert into t_shop @@ -164,6 +166,12 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop subtitle, + + shoprank, + + + sale_count, + @@ -245,7 +253,7 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop #{shopLecard,jdbcType=VARCHAR}, - #{shopScore,jdbcType=VARCHAR}, + #{shopScore,jdbcType=DECIMAL}, #{isbrandflag,jdbcType=INTEGER}, @@ -253,6 +261,12 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop #{subtitle,jdbcType=VARCHAR}, + + #{shoprank,jdbcType=INTEGER}, + + + #{saleCount,jdbcType=INTEGER}, + @@ -334,7 +348,7 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop shop_lecard = #{shopLecard,jdbcType=VARCHAR}, - shop_score = #{shopScore,jdbcType=VARCHAR}, + shop_score = #{shopScore,jdbcType=DECIMAL}, isbrandflag = #{isbrandflag,jdbcType=INTEGER}, @@ -342,6 +356,12 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop subtitle = #{subtitle,jdbcType=VARCHAR}, + + shoprank = #{shoprank,jdbcType=INTEGER}, + + + sale_count = #{saleCount,jdbcType=INTEGER}, + where id = #{id,jdbcType=VARCHAR} @@ -372,9 +392,11 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop shop_images = #{shopImages,jdbcType=VARCHAR}, shop_lename = #{shopLename,jdbcType=VARCHAR}, shop_lecard = #{shopLecard,jdbcType=VARCHAR}, - shop_score = #{shopScore,jdbcType=VARCHAR}, + shop_score = #{shopScore,jdbcType=DECIMAL}, isbrandflag = #{isbrandflag,jdbcType=INTEGER}, - subtitle = #{subtitle,jdbcType=VARCHAR} + subtitle = #{subtitle,jdbcType=VARCHAR}, + shoprank = #{shoprank,jdbcType=INTEGER}, + sale_count = #{saleCount,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR} @@ -412,9 +434,11 @@ rebate_amount, attr_id, printing_method,shop_images,shop_lename,shop_lecard,shop shop_images = #{shopImages,jdbcType=VARCHAR}, shop_lename = #{shopLename,jdbcType=VARCHAR}, shop_lecard = #{shopLecard,jdbcType=VARCHAR}, - shop_score = #{shopScore,jdbcType=VARCHAR}, + shop_score = #{shopScore,jdbcType=DECIMAL}, isbrandflag = #{isbrandflag,jdbcType=INTEGER}, - subtitle = #{subtitle,jdbcType=VARCHAR} + subtitle = #{subtitle,jdbcType=VARCHAR}, + shoprank = #{shoprank,jdbcType=INTEGER}, + sale_count = #{saleCount,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file