mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
mall:review + mall:快递费用
This commit is contained in:
parent
53e9be733f
commit
0083d12404
@ -74,6 +74,7 @@ public class DeliveryExpressController {
|
|||||||
return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult));
|
return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @jason:运费模版,可以去掉哈,没啥用;
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出快递公司 Excel")
|
@Operation(summary = "导出快递公司 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('trade:delivery:express:export')")
|
@PreAuthorize("@ss.hasPermission('trade:delivery:express:export')")
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.trade.convert.delivery;
|
package cn.iocoder.yudao.module.trade.convert.delivery;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*;
|
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.DeliveryExpressTemplateChargeDO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||||
@ -12,6 +9,10 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemp
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快递运费模板 Convert
|
* 快递运费模板 Convert
|
||||||
*
|
*
|
||||||
@ -22,6 +23,8 @@ public interface DeliveryExpressTemplateConvert {
|
|||||||
|
|
||||||
DeliveryExpressTemplateConvert INSTANCE = Mappers.getMapper(DeliveryExpressTemplateConvert.class);
|
DeliveryExpressTemplateConvert INSTANCE = Mappers.getMapper(DeliveryExpressTemplateConvert.class);
|
||||||
|
|
||||||
|
// ========== Template ==========
|
||||||
|
|
||||||
DeliveryExpressTemplateDO convert(DeliveryExpressTemplateCreateReqVO bean);
|
DeliveryExpressTemplateDO convert(DeliveryExpressTemplateCreateReqVO bean);
|
||||||
|
|
||||||
DeliveryExpressTemplateDO convert(DeliveryExpressTemplateUpdateReqVO bean);
|
DeliveryExpressTemplateDO convert(DeliveryExpressTemplateUpdateReqVO bean);
|
||||||
@ -36,10 +39,35 @@ public interface DeliveryExpressTemplateConvert {
|
|||||||
|
|
||||||
List<DeliveryExpressTemplateExcelVO> convertList02(List<DeliveryExpressTemplateDO> list);
|
List<DeliveryExpressTemplateExcelVO> convertList02(List<DeliveryExpressTemplateDO> list);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Template Charge ==========
|
||||||
|
|
||||||
DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, ExpressTemplateChargeBaseVO vo);
|
DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, ExpressTemplateChargeBaseVO vo);
|
||||||
|
|
||||||
DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Template Free ==========
|
||||||
|
|
||||||
DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, ExpressTemplateFreeBaseVO vo);
|
DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, ExpressTemplateFreeBaseVO vo);
|
||||||
|
|
||||||
DeliveryExpressTemplateFreeDO convertTemplateFree(ExpressTemplateFreeUpdateVO vo);
|
DeliveryExpressTemplateFreeDO convertTemplateFree(ExpressTemplateFreeUpdateVO vo);
|
||||||
@ -48,20 +76,9 @@ public interface DeliveryExpressTemplateConvert {
|
|||||||
|
|
||||||
List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list);
|
List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list);
|
||||||
|
|
||||||
default List<DeliveryExpressTemplateChargeDO> convertTemplateChargeList(Long templateId, Integer chargeMode, List<ExpressTemplateChargeBaseVO> list){
|
// TODO @jason:, 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) {
|
default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) {
|
||||||
|
// TODO @jason:可以使用 CollectionUtils.convertList,本质上就是 stream convert list
|
||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -72,12 +89,4 @@ public interface DeliveryExpressTemplateConvert {
|
|||||||
return templateFreeList;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,9 @@ package cn.iocoder.yudao.module.trade.dal.mysql.delivery;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
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.DeliveryExpressTemplateExportReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplatePageReqVO;
|
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 cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -33,8 +31,10 @@ public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpre
|
|||||||
.orderByAsc(DeliveryExpressTemplateDO::getSort));
|
.orderByAsc(DeliveryExpressTemplateDO::getSort));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @jason:可以用 selectOne(DeliveryExpressTemplateDO::getName, name),常用的我封装了哈。简洁一点~
|
||||||
default DeliveryExpressTemplateDO selectByName(String name) {
|
default DeliveryExpressTemplateDO selectByName(String name) {
|
||||||
return selectOne(new LambdaQueryWrapper<DeliveryExpressTemplateDO>()
|
return selectOne(new LambdaQueryWrapper<DeliveryExpressTemplateDO>()
|
||||||
.eq(DeliveryExpressTemplateDO::getName, name));
|
.eq(DeliveryExpressTemplateDO::getName, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
|
|||||||
private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper;
|
private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper;
|
private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper;
|
||||||
|
// TODO @jason:应该不用 BatchInsertMapper 拉,直接走 expressTemplateChargeMapper.insertBatch
|
||||||
@Resource
|
@Resource
|
||||||
private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper;
|
private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper;
|
||||||
@Resource
|
@Resource
|
||||||
@ -44,12 +45,15 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) {
|
public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) {
|
||||||
|
// TODO @jason:中英文之间,要有空格哈。例如说, // 校验模板名是否唯一
|
||||||
//校验模板名是否唯一
|
//校验模板名是否唯一
|
||||||
validateTemplateNameUnique(createReqVO.getName(), null);
|
validateTemplateNameUnique(createReqVO.getName(), null);
|
||||||
|
|
||||||
// 插入
|
// 插入
|
||||||
DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO);
|
DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO);
|
||||||
expressTemplateMapper.insert(deliveryExpressTemplate);
|
expressTemplateMapper.insert(deliveryExpressTemplate);
|
||||||
//插入运费模板计费表
|
//插入运费模板计费表
|
||||||
|
// TODO @jason:if (,中间要有空格
|
||||||
if(CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) {
|
if(CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) {
|
||||||
expressTemplateChargeBatchMapper.saveBatch(
|
expressTemplateChargeBatchMapper.saveBatch(
|
||||||
INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge())
|
INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge())
|
||||||
@ -121,7 +125,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
|
|||||||
//更新运费区域列表
|
//更新运费区域列表
|
||||||
List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size());
|
List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size());
|
||||||
for (ExpressTemplateChargeUpdateVO item : newChargeList) {
|
for (ExpressTemplateChargeUpdateVO item : newChargeList) {
|
||||||
if (Objects.nonNull(item.getId())) {
|
if (Objects.nonNull(item.getId())) { // TODO @jason:null 的判断,还是用 item.getId() != null 好一点。一般数组用方法,主要考虑 null + length = 0;
|
||||||
//计费模式以主表为准
|
//计费模式以主表为准
|
||||||
item.setChargeMode(updateReqVO.getChargeMode());
|
item.setChargeMode(updateReqVO.getChargeMode());
|
||||||
updateList.add(INSTANCE.convertTemplateCharge(item));
|
updateList.add(INSTANCE.convertTemplateCharge(item));
|
||||||
@ -131,7 +135,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
|
|||||||
addList.add(INSTANCE.convertTemplateCharge(item));
|
addList.add(INSTANCE.convertTemplateCharge(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//删除的运费区域id
|
//删除的运费区域id TODO @jason:这块放到删除部分的那块逻辑会好点(149 - 152 行),主要变量要贴相应的逻辑近一点哈。
|
||||||
Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId);
|
Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId);
|
||||||
deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId));
|
deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId));
|
||||||
//新增
|
//新增
|
||||||
@ -153,6 +157,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
|
|||||||
public void deleteDeliveryExpressTemplate(Long id) {
|
public void deleteDeliveryExpressTemplate(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateDeliveryExpressTemplateExists(id);
|
validateDeliveryExpressTemplateExists(id);
|
||||||
|
|
||||||
// 删除主表
|
// 删除主表
|
||||||
expressTemplateMapper.deleteById(id);
|
expressTemplateMapper.deleteById(id);
|
||||||
// 删除运费从表
|
// 删除运费从表
|
||||||
@ -162,9 +167,9 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验运费模板名是否唯一
|
* 校验运费模板名是否唯一 // TODO @jason:方法注释,和参数,要空一行。
|
||||||
* @param name 模板名称
|
* @param name 模板名称
|
||||||
* @param id 运费模板编号, 可以为null
|
* @param id 运费模板编号, 可以为null // TODO @jason:中英文之间,要空一行;其它地方也看看哈
|
||||||
*/
|
*/
|
||||||
private void validateTemplateNameUnique(String name, Long id) {
|
private void validateTemplateNameUnique(String name, Long id) {
|
||||||
DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name);
|
DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name);
|
||||||
|
@ -15,7 +15,6 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -35,6 +34,8 @@ public class AreaController {
|
|||||||
return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
|
return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @jason:1)url 使用中划线分隔哈,然后可以改成 children;2)id 需要添加 @RequestParam,因为可能会混淆编译;
|
||||||
|
// 3) swagger 注解要写下哈;
|
||||||
@GetMapping("/getChildrenArea")
|
@GetMapping("/getChildrenArea")
|
||||||
@Operation(summary = "获得地区的下级区域")
|
@Operation(summary = "获得地区的下级区域")
|
||||||
public CommonResult<List<LazyAreaNodeRespVO>> getChildrenArea(Integer id) {
|
public CommonResult<List<LazyAreaNodeRespVO>> getChildrenArea(Integer id) {
|
||||||
@ -43,8 +44,10 @@ public class AreaController {
|
|||||||
return success(AreaConvert.INSTANCE.convertList2(area.getChildren()));
|
return success(AreaConvert.INSTANCE.convertList2(area.getChildren()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @jason:1)读请求,使用 get 哈。2)然后参数不应该使用 @RequestBody;3)areaIds 改成 ids 更合适;
|
||||||
|
// 4)方法改成 getAreaChildrenList 获得子节点们;5)url 可以已改成 children-list
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@Operation(summary = "通过区域ids获得地区列表")
|
@Operation(summary = "通过区域 ids 获得地区列表")
|
||||||
public CommonResult<List<LazyAreaNodeRespVO>> list(@RequestBody Set<Integer> areaIds) {
|
public CommonResult<List<LazyAreaNodeRespVO>> list(@RequestBody Set<Integer> areaIds) {
|
||||||
List<Area> areaList = new ArrayList<>(areaIds.size());
|
List<Area> areaList = new ArrayList<>(areaIds.size());
|
||||||
for (Integer areaId : areaIds) {
|
for (Integer areaId : areaIds) {
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.ip.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
// TODO @jason:1)VO 不添加注释作者哈。2)是不是改成 AreaNodeSimpleRespVO,它其实是返回一个简洁的地区,懒加载只是它的使用场景;
|
||||||
/**
|
/**
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@ -16,6 +17,8 @@ public class LazyAreaNodeRespVO {
|
|||||||
@Schema(description = "名字", required = true, example = "北京")
|
@Schema(description = "名字", required = true, example = "北京")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
// TODO @jason:1)不设置默认值,交给业务逻辑那写入;2)这个字段必须返回哇?
|
||||||
@Schema(description = "是否叶子节点", required = true, example = "false")
|
@Schema(description = "是否叶子节点", required = true, example = "false")
|
||||||
private Boolean leaf = Boolean.FALSE;
|
private Boolean leaf = Boolean.FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user