物流管理--不包邮地区
parent
ae226440a5
commit
5a86a3c3a4
|
@ -0,0 +1,50 @@
|
|||
package cn.iocoder.yudao.module.product.controller.admin.express;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO;
|
||||
import cn.iocoder.yudao.module.product.service.express.ShippingTemplatesNoDeliveryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物流控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/admin/express/shipping/no_delivery")
|
||||
@Tag(name = "设置 -- 物流 -- 免费")
|
||||
public class ShippingTemplatesNoDeliveryController {
|
||||
|
||||
@Autowired
|
||||
private ShippingTemplatesNoDeliveryService shippingTemplatesNoDeliveryService;
|
||||
|
||||
/**
|
||||
* 根据模板id查询数据
|
||||
* @param tempId Integer 模板id
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('admin:shipping:templates:free:list')")
|
||||
@Operation(summary = "根据模板id查询数据")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<List<ShippingTemplatesNoDeliveryRespVO>> getList(@RequestParam Integer tempId){
|
||||
return CommonResult.success(shippingTemplatesNoDeliveryService.getListGroup(tempId));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.iocoder.yudao.module.product.controller.admin.express.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 免费模版 Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_shipping_templates_no_delivery")
|
||||
@Schema(description="指定不送达地区")
|
||||
public class ShippingTemplatesNoDeliveryRespVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@Schema(description = "城市ID, 多个逗号分割。 全国 all", required = true, example = "1,2,3,4")
|
||||
@NotNull(message = "请选择城市")
|
||||
private String cityId;
|
||||
}
|
|
@ -55,6 +55,9 @@ public class ShippingTemplatesReqVO implements Serializable {
|
|||
@Schema(description = "指定包邮设置", required = true)
|
||||
private List<ShippingTemplatesFreeRespVO> shippingTemplatesFreeRespVOList;
|
||||
|
||||
@Schema(description = "指定不包邮设置", required = true)
|
||||
private List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesNoDeliveryRespVOS;
|
||||
|
||||
@Schema(description = "排序", example = "0")
|
||||
@NotNull(message = "排序数字必须填写")
|
||||
@Min(value = 0, message = "排序最小为0")
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package cn.iocoder.yudao.module.product.dal.dataobject.express;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 免费运费模版
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_shipping_templates_no_delivery")
|
||||
public class ShippingTemplatesNoDeliveryDO extends TenantBaseDO {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 模板ID
|
||||
*/
|
||||
private Integer tempId;
|
||||
|
||||
/**
|
||||
*城市ID
|
||||
*/
|
||||
private Integer cityId;
|
||||
|
||||
/**
|
||||
*省份ID
|
||||
*/
|
||||
private Integer province_id;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package cn.iocoder.yudao.module.product.dal.mysql.express;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesNoDeliveryDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesNoDeliveryMapper extends BaseMapperX<ShippingTemplatesNoDeliveryDO> {
|
||||
|
||||
List<ShippingTemplatesNoDeliveryRespVO> getList(Integer tempId);
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package cn.iocoder.yudao.module.product.service.express;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesNoDeliveryDO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ShippingTemplatesFreeService 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ShippingTemplatesNoDeliveryService extends IService<ShippingTemplatesNoDeliveryDO> {
|
||||
|
||||
void saveAll(List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesFreeRespVOList, Integer id);
|
||||
|
||||
List<ShippingTemplatesNoDeliveryRespVO> getListGroup(Integer tempId);
|
||||
|
||||
/**
|
||||
* 根据模板编号、城市ID查询
|
||||
* @param tempId 模板编号
|
||||
* @param cityId 城市ID
|
||||
* @return 运费模板
|
||||
*/
|
||||
ShippingTemplatesNoDeliveryDO getByTempIdAndCityId(Integer tempId, Integer cityId);
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package cn.iocoder.yudao.module.product.service.express;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesNoDeliveryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesNoDeliveryMapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
|
||||
import cn.iocoder.yudao.module.system.service.ip.AreaService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ShippingTemplatesNoDeliveryServiceImpl extends ServiceImpl<ShippingTemplatesNoDeliveryMapper, ShippingTemplatesNoDeliveryDO> implements ShippingTemplatesNoDeliveryService {
|
||||
|
||||
@Resource
|
||||
private ShippingTemplatesNoDeliveryMapper shippingTemplatesNoDeliveryMapper;
|
||||
|
||||
@Autowired
|
||||
private AreaService areaService;
|
||||
|
||||
private List<Integer> cityIdList;
|
||||
|
||||
/**
|
||||
* 保存配送区域
|
||||
* @param shippingTemplatesNoDeliveryRespVOS List<ShippingTemplatesFreeRequest> 运费集合
|
||||
* @param tempId Integer 运费模板id
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-20
|
||||
*/
|
||||
@Override
|
||||
public void saveAll(List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesNoDeliveryRespVOS, Integer tempId) {
|
||||
ArrayList<ShippingTemplatesNoDeliveryDO> shippingTemplatesNoDeliveryDOS = new ArrayList<>();
|
||||
|
||||
for (ShippingTemplatesNoDeliveryRespVO shippingTemplatesNoDeliveryRespVO : shippingTemplatesNoDeliveryRespVOS) {
|
||||
if(shippingTemplatesNoDeliveryRespVO.getCityId().equals("all") || shippingTemplatesNoDeliveryRespVO.getCityId().equals("0")){
|
||||
cityIdList = getCityIdList();
|
||||
}else{
|
||||
cityIdList = StrUtils.stringToArray(shippingTemplatesNoDeliveryRespVO.getCityId());
|
||||
}
|
||||
for (Integer cityId: cityIdList) {
|
||||
ShippingTemplatesNoDeliveryDO shippingTemplatesNoDeliveryDO = new ShippingTemplatesNoDeliveryDO();
|
||||
shippingTemplatesNoDeliveryDO.setCityId(cityId);
|
||||
shippingTemplatesNoDeliveryDO.setTempId(tempId);
|
||||
shippingTemplatesNoDeliveryDOS.add(shippingTemplatesNoDeliveryDO);
|
||||
}
|
||||
}
|
||||
//批量保存模板数据
|
||||
saveBatch(shippingTemplatesNoDeliveryDOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有城市cityId
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-16
|
||||
* @return List<Integer>
|
||||
*/
|
||||
private List<Integer> getCityIdList() {
|
||||
if(this.cityIdList == null || this.cityIdList.size() < 1){
|
||||
this.cityIdList = areaService.getAreaTree().stream().map(AreaNodeRespVO::getId).collect(Collectors.toList());
|
||||
}
|
||||
return this.cityIdList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param tempId Integer 运费模板id
|
||||
* @return List<ShippingTemplatesFreeRequest>
|
||||
*/
|
||||
@Override
|
||||
public List<ShippingTemplatesNoDeliveryRespVO> getListGroup(Integer tempId) {
|
||||
return shippingTemplatesNoDeliveryMapper.getList(tempId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模板编号、城市ID查询
|
||||
* @param tempId 模板编号
|
||||
* @param cityId 城市ID
|
||||
* @return 运费模板
|
||||
*/
|
||||
@Override
|
||||
public ShippingTemplatesNoDeliveryDO getByTempIdAndCityId(Integer tempId, Integer cityId) {
|
||||
LambdaQueryWrapper<ShippingTemplatesNoDeliveryDO> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(ShippingTemplatesNoDeliveryDO::getTempId, tempId);
|
||||
lqw.eq(ShippingTemplatesNoDeliveryDO::getCityId, cityId);
|
||||
lqw.orderByDesc(ShippingTemplatesNoDeliveryDO::getId);
|
||||
lqw.last(" limit 1");
|
||||
return shippingTemplatesNoDeliveryMapper.selectOne(lqw);
|
||||
}
|
||||
}
|
|
@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesFreeRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesRegionRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesSearchReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.express.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.express.ShippingTemplatesDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -44,6 +41,9 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl<ShippingTemplatesM
|
|||
@Autowired
|
||||
private ShippingTemplatesFreeService shippingTemplatesFreeService;
|
||||
|
||||
@Autowired
|
||||
private ShippingTemplatesNoDeliveryService shippingTemplatesNoDeliveryService;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
|
@ -101,6 +101,12 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl<ShippingTemplatesM
|
|||
shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRespVOList, request.getType(), shippingTemplatesDO.getId());
|
||||
}
|
||||
|
||||
List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesNoDeliveryRespVOList = request.getShippingTemplatesNoDeliveryRespVOS();
|
||||
if(null != shippingTemplatesNoDeliveryRespVOList && shippingTemplatesNoDeliveryRespVOList.size() > 0){
|
||||
shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVOList, shippingTemplatesDO.getId());
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,6 +161,10 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl<ShippingTemplatesM
|
|||
if(CollUtil.isNotEmpty(shippingTemplatesFreeRespVOList) && request.getAppoint()){
|
||||
shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRespVOList, request.getType(), shippingTemplatesDO.getId());
|
||||
}
|
||||
List<ShippingTemplatesNoDeliveryRespVO> shippingTemplatesNoDeliveryRespVOList = request.getShippingTemplatesNoDeliveryRespVOS();
|
||||
if(CollUtil.isNotEmpty(shippingTemplatesNoDeliveryRespVOList)){
|
||||
shippingTemplatesNoDeliveryService.saveAll(shippingTemplatesNoDeliveryRespVOList, shippingTemplatesDO.getId());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.product.dal.mysql.express.ShippingTemplatesNoDeliveryMapper">
|
||||
|
||||
<select id="getList" resultType="cn.iocoder.yudao.module.product.controller.admin.express.vo.ShippingTemplatesNoDeliveryRespVO" parameterType="integer">
|
||||
SELECT id, group_concat(`city_id`) AS city_id, temp_id, province_idFROM eb_shipping_templates_free where temp_id = #{tempId, jdbcType=INTEGER} ORDER BY id ASC
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue