Merge branch 'master' of gitee.com:super-shopkeeper/chaozhanggui
This commit is contained in:
@@ -2,6 +2,7 @@ package cn.pluss.platform.configurer;
|
|||||||
|
|
||||||
import cn.pluss.platform.configurer.extend.CurrentUserMethodArgumentResolver;
|
import cn.pluss.platform.configurer.extend.CurrentUserMethodArgumentResolver;
|
||||||
import cn.pluss.platform.configurer.extend.FastJsonHttpMessageConverterEx;
|
import cn.pluss.platform.configurer.extend.FastJsonHttpMessageConverterEx;
|
||||||
|
import cn.pluss.platform.interceptor.EmojiInterceptor;
|
||||||
import cn.pluss.platform.interceptor.RequestInfoInterceptor;
|
import cn.pluss.platform.interceptor.RequestInfoInterceptor;
|
||||||
import cn.pluss.platform.interceptor.TokenRegistryInterceptor;
|
import cn.pluss.platform.interceptor.TokenRegistryInterceptor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -72,6 +73,7 @@ public class WebConfigurer implements WebMvcConfigurer {
|
|||||||
registry.addInterceptor(new RequestInfoInterceptor());
|
registry.addInterceptor(new RequestInfoInterceptor());
|
||||||
|
|
||||||
registry.addInterceptor(tokenRegistryInterceptor()).excludePathPatterns(excludes);
|
registry.addInterceptor(tokenRegistryInterceptor()).excludePathPatterns(excludes);
|
||||||
|
registry.addInterceptor(emojiInterceptor()).excludePathPatterns(excludes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@@ -88,4 +90,8 @@ public class WebConfigurer implements WebMvcConfigurer {
|
|||||||
public FastJsonHttpMessageConverterEx fastJsonHttpMessageConverterEx() {
|
public FastJsonHttpMessageConverterEx fastJsonHttpMessageConverterEx() {
|
||||||
return new FastJsonHttpMessageConverterEx();
|
return new FastJsonHttpMessageConverterEx();
|
||||||
}
|
}
|
||||||
|
@Bean
|
||||||
|
public EmojiInterceptor emojiInterceptor() {
|
||||||
|
return new EmojiInterceptor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package cn.pluss.platform.interceptor;
|
||||||
|
|
||||||
|
import cn.pluss.platform.exception.MsgException;
|
||||||
|
import cn.pluss.platform.util.Emoji;
|
||||||
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lyf
|
||||||
|
*/
|
||||||
|
public class EmojiInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
BufferedReader reader = request.getReader();
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
sb.append(line);
|
||||||
|
}
|
||||||
|
String body = sb.toString();
|
||||||
|
boolean emoji = Emoji.containsEmoji(body);
|
||||||
|
if (emoji) {
|
||||||
|
throw new MsgException("请正确输入");//这里是我自己封装了一个异常,根据自己需要写自己的异常
|
||||||
|
}
|
||||||
|
return super.preHandle(request, response, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -57,6 +57,7 @@ public class TokenRegistryInterceptor extends HandlerInterceptorAdapter {
|
|||||||
limitUri.add("/api/index.html");
|
limitUri.add("/api/index.html");
|
||||||
limitUri.add("/api/merchantOrder/posScanPay");
|
limitUri.add("/api/merchantOrder/posScanPay");
|
||||||
limitUri.add("/api/merchantOrder/pos/tradeQuery");
|
limitUri.add("/api/merchantOrder/pos/tradeQuery");
|
||||||
|
limitUri.add("/api/merchantOrder/returnOrder");
|
||||||
boolean passFlag = limitUri.stream().anyMatch(s -> s.equals(requestUri) || requestUri.startsWith(s));
|
boolean passFlag = limitUri.stream().anyMatch(s -> s.equals(requestUri) || requestUri.startsWith(s));
|
||||||
if (passFlag) {
|
if (passFlag) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package cn.pluss.platform.util;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class Emoji {
|
||||||
|
/**
|
||||||
|
* @Description: 是否有表情判断
|
||||||
|
* @author zhaopeng
|
||||||
|
* @email zp152527@163.com
|
||||||
|
* @date 2018/8/24 18:27
|
||||||
|
*/
|
||||||
|
public static boolean containsEmoji(String source) {
|
||||||
|
int len = source.length();
|
||||||
|
boolean isEmoji = false;
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
char hs = source.charAt(i);
|
||||||
|
if (0xd800 <= hs && hs <= 0xdbff) {
|
||||||
|
if (source.length() > 1) {
|
||||||
|
char ls = source.charAt(i + 1);
|
||||||
|
int uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
|
||||||
|
if (0x1d000 <= uc && uc <= 0x1f77f) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// non surrogate
|
||||||
|
if (0x2100 <= hs && hs <= 0x27ff && hs != 0x263b) {
|
||||||
|
return true;
|
||||||
|
} else if (0x2B05 <= hs && hs <= 0x2b07) {
|
||||||
|
return true;
|
||||||
|
} else if (0x2934 <= hs && hs <= 0x2935) {
|
||||||
|
return true;
|
||||||
|
} else if (0x3297 <= hs && hs <= 0x3299) {
|
||||||
|
return true;
|
||||||
|
} else if (hs == 0xa9 || hs == 0xae || hs == 0x303d
|
||||||
|
|| hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c
|
||||||
|
|| hs == 0x2b1b || hs == 0x2b50 || hs == 0x231a) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!isEmoji && source.length() > 1 && i < source.length() - 1) {
|
||||||
|
char ls = source.charAt(i + 1);
|
||||||
|
if (ls == 0x20e3) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isEmoji;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isEmojiCharacter(char codePoint) {
|
||||||
|
return (codePoint == 0x0) || (codePoint == 0x9) || (codePoint == 0xA)
|
||||||
|
|| (codePoint == 0xD)
|
||||||
|
|| ((codePoint >= 0x20) && (codePoint <= 0xD7FF))
|
||||||
|
|| ((codePoint >= 0xE000) && (codePoint <= 0xFFFD))
|
||||||
|
|| ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 过滤emoji 或者 其他非文字类型的字符
|
||||||
|
* @author zhaopeng
|
||||||
|
* @email zp152527@163.com
|
||||||
|
* @date 2018/8/24 18:27
|
||||||
|
*/
|
||||||
|
public static String filterEmoji(String source) {
|
||||||
|
if (StringUtils.isBlank(source)) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
StringBuilder buf = null;
|
||||||
|
int len = source.length();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
char codePoint = source.charAt(i);
|
||||||
|
if (isEmojiCharacter(codePoint)) {
|
||||||
|
if (buf == null) {
|
||||||
|
buf = new StringBuilder(source.length());
|
||||||
|
}
|
||||||
|
buf.append(codePoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buf == null) {
|
||||||
|
return source;
|
||||||
|
} else {
|
||||||
|
if (buf.length() == len) {
|
||||||
|
buf = null;
|
||||||
|
return source;
|
||||||
|
} else {
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -404,13 +404,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
}
|
}
|
||||||
//TODO
|
//TODO
|
||||||
// 如果不存在D1的结算信息,则直接将D0的结算信息带过来
|
// 如果不存在D1的结算信息,则直接将D0的结算信息带过来
|
||||||
// LambdaQueryWrapper<Account> qWrapperAccountD0 = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<Account> qWrapperAccountD0 = Wrappers.lambdaQuery();
|
||||||
// qWrapperAccountD0.eq(Account::getUserId, accountDTO.getUserId()).eq(Account::getChannelType, Account.CHANNEL_TYPE_D1);
|
qWrapperAccountD0.eq(Account::getUserId, accountDTO.getUserId()).eq(Account::getChannelType, Account.CHANNEL_TYPE_D1);
|
||||||
// int countD0 = baseMapper.selectCount(qWrapperAccountD0);
|
int countD0 = baseMapper.selectCount(qWrapperAccountD0);
|
||||||
// if (countD0 == 0) {
|
if (countD0 == 0) {
|
||||||
// account.setChannelType(Account.CHANNEL_TYPE_D1);
|
account.setChannelType(Account.CHANNEL_TYPE_D1);
|
||||||
// save(account);
|
save(account);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.pluss.platform.pay.impl;
|
package cn.pluss.platform.pay.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.json.JSON;
|
||||||
import cn.pluss.platform.api.Result;
|
import cn.pluss.platform.api.Result;
|
||||||
import cn.pluss.platform.api.ResultCode;
|
import cn.pluss.platform.api.ResultCode;
|
||||||
import cn.pluss.platform.api.ResultGenerator;
|
import cn.pluss.platform.api.ResultGenerator;
|
||||||
@@ -154,7 +155,7 @@ public class ApiPayServiceImpl implements ApiPayService {
|
|||||||
checSign(jsonObject,jsonObject.getString("merchantCode"));
|
checSign(jsonObject,jsonObject.getString("merchantCode"));
|
||||||
store = checkTransPayParams(jsonObject,jsonObject.getString("merchantCode"));
|
store = checkTransPayParams(jsonObject,jsonObject.getString("merchantCode"));
|
||||||
}
|
}
|
||||||
String payData = checkMercOrder(store,jsonObject);
|
String payData = checkMercOrder(store, jsonObject);
|
||||||
if(StringUtil.isNotEmpty(payData)){
|
if(StringUtil.isNotEmpty(payData)){
|
||||||
return payData;
|
return payData;
|
||||||
}
|
}
|
||||||
@@ -233,13 +234,15 @@ public class ApiPayServiceImpl implements ApiPayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String checkMercOrder(MerchantStore store,JSONObject jsonObject) {
|
private String checkMercOrder(MerchantStore store, JSONObject jsonObject) {
|
||||||
QueryWrapper<MerchantOrder> queryMercWrapper = new QueryWrapper<MerchantOrder>().eq("mercOrderNo", jsonObject.getString("mercOrderNo"));
|
QueryWrapper<MerchantOrder> queryMercWrapper = new QueryWrapper<MerchantOrder>().eq("mercOrderNo", jsonObject.getString("mercOrderNo"));
|
||||||
List<MerchantOrder> list = merchantOrderService.list(queryMercWrapper);
|
List<MerchantOrder> list = merchantOrderService.list(queryMercWrapper);
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
MerchantOrder order = list.get(0);
|
MerchantOrder order = list.get(0);
|
||||||
if(StringUtil.isNotEmpty(order.getPayData())){
|
if(StringUtil.isNotEmpty(order.getPayData())){
|
||||||
return order.getPayData();
|
StringBuilder payData = new StringBuilder(order.getPayData());
|
||||||
|
payData.insert(payData.length()-1,",\"orderNumber\":"+"\""+order.getOrderNumber()+"\"");
|
||||||
|
return payData.toString();
|
||||||
}
|
}
|
||||||
throw new MsgException("订单号重复!");
|
throw new MsgException("订单号重复!");
|
||||||
}
|
}
|
||||||
@@ -443,6 +446,7 @@ public class ApiPayServiceImpl implements ApiPayService {
|
|||||||
order.setPayData(payData.toJSONString());
|
order.setPayData(payData.toJSONString());
|
||||||
merchantOrderService.save(order);
|
merchantOrderService.save(order);
|
||||||
payData.put("payAmt",order.getConsumeFee().toString());
|
payData.put("payAmt",order.getConsumeFee().toString());
|
||||||
|
payData.put("orderNumber", order.getOrderNumber().toString());
|
||||||
return ResultGenerator.genSuccessJsonResult("处理成功", payData);
|
return ResultGenerator.genSuccessJsonResult("处理成功", payData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user