demand: oms\小程序-订单录入支持录入企业名称、企业税号 oms\小程序-查询订单详情支持查询企业名称、企业税号 oms\小程序-查询客户地址支持查询企业名称、企业税号 oms\小程序-新增/修改客户地址支持新增/修改企业名称、企业税号

This commit is contained in:
aike 2025-09-03 16:29:12 +08:00
parent 1e280705bf
commit 005ade694f
6 changed files with 164 additions and 63 deletions

View File

@ -26,6 +26,7 @@ import com.xdadan.erp.oms.common.enums.BusinessType;
import com.xdadan.erp.oms.domain.EmisCustomerAddress;
import com.xdadan.erp.oms.service.IEmisCustomerAddressService;
import com.xdadan.erp.oms.domain.exception.EmisBizError;
/**
* 客户收寄件地址Controller
@ -55,10 +56,12 @@ public class Oms2cCustomerAddressController extends BaseController
}
// @PreAuthorize("@ss.hasPermi('emis:emisCustomerAddress:list')")
@JacksonFilter(include= {"id","name","phone","country","province","city","county","countryName","provinceName","cityName","countyName","town","townName","address","postCode","email","company","blDefaultFlag","orderNum","createTime","remark"},value= EmisCustomerAddress.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
@JacksonFilter(include = { "id", "name", "phone", "country", "province", "city", "county", "countryName",
"provinceName", "cityName", "countyName", "town", "townName", "address", "postCode", "email", "company",
"blDefaultFlag", "orderNum", "createTime", "remark", "enterpriseName",
"enterpriseTaxId" }, value = EmisCustomerAddress.class, type = JacksonFilter.JscksonFilterType.RESPONSE)
@RequestMapping("/listSimple")
public TableDataInfo listSimple(EmisCustomerAddress emisCustomerAddress)
{
public TableDataInfo listSimple(EmisCustomerAddress emisCustomerAddress) {
// 需要限制,除总部外,只能查看站点自有数据
startPage();
// emisCustomerAddress.setUserId(getLoginUser().getUser().getId());
@ -67,7 +70,10 @@ public class Oms2cCustomerAddressController extends BaseController
return getDataTable(list);
}
@JacksonFilter(include= {"id","name","phone","country","province","city","county","address","postCode","email","company","countryName","provinceName","cityName","countyName","town","townName","blDefaultFlag","orderNum","createTime","remark"},value= EmisCustomerAddress.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
@JacksonFilter(include = { "id", "name", "phone", "country", "province", "city", "county", "address", "postCode",
"email", "company", "countryName", "provinceName", "cityName", "countyName", "town", "townName",
"blDefaultFlag", "orderNum", "createTime", "remark", "enterpriseName",
"enterpriseTaxId" }, value = EmisCustomerAddress.class, type = JacksonFilter.JscksonFilterType.RESPONSE)
@RequestMapping("/getAddressById")
public AjaxResult getAddressById(@RequestParam("id") Long id)
{
@ -122,32 +128,42 @@ public class Oms2cCustomerAddressController extends BaseController
// @PreAuthorize("@ss.hasPermi('emis:emisCustomerAddress:add')")
@Log(title = "客户收寄件地址", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EmisCustomerAddress emisCustomerAddress)
{
public AjaxResult add(@RequestBody EmisCustomerAddress emisCustomerAddress) {
try {
emisCustomerAddress.setUserId(getLoginUser().getUser().getId());
emisCustomerAddress.setCustomerCode(getLoginUser().getUser().getCustomerCode());
return toAjax(emisCustomerAddressService.insertEmisCustomerAddress(emisCustomerAddress));
} catch (EmisBizError e) {
return AjaxResult.error(e.getMessage());
}
}
@Log(title = "客户收寄件地址", businessType = BusinessType.INSERT)
@PostMapping("/addAddress")
public AjaxResult addAddress(@RequestBody EmisCustomerAddress emisCustomerAddress)
{
public AjaxResult addAddress(@RequestBody EmisCustomerAddress emisCustomerAddress) {
try {
emisCustomerAddress.setUserId(getLoginUser().getUser().getId());
emisCustomerAddress.setCustomerCode(getLoginUser().getUser().getCustomerCode());
return toAjax(emisCustomerAddressService.insertEmisCustomerAddress(emisCustomerAddress));
} catch (EmisBizError e) {
return AjaxResult.error(e.getMessage());
}
}
@Log(title = "客户收寄件地址", businessType = BusinessType.UPDATE)
@PostMapping("/editAddress")
public AjaxResult editAddress(@RequestBody EmisCustomerAddress emisCustomerAddress)
{
EmisCustomerAddress old=emisCustomerAddressService.selectEmisCustomerAddressById(emisCustomerAddress.getId());
public AjaxResult editAddress(@RequestBody EmisCustomerAddress emisCustomerAddress) {
try {
EmisCustomerAddress old = emisCustomerAddressService
.selectEmisCustomerAddressById(emisCustomerAddress.getId());
if (!getLoginUser().getUser().getCustomerCode().equals(old.getCustomerCode())) {
return AjaxResult.error("非法操作");
}
return toAjax(emisCustomerAddressService.updateEmisCustomerAddress(emisCustomerAddress));
} catch (EmisBizError e) {
return AjaxResult.error(e.getMessage());
}
}
/**
@ -156,14 +172,18 @@ public class Oms2cCustomerAddressController extends BaseController
// @PreAuthorize("@ss.hasPermi('emis:emisCustomerAddress:edit')")
@Log(title = "客户收寄件地址", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EmisCustomerAddress emisCustomerAddress)
{
EmisCustomerAddress old=emisCustomerAddressService.selectEmisCustomerAddressById(emisCustomerAddress.getId());
public AjaxResult edit(@RequestBody EmisCustomerAddress emisCustomerAddress) {
try {
EmisCustomerAddress old = emisCustomerAddressService
.selectEmisCustomerAddressById(emisCustomerAddress.getId());
if (!getLoginUser().getUser().getCustomerCode().equals(old.getCustomerCode())) {
return AjaxResult.error("非法操作");
}
return toAjax(emisCustomerAddressService.updateEmisCustomerAddress(emisCustomerAddress));
} catch (EmisBizError e) {
return AjaxResult.error(e.getMessage());
}
}
/**

View File

@ -84,4 +84,9 @@ public class EmisCustomerAddress extends BaseEntity
/* 使用站点名称 */
private String useSiteName;
/* 企业名称 */
private String enterpriseName;
/* 企业税号 */
private String enterpriseTaxId;
}

