Browse Source

基础资料客户添加收货地址

lazhaoqian 3 years ago
parent
commit
f2eb557edc

+ 119 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsAddr.java

@@ -0,0 +1,119 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.entity;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 客户收发货地址实体类
+ *
+ * @author BladeX
+ * @since 2021-12-28
+ */
+@Data
+@TableName("basic_corps_addr")
+@ApiModel(value = "CorpsAddr对象", description = "客户收发货地址")
+public class CorpsAddr implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 主键
+	*/
+		@ApiModelProperty(value = "主键")
+		private Long id;
+	/**
+	* 主表id
+	*/
+		@ApiModelProperty(value = "主表id")
+		private Long pid;
+	/**
+	* 公司地址
+	*/
+		@ApiModelProperty(value = "公司地址")
+		private String addr;
+	/**
+	* 联系人
+	*/
+		@ApiModelProperty(value = "联系人")
+		private String attn;
+	/**
+	* 电话
+	*/
+		@ApiModelProperty(value = "电话")
+		private String tel;
+	/**
+	* 备注
+	*/
+		@ApiModelProperty(value = "备注")
+		private String remarks;
+	/**
+	* 版本
+	*/
+		@ApiModelProperty(value = "版本")
+		private String version;
+	/**
+	* 创建人
+	*/
+		@ApiModelProperty(value = "创建人")
+		private Long createUser;
+	/**
+	* 创建部门
+	*/
+		@ApiModelProperty(value = "创建部门")
+		private Long createDept;
+	/**
+	* 创建时间
+	*/
+		@ApiModelProperty(value = "创建时间")
+		private Date createTime;
+	/**
+	* 修改人
+	*/
+		@ApiModelProperty(value = "修改人")
+		private Long updateUser;
+	/**
+	* 修改时间
+	*/
+		@ApiModelProperty(value = "修改时间")
+		private Date updateTime;
+	/**
+	* 状态(0 正常 1停用)
+	*/
+		@ApiModelProperty(value = "状态(0 正常 1停用)")
+		private Integer status;
+	/**
+	* 是否已删除(0 否 1是)
+	*/
+		@TableLogic
+		@ApiModelProperty(value = "是否已删除(0 否 1是)")
+		private Integer isDeleted;
+	/**
+	 * 租户id
+	 */
+		@ApiModelProperty(value = "租户id")
+	    private String tenantId;
+
+
+}

+ 6 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsDesc.java

