Browse Source

修改增加新的分组控件

multiwx
xh-pan1 1 year ago
parent
commit
413b27fc90
  1. 29
      cereshop-admin/src/main/java/com/shop/cereshop/admin/controller/shop/CereShopGroupLangInfoController.java
  2. 16
      cereshop-admin/src/main/java/com/shop/cereshop/admin/dao/shop/CereShopGroupLangInfoDAO.java
  3. 22
      cereshop-admin/src/main/java/com/shop/cereshop/admin/service/shop/CereShopGroupLangInfoService.java
  4. 28
      cereshop-admin/src/main/java/com/shop/cereshop/admin/service/shop/impl/CereShopGroupLangInfoServiceImpl.java
  5. 19
      cereshop-admin/src/main/resources/mybatis/mapper/shop/CereShopGroupLangInfoDAO.xml
  6. 19
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java
  7. 29
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/shop/CereShopGroupLangInfoController.java
  8. 41
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/shop/CereShopGroupDAO.java
  9. 16
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/shop/CereShopGroupLangInfoDAO.java
  10. 107
      cereshop-app/src/main/java/com/shop/cereshop/app/page/group/Group.java
  11. 113
      cereshop-app/src/main/java/com/shop/cereshop/app/page/group/GroupDetail.java
  12. 112
      cereshop-app/src/main/java/com/shop/cereshop/app/page/group/GroupProduct.java
  13. 37
      cereshop-app/src/main/java/com/shop/cereshop/app/param/shop/GroupGetAllParam.java
  14. 24
      cereshop-app/src/main/java/com/shop/cereshop/app/param/shop/ProductGetGroupParam.java
  15. 22
      cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/CereShopGroupLangInfoService.java
  16. 24
      cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/CereShopGroupService.java
  17. 28
      cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/impl/CereShopGroupLangInfoServiceImpl.java
  18. 151
      cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/impl/CereShopGroupServiceImpl.java
  19. 2
      cereshop-app/src/main/resources/application.yml
  20. 158
      cereshop-app/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml
  21. 19
      cereshop-app/src/main/resources/mybatis/mapper/shop/CereShopGroupLangInfoDAO.xml
  22. 18
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/CanvasController.java
  23. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/ShopGroupController.java
  24. 29
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/shop/CereShopGroupLangInfoController.java
  25. 16
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupLangInfoDAO.java
  26. 60
      cereshop-business/src/main/java/com/shop/cereshop/business/page/group/Group.java
  27. 58
      cereshop-business/src/main/java/com/shop/cereshop/business/page/group/GroupDetail.java
  28. 56
      cereshop-business/src/main/java/com/shop/cereshop/business/page/group/GroupProduct.java
  29. 55
      cereshop-business/src/main/java/com/shop/cereshop/business/page/order/Product.java
  30. 8
      cereshop-business/src/main/java/com/shop/cereshop/business/param/group/GroupProductParam.java
  31. 10
      cereshop-business/src/main/java/com/shop/cereshop/business/param/group/ShopGroupSaveParam.java
  32. 10
      cereshop-business/src/main/java/com/shop/cereshop/business/param/group/ShopGroupUpdateParam.java
  33. 16
      cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java
  34. 22
      cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupLangInfoService.java
  35. 28
      cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupLangInfoServiceImpl.java
  36. 132
      cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java
  37. 9
      cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml
  38. 19
      cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupLangInfoDAO.xml
  39. 58
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/shop/CereShopGroup.java
  40. 93
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/shop/CereShopGroupLangInfo.java

29
cereshop-admin/src/main/java/com/shop/cereshop/admin/controller/shop/CereShopGroupLangInfoController.java

@ -0,0 +1,29 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.admin.controller.shop;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
*
* </p>
*
* @author
* @date 2024-03-06
*/
@Slf4j
@RestController
@RequestMapping("/cereShopGroupLangInfo")
@Api(value = "CereShopGroupLangInfo", tags = "")
public class CereShopGroupLangInfoController {
}

16
cereshop-admin/src/main/java/com/shop/cereshop/admin/dao/shop/CereShopGroupLangInfoDAO.java

@ -0,0 +1,16 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.admin.dao.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CereShopGroupLangInfoDAO extends BaseMapper<CereShopGroupLangInfo> {
}

22
cereshop-admin/src/main/java/com/shop/cereshop/admin/service/shop/CereShopGroupLangInfoService.java

@ -0,0 +1,22 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.admin.service.shop;
import com.baomidou.mybatisplus.extension.service.IService;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
/**
* <p>
* 业务接口
*
* </p>
*
* @author
* @date 2024-03-06
*/
public interface CereShopGroupLangInfoService extends IService<CereShopGroupLangInfo> {
}

28
cereshop-admin/src/main/java/com/shop/cereshop/admin/service/shop/impl/CereShopGroupLangInfoServiceImpl.java

@ -0,0 +1,28 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.admin.service.shop.impl;
import com.shop.cereshop.admin.dao.shop.CereShopGroupLangInfoDAO;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.admin.service.shop.CereShopGroupLangInfoService;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 业务实现类
*
* </p>
*
* @author
* @date 2024-03-06
*/
@Slf4j
@Service
public class CereShopGroupLangInfoServiceImpl extends ServiceImpl<CereShopGroupLangInfoDAO, CereShopGroupLangInfo> implements CereShopGroupLangInfoService {
}

19
cereshop-admin/src/main/resources/mybatis/mapper/shop/CereShopGroupLangInfoDAO.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.admin.dao.shop.CereShopGroupLangInfoDAO">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="shop_group_id" jdbcType="BIGINT" property="shopGroupId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName"/>
<result column="group_describe" jdbcType="VARCHAR" property="groupDescribe"/>
<result column="language_type" jdbcType="VARCHAR" property="languageType"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, shop_group_id, group_name, group_describe, language_type
</sql>
</mapper>

19
cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java

