mall: 订单中心新增运费模板功能
This commit is contained in:
parent
e942b52a67
commit
01a67289a9
|
@ -487,6 +487,12 @@ INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `s
|
|||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2170, '快递公司更新', 'trade:delivery:express:update', 3, 3, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2171, '快递公司删除', 'trade:delivery:express:delete', 3, 4, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2172, '快递公司导出', 'trade:delivery:express:export', 3, 5, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2178, '快递运费模板导出', 'trade:delivery:express-template:export', 3, 5, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2177, '快递运费模板删除', 'trade:delivery:express-template:delete', 3, 4, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2176, '快递运费模板更新', 'trade:delivery:express-template:update', 3, 3, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2175, '快递运费模板创建', 'trade:delivery:express-template:create', 3, 2, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2174, '快递运费模板查询', 'trade:delivery:express-template:query', 3, 1, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2173, '运费模版', 'trade:delivery:express-template:query', 2, 1, 2165, 'express-template', '', 'mall/trade/delivery/expressTemplate/index', 'ExpressTemplate', 0, b'1', b'1', b'1', '1', '2023-05-20 06:48:10', '1', '2023-05-20 06:48:29', b'0');
|
||||
|
||||
INSERT INTO `system_dict_data`(`sort`,`label`,`value`,`dict_type`,`status`,`color_type`,`css_class`,`remark`,`creator`,`create_time`,`updater`,`update_time`,`deleted`) VALUES
|
||||
(1,'打',2,'product_unit',0,'','','',1, NOW(),1, NOW(),0),
|
||||
|
@ -520,4 +526,12 @@ INSERT INTO `system_dict_data`(`sort`,`label`,`value`,`dict_type`,`status`,`colo
|
|||
(1, '英寸', 30, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), 0),
|
||||
(1, '英尺', 31, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), 0),
|
||||
(1, '码', 32, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), 0),
|
||||
(1,'个',1,'product_unit',0,'','','',1, NOW(),1, NOW(),0);
|
||||
(1,'个',1,'product_unit',0,'','','',1, NOW(),1, NOW(),0);
|
||||
-- ----------------------------
|
||||
-- 数字字典,快递计费方式
|
||||
-- ----------------------------
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_dict_type`(`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (169, '快递计费方式', 'trade_delivery_express_charge_mode', 0, '用于商城交易模块配送管理', '1', '2023-05-21 22:45:03', '1', '2023-05-21 22:45:03', b'0', '1970-01-01 00:00:00');
|
||||
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1237, 2, '按体积', '3', 'trade_delivery_express_charge_mode', 0, '', '', '', '1', '2023-05-21 22:47:18', '1', '2023-05-21 22:47:18', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1236, 1, '按重量', '2', 'trade_delivery_express_charge_mode', 0, '', '', '', '1', '2023-05-21 22:46:58', '1', '2023-05-21 22:46:58', b'0');
|
||||
INSERT INTO `ruoyi-vue-pro`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1235, 0, '按件', '1', 'trade_delivery_express_charge_mode', 0, '', '', '', '1', '2023-05-21 22:46:40', '1', '2023-05-21 22:46:40', b'0');
|
||||
|
|
|
@ -48,5 +48,6 @@ public interface ErrorCodeConstants {
|
|||
// ========== 物流配送模块 1-011-003-000 ==========
|
||||
ErrorCode DELIVERY_EXPRESS_NOT_EXISTS = new ErrorCode(1011003000, "快递公司不存在");
|
||||
ErrorCode EXPRESS_CODE_DUPLICATE = new ErrorCode(1011003001, "已经存在该编码的快递公司");
|
||||
|
||||
ErrorCode EXPRESS_TEMPLATE_NOT_EXISTS = new ErrorCode(1011003002, "运费模板不存在");
|
||||
ErrorCode EXPRESS_TEMPLATE_NAME_DUPLICATE = new ErrorCode(1011003002, "已经存在该运费模板名");
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class DeliveryExpressController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得快递公司分页")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery-express:query')")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express:query')")
|
||||
public CommonResult<PageResult<DeliveryExpressRespVO>> getDeliveryExpressPage(@Valid DeliveryExpressPageReqVO pageVO) {
|
||||
PageResult<DeliveryExpressDO> pageResult = deliveryExpressService.getDeliveryExpressPage(pageVO);
|
||||
return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult));
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 快递运费模板")
|
||||
@RestController
|
||||
@RequestMapping("/trade/delivery/express-template")
|
||||
@Validated
|
||||
public class DeliveryExpressTemplateController {
|
||||
|
||||
@Resource
|
||||
private DeliveryExpressTemplateService deliveryExpressTemplateService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建快递运费模板")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:create')")
|
||||
public CommonResult<Long> createDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateCreateReqVO createReqVO) {
|
||||
return success(deliveryExpressTemplateService.createDeliveryExpressTemplate(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新快递运费模板")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:update')")
|
||||
public CommonResult<Boolean> updateDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateUpdateReqVO updateReqVO) {
|
||||
deliveryExpressTemplateService.updateDeliveryExpressTemplate(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除快递运费模板")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:delete')")
|
||||
public CommonResult<Boolean> deleteDeliveryExpressTemplate(@RequestParam("id") Long id) {
|
||||
deliveryExpressTemplateService.deleteDeliveryExpressTemplate(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得快递运费模板")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')")
|
||||
public CommonResult<DeliveryExpressTemplateRespVO> getDeliveryExpressTemplate(@RequestParam("id") Long id) {
|
||||
return success(deliveryExpressTemplateService.getDeliveryExpressTemplate(id));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得快递运费模板列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')")
|
||||
public CommonResult<List<DeliveryExpressTemplateSimpleRespVO>> getDeliveryExpressTemplateList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<DeliveryExpressTemplateDO> list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(ids);
|
||||
return success(DeliveryExpressTemplateConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得快递运费模板分页")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')")
|
||||
public CommonResult<PageResult<DeliveryExpressTemplateSimpleRespVO>> getDeliveryExpressTemplatePage(@Valid DeliveryExpressTemplatePageReqVO pageVO) {
|
||||
PageResult<DeliveryExpressTemplateDO> pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO);
|
||||
return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出快递运费模板 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express-template:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportDeliveryExpressTemplateExcel(@Valid DeliveryExpressTemplateExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<DeliveryExpressTemplateDO> list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<DeliveryExpressTemplateExcelVO> datas = DeliveryExpressTemplateConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "快递运费模板.xls", "数据", DeliveryExpressTemplateExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 快递运费模板 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class DeliveryExpressTemplateBaseVO {
|
||||
|
||||
@Schema(description = "模板名称", required = true, example = "王五")
|
||||
@NotNull(message = "模板名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积", required = true)
|
||||
@NotNull(message = "配送计费方式 1:按件 2:按重量 3:按体积不能为空")
|
||||
private Integer chargeMode;
|
||||
|
||||
@Schema(description = "排序", required = true)
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Schema(description = "管理后台 - 快递运费模板创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeliveryExpressTemplateCreateReqVO extends DeliveryExpressTemplateBaseVO {
|
||||
|
||||
@Schema(description = "区域运费列表")
|
||||
@Valid
|
||||
private List<ExpressTemplateChargeBaseVO> templateCharge = Collections.emptyList();
|
||||
|
||||
@Schema(description = "包邮区域列表")
|
||||
@Valid
|
||||
private List<ExpressTemplateFreeBaseVO> templateFree = Collections.emptyList();
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 快递运费模板 Excel VO
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class DeliveryExpressTemplateExcelVO {
|
||||
|
||||
@ExcelProperty("编号,自增")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("模板名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("配送计费方式 1:按件 2:按重量 3:按体积")
|
||||
private Integer chargeMode;
|
||||
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 快递运费模板 Excel 导出 Request VO,参数和 DeliveryExpressTemplatePageReqVO 是一致的")
|
||||
@Data
|
||||
public class DeliveryExpressTemplateExportReqVO {
|
||||
|
||||
@Schema(description = "模板名称", example = "王五")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积")
|
||||
private Integer chargeMode;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 快递运费模板分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeliveryExpressTemplatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "模板名称", example = "王五")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积")
|
||||
private Integer chargeMode;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@Schema(description = "管理后台 - 快递运费模板 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeliveryExpressTemplateRespVO extends DeliveryExpressTemplateBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "运费模板运费设置", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<ExpressTemplateChargeBaseVO> templateCharge;
|
||||
|
||||
@Schema(description = "运费模板包邮区域", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<ExpressTemplateFreeBaseVO> templateFree;
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 快递运费模板 精简 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeliveryExpressTemplateSimpleRespVO extends DeliveryExpressTemplateBaseVO {
|
||||
|
||||
@Schema(description = "编号,自增", required = true, example = "371")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", required = true)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 快递运费模板更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeliveryExpressTemplateUpdateReqVO extends DeliveryExpressTemplateBaseVO {
|
||||
|
||||
@Schema(description = "编号", required = true, example = "371")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "区域运费列表")
|
||||
@Valid
|
||||
private List<ExpressTemplateChargeUpdateVO> templateCharge = Collections.emptyList();
|
||||
|
||||
@Schema(description = "包邮区域列表")
|
||||
@Valid
|
||||
private List<ExpressTemplateFreeUpdateVO> templateFree = Collections.emptyList();
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 快递运费模板运费设置 Base VO,提供给添加运费模板使用
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class ExpressTemplateChargeBaseVO {
|
||||
|
||||
@Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "区域编号不能为空")
|
||||
private Integer areaId;
|
||||
|
||||
@Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||
@NotNull(message = "首件数量不能为空")
|
||||
private Double startCount;
|
||||
|
||||
@Schema(description = "起步价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||
@NotNull(message = "起步价不能为空")
|
||||
private Integer startPrice;
|
||||
|
||||
@Schema(description = "续件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@NotNull(message = "续件数量不能为空")
|
||||
private Double extraCount;
|
||||
|
||||
@Schema(description = "额外价", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
|
||||
@NotNull(message = "额外价不能为空")
|
||||
private Integer extraPrice;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class ExpressTemplateChargeUpdateVO extends ExpressTemplateChargeBaseVO {
|
||||
|
||||
@Schema(description = "编号", example = "6592")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配送模板编号", example = "1")
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "配送计费方式", example = "1")
|
||||
private Integer chargeMode;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 快递运费模板包邮 Base VO,提供给添加运费模板使用
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class ExpressTemplateFreeBaseVO {
|
||||
|
||||
@Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "区域编号不能为空")
|
||||
private Integer areaId;
|
||||
|
||||
@Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000")
|
||||
@NotNull(message = "包邮金额不能为空")
|
||||
private Integer freePrice;
|
||||
|
||||
@Schema(description = "包邮件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||
@NotNull(message = "包邮件数不能为空")
|
||||
private Integer freeCount;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 快递运费模板包邮 更新 VO
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class ExpressTemplateFreeUpdateVO extends ExpressTemplateFreeBaseVO {
|
||||
|
||||
@Schema(description = "编号", example = "6592")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配送模板编号", example = "1")
|
||||
private Long templateId;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package cn.iocoder.yudao.module.trade.convert.delivery;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 快递运费模板 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeliveryExpressTemplateConvert {
|
||||
|
||||
DeliveryExpressTemplateConvert INSTANCE = Mappers.getMapper(DeliveryExpressTemplateConvert.class);
|
||||
|
||||
DeliveryExpressTemplateDO convert(DeliveryExpressTemplateCreateReqVO bean);
|
||||
|
||||
DeliveryExpressTemplateDO convert(DeliveryExpressTemplateUpdateReqVO bean);
|
||||
|
||||
DeliveryExpressTemplateSimpleRespVO convert(DeliveryExpressTemplateDO bean);
|
||||
|
||||
DeliveryExpressTemplateRespVO convert2(DeliveryExpressTemplateDO bean);
|
||||
|
||||
List<DeliveryExpressTemplateSimpleRespVO> convertList(List<DeliveryExpressTemplateDO> list);
|
||||
|
||||
PageResult<DeliveryExpressTemplateSimpleRespVO> convertPage(PageResult<DeliveryExpressTemplateDO> page);
|
||||
|
||||
List<DeliveryExpressTemplateExcelVO> convertList02(List<DeliveryExpressTemplateDO> list);
|
||||
|
||||
DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, ExpressTemplateChargeBaseVO vo);
|
||||
|
||||
DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo);
|
||||
|
||||
DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, ExpressTemplateFreeBaseVO vo);
|
||||
|
||||
DeliveryExpressTemplateFreeDO convertTemplateFree(ExpressTemplateFreeUpdateVO vo);
|
||||
|
||||
List<ExpressTemplateChargeBaseVO> convertTemplateChargeList(List<DeliveryExpressTemplateChargeDO> list);
|
||||
|
||||
List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list);
|
||||
|
||||
default List<DeliveryExpressTemplateChargeDO> convertTemplateChargeList(Long templateId, Integer chargeMode, List<ExpressTemplateChargeBaseVO> list){
|
||||
if(CollUtil.isEmpty(list)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<DeliveryExpressTemplateChargeDO> templateChargeList = new ArrayList<>( list.size() );
|
||||
for (ExpressTemplateChargeBaseVO item : list) {
|
||||
templateChargeList.add(convertTemplateCharge(templateId, chargeMode, item));
|
||||
}
|
||||
return templateChargeList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<DeliveryExpressTemplateFreeDO> templateFreeList = new ArrayList<>(list.size());
|
||||
for (ExpressTemplateFreeBaseVO item : list) {
|
||||
templateFreeList.add(convertTemplateFree(templateId, item));
|
||||
}
|
||||
return templateFreeList;
|
||||
}
|
||||
|
||||
default DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean,
|
||||
List<DeliveryExpressTemplateChargeDO> chargeList,
|
||||
List<DeliveryExpressTemplateFreeDO> freeList){
|
||||
DeliveryExpressTemplateRespVO respVO = convert2(bean);
|
||||
respVO.setTemplateCharge(convertTemplateChargeList(chargeList));
|
||||
respVO.setTemplateFree(convertTemplateFreeList(freeList));
|
||||
return respVO;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ import lombok.Data;
|
|||
public class DeliveryExpressTemplateFreeDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
|
|
@ -2,12 +2,31 @@ package cn.iocoder.yudao.module.trade.dal.mysql.delivery;
|
|||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX<DeliveryExpressTemplateChargeDO> {
|
||||
|
||||
@Repository
|
||||
class BatchInsertMapper extends ServiceImpl<DeliveryExpressTemplateChargeMapper, DeliveryExpressTemplateChargeDO> {
|
||||
}
|
||||
|
||||
default List<DeliveryExpressTemplateChargeDO> selectListByTemplateId(Long templateId){
|
||||
return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateChargeDO>()
|
||||
.eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId));
|
||||
}
|
||||
|
||||
default int deleteByTemplateId(Long templateId){
|
||||
return delete(new LambdaQueryWrapper<DeliveryExpressTemplateChargeDO>()
|
||||
.eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,32 @@
|
|||
package cn.iocoder.yudao.module.trade.dal.mysql.delivery;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX<DeliveryExpressTemplateFreeDO> {
|
||||
|
||||
@Repository
|
||||
class BatchInsertMapper extends ServiceImpl<DeliveryExpressTemplateFreeMapper, DeliveryExpressTemplateFreeDO> {
|
||||
}
|
||||
|
||||
default List<DeliveryExpressTemplateFreeDO> selectListByTemplateId(Long templateId) {
|
||||
return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateFreeDO>()
|
||||
.eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId));
|
||||
}
|
||||
|
||||
default int deleteByTemplateId(Long templateId) {
|
||||
return delete(new LambdaQueryWrapper<DeliveryExpressTemplateFreeDO>()
|
||||
.eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,40 @@
|
|||
package cn.iocoder.yudao.module.trade.dal.mysql.delivery;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplateExportReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplatePageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpressTemplateDO> {
|
||||
|
||||
default PageResult<DeliveryExpressTemplateDO> selectPage(DeliveryExpressTemplatePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeliveryExpressTemplateDO>()
|
||||
.likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName())
|
||||
.eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode())
|
||||
.betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByAsc(DeliveryExpressTemplateDO::getSort));
|
||||
}
|
||||
|
||||
default List<DeliveryExpressTemplateDO> selectList(DeliveryExpressTemplateExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<DeliveryExpressTemplateDO>()
|
||||
.likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName())
|
||||
.eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode())
|
||||
.betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByAsc(DeliveryExpressTemplateDO::getSort));
|
||||
}
|
||||
|
||||
default DeliveryExpressTemplateDO selectByName(String name) {
|
||||
return selectOne(new LambdaQueryWrapper<DeliveryExpressTemplateDO>()
|
||||
.eq(DeliveryExpressTemplateDO::getName, name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package cn.iocoder.yudao.module.trade.service.delivery;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||
|
||||
/**
|
||||
* 快递运费模板 Service 接口
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public interface DeliveryExpressTemplateService {
|
||||
|
||||
/**
|
||||
* 创建快递运费模板
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDeliveryExpressTemplate(@Valid DeliveryExpressTemplateCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新快递运费模板
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDeliveryExpressTemplate(@Valid DeliveryExpressTemplateUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除快递运费模板
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDeliveryExpressTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 获得快递运费模板
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 快递运费模板详情
|
||||
*/
|
||||
DeliveryExpressTemplateRespVO getDeliveryExpressTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 获得快递运费模板列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 快递运费模板列表
|
||||
*/
|
||||
List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得快递运费模板分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 快递运费模板分页
|
||||
*/
|
||||
PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得快递运费模板列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 快递运费模板列表
|
||||
*/
|
||||
List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO);
|
||||
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
package cn.iocoder.yudao.module.trade.service.delivery;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateChargeMapper;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateFreeMapper;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert.INSTANCE;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 快递运费模板 Service 实现类
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTemplateService {
|
||||
|
||||
@Resource
|
||||
private DeliveryExpressTemplateMapper expressTemplateMapper;
|
||||
@Resource
|
||||
private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper;
|
||||
@Resource
|
||||
private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper;
|
||||
@Resource
|
||||
private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper;
|
||||
@Resource
|
||||
private DeliveryExpressTemplateFreeMapper.BatchInsertMapper expressTemplateFreeBatchMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) {
|
||||
//校验模板名是否唯一
|
||||
validateTemplateNameUnique(createReqVO.getName(), null);
|
||||
// 插入
|
||||
DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO);
|
||||
expressTemplateMapper.insert(deliveryExpressTemplate);
|
||||
//插入运费模板计费表
|
||||
if(CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) {
|
||||
expressTemplateChargeBatchMapper.saveBatch(
|
||||
INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge())
|
||||
);
|
||||
}
|
||||
//插入运费模板包邮表
|
||||
if(CollUtil.isNotEmpty(createReqVO.getTemplateFree())) {
|
||||
expressTemplateFreeBatchMapper.saveBatch(
|
||||
INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree())
|
||||
);
|
||||
}
|
||||
return deliveryExpressTemplate.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDeliveryExpressTemplateExists(updateReqVO.getId());
|
||||
//校验模板名是否唯一
|
||||
validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId());
|
||||
|
||||
//更新运费从表
|
||||
updateExpressTemplateCharge(updateReqVO);
|
||||
//更新包邮从表
|
||||
updateExpressTemplateFree(updateReqVO);
|
||||
//更新模板主表
|
||||
DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO);
|
||||
expressTemplateMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void updateExpressTemplateFree(DeliveryExpressTemplateUpdateReqVO updateReqVO) {
|
||||
List<DeliveryExpressTemplateFreeDO> oldFreeList = expressTemplateFreeMapper.selectListByTemplateId(updateReqVO.getId());
|
||||
List<ExpressTemplateFreeUpdateVO> newFreeList = updateReqVO.getTemplateFree();
|
||||
//新增包邮区域列表
|
||||
List<DeliveryExpressTemplateFreeDO> addFreeList = new ArrayList<>(newFreeList.size());
|
||||
//更新包邮区域列表
|
||||
List<DeliveryExpressTemplateFreeDO> updateFreeList = new ArrayList<>(newFreeList.size());
|
||||
for (ExpressTemplateFreeUpdateVO item : newFreeList) {
|
||||
if (Objects.nonNull(item.getId())) {
|
||||
updateFreeList.add(INSTANCE.convertTemplateFree(item));
|
||||
}else{
|
||||
item.setTemplateId(updateReqVO.getId());
|
||||
addFreeList.add(INSTANCE.convertTemplateFree(item));
|
||||
}
|
||||
}
|
||||
//删除的包邮区域id
|
||||
Set<Long> deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId);
|
||||
deleteFreeIds.removeAll(CollectionUtils.convertSet(updateFreeList, DeliveryExpressTemplateFreeDO::getId));
|
||||
//新增
|
||||
if (CollUtil.isNotEmpty(addFreeList)) {
|
||||
expressTemplateFreeBatchMapper.saveBatch(addFreeList);
|
||||
}
|
||||
//修改
|
||||
if (CollUtil.isNotEmpty(updateFreeList)) {
|
||||
expressTemplateFreeBatchMapper.saveOrUpdateBatch(updateFreeList);
|
||||
}
|
||||
//删除
|
||||
if (CollUtil.isNotEmpty(deleteFreeIds)) {
|
||||
expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateExpressTemplateCharge(DeliveryExpressTemplateUpdateReqVO updateReqVO) {
|
||||
List<DeliveryExpressTemplateChargeDO> oldChargeList = expressTemplateChargeMapper.selectListByTemplateId(updateReqVO.getId());
|
||||
List<ExpressTemplateChargeUpdateVO> newChargeList = updateReqVO.getTemplateCharge();
|
||||
//新增运费区域列表
|
||||
List<DeliveryExpressTemplateChargeDO> addList = new ArrayList<>(newChargeList.size());
|
||||
//更新运费区域列表
|
||||
List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size());
|
||||
for (ExpressTemplateChargeUpdateVO item : newChargeList) {
|
||||
if (Objects.nonNull(item.getId())) {
|
||||
//计费模式以主表为准
|
||||
item.setChargeMode(updateReqVO.getChargeMode());
|
||||
updateList.add(INSTANCE.convertTemplateCharge(item));
|
||||
}else{
|
||||
item.setTemplateId(updateReqVO.getId());
|
||||
item.setChargeMode(updateReqVO.getChargeMode());
|
||||
addList.add(INSTANCE.convertTemplateCharge(item));
|
||||
}
|
||||
}
|
||||
//删除的运费区域id
|
||||
Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId);
|
||||
deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId));
|
||||
//新增
|
||||
if (CollUtil.isNotEmpty(addList)) {
|
||||
expressTemplateChargeBatchMapper.saveBatch(addList);
|
||||
}
|
||||
//修改
|
||||
if (CollUtil.isNotEmpty(updateList)) {
|
||||
expressTemplateChargeBatchMapper.saveOrUpdateBatch(updateList);
|
||||
}
|
||||
//删除
|
||||
if (CollUtil.isNotEmpty(deleteChargeIds)) {
|
||||
expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDeliveryExpressTemplate(Long id) {
|
||||
// 校验存在
|
||||
validateDeliveryExpressTemplateExists(id);
|
||||
// 删除主表
|
||||
expressTemplateMapper.deleteById(id);
|
||||
// 删除运费从表
|
||||
expressTemplateChargeMapper.deleteByTemplateId(id);
|
||||
// 删除包邮从表
|
||||
expressTemplateFreeMapper.deleteByTemplateId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验运费模板名是否唯一
|
||||
* @param name 模板名称
|
||||
* @param id 运费模板编号, 可以为null
|
||||
*/
|
||||
private void validateTemplateNameUnique(String name, Long id) {
|
||||
DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name);
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空
|
||||
if (id == null) {
|
||||
throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE);
|
||||
}
|
||||
if (!template.getId().equals(id)) {
|
||||
throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDeliveryExpressTemplateExists(Long id) {
|
||||
if (expressTemplateMapper.selectById(id) == null) {
|
||||
throw exception(EXPRESS_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeliveryExpressTemplateRespVO getDeliveryExpressTemplate(Long id) {
|
||||
List<DeliveryExpressTemplateChargeDO> chargeList = expressTemplateChargeMapper.selectListByTemplateId(id);
|
||||
List<DeliveryExpressTemplateFreeDO> freeList = expressTemplateFreeMapper.selectListByTemplateId(id);
|
||||
DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id);
|
||||
return INSTANCE.convert(template, chargeList,freeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(Collection<Long> ids) {
|
||||
return expressTemplateMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) {
|
||||
return expressTemplateMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO) {
|
||||
return expressTemplateMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
@ -28,10 +29,10 @@ public class AreaController {
|
|||
|
||||
@GetMapping("/tree")
|
||||
@Operation(summary = "获得地区树")
|
||||
public CommonResult<List<AreaNodeRespVO>> getAreaTree() {
|
||||
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
||||
Assert.notNull(area, "获取不到中国");
|
||||
return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
|
||||
public CommonResult<List<AreaNodeRespVO>> getAreaTree(Integer id) {
|
||||
Area area = AreaUtils.getArea(id);
|
||||
Assert.notNull(area, String.format("获取不到 id : %d的区域", id));
|
||||
return success(AreaConvert.INSTANCE.convertList(Arrays.asList(area)));
|
||||
}
|
||||
|
||||
@GetMapping("/get-by-ip")
|
||||
|
|
Loading…
Reference in New Issue