Skip to content

Commit

Permalink
Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop i…
Browse files Browse the repository at this point in the history
…nto feature/pg
  • Loading branch information
LeiGaoRobot committed Dec 7, 2022
2 parents ede7a37 + 602678e commit 0eec406
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, "店铺状态异常,无法申请"),

/**
* 结算单
Expand Down
76 changes: 72 additions & 4 deletions framework/src/main/java/cn/lili/common/utils/RegularUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/**
* 用户名验证工具类
*
* @author Chopper
*/
public class RegularUtil {
Expand All @@ -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());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,11 @@ public interface MemberCouponService extends IService<MemberCoupon> {
*/
boolean recoveryMemberCoupon(List<String> memberCouponIds);

/**
* 作废优惠券
*
* @param couponId 优惠券ID
*/
void voidCoupon(String couponId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ public boolean recoveryMemberCoupon(List<String> memberCouponIds) {
return this.update(updateWrapper);
}

@Override
public void voidCoupon(String couponId) {
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(MemberCoupon::getCouponId, couponId);
updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
updateWrapper.set(MemberCoupon::getDeleteFlag, true);
this.update(updateWrapper);
}

/**
* 清除无效的会员优惠券
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ public boolean applyFirstStep(StoreCompanyDTO storeCompanyDTO) {
return storeDetailService.save(storeDetail);
} else {

//校验迪纳普状态
checkStoreStatus(store);
//复制参数 修改已存在店铺
BeanUtil.copyProperties(storeCompanyDTO, store);
this.updateById(store);
Expand All @@ -273,6 +275,8 @@ public boolean applySecondStep(StoreBankDTO storeBankDTO) {

//获取当前操作的店铺
Store store = getStoreByMember();
//校验迪纳普状态
checkStoreStatus(store);
StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId());
//设置店铺的银行信息
BeanUtil.copyProperties(storeBankDTO, storeDetail);
Expand All @@ -283,6 +287,9 @@ public boolean applySecondStep(StoreBankDTO storeBankDTO) {
public boolean applyThirdStep(StoreOtherInfoDTO storeOtherInfoDTO) {
//获取当前操作的店铺
Store store = getStoreByMember();

//校验迪纳普状态
checkStoreStatus(store);
BeanUtil.copyProperties(storeOtherInfoDTO, store);
this.updateById(store);

Expand All @@ -304,6 +311,22 @@ public boolean applyThirdStep(StoreOtherInfoDTO storeOtherInfoDTO) {
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) {
//修改店铺商品数量
Expand All @@ -320,10 +343,10 @@ public void updateStoreCollectionNum(CollectionDTO collectionDTO) {
@Override
public void storeToClerk() {
//清空店铺信息方便重新导入不会有重复数据
clerkService.remove(new LambdaQueryWrapper<Clerk>().eq(Clerk::getShopkeeper,true));
clerkService.remove(new LambdaQueryWrapper<Clerk>().eq(Clerk::getShopkeeper, true));
List<Clerk> clerkList = new ArrayList<>();
//遍历已开启的店铺
for (Store store : this.list(new LambdaQueryWrapper<Store>().eq(Store::getDeleteFlag,false).eq(Store::getStoreDisable,StoreStatusEnum.OPEN.name()))) {
for (Store store : this.list(new LambdaQueryWrapper<Store>().eq(Store::getDeleteFlag, false).eq(Store::getStoreDisable, StoreStatusEnum.OPEN.name()))) {
clerkList.add(new Clerk(store));
}
clerkService.saveBatch(clerkList);
Expand Down

0 comments on commit 0eec406

Please sign in to comment.