银行搜索增加了分词功能

This commit is contained in:
Jack 2025-05-12 23:29:16 +08:00
parent 2d2b0364f0
commit fe3a25b352
7 changed files with 127 additions and 49 deletions

View File

@ -102,19 +102,19 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa &ndash;&gt;--> <!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa &ndash;&gt;-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>--> <!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!-- <version>2.7.18</version>--> <!-- <version>2.7.18</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa &ndash;&gt;--> <!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa &ndash;&gt;-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.data</groupId>--> <!-- <groupId>org.springframework.data</groupId>-->
<!-- <artifactId>spring-data-jpa</artifactId>--> <!-- <artifactId>spring-data-jpa</artifactId>-->
<!-- <version>2.7.18</version>--> <!-- <version>2.7.18</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<!--excel工具--> <!--excel工具-->
<dependency> <dependency>
@ -274,6 +274,11 @@
<artifactId>spring-boot-starter-freemarker</artifactId> <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.huaban</groupId>
<artifactId>jieba-analysis</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies> </dependencies>
<!-- 指定仓库为阿里云与阿帕奇 --> <!-- 指定仓库为阿里云与阿帕奇 -->

View File

@ -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());
}
}

View File

@ -29,11 +29,16 @@ public class IpUtil implements ApplicationRunner {
log.error("IP2RegionUtils 没有成功加载数据文件"); log.error("IP2RegionUtils 没有成功加载数据文件");
return null; return null;
} }
if (CheckUtil.isEmpty(ip)) {
return null;
}
try { try {
return searcher.search(ip); return searcher.search(ip);
} catch (Exception e) { } catch (Exception e) {
log.error("IP{} 格式错误:{}", ip, e); log.error("IP{} 格式错误:{}", ip, e.getMessage());
return null; return ip;
} }
} }

View File