@@ -266,6 +266,12 @@ public class CorpsDesc implements Serializable {
 	@TableField(exist = false)
 	private List<CorpsItem> corpsItems;
 	/**
+	 * 客户地址
+	 */
+	@ApiModelProperty(value = "客户地址")
+	@TableField(exist = false)
+	private List<CorpsAddr> corpsAddrList;
+	/**
 	 * 客户类别
 	 */
 	@ApiModelProperty(value = "客户类别")

+ 36 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/vo/CorpsAddrVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.vo;
+
+import org.springblade.client.entity.CorpsAddr;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+
+/**
+ * 客户收发货地址视图实体类
+ *
+ * @author BladeX
+ * @since 2021-12-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "CorpsAddrVO对象", description = "客户收发货地址")
+public class CorpsAddrVO extends CorpsAddr {
+	private static final long serialVersionUID = 1L;
+
+}

+ 132 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsAddrController.java

@@ -0,0 +1,132 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.corps.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.bouncycastle.crypto.agreement.srp.SRP6Util;
+import org.springblade.client.corps.service.ICorpsAddrService;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.client.entity.CorpsAddr;
+import org.springblade.client.vo.CorpsAddrVO;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 客户收发货地址 控制器
+ *
+ * @author BladeX
+ * @since 2021-12-28
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/corpsAddr")
+@Api(value = "客户收发货地址", tags = "客户收发货地址接口")
+public class CorpsAddrController extends BladeController {
+
+	private final ICorpsAddrService corpsAddrService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入corpsAddr")
+	public R<CorpsAddr> detail(CorpsAddr corpsAddr) {
+		CorpsAddr detail = corpsAddrService.getOne(Condition.getQueryWrapper(corpsAddr));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页 客户收发货地址
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入corpsAddr")
+	public R<IPage<CorpsAddr>> list(CorpsAddr corpsAddr, Query query) {
+		corpsAddr.setTenantId(SecureUtil.getTenantId());
+		corpsAddr.setIsDeleted(0);
+		IPage<CorpsAddr> pages = corpsAddrService.page(Condition.getPage(query), Condition.getQueryWrapper(corpsAddr));
+		return R.data(pages);
+	}
+
+	/**
+	 * 自定义分页 客户收发货地址
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入corpsAddr")
+	public R<IPage<CorpsAddrVO>> page(CorpsAddrVO corpsAddr, Query query) {
+		corpsAddr.setTenantId(SecureUtil.getTenantId());
+		corpsAddr.setIsDeleted(0);
+		IPage<CorpsAddrVO> pages = corpsAddrService.selectCorpsAddrPage(Condition.getPage(query), corpsAddr);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 客户收发货地址
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入corpsAddr")
+	public R save(@Valid @RequestBody CorpsAddr corpsAddr) {
+		return R.status(corpsAddrService.save(corpsAddr));
+	}
+
+	/**
+	 * 修改 客户收发货地址
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入corpsAddr")
+	public R update(@Valid @RequestBody CorpsAddr corpsAddr) {
+		return R.status(corpsAddrService.updateById(corpsAddr));
+	}
+
+	/**
+	 * 新增或修改 客户收发货地址
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入corpsAddr")
+	public R submit(@Valid @RequestBody CorpsAddr corpsAddr) {
+		return R.status(corpsAddrService.saveOrUpdate(corpsAddr));
+	}
+
+
+	/**
+	 * 删除 客户收发货地址
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(corpsAddrService.removeByIds(Func.toLongList(ids)));
+	}
+
+
+}

+ 53 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/mapper/CorpsAddrMapper.java

@@ -0,0 +1,53 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.corps.mapper;
+
+import org.apache.ibatis.annotations.Param;
+import org.springblade.client.entity.CorpsAddr;
+import org.springblade.client.entity.CorpsAttn;
+import org.springblade.client.vo.CorpsAddrVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 客户收发货地址 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2021-12-28
+ */
+public interface CorpsAddrMapper extends BaseMapper<CorpsAddr> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param corpsAddr
+	 * @return
+	 */
+	List<CorpsAddrVO> selectCorpsAddrPage(IPage page, CorpsAddrVO corpsAddr);
+	/**
+	 * 查询客户联系人编码
+	 *
+	 * @param addr
+	 * @return
+	 */
+	CorpsAddr selectCorpsAddrCode(@Param("addr") String addr,
+								  @Param("pid")Long pid,
+								  @Param("tenantId") String tenantId);
+
+}

+ 37 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/mapper/CorpsAddrMapper.xml

@@ -0,0 +1,37 @@
+<?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="org.springblade.client.corps.mapper.CorpsAddrMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="corpsAddrResultMap" type="org.springblade.client.entity.CorpsAddr">
+        <id column="id" property="id"/>
+        <result column="pid" property="pid"/>
+        <result column="addr" property="addr"/>
+        <result column="attn" property="attn"/>
+        <result column="tel" property="tel"/>
+        <result column="remarks" property="remarks"/>
+        <result column="version" property="version"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="tenant_id" property="tenantId"/>
+    </resultMap>
+
+
+    <select id="selectCorpsAddrPage" resultMap="corpsAddrResultMap">
+        select * from basic_corps_addr where is_deleted = 0
+    </select>
+    <select id="selectCorpsAddrCode" resultMap="corpsAddrResultMap">
+        select id, addr
+        from basic_corps_attn
+        where is_deleted = 0
+          and addr = #{addr}
+          and pid = #{pid}
+          and tenant_id = #{tenantId}
+    </select>
+
+</mapper>

+ 41 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/ICorpsAddrService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.corps.service;
+
+import org.springblade.client.entity.CorpsAddr;
+import org.springblade.client.vo.CorpsAddrVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 客户收发货地址 服务类
+ *
+ * @author BladeX
+ * @since 2021-12-28
+ */
+public interface ICorpsAddrService extends IService<CorpsAddr> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param corpsAddr
+	 * @return
+	 */
+	IPage<CorpsAddrVO> selectCorpsAddrPage(IPage<CorpsAddrVO> page, CorpsAddrVO corpsAddr);
+
+}

