|
|
@@ -18,7 +18,6 @@ import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -28,9 +27,7 @@ import java.net.URLDecoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.DecimalFormatSymbols;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
@@ -154,7 +151,7 @@ public class SandPayService {
|
|
|
return requestServer(header, body, "https://cashier.sandpay.com.cn/qr/api/order/create");
|
|
|
}
|
|
|
|
|
|
- public JSONObject requestUnion(String orderId, BigDecimal amount, String subject, String desc,
|
|
|
+ public JSONObject requestQuick(String orderId, BigDecimal amount, String subject, String desc,
|
|
|
int timeout, String extend, String frontUrl) {
|
|
|
if (orderId.length() < 12) {
|
|
|
for (int i = orderId.length(); i < 12; i++) {
|
|
|
@@ -261,6 +258,34 @@ public class SandPayService {
|
|
|
return res.getJSONObject("body").getString("qrCode");
|
|
|
}
|
|
|
|
|
|
+ @Cacheable(value = "sandPayQuick", key = "#orderId")
|
|
|
+ public String payOrderQuick(Long orderId) {
|
|
|
+ Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ JSONObject extend = new JSONObject();
|
|
|
+ extend.put("type", "order");
|
|
|
+ extend.put("id", orderId);
|
|
|
+
|
|
|
+ JSONObject res = requestQuick(orderId.toString(), order.getTotalPrice(), order.getName(), order.getName(),
|
|
|
+ 180, extend.toJSONString(), generalProperties.getHost() + "/orderDetail?id=" + orderId);
|
|
|
+ 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("订单不存在"));
|