@ -19,6 +19,7 @@ import com.shop.cereshop.app.param.canvas.CanvasAppProductParam;
import com.shop.cereshop.app.param.canvas.CanvasCouponParam;
import com.shop.cereshop.app.param.canvas.RenovationParam;
import com.shop.cereshop.app.param.member.MemberProductPageParam;
import com.shop.cereshop.app.param.shop.ProductGetGroupParam;
import com.shop.cereshop.app.service.activity.CerePlatformActivityService;
import com.shop.cereshop.app.service.buyer.CereBuyerUserService;
import com.shop.cereshop.app.service.coupon.CereShopCouponService;
@ -30,6 +31,7 @@ import com.shop.cereshop.app.service.platformtool.CerePlatformSeckillService;
import com.shop.cereshop.app.service.price.CereShopPriceService;
import com.shop.cereshop.app.service.product.CereProductMemberService;
import com.shop.cereshop.app.service.product.CereShopProductService;
import com.shop.cereshop.app.service.shop.CereShopGroupService;
import com.shop.cereshop.app.utils.ContextUtil;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
@ -37,6 +39,7 @@ import com.shop.cereshop.commons.domain.canvas.CerePlatformCanvas;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.product.Classify;
import com.shop.cereshop.commons.domain.shop.CereShopGroup;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.commons.utils.EmptyUtils;
@ -96,6 +99,9 @@ public class CanvasController {
@Autowired
private CereLiveService cereLiveService;
@Autowired
private CereShopGroupService cereShopGroupService;
/**
* 画布选择商品查询
* @param param
@ -133,6 +139,19 @@ public class CanvasController {
}
/**
* 查询商品分组
* @return
*/
@GetMapping("getProductGroup")
@ApiOperation(value = "查询商品分组")
public Result<CereShopGroup> getProductGroup() throws CoBusinessException{
ProductGetGroupParam param = new ProductGetGroupParam();
param.setShopId(Long.parseLong(ContextUtil.getProject()));
List<CereShopGroup> list=cereShopGroupService.getGroupSelect(param);
return new Result(list);
}
/**
* 查询所有平台优惠券
* @return
*/

29
cereshop-app/src/main/java/com/shop/cereshop/app/controller/shop/CereShopGroupLangInfoController.java

@ -0,0 +1,29 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.controller.shop;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
*
* </p>
*
* @author
* @date 2024-03-06
*/
@Slf4j
@RestController
@RequestMapping("/cereShopGroupLangInfo")
@Api(value = "CereShopGroupLangInfo", tags = "")
public class CereShopGroupLangInfoController {
}

41
cereshop-app/src/main/java/com/shop/cereshop/app/dao/shop/CereShopGroupDAO.java

@ -0,0 +1,41 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.dao.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.app.page.group.Group;
import com.shop.cereshop.app.page.group.GroupDetail;
import com.shop.cereshop.app.page.group.GroupProduct;
import com.shop.cereshop.app.param.shop.GroupGetAllParam;
import com.shop.cereshop.commons.domain.shop.CereShopGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CereShopGroupDAO extends BaseMapper<CereShopGroup> {
int deleteByPrimaryKey(@Param("shopGroupId") Long shopGroupId);
int insertSelective(CereShopGroup record);
CereShopGroup selectByPrimaryKey(Long shopGroupId);
int updateByPrimaryKeySelective(CereShopGroup record);
int updateByPrimaryKey(CereShopGroup record);
List<CereShopGroup> getGroupSelect(@Param("project") String project, @Param("shopId") Long shopId);
void updateGroup(@Param("shopGroupId") Long shopGroupId);
GroupDetail getById(@Param("shopGroupId") Long shopGroupId);
List<Group> getAll(GroupGetAllParam param);
List<GroupProduct> findProducts(@Param("shopGroupId") Long shopGroupId);
List<CereShopGroup> selectAll(@Param("project") String project);
}

16
cereshop-app/src/main/java/com/shop/cereshop/app/dao/shop/CereShopGroupLangInfoDAO.java

@ -0,0 +1,16 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.dao.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CereShopGroupLangInfoDAO extends BaseMapper<CereShopGroupLangInfo> {
}

107
cereshop-app/src/main/java/com/shop/cereshop/app/page/group/Group.java

@ -0,0 +1,107 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.page.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 分组列表数据
*/
@Data
@ApiModel(value = "Group", description = "分组列表数据")
public class Group {
/**
* 商品分组id
*/
@ApiModelProperty(value = "商品分组id")
private Long shopGroupId;
/**
* 分组名称
*/
@ApiModelProperty(value = "分组名称")
private String groupName;
/**
* 分组描述
*/
@ApiModelProperty(value = "分组描述")
private String groupDescribe;
/**
* 商品数量
*/
@ApiModelProperty(value = "商品数量")
private Integer number;
/**
* 修改时间
*/
@ApiModelProperty(value = "修改时间")
private String updateTime;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
CereShopGroupLangInfo langInfo = langInfoMap.entrySet().stream().findFirst().get().getValue();
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
langInfo = langInfoMap.get(defaultLangType);
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
langInfo = langInfoMap.get(LangUtil.ZH);
} else if (langInfoMap.containsKey(LangUtil.EN)) {
langInfo = langInfoMap.get(LangUtil.EN);
}
if (Objects.nonNull(langInfo)) {
setGroupName(langInfo.getGroupName());
setGroupDescribe(langInfo.getGroupDescribe());
}
}else if(StringUtils.isNotEmpty(groupName)){
langInfoMap = new HashMap<>();
CereShopGroupLangInfo groupLangInfo = new CereShopGroupLangInfo();
groupLangInfo.setGroupName(getGroupName());
groupLangInfo.setGroupDescribe(getGroupDescribe());
groupLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, groupLangInfo);
}
}
public void initMap(List<CereShopGroupLangInfo> groupLangInfoList){
if (CollectionUtils.isNotEmpty(groupLangInfoList)) {
List<CereShopGroupLangInfo> langInfoList =
groupLangInfoList.stream().filter(item -> Objects.equals(item.getShopGroupId(), getShopGroupId())).collect(Collectors.toList());
Map<String, CereShopGroupLangInfo> groupLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(langInfoList)){
for (CereShopGroupLangInfo langInfo : langInfoList) {
groupLangInfoMap.put(langInfo.getLanguageType(), langInfo);
}
}
setLangInfoMap(groupLangInfoMap);
}
}
}

113
cereshop-app/src/main/java/com/shop/cereshop/app/page/group/GroupDetail.java

@ -0,0 +1,113 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.page.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 分组详情数据
*/
@Data
@ApiModel(value = "GroupDetail", description = "分组详情数据")
public class GroupDetail {
/**
* 商品分组id
*/
@ApiModelProperty(value = "商品分组id")
private Long shopGroupId;
/**
* 关联店铺id
*/
@ApiModelProperty(value = "关联店铺id")
private Long shopId;
/**
* 分组名称
*/
@ApiModelProperty(value = "分组名称")
private String groupName;
/**
* 分组封面图片地址
*/
@ApiModelProperty(value = "分组封面图片地址")
private String groupImage;
/**
* 分组描述
*/
@ApiModelProperty(value = "分组描述")
private String groupDescribe;
/**
* 关联商品数据
*/
@ApiModelProperty(value = "关联商品数据")
private List<GroupProduct> products;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
CereShopGroupLangInfo langInfo = langInfoMap.entrySet().stream().findFirst().get().getValue();
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
langInfo = langInfoMap.get(defaultLangType);
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
langInfo = langInfoMap.get(LangUtil.ZH);
} else if (langInfoMap.containsKey(LangUtil.EN)) {
langInfo = langInfoMap.get(LangUtil.EN);
}
if (Objects.nonNull(langInfo)) {
setGroupName(langInfo.getGroupName());
setGroupDescribe(langInfo.getGroupDescribe());
}
}else if(StringUtils.isNotEmpty(groupName)){
langInfoMap = new HashMap<>();
CereShopGroupLangInfo groupLangInfo = new CereShopGroupLangInfo();
groupLangInfo.setGroupName(getGroupName());
groupLangInfo.setGroupDescribe(getGroupDescribe());
groupLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, groupLangInfo);
}
}
public void initMap(List<CereShopGroupLangInfo> groupLangInfoList){
if (CollectionUtils.isNotEmpty(groupLangInfoList)) {
List<CereShopGroupLangInfo> langInfoList =
groupLangInfoList.stream().filter(item -> Objects.equals(item.getShopGroupId(), getShopGroupId())).collect(Collectors.toList());
Map<String, CereShopGroupLangInfo> groupLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(langInfoList)){
for (CereShopGroupLangInfo langInfo : langInfoList) {
groupLangInfoMap.put(langInfo.getLanguageType(), langInfo);
}
}
setLangInfoMap(groupLangInfoMap);
}
}
}

112
cereshop-app/src/main/java/com/shop/cereshop/app/page/group/GroupProduct.java