+ 76 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/impl/CorpsAddrServiceImpl.java

@@ -0,0 +1,76 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.corps.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.client.corps.mapper.CorpsAddrMapper;
+import org.springblade.client.corps.service.ICorpsAddrService;
+import org.springblade.client.entity.CorpsAddr;
+import org.springblade.client.entity.CorpsAttn;
+import org.springblade.client.entity.CorpsDesc;
+import org.springblade.client.vo.CorpsAddrVO;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.Date;
+
+/**
+ * 客户收发货地址 服务实现类
+ *
+ * @author BladeX
+ * @since 2021-12-28
+ */
+@Service
+public class CorpsAddrServiceImpl extends ServiceImpl<CorpsAddrMapper, CorpsAddr> implements ICorpsAddrService {
+
+	@Override
+	public IPage<CorpsAddrVO> selectCorpsAddrPage(IPage<CorpsAddrVO> page, CorpsAddrVO corpsAddr) {
+		return page.setRecords(baseMapper.selectCorpsAddrPage(page, corpsAddr));
+	}
+	public R saveOrUpdateAddr(CorpsDesc corpsDesc, Long userId, Long pId, String tenantId, Date date){
+		if (CollectionUtils.isNotEmpty(corpsDesc.getCorpsAddrList())){
+			for (CorpsAddr corpsAddr : corpsDesc.getCorpsAddrList()) {
+				corpsAddr.setPid(pId);
+				corpsAddr.setTenantId(tenantId);
+				if (StringUtil.isBlank(corpsAddr.getAddr())){
+					throw new RuntimeException("地址不能为空");
+				}
+				CorpsAddr corpsAttn = baseMapper.selectCorpsAddrCode(corpsAddr.getAddr(), corpsAddr.getPid(), SecureUtil.getTenantId());
+				if (corpsAttn != null && corpsAttn.getId() == null) {
+					throw new RuntimeException("地址不能重复:"+corpsAddr.getAddr()+"已存在");
+				} else if (corpsAttn != null && !corpsAttn.getId().equals(corpsAddr.getId())) {
+					throw new RuntimeException("地址不能重复:"+corpsAddr.getAddr()+"已存在");
+				}
+				if (corpsAddr.getId() == null){
+					corpsAddr.setCreateUser(userId);
+					corpsAddr.setCreateTime(date);
+					baseMapper.insert(corpsAddr);
+				}else {
+					corpsAddr.setUpdateUser(userId);
+					corpsAddr.setUpdateTime(date);
+					baseMapper.updateById(corpsAddr);
+				}
+			}
+		}
+		return R.success("保存成功");
+	}
+
+}

+ 9 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/impl/CorpsDescServiceImpl.java

@@ -46,6 +46,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 	private CorpsTypeDescMapper corpsTypeDescMapper;
 	private CorpsTypeServiceImpl corpsTypeService;
 	private CorpsTypeMapper corpsTypeMapper;
+	private CorpsAddrServiceImpl corpsAddrService;
 	@Autowired
 	private CorpsTypeDescMapper middleMapper;
 
@@ -96,6 +97,12 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 			return saveOrUpdateItems;
 		}
+		//保存客户地址信息
+		R addr = corpsAddrService.saveOrUpdateAddr(corpsDesc, userId, pId, tenantId, date);
+		if (!addr.isSuccess()){
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+			return addr;
+		}
 		//保存客户与类别对应关系
 		this.saveOrUpdateTypeDesc(corpsDesc, userId, pId, date, tenantId);
 		return R.data(corpsDesc);
@@ -113,6 +120,8 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 			desc.setCorpsFiles(corpsFilesService.list(new QueryWrapper<CorpsFiles>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
 			//获取客户优势项目
 			desc.setCorpsItems(corpsItemService.list(new QueryWrapper<CorpsItem>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
+			//获取客户地址
+			desc.setCorpsAddrList(corpsAddrService.list(new QueryWrapper<CorpsAddr>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
 			//获取客户类别
 			List<String> longs = corpsTypeDescMapper.selectTypeId(corpsDesc.getId());
 			desc.setCorpsTypeId(String.join(",", longs));