xiongzhu 3 лет назад
Родитель
Сommit
1cdac55bbd

+ 58 - 0
src/main/java/com/izouma/nineth/service/SandPayService.java

@@ -302,6 +302,64 @@ public class SandPayService {
         return res.getJSONObject("body").getString("credential");
     }
 
+    @Cacheable(value = "sandPayQuick", key = "#orderId")
+    public String payGiftQuick(Long orderId) {
+        GiftOrder order = giftOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
+        if (order.getStatus() != OrderStatus.NOT_PAID) {
+            throw new BusinessException("订单状态错误");
+        }
+        JSONObject extend = new JSONObject();
+        extend.put("type", "gift");
+        extend.put("id", orderId);
+
+        JSONObject res = requestQuick(orderId.toString(), order.getGasPrice(), "转增" + order.getAssetId(),
+                "转增" + order.getAssetId(), 180, extend.toJSONString(),
+                generalProperties.getHost() + "/9th/");
+        if (res == null)
+            throw new BusinessException("下单失败,请稍后再试");
+
+        if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
+            String msg = res.getJSONObject("head").getString("respMsg");
+            if (msg.contains("超限")) {
+                throw new BusinessException("超过商户单日额度");
+            }
+            if (msg.contains("商户状态")) {
+                throw new BusinessException("超过商户单日额度");
+            }
+            throw new BusinessException(msg);
+        }
+        return res.getJSONObject("body").getString("credential");
+    }
+
+    @Cacheable(value = "sandPayQuick", key = "#orderId")
+    public String payMintQuick(Long orderId) {
+        MintOrder order = mintOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
+        if (order.getStatus() != MintOrderStatus.NOT_PAID) {
+            throw new BusinessException("订单状态错误");
+        }
+        JSONObject extend = new JSONObject();
+        extend.put("type", "mintOrder");
+        extend.put("id", orderId);
+
+        JSONObject res = requestQuick(orderId.toString(), order.getGasPrice(),
+                "铸造活动:" + order.getMintActivityId(), "铸造活动:" + order.getMintActivityId(),
+                180, extend.toJSONString(), generalProperties.getHost() + "/9th/");
+        if (res == null)
+            throw new BusinessException("下单失败,请稍后再试");
+
+        if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
+            String msg = res.getJSONObject("head").getString("respMsg");
+            if (msg.contains("超限")) {
+                throw new BusinessException("超过商户单日额度");
+            }
+            if (msg.contains("商户状态")) {
+                throw new BusinessException("超过商户单日额度");
+            }
+            throw new BusinessException(msg);
+        }
+        return res.getJSONObject("body").getString("credential");
+    }
+
     @Cacheable(value = "sandPay", key = "#orderId")
     public String payGiftOrder(Long orderId) {
         GiftOrder order = giftOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));

+ 12 - 0
src/main/java/com/izouma/nineth/web/OrderPayControllerV2.java

@@ -72,6 +72,12 @@ public class OrderPayControllerV2 {
         return "AlipayHtml";
     }
 
+    @RequestMapping(value = "/gift/sandQuick", method = RequestMethod.GET, produces = "text/html")
+    @ResponseBody
+    public String payGiftQuick(@RequestParam Long id) {
+        return sandPayService.payGiftQuick(id);
+    }
+
     @RequestMapping(value = "/mint/alipay", method = RequestMethod.GET)
     @ResponseBody
     public String payMintOrderAlipayH5(Long id) {
@@ -85,4 +91,10 @@ public class OrderPayControllerV2 {
         model.addAttribute("orderId", id);
         return "AlipayHtml2";
     }
+
+    @RequestMapping(value = "/mint/sandQuick", method = RequestMethod.GET, produces = "text/html")
+    @ResponseBody
+    public String payMintQuick(@RequestParam Long id) {
+        return sandPayService.payMintQuick(id);
+    }
 }