运费模板 review 修改. 运费模块可以选择多个区域

This commit is contained in:
jason 2023-05-27 11:20:43 +08:00
parent 02fa6fc5c6
commit 55dbff7570
26 changed files with 193 additions and 254 deletions

View File

@ -350,7 +350,7 @@ DROP TABLE IF EXISTS `trade_delivery_express_template_free`;
CREATE TABLE `trade_delivery_express_template_free` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`template_id` bigint NOT NULL COMMENT '快递运费模板编号',
`area_id` int NOT NULL COMMENT '包邮区域 id',
`area_ids` varchar(100) NOT NULL COMMENT '包邮区域 ids',
`free_price` int NOT NULL COMMENT '包邮金额单位',
`free_count` int NOT NULL DEFAULT 0 COMMENT '包邮件数,',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
@ -369,7 +369,7 @@ DROP TABLE IF EXISTS `trade_delivery_express_template_charge`;
CREATE TABLE `trade_delivery_express_template_charge` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号自增',
`template_id` bigint NOT NULL COMMENT '快递运费模板编号',
`area_id` int NOT NULL COMMENT '配送区域 id',
`area_ids` varchar(100) NOT NULL COMMENT '配送区域 ids',
`charge_mode` tinyint NOT NULL COMMENT '配送计费方式',
`start_count` double NOT NULL COMMENT '首件数量',
`start_price` int NOT NULL COMMENT '起步价单位',
@ -501,7 +501,7 @@ INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `
INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2029, 'Banner删除', 'market:banner:delete', 3, 4, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', 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 (2164, '配送管理', '', 1, 0, 2072, 'delivery', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:18:02', '1', '2023-05-18 09:48:48', 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 (2165, '快递发货', '', 1, 0, 2164, 'express', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:22:06', '1', '2023-05-18 09:22:06', 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 (2166, '门店自提', '', 1, 1, 2164, 'pick-up-store', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:23:14', '1', '2023-05-18 09:23:14', 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 (2166, '门店自提', '', 1, 1, 2164, 'pick-up', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:23:14', '1', '2023-05-18 09:23:14', 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 (2167, '快递公司', '', 2, 0, 2165, 'express', '', 'mall/trade/delivery/express/index', 'Express', 0, b'1', b'1', b'1', '1', '2023-05-18 09:27:21', '1', '2023-05-18 22:11:14', 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 (2168, '快递公司查询', 'trade:delivery:express:query', 3, 1, 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 (2169, '快递公司创建', 'trade:delivery:express:create', 3, 2, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0');

View File

@ -45,4 +45,10 @@ public class StrUtils {
return Arrays.stream(longs).boxed().collect(Collectors.toList());
}
public static List<Integer> splitToInteger(String value, CharSequence separator) {
int[] integers = StrUtil.splitToInt(value, separator);
return Arrays.stream(integers).boxed().collect(Collectors.toList());
}
}

View File

@ -113,10 +113,20 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
Db.saveBatch(entities, size);
}
// @芋艿 是不是叫 updateByDo 或者 updateByEntity 更合适
default void updateBatch(T update) {
update(update, new QueryWrapper<>());
}
/**
* 根据ID 批量更新适合大量数据更新
*
* @param entities 实体们
*/
default void updateBatch(Collection<T> entities) {
Db.updateBatchById(entities);
}
default void updateBatch(Collection<T> entities, int size) {
Db.updateBatchById(entities, size);
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.framework.mybatis.core.type;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import org.apache.ibatis.type.TypeHandler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
/**
* List<Integer> 的类型转换器实现类对应数据库的 varchar 类型
*
* @author jason
*/
@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(List.class)
public class IntegerListTypeHandler implements TypeHandler<List<Integer>> {
private static final String COMMA = ",";
@Override
public void setParameter(PreparedStatement ps, int i, List<Integer> strings, JdbcType jdbcType) throws SQLException {
ps.setString(i, CollUtil.join(strings, COMMA));
}
@Override
public List<Integer> getResult(ResultSet rs, String columnName) throws SQLException {
String value = rs.getString(columnName);
return getResult(value);
}
@Override
public List<Integer> getResult(ResultSet rs, int columnIndex) throws SQLException {
String value = rs.getString(columnIndex);
return getResult(value);
}
@Override
public List<Integer> getResult(CallableStatement cs, int columnIndex) throws SQLException {
String value = cs.getString(columnIndex);
return getResult(value);
}
private List<Integer> getResult(String value) {
if (value == null) {
return null;
}
return StrUtils.splitToInteger(value, COMMA);
}
}

View File

@ -74,7 +74,7 @@ public class DeliveryExpressController {
return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult));
}
// TODO @jason运费模版可以去掉哈没啥用
// TODO @jason运费模版@芋艿 你的意思是运费模板导出没有必要吧已经去掉了这个是快递公司导出
@GetMapping("/export-excel")
@Operation(summary = "导出快递公司 Excel")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:export')")

View File

@ -84,17 +84,4 @@ public class DeliveryExpressTemplateController {
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);
}
}

View File

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@ -7,8 +10,6 @@ import java.time.LocalDateTime;
/**
* 快递公司 Excel VO
*
* @author jason
*/
@Data
public class DeliveryExpressExcelVO {
@ -28,9 +29,9 @@ public class DeliveryExpressExcelVO {
@ExcelProperty("排序")
private Integer sort;
@ExcelProperty("状态")
// TODO @jason可以使用 @DictFormat(DictTypeConstants.COMMON_STATUS)
private Byte status;
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.COMMON_STATUS)
private Integer status;
@ExcelProperty("创建时间")
private LocalDateTime createTime;

View File

@ -1,31 +0,0 @@
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;
}

View File

@ -1,26 +0,0 @@
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;
}

View File

@ -3,19 +3,19 @@ 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.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 快递运费模板运费设置 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 = "[1,120000]")
@NotEmpty(message = "区域编号列表不能为空")
private List<Integer> areaIds;
@Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "首件数量不能为空")

View File

@ -3,9 +3,7 @@ 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 {

View File

@ -3,19 +3,19 @@ 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.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 快递运费模板包邮 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 = "[1,120000]")
@NotEmpty(message = "区域编号列表不能为空")
private List<Integer> areaIds;
@Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000")
@NotNull(message = "包邮金额不能为空")

View File

@ -5,8 +5,6 @@ import lombok.Data;
/**
* 快递运费模板包邮 更新 VO
*
* @author jason
*/
@Data
public class ExpressTemplateFreeUpdateVO extends ExpressTemplateFreeBaseVO {

View File

@ -16,7 +16,7 @@ import org.mapstruct.factory.Mappers;
/**
* 快递公司 Convert
*
* @author 芋道源码
* @author jason
*/
@Mapper
public interface DeliveryExpressConvert {

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.convert.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;
@ -16,7 +17,7 @@ import java.util.List;
/**
* 快递运费模板 Convert
*
* @author 芋道源码
* @author jason
*/
@Mapper
public interface DeliveryExpressTemplateConvert {
@ -37,8 +38,6 @@ public interface DeliveryExpressTemplateConvert {
PageResult<DeliveryExpressTemplateSimpleRespVO> convertPage(PageResult<DeliveryExpressTemplateDO> page);
List<DeliveryExpressTemplateExcelVO> convertList02(List<DeliveryExpressTemplateDO> list);
default DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean,
List<DeliveryExpressTemplateChargeDO> chargeList,
List<DeliveryExpressTemplateFreeDO> freeList){
@ -55,15 +54,7 @@ public interface DeliveryExpressTemplateConvert {
DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo);
default List<DeliveryExpressTemplateChargeDO> convertTemplateChargeList(Long templateId, Integer chargeMode, List<ExpressTemplateChargeBaseVO> list) {
// TODO @jason可以使用 CollectionUtils.convertList本质上就是 stream convert 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;
return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo));
}
// ========== Template Free ==========
@ -76,17 +67,8 @@ public interface DeliveryExpressTemplateConvert {
List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list);
// TODO @jason, List中间一个空格哈代码的空格和空行要注意嘿嘿~
default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) {
// TODO @jason可以使用 CollectionUtils.convertList本质上就是 stream convert 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;
return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo));
}
}

View File

@ -1,17 +1,21 @@
package cn.iocoder.yudao.module.trade.dal.dataobject.delivery;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.List;
/**
* 快递运费模板计费配置 DO
*
* @author jason
*/
@TableName(value ="trade_delivery_express_template_charge")
@TableName(value ="trade_delivery_express_template_charge", autoResultMap = true)
@KeySequence("trade_delivery_express_template_charge_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
public class DeliveryExpressTemplateChargeDO extends BaseDO {
@ -30,9 +34,10 @@ public class DeliveryExpressTemplateChargeDO extends BaseDO {
private Long templateId;
/**
* 配送区域
* 配送区域编号列表
*/
private Integer areaId;
@TableField(typeHandler = IntegerListTypeHandler.class)
private List<Integer> areaIds;
/**
* 配送计费方式

View File

@ -1,17 +1,21 @@
package cn.iocoder.yudao.module.trade.dal.dataobject.delivery;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.List;
/**
* 快递运费模板包邮配置 DO
*
* @author jason
*/
@TableName(value ="trade_delivery_express_template_free")
@TableName(value ="trade_delivery_express_template_free", autoResultMap = true)
@KeySequence("trade_delivery_express_template_free_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
public class DeliveryExpressTemplateFreeDO extends BaseDO {
@ -29,10 +33,12 @@ public class DeliveryExpressTemplateFreeDO extends BaseDO {
*/
private Long templateId;
/**
* 包邮区域id
* 配送区域编号列表
*/
private Integer areaId;
@TableField(typeHandler = IntegerListTypeHandler.class)
private List<Integer> areaIds;
/**
* 包邮金额单位

View File

@ -14,10 +14,6 @@ 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));

View File

@ -14,10 +14,6 @@ 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));

View File

@ -4,14 +4,10 @@ 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.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> {
@ -23,18 +19,8 @@ public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpre
.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));
}
// TODO @jason可以用 selectOneDeliveryExpressTemplateDO::getName, name常用的我封装了哈简洁一点~
default DeliveryExpressTemplateDO selectByName(String name) {
return selectOne(new LambdaQueryWrapper<DeliveryExpressTemplateDO>()
.eq(DeliveryExpressTemplateDO::getName, name));
return selectOne(DeliveryExpressTemplateDO::getName,name);
}
}

View File

@ -58,13 +58,4 @@ public interface DeliveryExpressTemplateService {
* @return 快递运费模板分页
*/
PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO);
/**
* 获得快递运费模板列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 快递运费模板列表
*/
List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO);
}

View File

@ -36,32 +36,24 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper;
@Resource
private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper;
// TODO @jason应该不用 BatchInsertMapper 直接走 expressTemplateChargeMapper.insertBatch
@Resource
private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper;
@Resource
private DeliveryExpressTemplateFreeMapper.BatchInsertMapper expressTemplateFreeBatchMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) {
// TODO @jason中英文之间要有空格哈例如说 // 校验模板名是否唯一
// 校验模板名是否唯一
validateTemplateNameUnique(createReqVO.getName(), null);
// 插入
DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO);
expressTemplateMapper.insert(deliveryExpressTemplate);
// 插入运费模板计费表
// TODO @jasonif (中间要有空格
if (CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) {
expressTemplateChargeBatchMapper.saveBatch(
expressTemplateChargeMapper.insertBatch(
INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge())
);
}
// 插入运费模板包邮表
if (CollUtil.isNotEmpty(createReqVO.getTemplateFree())) {
expressTemplateFreeBatchMapper.saveBatch(
expressTemplateFreeMapper.insertBatch(
INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree())
);
}
@ -75,7 +67,6 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
validateDeliveryExpressTemplateExists(updateReqVO.getId());
// 校验模板名是否唯一
validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId());
// 更新运费从表
updateExpressTemplateCharge(updateReqVO);
// 更新包邮从表
@ -100,17 +91,17 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
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);
expressTemplateFreeMapper.insertBatch(addFreeList);
}
// 修改
if (CollUtil.isNotEmpty(updateFreeList)) {
expressTemplateFreeBatchMapper.saveOrUpdateBatch(updateFreeList);
expressTemplateFreeMapper.updateBatch(updateFreeList);
}
// 得到删除ids
Set<Long> deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId);
deleteFreeIds.removeAll(CollectionUtils.convertSet(updateFreeList, DeliveryExpressTemplateFreeDO::getId));
//删除
if (CollUtil.isNotEmpty(deleteFreeIds)) {
expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds);
@ -125,7 +116,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
// 更新运费区域列表
List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size());
for (ExpressTemplateChargeUpdateVO item : newChargeList) {
if (Objects.nonNull(item.getId())) { // TODO @jasonnull 的判断还是用 item.getId() != null 好一点一般数组用方法主要考虑 null + length = 0
if (item.getId() != null) {
// 计费模式以主表为准
item.setChargeMode(updateReqVO.getChargeMode());
updateList.add(INSTANCE.convertTemplateCharge(item));
@ -135,17 +126,17 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
addList.add(INSTANCE.convertTemplateCharge(item));
}
}
//删除的运费区域id TODO @jason这块放到删除部分的那块逻辑会好点149 - 152 )主要变量要贴相应的逻辑近一点哈
Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId);
deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId));
// 新增
if (CollUtil.isNotEmpty(addList)) {
expressTemplateChargeBatchMapper.saveBatch(addList);
expressTemplateChargeMapper.insertBatch(addList);
}
// 修改
if (CollUtil.isNotEmpty(updateList)) {
expressTemplateChargeBatchMapper.saveOrUpdateBatch(updateList);
expressTemplateChargeMapper.updateBatch(updateList);
}
// 得到删除的ids
Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId);
deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId));
// 删除
if (CollUtil.isNotEmpty(deleteChargeIds)) {
expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds);
@ -157,7 +148,6 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
public void deleteDeliveryExpressTemplate(Long id) {
// 校验存在
validateDeliveryExpressTemplateExists(id);
// 删除主表
expressTemplateMapper.deleteById(id);
// 删除运费从表
@ -167,9 +157,10 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
}
/**
* 校验运费模板名是否唯一 // TODO @jason方法注释和参数要空一行
* 校验运费模板名是否唯一
*
* @param name 模板名称
* @param id 运费模板编号, 可以为null // TODO @jason中英文之间要空一行其它地方也看看哈
* @param id 运费模板编号,可以为 null
*/
private void validateTemplateNameUnique(String name, Long id) {
DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name);
@ -208,10 +199,4 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
public PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) {
return expressTemplateMapper.selectPage(pageReqVO);
}
@Override
public List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO) {
return expressTemplateMapper.selectList(exportReqVO);
}
}

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.ip.core.Area;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.framework.ip.core.utils.IPUtils;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.LazyAreaNodeRespVO;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO;
import cn.iocoder.yudao.module.system.convert.ip.AreaConvert;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -34,23 +34,23 @@ public class AreaController {
return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
}
// TODO @jason1url 使用中划线分隔哈然后可以改成 children2id 需要添加 @RequestParam因为可能会混淆编译
// 3) swagger 注解要写下哈
@GetMapping("/getChildrenArea")
@GetMapping("/get-children")
@Operation(summary = "获得地区的下级区域")
public CommonResult<List<LazyAreaNodeRespVO>> getChildrenArea(Integer id) {
@Parameter(name = "id", description = "区域编号", required = true, example = "150000")
public CommonResult<List<AreaNodeSimpleRespVO>> getChildren(@RequestParam("id") Integer id) {
Area area = AreaUtils.getArea(id);
Assert.notNull(area, String.format("获取不到 id : %d 的区域", id));
return success(AreaConvert.INSTANCE.convertList2(area.getChildren()));
}
// TODO @jason1读请求使用 get 2然后参数不应该使用 @RequestBody3areaIds 改成 ids 更合适
// 4)方法改成 getAreaChildrenList 获得子节点们5url 可以已改成 children-list
@PostMapping("/list")
//@芋艿 是不是叫 getAreaListByIds 更合适 因为不一定是子节点 用于前端树选择获取缓存数据 <el-tree-select :cache-data="areaCache">
@GetMapping("/get-by-ids")
@Operation(summary = "通过区域 ids 获得地区列表")
public CommonResult<List<LazyAreaNodeRespVO>> list(@RequestBody Set<Integer> areaIds) {
List<Area> areaList = new ArrayList<>(areaIds.size());
for (Integer areaId : areaIds) {
@Parameter(name = "ids", description = "区域编号 ids", required = true, example = "1,150000")
public CommonResult<List<AreaNodeSimpleRespVO>> getAreaListByIds(@RequestParam("ids") Set<Integer> ids) {
List<Area> areaList = new ArrayList<>(ids.size());
for (Integer areaId : ids) {
areaList.add(AreaUtils.getArea(areaId));
}
return success(AreaConvert.INSTANCE.convertList2(areaList));

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.system.controller.admin.ip.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 简洁的地区节点 Response VO")
@Data
public class AreaNodeSimpleRespVO {
@Schema(description = "编号", required = true, example = "110000")
private Integer id;
@Schema(description = "名字", required = true, example = "北京")
private String name;
@Schema(description = "是否叶子节点", required = false, example = "false")
private Boolean leaf;
}

View File

@ -1,24 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.ip.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
// TODO @jason1VO 不添加注释作者哈2是不是改成 AreaNodeSimpleRespVO它其实是返回一个简洁的地区懒加载只是它的使用场景
/**
* @author jason
*/
@Schema(description = "管理后台 - 懒加载地区节点 Response VO")
@Data
public class LazyAreaNodeRespVO {
@Schema(description = "编号", required = true, example = "110000")
private Integer id;
@Schema(description = "名字", required = true, example = "北京")
private String name;
// TODO @jason1不设置默认值交给业务逻辑那写入2这个字段必须返回哇
@Schema(description = "是否叶子节点", required = true, example = "false")
private Boolean leaf = Boolean.FALSE;
}

View File

@ -3,12 +3,10 @@ package cn.iocoder.yudao.module.system.convert.ip;
import cn.iocoder.yudao.framework.ip.core.Area;
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.LazyAreaNodeRespVO;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import org.springframework.context.annotation.Lazy;
import java.util.List;
import java.util.Objects;
@ -20,10 +18,10 @@ public interface AreaConvert {
List<AreaNodeRespVO> convertList(List<Area> list);
List<LazyAreaNodeRespVO> convertList2(List<Area> list);
List<AreaNodeSimpleRespVO> convertList2(List<Area> list);
@Mapping(source = "type", target = "leaf")
LazyAreaNodeRespVO convert(Area area);
AreaNodeSimpleRespVO convert(Area area);
default Boolean convertAreaType(Integer type){
return Objects.equals(AreaTypeEnum.DISTRICT.getType(),type);