@ -0,0 +1,112 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.page.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.product.CereShopProductLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 分组商品数据
*/
@Data
@ApiModel(value = "GroupProduct", description = "分组商品数据")
public class GroupProduct {
/**
* 商品id
*/
@ApiModelProperty(value = "商品id")
private Long productId;
/**
* 商品名称
*/
@ApiModelProperty(value = "商品名称")
private String productName;
/**
* 上架状态 1-已上架 0-未上架
*/
@ApiModelProperty(value = "上架状态 1-已上架 0-未上架")
private Integer shelveState;
/**
* 图片
*/
@ApiModelProperty(value = "图片")
private String image;
/**
* 商品原价
*/
@ApiModelProperty(value = "商品原价")
private BigDecimal originalPrice;
/**
* 库存数量
*/
@ApiModelProperty(value = "库存数量")
private Integer stockNumber;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopProductLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
setProductName(langInfoMap.get(defaultLangType).getProductName());
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
setProductName(langInfoMap.get(LangUtil.ZH).getProductName());
} else if (langInfoMap.containsKey(LangUtil.EN)) {
setProductName(langInfoMap.get(LangUtil.EN).getProductName());
} else {
setProductName(langInfoMap.entrySet().stream().findFirst().get().getValue().getProductName());
}
}else if(StringUtils.isNotEmpty(productName)){
langInfoMap = new HashMap<>();
CereShopProductLangInfo classifyLangInfo = new CereShopProductLangInfo();
classifyLangInfo.setProductId(getProductId());
classifyLangInfo.setProductName(getProductName());
classifyLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, classifyLangInfo);
}
}
public void initMap(List<CereShopProductLangInfo> cereProductClassifyLangInfoList){
if (CollectionUtils.isNotEmpty(cereProductClassifyLangInfoList)) {
List<CereShopProductLangInfo> productClassifyLangInfoList =
cereProductClassifyLangInfoList.stream().filter(item -> Objects.equals(item.getProductId(), getProductId())).collect(Collectors.toList());
Map<String, CereShopProductLangInfo> cereProductClassifyLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(productClassifyLangInfoList)){
for (CereShopProductLangInfo cereProductClassifyLangInfo : productClassifyLangInfoList) {
cereProductClassifyLangInfoMap.put(cereProductClassifyLangInfo.getLanguageType(), cereProductClassifyLangInfo);
}
}
setLangInfoMap(cereProductClassifyLangInfoMap);
}
}
}

37
cereshop-app/src/main/java/com/shop/cereshop/app/param/shop/GroupGetAllParam.java

@ -0,0 +1,37 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.param.shop;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取分组列表请求
*/
@Data
@ApiModel(value = "GroupGetAllParam", description = "获取分组列表请求")
public class GroupGetAllParam extends PageParam {
/**
* 店铺id
*/
@ApiModelProperty(value = "店铺id")
private Long shopId;
/**
* 搜索字段
*/
@ApiModelProperty(value = "搜索字段")
private String search;
/**
* 平台号
*/
@ApiModelProperty(value = "平台号", hidden = true)
private String project;
}

24
cereshop-app/src/main/java/com/shop/cereshop/app/param/shop/ProductGetGroupParam.java

@ -0,0 +1,24 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.param.shop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取商品分组下拉请求
*/
@Data
@ApiModel(value = "ProductGetGroupParam", description = "获取商品分组下拉请求")
public class ProductGetGroupParam {
/**
* 关联店铺id
*/
@ApiModelProperty(value = "关联店铺id")
private Long shopId;
}

22
cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/CereShopGroupLangInfoService.java

@ -0,0 +1,22 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.shop;
import com.baomidou.mybatisplus.extension.service.IService;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
/**
* <p>
* 业务接口
*
* </p>
*
* @author
* @date 2024-03-06
*/
public interface CereShopGroupLangInfoService extends IService<CereShopGroupLangInfo> {
}

24
cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/CereShopGroupService.java

@ -0,0 +1,24 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.shop;
import com.shop.cereshop.app.page.group.GroupDetail;
import com.shop.cereshop.app.param.shop.GroupGetAllParam;
import com.shop.cereshop.app.param.shop.ProductGetGroupParam;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.shop.CereShopGroup;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.util.List;
public interface CereShopGroupService {
List<CereShopGroup> getGroupSelect(ProductGetGroupParam param) throws CoBusinessException;
GroupDetail getById(Long shopGroupId) throws CoBusinessException;
Page getAll(GroupGetAllParam param) throws CoBusinessException;
List<CereShopGroup> selectAll();
}

28
cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/impl/CereShopGroupLangInfoServiceImpl.java

@ -0,0 +1,28 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.shop.impl;
import com.shop.cereshop.app.dao.shop.CereShopGroupLangInfoDAO;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.app.service.shop.CereShopGroupLangInfoService;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 业务实现类
*
* </p>
*
* @author
* @date 2024-03-06
*/
@Slf4j
@Service
public class CereShopGroupLangInfoServiceImpl extends ServiceImpl<CereShopGroupLangInfoDAO, CereShopGroupLangInfo> implements CereShopGroupLangInfoService {
}

151
cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/impl/CereShopGroupServiceImpl.java

