Alipay-HK 接入 暂存

This commit is contained in:
2024-05-10 17:11:49 +08:00
parent ae937dbf65
commit d41bc284d4
16 changed files with 707 additions and 25 deletions

View File

@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1XpZ0+EIoJvQk
GHAdpcpr35S+UnxNdOE+1sZsIDWuyzXG0d6vOudITmYFTqVzJRaAArhwp+NQ/R9y
onsuUsEc0x2qTntySYMedHfI2TSl6qTsqpHykSLr6u0E4TuYUiGs/nf3t0A/rEvm
KK6OP4vNgUlANhOKDwiCAdmJkiOBEHJwLsN1xlcnBkUR0Wr+uauVo+A0opkM7HrB
aXXTcy+gpold+uCgCbRzFCiDr0uKsLJgb3Ce1aXTwa8k2dDg6mzhE0U65yhsNzjC
Cqg+g8tfEVha9Nrsmd6hG2iFHnk4rCqRXhjuI1V10GiZUppMWJtGD2tj7ZK0XXKh
5sAclu9RAgMBAAECggEBAKSQy8IclKKsHbA2wFwWV6Ijv2olnAYH/G0xId9wJmWQ
mx3oxb6Hmt3fzPAZ2UOuLkk+rq4Bl9+fnQ494bk5e2G1KWCjT512mFNk6F9EvmGh
k73uUvkeueoIQsG/wHxIYaf/SUlqbBCaPE/9L82AWVDBc36g0n/dfiHAnesWv8JV
agiTF/SIWDPtzRaVh8VObFOusHdqnRuLqV7n0FSVJePSNBFSSOz5XTttOtM4whg8
kw3jlCHbVMVKtPYcebxGf0vkDapyGJiZ6wc1rD4MXJTciG+WQNfNE+Af2UB606VC
Nlq/CRkXr2Ix9ASSMeE4TcH+0EoxeITpP2NV+3hAzgECgYEA7mWSd6HgPXMdwO33
efmx0qky+I/4bhicG9Go6021fRY+jUhRcj6VtDWBzuZwblgTSiDH4t2TbfB+hvQD
GVTJNc21+hXEVNu0ajqLuMiCgqaZCeNeJYYYowbLSbYd4t/nQh1vCZ/44aRWqG8G
eWEGruMaqSlGyFG7kyaoQaY1X6ECgYEAwsMGiupk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obDc4wgqoPoPL
XxFYWvTa7JneoRtohR55OKwqkV4Y7iNVddBomVKaTFibRg9rY+2StF1yoebAHJbv
UQIDAQAB
-----END PUBLIC KEY-----

View File

@@ -0,0 +1,21 @@
package com.ai.da.common.task;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class GenerateTask {
@Scheduled(cron = "0 0 */1 * * ?")
public void generateScheduled(){
log.info("测试定时器generate");
try{
}catch(Exception e){
}
}
}

View File

