|
|
@@ -2,13 +2,12 @@ package com.izouma.nineth.service;
|
|
|
|
|
|
import cn.com.sandpay.cashier.sdk.*;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.izouma.nineth.config.Constants;
|
|
|
import com.izouma.nineth.config.GeneralProperties;
|
|
|
+import com.izouma.nineth.config.RedisKeys;
|
|
|
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.dto.PayQuery;
|
|
|
+import com.izouma.nineth.enums.PayStatus;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.GiftOrderRepo;
|
|
|
import com.izouma.nineth.repo.MintOrderRepo;
|
|
|
@@ -18,34 +17,39 @@ import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.data.redis.core.BoundSetOperations;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.DecimalFormatSymbols;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
@Slf4j
|
|
|
public class SandPayService {
|
|
|
- private final OrderRepo orderRepo;
|
|
|
- private final GiftOrderRepo giftOrderRepo;
|
|
|
- private final SandPayProperties sandPayProperties;
|
|
|
- private final MintOrderRepo mintOrderRepo;
|
|
|
- private final SnowflakeIdWorker snowflakeIdWorker;
|
|
|
- private final GeneralProperties generalProperties;
|
|
|
-
|
|
|
- public String paddingOrderId(String orderId) {
|
|
|
+ private final OrderRepo orderRepo;
|
|
|
+ private final GiftOrderRepo giftOrderRepo;
|
|
|
+ private final SandPayProperties sandPayProperties;
|
|
|
+ private final MintOrderRepo mintOrderRepo;
|
|
|
+ private final SnowflakeIdWorker snowflakeIdWorker;
|
|
|
+ private final GeneralProperties generalProperties;
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
+
|
|
|
+ public static String paddingOrderId(String orderId) {
|
|
|
if (orderId != null && orderId.length() < 12) {
|
|
|
StringBuilder orderIdBuilder = new StringBuilder(orderId);
|
|
|
for (int i = orderIdBuilder.length(); i < 12; i++) {
|
|
|
@@ -56,7 +60,7 @@ public class SandPayService {
|
|
|
return orderId;
|
|
|
}
|
|
|
|
|
|
- public String getReqTime() {
|
|
|
+ public static String getReqTime() {
|
|
|
return DateTimeUtils.format(LocalDateTime.now(), "yyyyMMddHHmmss");
|
|
|
}
|
|
|
|
|
|
@@ -69,12 +73,12 @@ public class SandPayService {
|
|
|
.plusSeconds(seconds), "yyyyMMddHHmmss");
|
|
|
}
|
|
|
|
|
|
- public String convertAmount(BigDecimal amount) {
|
|
|
+ public static String convertAmount(BigDecimal amount) {
|
|
|
DecimalFormat df = new DecimalFormat("000000000000", DecimalFormatSymbols.getInstance(Locale.US));
|
|
|
return df.format(amount.multiply(new BigDecimal("100")));
|
|
|
}
|
|
|
|
|
|
- public JSONObject requestServer(JSONObject header, JSONObject body, String reqAddr) {
|
|
|
+ public static JSONObject requestServer(JSONObject header, JSONObject body, String reqAddr) {
|
|
|
|
|
|
Map<String, String> reqMap = new HashMap<String, String>();
|
|
|
JSONObject reqJson = new JSONObject();
|
|
|
@@ -137,22 +141,13 @@ public class SandPayService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public String requestAlipay(String orderId, BigDecimal amount, String subject, String desc,
|
|
|
- String timeout, String extend) {
|
|
|
- JSONObject res = requestAlipayRaw(orderId, amount, subject, desc, timeout, extend);
|
|
|
- if ("000000".equals(res.getJSONObject("head").getString("respCode"))) {
|
|
|
- return "alipays://platformapi/startapp?saId=10000007&qrcode=" + res.getJSONObject("body").getString("qrCode");
|
|
|
- }
|
|
|
- throw new BusinessException("绿洲宇宙冷却系统已启动,请稍后支付");
|
|
|
- }
|
|
|
+ public String pay(String orderId, String subject, BigDecimal amount, LocalDateTime expireAt, String type) {
|
|
|
+ String pOrderId = paddingOrderId(orderId);
|
|
|
+
|
|
|
+ JSONObject extend = new JSONObject();
|
|
|
+ extend.put("type", type);
|
|
|
+ extend.put("orderId", pOrderId);
|
|
|
|
|
|
- public JSONObject requestAlipayRaw(String orderId, BigDecimal amount, String subject, String desc,
|
|
|
- String timeout, String extend) {
|
|
|
- if (orderId.length() < 12) {
|
|
|
- for (int i = orderId.length(); i < 12; i++) {
|
|
|
- orderId = "0" + orderId;
|
|
|
- }
|
|
|
- }
|
|
|
JSONObject header = new JSONObject();
|
|
|
header.put("version", "1.0"); //版本号
|
|
|
header.put("method", "sandpay.trade.precreate"); //接口名称:统一下单并支付
|
|
|
@@ -168,23 +163,34 @@ public class SandPayService {
|
|
|
body.put("totalAmount", convertAmount(amount)); //订单金额 12位长度,精确到分
|
|
|
//body.put("limitPay", "5"); //限定支付方式 送1-限定不能使用贷记卡 送4-限定不能使用花呗 送5-限定不能使用贷记卡+花呗
|
|
|
body.put("subject", subject); //订单标题
|
|
|
- body.put("body", desc); //订单描述
|
|
|
- body.put("txnTimeOut", timeout); //订单超时时间
|
|
|
+ body.put("body", subject); //订单描述
|
|
|
+ body.put("txnTimeOut", getTimeout(expireAt, 0)); //订单超时时间
|
|
|
body.put("notifyUrl", sandPayProperties.getNotifyUrl()); //异步通知地址
|
|
|
body.put("bizExtendParams", ""); //业务扩展参数
|
|
|
body.put("merchExtendParams", ""); //商户扩展参数
|
|
|
- body.put("extend", extend); //扩展域
|
|
|
+ body.put("extend", extend.toJSONString()); //扩展域
|
|
|
|
|
|
- return requestServer(header, body, "https://cashier.sandpay.com.cn/qr/api/order/create");
|
|
|
- }
|
|
|
+ JSONObject res = requestServer(header, body, "https://cashier.sandpay.com.cn/qr/api/order/create");
|
|
|
|
|
|
- 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++) {
|
|
|
- orderId = "0" + orderId;
|
|
|
- }
|
|
|
+ String respCode = res.getJSONObject("head").getString("respCode");
|
|
|
+ if ("000000".equals(respCode)) {
|
|
|
+ redisTemplate.opsForValue()
|
|
|
+ .set(RedisKeys.PAY_TMP + orderId, Constants.PayChannel.SAND, 1, TimeUnit.DAYS);
|
|
|
+ return "alipays://platformapi/startapp?saId=10000007&qrcode="
|
|
|
+ + res.getJSONObject("body").getString("qrCode");
|
|
|
}
|
|
|
+ String msg = res.getJSONObject("head").getString("respMsg");
|
|
|
+ throw new BusinessException(Constants.PAY_ERR_MSG, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String payQuick(String orderId, String subject, BigDecimal amount, LocalDateTime expireAt,
|
|
|
+ String type, String returnUrl) {
|
|
|
+ String pOrderId = paddingOrderId(orderId);
|
|
|
+
|
|
|
+ JSONObject extend = new JSONObject();
|
|
|
+ extend.put("type", type);
|
|
|
+ extend.put("orderId", pOrderId);
|
|
|
+
|
|
|
JSONObject header = new JSONObject();
|
|
|
header.put("version", "1.0"); //版本号
|
|
|
header.put("method", "sandpay.trade.pay"); //接口名称:统一下单
|
|
|
@@ -198,12 +204,12 @@ public class SandPayService {
|
|
|
body.put("orderCode", orderId); //商户订单号
|
|
|
body.put("totalAmount", convertAmount(amount)); //订单金额
|
|
|
body.put("subject", subject); //订单标题
|
|
|
- body.put("body", desc); //订单描述
|
|
|
- body.put("txnTimeOut", getTimeout(timeout)); //订单超时时间
|
|
|
+ body.put("body", subject); //订单描述
|
|
|
+ body.put("txnTimeOut", getTimeout(expireAt, 0)); //订单超时时间
|
|
|
body.put("clientIp", "192.168.22.55"); //客户端IP
|
|
|
body.put("limitPay", ""); //限定支付方式 送1-限定不能使用贷记卡送 4-限定不能使用花呗 送5-限定不能使用贷记卡+花呗
|
|
|
body.put("notifyUrl", sandPayProperties.getNotifyUrl()); //异步通知地址
|
|
|
- body.put("frontUrl", frontUrl); //前台通知地址
|
|
|
+ body.put("frontUrl", returnUrl); //前台通知地址
|
|
|
body.put("storeId", ""); //商户门店编号
|
|
|
body.put("terminalId", ""); //商户终端编号
|
|
|
body.put("operatorId", ""); //操作员编号
|
|
|
@@ -212,13 +218,22 @@ public class SandPayService {
|
|
|
body.put("riskRateInfo", ""); //风控信息域
|
|
|
body.put("bizExtendParams", ""); //业务扩展参数
|
|
|
body.put("merchExtendParams", ""); //商户扩展参数
|
|
|
- body.put("extend", extend); //扩展域
|
|
|
+ body.put("extend", extend.toJSONString()); //扩展域
|
|
|
body.put("payMode", "sand_h5"); //支付模式
|
|
|
|
|
|
- return requestServer(header, body, "https://cashier.sandpay.com.cn/gateway/api/order/pay");
|
|
|
+ JSONObject res = requestServer(header, body, "https://cashier.sandpay.com.cn/gateway/api/order/pay");
|
|
|
+ String respCode = res.getJSONObject("head").getString("respCode");
|
|
|
+ if ("000000".equals(respCode)) {
|
|
|
+ redisTemplate.opsForValue()
|
|
|
+ .set(RedisKeys.PAY_TMP + orderId, Constants.PayChannel.SAND, 1, TimeUnit.DAYS);
|
|
|
+ return res.getJSONObject("body").getString("credential");
|
|
|
+ }
|
|
|
+ String msg = res.getJSONObject("head").getString("respMsg");
|
|
|
+ throw new BusinessException(Constants.PAY_ERR_MSG, msg);
|
|
|
}
|
|
|
|
|
|
public JSONObject query(String orderId) {
|
|
|
+ orderId = paddingOrderId(orderId);
|
|
|
JSONObject header = new JSONObject();
|
|
|
header.put("version", "1.0"); //版本号
|
|
|
header.put("method", "sandpay.trade.query"); //接口名称:订单查询
|
|
|
@@ -236,6 +251,7 @@ public class SandPayService {
|
|
|
}
|
|
|
|
|
|
public JSONObject refund(String orderId, BigDecimal amount) {
|
|
|
+ orderId = paddingOrderId(orderId);
|
|
|
JSONObject header = new JSONObject();
|
|
|
header.put("version", "1.0"); //版本号
|
|
|
header.put("method", "sandpay.trade.refund"); //接口名称:退货
|
|
|
@@ -249,188 +265,13 @@ public class SandPayService {
|
|
|
body.put("orderCode", snowflakeIdWorker.nextId()); //商户订单号
|
|
|
body.put("oriOrderCode", paddingOrderId(orderId)); //原交易订单号
|
|
|
body.put("refundAmount", convertAmount(amount)); //退货金额
|
|
|
- body.put("refundReason", "退货测试"); //退货原因
|
|
|
+ body.put("refundReason", "退款"); //退货原因
|
|
|
body.put("notifyUrl", sandPayProperties.getNotifyUrl()); //异步通知地址
|
|
|
body.put("extend", "");
|
|
|
|
|
|
return requestServer(header, body, "https://cashier.sandpay.com.cn/qr/api/order/refund");
|
|
|
}
|
|
|
|
|
|
- @Cacheable(value = "sandPay", key = "#orderId")
|
|
|
- public String payOrder(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 = requestAlipayRaw(orderId.toString(), order.getTotalPrice(), order.getName(), order.getName(),
|
|
|
- getTimeout(order.getCreatedAt(), 180), 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("超过商户单日额度");
|
|
|
- }
|
|
|
- if (msg.contains("商户状态")) {
|
|
|
- throw new BusinessException("超过商户单日额度");
|
|
|
- }
|
|
|
- throw new BusinessException(msg);
|
|
|
- }
|
|
|
-
|
|
|
- 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() + "/9th/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 = "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("订单不存在"));
|
|
|
- if (order.getStatus() != OrderStatus.NOT_PAID) {
|
|
|
- throw new BusinessException("订单状态错误");
|
|
|
- }
|
|
|
- JSONObject extend = new JSONObject();
|
|
|
- extend.put("type", "gift");
|
|
|
- extend.put("id", orderId);
|
|
|
-
|
|
|
- JSONObject res = requestAlipayRaw(orderId.toString(), order.getGasPrice(), "转增" + order.getAssetId(),
|
|
|
- "转增" + order.getAssetId(),
|
|
|
- getTimeout(order.getCreatedAt(), 180), 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("超过商户单日额度");
|
|
|
- }
|
|
|
- if (msg.contains("商户状态")) {
|
|
|
- throw new BusinessException("超过商户单日额度");
|
|
|
- }
|
|
|
- throw new BusinessException(msg);
|
|
|
- }
|
|
|
-
|
|
|
- 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 = requestAlipayRaw(orderId.toString(), order.getGasPrice(), "铸造活动:" + order.getMintActivityId(),
|
|
|
- "铸造活动:" + order.getMintActivityId(), getTimeout(order.getCreatedAt(), 180), 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("超过商户单日额度");
|
|
|
- }
|
|
|
- if (msg.contains("商户状态")) {
|
|
|
- throw new BusinessException("超过商户单日额度");
|
|
|
- }
|
|
|
- throw new BusinessException(msg);
|
|
|
- }
|
|
|
-
|
|
|
- return res.getJSONObject("body").getString("qrCode");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public JSONObject transfer(String id, String name, String bank, BigDecimal amount) {
|
|
|
JSONObject request = new JSONObject();
|
|
|
DecimalFormat df = new DecimalFormat("000000000000", DecimalFormatSymbols.getInstance(Locale.US));
|
|
|
@@ -648,4 +489,46 @@ public class SandPayService {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public PayQuery payQuery(String orderId) {
|
|
|
+ JSONObject res = query(orderId);
|
|
|
+ PayQuery query = new PayQuery(Constants.PayChannel.SAND);
|
|
|
+ String respCode = res.getJSONObject("head").getString("respCode");
|
|
|
+
|
|
|
+ if ("000000".equals(respCode)) {
|
|
|
+ query.setExist(true);
|
|
|
+ JSONObject body = res.getJSONObject("body");
|
|
|
+ query.setMsg(body.getString("orderMsg") + " " + body.getString("oriRespMsg"));
|
|
|
+ query.setAmount(new BigDecimal(body.getString("totalAmount"))
|
|
|
+ .divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
|
|
|
+ query.setTransactionId(body.getString("payOrderCode"));
|
|
|
+ if (StringUtils.isNotEmpty(body.getString("payTime"))) {
|
|
|
+ query.setPayTime(LocalDateTime.parse(body.getString("payTime"), DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
|
|
+ }
|
|
|
+ switch (body.getString("orderStatus")) {
|
|
|
+ case "00":
|
|
|
+ query.setStatus(PayStatus.SUCCESS);
|
|
|
+ break;
|
|
|
+ case "01":
|
|
|
+ query.setStatus(PayStatus.PENDING);
|
|
|
+ break;
|
|
|
+ case "02":
|
|
|
+ query.setStatus(PayStatus.FAIL);
|
|
|
+ break;
|
|
|
+ case "03":
|
|
|
+ query.setStatus(PayStatus.CANCEL);
|
|
|
+ break;
|
|
|
+ case "04":
|
|
|
+ query.setStatus(PayStatus.REFUNDED);
|
|
|
+ break;
|
|
|
+ case "05":
|
|
|
+ query.setStatus(PayStatus.REFUNDING);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ query.setExist(false);
|
|
|
+ query.setMsg(res.getString("msg"));
|
|
|
+ }
|
|
|
+ return query;
|
|
|
+ }
|
|
|
}
|