diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/yyx/YyxServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/yyx/YyxServiceImpl.java index 8acda2799..b68a54bb5 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/yyx/YyxServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/yyx/YyxServiceImpl.java @@ -39,30 +39,34 @@ public class YyxServiceImpl implements YyxService { @Override public void send(Long mchId, Integer payPrice, String phone) { - if (!ObjectUtil.isAllNotEmpty(mchId, payPrice, phone)) { - return; + try { + if (!ObjectUtil.isAllNotEmpty(mchId, payPrice, phone)) { + return; + } + // 查询商户绑定的云音箱设备 + List yyxList = hardManagerMapper.selectList(new LambdaQueryWrapper().eq(HardManagerEntity::getMerchantId, mchId) + .eq(HardManagerEntity::getType, HardTypeEnum.YYX.getType()) + ); + if (ObjectUtil.isEmpty(yyxList)) { + return; + } + + String yuanPrice = fenToYuan(payPrice); + String lastPhone = phoneToLastPhone(phone); + + String template = yyxConf.getTemplate(); + + // 把`template`中的`${price}`替换为`yuanPrice` + template = template.replace("${price}", yuanPrice); + // 把`template`中的`${phone}`替换为`lastPhone` + template = template.replace("${phone-last}", lastPhone); + + + String finalTemplate = template; + yyxList.forEach(v -> httpSend(v.getUniqueCode(), finalTemplate)); + } catch (Exception e) { + log.error("|{}|发送失败,异常:{}", TAG, e.getMessage()); } - // 查询商户绑定的云音箱设备 - List yyxList = hardManagerMapper.selectList(new LambdaQueryWrapper().eq(HardManagerEntity::getMerchantId, mchId) - .eq(HardManagerEntity::getType, HardTypeEnum.YYX.getType()) - ); - if (ObjectUtil.isEmpty(yyxList)) { - return; - } - - String yuanPrice = fenToYuan(payPrice); - String lastPhone = phoneToLastPhone(phone); - - String template = yyxConf.getTemplate(); - - // 把`template`中的`${price}`替换为`yuanPrice` - template = template.replace("${price}", yuanPrice); - // 把`template`中的`${phone}`替换为`lastPhone` - template = template.replace("${phone-last}", lastPhone); - - - String finalTemplate = template; - yyxList.forEach(v -> httpSend(v.getUniqueCode(), finalTemplate)); } private boolean httpSend(String deviceId, String msg) {