@@ -0,0 +1,329 @@
package com.ai.da.common.utils;
import com.ai.da.model.dto.AlipayHKParametersDTO;
import com.ai.da.model.dto.AlipayHKRequestDTO;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
import org.springframework.beans.factory.annotation.Value;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.HashMap;
import java.util.UUID;
@Slf4j
public class AlipayHKEncryptionUtil {
@Value("${alipay.hk.merchant-id}")
private static String merchantId;
@Value("${alipay.hk.segment-id}")
private static String segmentId;
@Value("${alipay.hk.AESKey}")
private static String aesKey;
@Value("${alipay.hk.rsaPrivateKey}")
private static String privateKeyPath;
@Value("${alipay.hk.rsaPublicKey}")
private static String publicKeyPath;
/**
* 加密
* @param param
* @param serviceName
* @return
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidAlgorithmParameterException
* @throws InvalidKeyException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
* @throws IOException
*/
public static AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
// Pre-shared secret key, DO NOT hardcode this key
String key = aesKey;
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
// 使用私钥创建数字签名
// Mode, aes-128-cbc for 128bit key
String mode = "aes-128-cbc";
// Padding mode
String padding = "pkcs7";
// signature alogrithm
String signatureAlgorithm = "rsa-sha256";
// String signatureAlgorithm = "SHA256withRSA";
// Message body
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
requestMessage.setService(serviceName);
requestMessage.setMerchant_id(merchantId);
requestMessage.setRequest_time(Long.toString(System.currentTimeMillis() / 1000L));
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
// HashMap<String, Object> param = new HashMap<>();
requestMessage.setParameters(param);
/*String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
param.put("order_ref", orderRef);
param.put("amount", 208.12);
param.put("subject", "四月帳單 April Bill");
param.put("wallet", "ALIPAYHK");
param.put("segment_id", segmentId);
param.put("payment_solution", "WAP");*/
// Serialize message body
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String content = gson.toJson(requestMessage);
// Secure random iv 获取随机种子
SecureRandom secureRandom = new SecureRandom();
byte[] iv = new byte[16]; //NEVER REUSE THIS IV WITH THE SAME KEY
secureRandom.nextBytes(iv);
// Algorithms
String alogrithm = "AES/CBC/PKCS5Padding";
// 创建 AES 密钥对象
SecretKey secretKey = new SecretKeySpec(key.getBytes(), "AES");
// 为加密算法提供一个随机的初始化向量,以增强加密安全性
IvParameterSpec parameterSpec = new IvParameterSpec(iv);
// 创建 Cipher 对象
Cipher cipher = Cipher.getInstance(alogrithm);
// 初始化为加密模式 Cipher.ENCRYPT_MODE
cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);
// Cipher text 对请求内容加密
byte[] cipherText = cipher.doFinal(content.getBytes());
// Concat iv and cipher text for signing
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(iv);
outputStream.write(cipherText);
byte signMessage[] = outputStream.toByteArray();
// Sign key 读取rsa私钥文件解析并得到私钥对象 privateKey
String rsaPrivateKeyPath = privateKeyPath;
PrivateKey privateKey = null;
byte[] signature;
try {
privateKey = readPrivateKeyFromFile(rsaPrivateKeyPath);
Signature signer = Signature.getInstance("SHA256withRSA");
signer.initSign(privateKey);
// 将加密内容和随机向量均加签
signer.update(signMessage);
signature = signer.sign();
} catch (SignatureException e) {
throw new RuntimeException(e);
} catch (Exception e) {
log.error(e.getMessage());
throw new RuntimeException(e);
}
Base64.Encoder encoder = Base64.getEncoder();
// Combine result
AlipayHKRequestDTO alipayHKRequestDTO = new AlipayHKRequestDTO();
alipayHKRequestDTO.setMerchant_id(merchantId);
alipayHKRequestDTO.setNonce(encoder.encodeToString(iv));
alipayHKRequestDTO.setMessage(encoder.encodeToString(cipherText));
alipayHKRequestDTO.setTag(encoder.encodeToString(signature));
String cipherSuite = mode + "-" + padding + "-with-" + signatureAlgorithm;
alipayHKRequestDTO.setCipher_suite(cipherSuite);
// Encode to json
String jsonEncoded = JSONObject.toJSONString(alipayHKRequestDTO);
log.info(jsonEncoded);
// String info = AlipayHKRequestUtil.createOrder(alipayHKRequestDTO);
// log.info(info);
return alipayHKRequestDTO;
}
/**
* 从文件中读取RSA私钥
* @param filePath
* @return
* @throws Exception
*/
private static PrivateKey readPrivateKeyFromFile(String filePath) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(filePath));
StringBuilder keyBuffer = new StringBuilder();
String line;
// 读取文本文件中的内容
while ((line = reader.readLine()) != null) {
keyBuffer.append(line);
}
reader.close();
// 去除私钥内容中的头部和尾部信息
String privateKeyContent = keyBuffer.toString()
.replace("-----BEGIN PRIVATE KEY-----", "")
.replace("-----END PRIVATE KEY-----", "")
.replaceAll("\\s+", ""); // 去除空格、换行等字符
// 进行 Base64 解码
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
return keyFactory.generatePrivate(keySpec);
}
/**
* 使用 AES 密钥和随机向量进行解密
*/
public static String decryptAES(String encryptedText, String iv) throws Exception {
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText);
byte[] ivBytes = Base64.getDecoder().decode(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey.getBytes(), "AES");
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
return new String(decryptedBytes, StandardCharsets.UTF_8);
}
public static void test() throws Exception {
// 加密数据
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
requestMessage.setService("create_order");
requestMessage.setMerchant_id(merchantId);
requestMessage.setRequest_time(Long.toString(System.currentTimeMillis() / 1000L));
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
HashMap<String, Object> param = new HashMap<>();
requestMessage.setParameters(param);
String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
param.put("order_ref", orderRef);
param.put("amount", 208.12);
param.put("subject", "四月帳單 April Bill");
param.put("wallet", "ALIPAYHK");
param.put("segment_id", segmentId);
param.put("payment_solution", "WAP");
Gson gson = new Gson();
String plaintext = gson.toJson(requestMessage);
System.out.println(plaintext);
// 生成 AES 密钥
String key = aesKey;
SecretKey aesKey = new SecretKeySpec(key.getBytes(), "AES");
// 使用 RSA 公钥加密 AES 密钥
String rsaPublicKeyPath = publicKeyPath;
PublicKey publicKey = readPublicKey(new File(rsaPublicKeyPath));
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
// Cipher rsaCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
rsaCipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] encryptedAesKey = rsaCipher.doFinal(aesKey.getEncoded());
// 使用 AES-128-CBC 加密数据
Cipher aesCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
byte[] ivBytes = generateRandomIV(aesCipher.getBlockSize());
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
aesCipher.init(Cipher.ENCRYPT_MODE, aesKey, ivSpec);
byte[] encryptedData = aesCipher.doFinal(plaintext.getBytes());
// 数字签名(使用 RSA 私钥)
String rsaPrivateKeyPath = privateKeyPath;
PrivateKey privateKey = readPrivateKeyFromFile(rsaPrivateKeyPath);
Signature signer = Signature.getInstance("SHA256withRSA");
signer.initSign(privateKey);
signer.update(encryptedData);
byte[] signatureBytes = signer.sign();
Base64.Encoder encoder = Base64.getEncoder();
// 将加密后的数据和签名进行Base64编码
String base64EncryptedData = Base64.getEncoder().encodeToString(encryptedData);
String base64Signature = Base64.getEncoder().encodeToString(signatureBytes);
// 输出加密后的数据和签名
System.out.println("加密后的数据:" + base64EncryptedData);
System.out.println("数字签名:" + base64Signature);
HashMap<String, String> result = new HashMap<String, String>();
result.put("merchant_id",merchantId);
result.put("nonce", encoder.encodeToString(ivBytes));
result.put("message", encoder.encodeToString(encryptedData));
result.put("tag", encoder.encodeToString(signatureBytes));
String mode = "aes-128-cbc";
// Padding mode
String padding = "pkcs7";
// signature alogrithm
String signatureAlgorithm = "rsa-sha256";
String cipherSuite = mode + "-" + padding + "-with-" + signatureAlgorithm;
result.put("cipher_suite", cipherSuite);
System.out.println("map 格式:" + result);
// Encode to json
String jsonEncoded = JSONObject.toJSONString(result);
System.out.println("json 格式:" + jsonEncoded);
AlipayHKRequestDTO alipayHKRequestDTO = new AlipayHKRequestDTO();
alipayHKRequestDTO.setMerchant_id(merchantId);
alipayHKRequestDTO.setNonce(encoder.encodeToString(ivBytes));
alipayHKRequestDTO.setMessage(encoder.encodeToString(encryptedData));
alipayHKRequestDTO.setTag(encoder.encodeToString(signatureBytes));
alipayHKRequestDTO.setCipher_suite(cipherSuite);
// String info = AlipayHKRequestUtil.createOrder(result);
// log.info(info);
// 解密和验证
// byte[] decryptedAesKey = rsaCipher.doFinal(encryptedAesKey);
byte[] decryptedAesKey = rsaCipher.doFinal(aesKey.getEncoded());
SecretKey decryptedAesSecretKey = new SecretKeySpec(decryptedAesKey, "AES");
aesCipher.init(Cipher.DECRYPT_MODE, decryptedAesSecretKey, ivSpec);
byte[] decryptedData = aesCipher.doFinal(Base64.getDecoder().decode(base64EncryptedData));
// 验证数字签名
Signature verifier = Signature.getInstance("SHA256withRSA");
verifier.initVerify(publicKey);
verifier.update(decryptedData);
boolean signatureValid = verifier.verify(Base64.getDecoder().decode(base64Signature));
System.out.println("解密后的数据:" + new String(decryptedData));
System.out.println("数字签名验证结果:" + signatureValid);
}
public static PublicKey readPublicKey(File file) throws Exception {
KeyFactory factory = KeyFactory.getInstance("RSA");
try (FileReader keyReader = new FileReader(file);
PemReader pemReader = new PemReader(keyReader)) {
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(content);
return factory.generatePublic(pubKeySpec);
}
}
private static byte[] generateRandomIV(int blockSize) {
SecureRandom random = new SecureRandom();
byte[] iv = new byte[blockSize];
random.nextBytes(iv);
return iv;
}
}