@ -0,0 +1,151 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.shop.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.app.dao.product.CereShopProductLangInfoDAO;
import com.shop.cereshop.app.dao.shop.CereShopGroupDAO;
import com.shop.cereshop.app.dao.shop.CereShopGroupLangInfoDAO;
import com.shop.cereshop.app.page.group.Group;
import com.shop.cereshop.app.page.group.GroupDetail;
import com.shop.cereshop.app.page.group.GroupProduct;
import com.shop.cereshop.app.param.shop.GroupGetAllParam;
import com.shop.cereshop.app.param.shop.ProductGetGroupParam;
import com.shop.cereshop.app.service.shop.CereShopGroupService;
import com.shop.cereshop.app.utils.ContextUtil;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.product.CereShopProductLangInfo;
import com.shop.cereshop.commons.domain.shop.CereShopGroup;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.ProjectUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CereShopGroupServiceImpl implements CereShopGroupService {
@Autowired
private CereShopGroupDAO cereShopGroupDAO;
@Autowired
private CereShopGroupLangInfoDAO cereShopGroupLangInfoDAO;
@Autowired
private CereShopProductLangInfoDAO cereShopProductLangInfoDAO;
@Override
public List<CereShopGroup> getGroupSelect(ProductGetGroupParam param) throws CoBusinessException {
// ContextUtil.getProject()
List<CereShopGroup> shopGroupList = cereShopGroupDAO.getGroupSelect(ProjectUtil.DEFAULT_PROJECT, param.getShopId());
setShopGroupLangInfo(shopGroupList);
return shopGroupList;
}
@Override
public GroupDetail getById(Long shopGroupId) throws CoBusinessException {
GroupDetail detail=cereShopGroupDAO.getById(shopGroupId);
if(detail!=null){
//设置商品数据
detail.setProducts(cereShopGroupDAO.findProducts(shopGroupId));
setGroupProductLangInfo(detail.getProducts());
}
setGroupDetailLangInfo(detail);
return detail;
}
@Override
public Page getAll(GroupGetAllParam param) throws CoBusinessException {
param.setProject(ContextUtil.getProject());
PageHelper.startPage(param.getPage(),param.getPageSize());
List<Group> list = cereShopGroupDAO.getAll(param);
setGroupLangInfo(list);
PageInfo<Group> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
@Override
public List<CereShopGroup> selectAll() {
List<CereShopGroup> groupList = cereShopGroupDAO.selectAll(ContextUtil.getProject());
setShopGroupLangInfo(groupList);
return groupList;
}
private void setGroupProductLangInfo(List<GroupProduct> groupProductList){
if(CollectionUtils.isEmpty(groupProductList)){
return;
}
List<Long> productIdList = new ArrayList<>();
productIdList.addAll(groupProductList.stream().map(GroupProduct::getProductId).collect(Collectors.toList()));
productIdList = productIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(productIdList)){
List<CereShopProductLangInfo> productLangInfoList = cereShopProductLangInfoDAO.selectList(Wrappers.<CereShopProductLangInfo>lambdaQuery().in(CereShopProductLangInfo::getProductId,productIdList));
if(CollectionUtils.isNotEmpty(groupProductList)){
for (GroupProduct product : groupProductList) {
product.initMap(productLangInfoList);
product.initData(ContextUtil.getLanguage());
}
}
}
}
private void setShopGroupLangInfo(List<CereShopGroup> shopGroupList){
if(CollectionUtils.isEmpty(shopGroupList)){
return;
}
List<Long> groupIdList = new ArrayList<>();
groupIdList.addAll(shopGroupList.stream().map(CereShopGroup::getShopGroupId).collect(Collectors.toList()));
groupIdList = groupIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(groupIdList)){
List<CereShopGroupLangInfo> groupLangInfoList = cereShopGroupLangInfoDAO.selectList(Wrappers.<CereShopGroupLangInfo>lambdaQuery().in(CereShopGroupLangInfo::getShopGroupId,groupIdList));
if(CollectionUtils.isNotEmpty(shopGroupList)){
for (CereShopGroup shopGroup : shopGroupList) {
shopGroup.initMap(groupLangInfoList);
shopGroup.initData(ContextUtil.getLanguage());
}
}
}
}
private void setGroupLangInfo(List<Group> groupList){
if(CollectionUtils.isEmpty(groupList)){
return;
}
List<Long> groupIdList = new ArrayList<>();
groupIdList.addAll(groupList.stream().map(Group::getShopGroupId).collect(Collectors.toList()));
groupIdList = groupIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(groupIdList)){
List<CereShopGroupLangInfo> groupLangInfoList = cereShopGroupLangInfoDAO.selectList(Wrappers.<CereShopGroupLangInfo>lambdaQuery().in(CereShopGroupLangInfo::getShopGroupId,groupIdList));
if(CollectionUtils.isNotEmpty(groupList)){
for (Group group : groupList) {
group.initMap(groupLangInfoList);
group.initData(ContextUtil.getLanguage());
}
}
}
}
private void setGroupDetailLangInfo(GroupDetail groupDetail){
if(groupDetail == null){
return;
}
List<CereShopGroupLangInfo> groupLangInfoList = cereShopGroupLangInfoDAO.selectList(Wrappers.<CereShopGroupLangInfo>lambdaQuery().eq(CereShopGroupLangInfo::getShopGroupId,groupDetail.getShopGroupId()));
groupDetail.initMap(groupLangInfoList);
groupDetail.initData(ContextUtil.getLanguage());
}
}

2
cereshop-app/src/main/resources/application.yml

@ -75,7 +75,7 @@ scrmTrackReportUrl: https://scrm-demo.zkthink.com/stage-api/wecom/clue-user/add
pay:
paymentMode: 4
spay:
xspay:
url: https://uwebgate.hnapay.com/webgate/unifiedAPI.htm
app_return_url: xx
app_notice_url: https://wechat.hnthee.com/ceres-app-api/extend/xsPay/pay/notify

158
cereshop-app/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml

@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.app.dao.shop.CereShopGroupDAO">
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.shop.CereShopGroup">
<id column="shop_group_id" jdbcType="BIGINT" property="shopGroupId" />
<result column="shop_id" jdbcType="BIGINT" property="shopId" />
<result column="project" jdbcType="VARCHAR" property="project" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="group_describe" jdbcType="VARCHAR" property="groupDescribe" />
<result column="group_image" jdbcType="VARCHAR" property="groupImage" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="update_time" jdbcType="VARCHAR" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
shop_group_id, shop_id, project, group_name,group_describe, group_image, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from cere_shop_group
where shop_group_id = #{shopGroupId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from cere_shop_group
where shop_group_id = #{shopGroupId,jdbcType=BIGINT}
</delete>
<insert id="insertSelective" keyColumn="shop_group_id" keyProperty="shopGroupId" parameterType="com.shop.cereshop.commons.domain.shop.CereShopGroup" useGeneratedKeys="true">
insert into cere_shop_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="shopId != null">
shop_id,
</if>
<if test="project != null and project!=''">
project,
</if>
<if test="groupName != null and groupName!=''">
group_name,
</if>
<if test="groupDescribe != null and groupDescribe!=''">
group_describe,
</if>
<if test="groupImage != null and groupImage!=''">
group_image,
</if>
<if test="createTime != null and createTime!=''">
create_time,
</if>
<if test="updateTime != null and updateTime!=''">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shopId != null">
#{shopId,jdbcType=BIGINT},
</if>
<if test="project != null and project!=''">
#{project,jdbcType=VARCHAR},
</if>
<if test="groupName != null and groupName!=''">
#{groupName,jdbcType=VARCHAR},
</if>
<if test="groupDescribe != null and groupDescribe!=''">
#{groupDescribe,jdbcType=VARCHAR},
</if>
<if test="groupImage != null and groupImage!=''">
#{groupImage,jdbcType=VARCHAR},
</if>
<if test="createTime != null and createTime!=''">
#{createTime,jdbcType=VARCHAR},
</if>
<if test="updateTime != null and updateTime!=''">
#{updateTime,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shop.cereshop.commons.domain.shop.CereShopGroup">
update cere_shop_group
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="project != null and project!=''">
project = #{groupName,jdbcType=VARCHAR},
</if>
<if test="groupName != null and groupName!=''">
group_name = #{groupName,jdbcType=VARCHAR},
</if>
<if test="groupDescribe != null and groupDescribe!=''">
group_describe = #{groupDescribe,jdbcType=VARCHAR},
</if>
<if test="groupImage != null and groupImage!=''">
group_image = #{groupImage,jdbcType=VARCHAR},
</if>
<if test="createTime != null and createTime!=''">
create_time = #{createTime,jdbcType=VARCHAR},
</if>
<if test="updateTime != null and updateTime!=''">
update_time = #{updateTime,jdbcType=VARCHAR},
</if>
</set>
where shop_group_id = #{shopGroupId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.shop.cereshop.commons.domain.shop.CereShopGroup">
update cere_shop_group
set shop_id = #{shopId,jdbcType=BIGINT},
project = #{project,jdbcType=VARCHAR},
group_name = #{groupName,jdbcType=VARCHAR},
group_describe = #{groupDescribe,jdbcType=VARCHAR},
group_image = #{groupImage,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=VARCHAR}
where shop_group_id = #{shopGroupId,jdbcType=BIGINT}
</update>
<select id="getGroupSelect" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.shop.CereShopGroup">
SELECT shop_group_id, shop_id, group_name FROM cere_shop_group where shop_id=#{shopId} AND project=#{project}
</select>
<select id="selectAll" resultType="com.shop.cereshop.commons.domain.shop.CereShopGroup">
SELECT shop_group_id,group_name, shop_id FROM cere_shop_group WHERE project=#{project}
</select>
<update id="updateGroup" parameterType="java.lang.Object">
UPDATE cere_shop_product set shop_group_id=NULL where shop_group_id=#{shopGroupId}
</update>
<select id="getById" parameterType="java.lang.Object" resultType="com.shop.cereshop.app.page.group.GroupDetail">
SELECT shop_group_id,group_name,group_image,group_describe FROM cere_shop_group where shop_group_id=#{shopGroupId}
</select>
<select id="getAll" parameterType="com.shop.cereshop.app.param.shop.GroupGetAllParam" resultType="com.shop.cereshop.app.page.group.Group">
SELECT a.shop_group_id, a.group_name, a.group_image,
ifnull(b.number, 0) as number, a.group_describe, a.update_time
from cere_shop_group a
LEFT JOIN (SELECT COUNT(*) number, shop_group_id from cere_shop_product GROUP BY shop_group_id) b
ON a.shop_group_id = b.shop_group_id
where a.shop_id = #{shopId}
<if test="search!=null and search!=''">
and a.group_name like concat('%', #{search}, '%')
</if>
<if test="project!=null and project!=''">
and a.project = #{project}
</if>
ORDER BY a.update_time DESC, a.create_time DESC
</select>
<select id="findProducts" parameterType="java.lang.Long" resultType="com.shop.cereshop.app.page.group.GroupProduct">
SELECT a.product_id,a.product_name,d.product_image image,b.original_price,c.stock_number,a.shelve_state from cere_shop_product a
LEFT JOIN (SELECT MIN(original_price) original_price,product_id from cere_product_sku GROUP BY product_id) b
ON a.product_id=b.product_id
LEFT JOIN (SELECT SUM(stock_number) stock_number,product_id FROM cere_product_sku GROUP BY product_id) c
ON a.product_id=c.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b where a.product_id=b.product_id
GROUP BY a.product_id) d ON a.product_id=d.product_id
where a.shop_group_id=#{shopGroupId}
</select>
</mapper>

