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>
- **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等的部署与初始化。
@@ -156,9 +155,11 @@
### 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)
- **社区贡献内容**:

View File

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

View File

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

View File

@@ -92,8 +92,9 @@ public class UserContext {
try {
//获取token的信息
Claims claims
= Jwts.parser()
= Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(accessToken).getBody();
//获取存储在claims中的用户信息
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 {
BufferedReader bufferedReader = null;
InputStreamReader reader = null;
//获取输入流
@@ -163,9 +162,16 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
//继续读取下一行流直到line为空
line = bufferedReader.readLine();
}
if (CharSequenceUtil.isNotEmpty(body) && Boolean.TRUE.equals(JSONUtil.isJsonObj(body.toString()))) {
//将body转换为map
Map<String, Object> map = JSONUtil.parseObj(body.toString());
// 兼容替换:不再使用过时的 JSONUtil.isJsonObj(String),改为尝试解析并捕获异常
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<String, Object> resultMap = new HashMap<>(map.size());
//遍历数组
@@ -205,6 +211,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
}
};
}
}
//将json字符串转换为字节
final ByteArrayInputStream bis = new ByteArrayInputStream(body.toString().getBytes());

View File

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

View File

@@ -90,7 +90,8 @@ public abstract class BaseElasticsearchService {
request.settings(Settings.builder()
.put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards())
.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));
//创建索引

View File

