|
@@ -16,6 +16,7 @@ import org.jebot.handler.dto.BotMessage;
|
|
import org.jebot.models.jebot.BotAccountBook;
|
|
import org.jebot.models.jebot.BotAccountBook;
|
|
import org.jebot.models.jebot.BotComplaint;
|
|
import org.jebot.models.jebot.BotComplaint;
|
|
import org.jebot.models.jebot.BotGroup;
|
|
import org.jebot.models.jebot.BotGroup;
|
|
|
|
+import org.jebot.models.xxpay.BlackUser;
|
|
import org.jebot.models.xxpay.PayOrder;
|
|
import org.jebot.models.xxpay.PayOrder;
|
|
import org.jebot.repository.jebot.BotAccountBookRepository;
|
|
import org.jebot.repository.jebot.BotAccountBookRepository;
|
|
import org.jebot.service.dto.UpdateBalance;
|
|
import org.jebot.service.dto.UpdateBalance;
|
|
@@ -124,21 +125,39 @@ public class ComplaintHandler extends AbstractHandler {
|
|
BotAccountBook channelAccountBook = accountBookRepository.findByBelongIdAndType(channelGroup.getDataId(), Constant.DATA_TYPE_CHANNEL);
|
|
BotAccountBook channelAccountBook = accountBookRepository.findByBelongIdAndType(channelGroup.getDataId(), Constant.DATA_TYPE_CHANNEL);
|
|
if (channelAccountBook == null) {
|
|
if (channelAccountBook == null) {
|
|
channelAccountBook = new BotAccountBook();
|
|
channelAccountBook = new BotAccountBook();
|
|
- channelAccountBook.setBelongId(merchantGroup.getDataId());
|
|
|
|
- channelAccountBook.setBelongName(merchantGroup.getDataName());
|
|
|
|
- channelAccountBook.setType(Constant.DATA_TYPE_MERCHANT);
|
|
|
|
|
|
+ channelAccountBook.setBelongId(channelGroup.getDataId()); // ✅ 通道ID
|
|
|
|
+ channelAccountBook.setBelongName(channelGroup.getDataName()); // ✅ 通道名称
|
|
|
|
+ channelAccountBook.setType(Constant.DATA_TYPE_CHANNEL); // ✅ 通道类型
|
|
channelAccountBook.setPaymentBalance(0);
|
|
channelAccountBook.setPaymentBalance(0);
|
|
channelAccountBook.setAgentBalance(0);
|
|
channelAccountBook.setAgentBalance(0);
|
|
- channelAccountBook = accountBookRepository.save(merchantAccountBook);
|
|
|
|
|
|
+ channelAccountBook = accountBookRepository.save(channelAccountBook); // ✅ 保存通道账本
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //更新总通道余额
|
|
|
|
+ BotAccountBook channelAllAccountBook = accountBookRepository.findByBelongIdAndType(channelGroup.getGroupId(), Constant.DATA_TYPE_CHANNEL);
|
|
|
|
+ if (channelAllAccountBook == null) {
|
|
|
|
+ channelAllAccountBook = new BotAccountBook();
|
|
|
|
+ channelAllAccountBook.setBelongId(channelGroup.getDataId()); // ✅ 通道ID
|
|
|
|
+ channelAllAccountBook.setBelongName(channelGroup.getDataName()); // ✅ 通道名称
|
|
|
|
+ channelAllAccountBook.setType(Constant.DATA_TYPE_CHANNEL); // ✅ 通道类型
|
|
|
|
+ channelAllAccountBook.setPaymentBalance(0);
|
|
|
|
+ channelAllAccountBook.setAgentBalance(0);
|
|
|
|
+ channelAllAccountBook = accountBookRepository.save(channelAllAccountBook); // ✅ 保存通道账本
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
double oldMerchantPaymentBalance = merchantAccountBook.getPaymentBalance();
|
|
double oldMerchantPaymentBalance = merchantAccountBook.getPaymentBalance();
|
|
double oldChannelPaymentBalance = channelAccountBook.getPaymentBalance();
|
|
double oldChannelPaymentBalance = channelAccountBook.getPaymentBalance();
|
|
|
|
+ double oldChannelAllPaymentBalance = channelAllAccountBook.getPaymentBalance();
|
|
double amount = payOrder.getAmount().movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
double amount = payOrder.getAmount().movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
double newMerchantPaymentBalance = BigDecimal.valueOf(oldMerchantPaymentBalance).movePointRight(Constant.AMOUNT_MOVE_POINT).
|
|
double newMerchantPaymentBalance = BigDecimal.valueOf(oldMerchantPaymentBalance).movePointRight(Constant.AMOUNT_MOVE_POINT).
|
|
add(payOrder.getAmount()).movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
add(payOrder.getAmount()).movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
double newChannelPaymentBalance = BigDecimal.valueOf(oldChannelPaymentBalance).movePointRight(Constant.AMOUNT_MOVE_POINT).
|
|
double newChannelPaymentBalance = BigDecimal.valueOf(oldChannelPaymentBalance).movePointRight(Constant.AMOUNT_MOVE_POINT).
|
|
add(payOrder.getAmount()).movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
add(payOrder.getAmount()).movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
|
|
+ double newChannelAllPaymentBalance = BigDecimal.valueOf(oldChannelAllPaymentBalance).movePointRight(Constant.AMOUNT_MOVE_POINT).
|
|
|
|
+ add(payOrder.getAmount()).movePointLeft(Constant.AMOUNT_MOVE_POINT).doubleValue();
|
|
|
|
|
|
//转发消息到商户群组
|
|
//转发消息到商户群组
|
|
CopyMessage sendMerchantCopyMessage = new CopyMessage(merchantGroup.getGroupId(), update.message().chat().id(), update.message().messageId());
|
|
CopyMessage sendMerchantCopyMessage = new CopyMessage(merchantGroup.getGroupId(), update.message().chat().id(), update.message().messageId());
|
|
@@ -165,6 +184,17 @@ public class ComplaintHandler extends AbstractHandler {
|
|
channelMessage.setBotGroup(channelGroup);
|
|
channelMessage.setBotGroup(channelGroup);
|
|
channelMessage.setBotUser(botMessage.getBotUser());
|
|
channelMessage.setBotUser(botMessage.getBotUser());
|
|
updateChannelPaymentBalance.setMessage(channelMessage);
|
|
updateChannelPaymentBalance.setMessage(channelMessage);
|
|
|
|
+
|
|
|
|
+ //更新通道总余额
|
|
|
|
+ UpdateBalance updateChannelAllPaymentBalance = new UpdateBalance();
|
|
|
|
+ updateChannelAllPaymentBalance.setId(channelAllAccountBook.getId());
|
|
|
|
+ updateChannelAllPaymentBalance.setOldBalance(oldChannelAllPaymentBalance);
|
|
|
|
+ updateChannelAllPaymentBalance.setNewBalance(newChannelAllPaymentBalance);
|
|
|
|
+ updateChannelAllPaymentBalance.setAmount(amount);
|
|
|
|
+ BotMessage channelAllMessage = new BotMessage();
|
|
|
|
+ channelAllMessage.setBotGroup(channelGroup);
|
|
|
|
+ channelAllMessage.setBotUser(botMessage.getBotUser());
|
|
|
|
+ updateChannelAllPaymentBalance.setMessage(channelAllMessage);
|
|
//构建发出投诉单号到上游群组的消息
|
|
//构建发出投诉单号到上游群组的消息
|
|
StringBuilder stringBuilderChannel = new StringBuilder();
|
|
StringBuilder stringBuilderChannel = new StringBuilder();
|
|
stringBuilderChannel.append("投诉订单: ").append("\n");
|
|
stringBuilderChannel.append("投诉订单: ").append("\n");
|
|
@@ -194,11 +224,11 @@ public class ComplaintHandler extends AbstractHandler {
|
|
Thread.sleep(300);
|
|
Thread.sleep(300);
|
|
merchantMessageResponse = botMessage.getTelegramBot().execute(sendMerchantMessage);
|
|
merchantMessageResponse = botMessage.getTelegramBot().execute(sendMerchantMessage);
|
|
Thread.sleep(300);
|
|
Thread.sleep(300);
|
|
- channelMessageResponse = botMessage.getTelegramBot().execute(sendChannelMessage);
|
|
|
|
|
|
+ channelMessageResponse = botMessage.getTelegramBot().execute(sendChannelMessage);
|
|
Thread.sleep(300);
|
|
Thread.sleep(300);
|
|
- channelOrderMessageResponse = botMessage.getTelegramBot().execute(sendChannelMessageOrder);
|
|
|
|
|
|
+ channelOrderMessageResponse = botMessage.getTelegramBot().execute(sendChannelMessageOrder);
|
|
Thread.sleep(300);
|
|
Thread.sleep(300);
|
|
- if (!merchantCopyResponse.isOk() || !merchantMessageResponse.isOk() || !channelMessageResponse.isOk()){
|
|
|
|
|
|
+ if (!merchantCopyResponse.isOk() || !merchantMessageResponse.isOk() || !channelMessageResponse.isOk()) {
|
|
log.error("消息发送失败: {}", merchantCopyResponse);
|
|
log.error("消息发送失败: {}", merchantCopyResponse);
|
|
throw new Exception("消息发送失败");
|
|
throw new Exception("消息发送失败");
|
|
}
|
|
}
|
|
@@ -211,11 +241,11 @@ public class ComplaintHandler extends AbstractHandler {
|
|
if (merchantMessageResponse != null && merchantMessageResponse.message().messageId() != null) {
|
|
if (merchantMessageResponse != null && merchantMessageResponse.message().messageId() != null) {
|
|
botMessage.getTelegramBot().execute(new DeleteMessage(merchantGroup.getGroupId(), merchantMessageResponse.message().messageId()));
|
|
botMessage.getTelegramBot().execute(new DeleteMessage(merchantGroup.getGroupId(), merchantMessageResponse.message().messageId()));
|
|
}
|
|
}
|
|
- if (channelMessageResponse != null && channelMessageResponse.message().messageId() != null) {
|
|
|
|
- botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelMessageResponse.message().messageId() ));
|
|
|
|
|
|
+ if (channelMessageResponse != null && channelMessageResponse.message().messageId() != null) {
|
|
|
|
+ botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelMessageResponse.message().messageId()));
|
|
}
|
|
}
|
|
- if (channelOrderMessageResponse != null && channelOrderMessageResponse.message().messageId() != null) {
|
|
|
|
- botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelOrderMessageResponse.message().messageId() ));
|
|
|
|
|
|
+ if (channelOrderMessageResponse != null && channelOrderMessageResponse.message().messageId() != null) {
|
|
|
|
+ botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelOrderMessageResponse.message().messageId()));
|
|
}
|
|
}
|
|
} catch (Exception rollbackException) {
|
|
} catch (Exception rollbackException) {
|
|
log.error("消息撤回失败: {}", rollbackException.getMessage());
|
|
log.error("消息撤回失败: {}", rollbackException.getMessage());
|
|
@@ -223,7 +253,7 @@ public class ComplaintHandler extends AbstractHandler {
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- handlerManager.getAccountBookService().updateMutiPaymentBalanceByIdAndPaymentBalance(updateMerchantPaymentBalance, updateChannelPaymentBalance);
|
|
|
|
|
|
+ handlerManager.getAccountBookService().updateMutiPaymentBalanceByIdAndPaymentBalance(updateMerchantPaymentBalance, updateChannelPaymentBalance,updateChannelAllPaymentBalance);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("更新商户或通道余额失败: {}", e.getMessage());
|
|
log.error("更新商户或通道余额失败: {}", e.getMessage());
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -240,7 +270,7 @@ public class ComplaintHandler extends AbstractHandler {
|
|
if (channelMessageResponse != null && channelMessageResponse.message() != null) {
|
|
if (channelMessageResponse != null && channelMessageResponse.message() != null) {
|
|
botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelMessageResponse.message().messageId()));
|
|
botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelMessageResponse.message().messageId()));
|
|
}
|
|
}
|
|
- if (channelOrderMessageResponse != null&& channelOrderMessageResponse.message() !=null) {
|
|
|
|
|
|
+ if (channelOrderMessageResponse != null && channelOrderMessageResponse.message() != null) {
|
|
botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelOrderMessageResponse.message().messageId()));
|
|
botMessage.getTelegramBot().execute(new DeleteMessage(channelGroup.getGroupId(), channelOrderMessageResponse.message().messageId()));
|
|
}
|
|
}
|
|
} catch (Exception rollbackException) {
|
|
} catch (Exception rollbackException) {
|
|
@@ -276,6 +306,22 @@ public class ComplaintHandler extends AbstractHandler {
|
|
if (!sendResponse.isOk()) {
|
|
if (!sendResponse.isOk()) {
|
|
log.error("投诉单号转发结果发送失败: {}", sendResponse);
|
|
log.error("投诉单号转发结果发送失败: {}", sendResponse);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //投诉完成,拉黑uid到t_black_user
|
|
|
|
+ String buyerId = payOrder.getBuyerId();
|
|
|
|
+ if (buyerId != null) {
|
|
|
|
+ //查询一下以前拉黑过没
|
|
|
|
+ BlackUser blackUserOld = handlerManager.getBlackUserRepository().findByUserId(buyerId);
|
|
|
|
+ if (blackUserOld != null) {
|
|
|
|
+ //以前拉黑过 不操作
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ BlackUser blackUser = new BlackUser();
|
|
|
|
+ blackUser.setUserId(buyerId);
|
|
|
|
+ blackUser.setCreateTime(new Date());
|
|
|
|
+ blackUser.setType(0);
|
|
|
|
+ this.handlerManager.getBlackUserRepository().save(blackUser);
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|