19
cereshop-app/src/main/resources/mybatis/mapper/shop/CereShopGroupLangInfoDAO.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.app.dao.shop.CereShopGroupLangInfoDAO">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="shop_group_id" jdbcType="BIGINT" property="shopGroupId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName"/>
<result column="group_describe" jdbcType="VARCHAR" property="groupDescribe"/>
<result column="language_type" jdbcType="VARCHAR" property="languageType"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, shop_group_id, group_name, group_describe, language_type
</sql>
</mapper>

18
cereshop-business/src/main/java/com/shop/cereshop/business/controller/CanvasController.java

@ -11,6 +11,7 @@ import com.shop.cereshop.business.page.price.ShopPriceDetail;
import com.shop.cereshop.business.page.product.CanvasBusinessProductParam;
import com.shop.cereshop.business.page.product.MemberProduct;
import com.shop.cereshop.business.param.canvas.CanvasCouponParam;
import com.shop.cereshop.business.param.product.ProductGetGroupParam;
import com.shop.cereshop.business.param.renovation.RenovationParam;
import com.shop.cereshop.business.service.activity.CerePlatformActivityService;
import com.shop.cereshop.business.service.canvas.CerePlatformCanvasService;
@ -19,12 +20,14 @@ import com.shop.cereshop.business.service.price.CereShopPriceService;
import com.shop.cereshop.business.service.product.CereProductClassifyService;
import com.shop.cereshop.business.service.product.CereProductMemberService;
import com.shop.cereshop.business.service.product.CereShopProductService;
import com.shop.cereshop.business.service.shop.CereShopGroupService;
import com.shop.cereshop.business.service.tool.CereShopCouponService;
import com.shop.cereshop.business.utils.ContextUtil;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.canvas.CerePlatformCanvas;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.product.Classify;
import com.shop.cereshop.commons.domain.shop.CereShopGroup;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.commons.utils.GsonUtil;
@ -58,6 +61,8 @@ public class CanvasController {
private CereProductClassifyService cereProductClassifyService;
@Autowired
private CereShopGroupService cereShopGroupService;
@Autowired
private CerePlatformCanvasService cerePlatformCanvasService;
@Autowired
@ -129,6 +134,19 @@ public class CanvasController {
}
/**
* 查询商品分组
* @return
*/
@GetMapping("getProductGroup")
@ApiOperation(value = "查询商品分组")
public Result<CereShopGroup> getProductGroup() throws CoBusinessException{
ProductGetGroupParam param = new ProductGetGroupParam();
param.setShopId(ContextUtil.getBusinessId());
List<CereShopGroup> list=cereShopGroupService.getGroupSelect(param);
return new Result(list);
}
/**
* 查询所有平台优惠券
* @return
*/

2
cereshop-business/src/main/java/com/shop/cereshop/business/controller/ShopGroupController.java

@ -140,7 +140,7 @@ public class ShopGroupController {
@PostMapping(value = "getProducts")
@ApiOperation(value = "手动添加商品查询")
public Result<Page<GroupProduct>> getProducts(@RequestBody GroupProductParam param) throws CoBusinessException{
param.setShopId(ContextUtil.getBusinessId());
param.setBusinessId(ContextUtil.getBusinessId());
Page page=cereShopGroupService.getProducts(param);
return new Result(page);
}

29
cereshop-business/src/main/java/com/shop/cereshop/business/controller/shop/CereShopGroupLangInfoController.java

@ -0,0 +1,29 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.controller.shop;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
*
* </p>
*
* @author
* @date 2024-03-06
*/
@Slf4j
@RestController
@RequestMapping("/cereShopGroupLangInfo")
@Api(value = "CereShopGroupLangInfo", tags = "")
public class CereShopGroupLangInfoController {
}

16
cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupLangInfoDAO.java

@ -0,0 +1,16 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.dao.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CereShopGroupLangInfoDAO extends BaseMapper<CereShopGroupLangInfo> {
}

60
cereshop-business/src/main/java/com/shop/cereshop/business/page/group/Group.java

@ -5,10 +5,21 @@
*/
package com.shop.cereshop.business.page.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 分组列表数据
*/
@ -44,4 +55,53 @@ public class Group {
*/
@ApiModelProperty(value = "修改时间")
private String updateTime;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
CereShopGroupLangInfo langInfo = langInfoMap.entrySet().stream().findFirst().get().getValue();
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
langInfo = langInfoMap.get(defaultLangType);
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
langInfo = langInfoMap.get(LangUtil.ZH);
} else if (langInfoMap.containsKey(LangUtil.EN)) {
langInfo = langInfoMap.get(LangUtil.EN);
}
if (Objects.nonNull(langInfo)) {
setGroupName(langInfo.getGroupName());
setGroupDescribe(langInfo.getGroupDescribe());
}
}else if(StringUtils.isNotEmpty(groupName)){
langInfoMap = new HashMap<>();
CereShopGroupLangInfo groupLangInfo = new CereShopGroupLangInfo();
groupLangInfo.setGroupName(getGroupName());
groupLangInfo.setGroupDescribe(getGroupDescribe());
groupLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, groupLangInfo);
}
}
public void initMap(List<CereShopGroupLangInfo> groupLangInfoList){
if (CollectionUtils.isNotEmpty(groupLangInfoList)) {
List<CereShopGroupLangInfo> langInfoList =
groupLangInfoList.stream().filter(item -> Objects.equals(item.getShopGroupId(), getShopGroupId())).collect(Collectors.toList());
Map<String, CereShopGroupLangInfo> groupLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(langInfoList)){
for (CereShopGroupLangInfo langInfo : langInfoList) {
groupLangInfoMap.put(langInfo.getLanguageType(), langInfo);
}
}
setLangInfoMap(groupLangInfoMap);
}
}
}

58
cereshop-business/src/main/java/com/shop/cereshop/business/page/group/GroupDetail.java

