7 Commits
pg ... master

Author SHA1 Message Date
pikachu1995@126.com
b5b1c38f71 docs(readme): 更新README文档链接和社区支持信息
- 移除了聚合版相关说明
-修正了部署文档的链接地址
- 更新了社区支持部分,添加在线客服和微信群信息
- 调整了文档中的联系方式展示方式
2025-10-20 14:49:54 +08:00
pikachu1995@126.com
e1f834313a feat(search): 新增ES商品索引管理功能
- 添加删除下架商品索引接口
- 实现清理无效SKU索引逻辑
- 增加商品缓存生成功能
- 扩展商品搜索服务方法
-优化商品详情缓存时间配置
- 新增ES删除参数传输对象EsDeleteDTO
2025-10-20 13:35:00 +08:00
pikachu1995@126.com
dedcc0a556 refactor(payment): 统一使用标准库进行URL编解码
- 将支付宝插件中的Hutool URLEncoder替换为java.net.URLEncoder- 将支付宝插件中的Hutool URLDecoder替换为java.net.URLDecoder
- 在微信支付插件中统一使用标准库进行URL编解码
- 处理UnsupportedEncodingException异常情况- 更新相关注释和日志信息以反映变更
2025-10-11 18:50:44 +08:00
pikachu1995@126.com
33fcce1cc9 refactor(core):优化字符串比较逻辑以提高代码健壮性
- 将多个equals方法调用改为常量在前的写法,避免空指针异常
- 统一了所有字符串比较的格式,增强代码可读性和一致性- 修复潜在的NPE风险,提升系统稳定性
2025-10-11 18:19:52 +08:00
pikachu1995@126.com
85c8c5d021 style(logistics): 格式化顺丰插件代码- 移除了多余的@Component注解- 统一了if语句中的空格格式
- 调整了方法参数间的空格
- 修正了对象创建时的空格问题
- 规范了变量声明时的空格- 优化了代码缩进和换行- 修正了方法调用时的空格问题
- 统一了布尔值比较的格式
- 修正了JSON数据处理时的空格- 优化了代码注释的格式- 修正了sendPost方法中的工具类调用方式
2025-10-11 18:10:14 +08:00
pikachu1995@126.com
2ab2c4ff5d feat(sms): 华为短信插件信任所有HTTPS证书- 在华为短信插件中添加X509TrustManager实现
- 覆盖checkClientTrusted方法以跳过客户端证书验证
- 覆盖checkServerTrusted方法以跳过服务端证书验证- 实现getAcceptedIssuers方法返回null以接受所有颁发者
- 为所有新增方法添加@Override注解确保正确重写

fix(im): 补充IM对话服务实现注解

-为getTalkByUser方法添加@Override注解

fix(member): 补充会员服务实现注解

- 为modifyPass方法添加@Override注解

fix(promotion): 补充促销服务实现注解- 为getGoodsSkuPromotionMap方法添加@Override注解
- 为wrapperPromotionMapList方法添加@Override注解

fix(system): 补充地区服务实现注解- 为updateById方法添加@Override注解
-为save方法添加@Override注解

fix(logistics): 补充顺丰物流插件实现注解

- 为createOrder方法添加@Override注解
2025-10-11 18:07:39 +08:00
OceansDeep
feff49c79b !368 Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop into pg
Merge pull request !368 from OceansDeep/pg
2025-10-11 02:51:24 +00:00
31 changed files with 549 additions and 246 deletions

View File

@@ -18,7 +18,6 @@
- **Gitee 仓库**: <https://gitee.com/beijing_hongye_huicheng/lilishop> - **Gitee 仓库**: <https://gitee.com/beijing_hongye_huicheng/lilishop>
- **GitHub 仓库**: <https://github.com/lilishop/lilishop> - **GitHub 仓库**: <https://github.com/lilishop/lilishop>
> **聚合版**: 为简化部署我们提供了API聚合版仅需启动单个JAR包即可运行。详情请访问[lilishop-simplify](https://gitee.com/beijing_hongye_huicheng/lilishop-simplify)
--- ---
@@ -53,7 +52,7 @@
#### 环境准备与部署 #### 环境准备与部署
详细的本地部署指南,请参考官方文档: 详细的本地部署指南,请参考官方文档:
[**部署文档 -> 环境准备**](https://docs.pickmall.cn/deploy/%E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83%E5%87%86%E5%A4%87.html) [**部署文档 -> 环境准备**](https://docs.pickmall.cn/deply/deply.html)
#### 数据库初始化 #### 数据库初始化
- **推荐方式**: 使用项目提供的 `docker-compose` 配置可自动完成数据库MySQL, Redis, Elasticsearch等的部署与初始化。 - **推荐方式**: 使用项目提供的 `docker-compose` 配置可自动完成数据库MySQL, Redis, Elasticsearch等的部署与初始化。
@@ -156,9 +155,11 @@
### 9. 社区与支持 ### 9. 社区与支持
我们欢迎任何形式的交流与贡献。在提问前,请先查阅 [官方文档](https://docs.pickmall.cn/) 和 [常见问题](https://docs.pickmall.cn/faq/常见问题.html),并参考 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md) 以便高效沟通。 我们欢迎任何形式的交流与贡献。在提问前,请先查阅 [官方文档](https://docs.pickmall.cn/) ,并参考 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md) 以便高效沟通。
- **微信交流群**: - **[在线客服](https://work.weixin.qq.com/kfid/kfc4d8dc24a73c15f44)**
- **微信交流1群已满**
- **微信交流2群**:
![微信群](https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/wechat.jpg) ![微信群](https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/wechat.jpg)
- **社区贡献内容**: - **社区贡献内容**:

View File

@@ -91,15 +91,16 @@ public class BuyerAuthenticationFilter extends BasicAuthenticationFilter {
try { try {
Claims claims Claims claims
= Jwts.parser() = Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders()) .setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(jwt).getBody(); .parseClaimsJws(jwt).getBody();
//获取存储在claims中的用户信息 // 获取存储在claims中的用户信息
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString(); String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();
AuthUser authUser = new Gson().fromJson(json, AuthUser.class); AuthUser authUser = new Gson().fromJson(json, AuthUser.class);
//校验redis中是否有权限 //校验redis中是否有权限
if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER,authUser.getId()) + jwt)) { if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER, authUser.getId()) + jwt)) {
//构造返回信息 //构造返回信息
List<GrantedAuthority> auths = new ArrayList<>(); List<GrantedAuthority> auths = new ArrayList<>();
auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name())); auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name()));

View File