View File

@@ -0,0 +1,53 @@
package com.ai.da.common.utils;
import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.model.dto.AlipayHKRequestDTO;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import java.io.IOException;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson.JSONObject;
@Slf4j
public class AlipayHKRequestUtil {
public static String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
.build();
MediaType mediaType = MediaType.parse("application/json;charset=utf-8");
long epochMilli = Instant.now().toEpochMilli();
log.info("Alipay-HK send request unix timestamp: {}", epochMilli);
String jsonString = JSONObject.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue);
log.info(jsonString);
RequestBody body = RequestBody.create(mediaType, jsonString);
Request request = new Request.Builder()
// .url("https://aqs-api.sandbox-codpayment.com")
.url("https://aqs-api.sandbox-codpayment.com/v1/service")
.method("POST", body)
.addHeader("Content-Type", "application/json;charset=utf-8")
.build();
Response response = null;
String bodyString;
try {
// log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue));
response = client.newCall(request).execute();
} catch (Exception e) {
// log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
// throw new BusinessException("generate.interface.error");
throw new BusinessException(e.getMessage());
}
return response.body().string();
}
}

View File

@@ -308,4 +308,46 @@ public class SendEmailUtil {
throw new BusinessException("failed.to.send.mail");
}
}
private final static Long GENERATE_EXCEPTION_WARNING_ID = 122589L;
public static void sendGenerateExceptionWarning(String message){
try {
// 实例化一个认证对象
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ses.tencentcloudapi.com");
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
SendEmailRequest req = new SendEmailRequest();
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
req.setDestination(new String[]{"xupei3360@163.com"});
// 根据邮件类型设置不同的主题和模板
String subject = "";
Template template = new Template();
subject = "Warning: AiDA 3.0 Generate Exception Warning";
template.setTemplateID(GENERATE_EXCEPTION_WARNING_ID);
JSONObject parameter = new JSONObject();
parameter.put("errorMessage", message);
parameter.put("time", DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS));
template.setTemplateData(parameter.toJSONString());
req.setSubject(subject);
req.setTemplate(template);
// 发送邮件
SendEmailResponse resp = client.SendEmail(req);
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
log.info("邮件发送失败###{}", e.toString());
throw new BusinessException("failed.to.send.mail");
}
}
}