@ -5,11 +5,20 @@
*/
package com.shop.cereshop.business.page.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 分组详情数据
@ -52,4 +61,53 @@ public class GroupDetail {
*/
@ApiModelProperty(value = "关联商品数据")
private List<GroupProduct> products;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
CereShopGroupLangInfo langInfo = langInfoMap.entrySet().stream().findFirst().get().getValue();
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
langInfo = langInfoMap.get(defaultLangType);
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
langInfo = langInfoMap.get(LangUtil.ZH);
} else if (langInfoMap.containsKey(LangUtil.EN)) {
langInfo = langInfoMap.get(LangUtil.EN);
}
if (Objects.nonNull(langInfo)) {
setGroupName(langInfo.getGroupName());
setGroupDescribe(langInfo.getGroupDescribe());
}
}else if(StringUtils.isNotEmpty(groupName)){
langInfoMap = new HashMap<>();
CereShopGroupLangInfo groupLangInfo = new CereShopGroupLangInfo();
groupLangInfo.setGroupName(getGroupName());
groupLangInfo.setGroupDescribe(getGroupDescribe());
groupLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, groupLangInfo);
}
}
public void initMap(List<CereShopGroupLangInfo> groupLangInfoList){
if (CollectionUtils.isNotEmpty(groupLangInfoList)) {
List<CereShopGroupLangInfo> langInfoList =
groupLangInfoList.stream().filter(item -> Objects.equals(item.getShopGroupId(), getShopGroupId())).collect(Collectors.toList());
Map<String, CereShopGroupLangInfo> groupLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(langInfoList)){
for (CereShopGroupLangInfo langInfo : langInfoList) {
groupLangInfoMap.put(langInfo.getLanguageType(), langInfo);
}
}
setLangInfoMap(groupLangInfoMap);
}
}
}

56
cereshop-business/src/main/java/com/shop/cereshop/business/page/group/GroupProduct.java

@ -5,11 +5,21 @@
*/
package com.shop.cereshop.business.page.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.product.CereShopProductLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 分组商品数据
@ -53,4 +63,50 @@ public class GroupProduct {
*/
@ApiModelProperty(value = "库存数量")
private Integer stockNumber;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopProductLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
setProductName(langInfoMap.get(defaultLangType).getProductName());
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
setProductName(langInfoMap.get(LangUtil.ZH).getProductName());
} else if (langInfoMap.containsKey(LangUtil.EN)) {
setProductName(langInfoMap.get(LangUtil.EN).getProductName());
} else {
setProductName(langInfoMap.entrySet().stream().findFirst().get().getValue().getProductName());
}
}else if(StringUtils.isNotEmpty(productName)){
langInfoMap = new HashMap<>();
CereShopProductLangInfo classifyLangInfo = new CereShopProductLangInfo();
classifyLangInfo.setProductId(getProductId());
classifyLangInfo.setProductName(getProductName());
classifyLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, classifyLangInfo);
}
}
public void initMap(List<CereShopProductLangInfo> cereProductClassifyLangInfoList){
if (CollectionUtils.isNotEmpty(cereProductClassifyLangInfoList)) {
List<CereShopProductLangInfo> productClassifyLangInfoList =
cereProductClassifyLangInfoList.stream().filter(item -> Objects.equals(item.getProductId(), getProductId())).collect(Collectors.toList());
Map<String, CereShopProductLangInfo> cereProductClassifyLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(productClassifyLangInfoList)){
for (CereShopProductLangInfo cereProductClassifyLangInfo : productClassifyLangInfoList) {
cereProductClassifyLangInfoMap.put(cereProductClassifyLangInfo.getLanguageType(), cereProductClassifyLangInfo);
}
}
setLangInfoMap(cereProductClassifyLangInfoMap);
}
}
}

55
cereshop-business/src/main/java/com/shop/cereshop/business/page/order/Product.java

@ -5,12 +5,21 @@
*/
package com.shop.cereshop.business.page.order;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.domain.product.CereShopProductLangInfo;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 订单商品返回数据实体类
@ -132,4 +141,50 @@ public class Product {
*/
@ApiModelProperty(value = "品牌名称")
private String brandName;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopProductLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
setProductName(langInfoMap.get(defaultLangType).getProductName());
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
setProductName(langInfoMap.get(LangUtil.ZH).getProductName());
} else if (langInfoMap.containsKey(LangUtil.EN)) {
setProductName(langInfoMap.get(LangUtil.EN).getProductName());
} else {
setProductName(langInfoMap.entrySet().stream().findFirst().get().getValue().getProductName());
}
}else if(StringUtils.isNotEmpty(productName)){
langInfoMap = new HashMap<>();
CereShopProductLangInfo classifyLangInfo = new CereShopProductLangInfo();
classifyLangInfo.setProductId(getProductId());
classifyLangInfo.setProductName(getProductName());
classifyLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, classifyLangInfo);
}
}
public void initMap(List<CereShopProductLangInfo> cereProductClassifyLangInfoList){
if (CollectionUtils.isNotEmpty(cereProductClassifyLangInfoList)) {
List<CereShopProductLangInfo> productClassifyLangInfoList =
cereProductClassifyLangInfoList.stream().filter(item -> Objects.equals(item.getProductId(), getProductId())).collect(Collectors.toList());
Map<String, CereShopProductLangInfo> cereProductClassifyLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(productClassifyLangInfoList)){
for (CereShopProductLangInfo cereProductClassifyLangInfo : productClassifyLangInfoList) {
cereProductClassifyLangInfoMap.put(cereProductClassifyLangInfo.getLanguageType(), cereProductClassifyLangInfo);
}
}
setLangInfoMap(cereProductClassifyLangInfoMap);
}
}
}

8
cereshop-business/src/main/java/com/shop/cereshop/business/param/group/GroupProductParam.java