View File

@ -42,6 +42,10 @@ public class Sender implements Serializable {
/* 公司 */
private String company;
/* 企业名称 */
private String enterpriseName;
/* 企业税号 */
private String enterpriseTaxId;
/* 寄件人客户地址ID */
private Integer id;
}

View File

@ -11,6 +11,7 @@ package com.xdadan.erp.oms.service;
import java.util.List;
import com.xdadan.erp.oms.domain.EmisCustomerAddress;
import com.xdadan.erp.oms.domain.exception.EmisBizError;
/**
* @ClassName EmisCustomerAddressService
@ -41,7 +42,7 @@ public interface IEmisCustomerAddressService
* @param emisCustomerAddress 客户收寄件地址
* @return 结果
*/
public int insertEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress);
public int insertEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress) throws EmisBizError;
/**
* 修改客户收寄件地址
@ -49,7 +50,7 @@ public interface IEmisCustomerAddressService
* @param emisCustomerAddress 客户收寄件地址
* @return 结果
*/
public int updateEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress);
public int updateEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress) throws EmisBizError;
/**
* 批量删除客户收寄件地址

View File

@ -17,6 +17,8 @@ import org.springframework.stereotype.Service;
import com.xdadan.erp.oms.domain.EmisCustomerAddress;
import com.xdadan.erp.oms.mapper.EmisCustomerAddressMapper;
import com.xdadan.erp.oms.service.IEmisCustomerAddressService;
import com.xdadan.erp.oms.domain.exception.EmisBizError;
import com.xdadan.erp.oms.domain.enumtype.EmisBizErrorType;
/**
* 客户收寄件地址Service业务层处理
@ -61,8 +63,17 @@ public class EmisCustomerAddressServiceImpl implements IEmisCustomerAddressServ
* @return 结果
*/
@Override
public int insertEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress)
{
public int insertEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress) throws EmisBizError {
// 验证企业名称格式
if (!validateEnterpriseName(emisCustomerAddress.getEnterpriseName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "企业名称不能包含空格、回车、@、#、$、%、&、数字等特殊符号");
}
// 验证企业税号格式
if (!validateEnterpriseTaxId(emisCustomerAddress.getEnterpriseTaxId())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "企业税号必须为8-18位数字和大写字母组成,不能包含汉字、空格等特殊符号");
}
// 新增地址
// emisCustomerAddress.preInsert();
// emisCustomerAddress.setUseSiteCode(getCurrentUser().getOwnerSiteCode());
@ -77,8 +88,17 @@ public class EmisCustomerAddressServiceImpl implements IEmisCustomerAddressServ
* @return 结果
*/
@Override
public int updateEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress)
{
public int updateEmisCustomerAddress(EmisCustomerAddress emisCustomerAddress) throws EmisBizError {
// 验证企业名称格式
if (!validateEnterpriseName(emisCustomerAddress.getEnterpriseName())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "企业名称不能包含空格、回车、@、#、$、%、&、数字等特殊符号");
}
// 验证企业税号格式
if (!validateEnterpriseTaxId(emisCustomerAddress.getEnterpriseTaxId())) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "企业税号必须为8-18位数字和大写字母组成,不能包含汉字、空格等特殊符号");
}
// emisCustomerAddress.setUseSiteCode(getCurrentUser().getOwnerSiteCode());
// emisCustomerAddress.setUseSite(getCurrentUser().getOwnerSiteName());
@ -149,5 +169,47 @@ public class EmisCustomerAddressServiceImpl implements IEmisCustomerAddressServ
return emisCustomerAddressMapper.checkUnique(emisCustomerAddress);
}
/**
* 验证企业名称格式
* 不允许包含空格、回车、@、#、$、%、&、数字等特殊符号
*/
public boolean validateEnterpriseName(String enterpriseName) {
if (com.xdadan.erp.oms.common.utils.StringUtils.isEmpty(enterpriseName)) {
return true;
}
// 检查是否包含不允许的字符
String invalidChars = " @#$%&0123456789";
for (char c : invalidChars.toCharArray()) {
if (enterpriseName.contains(String.valueOf(c))) {
return false;
}
}
// 检查是否包含回车符
if (enterpriseName.contains("\n") || enterpriseName.contains("\r")) {
return false;
}
return true;
}
/**
* 验证企业税号格式
* 8-18位数组成,由数字和大写字母组成,不允许有汉字、空格等特殊符号
*/
public boolean validateEnterpriseTaxId(String enterpriseTaxId) {
if (com.xdadan.erp.oms.common.utils.StringUtils.isEmpty(enterpriseTaxId)) {
return true;
}
// 检查长度
if (enterpriseTaxId.length() < 8 || enterpriseTaxId.length() > 18) {
return false;
}
// 检查是否只包含数字和大写字母
return enterpriseTaxId.matches("^[0-9A-Z]+$");
}
}

