Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product_new
commit
d084a87258
|
@ -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, "未知错误");
|
||||
|
||||
|
|
|
@ -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<Integer>
|
||||
*/
|
||||
public static List<Integer> stringToArray(String str){
|
||||
return stringToArrayByRegex(str, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串分割,转化为数组
|
||||
* @param str 字符串
|
||||
* @param regex 分隔符有
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-22
|
||||
* @return List<Integer>
|
||||
*/
|
||||
public static List<Integer> stringToArrayByRegex(String str, String regex ){
|
||||
List<Integer> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -73,6 +73,16 @@
|
|||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-system-biz</artifactId>
|
||||
<version>1.7.2-snapshot</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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<PageResult<ShippingTemplatesDO>> getList(@Validated ShippingTemplatesSearchReqVO request){
|
||||
PageResult<ShippingTemplatesDO> 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<String> 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<String> 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<String> 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<ShippingTemplatesDO> info(@RequestParam(value = "id") Integer id){
|
||||
return CommonResult.success(shippingTemplatesService.getInfo(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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<List<ShippingTemplatesFreeRespVO>> getList(@RequestParam Integer tempId){
|
||||
return CommonResult.success(shippingTemplatesFreeService.getListGroup(tempId));
|
||||
}
|
||||
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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<List<ShippingTemplatesRegionRespVO>> getList(@RequestParam Integer tempId){
|
||||
return CommonResult.success(shippingTemplatesRegionService.getListGroup(tempId));
|
||||
}
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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;
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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;
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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<ShippingTemplatesRegionRespVO> shippingTemplatesRegionRespVOList;
|
||||
|
||||
@Schema(description = "指定包邮", example = "1", required = true)
|
||||
@NotNull(message = "指定包邮必须选择")
|
||||
private Boolean appoint;
|
||||
|
||||
@Schema(description = "指定包邮设置", required = true)
|
||||
private List<ShippingTemplatesFreeRespVO> shippingTemplatesFreeRespVOList;
|
||||
|
||||
@Schema(description = "排序", example = "0")
|
||||
@NotNull(message = "排序数字必须填写")
|
||||
@Min(value = 0, message = "排序最小为0")
|
||||
private Integer sort;
|
||||
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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;
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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;
|
||||
|
||||
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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;
|
||||
|
||||
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@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;
|
||||
|
||||
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesFreeMapper extends BaseMapperX<ShippingTemplatesFreeDO> {
|
||||
|
||||
List<ShippingTemplatesFreeRespVO> getListGroup(Integer tempId);
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesMapper extends BaseMapperX<ShippingTemplatesDO> {
|
||||
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesRegionMapper extends BaseMapperX<ShippingTemplatesRegionDO> {
|
||||
|
||||
List<ShippingTemplatesRegionRespVO> getListGroup(Integer tempId);
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesFreeService extends IService<ShippingTemplatesFreeDO> {
|
||||
|
||||
void saveAll(List<ShippingTemplatesFreeRespVO> shippingTemplatesFreeRespVOList, Integer type, Integer id);
|
||||
|
||||
List<ShippingTemplatesFreeRespVO> getListGroup(Integer tempId);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param tempId 运费模板id
|
||||
*/
|
||||
Boolean delete(Integer tempId);
|
||||
|
||||
/**
|
||||
* 根据模板编号、城市ID查询
|
||||
* @param tempId 模板编号
|
||||
* @param cityId 城市ID
|
||||
* @return 运费模板
|
||||
*/
|
||||
ShippingTemplatesFreeDO getByTempIdAndCityId(Integer tempId, Integer cityId);
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class ShippingTemplatesFreeServiceImpl extends ServiceImpl<ShippingTemplatesFreeMapper, ShippingTemplatesFreeDO> implements ShippingTemplatesFreeService {
|
||||
|
||||
@Resource
|
||||
private ShippingTemplatesFreeMapper dao;
|
||||
|
||||
@Autowired
|
||||
private AreaService areaService;
|
||||
|
||||
private List<Integer> cityIdList;
|
||||
|
||||
/**
|
||||
* 保存配送区域
|
||||
* @param shippingTemplatesFreeRespVOList List<ShippingTemplatesFreeRequest> 运费集合
|
||||
* @param type Integer 计费方式
|
||||
* @param tempId Integer 运费模板id
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-20
|
||||
*/
|
||||
@Async
|
||||
@Override
|
||||
public void saveAll(List<ShippingTemplatesFreeRespVO> shippingTemplatesFreeRespVOList, Integer type, Integer tempId) {
|
||||
|
||||
ArrayList<ShippingTemplatesFreeDO> 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<Integer>
|
||||
*/
|
||||
private List<Integer> 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<ShippingTemplatesFreeDO> 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<ShippingTemplatesFreeDO> 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<ShippingTemplatesFreeDO> 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<ShippingTemplatesFreeRequest>
|
||||
*/
|
||||
@Override
|
||||
public List<ShippingTemplatesFreeRespVO> getListGroup(Integer tempId) {
|
||||
return dao.getListGroup(tempId);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesRegionService extends IService<ShippingTemplatesRegionDO> {
|
||||
|
||||
void saveAll(List<ShippingTemplatesRegionRespVO> shippingTemplatesRegionRespVOList, Integer type, Integer id);
|
||||
|
||||
List<ShippingTemplatesRegionRespVO> 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);
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class ShippingTemplatesRegionServiceImpl extends ServiceImpl<ShippingTemplatesRegionMapper, ShippingTemplatesRegionDO> implements ShippingTemplatesRegionService {
|
||||
|
||||
@Resource
|
||||
private ShippingTemplatesRegionMapper dao;
|
||||
|
||||
@Autowired
|
||||
private AreaService areaService;
|
||||
|
||||
private List<Integer> cityIdList;
|
||||
|
||||
@Override
|
||||
public List<ShippingTemplatesRegionDO> listByIds(Collection<? extends Serializable> idList) {
|
||||
LambdaQueryWrapper<ShippingTemplatesRegionDO> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.in(ShippingTemplatesRegionDO::getTempId, idList);
|
||||
lqw.orderByAsc(ShippingTemplatesRegionDO::getCityId);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配送区域及运费
|
||||
* @param shippingTemplatesRegionRespVOList List<ShippingTemplatesRegionRequest> 运费集合
|
||||
* @param type Integer 计费方式
|
||||
* @param tempId Integer 运费模板id
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-20
|
||||
*/
|
||||
@Async
|
||||
@Override
|
||||
public void saveAll(List<ShippingTemplatesRegionRespVO> shippingTemplatesRegionRespVOList, Integer type, Integer tempId) {
|
||||
ArrayList<ShippingTemplatesRegionDO> 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<Integer>
|
||||
*/
|
||||
private List<Integer> 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<ShippingTemplatesRegionDO> 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<ShippingTemplatesRegionDO> 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<ShippingTemplatesRegionDO> 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<ShippingTemplatesRegionRequest>
|
||||
*/
|
||||
@Override
|
||||
public List<ShippingTemplatesRegionRespVO> getListGroup(Integer tempId) {
|
||||
return dao.getListGroup(tempId);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesService extends IService<ShippingTemplatesDO> {
|
||||
|
||||
PageResult<ShippingTemplatesDO> 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);
|
||||
}
|
|
@ -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 <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class ShippingTemplatesServiceImpl extends ServiceImpl<ShippingTemplatesMapper, ShippingTemplatesDO> 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<ShippingTemplates>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ShippingTemplatesDO> getList(ShippingTemplatesSearchReqVO request) {
|
||||
|
||||
LambdaQueryWrapper<ShippingTemplatesDO> 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<ShippingTemplatesRegionRespVO> 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<ShippingTemplatesFreeRespVO> 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<ShippingTemplatesDO> 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<ShippingTemplatesRegionRespVO> shippingTemplatesRegionRespVOList = request.getShippingTemplatesRegionRespVOList();
|
||||
|
||||
if(shippingTemplatesRegionRespVOList.size() < 1){
|
||||
throw new ServiceException("请设置区域配送信息!");
|
||||
}
|
||||
shippingTemplatesRegionService.saveAll(shippingTemplatesRegionRespVOList, request.getType(), shippingTemplatesDO.getId());
|
||||
|
||||
List<ShippingTemplatesFreeRespVO> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?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="cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesFreeMapper">
|
||||
|
||||
<select id="getListGroup" resultType="cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesFreeRespVO" parameterType="integer">
|
||||
SELECT group_concat(`city_id`) AS city_id, title, `number`, price, uniqid FROM eb_shipping_templates_free where temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `uniqid` ORDER BY id ASC
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,5 @@
|
|||
<?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="cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,8 @@
|
|||
<?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="cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesRegionMapper">
|
||||
|
||||
<select id="getListGroup" resultType="cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesRegionRespVO" parameterType="integer">
|
||||
SELECT group_concat(`city_id`) AS city_id, title, `first`, first_price, `renewal`, renewal_price, uniqid FROM eb_shipping_templates_region where temp_id = #{tempId, jdbcType=INTEGER} GROUP BY `uniqid` ORDER BY id ASC
|
||||
</select>
|
||||
</mapper>
|
|
@ -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<AreaNodeRespVO> getAreaTree();
|
||||
|
||||
}
|
|
@ -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<AreaNodeRespVO> getAreaTree() {
|
||||
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
||||
Assert.notNull(area, "获取不到中国");
|
||||
return AreaConvert.INSTANCE.convertList(area.getChildren());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue