xiongzhu 4 years ago
parent
commit
c6351a6c17

+ 3 - 2
src/main/java/com/izouma/nineth/service/OrderPayService.java

@@ -106,7 +106,8 @@ public class OrderPayService {
                         System.currentTimeMillis()));
     }
 
-    public void payOrderAgreement(Long orderId, String bindCardId) {
+    @Cacheable(value = "payOrder", key = "'order#'+#orderId")
+    public Object payOrderAgreement(Long orderId, String bindCardId) {
         Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
         if (order.getStatus() != OrderStatus.NOT_PAID) {
             throw new BusinessException("订单状态错误");
@@ -118,7 +119,7 @@ public class OrderPayService {
         if (StringUtils.isEmpty(bindCardId)) {
             throw new BusinessException("请先绑定银行卡");
         }
-        payEaseService.pay(order.getName(), orderId.toString(), order.getTotalPrice(),
+       return payEaseService.pay(order.getName(), orderId.toString(), order.getTotalPrice(),
                 order.getUserId().toString(), bindCardId);
     }
 

+ 4 - 0
src/main/java/com/izouma/nineth/service/PayEaseService.java

@@ -67,6 +67,10 @@ public class PayEaseService {
             throw new BusinessException(error);
         } else {
             String bindStatus = responseData.getString("bindStatus");
+            if ("FAIL".equals(bindStatus)) {
+                String errorMsg = responseData.getString("errorMsg");
+                throw new BusinessException(errorMsg);
+            }
             String bindCardId = responseData.getString("bindCardId");
             String bankCardNumber = responseData.getString("bankCardNumber");
             bindCardRequest.setBindCardId(bindCardId);

+ 5 - 5
src/test/java/com/izouma/nineth/PayEaseTest.java

@@ -36,15 +36,15 @@ public class PayEaseTest {
     @Test
     public void bindCard() {
         //商户会员id
-        String merchantUserId = "1";
+        String merchantUserId = "9850";
         //	银⾏卡号
-        String bankCardNumber = "6222024301070380165";
+        String bankCardNumber = "6228270397009469879";
         //预留⼿机号
         String phoneNumber = "15077886171";
         //	持卡⼈姓名
-        String name = "熊竹";
+        String name = "潘惠";
         //	身份证号
-        String idCardNum = "321002199408304614";
+        String idCardNum = "321081199602086329";
 
 
         BindCardBuilder builder = new BindCardBuilder(merchantId);
@@ -84,7 +84,7 @@ public class PayEaseTest {
 
     @Test
     public void bindCardCaptcha() {
-        String bindCardId = "20220519093153711994335360860160";
+        String bindCardId = "20220519038583712044350867390464";
 
         BindCardKaptchaBuilder builder = new BindCardKaptchaBuilder(merchantId);
         builder.setBindCardId(bindCardId);