diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/channel/service/impl/ChannelServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/channel/service/impl/ChannelServiceImpl.java index 09f70e0..a21124c 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/channel/service/impl/ChannelServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/channel/service/impl/ChannelServiceImpl.java @@ -230,7 +230,7 @@ public class ChannelServiceImpl implements ChannelService return ChannelApiType.CREDIT.getType().equals(item.getApiType()); }); - if (hasCredit) { + if (hasCredit && query.getUserId() != null) { // 查询挂账选项 CreditUserQuery creditQuery = new CreditUserQuery(); creditQuery.setId(query.getSubId()); @@ -254,6 +254,11 @@ public class ChannelServiceImpl implements ChannelService return channelPaySubVO; }).collect(Collectors.toList())); }); + } else { + // 移除挂账渠道 + result = result.stream() + .filter(item -> !ChannelApiType.CREDIT.getType().equals(item.getApiType())) + .collect(Collectors.toList()); } return result; diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/creditPay/service/impl/CreditPayServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/creditPay/service/impl/CreditPayServiceImpl.java index 5d822d1..3aeea8c 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/creditPay/service/impl/CreditPayServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/creditPay/service/impl/CreditPayServiceImpl.java @@ -20,6 +20,7 @@ import com.ruoyi.bst.creditUser.domain.CreditUserVO; import com.ruoyi.bst.creditUser.service.CreditUserService; import com.ruoyi.bst.pay.domain.PayVO; import com.ruoyi.bst.pay.service.PayService; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.pay.PayApi; import com.ruoyi.common.pay.Payable; import com.ruoyi.common.pay.Refundable; @@ -199,7 +200,8 @@ public class CreditPayServiceImpl implements CreditPayService, PayApi // 关闭支付单 @Override public void closeByOutTradeNo(String outTradeNo, Object config) { - // 什么都不做,当前支付单无法关闭 + // 支付单无法关闭 + throw new ServiceException("挂账支付无法关闭:" + outTradeNo); } // 查询支付单 diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java index 28a9194..cda3fc7 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java @@ -447,7 +447,9 @@ public class PayServiceImpl implements PayService { ServiceUtil.assertion(app == null, "ID为%s的APP信息不存在", pay.getAppId()); // 获取支付结果,若成功则处理支付成功 Object result = this.queryPayInfo(payApi, pay, channel, app); - if (payApi.isPaySuccess(result)) { + boolean isPaySuccess = payApi.isPaySuccess(result); + log.info("刷新支付结果:{}, {}, {}", pay.getNo(), isPaySuccess, result); + if (isPaySuccess) { this.handleSuccess(pay, payApi.getPayTime(result)); } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChannelController.java b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChannelController.java index 16dd70e..411b889 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChannelController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChannelController.java @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.bst.channel.service.ChannelService; +import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -20,8 +21,15 @@ public class AppChannelController extends BaseController { @ApiOperation("获取可用支付渠道列表") @GetMapping("/list") + @Anonymous public AjaxResult list(Long areaId, Long appId, String bstType) { - return success(channelService.selectPayChannelList(getUserId(), areaId, appId, bstType)); + Long userId = null; + try { + userId = getUserId(); + } catch (Exception e) { + userId = null; + } + return success(channelService.selectPayChannelList(userId, areaId, appId, bstType)); } @ApiOperation("获取骑行费可用的支付渠道")