api开放钱包创建接口
This commit is contained in:
1 parent
658e6ccf1e
commit
a2be79377b
26 files changed
+636
-4
No files matched your search
@@ -7,6 +7,7 @@ import com.ruoyi.system.domain.UsdtOrdersPlus;
|
||||
import com.ruoyi.system.service.IAppApiKeysService;
|
||||
import com.ruoyi.system.service.IUsdtOrdersService;
|
||||
import com.ruoyi.system.service.PaymentSignatureService;
|
||||
import com.ruoyi.system.service.AppPrivateKeyCipher;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -25,13 +26,14 @@ public class PaymentApiController {
|
||||
@Autowired private IAppApiKeysService keys;
|
||||
@Autowired private IUsdtOrdersService orders;
|
||||
@Autowired private StringRedisTemplate redis;
|
||||
@Autowired private AppPrivateKeyCipher privateKeyCipher;
|
||||
|
||||
@PostMapping("/create-transaction")
|
||||
public AjaxResult create(@RequestBody Map<String, Object> body) {
|
||||
String signature = String.valueOf(body.get("signature"));
|
||||
Long appId = parseLong(body.get("app_id"));
|
||||
AppApiKeysPlus key = activeKey(appId, body.get("api_key"));
|
||||
if (key == null || !PaymentSignatureService.verify(body, key.getApiSecret(), signature)) return AjaxResult.error("签名无效");
|
||||
if (key == null || !PaymentSignatureService.verify(body, privateKeyCipher.decryptCredentialSecret(key.getApiSecret()), signature)) return AjaxResult.error("签名无效");
|
||||
String orderId = String.valueOf(body.get("order_id"));
|
||||
if (orderId.length() == 0 || orderId.length() > 32 || body.get("amount") == null || body.get("wallet_user_name") == null) return AjaxResult.error("缺少必要参数");
|
||||
if (!validUrl(body.get("notify_url")) || (body.get("redirect_url") != null && !validUrl(body.get("redirect_url")))) return AjaxResult.error("回调地址无效");
|
||||
@@ -51,7 +53,7 @@ public class PaymentApiController {
|
||||
@PostMapping("/query")
|
||||
public AjaxResult query(@RequestBody Map<String, Object> body) {
|
||||
Long appId = parseLong(body.get("app_id")); AppApiKeysPlus key = activeKey(appId, body.get("api_key")); String signature = String.valueOf(body.get("signature"));
|
||||
if (key == null || !PaymentSignatureService.verify(body, key.getApiSecret(), signature)) return AjaxResult.error("签名无效");
|
||||
if (key == null || !PaymentSignatureService.verify(body, privateKeyCipher.decryptCredentialSecret(key.getApiSecret()), signature)) return AjaxResult.error("签名无效");
|
||||
UsdtOrdersPlus order = orders.getOne(new LambdaQueryWrapper<UsdtOrdersPlus>().eq(UsdtOrdersPlus::getAppId, appId).eq(UsdtOrdersPlus::getOrderId, String.valueOf(body.get("order_id"))));
|
||||
if (order == null) return AjaxResult.error("订单不存在");
|
||||
Map<String, Object> result = new HashMap<String, Object>(); result.put("order_id", order.getOrderId()); result.put("trade_id", order.getTradeId()); result.put("status", order.getStatus()); result.put("transaction_id", order.getBlockTransactionId()); return AjaxResult.success(result);
|
||||
|
||||
Reference in new issue
Block a user