From e7bc4f312ad836305802d0e509be60c999806d8a Mon Sep 17 00:00:00 2001 From: sj <1304317391@qq.com> Date: Thu, 13 Oct 2022 09:41:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81=E7=83=AD?= =?UTF-8?q?=E6=A6=9C=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=B9=B6=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E6=8C=89=E5=93=81=E7=89=8C=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rest/AppStoreHotListController.java | 45 ++++++ .../product/rest/AppStoreBrandController.java | 11 ++ .../modules/shop/rest/BxgIndexController.java | 2 + .../activity/domain/YxStoreCoupon.java | 6 +- .../activity/rest/StoreCouponController.java | 1 + .../impl/YxStoreCouponUserServiceImpl.java | 1 - .../service/impl/YxStoreCartServiceImpl.java | 64 +++++++-- .../evaluation/domain/YxEvaluation.java | 1 - .../service/impl/YxEvaluationServiceImpl.java | 2 +- .../hotList/domain/YxStoreHotList.java | 71 ++++++++++ .../rest/YxStoreHotListController.java | 89 ++++++++++++ .../service/YxStoreHotListService.java | 53 +++++++ .../service/dto/YxStoreHotListDto.java | 50 +++++++ .../dto/YxStoreHotListQueryCriteria.java | 19 +++ .../impl/YxStoreHotListServiceImpl.java | 130 ++++++++++++++++++ .../service/mapper/YxStoreHotListMapper.java | 22 +++ .../hotList/service/vo/YxStoreHotListVo.java | 37 +++++ .../impl/YxStoreProductServiceImpl.java | 26 +++- .../yixiang/modules/product/vo/ProductVo.java | 5 + .../impl/YxSystemGroupDataServiceImpl.java | 2 +- .../modules/store/domain/YxStoreBrand.java | 4 +- .../store/service/YxStoreBrandService.java | 5 +- .../store/service/dto/YxStoreBrandDto.java | 3 + .../service/impl/YxStoreBrandServiceImpl.java | 17 ++- .../modules/store/vo/YxStoreBrandVo.java | 47 +++++++ .../main/java/co/yixiang/utils/BrandDTO.java | 7 + .../java/co/yixiang/utils/HotListDTO.java | 30 ++++ 27 files changed, 725 insertions(+), 25 deletions(-) create mode 100644 zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListDto.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListQueryCriteria.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListMapper.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/vo/YxStoreHotListVo.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/store/vo/YxStoreBrandVo.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/utils/HotListDTO.java diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java new file mode 100644 index 00000000..d9e318f3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java @@ -0,0 +1,45 @@ +package co.yixiang.app.modules.hotList.rest; + +import cn.iocoder.yudao.framework.common.pojo.ApiResult; +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.modules.evaluation.service.YxEvaluationService; +import co.yixiang.modules.hotList.service.YxStoreHotListService; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; +import co.yixiang.utils.EvaluationDTO; +import co.yixiang.utils.HotListDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + *

+ * 商品热榜控制器 + *

