|
@@ -126,7 +126,7 @@ public class BotRest {
|
|
|
|
|
|
// 防止发送消息过快
|
|
|
try {
|
|
|
- Thread.sleep(500);
|
|
|
+ Thread.sleep(1000);
|
|
|
} catch (InterruptedException e) {
|
|
|
log.error("线程中断: {}", e.getMessage(), e);
|
|
|
}
|
|
@@ -143,8 +143,13 @@ public class BotRest {
|
|
|
private void sendMessageAndLog(BotMessage message, String content) {
|
|
|
SendMessage sendMessage = new SendMessage(message.getBotGroup().getDataId(), content);
|
|
|
SendResponse execute = message.getTelegramBot().execute(sendMessage);
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
if (!execute.isOk()) {
|
|
|
- log.error("发送消息失败, 错误信息: {}", execute.description());
|
|
|
+ log.error("发送消息失败,群组ID: {}, 错误信息: {}", message.getBotGroup().getDataId(), execute.description());
|
|
|
} else {
|
|
|
log.info("发送消息成功, 群组ID: {}, 内容: {}", message.getBotGroup().getDataId(), content);
|
|
|
}
|
|
@@ -218,7 +223,7 @@ public class BotRest {
|
|
|
|
|
|
// 防止发送消息过快
|
|
|
try {
|
|
|
- Thread.sleep(500);
|
|
|
+ Thread.sleep(1000);
|
|
|
} catch (InterruptedException e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
@@ -287,6 +292,11 @@ public class BotRest {
|
|
|
// ================= 发送账单 =================
|
|
|
SendMessage sendMessage = new SendMessage(mchGroup.getGroupId(), stringBuilder.toString());
|
|
|
SendResponse execute = message.getTelegramBot().execute(sendMessage);
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
if (!execute.isOk()) {
|
|
|
log.error("一键结算发送消息失败, 错误信息: {}", execute.description());
|
|
|
return false;
|
|
@@ -381,11 +391,15 @@ public class BotRest {
|
|
|
// ================= 发送账单 =================
|
|
|
SendMessage sendMessage = new SendMessage(mchGroup.getGroupId(), stringBuilder.toString());
|
|
|
SendResponse execute = message.getTelegramBot().execute(sendMessage);
|
|
|
+ try {
|
|
|
+ Thread.sleep(2000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
if (!execute.isOk()) {
|
|
|
log.error("一键结算发送消息失败, 错误信息: {}", execute.description());
|
|
|
return false;
|
|
|
} else {
|
|
|
- // ================= 更新商户账本 =================
|
|
|
BotAccountBook accountBook = handlerManager.getAccountBookRepository()
|
|
|
.findByBelongIdAndType(mchGroup.getDataId(), DATA_TYPE_CHANNEL);
|
|
|
|
|
@@ -407,7 +421,11 @@ public class BotRest {
|
|
|
for (BotGroup botGroup : botGroups) {
|
|
|
BotAccountBook accountBookchannl = handlerManager.getAccountBookRepository()
|
|
|
.findByBelongIdAndType(botGroup.getDataId(), DATA_TYPE_CHANNEL);
|
|
|
- oldPaymentBalance += accountBookchannl.getPaymentBalance();
|
|
|
+ if (accountBookchannl == null) {
|
|
|
+ oldPaymentBalance += 0;
|
|
|
+ } else {
|
|
|
+ oldPaymentBalance += accountBookchannl.getPaymentBalance();
|
|
|
+ }
|
|
|
}
|
|
|
oldPaymentBalance += accountBookAll.getPaymentBalance();
|
|
|
double newPaymentBalance = BigDecimal.valueOf(oldPaymentBalance)
|