Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product_new

pull/2/head
perry 2023-05-10 15:38:42 +08:00
commit d084a87258
27 changed files with 1487 additions and 0 deletions

View File

@ -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, "未知错误");

View File

@ -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;
}
}

View File

@ -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>

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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));
}
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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));
}
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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));
}
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public interface ShippingTemplatesFreeMapper extends BaseMapperX<ShippingTemplatesFreeDO> {
List<ShippingTemplatesFreeRespVO> getListGroup(Integer tempId);
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public interface ShippingTemplatesMapper extends BaseMapperX<ShippingTemplatesDO> {
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public interface ShippingTemplatesRegionMapper extends BaseMapperX<ShippingTemplatesRegionDO> {
List<ShippingTemplatesRegionRespVO> getListGroup(Integer tempId);
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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);
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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);
}
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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);
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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);
}
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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);
}

View File

@ -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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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;
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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();
}

View File

@ -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());
}
}