@@ -205,7 +205,7 @@ public class GoodsImportServiceImpl implements GoodsImportService {
goodsImportDTO.setCategory(category);
goodsImportDTO.setTemplate(templateId);
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<>();
goodsGalleryList.add(objects.get(6).toString());

View File

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

View File

@@ -535,7 +535,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
try (InputStream inputStream = file.getInputStream()) {
// 使用 WorkbookFactory.create 方法读取 Excel 文件
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0); // 我们只读取第一个sheet
// 我们只读取第一个sheet
Sheet sheet = workbook.getSheetAt(0);
// 检查第一个sheet的行数是否超过10002行
if (sheet.getPhysicalNumberOfRows() > 10002) {
@@ -1039,7 +1040,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
// 设置下拉列表数据验证
DataValidationHelper validationHelper = templateSheet.getDataValidationHelper();
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);
validation.setSuppressDropDownArrow(true);
validation.setShowErrorBox(true);

View File

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

View File

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

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.code.ExpressServiceCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.util.*;
/**
* 顺丰插件
*
* @author admin
*/
@Slf4j
@@ -43,7 +43,8 @@ public class ShunfengPlugin implements LogisticsPlugin {
**/
private LogisticsSetting logisticsSetting;
public ShunfengPlugin(){}
public ShunfengPlugin() {
}
public ShunfengPlugin(LogisticsSetting logisticsSetting) {
this.logisticsSetting = logisticsSetting;
@@ -59,6 +60,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
*
* @param orderDetailVO
*/
@Override
public String createOrder(OrderDetailVO orderDetailVO) {
StoreDetailService storeService = SpringContextUtil.getBean(StoreDetailService.class);
StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = storeService.getStoreDeliverGoodsAddressDto(orderDetailVO.getOrder().getStoreId());
@@ -219,7 +221,6 @@ public class ShunfengPlugin implements LogisticsPlugin {
}
private String sendPost(IServiceCodeStandard standardService, Map<String, Object> msgDataMap) throws UnsupportedEncodingException {
CallExpressServiceTools tools = CallExpressServiceTools.getInstance();
Map<String, String> params = new HashMap<String, String>();
String timeStamp = String.valueOf(System.currentTimeMillis());
// 顾客编码
@@ -230,7 +231,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
params.put("timestamp", timeStamp);
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);
log.info("===调用地址 ===" + logisticsSetting.getCallUrl());

View File

@@ -335,6 +335,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
}
@DemoSite
@Override
public Member modifyPass(String oldPassword, String newPassword) {
AuthUser tokenUser = UserContext.getCurrentUser();
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.setErrorMessage("促销商品库存不足,现有库存数量[" + quantity + "]");

View File

@@ -1,13 +1,10 @@
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.lili.common.context.ThreadContextHolder;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.properties.ApiProperties;
import cn.lili.common.properties.DomainProperties;
import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.SnowFlake;
@@ -40,7 +37,6 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
@@ -90,13 +86,14 @@ public class AliPayPlugin implements Payment {
payModel.setBody(cashierParam.getTitle());
payModel.setSubject(cashierParam.getDetail());
payModel.setTotalAmount(cashierParam.getPrice() + "");
//回传数据
payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8));
//3分钟超时
payModel.setTimeoutExpress("3m");
payModel.setOutTradeNo(outTradeNo);
payModel.setProductCode("QUICK_WAP_PAY");
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));
AliPayRequest.wapPay(response, payModel, callbackUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY),
notifyUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY));
@@ -130,8 +127,8 @@ public class AliPayPlugin implements Payment {
//3分钟超时
payModel.setTimeoutExpress("3m");
//回传数据
payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8));
//回传数据(替换 Hutool 的 URLEncoder 为 JDK 的 java.net.URLEncoder
payModel.setPassbackParams(java.net.URLEncoder.encode(BeanUtil.formatKeyValuePair(payParam), "UTF-8"));
payModel.setOutTradeNo(outTradeNo);
payModel.setProductCode("QUICK_MSECURITY_PAY");
@@ -164,8 +161,8 @@ public class AliPayPlugin implements Payment {
payModel.setSubject(cashierParam.getDetail());
payModel.setTotalAmount(cashierParam.getPrice() + "");
//回传数据
payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8));
//回传数据(替换 Hutool 的 URLEncoder 为 JDK 的 java.net.URLEncoder
payModel.setPassbackParams(java.net.URLEncoder.encode(BeanUtil.formatKeyValuePair(payParam), "UTF-8"));
payModel.setTimeoutExpress("3m");
payModel.setOutTradeNo(outTradeNo);
log.info("支付宝扫码:{}", payModel);
@@ -314,7 +311,8 @@ public class AliPayPlugin implements Payment {
return;
}
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());
@@ -331,6 +329,8 @@ public class AliPayPlugin implements Payment {
}
} catch (AlipayApiException 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;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
@@ -67,7 +66,7 @@ public class UnionPayPlugin implements Payment {
String ip = IpKit.getRealIp(request);
//第三方付款订单
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()
.service(ServiceEnum.NATIVE.toString())
.mch_id(unionPaymentSetting.getUnionPayMachId())
@@ -94,12 +93,10 @@ public class UnionPayPlugin implements Payment {
@Override
public ResultMessage<Object> appPay(HttpServletRequest request, PayParam payParam) {
try {
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
UnionPaymentSetting unionPaymentSetting = this.unionPaymentSetting();
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
String ip = IpKit.getRealIp(request);
Map<String, String> params = UnifiedOrderModel.builder()
@@ -135,9 +132,7 @@ public class UnionPayPlugin implements Payment {
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
return null;
}
}
@@ -147,10 +142,12 @@ public class UnionPayPlugin implements Payment {
String buyerId="";
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
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
String ip = IpKit.getRealIp(request);
try {
String attach = java.net.URLEncoder.encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8.name());
if (StrUtil.isEmpty(buyerLogonId) && StrUtil.isEmpty(buyerId)) {
log.error("buyer_logon_id buyer_id 不能同时为空");
return null;

View File

@@ -1,7 +1,5 @@
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.lili.cache.Cache;
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 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();
@@ -158,12 +156,11 @@ public class WechatPlugin implements Payment {
}
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
}
// 构建service
H5Service service = new H5Service.Builder().config(config).build();
@@ -202,7 +199,6 @@ public class WechatPlugin implements Payment {
}
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
//支付金额
@@ -212,7 +208,8 @@ public class WechatPlugin implements Payment {
//过期时间
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();
String appid = setting.getJsapiAppId();
@@ -221,7 +218,7 @@ public class WechatPlugin implements Payment {
}
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
@@ -271,7 +268,8 @@ public class WechatPlugin implements Payment {
//过期时间
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();
String appid = setting.getJsapiAppId();
@@ -280,7 +278,7 @@ public class WechatPlugin implements Payment {
}
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
@@ -331,7 +329,8 @@ public class WechatPlugin implements Payment {
//过期时间
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();
@@ -341,7 +340,7 @@ public class WechatPlugin implements Payment {
}
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
@@ -405,12 +404,13 @@ public class WechatPlugin implements Payment {
if (StringUtils.isEmpty(appid)) {
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();
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
@@ -501,7 +501,6 @@ public class WechatPlugin implements Payment {
}
//获取用户openId
Connect connect = connectService.queryConnect(
ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId())
@@ -511,7 +510,7 @@ public class WechatPlugin implements Payment {
WechatPaymentSetting setting = wechatPaymentSetting();
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
@@ -572,7 +571,7 @@ public class WechatPlugin implements Payment {
WechatPaymentSetting setting = wechatPaymentSetting();
NotificationConfig config = null;
if(setting.getPublicType().equals("CERT")) {
if ("CERT".equals(setting.getPublicType())) {
config = new RSAAutoCertificateConfig.Builder()
.merchantId(setting.getMchId())
.privateKey(setting.getApiclientKey())
@@ -597,8 +596,10 @@ public class WechatPlugin implements Payment {
// 以支付通知回调为例,验签、解密并转换成 Transaction
Transaction transaction = parser.parse(requestParam, Transaction.class);
String payParamJson = URLDecoder.decode(transaction.getAttach(), StandardCharsets.UTF_8);
PayParam payParam = JSONUtil.toBean(payParamJson, PayParam.class);
// 将 Hutool URLDecoder 替换为标准库
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());
@@ -631,7 +632,7 @@ public class WechatPlugin implements Payment {
WechatPaymentSetting setting = wechatPaymentSetting();
Config config = null;
if(setting.getPublicType().equals("CERT")){
if ("CERT".equals(setting.getPublicType())) {
config = this.getCertificateConfig(setting);
} else {
config = this.getPublicKeyConfig(setting);
@@ -669,7 +670,7 @@ public class WechatPlugin implements Payment {
WechatPaymentSetting setting = wechatPaymentSetting();
NotificationConfig config = null;
if(setting.getPublicType().equals("CERT")) {
if ("CERT".equals(setting.getPublicType())) {
config = new RSAAutoCertificateConfig.Builder()
.merchantId(setting.getMchId())
.privateKey(setting.getApiclientKey())
@@ -721,6 +722,7 @@ public class WechatPlugin implements Payment {
/**
* 获取微信公钥配置
*
* @param setting
* @return
*/
@@ -738,6 +740,7 @@ public class WechatPlugin implements Payment {
/**
* 获取微信证书配置
*
* @param setting
* @return
*/
@@ -752,15 +755,16 @@ public class WechatPlugin implements Payment {
/**
* 修改订单支付单号
*
* @param payParam 支付参数
* @param outOrderNo 订单号
*/
private void updateOrderPayNo(PayParam payParam, String outOrderNo) {
if(payParam.getOrderType().equals("ORDER")){
if ("ORDER".equals(payParam.getOrderType())) {
orderService.update(new LambdaUpdateWrapper<Order>()
.eq(Order::getSn, payParam.getSn())
.set(Order::getPayOrderNo, outOrderNo));
}else if(payParam.getOrderType().equals("TRADE")){
} else if ("TRADE".equals(payParam.getOrderType())) {
orderService.update(new LambdaUpdateWrapper<Order>()
.eq(Order::getTradeSn, payParam.getSn())
.set(Order::getPayOrderNo, outOrderNo));

View File

@@ -411,9 +411,12 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<Cou
//判断优惠券的发送范围,获取会员列表
List<String> ids = new ArrayList<>();
if (JSONUtil.isJsonArray(couponActivity.getActivityScopeInfo())) {
JSONArray array = JSONUtil.parseArray(couponActivity.getActivityScopeInfo());
String scopeInfo = couponActivity.getActivityScopeInfo();
try {
JSONArray array = JSONUtil.parseArray(scopeInfo);
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);
}

View File

@@ -87,6 +87,7 @@ public class PromotionServiceImpl implements PromotionService {
* @param goodsSkuId 商品skuId
* @return 当前促销活动集合
*/
@Override
public Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId) {
String storeIds = storeId + "," + PromotionTools.PLATFORM_ID;
List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(goodsSkuId, storeIds);
@@ -99,7 +100,7 @@ public class PromotionServiceImpl implements PromotionService {
promotionGoodsService.deletePromotionGoodsByGoods(goodsIds);
kanjiaActivityGoodsService.deleteByGoodsIds(goodsIds);
}
@Override
public Map<String, Object> wrapperPromotionMapList(List<PromotionGoods> promotionGoodsList) {
Map<String, Object> promotionMap = new HashMap<>();
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 {
/**
* 删除下架商品索引
*/
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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;
@@ -26,6 +28,16 @@ public interface EsGoodsSearchService {
*/
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 商品索引
*/
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.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.thread.ThreadUtil;
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.EsSuffix;
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.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.BrandService;
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.goods.service.*;
import cn.lili.modules.promotion.entity.dos.BasePromotions;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
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.EsGoodsAttribute;
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.repository.EsGoodsIndexRepository;
import cn.lili.modules.search.service.CustomWordsService;
import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.search.service.EsGoodsSearchService;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
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.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -65,10 +68,13 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
import org.springframework.beans.factory.annotation.Autowired;
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.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
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.stereotype.Service;
@@ -111,6 +117,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired
private GoodsSkuService goodsSkuService;
@Autowired
private GoodsService goodsService;
@Autowired
private BrandService brandService;
@Autowired
@@ -119,6 +127,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired
private StoreGoodsLabelService storeGoodsLabelService;
@Autowired
private EsGoodsSearchService esGoodsSearchService;
@Autowired
private Cache<Object> cache;
/**
* rocketMq
@@ -145,6 +155,126 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
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
public void init() {
//获取索引任务标识
@@ -248,9 +378,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
List<PromotionGoods> promotionGoods = skuValidPromotions.stream()
.filter(j ->
(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.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()))
)
.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修改商品活动索引-原商品索引活动信息:{}", 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);
} 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.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.*;
@@ -98,6 +99,12 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
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
public Page<EsGoodsIndex> searchGoodsByPage(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
// 判断商品索引是否存在
@@ -402,7 +409,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
* @param pageVo 分页参数
* @return es搜索builder
*/
private NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
@Override
public NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
if (pageVo != null) {
int pageNumber = pageVo.getPageNumber() - 1;

View File

@@ -123,7 +123,7 @@ public class SmsUtilAliImplService implements SmsUtil {
@Override
public boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code) {
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));
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 {
//必填,请参考"开发准备"获取如下数据,替换为实际值
String url = "https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1"; //APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
String appKey = smsSetting.getHuaweiAppKey(); //APP_Key
String appSecret = smsSetting.getHuaweiAppSecret(); //APP_Secret
String sender = smsSetting.getHuaweiSender(); //国内短信签名通道号或国际/港澳台短信通道号
String templateId = templateCode; //模板ID
//APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
String url = "https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1";
String appKey = smsSetting.getHuaweiAppKey();
String appSecret = smsSetting.getHuaweiAppSecret();
String sender = smsSetting.getHuaweiSender();
//条件必填,国内短信关注,当templateId指定的模板类型为通用模板时生效且必填,必须是已审核通过的,与模板类型一致的签名名称
//国际/港澳台短信不用关注该参数
String signature = smsSetting.getHuaweiSignature(); //签名名称
// 模板ID
String templateId = templateCode;
//必填,全局号码格式(包含国家码),示例:+8615123456789,多个号码之间用英文逗号分隔
String receiver = mobile; //短信接收人号码
// 签名名称
String signature = smsSetting.getHuaweiSignature();
//选填,短信状态报告接收地址,推荐使用域名,为空或者不填表示不接收状态报告
String receiver = mobile;
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
String body = buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature);
@@ -179,12 +180,14 @@ public class HuaweiSmsPlugin implements SmsPlugin {
connection.connect();
out = new OutputStreamWriter(connection.getOutputStream());
out.write(body); //发送请求Body参数
// 发送请求Body参数
out.write(body);
out.flush();
out.close();
int status = connection.getResponseCode();
if (200 == status) { //200
if (200 == status) {
is = connection.getInputStream();
} else { //400/401
is = connection.getErrorStream();
@@ -194,7 +197,9 @@ public class HuaweiSmsPlugin implements SmsPlugin {
while ((line = in.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString()); //打印响应消息实体
// 打印响应消息实体
System.out.println(result.toString());
} catch (Exception e) {
e.printStackTrace();
} finally {
@@ -275,8 +280,12 @@ public class HuaweiSmsPlugin implements SmsPlugin {
return null;
}
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;
byte[] passwordDigest = null;
@@ -289,8 +298,8 @@ public class HuaweiSmsPlugin implements SmsPlugin {
e.printStackTrace();
}
//如果JDK版本是1.8,请加载原生Base64类,并使用如下代码
String passwordDigestBase64Str = Base64.getEncoder().encodeToString(passwordDigest); //PasswordDigest
// PasswordDigest
String passwordDigestBase64Str = Base64.getEncoder().encodeToString(passwordDigest);
//如果JDK版本低于1.8,请加载三方库提供Base64类,并使用如下代码
//String passwordDigestBase64Str = Base64.encodeBase64String(passwordDigest); //PasswordDigest
//若passwordDigestBase64Str中包含换行符,请执行如下代码进行修正
@@ -303,14 +312,15 @@ public class HuaweiSmsPlugin implements SmsPlugin {
static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return;
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return;
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}

View File

@@ -27,6 +27,7 @@ public interface RegionService extends IService<Region> {
* @return
*/
@CacheEvict(allEntries = true)
@Override
boolean updateById(Region region);
/**
* 更新地区
@@ -35,6 +36,7 @@ public interface RegionService extends IService<Region> {
* @return
*/
@CacheEvict(allEntries = true)
@Override
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.vo.ResultMessage;
import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.system.aspect.annotation.SystemLogPoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -36,4 +39,30 @@ public class ElasticsearchController {
public ResultMessage<Map<String, Long>> 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 {
Claims claims
= Jwts.parser()
= Jwts.parserBuilder()
.setSigningKey(SecretKeyUtil.generalKeyByDecoders())
.build()
.parseClaimsJws(jwt).getBody();
//获取存储在claims中的用户信息
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();

View File

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