diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 79193a59..6acf99dd 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -408,6 +408,7 @@ public enum ResultCode { STORE_NOT_LOGIN_ERROR(50005, "未登录店铺"), STORE_CLOSE_ERROR(50006, "店铺关闭,请联系管理员"), FREIGHT_TEMPLATE_NOT_EXIST(50010, "当前模版不存在"), + STORE_STATUS_ERROR(50011, "店铺状态异常,无法申请"), /** * 结算单 diff --git a/framework/src/main/java/cn/lili/common/utils/RegularUtil.java b/framework/src/main/java/cn/lili/common/utils/RegularUtil.java index 3837cf24..3bbf9dba 100644 --- a/framework/src/main/java/cn/lili/common/utils/RegularUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/RegularUtil.java @@ -5,6 +5,7 @@ import java.util.regex.Pattern; /** * 用户名验证工具类 + * * @author Chopper */ public class RegularUtil { @@ -20,21 +21,88 @@ public class RegularUtil { */ private static final Pattern EMAIL = Pattern.compile("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$"); - public static boolean mobile(String v){ + //sql正则 + + static Pattern sqlPattern = Pattern.compile("(select|update|and|delete|insert|trancate|char|substr|ascii|declare|exec|count|master|into|drop|execute" + +// 可能涉及英文查询参数问题 +// "|in|not in exists|not exists" + +// "|between|not between" + +// "|like|not like" + +// "|is null|is not null" + + ")", Pattern.CASE_INSENSITIVE); + + //符号正则 + static Pattern symbolPattern = Pattern.compile("[\\s~·`!!@#¥$%^……&*(())\\-——\\-_=+【\\[\\]】{{}}\\|、\\\\;;::‘'“”\",,《<。.》>、/??]"); + + + /** + * 校验手机号 + * + * @param v + * @return + */ + public static boolean mobile(String v) { Matcher m = MOBILE.matcher(v); - if(m.matches()){ + if (m.matches()) { return true; } return false; } - public static boolean email(String v){ + //校验邮箱 + public static boolean email(String v) { Matcher m = EMAIL.matcher(v); - if(m.matches()){ + if (m.matches()) { return true; } return false; } + + + /** + * 搜索参数过滤 + * + * @param str 字符串 + * @return 过滤后的字符串 + */ + public static String replace(String str) { + + return symbolReplace(sqlReplace(str)); + } + + /** + * 过滤sql关键字 + * + * @param str 字符串 + * @return 过滤后的字符串 + */ + public static String sqlReplace(String str) { + if (StringUtils.isEmpty(str)) { + return ""; + } + Matcher sqlMatcher = sqlPattern.matcher(str); + return sqlMatcher.replaceAll(""); + } + + /** + * 符号过滤 + * + * @param str 字符串 + * @return 过滤后的字符串 + */ + public static String symbolReplace(String str) { + if (StringUtils.isEmpty(str)) { + return ""; + } + Matcher symbolMatcher = symbolPattern.matcher(str); + return symbolMatcher.replaceAll(""); + } + + public static void main(String[] args) { + System.out.println(replace("selectSELECTINORNOTIN123阿松大asdfa!@#$%^&&*()_+{}[]!?>?").trim()); + } + + } diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java index 132367a9..7ca8245e 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java @@ -147,4 +147,11 @@ public interface MemberCouponService extends IService { */ boolean recoveryMemberCoupon(List memberCouponIds); + /** + * 作废优惠券 + * + * @param couponId 优惠券ID + */ + void voidCoupon(String couponId); + } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index cee103dc..415f45fa 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -293,6 +293,15 @@ public class MemberCouponServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.in(MemberCoupon::getCouponId, couponId); + updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); + updateWrapper.set(MemberCoupon::getDeleteFlag, true); + this.update(updateWrapper); + } + /** * 清除无效的会员优惠券 * diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java b/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java index 2f0759d6..305fd5f6 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java @@ -1,5 +1,7 @@ package cn.lili.modules.search.entity.dto; +import cn.lili.common.utils.RegularUtil; +import cn.lili.common.utils.StringUtils; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -47,4 +49,11 @@ public class EsGoodsSearchDTO { @ApiModelProperty("当前商品skuId,根据当前浏览的商品信息来给用户推荐可能喜欢的商品") private String currentGoodsId; + //过滤搜索关键字 + public String getKeyword() { + if (StringUtils.isNotEmpty(keyword)) { + RegularUtil.replace(this.keyword); + } + return keyword; + } } diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index e92c50f0..6b23f60e 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -250,6 +250,8 @@ public class StoreServiceImpl extends ServiceImpl implements return storeDetailService.save(storeDetail); } else { + //校验迪纳普状态 + checkStoreStatus(store); //复制参数 修改已存在店铺 BeanUtil.copyProperties(storeCompanyDTO, store); this.updateById(store); @@ -273,6 +275,8 @@ public class StoreServiceImpl extends ServiceImpl implements //获取当前操作的店铺 Store store = getStoreByMember(); + //校验迪纳普状态 + checkStoreStatus(store); StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId()); //设置店铺的银行信息 BeanUtil.copyProperties(storeBankDTO, storeDetail); @@ -283,6 +287,9 @@ public class StoreServiceImpl extends ServiceImpl implements public boolean applyThirdStep(StoreOtherInfoDTO storeOtherInfoDTO) { //获取当前操作的店铺 Store store = getStoreByMember(); + + //校验迪纳普状态 + checkStoreStatus(store); BeanUtil.copyProperties(storeOtherInfoDTO, store); this.updateById(store); @@ -304,6 +311,22 @@ public class StoreServiceImpl extends ServiceImpl implements return this.updateById(store); } + /** + * 申请店铺时 对店铺状态进行校验判定 + * + * @param store 店铺 + */ + private void checkStoreStatus(Store store) { + + //如果店铺状态为申请中或者已申请,则正常走流程,否则抛出异常 + if (store.getStoreDisable().equals(StoreStatusEnum.APPLY.name()) || store.getStoreDisable().equals(StoreStatusEnum.APPLYING.name())) { + return; + } else { + throw new ServiceException(ResultCode.STORE_STATUS_ERROR); + } + + } + @Override public void updateStoreGoodsNum(String storeId, Long num) { //修改店铺商品数量 @@ -320,10 +343,10 @@ public class StoreServiceImpl extends ServiceImpl implements @Override public void storeToClerk() { //清空店铺信息方便重新导入不会有重复数据 - clerkService.remove(new LambdaQueryWrapper().eq(Clerk::getShopkeeper,true)); + clerkService.remove(new LambdaQueryWrapper().eq(Clerk::getShopkeeper, true)); List clerkList = new ArrayList<>(); //遍历已开启的店铺 - for (Store store : this.list(new LambdaQueryWrapper().eq(Store::getDeleteFlag,false).eq(Store::getStoreDisable,StoreStatusEnum.OPEN.name()))) { + for (Store store : this.list(new LambdaQueryWrapper().eq(Store::getDeleteFlag, false).eq(Store::getStoreDisable, StoreStatusEnum.OPEN.name()))) { clerkList.add(new Clerk(store)); } clerkService.saveBatch(clerkList);