View File

@@ -0,0 +1,22 @@
package com.ai.da.controller;
import com.ai.da.common.response.Response;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@RestController
@RequestMapping("/api/ali-pay-hk")
@Api(tags = "网站支付 香港支付宝")
@Slf4j
public class AlipayHKController {
public Response<String> createOrder(){
return Response.success();
}
}

View File

@@ -0,0 +1,18 @@
package com.ai.da.model.dto;
import lombok.*;
import java.util.HashMap;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AlipayHKParametersDTO {
private String request_uuid;
private String request_time;
private String service;
private String merchant_id;
private HashMap<String, Object> parameters;
}

View File

@@ -0,0 +1,24 @@
package com.ai.da.model.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AlipayHKRequestDTO implements Serializable {
private String merchant_id;
private String nonce;
private String message;
private String tag;
private String cipher_suite;
}

View File

@@ -0,0 +1,22 @@
package com.ai.da.model.dto;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AlipayHKResponseDTO {
private boolean success;
private String reference_id;
private JSONObject result;
private String error;
private String error_code;
}

View File

@@ -48,9 +48,9 @@ public class DesignSingleItemDTO {
@ApiModelProperty("图层优先级")
private Integer priority;
@ApiModelProperty("渐变 起始/目标 颜色")
private List<List<Integer>> gradient;
@ApiModelProperty("渐变角度")
private Float gradient_angle;
// @ApiModelProperty("渐变 起始/目标 颜色")
// private List<List<Integer>> gradient;
//
// @ApiModelProperty("渐变角度")
// private Float gradient_angle;
}

