银行搜索增加了分词功能
This commit is contained in:
parent
2d2b0364f0
commit
fe3a25b352
@ -102,19 +102,19 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
|
||||
<!-- <version>2.7.18</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
|
||||
<!-- <version>2.7.18</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <!– https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.data</groupId>-->
|
||||
<!-- <artifactId>spring-data-jpa</artifactId>-->
|
||||
<!-- <version>2.7.18</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.data</groupId>-->
|
||||
<!-- <artifactId>spring-data-jpa</artifactId>-->
|
||||
<!-- <version>2.7.18</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--excel工具-->
|
||||
<dependency>
|
||||
@ -274,6 +274,11 @@
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.huaban</groupId>
|
||||
<artifactId>jieba-analysis</artifactId>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<!-- 指定仓库为阿里云与阿帕奇 -->
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.utils;
|
||||
|
||||
import com.huaban.analysis.jieba.JiebaSegmenter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class JiebaUtils {
|
||||
|
||||
private final JiebaSegmenter segmenter = new JiebaSegmenter();
|
||||
|
||||
public static void main(String[] args) {
|
||||
JiebaUtils jiebaUtils = new JiebaUtils();
|
||||
String text = "中国工商银行桂平市光明支行";
|
||||
List<String> words = jiebaUtils.segmentForSearch(text);
|
||||
System.out.println(words);
|
||||
}
|
||||
|
||||
/**
|
||||
* 精确模式分词
|
||||
*/
|
||||
public List<String> segment(String text) {
|
||||
return segmenter.process(text, JiebaSegmenter.SegMode.INDEX)
|
||||
.stream()
|
||||
.map(token -> token.word)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索模式分词(更细粒度)
|
||||
*/
|
||||
public List<String> segmentForSearch(String text) {
|
||||
return segmenter.process(text, JiebaSegmenter.SegMode.SEARCH)
|
||||
.stream()
|
||||
.map(token -> token.word)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@ -29,11 +29,16 @@ public class IpUtil implements ApplicationRunner {
|
||||
log.error("IP2RegionUtils 没有成功加载数据文件");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (CheckUtil.isEmpty(ip)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return searcher.search(ip);
|
||||
} catch (Exception e) {
|
||||
log.error("IP:{} 格式错误:{}", ip, e);
|
||||
return null;
|
||||
log.error("IP:{} 格式错误:{}", ip, e.getMessage());
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,14 +13,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.modules.lakala.LklBanks;
|
||||
import com.suisung.mall.common.utils.JiebaUtils;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.lakala.mapper.LklBanksMapper;
|
||||
import com.suisung.mall.shop.lakala.service.LklBanksService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LklBanksServiceImpl extends BaseServiceImpl<LklBanksMapper, LklBanks> implements LklBanksService {
|
||||
|
||||
@Resource
|
||||
private JiebaUtils jiebaUtils;
|
||||
|
||||
/**
|
||||
* 根据关键字查询有效记录分页列表
|
||||
@ -43,14 +51,24 @@ public class LklBanksServiceImpl extends BaseServiceImpl<LklBanksMapper, LklBank
|
||||
|
||||
queryWrapper.eq("status", CommonConstant.Enable).orderByAsc("branch_bank_no");
|
||||
if (StrUtil.isNotBlank(keyword)) {
|
||||
queryWrapper.and(wrapper -> wrapper
|
||||
.like("branch_bank_name", keyword)
|
||||
.or()
|
||||
.like("branch_bank_no", keyword)
|
||||
.or()
|
||||
.like("clear_no", keyword)
|
||||
.or()
|
||||
.like("bank_no", keyword));
|
||||
List<String> keywordList = jiebaUtils.segmentForSearch(keyword);
|
||||
log.info("分词后的关键词:{}", keywordList);
|
||||
queryWrapper.and(wrapper -> {
|
||||
// wrapper.like("branch_bank_name", keyword)
|
||||
// .or()
|
||||
// .like("branch_bank_no", keyword)
|
||||
// .or()
|
||||
// .like("clear_no", keyword)
|
||||
// .or()
|
||||
// .like("bank_no", keyword);
|
||||
|
||||
// 再添加分词后的关键词条件
|
||||
|
||||
for (String kw : keywordList) {
|
||||
wrapper.like("branch_bank_name", kw);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return lists(queryWrapper, pageNum, pageSize);
|
||||
|
||||
@ -131,7 +131,8 @@ public class LklTkServiceImpl {
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("Base64 解码时出现非法参数异常: ", e.getMessage());
|
||||
} catch (Exception e) {
|
||||
// 捕获其他可能的异常,如 NoSuchAlgorithmException、NoSuchPaddingException、InvalidKeySpecException、InvalidKeyException、BadPaddingException 等
|
||||
// 捕获其他可能的异常,如 NoSuchAlgorithmException、NoSuchPaddingException、
|
||||
// InvalidKeySpecException、InvalidKeyException、BadPaddingException 等
|
||||
logger.error("解密过程中出现异常: ", e.getMessage());
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ public class LklTkServiceImpl {
|
||||
header.put("Authorization", getLklTkAuthorization());
|
||||
|
||||
// 获取商家入驻信息,组成请求参数
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByCondition(mchMobile, bizLicenseNumber, CommonConstant.MCH_APPR_STA_LKL_PADDING);
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByCondition(mchMobile, bizLicenseNumber, CommonConstant.MCH_APPR_STA_PASS, CommonConstant.MCH_APPR_STA_LKL_PADDING);
|
||||
if (ObjectUtil.isEmpty(shopMchEntry)) {
|
||||
return Pair.of(false, "商家入驻信息不存在");
|
||||
}
|
||||
@ -425,12 +426,14 @@ public class LklTkServiceImpl {
|
||||
JSONObject bizContent = new JSONObject();
|
||||
bizContent.put("activityId", 687);
|
||||
bizContent.put("termNum", "1");
|
||||
bizContent.put("mcc", "5311"); // 超市的 code
|
||||
bizContent.put("mcc", "12015"); // 超市的 code
|
||||
bizContent.put("fees", new JSONArray() {{
|
||||
put(new JSONObject() {{
|
||||
put("feeCode", "WECHAT");
|
||||
put("feeValue", 0.38);
|
||||
}});
|
||||
put(new JSONObject() {
|
||||
{
|
||||
put("feeCode", "WECHAT");
|
||||
put("feeValue", 0.6);
|
||||
}
|
||||
});
|
||||
}});
|
||||
formData.put("bizContent", bizContent);
|
||||
|
||||
@ -526,17 +529,21 @@ public class LklTkServiceImpl {
|
||||
|
||||
JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody);
|
||||
if (reqBodyJSON.isEmpty() || reqBodyJSON.get("data") == null) {
|
||||
return new JSONObject().set("code", "500").set("message", "参数格式有误");
|
||||
return new JSONObject().set("code", "500").set("message", "参数格式有误,无法解析");
|
||||
}
|
||||
|
||||
String srcData = reqBodyJSON.getStr("data");
|
||||
if (StrUtil.isBlank(srcData)) {
|
||||
return new JSONObject().set("code", "500").set("message", "关键参数为空值");
|
||||
}
|
||||
|
||||
// 公钥解密出来的数据
|
||||
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath);
|
||||
logger.debug("解密公钥:{}", notifyPubKey);
|
||||
String data = decryptNotifyData(notifyPubKey, reqBodyJSON.getStr("data"));
|
||||
logger.debug("拉卡拉进件异步通知返回解密后的参数:{}", data);
|
||||
|
||||
String data = decryptNotifyData(notifyPubKey, srcData);
|
||||
logger.debug("拉卡拉进件异步通知返回 data 数据:{}, 解密后的 data 数据:{}", srcData, data);
|
||||
if (StrUtil.isBlank(data)) {
|
||||
return new JSONObject().set("code", "500").set("message", "参数解密出错");
|
||||
return new JSONObject().set("code", "500").set("message", "无法解密出 data 参数");
|
||||
}
|
||||
|
||||
// 逻辑处理
|
||||
@ -548,7 +555,6 @@ public class LklTkServiceImpl {
|
||||
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
|
||||
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
|
||||
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
|
||||
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
|
||||
if (ObjectUtil.isEmpty(shopMchEntry)) {
|
||||
return new JSONObject().set("code", "500").set("message", "商户入驻信息不存在");
|
||||
|
||||
@ -103,10 +103,10 @@ public interface ShopMchEntryService {
|
||||
*
|
||||
* @param loginMobile
|
||||
* @param bizLicenseNumber
|
||||
* @param approvalStatus
|
||||
* @param approvalStatusList
|
||||
* @return
|
||||
*/
|
||||
ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer approvalStatus);
|
||||
ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer... approvalStatusList);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -42,10 +42,7 @@ import org.springframework.data.util.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 商家入驻申请表
|
||||
@ -634,12 +631,12 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
*
|
||||
* @param loginMobile
|
||||
* @param bizLicenseNumber
|
||||
* @param approvalStatus
|
||||
* @param approvalStatusList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer approvalStatus) {
|
||||
if (StrUtil.isBlank(loginMobile) && StrUtil.isBlank(bizLicenseNumber) && ObjectUtil.isEmpty(approvalStatus)) {
|
||||
public ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer... approvalStatusList) {
|
||||
if (StrUtil.isBlank(loginMobile) && StrUtil.isBlank(bizLicenseNumber) && ObjectUtil.isEmpty(approvalStatusList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -653,12 +650,11 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
queryWrapper.eq("biz_license_number", bizLicenseNumber);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(approvalStatus)) {
|
||||
queryWrapper.eq("approval_status", approvalStatus);
|
||||
if (ObjectUtil.isNotEmpty(approvalStatusList)) {
|
||||
queryWrapper.in("approval_status", Arrays.stream(approvalStatusList).toArray());
|
||||
}
|
||||
|
||||
// todo 合同签署状态条件
|
||||
|
||||
List<ShopMchEntry> recordList = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(recordList)) {
|
||||
return null;
|
||||
@ -744,7 +740,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("login_mobile", loginMobile);
|
||||
if (ObjectUtil.isNotEmpty(lklAuditStatus)) {
|
||||
updateWrapper.set("lkl_audit_status", lklAuditStatus);
|
||||
updateWrapper.set("lkl_tk_audit_status", lklAuditStatus);
|
||||
}
|
||||
if (StrUtil.isNotBlank(lklMerCupNo)) {
|
||||
updateWrapper.set("lkl_mer_cup_no", lklMerCupNo); // 银联商户号
|
||||
@ -778,7 +774,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("lkl_mer_inner_no", lklInnerMerNo);
|
||||
if (ObjectUtil.isNotEmpty(lklAuditStatus)) {
|
||||
updateWrapper.set("lkl_audit_status", lklAuditStatus);
|
||||
updateWrapper.set("lkl_tk_audit_status", lklAuditStatus);
|
||||
}
|
||||
|
||||
// 商家入驻审核正式通过
|
||||
|
||||
Loading…
Reference in New Issue
Block a user