@ -18,7 +18,13 @@ import java.math.BigDecimal;
@Data
@ApiModel(value = "GroupProductParam", description = "获取分组商品列表请求")
public class GroupProductParam extends PageParam {
/**
* 商家id
*/
@ApiModelProperty(value = "商家id")
private Long businessId;
/**
* 店铺id
*/

10
cereshop-business/src/main/java/com/shop/cereshop/business/param/group/ShopGroupSaveParam.java

@ -5,12 +5,15 @@
*/
package com.shop.cereshop.business.param.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author 新增商品分组
@ -61,6 +64,13 @@ public class ShopGroupSaveParam implements Serializable {
@ApiModelProperty(value = "筛选条件数组")
private List<GroupCondition> conditions;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
private static final long serialVersionUID = 1L;
}

10
cereshop-business/src/main/java/com/shop/cereshop/business/param/group/ShopGroupUpdateParam.java

@ -5,12 +5,15 @@
*/
package com.shop.cereshop.business.param.group;
import com.baomidou.mybatisplus.annotation.TableField;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author 修改商品分组
@ -66,6 +69,13 @@ public class ShopGroupUpdateParam implements Serializable {
@ApiModelProperty(value = "筛选条件数组")
private List<GroupCondition> conditions;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
private static final long serialVersionUID = 1L;
}

16
cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java

@ -811,16 +811,16 @@ public class CereShopProductServiceImpl implements CereShopProductService {
list=cereShopProductDAO.getProducts(param);
}
List<Long> classifyIdList = new ArrayList<>();
classifyIdList.addAll(list.stream().map(CanvasProduct::getProductId).collect(Collectors.toList()));
classifyIdList = classifyIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
List<Long> productIdList = new ArrayList<>();
productIdList.addAll(list.stream().map(CanvasProduct::getProductId).collect(Collectors.toList()));
productIdList = productIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(classifyIdList)){
List<CereShopProductLangInfo> cereProductClassifyLangInfoList = shopProductLangInfoService.list(Wrappers.<CereShopProductLangInfo>lambdaQuery().in(CereShopProductLangInfo::getProductId,classifyIdList));
if(CollectionUtils.isNotEmpty(productIdList)){
List<CereShopProductLangInfo> productLangInfoList = shopProductLangInfoService.list(Wrappers.<CereShopProductLangInfo>lambdaQuery().in(CereShopProductLangInfo::getProductId,productIdList));
if(CollectionUtils.isNotEmpty(list)){
for (CanvasProduct classify : list) {
classify.initMap(cereProductClassifyLangInfoList);
classify.initData(ContextUtil.getLanguage());
for (CanvasProduct product : list) {
product.initMap(productLangInfoList);
product.initData(ContextUtil.getLanguage());
}
}
}

22
cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupLangInfoService.java

@ -0,0 +1,22 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.shop;
import com.baomidou.mybatisplus.extension.service.IService;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
/**
* <p>
* 业务接口
*
* </p>
*
* @author
* @date 2024-03-06
*/
public interface CereShopGroupLangInfoService extends IService<CereShopGroupLangInfo> {
}

28
cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupLangInfoServiceImpl.java

@ -0,0 +1,28 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.shop.impl;
import com.shop.cereshop.business.dao.shop.CereShopGroupLangInfoDAO;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.business.service.shop.CereShopGroupLangInfoService;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 业务实现类
*
* </p>
*
* @author
* @date 2024-03-06
*/
@Slf4j
@Service
public class CereShopGroupLangInfoServiceImpl extends ServiceImpl<CereShopGroupLangInfoDAO, CereShopGroupLangInfo> implements CereShopGroupLangInfoService {
}

132
cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java

@ -5,9 +5,12 @@
*/
package com.shop.cereshop.business.service.shop.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.product.CereShopProductLangInfoDAO;
import com.shop.cereshop.business.dao.shop.CereShopGroupDAO;
import com.shop.cereshop.business.dao.shop.CereShopGroupLangInfoDAO;
import com.shop.cereshop.business.page.group.Group;
import com.shop.cereshop.business.page.group.GroupDetail;
import com.shop.cereshop.business.page.group.GroupProduct;
@ -20,16 +23,20 @@ import com.shop.cereshop.business.utils.ContextUtil;
import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.product.CereShopProductLangInfo;
import com.shop.cereshop.commons.domain.shop.CereShopGroup;
import com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.TimeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -44,9 +51,18 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
@Autowired
private CerePlatformLogService cerePlatformLogService;
@Autowired
private CereShopGroupLangInfoDAO cereShopGroupLangInfoDAO;
@Autowired
private CereShopProductLangInfoDAO cereShopProductLangInfoDAO;
@Override
public List<CereShopGroup> getGroupSelect(ProductGetGroupParam param) throws CoBusinessException {
return cereShopGroupDAO.getGroupSelect(ContextUtil.getProject(), param.getShopId());
List<CereShopGroup> shopGroupList = cereShopGroupDAO.getGroupSelect(ContextUtil.getProject(), param.getShopId());
setShopGroupLangInfo(shopGroupList);
return shopGroupList;
}
@Override
@ -62,7 +78,17 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
group.setCreateTime(time);
group.setUpdateTime(time);
group.setGroupDescribe(param.getGroupDescribe());
group.setLangInfoMap(param.getLangInfoMap());
group.initData();
cereShopGroupDAO.insert(group);
for (Map.Entry<String, CereShopGroupLangInfo> groupLangInfoEntry : param.getLangInfoMap().entrySet()) {
CereShopGroupLangInfo groupLangInfo = groupLangInfoEntry.getValue();
groupLangInfo.setShopGroupId(group.getShopGroupId());
groupLangInfo.setId(null);
cereShopGroupLangInfoDAO.insert(groupLangInfo);
}
if(!EmptyUtils.isEmpty(param.getIds())){
//手动添加商品
cereShopGroupDAO.addProduct(param.getIds(),group.getShopGroupId());
@ -112,7 +138,17 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
group.setGroupImage(param.getGroupImage());
group.setGroupDescribe(param.getGroupDescribe());
group.setUpdateTime(time);
group.setLangInfoMap(param.getLangInfoMap());
group.initData();
cereShopGroupDAO.updateByPrimaryKeySelective(group);
cereShopGroupLangInfoDAO.delete(Wrappers.<CereShopGroupLangInfo>lambdaQuery().eq(CereShopGroupLangInfo::getShopGroupId,group.getShopGroupId()));
for (Map.Entry<String, CereShopGroupLangInfo> groupLangInfoEntry : param.getLangInfoMap().entrySet()) {
CereShopGroupLangInfo groupLangInfo = groupLangInfoEntry.getValue();
groupLangInfo.setShopGroupId(group.getShopGroupId());
groupLangInfo.setId(null);
cereShopGroupLangInfoDAO.insert(groupLangInfo);
}
if(!EmptyUtils.isEmpty(param.getIds())){
//清空之前添加的商品
cereShopGroupDAO.deleteProduct(group.getShopGroupId());
@ -185,6 +221,7 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
//查询商品数据
list=cereShopGroupDAO.findProductByIds(ids);
}
setProductLangInfo(list);
return list;
}
@ -205,7 +242,9 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
if(detail!=null){
//设置商品数据
detail.setProducts(cereShopGroupDAO.findProducts(shopGroupId));
setGroupProductLangInfo(detail.getProducts());
}
setGroupDetailLangInfo(detail);
return detail;
}
@ -214,6 +253,7 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
param.setProject(ContextUtil.getProject());
PageHelper.startPage(param.getPage(),param.getPageSize());
List<Group> list = cereShopGroupDAO.getAll(param);
setGroupLangInfo(list);
PageInfo<Group> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
@ -223,6 +263,7 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
public Page getProducts(GroupProductParam param) throws CoBusinessException {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<GroupProduct> list = cereShopGroupDAO.getProducts(param);
setGroupProductLangInfo(list);
PageInfo<GroupProduct> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
@ -231,6 +272,93 @@ public class CereShopGroupServiceImpl implements CereShopGroupService {
@Override
public List<CereShopGroup> selectAll() {
return cereShopGroupDAO.selectAll(ContextUtil.getProject());
List<CereShopGroup> groupList = cereShopGroupDAO.selectAll(ContextUtil.getProject());
setShopGroupLangInfo(groupList);
return groupList;
}
private void setGroupProductLangInfo(List<GroupProduct> groupProductList){
if(CollectionUtils.isEmpty(groupProductList)){
return;
}
List<Long> productIdList = new ArrayList<>();
productIdList.addAll(groupProductList.stream().map(GroupProduct::getProductId).collect(Collectors.toList()));
productIdList = productIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(productIdList)){
List<CereShopProductLangInfo> productLangInfoList = cereShopProductLangInfoDAO.selectList(Wrappers.<CereShopProductLangInfo>lambdaQuery().in(CereShopProductLangInfo::getProductId,productIdList));
if(CollectionUtils.isNotEmpty(groupProductList)){
for (GroupProduct product : groupProductList) {
product.initMap(productLangInfoList);
product.initData(ContextUtil.getLanguage());
}
}
}
}
private void setProductLangInfo(List<Product> productList){
if(CollectionUtils.isEmpty(productList)){
return;
}
List<Long> productIdList = new ArrayList<>();
productIdList.addAll(productList.stream().map(Product::getProductId).collect(Collectors.toList()));
productIdList = productIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(productIdList)){
List<CereShopProductLangInfo> productLangInfoList = cereShopProductLangInfoDAO.selectList(Wrappers.<CereShopProductLangInfo>lambdaQuery().in(CereShopProductLangInfo::getProductId,productIdList));
if(CollectionUtils.isNotEmpty(productList)){
for (Product product : productList) {
product.initMap(productLangInfoList);
product.initData(ContextUtil.getLanguage());
}
}
}
}
private void setShopGroupLangInfo(List<CereShopGroup> shopGroupList){
if(CollectionUtils.isEmpty(shopGroupList)){
return;
}
List<Long> groupIdList = new ArrayList<>();
groupIdList.addAll(shopGroupList.stream().map(CereShopGroup::getShopGroupId).collect(Collectors.toList()));
groupIdList = groupIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(groupIdList)){
List<CereShopGroupLangInfo> groupLangInfoList = cereShopGroupLangInfoDAO.selectList(Wrappers.<CereShopGroupLangInfo>lambdaQuery().in(CereShopGroupLangInfo::getShopGroupId,groupIdList));
if(CollectionUtils.isNotEmpty(shopGroupList)){
for (CereShopGroup shopGroup : shopGroupList) {
shopGroup.initMap(groupLangInfoList);
shopGroup.initData(ContextUtil.getLanguage());
}
}
}
}
private void setGroupLangInfo(List<Group> groupList){
if(CollectionUtils.isEmpty(groupList)){
return;
}
List<Long> groupIdList = new ArrayList<>();
groupIdList.addAll(groupList.stream().map(Group::getShopGroupId).collect(Collectors.toList()));
groupIdList = groupIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(groupIdList)){
List<CereShopGroupLangInfo> groupLangInfoList = cereShopGroupLangInfoDAO.selectList(Wrappers.<CereShopGroupLangInfo>lambdaQuery().in(CereShopGroupLangInfo::getShopGroupId,groupIdList));
if(CollectionUtils.isNotEmpty(groupList)){
for (Group group : groupList) {
group.initMap(groupLangInfoList);
group.initData(ContextUtil.getLanguage());
}
}
}
}
private void setGroupDetailLangInfo(GroupDetail groupDetail){
if(groupDetail == null){
return;
}
List<CereShopGroupLangInfo> groupLangInfoList = cereShopGroupLangInfoDAO.selectList(Wrappers.<CereShopGroupLangInfo>lambdaQuery().eq(CereShopGroupLangInfo::getShopGroupId,groupDetail.getShopGroupId()));
groupDetail.initMap(groupLangInfoList);
groupDetail.initData(ContextUtil.getLanguage());
}
}

