From ae226440a5d6ec4d7489a20e879f8761899c1408 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 15:20:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=B5=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/GlobalErrorCodeConstants.java | 1 + .../common/util/string/StrUtils.java | 38 ++++ .../yudao-module-product-biz/pom.xml | 10 + .../express/ShippingTemplatesController.java | 113 +++++++++++ .../ShippingTemplatesFreeController.java | 50 +++++ .../ShippingTemplatesRegionController.java | 49 +++++ .../vo/ShippingTemplatesFreeRespVO.java | 51 +++++ .../vo/ShippingTemplatesRegionRespVO.java | 60 ++++++ .../express/vo/ShippingTemplatesReqVO.java | 63 ++++++ .../vo/ShippingTemplatesSearchReqVO.java | 33 +++ .../express/ShippingTemplatesDO.java | 67 ++++++ .../express/ShippingTemplatesFreeDO.java | 88 ++++++++ .../express/ShippingTemplatesRegionDO.java | 98 +++++++++ .../express/ShippingTemplatesFreeMapper.java | 24 +++ .../express/ShippingTemplatesMapper.java | 20 ++ .../ShippingTemplatesRegionMapper.java | 24 +++ .../express/ShippingTemplatesFreeService.java | 40 ++++ .../ShippingTemplatesFreeServiceImpl.java | 155 ++++++++++++++ .../ShippingTemplatesRegionService.java | 41 ++++ .../ShippingTemplatesRegionServiceImpl.java | 168 +++++++++++++++ .../express/ShippingTemplatesService.java | 47 +++++ .../express/ShippingTemplatesServiceImpl.java | 192 ++++++++++++++++++ .../express/ShippingTemplatesFreeMapper.xml | 8 + .../express/ShippingTemplatesMapper.xml | 5 + .../express/ShippingTemplatesRegionMapper.xml | 8 + .../module/system/service/ip/AreaService.java | 11 + .../system/service/ip/AreaServiceImpl.java | 23 +++ 27 files changed, 1487 insertions(+) create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesController.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesFreeController.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesRegionController.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesReqVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesSearchReqVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesDO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesFreeDO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesRegionDO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesFreeMapper.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesMapper.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesRegionMapper.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeService.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeServiceImpl.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionService.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionServiceImpl.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesService.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesServiceImpl.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesMapper.xml create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaService.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaServiceImpl.java diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java index 61533de60..1c136d568 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java @@ -34,6 +34,7 @@ public interface GlobalErrorCodeConstants { // ========== 自定义错误段 ========== ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求 ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式,禁止写操作"); + ErrorCode OPERATION_ERROR = new ErrorCode(902, "数据操作失败"); ErrorCode UNKNOWN = new ErrorCode(999, "未知错误"); diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java index 88ba22d87..71288705a 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java @@ -2,7 +2,9 @@ package cn.iocoder.yudao.framework.common.util.string; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; +import org.apache.commons.lang3.StringUtils; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -45,4 +47,40 @@ public class StrUtils { return Arrays.stream(longs).boxed().collect(Collectors.toList()); } + /** + * 字符串分割,转化为数组 + * @param str 字符串 + * @author Mr.Zhang + * @since 2020-04-22 + * @return List + */ + public static List stringToArray(String str){ + return stringToArrayByRegex(str, ","); + } + + /** + * 字符串分割,转化为数组 + * @param str 字符串 + * @param regex 分隔符有 + * @author Mr.Zhang + * @since 2020-04-22 + * @return List + */ + public static List stringToArrayByRegex(String str, String regex ){ + List list = new ArrayList<>(); + if (str.contains(regex)){ + + String[] split = str.split(regex); + + for (String value : split) { + if(!StringUtils.isBlank(value)){ + list.add(Integer.parseInt(value.trim())); + } + } + }else { + list.add(Integer.parseInt(str)); + } + return list; + } + } diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml index 42fbf3c4c..36643aefa 100644 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ b/yudao-module-mall/yudao-module-product-biz/pom.xml @@ -73,6 +73,16 @@ com.github.pagehelper pagehelper-spring-boot-starter + + org.hibernate.validator + hibernate-validator + + + cn.iocoder.boot + yudao-module-system-biz + 1.7.2-snapshot + compile + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesController.java new file mode 100644 index 000000000..3d37bc078 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesController.java @@ -0,0 +1,113 @@ +package cn.iocoder.yudao.module.product.controller.admin.express; + +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.dal.dataobject.express.ShippingTemplatesDO; +import cn.iocoder.yudao.module.product.service.express.ShippingTemplatesService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +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.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 物流-模板控制器 + * +---------------------------------------------------------------------- + * | 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/templates") +@Tag(name = "设置 -- 物流 -- 模板") +public class ShippingTemplatesController { + + @Autowired + private ShippingTemplatesService shippingTemplatesService; + + /** + * 分页显示 + * @param request 搜索条件 + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:list')") + @Operation(summary = "分页列表") + @RequestMapping(value = "/list", method = RequestMethod.GET) + public CommonResult> getList(@Validated ShippingTemplatesSearchReqVO request){ + PageResult shippingTemplatesCommonPage = shippingTemplatesService.getList(request); + return CommonResult.success(shippingTemplatesCommonPage); + } + + /** + * 新增 + * @param request 新增参数 + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:save')") + @Operation(summary = "新增") + @RequestMapping(value = "/save", method = RequestMethod.POST) + public CommonResult save(@RequestBody @Validated ShippingTemplatesReqVO request){ + if (shippingTemplatesService.create(request)) { + return success("新增运费模板成功"); + } + return CommonResult.error(GlobalErrorCodeConstants.OPERATION_ERROR.getCode(),"新增运费模板失败"); + } + + /** + * 删除 + * @param id Integer + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:delete')") + @Operation(summary = "删除") + @RequestMapping(value = "/delete", method = RequestMethod.GET) + @Parameter(name="id", description="模板ID", required = true) + public CommonResult delete(@RequestParam(value = "id") Integer id){ + if(shippingTemplatesService.remove(id)){ + return success("删除成功"); + }else{ + return CommonResult.error(GlobalErrorCodeConstants.OPERATION_ERROR.getCode(),"删除失败"); + } + } + + /** + * 修改 + * @param id integer id + * @param request ShippingTemplatesRequest 修改参数 + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:update')") + @Operation(summary = "修改") + @RequestMapping(value = "/update", method = RequestMethod.POST) + public CommonResult update(@RequestParam Integer id, @RequestBody @Validated ShippingTemplatesReqVO request){ + if (shippingTemplatesService.update(id, request)) { + return CommonResult.success("修改成功"); + } + return CommonResult.error(GlobalErrorCodeConstants.OPERATION_ERROR.getCode(),"修改失败"); + } + + /** + * 查询信息 + * @param id Integer + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:info')") + @Operation(summary = "详情") + @RequestMapping(value = "/info", method = RequestMethod.GET) + @Parameter(name="id", description="模板ID", required = true) + public CommonResult info(@RequestParam(value = "id") Integer id){ + return CommonResult.success(shippingTemplatesService.getInfo(id)); + } +} + + + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesFreeController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesFreeController.java new file mode 100644 index 000000000..e7ce82a96 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesFreeController.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.ShippingTemplatesFreeRespVO; +import cn.iocoder.yudao.module.product.service.express.ShippingTemplatesFreeService; +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/free") +@Tag(name = "设置 -- 物流 -- 免费") +public class ShippingTemplatesFreeController { + + @Autowired + private ShippingTemplatesFreeService shippingTemplatesFreeService; + + /** + * 根据模板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(shippingTemplatesFreeService.getListGroup(tempId)); + } + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesRegionController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesRegionController.java new file mode 100644 index 000000000..40c49da09 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/ShippingTemplatesRegionController.java @@ -0,0 +1,49 @@ +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.ShippingTemplatesRegionRespVO; +import cn.iocoder.yudao.module.product.service.express.ShippingTemplatesRegionService; +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/region") +@Tag(name = "设置 -- 物流 -- 付费") +public class ShippingTemplatesRegionController { + + @Autowired + private ShippingTemplatesRegionService shippingTemplatesRegionService; + + /** + * 根据模板id查询数据 + * @param tempId Integer 模板id + */ + @PreAuthorize("hasAuthority('admin:shipping:templates:region:list')") + @Operation(summary = "根据模板id查询数据") + @RequestMapping(value = "/list", method = RequestMethod.GET) + public CommonResult> getList(@RequestParam Integer tempId){ + return CommonResult.success(shippingTemplatesRegionService.getListGroup(tempId)); + } +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java new file mode 100644 index 000000000..dd71eb8d6 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesFreeRespVO.java @@ -0,0 +1,51 @@ +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.DecimalMin; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 免费模版 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_free") +@Schema(description="免费") +public class ShippingTemplatesFreeRespVO implements Serializable { + + private static final long serialVersionUID=1L; + + @Schema(description = "城市ID, 多个逗号分割。 全国 all", required = true, example = "1,2,3,4") + @NotNull(message = "请选择城市") + private String cityId; + + @Schema(description = "城市名称描述") + private String title; + + @Schema(description = "包邮件数", required = true, example = "1") +// @Min(value = 1, message = "请填写包邮件数") + @DecimalMin(value = "0.1", message = "包邮不能低于0.1") + private BigDecimal number; + + @Schema(description = "包邮金额", required = true, example = "0.1") + @NotNull(message = "请填写包邮金额") + @DecimalMin(value = "0", message = "包邮金额不能低于0") + private BigDecimal price; +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java new file mode 100644 index 000000000..53cc84021 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesRegionRespVO.java @@ -0,0 +1,60 @@ +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.DecimalMin; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 模板区域Reuqest + * +---------------------------------------------------------------------- + * | 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_region") +@Schema(description="付费") +public class ShippingTemplatesRegionRespVO implements Serializable { + + private static final long serialVersionUID=1L; + + @Schema(description = "城市ID, 多个逗号分割。全国 all", required = true, example = "1,2,3,4") + @NotNull(message = "请选择城市") + private String cityId; + + @Schema(description = "城市名称描述") + private String title; + + @Schema(description = "首件", required = true, example = "0.1") + @DecimalMin(value = "0.1", message = "首件金额不能低于0.1") + private BigDecimal first; + + @Schema(description = "首件运费", required = true, example = "0.1") + @DecimalMin(value = "0.1", message = "首件运费金额不能低于0.1") + private BigDecimal firstPrice; + + @Schema(description = "续件", required = true, example = "0.1") + @DecimalMin(value = "0.1", message = "续件不能低于0.1") + private BigDecimal renewal; + + @Schema(description = "续件运费", required = true, example = "0.1") + @DecimalMin(value = "0.1", message = "续件运费金额不能低于0.1") + private BigDecimal renewalPrice; + + @Schema(description = "分组唯一值") + private String uniqid; +} 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 new file mode 100644 index 000000000..ebe2aaa10 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesReqVO.java @@ -0,0 +1,63 @@ +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 org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * 模版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") +@Schema(description="模板") +public class ShippingTemplatesReqVO implements Serializable { + + private static final long serialVersionUID=1L; + + @Schema(description = "模板名称", required = true) + @NotBlank(message = "模板名称必须填写") + @Length(max = 200, message = "模板名称不能超过200个字符") + private String name; + + @Schema(description = "计费方式 1(按件数), 2(按重量),3(按体积)", example = "1", required = true) + @NotNull(message = "计费方式必须选择") + @Range(min = 1, max = 3, message = "计费方式选择区间 1(按件数), 2(按重量),3(按体积)") + private Integer type; + + @Schema(description = "配送区域及运费", required = true) + private List shippingTemplatesRegionRespVOList; + + @Schema(description = "指定包邮", example = "1", required = true) + @NotNull(message = "指定包邮必须选择") + private Boolean appoint; + + @Schema(description = "指定包邮设置", required = true) + private List shippingTemplatesFreeRespVOList; + + @Schema(description = "排序", example = "0") + @NotNull(message = "排序数字必须填写") + @Min(value = 0, message = "排序最小为0") + private Integer sort; + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesSearchReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesSearchReqVO.java new file mode 100644 index 000000000..861406fc9 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/express/vo/ShippingTemplatesSearchReqVO.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.product.controller.admin.express.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 模板搜索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") +@Schema(description="模板搜索") +public class ShippingTemplatesSearchReqVO extends PageParam { + + private static final long serialVersionUID=1L; + + @Schema(description = "模板名称") + private String keywords; +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesDO.java new file mode 100644 index 000000000..3f13e0570 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesDO.java @@ -0,0 +1,67 @@ +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; + +import java.util.Date; + +/** + * 运费模版对象 + * +---------------------------------------------------------------------- + * | 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") +public class ShippingTemplatesDO extends TenantBaseDO { + + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + *模板名称 + */ + private String name; + + /** + *计费方式 + */ + private Integer type; + + /** + *指定包邮 + */ + private Boolean appoint; + + /** + *排序 + */ + private Integer sort; + + /** + *创建时间 + */ + private Date createTime; + + /** + *修改时间 + */ + private Date updateTime; + + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesFreeDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesFreeDO.java new file mode 100644 index 000000000..929b6bcb0 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesFreeDO.java @@ -0,0 +1,88 @@ +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; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 免费运费模版 + * +---------------------------------------------------------------------- + * | 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_free") +public class ShippingTemplatesFreeDO 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; + + /** + *描述 + */ + private String title; + + /** + *包邮件数 + */ + private BigDecimal number; + + /** + *包邮金额 + */ + private BigDecimal price; + + /** + *计费方式 + */ + private Integer type; + + /** + *分组唯一值 + */ + private String uniqid; + + /** + *是否无效 + */ + private Boolean status; + + /** + *创建时间 + */ + private Date createTime; + + /** + *修改时间 + */ + private Date updateTime; + + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesRegionDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesRegionDO.java new file mode 100644 index 000000000..7fcc9e268 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/express/ShippingTemplatesRegionDO.java @@ -0,0 +1,98 @@ +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; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 运费模版区域 + * +---------------------------------------------------------------------- + * | 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_region") +public class ShippingTemplatesRegionDO 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; + + /** + *描述 + */ + private String title; + + /** + *首件 + */ + private BigDecimal first; + + /** + *首件运费 + */ + private BigDecimal firstPrice; + + /** + *续件 + */ + private BigDecimal renewal; + + /** + *续件运费 + */ + private BigDecimal renewalPrice; + + /** + *计费方式 1按件数 2按重量 3按体积 + */ + private Integer type; + + /** + *分组唯一值 + */ + private String uniqid; + + /** + *是否无效 + */ + private Boolean status; + + /** + *创建时间 + */ + private Date createTime; + + /** + *修改时间 + */ + private Date updateTime; + + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesFreeMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesFreeMapper.java new file mode 100644 index 000000000..9c081fd10 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesFreeMapper.java @@ -0,0 +1,24 @@ +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.ShippingTemplatesFreeRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesFreeDO; + +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 ShippingTemplatesFreeMapper extends BaseMapperX { + + List getListGroup(Integer tempId); +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesMapper.java new file mode 100644 index 000000000..655ecfd4a --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesMapper.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.product.dal.mysql.express; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesDO; + +/** + * Mapper 接口 + * +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- + */ +public interface ShippingTemplatesMapper extends BaseMapperX { + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesRegionMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesRegionMapper.java new file mode 100644 index 000000000..03daafa81 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/express/ShippingTemplatesRegionMapper.java @@ -0,0 +1,24 @@ +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.ShippingTemplatesRegionRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesRegionDO; + +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 ShippingTemplatesRegionMapper extends BaseMapperX { + + List getListGroup(Integer tempId); +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeService.java new file mode 100644 index 000000000..73bb55af1 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeService.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.product.service.express; + +import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesFreeRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesFreeDO; +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 ShippingTemplatesFreeService extends IService { + + void saveAll(List shippingTemplatesFreeRespVOList, Integer type, Integer id); + + List getListGroup(Integer tempId); + + /** + * 删除 + * @param tempId 运费模板id + */ + Boolean delete(Integer tempId); + + /** + * 根据模板编号、城市ID查询 + * @param tempId 模板编号 + * @param cityId 城市ID + * @return 运费模板 + */ + ShippingTemplatesFreeDO 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/ShippingTemplatesFreeServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeServiceImpl.java new file mode 100644 index 000000000..a7e6a8274 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesFreeServiceImpl.java @@ -0,0 +1,155 @@ +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.ShippingTemplatesFreeRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesFreeDO; +import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesFreeMapper; +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.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** +* ShippingTemplatesFreeServiceImpl 接口实现 +* +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- +*/ +@Service +public class ShippingTemplatesFreeServiceImpl extends ServiceImpl implements ShippingTemplatesFreeService { + + @Resource + private ShippingTemplatesFreeMapper dao; + + @Autowired + private AreaService areaService; + + private List cityIdList; + + /** + * 保存配送区域 + * @param shippingTemplatesFreeRespVOList List 运费集合 + * @param type Integer 计费方式 + * @param tempId Integer 运费模板id + * @author Mr.Zhang + * @since 2020-05-20 + */ + @Async + @Override + public void saveAll(List shippingTemplatesFreeRespVOList, Integer type, Integer tempId) { + + ArrayList shippingTemplatesFreesListDO = new ArrayList<>(); + + //把目前模板下的所有数据标记为无效 + updateStatus(tempId); + + for (ShippingTemplatesFreeRespVO shippingTemplatesFreeRespVO : shippingTemplatesFreeRespVOList) { + String uniqueKey = DigestUtils.md5Hex(shippingTemplatesFreeRespVO.toString()); + if(shippingTemplatesFreeRespVO.getCityId().equals("all") || shippingTemplatesFreeRespVO.getCityId().equals("0")){ + cityIdList = getCityIdList(); + }else{ + cityIdList = StrUtils.stringToArray(shippingTemplatesFreeRespVO.getCityId()); + } + for (Integer cityId: cityIdList) { + ShippingTemplatesFreeDO shippingTemplatesFreeDO = new ShippingTemplatesFreeDO(); + shippingTemplatesFreeDO.setCityId(cityId); + shippingTemplatesFreeDO.setTitle(shippingTemplatesFreeRespVO.getTitle()); + shippingTemplatesFreeDO.setUniqid(uniqueKey); + shippingTemplatesFreeDO.setTempId(tempId); + shippingTemplatesFreeDO.setType(type); + shippingTemplatesFreeDO.setNumber(shippingTemplatesFreeRespVO.getNumber()); + shippingTemplatesFreeDO.setPrice(shippingTemplatesFreeRespVO.getPrice()); + shippingTemplatesFreeDO.setStatus(true); + shippingTemplatesFreesListDO.add(shippingTemplatesFreeDO); + } + } + //批量保存模板数据 + saveBatch(shippingTemplatesFreesListDO); + + //删除模板下的无效数据 + delete(tempId); + } + + /** + * 获取所有城市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 + * @author Mr.Zhang + * @since 2020-05-20 + */ + private void updateStatus(Integer tempId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(ShippingTemplatesFreeDO::getTempId, tempId); + + ShippingTemplatesFreeDO shippingTemplatesFreeDO = new ShippingTemplatesFreeDO(); + shippingTemplatesFreeDO.setStatus(false); + update(shippingTemplatesFreeDO, lambdaQueryWrapper); + } + + /** + * 删除模板下的无效数据 + * @param tempId Integer 运费模板id + */ + @Override + public Boolean delete(Integer tempId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(ShippingTemplatesFreeDO::getTempId, tempId); + lambdaQueryWrapper.eq(ShippingTemplatesFreeDO::getStatus, false); + return dao.delete(lambdaQueryWrapper) > 0; + } + + /** + * 根据模板编号、城市ID查询 + * @param tempId 模板编号 + * @param cityId 城市ID + * @return 运费模板 + */ + @Override + public ShippingTemplatesFreeDO getByTempIdAndCityId(Integer tempId, Integer cityId) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(ShippingTemplatesFreeDO::getTempId, tempId); + lqw.eq(ShippingTemplatesFreeDO::getCityId, cityId); + lqw.eq(ShippingTemplatesFreeDO::getStatus, true); + lqw.orderByDesc(ShippingTemplatesFreeDO::getId); + lqw.last(" limit 1"); + return dao.selectOne(lqw); + } + + /** + * 分组查询 + * @param tempId Integer 运费模板id + * @return List + */ + @Override + public List getListGroup(Integer tempId) { + return dao.getListGroup(tempId); + } +} + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionService.java new file mode 100644 index 000000000..e6f20488f --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionService.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.product.service.express; + +import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesRegionRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesRegionDO; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** +* ShippingTemplatesRegionService 接口 +* +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- +*/ +public interface ShippingTemplatesRegionService extends IService { + + void saveAll(List shippingTemplatesRegionRespVOList, Integer type, Integer id); + + List getListGroup(Integer tempId); + + /** + * 删除 + * @param tempId 运费模板id + * @return Boolean + */ + Boolean delete(Integer tempId); + + /** + * 根据模板编号、城市ID查询 + * @param tempId 模板编号 + * @param cityId 城市ID + * @return 运费模板 + */ + ShippingTemplatesRegionDO 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/ShippingTemplatesRegionServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionServiceImpl.java new file mode 100644 index 000000000..dadcca922 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesRegionServiceImpl.java @@ -0,0 +1,168 @@ +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.ShippingTemplatesRegionRespVO; +import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesRegionDO; +import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesRegionMapper; +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.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** +* ShippingTemplatesRegionServiceImpl 接口实现 +* +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- +*/ +@Service +public class ShippingTemplatesRegionServiceImpl extends ServiceImpl implements ShippingTemplatesRegionService { + + @Resource + private ShippingTemplatesRegionMapper dao; + + @Autowired + private AreaService areaService; + + private List cityIdList; + + @Override + public List listByIds(Collection idList) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.in(ShippingTemplatesRegionDO::getTempId, idList); + lqw.orderByAsc(ShippingTemplatesRegionDO::getCityId); + return dao.selectList(lqw); + } + + /** + * 保存配送区域及运费 + * @param shippingTemplatesRegionRespVOList List 运费集合 + * @param type Integer 计费方式 + * @param tempId Integer 运费模板id + * @author Mr.Zhang + * @since 2020-05-20 + */ + @Async + @Override + public void saveAll(List shippingTemplatesRegionRespVOList, Integer type, Integer tempId) { + ArrayList shippingTemplatesRegionDOList = new ArrayList<>(); + + //把目前模板下的所有数据标记为无效 + updateStatus(tempId); + + for (ShippingTemplatesRegionRespVO shippingTemplatesRegionRespVO : shippingTemplatesRegionRespVOList) { + String uniqueKey = DigestUtils.md5Hex(shippingTemplatesRegionRespVO.toString()); + + if(shippingTemplatesRegionRespVO.getCityId().equals("all") || shippingTemplatesRegionRespVO.getCityId().equals("0")){ + cityIdList = getCityIdList(); + }else{ + cityIdList = StrUtils.stringToArray(shippingTemplatesRegionRespVO.getCityId()); + } + for (Integer cityId: cityIdList) { + ShippingTemplatesRegionDO shippingTemplatesRegionDO = new ShippingTemplatesRegionDO(); + shippingTemplatesRegionDO.setCityId(cityId); + shippingTemplatesRegionDO.setTitle(shippingTemplatesRegionRespVO.getTitle()); + shippingTemplatesRegionDO.setUniqid(uniqueKey); + shippingTemplatesRegionDO.setRenewal(shippingTemplatesRegionRespVO.getRenewal()); + shippingTemplatesRegionDO.setRenewalPrice(shippingTemplatesRegionRespVO.getRenewalPrice()); + shippingTemplatesRegionDO.setFirst(shippingTemplatesRegionRespVO.getFirst()); + shippingTemplatesRegionDO.setFirstPrice(shippingTemplatesRegionRespVO.getFirstPrice()); + shippingTemplatesRegionDO.setTempId(tempId); + shippingTemplatesRegionDO.setType(type); + shippingTemplatesRegionDO.setStatus(true); + shippingTemplatesRegionDOList.add(shippingTemplatesRegionDO); + } + } + //批量保存模板数据 + saveBatch(shippingTemplatesRegionDOList); + + //删除模板下的无效数据 + delete(tempId); + } + + /** + * 获取所有城市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 + * @author Mr.Zhang + * @since 2020-05-20 + */ + private void updateStatus(Integer tempId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(ShippingTemplatesRegionDO::getTempId, tempId); + + ShippingTemplatesRegionDO shippingTemplatesRegionDO = new ShippingTemplatesRegionDO(); + shippingTemplatesRegionDO.setStatus(false); + update(shippingTemplatesRegionDO, lambdaQueryWrapper); + } + + /** + * 删除模板下的无效数据 + * @param tempId Integer 运费模板id + * @return Boolean + */ + @Override + public Boolean delete(Integer tempId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(ShippingTemplatesRegionDO::getTempId, tempId); + lambdaQueryWrapper.eq(ShippingTemplatesRegionDO::getStatus, false); + return dao.delete(lambdaQueryWrapper) > 0; + } + + /** + * 根据模板编号、城市ID查询 + * @param tempId 模板编号 + * @param cityId 城市ID + * @return 运费模板 + */ + @Override + public ShippingTemplatesRegionDO getByTempIdAndCityId(Integer tempId, Integer cityId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(ShippingTemplatesRegionDO::getTempId, tempId); + lambdaQueryWrapper.eq(ShippingTemplatesRegionDO::getCityId, cityId); + lambdaQueryWrapper.eq(ShippingTemplatesRegionDO::getStatus, true); + lambdaQueryWrapper.orderByDesc(ShippingTemplatesRegionDO::getId); + lambdaQueryWrapper.last(" limit 1"); + return dao.selectOne(lambdaQueryWrapper); + } + + /** + * 分组查询 + * @param tempId Integer 运费模板id + * @return List + */ + @Override + public List getListGroup(Integer tempId) { + return dao.getListGroup(tempId); + } +} + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesService.java new file mode 100644 index 000000000..7b8b5bea8 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesService.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.product.service.express; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.dal.dataobject.express.ShippingTemplatesDO; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* ShippingTemplatesService 接口 +* +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- +*/ +public interface ShippingTemplatesService extends IService { + + PageResult getList(ShippingTemplatesSearchReqVO request); + + /** + * 新增运费模板 + * @param request 请求参数 + * @return 新增结果 + */ + Boolean create(ShippingTemplatesReqVO request); + + Boolean update(Integer id, ShippingTemplatesReqVO request); + + /** + * 删除模板 + * @param id 模板id + * @return Boolean + */ + Boolean remove(Integer id); + + /** + * 获取模板信息 + * @param id 模板id + * @return ShippingTemplates + */ + ShippingTemplatesDO getInfo(Integer id); +} 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 new file mode 100644 index 000000000..7cd4d0039 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/express/ShippingTemplatesServiceImpl.java @@ -0,0 +1,192 @@ +package cn.iocoder.yudao.module.product.service.express; + +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.dal.dataobject.express.ShippingTemplatesDO; +import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; + +import javax.annotation.Resource; +import java.util.List; + +/** +* ShippingTemplatesServiceImpl 接口实现 +* +---------------------------------------------------------------------- + * | CRMEB [ CRMEB赋能开发者,助力企业发展 ] + * +---------------------------------------------------------------------- + * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 + * +---------------------------------------------------------------------- + * | Author: CRMEB Team + * +---------------------------------------------------------------------- +*/ +@Service +public class ShippingTemplatesServiceImpl extends ServiceImpl implements ShippingTemplatesService { + + @Resource + private ShippingTemplatesMapper dao; + + @Autowired + private ShippingTemplatesRegionService shippingTemplatesRegionService; + + @Autowired + private ShippingTemplatesFreeService shippingTemplatesFreeService; + + @Autowired + private TransactionTemplate transactionTemplate; + + /** + * 列表 + * @param request 请求参数 + * @author Mr.Zhang + * @since 2020-04-17 + * @return List + */ + @Override + public PageResult getList(ShippingTemplatesSearchReqVO request) { + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + if(!StringUtils.isBlank(request.getKeywords())){ + lambdaQueryWrapper.like(ShippingTemplatesDO::getName, request.getKeywords()); + } + lambdaQueryWrapper.orderByDesc(ShippingTemplatesDO::getSort).orderByDesc(ShippingTemplatesDO::getId); + + return dao.selectPage(request, lambdaQueryWrapper); + } + + /** + * 新增 + * @param request 新增参数 + * @author Mr.Zhang + * @since 2020-04-17 + * @return bool + */ + @Override + public Boolean create(ShippingTemplatesReqVO request) { + // 判断模板名称是否重复 + if (isExistName(request.getName())) { + throw new ServiceException("模板名称已存在,请更换模板名称!"); + } + List shippingTemplatesRegionRespVOList = request.getShippingTemplatesRegionRespVOList(); + if (CollUtil.isEmpty(shippingTemplatesRegionRespVOList)) { + throw new ServiceException("区域运费最少需要一条默认的全国区域"); + } + + ShippingTemplatesDO shippingTemplatesDO = new ShippingTemplatesDO(); + shippingTemplatesDO.setName(request.getName()); + shippingTemplatesDO.setSort(request.getSort()); + shippingTemplatesDO.setType(request.getType()); + shippingTemplatesDO.setAppoint(request.getAppoint()); + + save(shippingTemplatesDO); + + //区域运费 + shippingTemplatesRegionService.saveAll(shippingTemplatesRegionRespVOList, request.getType(), shippingTemplatesDO.getId()); + + + List shippingTemplatesFreeRespVOList = request.getShippingTemplatesFreeRespVOList(); + if(null != shippingTemplatesFreeRespVOList && shippingTemplatesFreeRespVOList.size() > 0 && request.getAppoint()){ + shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRespVOList, request.getType(), shippingTemplatesDO.getId()); + } + + return true; + } + + /** + * 根据模板名称获取模板 + * @param name 模板名称 + * @return ShippingTemplates + */ + private ShippingTemplatesDO getByName(String name) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.in(ShippingTemplatesDO::getName, name); + return dao.selectOne(lqw); + } + + /** + * 是否存在模板名称 + */ + private Boolean isExistName(String name) { + ShippingTemplatesDO templates = getByName(name); + if (ObjectUtil.isNull(templates)) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + /** + * 新增 + * @param id Integer 模板id + * @param request ShippingTemplatesRequest 新增参数 + */ + @Override + public Boolean update(Integer id, ShippingTemplatesReqVO request) { + ShippingTemplatesDO shippingTemplatesDO = new ShippingTemplatesDO(); + shippingTemplatesDO.setId(id); + shippingTemplatesDO.setName(request.getName()); + shippingTemplatesDO.setSort(request.getSort()); + shippingTemplatesDO.setType(request.getType()); + shippingTemplatesDO.setAppoint(request.getAppoint()); + + + updateById(shippingTemplatesDO); + + //区域运费 + List shippingTemplatesRegionRespVOList = request.getShippingTemplatesRegionRespVOList(); + + if(shippingTemplatesRegionRespVOList.size() < 1){ + throw new ServiceException("请设置区域配送信息!"); + } + shippingTemplatesRegionService.saveAll(shippingTemplatesRegionRespVOList, request.getType(), shippingTemplatesDO.getId()); + + List shippingTemplatesFreeRespVOList = request.getShippingTemplatesFreeRespVOList(); + if(CollUtil.isNotEmpty(shippingTemplatesFreeRespVOList) && request.getAppoint()){ + shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRespVOList, request.getType(), shippingTemplatesDO.getId()); + } + + return true; + } + + /** + * 删除 + * @param id Integer + * @return boolean + */ + @Override + public Boolean remove(Integer id) { + return transactionTemplate.execute(e -> { + shippingTemplatesRegionService.delete(id); + shippingTemplatesFreeService.delete(id); + removeById(id); + return Boolean.TRUE; + }); + } + + /** + * 获取模板信息 + * @param id 模板id + * @return ShippingTemplates + */ + @Override + public ShippingTemplatesDO getInfo(Integer id) { + ShippingTemplatesDO template = getById(id); + if (ObjectUtil.isNull(template)) { + throw new ServiceException("模板不存在"); + } + return template; + } + +} + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml new file mode 100644 index 000000000..d8367e5e2 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesFreeMapper.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesMapper.xml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesMapper.xml new file mode 100644 index 000000000..743e3d994 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml new file mode 100644 index 000000000..1e7c7d4a7 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/resources/mapper/express/ShippingTemplatesRegionMapper.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaService.java new file mode 100644 index 000000000..3dca50d31 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaService.java @@ -0,0 +1,11 @@ +package cn.iocoder.yudao.module.system.service.ip; + +import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; + +import java.util.List; + +public interface AreaService { + + List getAreaTree(); + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaServiceImpl.java new file mode 100644 index 000000000..bf2ab8a9a --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/ip/AreaServiceImpl.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.system.service.ip; + +import cn.hutool.core.lang.Assert; +import cn.iocoder.yudao.framework.ip.core.Area; +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; +import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; +import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; + +import java.util.List; + +public class AreaServiceImpl implements AreaService{ + + /** + * 获取地区树 + * @return + */ + @Override + public List getAreaTree() { + Area area = AreaUtils.getArea(Area.ID_CHINA); + Assert.notNull(area, "获取不到中国"); + return AreaConvert.INSTANCE.convertList(area.getChildren()); + } +}