Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5b1c38f71 | ||
|
|
e1f834313a | ||
|
|
dedcc0a556 | ||
|
|
33fcce1cc9 | ||
|
|
85c8c5d021 | ||
|
|
2ab2c4ff5d | ||
|
|
feff49c79b |
@@ -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群**:
|
||||

|
||||
|
||||
- **社区贡献内容**:
|
||||
|
||||
@@ -91,15 +91,16 @@ public class BuyerAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
|
||||
try {
|
||||
Claims claims
|
||||
= Jwts.parser()
|
||||
= Jwts.parserBuilder()
|
||||
.setSigningKey(SecretKeyUtil.generalKeyByDecoders())
|
||||
.build()
|
||||
.parseClaimsJws(jwt).getBody();
|
||||
//获取存储在claims中的用户信息
|
||||
// 获取存储在claims中的用户信息
|
||||
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();
|
||||
AuthUser authUser = new Gson().fromJson(json, AuthUser.class);
|
||||
|
||||
//校验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<>();
|
||||
auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name()));
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接错误消息
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -144,7 +144,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
|
||||
BufferedReader bufferedReader = null;
|
||||
|
||||
InputStreamReader reader = null;
|
||||
|
||||
//获取输入流
|
||||
@@ -163,47 +162,55 @@ 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());
|
||||
//创建空的map用于存储结果
|
||||
Map<String, Object> resultMap = new HashMap<>(map.size());
|
||||
//遍历数组
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//如果map.get(key)获取到的是字符串就需要进行处理,如果不是直接存储resultMap
|
||||
if (map.get(entry.getKey()) instanceof String) {
|
||||
resultMap.put(entry.getKey(), filterXss(entry.getKey(), entry.getValue().toString()));
|
||||
} else {
|
||||
resultMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
// 兼容替换:不再使用过时的 JSONUtil.isJsonObj(String),改为尝试解析并捕获异常
|
||||
if (CharSequenceUtil.isNotEmpty(body)) {
|
||||
Map<String, Object> map = null;
|
||||
try {
|
||||
map = JSONUtil.parseObj(body.toString());
|
||||
} catch (Exception ignore) {
|
||||
map = null;
|
||||
}
|
||||
|
||||
//将resultMap转换为json字符串
|
||||
String resultStr = JSONUtil.toJsonStr(resultMap);
|
||||
//将json字符串转换为字节
|
||||
final ByteArrayInputStream resultBIS = new ByteArrayInputStream(resultStr.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
//实现接口
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
if (map != null) {
|
||||
//创建空的map用于存储结果
|
||||
Map<String, Object> resultMap = new HashMap<>(map.size());
|
||||
//遍历数组
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//如果map.get(key)获取到的是字符串就需要进行处理,如果不是直接存储resultMap
|
||||
if (map.get(entry.getKey()) instanceof String) {
|
||||
resultMap.put(entry.getKey(), filterXss(entry.getKey(), entry.getValue().toString()));
|
||||
} else {
|
||||
resultMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
//将resultMap转换为json字符串
|
||||
String resultStr = JSONUtil.toJsonStr(resultMap);
|
||||
//将json字符串转换为字节
|
||||
final ByteArrayInputStream resultBIS = new ByteArrayInputStream(resultStr.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
//实现接口
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return resultBIS.read();
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return resultBIS.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//将json字符串转换为字节
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
//创建索引
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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() + "," +
|
||||
//发件人信息
|
||||
"'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() + "'" + //收件人详细地址
|
||||
"}," +
|
||||
//商品信息
|
||||
"'Commodity': [";
|
||||
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() + "'"
|
||||
+ "},"
|
||||
// 收件人信息
|
||||
+ "'Receiver': {"
|
||||
+ "'Name': '" + order.getConsigneeName() + "',"
|
||||
+ "'Mobile': '" + order.getConsigneeMobile() + "',"
|
||||
// 省
|
||||
+ "'ProvinceName': '" + ConsigneeAddress[0] + "',"
|
||||
// 市
|
||||
+ "'CityName': '" + ConsigneeAddress[1] + "',"
|
||||
// 区
|
||||
+ "'ExpAreaName': '" + ConsigneeAddress[2] + "',"
|
||||
// 收件人详细地址
|
||||
+ "'Address': '" + order.getConsigneeDetail() + "'"
|
||||
+ "},"
|
||||
// 商品信息
|
||||
+ "'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<>();
|
||||
@@ -200,9 +217,9 @@ public class KdniaoPlugin implements LogisticsPlugin {
|
||||
JSONObject obj = JSONObject.parseObject(result);
|
||||
log.info("电子面单响应:{}", result);
|
||||
if (!"100".equals(obj.getString("ResultCode"))) {
|
||||
// resultMap.put("Reason",obj.getString("Reason"));
|
||||
// resultMap.put("Reason",obj.getString("Reason"));
|
||||
throw new ServiceException(obj.getString("Reason"));
|
||||
// return resultMap;
|
||||
// return resultMap;
|
||||
}
|
||||
|
||||
JSONObject orderJson = JSONObject.parseObject(obj.getString("Order"));
|
||||
|
||||
@@ -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,10 +60,11 @@ 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());
|
||||
if(storeDeliverGoodsAddressDTO == null){
|
||||
if (storeDeliverGoodsAddressDTO == null) {
|
||||
throw new ServiceException(ResultCode.STORE_DELIVER_ADDRESS_EXIST);
|
||||
}
|
||||
try {
|
||||
@@ -108,7 +110,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
|
||||
|
||||
String result = sendPost(ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER, msgDataMap);
|
||||
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();
|
||||
}
|
||||
throw new ServiceException(resultData.get("errorMsg").toString());
|
||||
@@ -141,10 +143,10 @@ public class ShunfengPlugin implements LogisticsPlugin {
|
||||
msgDataMap.put("trackingNumber", trackingNumber);
|
||||
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_ROUTES, msgDataMap));
|
||||
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");
|
||||
List<Map> routes = routesJson.toList(Map.class);
|
||||
return new Traces(logistics.getName(),expNo,routes);
|
||||
return new Traces(logistics.getName(), expNo, routes);
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -164,7 +166,7 @@ public class ShunfengPlugin implements LogisticsPlugin {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String,Object> labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
public Map<String, Object> labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
try {
|
||||
Map<String, Object> msgDataMap = new HashMap<>();
|
||||
//模板编码
|
||||
@@ -173,15 +175,15 @@ public class ShunfengPlugin implements LogisticsPlugin {
|
||||
//业务数据
|
||||
Map<String, Object> documents = new HashMap<>();
|
||||
documents.put("masterWaybillNo", labelOrderDTO.getOrder().getLogisticsNo());
|
||||
msgDataMap.put("documents",documents);
|
||||
msgDataMap.put("sync",true);
|
||||
msgDataMap.put("documents", documents);
|
||||
msgDataMap.put("sync", true);
|
||||
/**
|
||||
* 版本号,传固定值:2.0
|
||||
*/
|
||||
msgDataMap.put("version", "2.0");
|
||||
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.COM_RECE_CLOUD_PRINT_WAYBILLS, msgDataMap));
|
||||
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);
|
||||
}
|
||||
throw new ServiceException(resultData.getJSONArray("errorMessage").get(0).toString());
|
||||
@@ -204,13 +206,13 @@ public class ShunfengPlugin implements LogisticsPlugin {
|
||||
//校验类型 1,电话号码校验 2,月结卡号校验
|
||||
msgDataMap.put("checkType", 1);
|
||||
//校验值 当校验类型为1时传电话号码 当校验类型为2时传月结卡号
|
||||
List<String> mobileList= new ArrayList<>();
|
||||
List<String> mobileList = new ArrayList<>();
|
||||
mobileList.add(checkNos);
|
||||
msgDataMap.put("checkNos", mobileList);
|
||||
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_PROMITM, msgDataMap));
|
||||
JSONObject resultData = result.getJSONObject("apiResultData");
|
||||
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){
|
||||
return resultData.getJSONObject("msgData").get("promiseTm").toString();
|
||||
if (Boolean.TRUE.toString().equals(resultData.get("success").toString())) {
|
||||
return resultData.getJSONObject("msgData").get("promiseTm").toString();
|
||||
}
|
||||
throw new ServiceException(resultData.get("errorMsg").toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 + "]");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
@@ -157,13 +155,12 @@ public class WechatPlugin implements Payment {
|
||||
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
|
||||
}
|
||||
|
||||
Config config =null;
|
||||
if(setting.getPublicType().equals("CERT")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
|
||||
// 构建service
|
||||
H5Service service = new H5Service.Builder().config(config).build();
|
||||
|
||||
@@ -181,7 +178,7 @@ public class WechatPlugin implements Payment {
|
||||
prepayRequest.setSceneInfo(sceneInfo);
|
||||
// 调用下单方法,得到应答
|
||||
com.wechat.pay.java.service.payments.h5.model.PrepayResponse response = service.prepay(prepayRequest);
|
||||
updateOrderPayNo(payParam,outOrderNo);
|
||||
updateOrderPayNo(payParam, outOrderNo);
|
||||
|
||||
return ResultUtil.data(response.getH5Url());
|
||||
} catch (Exception e) {
|
||||
@@ -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();
|
||||
@@ -220,11 +217,11 @@ public class WechatPlugin implements Payment {
|
||||
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
|
||||
}
|
||||
|
||||
Config config =null;
|
||||
if(setting.getPublicType().equals("CERT")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
// 构建service
|
||||
JsapiService service = new JsapiService.Builder().config(config).build();
|
||||
@@ -246,7 +243,7 @@ public class WechatPlugin implements Payment {
|
||||
prepayRequest.setPayer(payer);
|
||||
// 调用下单方法,得到应答
|
||||
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());
|
||||
log.info("唤起支付参数:{}", map);
|
||||
@@ -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();
|
||||
@@ -279,11 +277,11 @@ public class WechatPlugin implements Payment {
|
||||
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
|
||||
}
|
||||
|
||||
Config config =null;
|
||||
if(setting.getPublicType().equals("CERT")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
// 构建service
|
||||
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);
|
||||
updateOrderPayNo(payParam,outOrderNo);
|
||||
updateOrderPayNo(payParam, outOrderNo);
|
||||
Map<String, String> map = WxPayKit.appPrepayIdCreateSign(appid,
|
||||
setting.getMchId(),
|
||||
response.getPrepayId(),
|
||||
setting.getApiclientKey(), SignType.MD5);
|
||||
log.info("唤起支付参数:{}", map);
|
||||
//修改付款单号
|
||||
updateOrderPayNo(payParam,outOrderNo);
|
||||
updateOrderPayNo(payParam, outOrderNo);
|
||||
return ResultUtil.data(map);
|
||||
} catch (Exception e) {
|
||||
log.error("支付异常", e);
|
||||
@@ -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();
|
||||
|
||||
@@ -340,11 +339,11 @@ public class WechatPlugin implements Payment {
|
||||
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
|
||||
}
|
||||
|
||||
Config config =null;
|
||||
if(setting.getPublicType().equals("CERT")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
// 构建service
|
||||
NativePayService service = new NativePayService.Builder().config(config).build();
|
||||
@@ -363,7 +362,7 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
// 调用下单方法,得到应答
|
||||
PrepayResponse response = service.prepay(prepayRequest);
|
||||
updateOrderPayNo(payParam,outOrderNo);
|
||||
updateOrderPayNo(payParam, outOrderNo);
|
||||
return ResultUtil.data(response.getCodeUrl());
|
||||
|
||||
} catch (ServiceException e) {
|
||||
@@ -405,15 +404,16 @@ 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")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
// 构建service
|
||||
JsapiService service = new JsapiService.Builder().config(config).build();
|
||||
@@ -432,7 +432,7 @@ public class WechatPlugin implements Payment {
|
||||
prepayRequest.setPayer(payer);
|
||||
// 调用下单方法,得到应答
|
||||
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());
|
||||
log.info("唤起支付参数:{}", map);
|
||||
@@ -501,7 +501,6 @@ public class WechatPlugin implements Payment {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取用户openId
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId())
|
||||
@@ -510,11 +509,11 @@ public class WechatPlugin implements Payment {
|
||||
//获取微信设置
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
|
||||
Config config =null;
|
||||
if(setting.getPublicType().equals("CERT")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
// 构建service
|
||||
TransferBatchService service = new TransferBatchService.Builder().config(config).build();
|
||||
@@ -544,7 +543,7 @@ public class WechatPlugin implements Payment {
|
||||
log.info("微信提现响应 {}", response);
|
||||
|
||||
|
||||
return TransferResultDTO.builder().result(response.getBatchId()!= null).build();
|
||||
return TransferResultDTO.builder().result(response.getBatchId() != null).build();
|
||||
//根据自身业务进行接下来的任务处理
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -571,23 +570,23 @@ public class WechatPlugin implements Payment {
|
||||
.build();
|
||||
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
NotificationConfig config=null;
|
||||
if(setting.getPublicType().equals("CERT")) {
|
||||
config = new RSAAutoCertificateConfig.Builder()
|
||||
NotificationConfig config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(setting.getMchId())
|
||||
.privateKey(setting.getApiclientKey())
|
||||
.merchantSerialNumber(setting.getSerialNumber())
|
||||
.apiV3Key(setting.getApiKey3())
|
||||
.build();
|
||||
}else{
|
||||
config = new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(setting.getMchId())
|
||||
.apiV3Key(setting.getApiKey3())
|
||||
.privateKey(setting.getApiclientKey())
|
||||
.merchantSerialNumber(setting.getSerialNumber())
|
||||
.publicKeyId(setting.getPublicId())
|
||||
.publicKey(setting.getPublicKey())
|
||||
.build();
|
||||
} else {
|
||||
config = new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(setting.getMchId())
|
||||
.apiV3Key(setting.getApiKey3())
|
||||
.privateKey(setting.getApiclientKey())
|
||||
.merchantSerialNumber(setting.getSerialNumber())
|
||||
.publicKeyId(setting.getPublicId())
|
||||
.publicKey(setting.getPublicKey())
|
||||
.build();
|
||||
}
|
||||
|
||||
// 初始化 NotificationParser
|
||||
@@ -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());
|
||||
|
||||
@@ -630,11 +631,11 @@ public class WechatPlugin implements Payment {
|
||||
//获取微信设置
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
|
||||
Config config =null;
|
||||
if(setting.getPublicType().equals("CERT")){
|
||||
config=this.getCertificateConfig(setting);
|
||||
}else {
|
||||
config=this.getPublicKeyConfig(setting);
|
||||
Config config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = this.getCertificateConfig(setting);
|
||||
} else {
|
||||
config = this.getPublicKeyConfig(setting);
|
||||
}
|
||||
// 构建service
|
||||
RefundService refundService = new RefundService.Builder().config(config).build();
|
||||
@@ -646,7 +647,7 @@ public class WechatPlugin implements Payment {
|
||||
request.setReason(refundLog.getRefundReason());
|
||||
request.setNotifyUrl(refundNotifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT));
|
||||
|
||||
Refund refund=refundService.create(request);
|
||||
Refund refund = refundService.create(request);
|
||||
|
||||
log.info("微信退款响应 {}", refund);
|
||||
refundLogService.save(refundLog);
|
||||
@@ -668,15 +669,15 @@ public class WechatPlugin implements Payment {
|
||||
.build();
|
||||
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
NotificationConfig config=null;
|
||||
if(setting.getPublicType().equals("CERT")) {
|
||||
NotificationConfig config = null;
|
||||
if ("CERT".equals(setting.getPublicType())) {
|
||||
config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(setting.getMchId())
|
||||
.privateKey(setting.getApiclientKey())
|
||||
.merchantSerialNumber(setting.getSerialNumber())
|
||||
.apiV3Key(setting.getApiKey3())
|
||||
.build();
|
||||
}else{
|
||||
} else {
|
||||
config = new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(setting.getMchId())
|
||||
.apiV3Key(setting.getApiKey3())
|
||||
@@ -721,10 +722,11 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
/**
|
||||
* 获取微信公钥配置
|
||||
*
|
||||
* @param setting
|
||||
* @return
|
||||
*/
|
||||
private RSAPublicKeyConfig getPublicKeyConfig(WechatPaymentSetting setting){
|
||||
private RSAPublicKeyConfig getPublicKeyConfig(WechatPaymentSetting setting) {
|
||||
return
|
||||
new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(setting.getMchId())
|
||||
@@ -738,6 +740,7 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
/**
|
||||
* 获取微信证书配置
|
||||
*
|
||||
* @param setting
|
||||
* @return
|
||||
*/
|
||||
@@ -752,18 +755,19 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
/**
|
||||
* 修改订单支付单号
|
||||
* @param payParam 支付参数
|
||||
*
|
||||
* @param payParam 支付参数
|
||||
* @param outOrderNo 订单号
|
||||
*/
|
||||
private void updateOrderPayNo(PayParam payParam,String outOrderNo ){
|
||||
if(payParam.getOrderType().equals("ORDER")){
|
||||
private void updateOrderPayNo(PayParam payParam, String outOrderNo) {
|
||||
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")){
|
||||
.eq(Order::getSn, payParam.getSn())
|
||||
.set(Order::getPayOrderNo, outOrderNo));
|
||||
} else if ("TRADE".equals(payParam.getOrderType())) {
|
||||
orderService.update(new LambdaUpdateWrapper<Order>()
|
||||
.eq(Order::getTradeSn,payParam.getSn())
|
||||
.set(Order::getPayOrderNo,outOrderNo));
|
||||
.eq(Order::getTradeSn, payParam.getSn())
|
||||
.set(Order::getPayOrderNo, outOrderNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -19,6 +19,18 @@ import java.util.Map;
|
||||
**/
|
||||
public interface EsGoodsIndexService {
|
||||
|
||||
/**
|
||||
* 删除下架商品索引
|
||||
*/
|
||||
Boolean deleteGoodsDown();
|
||||
|
||||
/**
|
||||
* 删除不存在的索引
|
||||
* @return
|
||||
*/
|
||||
Boolean delSkuIndex();
|
||||
|
||||
Boolean goodsCache();
|
||||
/**
|
||||
* 全局索引数据初始化
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user