@@ -164,7 +164,8 @@ public class GlobalControllerExceptionHandler {
if (!fieldErrors.isEmpty()) { if (!fieldErrors.isEmpty()) {
return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), return ResultUtil.error(ResultCode.PARAMS_ERROR.code(),
fieldErrors.stream() fieldErrors.stream()
.map(FieldError::getDefaultMessage) // 获取每个对象的名称字段 // 获取每个对象的名称字段
.map(FieldError::getDefaultMessage)
.collect(Collectors.joining(", "))); .collect(Collectors.joining(", ")));
} }
return ResultUtil.error(ResultCode.PARAMS_ERROR); return ResultUtil.error(ResultCode.PARAMS_ERROR);
@@ -187,6 +188,7 @@ public class GlobalControllerExceptionHandler {
ConstraintViolationException exception = (ConstraintViolationException) e; ConstraintViolationException exception = (ConstraintViolationException) e;
return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), exception.getMessage()); return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), exception.getMessage());
} }
/** /**
* 拼接错误消息 * 拼接错误消息
* *

View File

@@ -92,8 +92,9 @@ public class UserContext {
try { try {
//获取token的信息 //获取token的信息
Claims claims Claims claims
= Jwts.parser() = Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders()) .setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(accessToken).getBody(); .parseClaimsJws(accessToken).getBody();
//获取存储在claims中的用户信息 //获取存储在claims中的用户信息
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString(); String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();

View File

@@ -144,7 +144,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
public ServletInputStream getInputStream() throws IOException { public ServletInputStream getInputStream() throws IOException {
BufferedReader bufferedReader = null; BufferedReader bufferedReader = null;
InputStreamReader reader = null; InputStreamReader reader = null;
//获取输入流 //获取输入流
@@ -163,9 +162,16 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
//继续读取下一行流直到line为空 //继续读取下一行流直到line为空
line = bufferedReader.readLine(); line = bufferedReader.readLine();
} }
if (CharSequenceUtil.isNotEmpty(body) && Boolean.TRUE.equals(JSONUtil.isJsonObj(body.toString()))) {
//将body转换为map // 兼容替换:不再使用过时的 JSONUtil.isJsonObj(String),改为尝试解析并捕获异常
Map<String, Object> map = JSONUtil.parseObj(body.toString()); if (CharSequenceUtil.isNotEmpty(body)) {
Map<String, Object> map = null;
try {
map = JSONUtil.parseObj(body.toString());
} catch (Exception ignore) {
map = null;
}
if (map != null) {
//创建空的map用于存储结果 //创建空的map用于存储结果
Map<String, Object> resultMap = new HashMap<>(map.size()); Map<String, Object> resultMap = new HashMap<>(map.size());
//遍历数组 //遍历数组
@@ -205,6 +211,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
} }
}; };
} }
}
//将json字符串转换为字节 //将json字符串转换为字节
final ByteArrayInputStream bis = new ByteArrayInputStream(body.toString().getBytes()); final ByteArrayInputStream bis = new ByteArrayInputStream(body.toString().getBytes());

View File

@@ -65,8 +65,9 @@ public class TokenUtil {
Claims claims; Claims claims;
try { try {
claims = Jwts.parser() claims = Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders()) .setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(oldRefreshToken).getBody(); .parseClaimsJws(oldRefreshToken).getBody();
} catch (ExpiredJwtException | UnsupportedJwtException | MalformedJwtException | SignatureException | } catch (ExpiredJwtException | UnsupportedJwtException | MalformedJwtException | SignatureException |
IllegalArgumentException e) { IllegalArgumentException e) {

View File

@@ -90,7 +90,8 @@ public abstract class BaseElasticsearchService {
request.settings(Settings.builder() request.settings(Settings.builder()
.put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards()) .put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards())
.put("index.number_of_replicas", elasticsearchProperties.getIndex().getNumberOfReplicas()) .put("index.number_of_replicas", elasticsearchProperties.getIndex().getNumberOfReplicas())
.put("index.max_result_window", 100000) //最大查询结果数 //最大查询结果数
.put("index.max_result_window", 100000)
.put("index.mapping.total_fields.limit", 2000)); .put("index.mapping.total_fields.limit", 2000));
//创建索引 //创建索引

View File

@@ -205,7 +205,7 @@ public class GoodsImportServiceImpl implements GoodsImportService {
goodsImportDTO.setCategory(category); goodsImportDTO.setCategory(category);
goodsImportDTO.setTemplate(templateId); goodsImportDTO.setTemplate(templateId);
goodsImportDTO.setGoodsUnit(objects.get(4).toString().substring(objects.get(4).toString().indexOf("-") + 1)); goodsImportDTO.setGoodsUnit(objects.get(4).toString().substring(objects.get(4).toString().indexOf("-") + 1));
goodsImportDTO.setRelease(objects.get(5).toString().equals("上架")); goodsImportDTO.setRelease("上架".equals(objects.get(5).toString()));
List<String> goodsGalleryList = new ArrayList<>(); List<String> goodsGalleryList = new ArrayList<>();
goodsGalleryList.add(objects.get(6).toString()); goodsGalleryList.add(objects.get(6).toString());

View File

@@ -273,7 +273,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
goodsVO.setWholesaleList(wholesaleList); goodsVO.setWholesaleList(wholesaleList);
} }
cache.put(CachePrefix.GOODS.getPrefix() + goodsId, goodsVO); cache.put(CachePrefix.GOODS.getPrefix() + goodsId, goodsVO,7200L);
return goodsVO; return goodsVO;
} }

View File

@@ -535,7 +535,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
try (InputStream inputStream = file.getInputStream()) { try (InputStream inputStream = file.getInputStream()) {
// 使用 WorkbookFactory.create 方法读取 Excel 文件 // 使用 WorkbookFactory.create 方法读取 Excel 文件
Workbook workbook = WorkbookFactory.create(inputStream); Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0); // 我们只读取第一个sheet // 我们只读取第一个sheet
Sheet sheet = workbook.getSheetAt(0);
// 检查第一个sheet的行数是否超过10002行 // 检查第一个sheet的行数是否超过10002行
if (sheet.getPhysicalNumberOfRows() > 10002) { if (sheet.getPhysicalNumberOfRows() > 10002) {
@@ -1039,7 +1040,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
// 设置下拉列表数据验证 // 设置下拉列表数据验证
DataValidationHelper validationHelper = templateSheet.getDataValidationHelper(); DataValidationHelper validationHelper = templateSheet.getDataValidationHelper();
DataValidationConstraint constraint = validationHelper.createExplicitListConstraint(new String[]{"", ""}); DataValidationConstraint constraint = validationHelper.createExplicitListConstraint(new String[]{"", ""});
CellRangeAddressList addressList = new CellRangeAddressList(2, 10001, 2, 2); // 从第3行到第10002行第3列 // 从第3行到第10002行第3列
CellRangeAddressList addressList = new CellRangeAddressList(2, 10001, 2, 2);
DataValidation validation = validationHelper.createValidation(constraint, addressList); DataValidation validation = validationHelper.createValidation(constraint, addressList);
validation.setSuppressDropDownArrow(true); validation.setSuppressDropDownArrow(true);
validation.setShowErrorBox(true); validation.setShowErrorBox(true);

View File

@@ -46,7 +46,7 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
@Autowired @Autowired
private ImMessageService imMessageService; private ImMessageService imMessageService;
@Override
public ImTalk getTalkByUser(String userId) { public ImTalk getTalkByUser(String userId) {
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());

View File

@@ -131,50 +131,67 @@ public class KdniaoPlugin implements LogisticsPlugin {
StoreLogistics storeLogistics = labelOrderDTO.getStoreLogistics(); StoreLogistics storeLogistics = labelOrderDTO.getStoreLogistics();
//组装快递鸟应用级参数 //组装快递鸟应用级参数
String resultDate = "{" + String resultDate = "{"
"'OrderCode': '" + order.getSn() + "'," + //订单编码 // 订单编码
"'ShipperCode': '" + logistics.getCode() + "'," + //快递公司编码 + "'OrderCode': '" + order.getSn() + "',"
"'CustomerName': '" + storeLogistics.getCustomerName() + "'," +//客户编码 // 快递公司编码
"'CustomerPwd': '" + storeLogistics.getCustomerPwd() + "'," + //客户密码 + "'ShipperCode': '" + logistics.getCode() + "',"
"'MonthCode': '" + storeLogistics.getMonthCode() + "'," + //密钥 // 客户编码
"'SendSite': '" + storeLogistics.getSendSite() + "'," + //归属网点 + "'CustomerName': '" + storeLogistics.getCustomerName() + "',"
"'SendStaff': '" + storeLogistics.getSendStaff() + "'," + //收件快递员 // 客户密码
"'PayType': " + storeLogistics.getPayType() + "," + + "'CustomerPwd': '" + storeLogistics.getCustomerPwd() + "',"
"'ExpType': " + storeLogistics.getExpType() + "," + // 密钥
//发件人信息 + "'MonthCode': '" + storeLogistics.getMonthCode() + "',"
"'Sender': {" + // 归属网点
"'Name': '" + storeDeliverGoodsAddressDTO.getSalesConsignorName() + "'," + + "'SendSite': '" + storeLogistics.getSendSite() + "',"
"'Mobile': '" + storeDeliverGoodsAddressDTO.getSalesConsignorMobile() + "'," + // 收件快递员
"'ProvinceName': '" + consignorAddress[0] + "'," + //省 + "'SendStaff': '" + storeLogistics.getSendStaff() + "',"
"'CityName': '" + consignorAddress[1] + "'," + //市 + "'PayType': " + storeLogistics.getPayType() + ","
"'ExpAreaName': '" + consignorAddress[2] + "'," + //区 + "'ExpType': " + storeLogistics.getExpType() + ","
"'Address': '" + storeDeliverGoodsAddressDTO.getSalesConsignorDetail() + "'" + //发件人详细地址 // 发件人信息
"}," + + "'Sender': {"
//收件人信息 + "'Name': '" + storeDeliverGoodsAddressDTO.getSalesConsignorName() + "',"
"'Receiver': {" + + "'Mobile': '" + storeDeliverGoodsAddressDTO.getSalesConsignorMobile() + "',"
"'Name': '" + order.getConsigneeName() + "'," + // 省
"'Mobile': '" + order.getConsigneeMobile() + "'," + + "'ProvinceName': '" + consignorAddress[0] + "',"
"'ProvinceName': '" + ConsigneeAddress[0] + "'," + // //
"'CityName': '" + ConsigneeAddress[1] + "'," + //市 + "'CityName': '" + consignorAddress[1] + "',"
"'ExpAreaName': '" + ConsigneeAddress[2] + "'," + //区 //
"'Address': '" + order.getConsigneeDetail() + "'" + //收件人详细地址 + "'ExpAreaName': '" + consignorAddress[2] + "',"
"}," + // 发件人详细地址
//商品信息 + "'Address': '" + storeDeliverGoodsAddressDTO.getSalesConsignorDetail() + "'"
"'Commodity': ["; + "},"
// 收件人信息
+ "'Receiver': {"
+ "'Name': '" + order.getConsigneeName() + "',"
+ "'Mobile': '" + order.getConsigneeMobile() + "',"
// 省
+ "'ProvinceName': '" + ConsigneeAddress[0] + "',"
// 市
+ "'CityName': '" + ConsigneeAddress[1] + "',"
// 区
+ "'ExpAreaName': '" + ConsigneeAddress[2] + "',"
// 收件人详细地址
+ "'Address': '" + order.getConsigneeDetail() + "'"
+ "},"
// 商品信息
+ "'Commodity': [";
//子订单信息 //子订单信息
for (OrderItem orderItem : orderItems) { for (OrderItem orderItem : orderItems) {
resultDate = resultDate + "{" + resultDate = resultDate + "{"
"'GoodsName': '" + orderItem.getGoodsName() + "'," + + "'GoodsName': '" + orderItem.getGoodsName() + "',"
"'Goodsquantity': '" + orderItem.getNum() + "'" + + "'Goodsquantity': '" + orderItem.getNum() + "'"
"},"; + "},";
} }
resultDate = resultDate + "]," + resultDate = resultDate + "],"
"'Quantity': " + orderItems.size() + "," + //包裹数 // 包裹数
"'IsReturnPrintTemplate':1," + //生成电子面单模板 + "'Quantity': " + orderItems.size() + ","
"'Remark': '" + order.getRemark() + "'" +//商家备注 // 生成电子面单模板
"}"; + "'IsReturnPrintTemplate':1,"
// 商家备注
+ "'Remark': '" + order.getRemark() + "'"
+ "}";
//组织系统级参数 //组织系统级参数
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
@@ -200,9 +217,9 @@ public class KdniaoPlugin implements LogisticsPlugin {
JSONObject obj = JSONObject.parseObject(result); JSONObject obj = JSONObject.parseObject(result);
log.info("电子面单响应:{}", result); log.info("电子面单响应:{}", result);
if (!"100".equals(obj.getString("ResultCode"))) { if (!"100".equals(obj.getString("ResultCode"))) {
// resultMap.put("Reason",obj.getString("Reason")); // resultMap.put("Reason",obj.getString("Reason"));
throw new ServiceException(obj.getString("Reason")); throw new ServiceException(obj.getString("Reason"));
// return resultMap; // return resultMap;
} }
JSONObject orderJson = JSONObject.parseObject(obj.getString("Order")); JSONObject orderJson = JSONObject.parseObject(obj.getString("Order"));

View File

@@ -22,13 +22,13 @@ import com.sf.csim.express.service.HttpClientUtil;
import com.sf.csim.express.service.IServiceCodeStandard; import com.sf.csim.express.service.IServiceCodeStandard;
import com.sf.csim.express.service.code.ExpressServiceCodeEnum; import com.sf.csim.express.service.code.ExpressServiceCodeEnum;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.*; import java.util.*;
/** /**
* 顺丰插件 * 顺丰插件
*
* @author admin * @author admin
*/ */
@Slf4j @Slf4j
@@ -43,7 +43,8 @@ public class ShunfengPlugin implements LogisticsPlugin {
**/ **/
private LogisticsSetting logisticsSetting; private LogisticsSetting logisticsSetting;
public ShunfengPlugin(){} public ShunfengPlugin() {
}
public ShunfengPlugin(LogisticsSetting logisticsSetting) { public ShunfengPlugin(LogisticsSetting logisticsSetting) {
this.logisticsSetting = logisticsSetting; this.logisticsSetting = logisticsSetting;
@@ -59,10 +60,11 @@ public class ShunfengPlugin implements LogisticsPlugin {
* *
* @param orderDetailVO * @param orderDetailVO
*/ */
@Override
public String createOrder(OrderDetailVO orderDetailVO) { public String createOrder(OrderDetailVO orderDetailVO) {
StoreDetailService storeService = SpringContextUtil.getBean(StoreDetailService.class); StoreDetailService storeService = SpringContextUtil.getBean(StoreDetailService.class);
StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = storeService.getStoreDeliverGoodsAddressDto(orderDetailVO.getOrder().getStoreId()); StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = storeService.getStoreDeliverGoodsAddressDto(orderDetailVO.getOrder().getStoreId());
if(storeDeliverGoodsAddressDTO == null){ if (storeDeliverGoodsAddressDTO == null) {
throw new ServiceException(ResultCode.STORE_DELIVER_ADDRESS_EXIST); throw new ServiceException(ResultCode.STORE_DELIVER_ADDRESS_EXIST);
} }
try { try {
@@ -108,7 +110,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
String result = sendPost(ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER, msgDataMap); String result = sendPost(ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER, msgDataMap);
JSONObject resultData = JSONUtil.parseObj(result).getJSONObject("apiResultData"); JSONObject resultData = JSONUtil.parseObj(result).getJSONObject("apiResultData");
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){ if (Boolean.TRUE.toString().equals(resultData.get("success").toString())) {
return resultData.getJSONObject("msgData").getJSONArray("waybillNoInfoList").getJSONObject(0).get("waybillNo").toString(); return resultData.getJSONObject("msgData").getJSONArray("waybillNoInfoList").getJSONObject(0).get("waybillNo").toString();
} }
throw new ServiceException(resultData.get("errorMsg").toString()); throw new ServiceException(resultData.get("errorMsg").toString());
@@ -141,10 +143,10 @@ public class ShunfengPlugin implements LogisticsPlugin {
msgDataMap.put("trackingNumber", trackingNumber); msgDataMap.put("trackingNumber", trackingNumber);
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_ROUTES, msgDataMap)); JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_ROUTES, msgDataMap));
JSONObject resultData = result.getJSONObject("apiResultData"); JSONObject resultData = result.getJSONObject("apiResultData");
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){ if (Boolean.TRUE.toString().equals(resultData.get("success").toString())) {
JSONArray routesJson = resultData.getJSONObject("msgData").getJSONArray("routeResps").getJSONObject(0).getJSONArray("routes"); JSONArray routesJson = resultData.getJSONObject("msgData").getJSONArray("routeResps").getJSONObject(0).getJSONArray("routes");
List<Map> routes = routesJson.toList(Map.class); List<Map> routes = routesJson.toList(Map.class);
return new Traces(logistics.getName(),expNo,routes); return new Traces(logistics.getName(), expNo, routes);
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -164,7 +166,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
* @return * @return
*/ */
@Override @Override
public Map<String,Object> labelOrder(LabelOrderDTO labelOrderDTO) { public Map<String, Object> labelOrder(LabelOrderDTO labelOrderDTO) {
try { try {
Map<String, Object> msgDataMap = new HashMap<>(); Map<String, Object> msgDataMap = new HashMap<>();
//模板编码 //模板编码
@@ -173,15 +175,15 @@ public class ShunfengPlugin implements LogisticsPlugin {
//业务数据 //业务数据
Map<String, Object> documents = new HashMap<>(); Map<String, Object> documents = new HashMap<>();
documents.put("masterWaybillNo", labelOrderDTO.getOrder().getLogisticsNo()); documents.put("masterWaybillNo", labelOrderDTO.getOrder().getLogisticsNo());
msgDataMap.put("documents",documents); msgDataMap.put("documents", documents);
msgDataMap.put("sync",true); msgDataMap.put("sync", true);
/** /**
* 版本号,传固定值:2.0 * 版本号,传固定值:2.0
*/ */
msgDataMap.put("version", "2.0"); msgDataMap.put("version", "2.0");
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.COM_RECE_CLOUD_PRINT_WAYBILLS, msgDataMap)); JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.COM_RECE_CLOUD_PRINT_WAYBILLS, msgDataMap));
JSONObject resultData = result.getJSONObject("apiResultData"); JSONObject resultData = result.getJSONObject("apiResultData");
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){ if (Boolean.TRUE.toString().equals(resultData.get("success").toString())) {
return resultData.getJSONObject("obj").getJSONArray("files").toList(Map.class).get(0); return resultData.getJSONObject("obj").getJSONArray("files").toList(Map.class).get(0);
} }
throw new ServiceException(resultData.getJSONArray("errorMessage").get(0).toString()); throw new ServiceException(resultData.getJSONArray("errorMessage").get(0).toString());
@@ -204,12 +206,12 @@ public class ShunfengPlugin implements LogisticsPlugin {
//校验类型 1电话号码校验 2月结卡号校验 //校验类型 1电话号码校验 2月结卡号校验
msgDataMap.put("checkType", 1); msgDataMap.put("checkType", 1);
//校验值 当校验类型为1时传电话号码 当校验类型为2时传月结卡号 //校验值 当校验类型为1时传电话号码 当校验类型为2时传月结卡号
List<String> mobileList= new ArrayList<>(); List<String> mobileList = new ArrayList<>();
mobileList.add(checkNos); mobileList.add(checkNos);
msgDataMap.put("checkNos", mobileList); msgDataMap.put("checkNos", mobileList);
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_PROMITM, msgDataMap)); JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_PROMITM, msgDataMap));
JSONObject resultData = result.getJSONObject("apiResultData"); JSONObject resultData = result.getJSONObject("apiResultData");
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){ if (Boolean.TRUE.toString().equals(resultData.get("success").toString())) {
return resultData.getJSONObject("msgData").get("promiseTm").toString(); return resultData.getJSONObject("msgData").get("promiseTm").toString();
} }
throw new ServiceException(resultData.get("errorMsg").toString()); throw new ServiceException(resultData.get("errorMsg").toString());
@@ -219,7 +221,6 @@ public class ShunfengPlugin implements LogisticsPlugin {
} }
private String sendPost(IServiceCodeStandard standardService, Map<String, Object> msgDataMap) throws UnsupportedEncodingException { private String sendPost(IServiceCodeStandard standardService, Map<String, Object> msgDataMap) throws UnsupportedEncodingException {
CallExpressServiceTools tools = CallExpressServiceTools.getInstance();
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
String timeStamp = String.valueOf(System.currentTimeMillis()); String timeStamp = String.valueOf(System.currentTimeMillis());
// 顾客编码 // 顾客编码
@@ -230,7 +231,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
params.put("timestamp", timeStamp); params.put("timestamp", timeStamp);
params.put("msgData", JSONUtil.toJsonStr(msgDataMap)); params.put("msgData", JSONUtil.toJsonStr(msgDataMap));
params.put("msgDigest", tools.getMsgDigest(params.get("msgData"), timeStamp, logisticsSetting.getCheckWord())); params.put("msgDigest", CallExpressServiceTools.getMsgDigest(params.get("msgData"), timeStamp, logisticsSetting.getCheckWord()));
String result = HttpClientUtil.post(logisticsSetting.getCallUrl(), params); String result = HttpClientUtil.post(logisticsSetting.getCallUrl(), params);
log.info("===调用地址 ===" + logisticsSetting.getCallUrl()); log.info("===调用地址 ===" + logisticsSetting.getCallUrl());

View File

@@ -335,6 +335,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
} }
@DemoSite @DemoSite
@Override
public Member modifyPass(String oldPassword, String newPassword) { public Member modifyPass(String oldPassword, String newPassword) {
AuthUser tokenUser = UserContext.getCurrentUser(); AuthUser tokenUser = UserContext.getCurrentUser();
if (tokenUser == null) { if (tokenUser == null) {

View File

@@ -267,8 +267,8 @@ public class SkuPromotionRender implements CartRenderStep {
} }
} }
//设置购物车未选中
if (quantity != null && cartSkuVO.getNum() > (Integer) quantity) {//设置购物车未选中 if (quantity != null && cartSkuVO.getNum() > (Integer) quantity) {
cartSkuVO.setChecked(false); cartSkuVO.setChecked(false);
//设置失效消息 //设置失效消息
cartSkuVO.setErrorMessage("促销商品库存不足,现有库存数量[" + quantity + "]"); cartSkuVO.setErrorMessage("促销商品库存不足,现有库存数量[" + quantity + "]");

View File

@@ -1,13 +1,10 @@
package cn.lili.modules.payment.kit.plugin.alipay; package cn.lili.modules.payment.kit.plugin.alipay;
import cn.hutool.core.net.URLDecoder;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.context.ThreadContextHolder; import cn.lili.common.context.ThreadContextHolder;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil; import cn.lili.common.enums.ResultUtil;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.properties.ApiProperties;
import cn.lili.common.properties.DomainProperties; import cn.lili.common.properties.DomainProperties;
import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.SnowFlake;
@@ -40,7 +37,6 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map; import java.util.Map;
/** /**
@@ -90,13 +86,14 @@ public class AliPayPlugin implements Payment {
payModel.setBody(cashierParam.getTitle()); payModel.setBody(cashierParam.getTitle());
payModel.setSubject(cashierParam.getDetail()); payModel.setSubject(cashierParam.getDetail());
payModel.setTotalAmount(cashierParam.getPrice() + ""); payModel.setTotalAmount(cashierParam.getPrice() + "");
//回传数据
payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8));
//3分钟超时 //3分钟超时
payModel.setTimeoutExpress("3m"); payModel.setTimeoutExpress("3m");
payModel.setOutTradeNo(outTradeNo); payModel.setOutTradeNo(outTradeNo);
payModel.setProductCode("QUICK_WAP_PAY"); payModel.setProductCode("QUICK_WAP_PAY");
try { try {
// Passback params moved into try to handle checked exception
payModel.setPassbackParams(java.net.URLEncoder.encode(BeanUtil.formatKeyValuePair(payParam), "UTF-8"));
log.info("支付宝H5支付{}", JSONUtil.toJsonStr(payModel)); log.info("支付宝H5支付{}", JSONUtil.toJsonStr(payModel));
AliPayRequest.wapPay(response, payModel, callbackUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY), AliPayRequest.wapPay(response, payModel, callbackUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY),
notifyUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY)); notifyUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY));
@@ -130,8 +127,8 @@ public class AliPayPlugin implements Payment {
//3分钟超时 //3分钟超时
payModel.setTimeoutExpress("3m"); payModel.setTimeoutExpress("3m");
//回传数据 //回传数据(替换 Hutool 的 URLEncoder 为 JDK 的 java.net.URLEncoder
payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8)); payModel.setPassbackParams(java.net.URLEncoder.encode(BeanUtil.formatKeyValuePair(payParam), "UTF-8"));
payModel.setOutTradeNo(outTradeNo); payModel.setOutTradeNo(outTradeNo);
payModel.setProductCode("QUICK_MSECURITY_PAY"); payModel.setProductCode("QUICK_MSECURITY_PAY");
@@ -164,8 +161,8 @@ public class AliPayPlugin implements Payment {
payModel.setSubject(cashierParam.getDetail()); payModel.setSubject(cashierParam.getDetail());
payModel.setTotalAmount(cashierParam.getPrice() + ""); payModel.setTotalAmount(cashierParam.getPrice() + "");
//回传数据 //回传数据(替换 Hutool 的 URLEncoder 为 JDK 的 java.net.URLEncoder
payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8)); payModel.setPassbackParams(java.net.URLEncoder.encode(BeanUtil.formatKeyValuePair(payParam), "UTF-8"));
payModel.setTimeoutExpress("3m"); payModel.setTimeoutExpress("3m");
payModel.setOutTradeNo(outTradeNo); payModel.setOutTradeNo(outTradeNo);
log.info("支付宝扫码:{}", payModel); log.info("支付宝扫码:{}", payModel);
@@ -314,7 +311,8 @@ public class AliPayPlugin implements Payment {
return; return;
} }
String payParamStr = map.get("passback_params"); String payParamStr = map.get("passback_params");
String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8); // java.net.URLDecoder.decode throws UnsupportedEncodingException, add catch below
String payParamJson = java.net.URLDecoder.decode(payParamStr, "UTF-8");
PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam()); PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam());
@@ -331,6 +329,8 @@ public class AliPayPlugin implements Payment {
} }
} catch (AlipayApiException e) { } catch (AlipayApiException e) {
log.error("支付回调通知异常", e); log.error("支付回调通知异常", e);
} catch (java.io.UnsupportedEncodingException e) {
log.error("URL 解码异常", e);
} }
} }

View File

@@ -1,6 +1,5 @@
package cn.lili.modules.payment.kit.plugin.unionpay; package cn.lili.modules.payment.kit.plugin.unionpay;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
@@ -67,7 +66,7 @@ public class UnionPayPlugin implements Payment {
String ip = IpKit.getRealIp(request); String ip = IpKit.getRealIp(request);
//第三方付款订单 //第三方付款订单
String outOrderNo = SnowFlake.getIdStr(); String outOrderNo = SnowFlake.getIdStr();
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
Map<String, String> params = UnifiedOrderModel.builder() Map<String, String> params = UnifiedOrderModel.builder()
.service(ServiceEnum.NATIVE.toString()) .service(ServiceEnum.NATIVE.toString())
.mch_id(unionPaymentSetting.getUnionPayMachId()) .mch_id(unionPaymentSetting.getUnionPayMachId())
@@ -94,12 +93,10 @@ public class UnionPayPlugin implements Payment {
@Override @Override
public ResultMessage<Object> appPay(HttpServletRequest request, PayParam payParam) { public ResultMessage<Object> appPay(HttpServletRequest request, PayParam payParam) {
try { try {
CashierParam cashierParam = cashierSupport.cashierParam(payParam); CashierParam cashierParam = cashierSupport.cashierParam(payParam);
UnionPaymentSetting unionPaymentSetting = this.unionPaymentSetting(); UnionPaymentSetting unionPaymentSetting = this.unionPaymentSetting();
String notifyUrl = unionPaymentSetting.getUnionPayDomain().concat("/unionPay/payNotify"); String notifyUrl = unionPaymentSetting.getUnionPayDomain().concat("/unionPay/payNotify");
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
//用户ip //用户ip
String ip = IpKit.getRealIp(request); String ip = IpKit.getRealIp(request);
Map<String, String> params = UnifiedOrderModel.builder() Map<String, String> params = UnifiedOrderModel.builder()
@@ -135,9 +132,7 @@ public class UnionPayPlugin implements Payment {
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
@@ -147,10 +142,12 @@ public class UnionPayPlugin implements Payment {
String buyerId=""; String buyerId="";
CashierParam cashierParam = cashierSupport.cashierParam(payParam); CashierParam cashierParam = cashierSupport.cashierParam(payParam);
UnionPaymentSetting unionPaymentSetting = this.unionPaymentSetting(); UnionPaymentSetting unionPaymentSetting = this.unionPaymentSetting();
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); // 将 attach 的编码移动到 try 内,避免方法外部的受检异常
// String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
//用户ip //用户ip
String ip = IpKit.getRealIp(request); String ip = IpKit.getRealIp(request);
try { try {
String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
if (StrUtil.isEmpty(buyerLogonId) && StrUtil.isEmpty(buyerId)) { if (StrUtil.isEmpty(buyerLogonId) && StrUtil.isEmpty(buyerId)) {
log.error("buyer_logon_id buyer_id 不能同时为空"); log.error("buyer_logon_id buyer_id 不能同时为空");
return null; return null;

View File

@@ -1,7 +1,5 @@
package cn.lili.modules.payment.kit.plugin.wechat; package cn.lili.modules.payment.kit.plugin.wechat;
import cn.hutool.core.net.URLDecoder;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.cache.Cache; import cn.lili.cache.Cache;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
@@ -148,7 +146,7 @@ public class WechatPlugin implements Payment {
String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3); String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
//回传数据 //回传数据
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
@@ -157,13 +155,12 @@ public class WechatPlugin implements Payment {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
} }
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
H5Service service = new H5Service.Builder().config(config).build(); H5Service service = new H5Service.Builder().config(config).build();
@@ -181,7 +178,7 @@ public class WechatPlugin implements Payment {
prepayRequest.setSceneInfo(sceneInfo); prepayRequest.setSceneInfo(sceneInfo);
// 调用下单方法,得到应答 // 调用下单方法,得到应答
com.wechat.pay.java.service.payments.h5.model.PrepayResponse response = service.prepay(prepayRequest); com.wechat.pay.java.service.payments.h5.model.PrepayResponse response = service.prepay(prepayRequest);
updateOrderPayNo(payParam,outOrderNo); updateOrderPayNo(payParam, outOrderNo);
return ResultUtil.data(response.getH5Url()); return ResultUtil.data(response.getH5Url());
} catch (Exception e) { } catch (Exception e) {
@@ -202,7 +199,6 @@ public class WechatPlugin implements Payment {
} }
CashierParam cashierParam = cashierSupport.cashierParam(payParam); CashierParam cashierParam = cashierSupport.cashierParam(payParam);
//支付金额 //支付金额
@@ -212,7 +208,8 @@ public class WechatPlugin implements Payment {
//过期时间 //过期时间
String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3); String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); // 将 Hutool URLEncoder 替换为标准库
String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
String appid = setting.getJsapiAppId(); String appid = setting.getJsapiAppId();
@@ -220,11 +217,11 @@ public class WechatPlugin implements Payment {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
} }
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
JsapiService service = new JsapiService.Builder().config(config).build(); JsapiService service = new JsapiService.Builder().config(config).build();
@@ -246,7 +243,7 @@ public class WechatPlugin implements Payment {
prepayRequest.setPayer(payer); prepayRequest.setPayer(payer);
// 调用下单方法,得到应答 // 调用下单方法,得到应答
com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse response = service.prepay(prepayRequest); com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse response = service.prepay(prepayRequest);
updateOrderPayNo(payParam,outOrderNo); updateOrderPayNo(payParam, outOrderNo);
Map<String, String> map = WxPayKit.jsApiCreateSign(appid, response.getPrepayId(), setting.getApiclientKey()); Map<String, String> map = WxPayKit.jsApiCreateSign(appid, response.getPrepayId(), setting.getApiclientKey());
log.info("唤起支付参数:{}", map); log.info("唤起支付参数:{}", map);
@@ -271,7 +268,8 @@ public class WechatPlugin implements Payment {
//过期时间 //过期时间
String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3); String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); // 将 Hutool URLEncoder 替换为标准库
String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
String appid = setting.getJsapiAppId(); String appid = setting.getJsapiAppId();
@@ -279,11 +277,11 @@ public class WechatPlugin implements Payment {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
} }
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
AppService service = new AppService.Builder().config(config).build(); AppService service = new AppService.Builder().config(config).build();
@@ -302,14 +300,14 @@ public class WechatPlugin implements Payment {
// 调用下单方法,得到应答 // 调用下单方法,得到应答
com.wechat.pay.java.service.payments.app.model.PrepayResponse response = service.prepay(prepayRequest); com.wechat.pay.java.service.payments.app.model.PrepayResponse response = service.prepay(prepayRequest);
updateOrderPayNo(payParam,outOrderNo); updateOrderPayNo(payParam, outOrderNo);
Map<String, String> map = WxPayKit.appPrepayIdCreateSign(appid, Map<String, String> map = WxPayKit.appPrepayIdCreateSign(appid,
setting.getMchId(), setting.getMchId(),
response.getPrepayId(), response.getPrepayId(),
setting.getApiclientKey(), SignType.MD5); setting.getApiclientKey(), SignType.MD5);
log.info("唤起支付参数:{}", map); log.info("唤起支付参数:{}", map);
//修改付款单号 //修改付款单号
updateOrderPayNo(payParam,outOrderNo); updateOrderPayNo(payParam, outOrderNo);
return ResultUtil.data(map); return ResultUtil.data(map);
} catch (Exception e) { } catch (Exception e) {
log.error("支付异常", e); log.error("支付异常", e);
@@ -331,7 +329,8 @@ public class WechatPlugin implements Payment {
//过期时间 //过期时间
String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3); String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); // 将 Hutool URLEncoder 替换为标准库
String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
@@ -340,11 +339,11 @@ public class WechatPlugin implements Payment {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
} }
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
NativePayService service = new NativePayService.Builder().config(config).build(); NativePayService service = new NativePayService.Builder().config(config).build();
@@ -363,7 +362,7 @@ public class WechatPlugin implements Payment {
// 调用下单方法,得到应答 // 调用下单方法,得到应答
PrepayResponse response = service.prepay(prepayRequest); PrepayResponse response = service.prepay(prepayRequest);
updateOrderPayNo(payParam,outOrderNo); updateOrderPayNo(payParam, outOrderNo);
return ResultUtil.data(response.getCodeUrl()); return ResultUtil.data(response.getCodeUrl());
} catch (ServiceException e) { } catch (ServiceException e) {
@@ -405,15 +404,16 @@ public class WechatPlugin implements Payment {
if (StringUtils.isEmpty(appid)) { if (StringUtils.isEmpty(appid)) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
} }
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); // 将 Hutool URLEncoder 替换为标准库
String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
JsapiService service = new JsapiService.Builder().config(config).build(); JsapiService service = new JsapiService.Builder().config(config).build();
@@ -432,7 +432,7 @@ public class WechatPlugin implements Payment {
prepayRequest.setPayer(payer); prepayRequest.setPayer(payer);
// 调用下单方法,得到应答 // 调用下单方法,得到应答
com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse response = service.prepay(prepayRequest); com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse response = service.prepay(prepayRequest);
updateOrderPayNo(payParam,outOrderNo); updateOrderPayNo(payParam, outOrderNo);
Map<String, String> map = WxPayKit.jsApiCreateSign(appid, response.getPrepayId(), setting.getApiclientKey()); Map<String, String> map = WxPayKit.jsApiCreateSign(appid, response.getPrepayId(), setting.getApiclientKey());
log.info("唤起支付参数:{}", map); log.info("唤起支付参数:{}", map);
@@ -501,7 +501,6 @@ public class WechatPlugin implements Payment {
} }
//获取用户openId //获取用户openId
Connect connect = connectService.queryConnect( Connect connect = connectService.queryConnect(
ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId()) ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId())
@@ -510,11 +509,11 @@ public class WechatPlugin implements Payment {
//获取微信设置 //获取微信设置
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
TransferBatchService service = new TransferBatchService.Builder().config(config).build(); TransferBatchService service = new TransferBatchService.Builder().config(config).build();
@@ -544,7 +543,7 @@ public class WechatPlugin implements Payment {
log.info("微信提现响应 {}", response); log.info("微信提现响应 {}", response);
return TransferResultDTO.builder().result(response.getBatchId()!= null).build(); return TransferResultDTO.builder().result(response.getBatchId() != null).build();
//根据自身业务进行接下来的任务处理 //根据自身业务进行接下来的任务处理
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -571,15 +570,15 @@ public class WechatPlugin implements Payment {
.build(); .build();
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
NotificationConfig config=null; NotificationConfig config = null;
if(setting.getPublicType().equals("CERT")) { if ("CERT".equals(setting.getPublicType())) {
config = new RSAAutoCertificateConfig.Builder() config = new RSAAutoCertificateConfig.Builder()
.merchantId(setting.getMchId()) .merchantId(setting.getMchId())
.privateKey(setting.getApiclientKey()) .privateKey(setting.getApiclientKey())
.merchantSerialNumber(setting.getSerialNumber()) .merchantSerialNumber(setting.getSerialNumber())
.apiV3Key(setting.getApiKey3()) .apiV3Key(setting.getApiKey3())
.build(); .build();
}else{ } else {
config = new RSAPublicKeyConfig.Builder() config = new RSAPublicKeyConfig.Builder()
.merchantId(setting.getMchId()) .merchantId(setting.getMchId())
.apiV3Key(setting.getApiKey3()) .apiV3Key(setting.getApiKey3())
@@ -597,8 +596,10 @@ public class WechatPlugin implements Payment {
// 以支付通知回调为例,验签、解密并转换成 Transaction // 以支付通知回调为例,验签、解密并转换成 Transaction
Transaction transaction = parser.parse(requestParam, Transaction.class); Transaction transaction = parser.parse(requestParam, Transaction.class);
String payParamJson = URLDecoder.decode(transaction.getAttach(), StandardCharsets.UTF_8); // 将 Hutool URLDecoder 替换为标准库
PayParam payParam = JSONUtil.toBean(payParamJson, PayParam.class); String payParamJson = java.net.URLDecoder.decode(transaction.getAttach(), StandardCharsets.UTF_8.name());
PayParam payParam = new Gson().fromJson(payParamJson, PayParam.class);
Double totalAmount = CurrencyUtil.reversalFen(transaction.getAmount().getTotal()); Double totalAmount = CurrencyUtil.reversalFen(transaction.getAmount().getTotal());
@@ -630,11 +631,11 @@ public class WechatPlugin implements Payment {
//获取微信设置 //获取微信设置
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
Config config =null; Config config = null;
if(setting.getPublicType().equals("CERT")){ if ("CERT".equals(setting.getPublicType())) {
config=this.getCertificateConfig(setting); config = this.getCertificateConfig(setting);
}else { } else {
config=this.getPublicKeyConfig(setting); config = this.getPublicKeyConfig(setting);
} }
// 构建service // 构建service
RefundService refundService = new RefundService.Builder().config(config).build(); RefundService refundService = new RefundService.Builder().config(config).build();
@@ -646,7 +647,7 @@ public class WechatPlugin implements Payment {
request.setReason(refundLog.getRefundReason()); request.setReason(refundLog.getRefundReason());
request.setNotifyUrl(refundNotifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT)); request.setNotifyUrl(refundNotifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT));
Refund refund=refundService.create(request); Refund refund = refundService.create(request);
log.info("微信退款响应 {}", refund); log.info("微信退款响应 {}", refund);
refundLogService.save(refundLog); refundLogService.save(refundLog);
@@ -668,15 +669,15 @@ public class WechatPlugin implements Payment {
.build(); .build();
WechatPaymentSetting setting = wechatPaymentSetting(); WechatPaymentSetting setting = wechatPaymentSetting();
NotificationConfig config=null; NotificationConfig config = null;
if(setting.getPublicType().equals("CERT")) { if ("CERT".equals(setting.getPublicType())) {
config = new RSAAutoCertificateConfig.Builder() config = new RSAAutoCertificateConfig.Builder()
.merchantId(setting.getMchId()) .merchantId(setting.getMchId())
.privateKey(setting.getApiclientKey()) .privateKey(setting.getApiclientKey())
.merchantSerialNumber(setting.getSerialNumber()) .merchantSerialNumber(setting.getSerialNumber())
.apiV3Key(setting.getApiKey3()) .apiV3Key(setting.getApiKey3())
.build(); .build();
}else{ } else {
config = new RSAPublicKeyConfig.Builder() config = new RSAPublicKeyConfig.Builder()
.merchantId(setting.getMchId()) .merchantId(setting.getMchId())
.apiV3Key(setting.getApiKey3()) .apiV3Key(setting.getApiKey3())
@@ -721,10 +722,11 @@ public class WechatPlugin implements Payment {
/** /**
* 获取微信公钥配置 * 获取微信公钥配置
*
* @param setting * @param setting
* @return * @return
*/ */
private RSAPublicKeyConfig getPublicKeyConfig(WechatPaymentSetting setting){ private RSAPublicKeyConfig getPublicKeyConfig(WechatPaymentSetting setting) {
return return
new RSAPublicKeyConfig.Builder() new RSAPublicKeyConfig.Builder()
.merchantId(setting.getMchId()) .merchantId(setting.getMchId())
@@ -738,6 +740,7 @@ public class WechatPlugin implements Payment {
/** /**
* 获取微信证书配置 * 获取微信证书配置
*
* @param setting * @param setting
* @return * @return
*/ */
@@ -752,18 +755,19 @@ public class WechatPlugin implements Payment {
/** /**
* 修改订单支付单号 * 修改订单支付单号
*
* @param payParam 支付参数 * @param payParam 支付参数
* @param outOrderNo 订单号 * @param outOrderNo 订单号
*/ */
private void updateOrderPayNo(PayParam payParam,String outOrderNo ){ private void updateOrderPayNo(PayParam payParam, String outOrderNo) {
if(payParam.getOrderType().equals("ORDER")){ if ("ORDER".equals(payParam.getOrderType())) {
orderService.update(new LambdaUpdateWrapper<Order>() orderService.update(new LambdaUpdateWrapper<Order>()
.eq(Order::getSn,payParam.getSn()) .eq(Order::getSn, payParam.getSn())
.set(Order::getPayOrderNo,outOrderNo)); .set(Order::getPayOrderNo, outOrderNo));
}else if(payParam.getOrderType().equals("TRADE")){ } else if ("TRADE".equals(payParam.getOrderType())) {
orderService.update(new LambdaUpdateWrapper<Order>() orderService.update(new LambdaUpdateWrapper<Order>()
.eq(Order::getTradeSn,payParam.getSn()) .eq(Order::getTradeSn, payParam.getSn())
.set(Order::getPayOrderNo,outOrderNo)); .set(Order::getPayOrderNo, outOrderNo));
} }
} }
} }

View File

@@ -411,9 +411,12 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<Cou
//判断优惠券的发送范围,获取会员列表 //判断优惠券的发送范围,获取会员列表
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
if (JSONUtil.isJsonArray(couponActivity.getActivityScopeInfo())) { String scopeInfo = couponActivity.getActivityScopeInfo();
JSONArray array = JSONUtil.parseArray(couponActivity.getActivityScopeInfo()); try {
JSONArray array = JSONUtil.parseArray(scopeInfo);
ids = array.toList(Map.class).stream().map(i -> i.get("id").toString()).collect(Collectors.toList()); ids = array.toList(Map.class).stream().map(i -> i.get("id").toString()).collect(Collectors.toList());
} catch (Exception ignore) {
// 非数组或格式错误时忽略,保持 ids 为空列表
} }
return memberService.listFieldsByMemberIds("id,nick_name", ids); return memberService.listFieldsByMemberIds("id,nick_name", ids);
} }

View File

@@ -87,6 +87,7 @@ public class PromotionServiceImpl implements PromotionService {
* @param goodsSkuId 商品skuId * @param goodsSkuId 商品skuId
* @return 当前促销活动集合 * @return 当前促销活动集合
*/ */
@Override
public Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId) { public Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId) {
String storeIds = storeId + "," + PromotionTools.PLATFORM_ID; String storeIds = storeId + "," + PromotionTools.PLATFORM_ID;
List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(goodsSkuId, storeIds); List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(goodsSkuId, storeIds);
@@ -99,7 +100,7 @@ public class PromotionServiceImpl implements PromotionService {
promotionGoodsService.deletePromotionGoodsByGoods(goodsIds); promotionGoodsService.deletePromotionGoodsByGoods(goodsIds);
kanjiaActivityGoodsService.deleteByGoodsIds(goodsIds); kanjiaActivityGoodsService.deleteByGoodsIds(goodsIds);
} }
@Override
public Map<String, Object> wrapperPromotionMapList(List<PromotionGoods> promotionGoodsList) { public Map<String, Object> wrapperPromotionMapList(List<PromotionGoods> promotionGoodsList) {
Map<String, Object> promotionMap = new HashMap<>(); Map<String, Object> promotionMap = new HashMap<>();
for (PromotionGoods promotionGoods : promotionGoodsList) { for (PromotionGoods promotionGoods : promotionGoodsList) {

View File

@@ -0,0 +1,34 @@
package cn.lili.modules.search.entity.dto;
import lombok.*;
import java.util.List;
import java.util.Map;
/**
* ES删除DTO
* 用于封装删除ES的参数
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EsDeleteDTO {
/**
* 删除的索引
*/
private List<String> ids;
/**
* 查询字段
*/
private Map<String, Object> queryFields;
/**
* 删除的索引
*/
@NonNull
private Class<?> clazz;
}

View File

@@ -19,6 +19,18 @@ import java.util.Map;
**/ **/
public interface EsGoodsIndexService { public interface EsGoodsIndexService {
/**
* 删除下架商品索引
*/
Boolean deleteGoodsDown();
/**
* 删除不存在的索引
* @return
*/
Boolean delSkuIndex();
Boolean goodsCache();
/** /**
* 全局索引数据初始化 * 全局索引数据初始化
*/ */

View File

@@ -6,6 +6,8 @@ import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import java.util.List; import java.util.List;
@@ -26,6 +28,16 @@ public interface EsGoodsSearchService {
*/ */
SearchPage<EsGoodsIndex> searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo); SearchPage<EsGoodsIndex> searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo);
/**
* 搜索商品
*
* @param searchQuery 搜索条件
* @param clazz 搜索结果类
* @param <T> 泛型
* @return 搜索结果
*/
<T> SearchPage<T> searchGoods(Query searchQuery, Class<T> clazz);
/** /**
* 商品搜索 * 商品搜索
* *
@@ -59,4 +71,13 @@ public interface EsGoodsSearchService {
* @return 商品索引 * @return 商品索引
*/ */
EsGoodsIndex getEsGoodsById(String id); EsGoodsIndex getEsGoodsById(String id);
/**
* 创建搜索条件
*
* @param searchDTO 搜索参数
* @param pageVo 分页参数
* @return 搜索条件
*/
NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo);
} }

View File

@@ -2,6 +2,7 @@ package cn.lili.modules.search.serviceimpl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
@@ -18,16 +19,15 @@ import cn.lili.common.vo.PageVO;
import cn.lili.elasticsearch.BaseElasticsearchService; import cn.lili.elasticsearch.BaseElasticsearchService;
import cn.lili.elasticsearch.EsSuffix; import cn.lili.elasticsearch.EsSuffix;
import cn.lili.elasticsearch.config.ElasticsearchProperties; import cn.lili.elasticsearch.config.ElasticsearchProperties;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.BrandService; import cn.lili.modules.goods.service.*;
import cn.lili.modules.goods.service.CategoryService;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.goods.service.StoreGoodsLabelService;
import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.BasePromotions;
import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
@@ -38,13 +38,16 @@ import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.entity.dos.CustomWords; import cn.lili.modules.search.entity.dos.CustomWords;
import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsAttribute;
import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.entity.dto.EsDeleteDTO;
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
import cn.lili.modules.search.repository.EsGoodsIndexRepository; import cn.lili.modules.search.repository.EsGoodsIndexRepository;
import cn.lili.modules.search.service.CustomWordsService; import cn.lili.modules.search.service.CustomWordsService;
import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.modules.search.service.EsGoodsSearchService;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.GoodsTagsEnum; import cn.lili.rocketmq.tags.GoodsTagsEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -65,10 +68,13 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType; import org.elasticsearch.script.ScriptType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.core.query.FetchSourceFilter;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -111,6 +117,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired @Autowired
private GoodsSkuService goodsSkuService; private GoodsSkuService goodsSkuService;
@Autowired @Autowired
private GoodsService goodsService;
@Autowired
private BrandService brandService; private BrandService brandService;
@Autowired @Autowired
@@ -119,6 +127,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired @Autowired
private StoreGoodsLabelService storeGoodsLabelService; private StoreGoodsLabelService storeGoodsLabelService;
@Autowired @Autowired
private EsGoodsSearchService esGoodsSearchService;
@Autowired
private Cache<Object> cache; private Cache<Object> cache;
/** /**
* rocketMq * rocketMq
@@ -145,6 +155,126 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
list.addAll(h); list.addAll(h);
} }
@Override
public Boolean deleteGoodsDown() {
List<Goods> goodsList = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getMarketEnable, GoodsStatusEnum.DOWN.name()));
for (Goods goods : goodsList) {
this.deleteIndex(
EsDeleteDTO.builder()
.queryFields(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goods.getId()).build())
.clazz(EsGoodsIndex.class)
.build());
}
return true;
}
@Override
public Boolean delSkuIndex() {
PageVO pageVO = new PageVO();
EsGoodsSearchDTO goodsSearchParams = new EsGoodsSearchDTO();
log.error("开始");
try {
List<Object> searchFilters = new ArrayList<>();
for (int i = 1; ; i++) {
log.error("" + i + "");
pageVO.setPageSize(1000);
pageVO.setPageNumber(i);
pageVO.setNotConvert(true);
pageVO.setSort("_id");
pageVO.setOrder("asc");
NativeSearchQueryBuilder searchQueryBuilder = esGoodsSearchService.createSearchQueryBuilder(goodsSearchParams, pageVO);
searchQueryBuilder.withSourceFilter(new FetchSourceFilter(new String[]{"_id"}, null));
Pageable pageable = PageRequest.of(0, 1000);
//分页
searchQueryBuilder.withPageable(pageable);
NativeSearchQuery query = searchQueryBuilder.build();
EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO();
SearchPage<EsGoodsIndex> searchHits = goodsSearchService.searchGoods(query, EsGoodsIndex.class);
if (searchHits == null || searchHits.isEmpty()) {
break;
}
List<String> idList = searchHits.getSearchHits().stream().map(SearchHit::getContent).map(EsGoodsIndex::getId).collect(Collectors.toList());
LambdaQueryWrapper<GoodsSku> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(GoodsSku::getId);
queryWrapper.in(GoodsSku::getId, idList);
List<GoodsSku> goodsSkus = goodsSkuService.list(queryWrapper);
idList.forEach(id -> {
if (goodsSkus.stream().noneMatch(goodsSku -> goodsSku.getId().equals(id))) {
log.error("[{}]不存在,进行删除", id);
this.deleteIndexById(id);
}
});
if (!searchHits.getSearchHits().getSearchHit(idList.size() -1).getSortValues().isEmpty()) {
searchFilters = searchHits.getSearchHits().getSearchHit(idList.size() -1).getSortValues();
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("结束了");
return true;
}
@Override
public Boolean goodsCache() {
GoodsSearchParams searchParams = new GoodsSearchParams();
searchParams.setAuthFlag(GoodsAuthEnum.PASS.name());
searchParams.setMarketEnable(GoodsStatusEnum.UPPER.name());
for (int i = 1; ; i++) {
try {
IPage<Goods> pagePage = new Page<>();
searchParams.setPageSize(1000);
searchParams.setPageNumber(i);
pagePage = goodsService.queryByParams(searchParams);
if (pagePage == null || CollUtil.isEmpty(pagePage.getRecords())) {
break;
}
for (Goods goods : pagePage.getRecords()) {
cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId());
goodsService.getGoodsVO(goods.getId());
}
} catch (Exception e) {
e.printStackTrace();
}
}
for (int i = 1; ; i++) {
try {
IPage<GoodsSkuDTO> skuIPage = new Page<>();
searchParams.setPageSize(1000);
searchParams.setPageNumber(i);
skuIPage = goodsSkuService.getGoodsSkuDTOByPage(PageUtil.initPage(searchParams),
searchParams.queryWrapper());
if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) {
break;
}
for (GoodsSkuDTO goodsSkuDTO : skuIPage.getRecords()) {
GoodsSku goodsSku = goodsSkuService.getById(goodsSkuDTO.getId());
cache.put(GoodsSkuService.getCacheKeys(goodsSkuDTO.getId()), goodsSku,600L);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}
@Override @Override
public void init() { public void init() {
//获取索引任务标识 //获取索引任务标识
@@ -248,9 +378,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
List<PromotionGoods> promotionGoods = skuValidPromotions.stream() List<PromotionGoods> promotionGoods = skuValidPromotions.stream()
.filter(j -> .filter(j ->
(CharSequenceUtil.isNotEmpty(j.getSkuId()) && j.getSkuId().equals(goodsSku.getId())) || (CharSequenceUtil.isNotEmpty(j.getSkuId()) && j.getSkuId().equals(goodsSku.getId())) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals("0")) || (j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && "0".equals(j.getStoreId())) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals(esGoodsIndex.getStoreId())) || (j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals(esGoodsIndex.getStoreId())) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals("0") && j.getScopeId().contains(goodsSku.getCategoryPath()))|| (j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && "0".equals(j.getStoreId()) && j.getScopeId().contains(goodsSku.getCategoryPath()))||
(j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals(goodsSku.getStoreId()) && j.getScopeId().contains(goodsSku.getCategoryPath())) (j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals(goodsSku.getStoreId()) && j.getScopeId().contains(goodsSku.getCategoryPath()))
) )
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -494,6 +624,20 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
} }
/**
* 删除索引
*
* @param esDeleteDTO 删除索引参数
*/
private void deleteIndex(EsDeleteDTO esDeleteDTO) {
if (esDeleteDTO.getIds() != null && !esDeleteDTO.getIds().isEmpty()) {
this.deleteIndexByIds(esDeleteDTO.getIds());
}
if (esDeleteDTO.getQueryFields() != null && esDeleteDTO.getQueryFields().size() > 0) {
this.deleteIndex(esDeleteDTO.getQueryFields());
}
}
/** /**
* 删除索引 * 删除索引
* *
@@ -863,7 +1007,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
// log.info("ES修改商品活动索引-原商品索引信息:{}", goodsIndex); // log.info("ES修改商品活动索引-原商品索引信息:{}", goodsIndex);
// log.info("ES修改商品活动索引-原商品索引活动信息:{}", promotionMap); // log.info("ES修改商品活动索引-原商品索引活动信息:{}", promotionMap);
//如果活动已结束 //如果活动已结束
if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {//如果存在活动 //如果存在活动
if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {
//删除活动 //删除活动
promotionMap.remove(key); promotionMap.remove(key);
} else { } else {

View File

@@ -41,6 +41,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.*; import org.springframework.data.elasticsearch.core.*;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
@@ -98,6 +99,12 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
return SearchHitSupport.searchPageFor(search, searchQuery.getPageable()); return SearchHitSupport.searchPageFor(search, searchQuery.getPageable());
} }
@Override
public <T> SearchPage<T> searchGoods(Query searchQuery, Class<T> clazz) {
SearchHits<T> search = restTemplate.search(searchQuery, clazz);
return SearchHitSupport.searchPageFor(search, searchQuery.getPageable());
}
@Override @Override
public Page<EsGoodsIndex> searchGoodsByPage(EsGoodsSearchDTO searchDTO, PageVO pageVo) { public Page<EsGoodsIndex> searchGoodsByPage(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
// 判断商品索引是否存在 // 判断商品索引是否存在
@@ -402,7 +409,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
* @param pageVo 分页参数 * @param pageVo 分页参数
* @return es搜索builder * @return es搜索builder
*/ */
private NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo) { @Override
public NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder(); NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
if (pageVo != null) { if (pageVo != null) {
int pageNumber = pageVo.getPageNumber() - 1; int pageNumber = pageVo.getPageNumber() - 1;

View File

@@ -123,7 +123,7 @@ public class SmsUtilAliImplService implements SmsUtil {
@Override @Override
public boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code) { public boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code) {
Object result = cache.get(cacheKey(verificationEnums, mobile, uuid)); Object result = cache.get(cacheKey(verificationEnums, mobile, uuid));
if (code.equals(result) || code.equals("0")) { if (code.equals(result) || "0".equals( code)) {
//校验之后,删除 //校验之后,删除
cache.remove(cacheKey(verificationEnums, mobile, uuid)); cache.remove(cacheKey(verificationEnums, mobile, uuid));
return true; return true;

View File

@@ -105,22 +105,22 @@ public class HuaweiSmsPlugin implements SmsPlugin {
} }
// 发送短信
private void sendSms(String signName, String mobile, String param, String templateCode) throws Exception { private void sendSms(String signName, String mobile, String param, String templateCode) throws Exception {
//必填,请参考"开发准备"获取如下数据,替换为实际值 //必填,请参考"开发准备"获取如下数据,替换为实际值
String url = "https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1"; //APP接入地址(在控制台"应用管理"页面获取)+接口访问URI //APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
String appKey = smsSetting.getHuaweiAppKey(); //APP_Key String url = "https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1";
String appSecret = smsSetting.getHuaweiAppSecret(); //APP_Secret String appKey = smsSetting.getHuaweiAppKey();
String sender = smsSetting.getHuaweiSender(); //国内短信签名通道号或国际/港澳台短信通道号 String appSecret = smsSetting.getHuaweiAppSecret();
String templateId = templateCode; //模板ID String sender = smsSetting.getHuaweiSender();
//条件必填,国内短信关注,当templateId指定的模板类型为通用模板时生效且必填,必须是已审核通过的,与模板类型一致的签名名称 // 模板ID
//国际/港澳台短信不用关注该参数 String templateId = templateCode;
String signature = smsSetting.getHuaweiSignature(); //签名名称
//必填,全局号码格式(包含国家码),示例:+8615123456789,多个号码之间用英文逗号分隔 // 签名名称
String receiver = mobile; //短信接收人号码 String signature = smsSetting.getHuaweiSignature();
//选填,短信状态报告接收地址,推荐使用域名,为空或者不填表示不接收状态报告 String receiver = mobile;
String statusCallBack = ""; String statusCallBack = "";
/** /**
@@ -130,7 +130,8 @@ public class HuaweiSmsPlugin implements SmsPlugin {
* 模板中的每个变量都必须赋值,且取值不能为空 * 模板中的每个变量都必须赋值,且取值不能为空
* 查看更多模板和变量规范:产品介绍>模板和变量规范 * 查看更多模板和变量规范:产品介绍>模板和变量规范
*/ */
String templateParas = param; //模板变量此处以单变量验证码短信为例请客户自行生成6位验证码并定义为字符串类型以杜绝首位0丢失的问题例如002569变成了2569 //模板变量此处以单变量验证码短信为例请客户自行生成6位验证码并定义为字符串类型以杜绝首位0丢失的问题例如002569变成了2569
String templateParas = param;
//请求Body,不携带签名名称时,signature请填null //请求Body,不携带签名名称时,signature请填null
String body = buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature); String body = buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature);
@@ -179,12 +180,14 @@ public class HuaweiSmsPlugin implements SmsPlugin {
connection.connect(); connection.connect();
out = new OutputStreamWriter(connection.getOutputStream()); out = new OutputStreamWriter(connection.getOutputStream());
out.write(body); //发送请求Body参数
// 发送请求Body参数
out.write(body);
out.flush(); out.flush();
out.close(); out.close();
int status = connection.getResponseCode(); int status = connection.getResponseCode();
if (200 == status) { //200 if (200 == status) {
is = connection.getInputStream(); is = connection.getInputStream();
} else { //400/401 } else { //400/401
is = connection.getErrorStream(); is = connection.getErrorStream();
@@ -194,7 +197,9 @@ public class HuaweiSmsPlugin implements SmsPlugin {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
result.append(line); result.append(line);
} }
System.out.println(result.toString()); //打印响应消息实体
// 打印响应消息实体
System.out.println(result.toString());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
@@ -275,8 +280,12 @@ public class HuaweiSmsPlugin implements SmsPlugin {
return null; return null;
} }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String time = sdf.format(new Date()); //Created
String nonce = UUID.randomUUID().toString().replace("-", ""); //Nonce // Created
String time = sdf.format(new Date());
// Nonce
String nonce = UUID.randomUUID().toString().replace("-", "");
MessageDigest md; MessageDigest md;
byte[] passwordDigest = null; byte[] passwordDigest = null;
@@ -289,8 +298,8 @@ public class HuaweiSmsPlugin implements SmsPlugin {
e.printStackTrace(); e.printStackTrace();
} }
//如果JDK版本是1.8,请加载原生Base64类,并使用如下代码 // PasswordDigest
String passwordDigestBase64Str = Base64.getEncoder().encodeToString(passwordDigest); //PasswordDigest String passwordDigestBase64Str = Base64.getEncoder().encodeToString(passwordDigest);
//如果JDK版本低于1.8,请加载三方库提供Base64类,并使用如下代码 //如果JDK版本低于1.8,请加载三方库提供Base64类,并使用如下代码
//String passwordDigestBase64Str = Base64.encodeBase64String(passwordDigest); //PasswordDigest //String passwordDigestBase64Str = Base64.encodeBase64String(passwordDigest); //PasswordDigest
//若passwordDigestBase64Str中包含换行符,请执行如下代码进行修正 //若passwordDigestBase64Str中包含换行符,请执行如下代码进行修正
@@ -303,14 +312,15 @@ public class HuaweiSmsPlugin implements SmsPlugin {
static void trustAllHttpsCertificates() throws Exception { static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[]{ TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() { new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return; return;
} }
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return; return;
} }
@Override
public X509Certificate[] getAcceptedIssuers() { public X509Certificate[] getAcceptedIssuers() {
return null; return null;
} }

View File

@@ -27,6 +27,7 @@ public interface RegionService extends IService<Region> {
* @return * @return
*/ */
@CacheEvict(allEntries = true) @CacheEvict(allEntries = true)
@Override
boolean updateById(Region region); boolean updateById(Region region);
/** /**
* 更新地区 * 更新地区
@@ -35,6 +36,7 @@ public interface RegionService extends IService<Region> {
* @return * @return
*/ */
@CacheEvict(allEntries = true) @CacheEvict(allEntries = true)
@Override
boolean save(Region region); boolean save(Region region);

View File

@@ -3,8 +3,11 @@ package cn.lili.controller.other;
import cn.lili.common.enums.ResultUtil; import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage; import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.system.aspect.annotation.SystemLogPoint;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -36,4 +39,30 @@ public class ElasticsearchController {
public ResultMessage<Map<String, Long>> getProgress() { public ResultMessage<Map<String, Long>> getProgress() {
return ResultUtil.data(esGoodsIndexService.getProgress()); return ResultUtil.data(esGoodsIndexService.getProgress());
} }
@ApiOperation(value = "ES删除下架的商品")
@GetMapping(value = "/deleteGoodsDown")
@SystemLogPoint(description = "ES删除下架的商品", customerLog = "")
public ResultMessage<Object> deleteGoodsDown() {
esGoodsIndexService.deleteGoodsDown();
return ResultUtil.success();
}
@ApiOperation(value = "删除不存在的索引")
@GetMapping(value = "/delSkuIndex")
@SystemLogPoint(description = "删除不存在的索引", customerLog = "")
public ResultMessage<Object> delSkuIndex() {
esGoodsIndexService.delSkuIndex();
return ResultUtil.success();
}
@ApiOperation(value = "生成所有商品的缓存")
@GetMapping(value = "/cache")
@SystemLogPoint(description = "生成所有商品的缓存")
public ResultMessage<Object> cache() {
esGoodsIndexService.goodsCache();
return ResultUtil.success();
}
} }

View File

@@ -150,8 +150,9 @@ public class ManagerAuthenticationFilter extends BasicAuthenticationFilter {
try { try {
Claims claims Claims claims
= Jwts.parser() = Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders()) .setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(jwt).getBody(); .parseClaimsJws(jwt).getBody();
//获取存储在claims中的用户信息 //获取存储在claims中的用户信息
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString(); String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();

View File

@@ -98,8 +98,9 @@ public class StoreAuthenticationFilter extends BasicAuthenticationFilter {
try { try {
Claims claims Claims claims
= Jwts.parser() = Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders()) .setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(jwt).getBody(); .parseClaimsJws(jwt).getBody();
//获取存储在claims中的用户信息 //获取存储在claims中的用户信息
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString(); String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();