@ -13,14 +13,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.suisung.mall.common.constant.CommonConstant; import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.modules.lakala.LklBanks; 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.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.lakala.mapper.LklBanksMapper; import com.suisung.mall.shop.lakala.mapper.LklBanksMapper;
import com.suisung.mall.shop.lakala.service.LklBanksService; import com.suisung.mall.shop.lakala.service.LklBanksService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Service @Service
public class LklBanksServiceImpl extends BaseServiceImpl<LklBanksMapper, LklBanks> implements LklBanksService { 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"); queryWrapper.eq("status", CommonConstant.Enable).orderByAsc("branch_bank_no");
if (StrUtil.isNotBlank(keyword)) { if (StrUtil.isNotBlank(keyword)) {
queryWrapper.and(wrapper -> wrapper List<String> keywordList = jiebaUtils.segmentForSearch(keyword);
.like("branch_bank_name", keyword) log.info("分词后的关键词:{}", keywordList);
.or() queryWrapper.and(wrapper -> {
.like("branch_bank_no", keyword) // wrapper.like("branch_bank_name", keyword)
.or() // .or()
.like("clear_no", keyword) // .like("branch_bank_no", keyword)
.or() // .or()
.like("bank_no", keyword)); // .like("clear_no", keyword)
// .or()
// .like("bank_no", keyword);
// 再添加分词后的关键词条件
for (String kw : keywordList) {
wrapper.like("branch_bank_name", kw);
}
});
} }
return lists(queryWrapper, pageNum, pageSize); return lists(queryWrapper, pageNum, pageSize);

View File

@ -131,7 +131,8 @@ public class LklTkServiceImpl {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
logger.error("Base64 解码时出现非法参数异常: ", e.getMessage()); logger.error("Base64 解码时出现非法参数异常: ", e.getMessage());
} catch (Exception e) { } catch (Exception e) {
// 捕获其他可能的异常 NoSuchAlgorithmExceptionNoSuchPaddingExceptionInvalidKeySpecExceptionInvalidKeyExceptionBadPaddingException // 捕获其他可能的异常 NoSuchAlgorithmExceptionNoSuchPaddingException
// InvalidKeySpecExceptionInvalidKeyExceptionBadPaddingException
logger.error("解密过程中出现异常: ", e.getMessage()); logger.error("解密过程中出现异常: ", e.getMessage());
} }
@ -337,7 +338,7 @@ public class LklTkServiceImpl {
header.put("Authorization", getLklTkAuthorization()); 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)) { if (ObjectUtil.isEmpty(shopMchEntry)) {
return Pair.of(false, "商家入驻信息不存在"); return Pair.of(false, "商家入驻信息不存在");
} }
@ -425,12 +426,14 @@ public class LklTkServiceImpl {
JSONObject bizContent = new JSONObject(); JSONObject bizContent = new JSONObject();
bizContent.put("activityId", 687); bizContent.put("activityId", 687);
bizContent.put("termNum", "1"); bizContent.put("termNum", "1");
bizContent.put("mcc", "5311"); // 超市的 code bizContent.put("mcc", "12015"); // 超市的 code
bizContent.put("fees", new JSONArray() {{ bizContent.put("fees", new JSONArray() {{
put(new JSONObject() {{ put(new JSONObject() {
put("feeCode", "WECHAT"); {
put("feeValue", 0.38); put("feeCode", "WECHAT");
}}); put("feeValue", 0.6);
}
});
}}); }});
formData.put("bizContent", bizContent); formData.put("bizContent", bizContent);
@ -526,17 +529,21 @@ public class LklTkServiceImpl {
JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody); JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody);
if (reqBodyJSON.isEmpty() || reqBodyJSON.get("data") == null) { 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); String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath);
logger.debug("解密公钥:{}", notifyPubKey); logger.debug("解密公钥:{}", notifyPubKey);
String data = decryptNotifyData(notifyPubKey, reqBodyJSON.getStr("data")); String data = decryptNotifyData(notifyPubKey, srcData);
logger.debug("拉卡拉进件异步通知返回解密后的参数:{}", data); logger.debug("拉卡拉进件异步通知返回 data 数据:{}, 解密后的 data 数据:{}", srcData, data);
if (StrUtil.isBlank(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 merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号 String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo); ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
if (ObjectUtil.isEmpty(shopMchEntry)) { if (ObjectUtil.isEmpty(shopMchEntry)) {
return new JSONObject().set("code", "500").set("message", "商户入驻信息不存在"); return new JSONObject().set("code", "500").set("message", "商户入驻信息不存在");

View File

@ -103,10 +103,10 @@ public interface ShopMchEntryService {
* *
* @param loginMobile * @param loginMobile
* @param bizLicenseNumber * @param bizLicenseNumber
* @param approvalStatus * @param approvalStatusList
* @return * @return
*/ */
ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer approvalStatus); ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer... approvalStatusList);
/** /**

View File

@ -42,10 +42,7 @@ import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 商家入驻申请表 * 商家入驻申请表
@ -634,12 +631,12 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
* *
* @param loginMobile * @param loginMobile
* @param bizLicenseNumber * @param bizLicenseNumber
* @param approvalStatus * @param approvalStatusList
* @return * @return
*/ */
@Override @Override
public ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer approvalStatus) { public ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer... approvalStatusList) {
if (StrUtil.isBlank(loginMobile) && StrUtil.isBlank(bizLicenseNumber) && ObjectUtil.isEmpty(approvalStatus)) { if (StrUtil.isBlank(loginMobile) && StrUtil.isBlank(bizLicenseNumber) && ObjectUtil.isEmpty(approvalStatusList)) {
return null; return null;
} }
@ -653,12 +650,11 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
queryWrapper.eq("biz_license_number", bizLicenseNumber); queryWrapper.eq("biz_license_number", bizLicenseNumber);
} }
if (ObjectUtil.isNotEmpty(approvalStatus)) { if (ObjectUtil.isNotEmpty(approvalStatusList)) {
queryWrapper.eq("approval_status", approvalStatus); queryWrapper.in("approval_status", Arrays.stream(approvalStatusList).toArray());
} }
// todo 合同签署状态条件 // todo 合同签署状态条件
List<ShopMchEntry> recordList = list(queryWrapper); List<ShopMchEntry> recordList = list(queryWrapper);
if (CollectionUtil.isEmpty(recordList)) { if (CollectionUtil.isEmpty(recordList)) {
return null; return null;
@ -744,7 +740,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("login_mobile", loginMobile); updateWrapper.eq("login_mobile", loginMobile);
if (ObjectUtil.isNotEmpty(lklAuditStatus)) { if (ObjectUtil.isNotEmpty(lklAuditStatus)) {
updateWrapper.set("lkl_audit_status", lklAuditStatus); updateWrapper.set("lkl_tk_audit_status", lklAuditStatus);
} }
if (StrUtil.isNotBlank(lklMerCupNo)) { if (StrUtil.isNotBlank(lklMerCupNo)) {
updateWrapper.set("lkl_mer_cup_no", lklMerCupNo); // 银联商户号 updateWrapper.set("lkl_mer_cup_no", lklMerCupNo); // 银联商户号
@ -778,7 +774,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("lkl_mer_inner_no", lklInnerMerNo); updateWrapper.eq("lkl_mer_inner_no", lklInnerMerNo);
if (ObjectUtil.isNotEmpty(lklAuditStatus)) { if (ObjectUtil.isNotEmpty(lklAuditStatus)) {
updateWrapper.set("lkl_audit_status", lklAuditStatus); updateWrapper.set("lkl_tk_audit_status", lklAuditStatus);
} }
// 商家入驻审核正式通过 // 商家入驻审核正式通过