From 5a86a3c3a4a44759f9fe408034d1663c73745dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F=E5=BC=A0?= <1085577365@qq.com> Date: Wed, 10 May 2023 16:43:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=B5=81=E7=AE=A1=E7=90=86--=E4=B8=8D?= =?UTF-8?q?=E5=8C=85=E9=82=AE=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ShippingTemplatesNoDeliveryController.java | 50 ++++++++++ .../vo/ShippingTemplatesNoDeliveryRespVO.java | 36 +++++++ .../express/vo/ShippingTemplatesReqVO.java | 3 + .../ShippingTemplatesNoDeliveryDO.java | 50 ++++++++++ .../ShippingTemplatesNoDeliveryMapper.java | 25 +++++ .../ShippingTemplatesNoDeliveryService.java | 34 +++++++ ...hippingTemplatesNoDeliveryServiceImpl.java | 95 +++++++++++++++++++ .../express/ShippingTemplatesServiceImpl.java | 18 +++- .../ShippingTemplatesNoDeliveryMapper.xml | 8 ++ 9 files changed, 315 insertions(+), 4 deletions(-) create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesNoDeliveryController.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesNoDeliveryMapper.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryService.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryServiceImpl.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesNoDeliveryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesNoDeliveryController.java new file mode 100644 index 000000000..c7a9cb80a --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesNoDeliveryController.java @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.product.controller.admin.express; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO; +import cn.iocoder.yudao.module.product.service.express.ShippingTemplatesNoDeliveryService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 物流控制器 + * +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- + */ +@Slf4j +@RestController +@RequestMapping("api/admin/express/shipping/no_delivery") +@Tag(name = "设置 -- 物流 -- 免费") +public class ShippingTemplatesNoDeliveryController { + + @Autowired + private ShippingTemplatesNoDeliveryService shippingTemplatesNoDeliveryService; + + /** + * 根据模板id查询数据 + * @param tempId Integer 模板id + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:free:list')") + @Operation(summary = "根据模板id查询数据") + @RequestMapping(value = "/list", method = RequestMethod.GET) + public CommonResult> getList(@RequestParam Integer tempId){ + return CommonResult.success(shippingTemplatesNoDeliveryService.getListGroup(tempId)); + } + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java new file mode 100644 index 000000000..e9115e619 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesNoDeliveryRespVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.product.controller.admin.express.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 免费模版 Request + * +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("eb_shipping_templates_no_delivery") +@Schema(description="指定不送达地区") +public class ShippingTemplatesNoDeliveryRespVO implements Serializable { + + private static final long serialVersionUID=1L; + + @Schema(description = "城市ID, 多个逗号分割。 全国 all", required = true, example = "1,2,3,4") + @NotNull(message = "请选择城市") + private String cityId; +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesReqVO.java index ebe2aaa10..9f2ac2c6b 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesReqVO.java @@ -55,6 +55,9 @@ public class ShippingTemplatesReqVO implements Serializable { @Schema(description = "指定包邮设置", required = true) private List shippingTemplatesFreeRespVOList; + @Schema(description = "指定不包邮设置", required = true) + private List shippingTemplatesNoDeliveryRespVOS; + @Schema(description = "排序", example = "0") @NotNull(message = "排序数字必须填写") @Min(value = 0, message = "排序最小为0") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java new file mode 100644 index 000000000..c49e064f2 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesNoDeliveryDO.java @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.product.dal.dataobject.express; + +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 免费运费模版 + * +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("eb_shipping_templates_no_delivery") +public class ShippingTemplatesNoDeliveryDO extends TenantBaseDO { + + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 模板ID + */ + private Integer tempId; + + /** + *城市ID + */ + private Integer cityId; + + /** + *省份ID + */ + private Integer province_id; + + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesNoDeliveryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesNoDeliveryMapper.java new file mode 100644 index 000000000..5eca077c6 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesNoDeliveryMapper.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.product.dal.mysql.express; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesNoDeliveryDO; + +import java.util.List; + +/** + * Mapper 接口 + * +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- + */ +public interface ShippingTemplatesNoDeliveryMapper extends BaseMapperX { + + List getList(Integer tempId); + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryService.java new file mode 100644 index 000000000..63e3e3a58 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryService.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.product.service.express; + +import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesNoDeliveryDO; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** +* ShippingTemplatesFreeService 接口 +* +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- +*/ +public interface ShippingTemplatesNoDeliveryService extends IService { + + void saveAll(List shippingTemplatesFreeRespVOList, Integer id); + + List getListGroup(Integer tempId); + + /** + * 根据模板编号、城市ID查询 + * @param tempId 模板编号 + * @param cityId 城市ID + * @return 运费模板 + */ + ShippingTemplatesNoDeliveryDO getByTempIdAndCityId(Integer tempId, Integer cityId); +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryServiceImpl.java new file mode 100644 index 000000000..dc361c5d1 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesNoDeliveryServiceImpl.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.product.service.express; + +import cn.iocoder.yudao.framework.common.util.string.StrUtils; +import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesNoDeliveryDO; +import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesNoDeliveryMapper; +import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; +import cn.iocoder.yudao.module.system.service.ip.AreaService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class ShippingTemplatesNoDeliveryServiceImpl extends ServiceImpl implements ShippingTemplatesNoDeliveryService { + + @Resource + private ShippingTemplatesNoDeliveryMapper shippingTemplatesNoDeliveryMapper; + + @Autowired + private AreaService areaService; + + private List cityIdList; + + /** + * 保存配送区域 + * @param shippingTemplatesNoDeliveryRespVOS List 运费集合 + * @param tempId Integer 运费模板id + * @author Mr.Zhang + * @since 2020-05-20 + */ + @Override + public void saveAll(List shippingTemplatesNoDeliveryRespVOS, Integer tempId) { + ArrayList shippingTemplatesNoDeliveryDOS = new ArrayList<>(); + + for (ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVO : shippingTemplatesNoDeliveryRespVOS) { + if(shippingTemplatesNoDeliveryRespVO.getCityId().equals("all") || shippingTemplatesNoDeliveryRespVO.getCityId().equals("0")){ + cityIdList = getCityIdList(); + }else{ + cityIdList = StrUtils.stringToArray(shippingTemplatesNoDeliveryRespVO.getCityId()); + } + for (Integer cityId: cityIdList) { + ShippingTemplatesNoDeliveryDO shippingTemplatesNoDeliveryDO = new ShippingTemplatesNoDeliveryDO(); + shippingTemplatesNoDeliveryDO.setCityId(cityId); + shippingTemplatesNoDeliveryDO.setTempId(tempId); + shippingTemplatesNoDeliveryDOS.add(shippingTemplatesNoDeliveryDO); + } + } + //批量保存模板数据 + saveBatch(shippingTemplatesNoDeliveryDOS); + } + + /** + * 获取所有城市cityId + * @author Mr.Zhang + * @since 2020-04-16 + * @return List + */ + private List getCityIdList() { + if(this.cityIdList == null || this.cityIdList.size() < 1){ + this.cityIdList = areaService.getAreaTree().stream().map(AreaNodeRespVO::getId).collect(Collectors.toList()); + } + return this.cityIdList; + } + + + /** + * 查询 + * @param tempId Integer 运费模板id + * @return List + */ + @Override + public List getListGroup(Integer tempId) { + return shippingTemplatesNoDeliveryMapper.getList(tempId); + } + + /** + * 根据模板编号、城市ID查询 + * @param tempId 模板编号 + * @param cityId 城市ID + * @return 运费模板 + */ + @Override + public ShippingTemplatesNoDeliveryDO getByTempIdAndCityId(Integer tempId, Integer cityId) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(ShippingTemplatesNoDeliveryDO::getTempId, tempId); + lqw.eq(ShippingTemplatesNoDeliveryDO::getCityId, cityId); + lqw.orderByDesc(ShippingTemplatesNoDeliveryDO::getId); + lqw.last(" limit 1"); + return shippingTemplatesNoDeliveryMapper.selectOne(lqw); + } +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesServiceImpl.java index 7cd4d0039..dfe4d7eb2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesServiceImpl.java @@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesFreeRespVO; -import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesRegionRespVO; -import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesReqVO; -import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesSearchReqVO; +import cn.iocoder.yudao.module.product.controller.admin.express.vo.*; import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesDO; import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -44,6 +41,9 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl shippingTemplatesNoDeliveryRespVOList = request.getShippingTemplatesNoDeliveryRespVOS(); + if(null != shippingTemplatesNoDeliveryRespVOList && shippingTemplatesNoDeliveryRespVOList.size() > 0){ + shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVOList, shippingTemplatesDO.getId()); + } + + return true; } @@ -155,6 +161,10 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl shippingTemplatesNoDeliveryRespVOList = request.getShippingTemplatesNoDeliveryRespVOS(); + if(CollUtil.isNotEmpty(shippingTemplatesNoDeliveryRespVOList)){ + shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVOList, shippingTemplatesDO.getId()); + } return true; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml new file mode 100644 index 000000000..1e2374f80 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesNoDeliveryMapper.xml @@ -0,0 +1,8 @@ + + + + + +