View File

@ -27,7 +27,8 @@
<result property="blSiteDefaultFlag" column="bl_site_default_flag" />
<result property="useSite" column="use_site" />
<result property="useSiteCode" column="use_site_code" />
<result property="enterpriseName" column="enterprise_name" />
<result property="enterpriseTaxId" column="enterprise_tax_id" />
<association property="countryName" column="country" select="com.xdadan.erp.oms.mapper.EmisBaseMapper.selectCountryNameByCode"/>
<association property="provinceName" column="province" select="com.xdadan.erp.oms.mapper.EmisBaseMapper.selectRegionNameByCode"/>
@ -38,7 +39,7 @@
</resultMap>
<sql id="selectEmisCustomerAddressVo">
select id, user_id, customer_code, short_name, alias, address_type, country, name, phone, province, city, county, town, address, post_code, email, company, bl_default_flag, order_num, bl_site_default_flag, use_site, use_site_code, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site from emis_customer_address
select id, user_id, customer_code, short_name, alias, address_type, country, name, phone, province, city, county, town, address, post_code, email, company, bl_default_flag, order_num, bl_site_default_flag, use_site, use_site_code, enterprise_name, enterprise_tax_id, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site from emis_customer_address
</sql>
@ -63,6 +64,8 @@
<if test="postCode != null and postCode != ''"> and post_code like concat('%', #{postCode}, '%')</if>
<if test="email != null and email != ''"> and email like concat('%', #{email}, '%')</if>
<if test="company != null and company != ''"> and company like concat('%', #{company}, '%')</if>
<if test="enterpriseName != null and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
<if test="enterpriseTaxId != null and enterpriseTaxId != ''"> and enterprise_tax_id like concat('%', #{enterpriseTaxId}, '%')</if>
<if test="blDefaultFlag != null and blDefaultFlag != ''"> and bl_default_flag = #{blDefaultFlag}</if>
<if test="orderNum != null "> and order_num like concat('%', #{orderNum}, '%')</if>
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''"> and bl_site_default_flag like concat('%', #{blSiteDefaultFlag}, '%')</if>
@ -87,7 +90,7 @@
</select>
<select id="selectEmisCustomerAddressById" parameterType="Long" resultMap="EmisCustomerAddressResult">
select id, user_id, customer_code, short_name, alias, address_type, country, name, phone, province, city, county, town, address, post_code, email, company, bl_default_flag, order_num, bl_site_default_flag, use_site, use_site_code, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site
select id, user_id, customer_code, short_name, alias, address_type, country, name, phone, province, city, county, town, address, post_code, email, company, bl_default_flag, order_num, bl_site_default_flag, use_site, use_site_code, enterprise_name, enterprise_tax_id, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site
from emis_customer_address a
where a.id = #{id}
</select>
@ -116,6 +119,8 @@
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''">bl_site_default_flag,</if>
<if test="useSite != null and useSite != ''">use_site,</if>
<if test="useSiteCode != null and useSiteCode != ''">use_site_code,</if>
<if test="enterpriseName != null and enterpriseName != ''">enterprise_name,</if>
<if test="enterpriseTaxId != null and enterpriseTaxId != ''">enterprise_tax_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
@ -147,6 +152,8 @@
<if test="blSiteDefaultFlag != null and blSiteDefaultFlag != ''">#{blSiteDefaultFlag},</if>
<if test="useSite != null and useSite != ''">#{useSite},</if>
<if test="useSiteCode != null and useSiteCode != ''">#{useSiteCode},</if>
<if test="enterpriseName != null and enterpriseName != ''">#{enterpriseName},</if>
<if test="enterpriseTaxId != null and enterpriseTaxId != ''">#{enterpriseTaxId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
@ -175,6 +182,8 @@
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
<if test="email != null and email != ''">email = #{email},</if>
<if test="company != null and company != ''">company = #{company},</if>
<if test="enterpriseName != null and enterpriseName != ''">enterprise_name = #{enterpriseName},</if>
<if test="enterpriseTaxId != null and enterpriseTaxId != ''">enterprise_tax_id = #{enterpriseTaxId},</if>
</trim>
where id = #{id}