View File

@@ -2596,9 +2596,7 @@ public class PythonService {
pythonTAllInfoService.getImageIdByPath(designSingleItem.getPath()),
designSingleItem.getOffset(),
designSingleItem.getScale(),
designSingleItem.getPriority(),
designSingleItem.getGradient(),
designSingleItem.getGradient_angle()));
designSingleItem.getPriority()));
});

View File

@@ -74,9 +74,12 @@ public class DesignPythonItem {
*/
private Integer priority;
private List<List<Integer>> gradient;
private Float gradient_angle;
/**
* 渐变图片的minio地址
*/
private String gradient;
//
// private Float gradient_angle;
public static List<String> OUTWEAR_DRESS_BLOUSE = Arrays.asList(CollectionLevel2TypeEnum.OUTWEAR.getRealName(),
CollectionLevel2TypeEnum.DRESS.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
@@ -126,20 +129,20 @@ public class DesignPythonItem {
this.priority = priority;
}
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List<Long> offset, Float resize_scale,Integer priority, List<List<Integer>> gradient, Float gradient_angle) {
this.type = type;
this.path = path;
this.color = color;
this.print = print;
// this.icon = icon;
this.businessId = businessId;
this.image_id = image_id;
this.offset = offset;
this.resize_scale = resize_scale;
this.priority = priority;
this.gradient = gradient;
this.gradient_angle = gradient_angle;
}
// public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List<Long> offset, Float resize_scale,Integer priority) {
// this.type = type;
// this.path = path;
// this.color = color;
// this.print = print;
//// this.icon = icon;
// this.businessId = businessId;
// this.image_id = image_id;
// this.offset = offset;
// this.resize_scale = resize_scale;
// this.priority = priority;
//// this.gradient = gradient;
//// this.gradient_angle = gradient_angle;
// }
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, String icon, Long businessId, Long image_id) {
this.type = type;

View File

@@ -0,0 +1,4 @@
package com.ai.da.service;
public interface AlipayHKService {
}

View File

@@ -0,0 +1,98 @@
package com.ai.da.service.impl;
import com.ai.da.common.enums.CreditsEventsEnum;
import com.ai.da.service.AlipayHKService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
@Service
@Slf4j
public class AlipayHKServiceImpl implements AlipayHKService {
@Value("${alipay.hk.merchant-id}")
private static String merchantId;
@Value("${alipay.hk.segment-id}")
private static String segmentId;
@Value("${alipay.hk.AESKey}")
private static String aesKey;
@Value("${alipay.hk.rsaPrivateKey}")
private static String privateKeyPath;
@Value("${alipay.hk.rsaPublicKey}")
private static String publicKeyPath;
/**
* 创建订单
*/
public void createOrder(Integer amount){
HashMap<String, Object> param = new HashMap<>();
String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
param.put("order_ref", orderRef);
param.put("amount", Integer.parseInt(CreditsEventsEnum.PRICE.getValue()) * amount);
param.put("subject", "AiDA Credits Purchase");
param.put("wallet", "ALIPAYHK");
param.put("segment_id", segmentId);
param.put("payment_solution", "WAP");
}
/**
* 异步回调
* @return
*/
public void callback(){
}
public static String decrypt(String message){
String text = "{\"success\":true,\"reference_id\":\"d4f55a35-8725-40f3-8279-37ea95837741\",\"result\":{\"nonce\":\"tUsbfFrNWcZZYrN3dWQHNQ==\",\"message\":\"6wCHtIMRXXgj0TOV7jtvCzbKc+gWEnqbgAD5pMx4sIvliL65EF+btKRheJI/0gssOj0PdwUPYLlgjTdSWQZraQLU4F05FGSYJ7lNxFZ1tXLvhUv4ukiCz0xyPJIQ5vvNH/SmQ5iIQvMO/fTg6ZiZj2I+Oahzy5h2/cXmrXBEedNFZSG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DdOB3nQ3HorqTFC+0kZMdTCO1L7zRbZQxWoExB41wQW3CNLvEkJlpaUv5TWKkep1wcT2PKFbuSVPnFnVnxZ7qNdlVLmBzEs9nX15C61+a28gFij4wj6ed8LIJwT4KapfZAFWwl2V2KmonqiXKk60/StBK9/dWHGfZ4ysPvXBB+fxJj3hR36Vu4HceNVYg+9tf5zEJ79J664iiyEFdyKzORlXnsJF33oPKC0+cuH1qhBzyf/o6t86F4DbpMBb2xhFRt1mDgFrV40JhT+2+iLCIqUmATBYsAYZZ9XIyi3vyaRGhgdd1ND/bhddALm/GKD4AJUo8FKtdkerYSbk/TpPLhvbrEFSDpkCT+JoOLiF4EzqRwZOrQklaXBOS67aaATRBzDxKJuFSGuFAWAIdLHhXcj/wDmnh1fqj03D4NmNmVSw7wKmt1OjI9arh6Ua1Mp7+1g+NT4BEdRnPYQX3CeiyRa0RUNyWxFDYZPGGpjSVNLf0vrzRh3hLEGBUlHXCza0SWuARkGmS6YdsvJr3gt+RlxXtrnI0LC0lgi9/Vw5zM5dGYX24tUOqCEA/9/FVvVZddfimYhmP44+ST1xTDgDw0rtVZQrcQjEg4UCcFq";
try {
// String s = decryptAES(str, "tUsbfFrNWcZZYrN3dWQHNQ==");
// log.info(s);
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
public static void main(String[] args) throws Exception {
// test();
// AESCBCWithRSA();
// decrypt();
}
}

View File

@@ -0,0 +1,11 @@
alipay.hk.merchant-id=3015240422190522
alipay.hk.segment-id=2971373831
alipay.hk.AESKey=UzRC2CncDUP6VlEd
alipay.hk.rsaPrivateKey=files/CODE-CREATE LIMITED-3015240422190522-merchant.private.key.txt
alipay.hk.rsaPublicKey=files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem
alipay.hk.api.url=https://aqs-api.sandbox-codpayment.com/