物流管理--不包邮地区

pull/2/head
小小张 2023-05-10 16:43:54 +08:00
parent ae226440a5
commit 5a86a3c3a4
9 changed files with 315 additions and 4 deletions

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.product.controller.admin.express;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.controller.admin.express.vo.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 CRMEBCRMEB
* +----------------------------------------------------------------------
* | 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));
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.product.dal.mysql.express.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>