fix: 微信支付,创建失败,问题修复。
This commit is contained in:
@@ -7,6 +7,7 @@ import com.intc.common.core.utils.StringUtils;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.intc.fishery.constant.DefineDeviceWarnCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -172,9 +173,15 @@ public class PayDeviceServiceImpl implements IPayDeviceService {
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
|
||||
// 4. 直接更新设备的到期时间为前端传来的新到期时间
|
||||
// 4. 直接更新设备的到期时间为前端传来的新到期时间,同时清除「设备到期」告警位
|
||||
Integer oldWarnCode = device.getWarnCode();
|
||||
if (oldWarnCode != null) {
|
||||
device.setWarnCode(oldWarnCode & ~DefineDeviceWarnCode.DeviceTimeDead);
|
||||
}
|
||||
device.setDeadTime(bo.getDeadTime());
|
||||
deviceMapper.updateById(device);
|
||||
log.info("后台续费成功,更新设备到期时间并清除到期告警: serialNum={}, newDeadTime={}, oldWarnCode={}, newWarnCode={}",
|
||||
device.getSerialNum(), bo.getDeadTime(), oldWarnCode, device.getWarnCode());
|
||||
}
|
||||
|
||||
return flag;
|
||||
|
||||
@@ -59,13 +59,16 @@ public class WxPayConfiguration {
|
||||
log.info("使用私钥路径配置: {}", wxPayProperties.getPrivateKeyPath());
|
||||
}
|
||||
|
||||
// 商户证书配置(V3 API必须,apiclient_cert.pem)
|
||||
if (wxPayProperties.getPrivateCertContent() != null && !wxPayProperties.getPrivateCertContent().isEmpty()) {
|
||||
payConfig.setPrivateCertContent(wxPayProperties.getPrivateCertContent().getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
// 商户证书配置(apiclient_cert.pem),有真实PEM内容才设置,避免占位符导致v3请求构造异常
|
||||
String privateCertContent = wxPayProperties.getPrivateCertContent();
|
||||
if (privateCertContent != null && privateCertContent.startsWith("-----BEGIN CERTIFICATE-----")) {
|
||||
payConfig.setPrivateCertContent(privateCertContent.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
log.info("使用商户证书内容配置");
|
||||
} else if (wxPayProperties.getPrivateCertPath() != null) {
|
||||
payConfig.setPrivateCertPath(wxPayProperties.getPrivateCertPath());
|
||||
log.info("使用商户证书路径配置: {}", wxPayProperties.getPrivateCertPath());
|
||||
} else {
|
||||
log.info("未配置商户证书,将使用私钥直接签名");
|
||||
}
|
||||
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.intc.common.core.exception.ServiceException;
|
||||
import com.intc.fishery.constant.DefineDeviceWarnCode;
|
||||
import com.intc.fishery.domain.Device;
|
||||
import com.intc.fishery.domain.PayDevice;
|
||||
import com.intc.fishery.domain.PayOrder;
|
||||
@@ -313,15 +314,22 @@ public class PayOrderBusinessServiceImpl implements PayOrderBusinessService {
|
||||
// 计算新的到期时间
|
||||
Date newDeadTime = calculateNewDeadTime(device.getDeadTime(), payDevice.getAddMonth());
|
||||
|
||||
// 更新设备到期时间
|
||||
// 清除 warnCode 中的「设备到期」标志位(续费后恢复正常状态)
|
||||
Integer oldWarnCode = device.getWarnCode();
|
||||
Integer newWarnCode = oldWarnCode != null
|
||||
? (oldWarnCode & ~DefineDeviceWarnCode.DeviceTimeDead)
|
||||
: 0;
|
||||
|
||||
// 更新设备到期时间,并同步清除到期告警位
|
||||
deviceMapper.update(null,
|
||||
new LambdaUpdateWrapper<Device>()
|
||||
.eq(Device::getId, device.getId())
|
||||
.set(Device::getDeadTime, newDeadTime)
|
||||
.set(Device::getWarnCode, newWarnCode)
|
||||
);
|
||||
|
||||
log.info("更新设备到期时间: deviceId={}, serialNum={}, newDeadTime={}",
|
||||
device.getId(), device.getSerialNum(), newDeadTime);
|
||||
log.info("续费成功,更新设备到期时间并清除到期告警: deviceId={}, serialNum={}, newDeadTime={}, oldWarnCode={}, newWarnCode={}",
|
||||
device.getId(), device.getSerialNum(), newDeadTime, oldWarnCode, newWarnCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user