|
|
@@ -4,10 +4,13 @@ import cn.com.sandpay.cashier.sdk.*;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.izouma.nineth.config.SandPayProperties;
|
|
|
import com.izouma.nineth.domain.GiftOrder;
|
|
|
+import com.izouma.nineth.domain.MintOrder;
|
|
|
import com.izouma.nineth.domain.Order;
|
|
|
+import com.izouma.nineth.enums.MintOrderStatus;
|
|
|
import com.izouma.nineth.enums.OrderStatus;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.GiftOrderRepo;
|
|
|
+import com.izouma.nineth.repo.MintOrderRepo;
|
|
|
import com.izouma.nineth.repo.OrderRepo;
|
|
|
import com.izouma.nineth.utils.DateTimeUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -37,6 +40,7 @@ public class SandPayService {
|
|
|
private final OrderRepo orderRepo;
|
|
|
private final GiftOrderRepo giftOrderRepo;
|
|
|
private final SandPayProperties sandPayProperties;
|
|
|
+ private final MintOrderRepo mintOrderRepo;
|
|
|
|
|
|
public JSONObject requestServer(JSONObject header, JSONObject body, String reqAddr) {
|
|
|
|
|
|
@@ -201,4 +205,30 @@ public class SandPayService {
|
|
|
|
|
|
return res.getJSONObject("body").getString("qrCode");
|
|
|
}
|
|
|
+
|
|
|
+ @Cacheable(value = "sandPay", key = "#orderId")
|
|
|
+ public String payMintOrder(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 = requestAlipay(orderId.toString(), order.getGasPrice(), "铸造活动:" + order.getMintActivityId(),
|
|
|
+ "铸造活动:" + order.getMintActivityId(), order.getCreatedAt().plusMinutes(3), extend.toJSONString());
|
|
|
+ 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("超过商户单日额度");
|
|
|
+ }
|
|
|
+ throw new BusinessException(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return res.getJSONObject("body").getString("qrCode");
|
|
|
+ }
|
|
|
}
|