+ * + * @author ssj + * @since 2022-10-8 + */ +@Slf4j +@RestController +@Api(value = "商品热门榜单", tags = "商城:热门榜单") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class AppStoreHotListController { + private final YxStoreHotListService yxStoreHotListService; + + + /** + * 热门榜单列表 + */ + @AnonymousAccess + @GetMapping("/hotList") + @ApiOperation(value = "热门榜单列表",notes = "热门榜单") + public ApiResult> getYxStoreHotList(){ + return ApiResult.ok(yxStoreHotListService.getList()); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreBrandController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreBrandController.java index 7e161226..e4e8c986 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreBrandController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreBrandController.java @@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -39,4 +40,14 @@ public class AppStoreBrandController { public ApiResult> getYxStoreBrandPageList(){ return ApiResult.ok(yxStoreBrandService.getList()); } + + /** + * 商品品牌列表 + */ + @AnonymousAccess + @GetMapping("/brand/{id}") + @ApiOperation(value = "商品品牌详情",notes = "商品品牌详情") + public ApiResult getYxStoreBrandById(@PathVariable String id){ + return ApiResult.ok(yxStoreBrandService.getYxStoreBrandById(id)); + } } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java index 82d5083c..7cb8d6ef 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java @@ -93,6 +93,7 @@ public class BxgIndexController { @ApiOperation(value = "首页数据",notes = "首页数据") public ApiResult index(){ IndexVo indexVo = IndexVo.builder() + //首页图 .banner(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_BANNER)) .bastList(storeProductService.getList(1,6, ProductEnum.TYPE_1.getValue())) .evaluationList(evaluationService.getList(1,5)) @@ -101,6 +102,7 @@ public class BxgIndexController { .firstList(storeProductService.getList(1,6,ProductEnum.TYPE_3.getValue())) .likeInfo(storeProductService.getList(1,80,ProductEnum.TYPE_2.getValue())) .mapKey(systemConfigService.getData(ShopKeyUtils.getTengXunMapKey())) + //菜单 .menus(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_MENUS)) .roll(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_ROLL_NEWS)) .seckillList(storeSeckillService.getList(1, 4)) diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java index ff1e0937..5c925f04 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java @@ -67,7 +67,7 @@ public class YxStoreCoupon extends BaseDomain { // @ApiModelProperty(value = "优惠券有效期限(单位:天)") // private Integer couponTime; -// /** 优惠券有效期限(单位:天) */ +// /** 优惠券有效期限(单位:天) */ // @NotNull(message = "请输入有效期限") // @ApiModelProperty(value = "优惠券有效期限(单位:天;几号到几号)") // private Object useTime; @@ -75,12 +75,12 @@ public class YxStoreCoupon extends BaseDomain { /** 优惠券开始使用期限(单位:天) */ @NotNull(message = "请输入开始期限") @ApiModelProperty(value = "优惠券使用期限(单位:天)") - private Object useStartTime; + private String useStartTime; /** 优惠券结束使用期限(单位:天) */ @NotNull(message = "请输入有效结束期限") @ApiModelProperty(value = "优惠券失效期限(单位:天)") - private Object useEndTime; + private String useEndTime; /** 排序 */ @ApiModelProperty(value = "排序") diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java index 844d2930..6af063b0 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java @@ -67,6 +67,7 @@ public class StoreCouponController { return new ResponseEntity<>(yxStoreCouponService.save(resources),HttpStatus.CREATED); } + @Log("修改") @ApiOperation(value = "修改") @PutMapping(value = "/yxStoreCoupon") diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java index 6e39a6cf..501370b5 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java @@ -218,7 +218,6 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl implements YxStoreCartService { + @Autowired + private StoreProductMapper storeProductMapper; + + @Autowired + private YxStoreBrandMapper yxStoreBrandMapper; @Autowired private IGenerator generator; @@ -146,7 +149,7 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl map = new LinkedHashMap<>(); - map.put("valid", valid); - map.put("invalid", invalid); + //最终返回的有效商品的数组 + ArrayList cartList=new ArrayList<>(); + //获取不重复的品牌id数组 + LinkedHashSet BrandIdList = new LinkedHashSet<>(); + //有效商品 + valid.forEach(item->{ + YxStoreProduct storeProduct = storeProductMapper.selectById(item.getProductId()); + BrandIdList.add(storeProduct.getBrandId()); + }); + //无效商品 + invalid.forEach(item->{ + YxStoreProduct storeProduct = storeProductMapper.selectById(item.getProductId()); + BrandIdList.add(storeProduct.getBrandId()); + }); + BrandIdList.forEach(item->{ + Map map1 = new LinkedHashMap<>(); + YxStoreBrand yxStoreBrand=yxStoreBrandMapper.selectById(item); + Map list = new LinkedHashMap<>(); + list.put("brandName",yxStoreBrand.getBrandName()); + list.put("pic",yxStoreBrand.getPic()); + map1.put("brand",list); + //对valid/invalid进行筛选,只要当前品牌下的商品 + List validProductList = new ArrayList<>(); + List invalidProductList = new ArrayList<>(); + valid.forEach(item1->{ + YxStoreProduct yxStoreProduct= storeProductMapper.selectById(item1.getProductId());; +// //商品品牌id相等 + if (item.equals(yxStoreProduct.getBrandId())){ + validProductList.add(item1); + } + }); + invalid.forEach(item1->{ + YxStoreProduct yxStoreProduct= storeProductMapper.selectById(item1.getProductId());; + //商品品牌id相等 + if (item.equals(yxStoreProduct.getBrandId())){ + invalidProductList.add(item1); + } + }); + map1.put("validProductList",validProductList); + map1.put("invalidProductList",invalidProductList); + cartList.add(map1); + }); +// map.put("valid", valid); +// map.put("invalid", invalid); + map.put("cartList",cartList); return map; } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java index 0d7d97f9..27892138 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java @@ -45,7 +45,6 @@ public class YxEvaluation implements Serializable { private String videoInput; - /** 关联商品信息 */ @NotNull private String product; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java index d6e95f2b..e087d8d8 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java @@ -121,7 +121,7 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl> getYxStoreHotLists(YxStoreHotListQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreHotListService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增hotList") + @ApiOperation("新增hotList") +// @PreAuthorize("@el.check('admin','yxStoreHotList:add')") + public ResponseEntity create(@Validated @RequestBody YxStoreHotList resources){ + return new ResponseEntity<>(yxStoreHotListService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改hotList") + @ApiOperation("修改hotList") +// @PreAuthorize("@el.check('admin','yxStoreHotList:edit')") + public ResponseEntity update(@Validated @RequestBody YxStoreHotList resources){ + yxStoreHotListService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除hotList") + @ApiOperation("删除hotList") +// @PreAuthorize("@el.check('admin','yxStoreHotList:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + Arrays.asList(ids).forEach(id->{ + yxStoreHotListService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java new file mode 100644 index 00000000..8d084477 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java @@ -0,0 +1,53 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.domain.PageResult; +import co.yixiang.modules.hotList.domain.YxStoreHotList; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListQueryCriteria; +import co.yixiang.modules.hotList.service.vo.YxStoreHotListVo; +import co.yixiang.utils.HotListDTO; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +/** +* @author ssj +* @date 2022-10-08 +*/ +public interface YxStoreHotListService extends BaseService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreHotListQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + List getList(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListDto.java new file mode 100644 index 00000000..fb0103eb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListDto.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.dto; + +import co.yixiang.modules.product.domain.YxStoreProduct; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +/** +* @author ssj +* @date 2022-10-08 +*/ +@Data +public class YxStoreHotListDto implements Serializable { + + /** 榜单列表ID */ + private Integer id; + + /** 榜单名称 */ + private String listName; + + /** 排序 */ + private Integer sort; + + /**商品列表*/ + private String productList; + + /** 是否显示 */ + private Integer isShow; + + /** 添加时间 */ + private Timestamp createTime; + + private Timestamp updateTime; + + /** 删除状态 */ + private Integer isDel; + + private Long tenantId; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListQueryCriteria.java new file mode 100644 index 00000000..6448caa5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.dto; + +import lombok.Data; + +/** +* @author ssj +* @date 2022-10-08 +*/ +@Data +public class YxStoreHotListQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java new file mode 100644 index 00000000..8a91ec84 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java @@ -0,0 +1,130 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.impl; + +import org.springframework.beans.BeanUtils; +import cn.hutool.json.JSONUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.hotList.domain.YxStoreHotList; +import co.yixiang.modules.hotList.service.YxStoreHotListService; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListQueryCriteria; +import co.yixiang.modules.hotList.service.mapper.YxStoreHotListMapper; +import co.yixiang.modules.hotList.service.vo.YxStoreHotListVo; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.HotListDTO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** +* @author ssj +* @date 2022-10-08 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxStoreHotList") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreHotListServiceImpl extends BaseServiceImpl implements YxStoreHotListService { + + private final IGenerator generator; + private final YxStoreProductService yxStoreProductService; + + + @SneakyThrows + @Override + //@Cacheable + public PageResult queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); +// PageInfo page1 = new PageInfo<>(); +// BeanUtils.copyProperties(page,page1); +// BeanUtilsBean.getInstance().copyProperties(page1, page); + page.getList().forEach(hotList->{ + List productArr = JSONUtil.toList(hotList.getProductList(), Integer.class); + List list1 =new ArrayList<>(); + productArr.forEach(productId->{ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .eq(YxStoreProduct::getId, productId); + //这里需要有一个非空判断 + YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(Long.valueOf(productId)); + list1.add(yxStoreProduct); + }); + hotList.setProductList(JSONUtil.toJsonStr(list1)); +// hotList.setProductInfo(list1); + }); + return generator.convertPageInfo(page, YxStoreHotListVo.class); + } + + + @Override + //@Cacheable + public List queryAll(YxStoreHotListQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreHotList.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreHotListDto yxStoreHotList : all) { + Map map = new LinkedHashMap<>(); + map.put("榜单名称", yxStoreHotList.getListName()); + map.put("排序", yxStoreHotList.getSort()); + map.put("商品列表", yxStoreHotList.getProductList()); + map.put("是否显示", yxStoreHotList.getIsShow()); + map.put("添加时间", yxStoreHotList.getCreateTime()); + map.put(" updateTime", yxStoreHotList.getUpdateTime()); + map.put("删除状态", yxStoreHotList.getIsDel()); + map.put(" tenantId", yxStoreHotList.getTenantId()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public List getList() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxStoreHotList::getSort); + List list = generator.convert(baseMapper.selectList(wrapper),HotListDTO.class); + list.forEach(hotListDto->{ + List productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); + List list1 =new ArrayList<>(); + productArr.forEach(productId->{ + //这里需要有一个非空判断 + YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(Long.valueOf(productId)); + list1.add(yxStoreProduct); + }); + hotListDto.setProductInfo(list1); + }); + return list; + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListMapper.java new file mode 100644 index 00000000..ec531958 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.hotList.domain.YxStoreHotList; +import org.springframework.stereotype.Repository; + +/** +* @author ssj +* @date 2022-10-08 +*/ +@Repository +public interface YxStoreHotListMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/vo/YxStoreHotListVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/vo/YxStoreHotListVo.java new file mode 100644 index 00000000..eb27d5fb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/vo/YxStoreHotListVo.java @@ -0,0 +1,37 @@ +package co.yixiang.modules.hotList.service.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + + +@Data +public class YxStoreHotListVo implements Serializable { + /** 榜单列表ID */ + private Integer id; + + /** 榜单名称 */ + private String listName; + + /** 排序 */ + private Integer sort; + + /**商品列表*/ + private String productList; + + /** 是否显示 */ + private Integer isShow; + + /** 添加时间 */ + private Timestamp createTime; + + private Timestamp updateTime; + + /** 删除状态 */ + private Integer isDel; + + private Long tenantId; + +// private List productInfo; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java index b7202b17..adaafb6d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java @@ -27,7 +27,9 @@ import co.yixiang.enums.SortEnum; import co.yixiang.enums.SpecTypeEnum; import co.yixiang.exception.BadRequestException; import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.activity.service.mapper.YxStoreBargainMapper; import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.modules.store.domain.YxStoreBrand; import co.yixiang.modules.store.service.YxStoreBrandService; import co.yixiang.modules.product.domain.YxStoreProduct; import co.yixiang.modules.product.domain.YxStoreProductAttrValue; @@ -53,6 +55,8 @@ import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemStoreService; import co.yixiang.modules.store.service.YxStoreBrandService; +import co.yixiang.modules.store.service.mapper.YxStoreBrandMapper; +import co.yixiang.modules.store.vo.YxStoreBrandVo; import co.yixiang.modules.template.domain.YxShippingTemplates; import co.yixiang.modules.template.service.YxShippingTemplatesService; import co.yixiang.modules.user.service.YxUserService; @@ -90,6 +94,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl { @@ -303,19 +315,24 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) .eq(YxStoreProduct::getId, id); YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper); + if (ObjectUtil.isNull(storeProduct)) { throw new ErrorRequestException("商品不存在或已下架"); } - + LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); + wrapper1.eq(YxStoreBrand::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .eq(YxStoreBrand::getId, storeProduct.getBrandId()); + YxStoreBrand storeBrand =storeBrandMapper.selectOne(wrapper1); //获取商品sku Map returnMap = yxStoreProductAttrService.getProductAttrDetail(id); ProductVo productVo = new ProductVo(); YxStoreProductQueryVo storeProductQueryVo = generator.convert(storeProduct, YxStoreProductQueryVo.class); - + //获取商品品牌信息 + YxStoreBrandVo yxStoreBrandVo =generator.convert(storeBrand,YxStoreBrandVo.class); //设置销量 storeProductQueryVo.setSales(storeProductQueryVo.getSales() + storeProductQueryVo.getFicti()); @@ -360,6 +377,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl) returnMap.get("productAttr")); productVo.setProductValue((Map) returnMap.get("productValue")); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java index 49a0f1ac..031ea14d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java @@ -1,6 +1,8 @@ package co.yixiang.modules.product.vo; import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.store.domain.YxStoreBrand; +import co.yixiang.modules.store.vo.YxStoreBrandVo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -47,6 +49,9 @@ public class ProductVo{ @ApiModelProperty(value = "商品信息") private YxStoreProductQueryVo storeInfo; + @ApiModelProperty(value = "品牌信息") + private YxStoreBrandVo brandInfo; + @ApiModelProperty(value = "腾讯地图key") private String mapKey; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java index bc17f851..592308ed 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java @@ -62,7 +62,7 @@ public class YxSystemGroupDataServiceImpl extends BaseServiceImpllambdaQuery() .eq(YxSystemGroupData::getGroupName,name) .eq(YxSystemGroupData::getStatus,CommonEnum.SHOW_STATUS_1.getValue()) - .orderByDesc(YxSystemGroupData::getSort)); + .orderByAsc(YxSystemGroupData::getSort)); List list = systemGroupDatas .stream() diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/store/domain/YxStoreBrand.java b/zsw-bxg/src/main/java/co/yixiang/modules/store/domain/YxStoreBrand.java index 49584cc3..79637cff 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/store/domain/YxStoreBrand.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/store/domain/YxStoreBrand.java @@ -30,7 +30,6 @@ public class YxStoreBrand implements Serializable { @TableId private Integer id; - /** 品牌名称 */ @NotBlank private String brandName; @@ -41,10 +40,11 @@ public class YxStoreBrand implements Serializable { /** 排序 */ private Integer sort; - /** 图标 */ private String pic; + /** 背景图片 */ + private String backgroundImage; /** 是否展示 */ private Integer isShow; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/store/service/YxStoreBrandService.java b/zsw-bxg/src/main/java/co/yixiang/modules/store/service/YxStoreBrandService.java index cb54294d..196f82df 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/store/service/YxStoreBrandService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/store/service/YxStoreBrandService.java @@ -25,7 +25,8 @@ import javax.servlet.http.HttpServletResponse; public interface YxStoreBrandService extends BaseService { List getList(); - + + /** * 查询数据分页 * @param criteria 条件 @@ -48,4 +49,6 @@ public interface YxStoreBrandService extends BaseService { * @throws IOException / */ void download(List all, HttpServletResponse response) throws IOException; + + BrandDTO getYxStoreBrandById(String id); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/store/service/dto/YxStoreBrandDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/store/service/dto/YxStoreBrandDto.java index d4821d5e..9c2a5913 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/store/service/dto/YxStoreBrandDto.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/store/service/dto/YxStoreBrandDto.java @@ -34,6 +34,9 @@ public class YxStoreBrandDto implements Serializable { /** 图标 */ private String pic; + /**背景图 */ + private String backgroundImage; + /** 是否推荐 */ private Integer isShow; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/store/service/impl/YxStoreBrandServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/store/service/impl/YxStoreBrandServiceImpl.java index 2513d314..30cb592d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/store/service/impl/YxStoreBrandServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/store/service/impl/YxStoreBrandServiceImpl.java @@ -8,6 +8,7 @@ */ package co.yixiang.modules.store.service.impl; +import cn.hutool.core.bean.BeanUtil; import co.yixiang.common.service.impl.BaseServiceImpl; import co.yixiang.common.utils.QueryHelpPlus; import co.yixiang.domain.PageResult; @@ -23,6 +24,7 @@ import co.yixiang.modules.store.service.YxStoreBrandService; import co.yixiang.modules.store.service.dto.YxStoreBrandDto; import co.yixiang.modules.store.service.dto.YxStoreBrandQueryCriteria; import co.yixiang.modules.store.service.mapper.YxStoreBrandMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -48,8 +50,8 @@ import java.util.LinkedHashMap; public class YxStoreBrandServiceImpl extends BaseServiceImpl implements YxStoreBrandService { private final IGenerator generator; - - + @Autowired + private YxStoreBrandMapper yxStoreBrandMapper; /** * 获取商家品牌树形列表 * @return List @@ -88,6 +90,7 @@ public class YxStoreBrandServiceImpl extends BaseServiceImpl wrapper=new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreBrand::getId,id); + YxStoreBrand yxStoreBrand=yxStoreBrandMapper.selectOne(wrapper); + BrandDTO brandDTO=new BrandDTO(); + BeanUtil.copyProperties(yxStoreBrand,brandDTO); + return brandDTO; + } } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/store/vo/YxStoreBrandVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/store/vo/YxStoreBrandVo.java new file mode 100644 index 00000000..2d3aa126 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/store/vo/YxStoreBrandVo.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2018-2020 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.store.vo; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.validation.constraints.*; +import java.sql.Timestamp; +import java.io.Serializable; + +/** + * @author ssj + * @date 2022-09-15 + */ +@Data +@TableName("yx_store_brand") +public class YxStoreBrandVo implements Serializable { + + /** 商品品牌表ID */ + @TableId + private Integer id; + + + /** 品牌名称 */ + @NotBlank + private String brandName; + + /** 品牌描述*/ + private String brandDescription; + + + /** 图标 */ + private String pic; + + /** 图标 */ + private String backgroundImage; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/BrandDTO.java b/zsw-bxg/src/main/java/co/yixiang/utils/BrandDTO.java index 8985bc0e..db838135 100644 --- a/zsw-bxg/src/main/java/co/yixiang/utils/BrandDTO.java +++ b/zsw-bxg/src/main/java/co/yixiang/utils/BrandDTO.java @@ -31,6 +31,13 @@ public class BrandDTO implements Serializable { */ private String pic; + /** + * 背景图url + */ + private String backgroundImage; + + /** 品牌描述*/ + private String brandDescription; // private List children = new ArrayList<>(); } diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/HotListDTO.java b/zsw-bxg/src/main/java/co/yixiang/utils/HotListDTO.java new file mode 100644 index 00000000..c6d1a742 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/HotListDTO.java @@ -0,0 +1,30 @@ +package co.yixiang.utils; + +import co.yixiang.modules.product.domain.YxStoreProduct; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Array; +import java.util.List; + +@Data +public class HotListDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId + /** 榜单列表ID */ + private Integer id; + + /** 榜单名称 */ + private String listName; + + /**商品数组*/ + private String productList; + +// /**商品信息数组**/ + private List productInfo; + + +}