9
cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml

@ -163,7 +163,14 @@
ON a.product_id=c.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b where a.product_id=b.product_id
GROUP BY a.product_id) d ON a.product_id=d.product_id
where a.shop_id=#{shopId}
INNER JOIN cere_platform_shop cps ON cps.shop_id = a.shop_id
where 1=1
<if test="shopId!=null and shopId > 0">
AND a.shop_id=#{shopId}
</if>
<if test="businessId!=null and businessId > 0">
AND cps.business_id = #{businessId}
</if>
<if test="search!=null and search!=''">
and (a.product_id like concat('%',#{search},'%') OR
a.product_name like concat('%',#{search},'%'))

19
cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupLangInfoDAO.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.business.dao.shop.CereShopGroupLangInfoDAO">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.shop.CereShopGroupLangInfo">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="shop_group_id" jdbcType="BIGINT" property="shopGroupId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName"/>
<result column="group_describe" jdbcType="VARCHAR" property="groupDescribe"/>
<result column="language_type" jdbcType="VARCHAR" property="languageType"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, shop_group_id, group_name, group_describe, language_type
</sql>
</mapper>

58
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/shop/CereShopGroup.java

@ -6,12 +6,21 @@
package com.shop.cereshop.commons.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.shop.cereshop.commons.utils.LangUtil;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* cere_shop_group 店铺商品分组实体类
@ -71,4 +80,53 @@ public class CereShopGroup implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 名称Map
*/
@ApiModelProperty(value = "名称Map")
@TableField(exist = false)
private Map<String, CereShopGroupLangInfo> langInfoMap;
public void initData(){
initData(LangUtil.ZH);
}
public void initData(String defaultLangType){
if(CollectionUtils.isNotEmpty(langInfoMap)) {
CereShopGroupLangInfo langInfo = langInfoMap.entrySet().stream().findFirst().get().getValue();
if (StringUtils.isNotEmpty(defaultLangType) && langInfoMap.containsKey(defaultLangType)) {
langInfo = langInfoMap.get(defaultLangType);
}else if (langInfoMap.containsKey(LangUtil.ZH)) {
langInfo = langInfoMap.get(LangUtil.ZH);
} else if (langInfoMap.containsKey(LangUtil.EN)) {
langInfo = langInfoMap.get(LangUtil.EN);
}
if (Objects.nonNull(langInfo)) {
setGroupName(langInfo.getGroupName());
setGroupDescribe(langInfo.getGroupDescribe());
}
}else if(StringUtils.isNotEmpty(groupName)){
langInfoMap = new HashMap<>();
CereShopGroupLangInfo groupLangInfo = new CereShopGroupLangInfo();
groupLangInfo.setGroupName(getGroupName());
groupLangInfo.setGroupDescribe(getGroupDescribe());
groupLangInfo.setLanguageType(LangUtil.ZH);
langInfoMap.put(LangUtil.ZH, groupLangInfo);
}
}
public void initMap(List<CereShopGroupLangInfo> groupLangInfoList){
if (CollectionUtils.isNotEmpty(groupLangInfoList)) {
List<CereShopGroupLangInfo> langInfoList =
groupLangInfoList.stream().filter(item -> Objects.equals(item.getShopGroupId(), getShopGroupId())).collect(Collectors.toList());
Map<String, CereShopGroupLangInfo> groupLangInfoMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(langInfoList)){
for (CereShopGroupLangInfo langInfo : langInfoList) {
groupLangInfoMap.put(langInfo.getLanguageType(), langInfo);
}
}
setLangInfoMap(groupLangInfoMap);
}
}
}

93
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/shop/CereShopGroupLangInfo.java

@ -0,0 +1,93 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.commons.domain.shop;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
/**
* <p>
* 实体类
*
* </p>
*
* @since 2024-03-06
*/
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@TableName("cere_shop_group_lang_info")
@ApiModel(value = "CereShopGroupLangInfo", description = "")
@AllArgsConstructor
public class CereShopGroupLangInfo {
private static final long serialVersionUID = 1L;
/**
* 主键Id
*/
@ApiModelProperty(value = "主键Id")
@NotNull(message = "主键Id不能为空")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 分组主键
*/
@ApiModelProperty(value = "分组主键")
@TableField("shop_group_id")
private Long shopGroupId;
/**
* 分组名字
*/
@ApiModelProperty(value = "分组名字")
@Length(max = 255, message = "分组名字长度不能超过255")
@TableField(value = "group_name", condition = LIKE)
private String groupName;
/**
* 分组描述
*/
@ApiModelProperty(value = "分组描述")
@Length(max = 255, message = "分组描述长度不能超过255")
@TableField(value = "group_describe", condition = LIKE)
private String groupDescribe;
/**
* 语言类型
*/
@ApiModelProperty(value = "语言类型")
@Length(max = 32, message = "语言类型长度不能超过32")
@TableField(value = "language_type", condition = LIKE)
private String languageType;
}
Loading…
Cancel
Save