From 3790b8ee7235f340d4f077f25bf3c98685697b06 Mon Sep 17 00:00:00 2001 From: xupei Date: Wed, 15 May 2024 15:38:11 +0800 Subject: [PATCH 1/5] =?UTF-8?q?Alipay-HK=20=E5=88=9B=E5=BB=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E5=BC=82=E6=AD=A5=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 + .../da/common/constant/AlipayHKConstant.java | 20 ++ .../com/ai/da/common/enums/PayTypeEnum.java | 7 +- .../security/filter/AuthenticationFilter.java | 2 +- .../common/utils/AlipayHKEncryptionUtil.java | 60 ++++- .../da/common/utils/AlipayHKRequestUtil.java | 22 +- .../ai/da/controller/AlipayHKController.java | 30 ++- .../da/mapper/primary/entity/PaymentInfo.java | 2 +- .../ai/da/model/dto/AlipayHKCallbackDTO.java | 30 +++ .../com/ai/da/service/AlipayHKService.java | 10 + .../com/ai/da/service/PaymentInfoService.java | 3 + .../da/service/impl/AlipayHKServiceImpl.java | 245 ++++++++++++++++-- .../service/impl/PaymentInfoServiceImpl.java | 41 ++- src/main/resources/alipay-hk.properties | 11 - src/main/resources/alipay-sandbox.properties | 7 + src/main/resources/application-dev.properties | 2 +- 16 files changed, 429 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/ai/da/common/constant/AlipayHKConstant.java create mode 100644 src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java delete mode 100644 src/main/resources/alipay-hk.properties diff --git a/pom.xml b/pom.xml index 21b1264b..f816c5ca 100644 --- a/pom.xml +++ b/pom.xml @@ -226,6 +226,12 @@ 2.17.1 + + com.stripe + stripe-java + 25.0.0 + + diff --git a/src/main/java/com/ai/da/common/constant/AlipayHKConstant.java b/src/main/java/com/ai/da/common/constant/AlipayHKConstant.java new file mode 100644 index 00000000..aa290cc1 --- /dev/null +++ b/src/main/java/com/ai/da/common/constant/AlipayHKConstant.java @@ -0,0 +1,20 @@ +package com.ai.da.common.constant; + +public class AlipayHKConstant { + + // 服务名 + public static final String CREATE_ORDER = "create_order"; + public static final String ORDER_DETAILS = "order_details"; + public static final String TRANSACTION_DETAILS = "transaction_details"; + public static final String GET_FILE = "get_file"; + public static final String CREATE_AUTO_DEBIT = "create_auto_debit"; + public static final String REFRESH_TRANSACTION_STATUS = "refresh_transaction_status"; + public static final String REFUND_TRANSACTION = "refund_transaction"; + + // 订单状态 + public static final String STATUS_NEW = "new"; + public static final String STATUS_WAIT = "wait"; + public static final String STATUS_PAID = "paid"; + public static final String STATUS_EXPIRED = "expired"; + public static final String STATUS_LIQUIDATED = "liquidated"; +} diff --git a/src/main/java/com/ai/da/common/enums/PayTypeEnum.java b/src/main/java/com/ai/da/common/enums/PayTypeEnum.java index 70067578..5bc14b21 100644 --- a/src/main/java/com/ai/da/common/enums/PayTypeEnum.java +++ b/src/main/java/com/ai/da/common/enums/PayTypeEnum.java @@ -19,7 +19,12 @@ public enum PayTypeEnum { /** * PayPal */ - PAYPAL("PayPal"); + PAYPAL("PayPal"), + + /** + * 香港支付宝 + */ + ALIPAY_HK("Alipay-HK"); /** * 类型 diff --git a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java index 9e404107..4256b8fe 100644 --- a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java +++ b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java @@ -49,7 +49,7 @@ public class AuthenticationFilter extends OncePerRequestFilter { "/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew", "/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl", // "/api/python/chatStream", - "/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back" + "/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify" ); @Override diff --git a/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java b/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java index 205c7f94..5e8662a3 100644 --- a/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java +++ b/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java @@ -6,9 +6,16 @@ import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.extern.slf4j.Slf4j; +import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; +import org.bouncycastle.crypto.digests.SHA256Digest; +import org.bouncycastle.crypto.params.AsymmetricKeyParameter; +import org.bouncycastle.crypto.signers.RSADigestSigner; +import org.bouncycastle.crypto.util.PublicKeyFactory; +import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.util.io.pem.PemObject; import org.bouncycastle.util.io.pem.PemReader; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import javax.crypto.*; import javax.crypto.spec.IvParameterSpec; @@ -25,22 +32,24 @@ import java.util.HashMap; import java.util.UUID; @Slf4j +@Component public class AlipayHKEncryptionUtil { - @Value("${alipay.hk.merchant-id}") - private static String merchantId; + @Value("${alipayHK.merchantId}") + private String merchantId; - @Value("${alipay.hk.segment-id}") - private static String segmentId; + @Value("${alipayHK.segmentId}") + private String segmentId; - @Value("${alipay.hk.AESKey}") - private static String aesKey; + @Value("${alipayHK.AESKey}") + private String aesKey; - @Value("${alipay.hk.rsaPrivateKey}") - private static String privateKeyPath; + @Value("${alipayHK.rsaPrivateKey}") + private String privateKeyPath; + + @Value("${alipayHK.rsaPublicKey}") + private String publicKeyPath; - @Value("${alipay.hk.rsaPublicKey}") - private static String publicKeyPath; /** * 加密 @@ -55,7 +64,7 @@ public class AlipayHKEncryptionUtil { * @throws BadPaddingException * @throws IOException */ - public static AlipayHKRequestDTO AESCBCWithRSA(HashMap param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException { + public AlipayHKRequestDTO AESCBCWithRSA(HashMap 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 @@ -187,7 +196,7 @@ public class AlipayHKEncryptionUtil { /** * 使用 AES 密钥和随机向量进行解密 */ - public static String decryptAES(String encryptedText, String iv) throws Exception { + public String decryptAES(String encryptedText, String iv) throws Exception { byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText); byte[] ivBytes = Base64.getDecoder().decode(iv); @@ -201,7 +210,7 @@ public class AlipayHKEncryptionUtil { return new String(decryptedBytes, StandardCharsets.UTF_8); } - public static void test() throws Exception { + public void test() throws Exception { // 加密数据 AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO(); requestMessage.setService("create_order"); @@ -326,4 +335,29 @@ public class AlipayHKEncryptionUtil { random.nextBytes(iv); return iv; } + + public Boolean signatureVerification(String data, String signatureBase64){ + + Base64.Decoder decoder = Base64.getDecoder(); + // Verify key + try { +// PublicKey publicKey = readPublicKey(new File(publicKeyPath)); + InputStreamReader isrPub = new InputStreamReader(new FileInputStream(publicKeyPath)); + PEMParser pemParserPub = new PEMParser(isrPub); + SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject(); + AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo); + // Verifying + RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest()); + verifier.init(false, pubKey); + byte[] signMessageForVerifing = data.getBytes(); + byte[] signatureBase64ForVerifing = decoder.decode(signatureBase64); + verifier.update(signMessageForVerifing, 0, signMessageForVerifing.length); + Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifing); + return verifyResult; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + } diff --git a/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java b/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java index 331c01ed..771f5154 100644 --- a/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java +++ b/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java @@ -11,11 +11,13 @@ import java.time.Instant; import java.util.concurrent.TimeUnit; import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Component; @Slf4j +@Component public class AlipayHKRequestUtil { - public static String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException { + public String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException { OkHttpClient client = new OkHttpClient().newBuilder() .connectTimeout(30, TimeUnit.SECONDS) .pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒) @@ -32,22 +34,28 @@ public class AlipayHKRequestUtil { 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; + Response response; String bodyString; try { -// log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue)); response = client.newCall(request).execute(); + assert response.body() != null; + bodyString = response.body().string(); } 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(); + JSONObject jsonObject = JSONObject.parseObject(bodyString); + boolean success = (boolean) jsonObject.get("success"); + if (success){ + return bodyString; + } else { + String message = jsonObject.get("error_code").toString() + ":" + jsonObject.get("error"); + log.error("Alipay return message : {}", message); + throw new BusinessException("Alipay return message : " + message); + } } } diff --git a/src/main/java/com/ai/da/controller/AlipayHKController.java b/src/main/java/com/ai/da/controller/AlipayHKController.java index 9b2fca11..38f2da9b 100644 --- a/src/main/java/com/ai/da/controller/AlipayHKController.java +++ b/src/main/java/com/ai/da/controller/AlipayHKController.java @@ -1,22 +1,40 @@ package com.ai.da.controller; import com.ai.da.common.response.Response; +import com.ai.da.service.AlipayHKService; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; 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; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; @CrossOrigin @RestController -@RequestMapping("/api/ali-pay-hk") +@RequestMapping("/api/alipay-hk") @Api(tags = "网站支付 香港支付宝") @Slf4j public class AlipayHKController { - public Response createOrder(){ - return Response.success(); + @Resource + private AlipayHKService alipayHKService; + + @ApiOperation(value = "创建订单") + @PostMapping(value = "/createOrder") + public Response createOrder(@RequestParam Integer amount, @RequestParam String wallet) { + String order = alipayHKService.createOrder(amount, wallet); + return Response.success(order); + } + + @ApiOperation("支付通知") + @PostMapping("/trade/notify") + public String callback(@RequestParam Map params){ + return alipayHKService.callback(params); } + + + } diff --git a/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java b/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java index 8557aa83..2d7cf881 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java @@ -17,7 +17,7 @@ public class PaymentInfo extends BaseEntity{ private String tradeState;//交易状态 - private Integer payerTotal;//支付金额(分) + private Long payerTotal;//支付金额(元) private String content;//通知参数 } diff --git a/src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java b/src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java new file mode 100644 index 00000000..d1e40107 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java @@ -0,0 +1,30 @@ +package com.ai.da.model.dto; + +import lombok.Data; + +@Data +public class AlipayHKCallbackDTO { + + private String transaction_id; + + private Long amount; + + private String currency; + + private String payment_time; + + private String merchant_id; + + private String segment_id; + + private String out_trade_no; + + private String type; + + private String status; + + private String pid; + + private String subject; + +} diff --git a/src/main/java/com/ai/da/service/AlipayHKService.java b/src/main/java/com/ai/da/service/AlipayHKService.java index baf56c8e..47f06d2b 100644 --- a/src/main/java/com/ai/da/service/AlipayHKService.java +++ b/src/main/java/com/ai/da/service/AlipayHKService.java @@ -1,4 +1,14 @@ package com.ai.da.service; +import com.ai.da.model.dto.AlipayHKCallbackDTO; + +import java.util.Map; + public interface AlipayHKService { + + String createOrder(Integer amount, String wallet); + + String callback(Map params); + + void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO); } diff --git a/src/main/java/com/ai/da/service/PaymentInfoService.java b/src/main/java/com/ai/da/service/PaymentInfoService.java index 4a350dff..de9526b1 100644 --- a/src/main/java/com/ai/da/service/PaymentInfoService.java +++ b/src/main/java/com/ai/da/service/PaymentInfoService.java @@ -1,5 +1,6 @@ package com.ai.da.service; +import com.ai.da.model.dto.AlipayHKCallbackDTO; import com.paypal.orders.Order; import java.util.Map; @@ -11,4 +12,6 @@ public interface PaymentInfoService { void createPaymentInfoForAliPay(Map params); void createPaymentInfoForPayPal(Order order); + + void createPaymentInfoForAliPayHK(AlipayHKCallbackDTO alipayHKCallbackDTO); } diff --git a/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java b/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java index 4445c6cb..0876991a 100644 --- a/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java @@ -1,50 +1,113 @@ package com.ai.da.service.impl; +import com.ai.da.common.constant.AlipayHKConstant; import com.ai.da.common.enums.CreditsEventsEnum; -import com.ai.da.service.AlipayHKService; +import com.ai.da.common.enums.OrderStatusEnum; +import com.ai.da.common.enums.PayTypeEnum; +import com.ai.da.common.utils.AlipayHKEncryptionUtil; +import com.ai.da.common.utils.AlipayHKRequestUtil; +import com.ai.da.mapper.primary.entity.OrderInfo; +import com.ai.da.model.dto.AlipayHKCallbackDTO; +import com.ai.da.model.dto.AlipayHKRequestDTO; +import com.ai.da.service.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Arrays; import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; @Service @Slf4j public class AlipayHKServiceImpl implements AlipayHKService { - @Value("${alipay.hk.merchant-id}") - private static String merchantId; + @Value("${alipayHK.merchantId}") + private String merchantId; - @Value("${alipay.hk.segment-id}") - private static String segmentId; + @Value("${alipayHK.segmentId}") + private String segmentId; - @Value("${alipay.hk.AESKey}") - private static String aesKey; + @Value("${alipayHK.AESKey}") + private String aesKey; - @Value("${alipay.hk.rsaPrivateKey}") - private static String privateKeyPath; + @Value("${alipayHK.rsaPrivateKey}") + private String privateKeyPath; - @Value("${alipay.hk.rsaPublicKey}") - private static String publicKeyPath; + @Value("${alipayHK.rsaPublicKey}") + private String publicKeyPath; + + @Resource + private OrderInfoService orderInfoService; + @Resource + private PaymentInfoService paymentInfoService; + @Resource + private CreditsService creditsService; + @Resource + private AlipayHKEncryptionUtil alipayHKEncryptionUtil; + @Resource + private AlipayHKRequestUtil alipayHKRequestUtil; /** * 创建订单 */ - public void createOrder(Integer amount){ + @Override + public String createOrder(Integer amount, String wallet){ - HashMap 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"); + try{ + HashMap 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"); + // ALIPAYHK 或者 ALIPAYCN + param.put("wallet", wallet); + param.put("segment_id", segmentId); + param.put("payment_solution", "WAP"); + log.info("alipay-hk 创建订单,参数信息: {}", param); + // 生成订单 + log.info("创建订单"); + OrderInfo orderInfo = orderInfoService.createOrderByProductId(amount, PayTypeEnum.ALIPAY_HK.getType()); + // 加密 + AlipayHKRequestDTO alipayHKRequestDTO = alipayHKEncryptionUtil.AESCBCWithRSA(param, AlipayHKConstant.CREATE_ORDER); + // 请求Alipay服务端 + String response = alipayHKRequestUtil.createOrder(alipayHKRequestDTO); + // 获取response中的加密数据 + JSONObject responseObj = JSONObject.parseObject(response); + JSONObject resultObj = JSONObject.parseObject(responseObj.get("result").toString()); + String nonce = resultObj.get("nonce").toString(); + String message = resultObj.get("message").toString(); + // 解密 + String s = alipayHKEncryptionUtil.decryptAES(message, nonce); + JSONObject jsonObject = JSONObject.parseObject(s); + String orderId = jsonObject.get("out_trade_no").toString(); + + orderInfoService.updateOrderNoById(orderInfo.getId(), orderId); + + + log.info("create_order 接口返回信息 :{}", s); + + return s; + + + }catch (Exception e){ + log.error("订单创建失败 : {}", e.getMessage()); + // todo 或者抛异常 + return null; + } } @@ -53,8 +116,122 @@ public class AlipayHKServiceImpl implements AlipayHKService { * 异步回调 * @return */ - public void callback(){ + public String callback(Map params){ + log.info("支付通知正在执行"); + log.info("通知参数 ===> {}", params); + String result = "failure"; + + String data = params.get("data"); + String signature = params.get("signature"); + + try { + // 异步回调验签 + Boolean verification = alipayHKEncryptionUtil.signatureVerification(data, signature); + + if (!verification){ + log.error("alipay-hk 验签失败"); + return result; + } + + AlipayHKCallbackDTO alipayHKCallbackDTO = JSONObject.parseObject(data, AlipayHKCallbackDTO.class); + //按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验, + //1 商户需要验证该通知数据中的 out_trade_no 是否为商户系统中创建的订单号 + String outTradeNo = alipayHKCallbackDTO.getOut_trade_no(); + OrderInfo order = orderInfoService.getOrderByOrderNo(outTradeNo); + if(order == null){ + log.error("订单不存在"); + return result; + } + + //2 判断 total_amount 是否确实为该订单的实际金额(即商户订单创建时的金额) + Long totalAmount = alipayHKCallbackDTO.getAmount(); + Long totalFee = order.getTotalFee().longValue(); + if(totalAmount != totalFee){ + log.error("金额校验失败"); + return result; + } + + //3 校验通知中的 seller_id(或者 seller_email) 是否为 out_trade_no 这笔单据的对应的操作方 + String sellerId = alipayHKCallbackDTO.getMerchant_id(); + String sellerIdProperty = merchantId; + if(!sellerId.equals(sellerIdProperty)){ + log.error("商家pid校验失败"); + return result; + } + + //4 验证 app_id 是否为该商户本身 + String segId = alipayHKCallbackDTO.getSegment_id(); + String segmentIdProperty = segmentId; + if(!segId.equals(segmentIdProperty)){ + log.error("segmentId校验失败"); + return result; + } + + //在支付宝的业务通知中,只有交易通知状态为 TRADE_SUCCESS时, + // 支付宝才会认定为买家付款成功。 + String tradeStatus = alipayHKCallbackDTO.getStatus(); + if(!AlipayHKConstant.STATUS_PAID.equals(tradeStatus)){ + log.error("支付未成功"); + return result; + } + + processOrder(alipayHKCallbackDTO); + result = "success"; + }catch (Exception e){ + log.error(e.getMessage()); + } + + + return result; + + } + + private final ReentrantLock lock = new ReentrantLock(); + + + @Transactional(rollbackFor = Exception.class) + @Override + public void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO) { + + log.info("处理订单"); + + //获取订单号 + String orderNo = alipayHKCallbackDTO.getOut_trade_no(); + String totalAmount = alipayHKCallbackDTO.getAmount().toString(); + + /*在对业务数据进行状态检查和处理之前, + 要采用数据锁进行并发控制, + 以避免函数重入造成的数据混乱*/ + //尝试获取锁: + // 成功获取则立即返回true,获取失败则立即返回false。不必一直等待锁的释放 + if(lock.tryLock()) { + try { + //处理重复通知 + //接口调用的幂等性:无论接口被调用多少次,以下业务执行一次 +// String orderStatus = orderInfoService.getOrderStatus(orderNo); + OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(orderNo); + String orderStatus = orderByOrderNo.getOrderStatus(); + // 当订单状态处于未支付或超时已关闭时,更新订单状态 + if (!OrderStatusEnum.NOT_PAY.getType().equals(orderStatus) || !OrderStatusEnum.TIMEOUT_CLOSED.getType().equals(orderStatus)) { + return; + } + //更新订单状态 + orderInfoService.updateStatusByOrderNo(orderNo, OrderStatusEnum.SUCCESS); + //记录支付日志 + paymentInfoService.createPaymentInfoForAliPayHK(alipayHKCallbackDTO); + // 添加积分变更记录 + creditsService.insertToCreditsDetail(orderByOrderNo.getAccountId(), + CreditsEventsEnum.BUY_CREDITS.getName() + "--AlipayHK", + CreditsEventsEnum.BUY_CREDITS.getValue(), + "positive"); + // 更新积分 + creditsService.buyCredits(orderByOrderNo.getAccountId(),Integer.parseInt(totalAmount) / Integer.parseInt(CreditsEventsEnum.PRICE.getValue())); + } finally { + //要主动释放锁 + lock.unlock(); + } + } } @@ -88,10 +265,28 @@ public class AlipayHKServiceImpl implements AlipayHKService { - public static void main(String[] args) throws Exception { -// test(); -// AESCBCWithRSA(); -// decrypt(); +// public static void main(String[] args) throws Exception { +//// test(); +//// AESCBCWithRSA(); +//// decrypt(); +// } + + public static void main(String[] args) { + System.out.println("Supported TLS versions:"); + String[] tlsVersions = getSupportedTLSVersions(); + Arrays.stream(tlsVersions).forEach(System.out::println); + } + + public static String[] getSupportedTLSVersions() { + try { + SSLContext context = SSLContext.getDefault(); + SSLSocketFactory factory = context.getSocketFactory(); + String[] supportedProtocols = factory.getDefaultCipherSuites(); + return supportedProtocols; + } catch (Exception e) { + e.printStackTrace(); + return new String[0]; + } } diff --git a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java index 367dd376..224bfd91 100644 --- a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java @@ -3,6 +3,7 @@ package com.ai.da.service.impl; import com.ai.da.common.enums.PayTypeEnum; import com.ai.da.mapper.primary.PaymentInfoMapper; import com.ai.da.mapper.primary.entity.PaymentInfo; +import com.ai.da.model.dto.AlipayHKCallbackDTO; import com.ai.da.service.PaymentInfoService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.gson.Gson; @@ -48,7 +49,8 @@ public class PaymentInfoServiceImpl extends ServiceImpl Date: Thu, 16 May 2024 15:32:39 +0800 Subject: [PATCH 2/5] =?UTF-8?q?generate=20text=E5=AD=98db=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ai/da/service/impl/GenerateServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 48f3655a..fbe8715d 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -259,7 +259,7 @@ public class GenerateServiceImpl extends ServiceImpl i switch (level1Type) { case "Moodboard": text = translated + ",high quality"; - generate.setText(text); +// generate.setText(text); break; case "Printboard": if (userInput.contains("Painting Style")) { @@ -270,11 +270,11 @@ public class GenerateServiceImpl extends ServiceImpl i userInput = "Still life photography,hyper realism,3d,deepened projection,increased permutation value,increased concavity and convexity value," + translated; } text = userInput + ", fabric print, high quality"; - generate.setText(text); +// generate.setText(text); break; case "Sketchboard": text = "clear lines, simple outlines monochrome white vector image of " + translated + ", no background, sketch flat, front view display, best quality, ultra-high resolution 8k"; - generate.setText(text); +// generate.setText(text); default: } return text; From 5ebf0669f50898b3e0c20c2ff1aa0679a7cbffad Mon Sep 17 00:00:00 2001 From: xupei Date: Thu, 23 May 2024 15:48:55 +0800 Subject: [PATCH 3/5] =?UTF-8?q?alipay-hk=20=E5=88=87=E6=8D=A2=E5=88=B0live?= =?UTF-8?q?=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-2088841167357411-merchant.private.key.txt | 28 +++++++++++++++++++ ...Create Limited.merchant.aqs.public.key.pem | 9 ++++++ .../da/common/utils/AlipayHKRequestUtil.java | 3 +- .../da/mapper/primary/entity/OrderInfo.java | 2 +- .../ai/da/mapper/primary/entity/Product.java | 3 +- .../da/mapper/primary/entity/RefundInfo.java | 6 ++-- .../ai/da/service/impl/AliPayServiceImpl.java | 5 ++-- .../da/service/impl/AlipayHKServiceImpl.java | 6 ++-- .../da/service/impl/OrderInfoServiceImpl.java | 3 +- .../impl/PayPalCheckoutServiceImpl.java | 8 ++++-- src/main/resources/alipay-sandbox.properties | 14 ++++++---- 11 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 files/Code-Create Limited-2088841167357411-merchant.private.key.txt create mode 100644 files/Code-Create Limited.merchant.aqs.public.key.pem diff --git a/files/Code-Create Limited-2088841167357411-merchant.private.key.txt b/files/Code-Create Limited-2088841167357411-merchant.private.key.txt new file mode 100644 index 00000000..24cbf57d --- /dev/null +++ b/files/Code-Create Limited-2088841167357411-merchant.private.key.txt @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDD+NUduhLJcb2Z +ryLwtIHdmjfh6Wn73E9umHmdPf6yF7IbDoTDBmIAfaPU/oiLgrka3fKGCkn/yHvW +QcL+Ry96/Uu+iIN9SbG5vPVvLtLfx+5++IE8p3RxcSDQggqFuJ+osebXeVIrOcTZ +s7nXCqGenTcagv2eJESiq712fcBvY1wVgilT6ERVQy+zdvwAOiS6wXF/51AueP+E +rNDHuPLkGH6JhLtO4LffeYgM/Th7eCl/WWLkiVMSoeJt7vWFe4bYV/IYW1qI2aQX +H1DYmvwgDfDv8jRORD9D191YBqq1l3Tw7VSjFrpydFvSK46dbXKBj3oA5ZiJ+Ttj +ZCtBRiOdAgMBAAECggEAUKl4Fs9C8lV1o+85Y3f4yBy1CbCIZhltPGlYDUe6MNWe +ApL8REW5Sthr+bx2uW2qAQv/yfosMTL0/eB9gSoNugLODXOlI4mUtI25O/U66M8j +NHHWx/9o51SYHBqaeCXg2Y+4I1KVZqNVigH26TNACMhPKQNnnpLxCT/FMSNbdLzo +wfFMyjN7R3Hc8ZB1C2zx+fLJm1DNZeOJOHAkW1LprlotRv6eq3lOwZaDDUTB5xhT +0Erev3djC/R08Fne1y09ukar8z0tX3Fm9SzHJDFVoh1HOYPWayCiAxOhip+JnFct +rtK5jjuB8DAP4Q1k12yOWUFwb6NOG9Hf/G6XExRPBQKBgQD1P2SnKD1IlNSrvVJn +2HzKnBVllVo50fbv7SpnP8H1B5vt2Qo/mgOGtzbeXyK4mcLFaWg9++BrsjTXwZFi +wmKeJgNI822DPhF5qQhK7Cc+WMwesufGrTnmRUOEFYehz9ffZBvMa1s/ObIEyLcr +tYitT74+nFdRPtr+8PN06QMEcwKBgQDMkGFWhSO7p7VMuV0H0uC1fj3GGtVvM+Ps +a9ASs0HBhQaOpberkKY9vgry6HoJ8CGvbrxlmc3JoYPRwKN3oQRYLvGSF96HAg9i +643FmVAWiVzHpjYX9fMJyCzXiOw6Qet8Zp3Ewaw9BBG0200Fj6/zGc8XEqNjIv5Q +DQ9MosRDrwKBgQCU5i5IRugeXy5YLxQPNKNfqDBdgrZLEK2qsgXithUencYQPIw6 +XVnyut43WO+NwN0+WmcN6xUwjfwDWuTYX0jc2Bt6eUFuQ4r8oKIGSybwdZ1IrjqG +p7nVkwwQ77lvhu98FB3EmRHHa1IoEW0Uvp0DDL1m6ikhjNYNn2FRA//u/QKBgGbY +a+eo1ldBMPha9Te6wLjeuEYCNa5L41p4tcrBDt0xeSN8k4QRHFNMWYrYcIrQjM77 +mIJoOjsWFgT9mfHKJToEl/VAROORmJS+Iq/mrYo3E0tY+DdBsygG2Oyf7Uw42iDY +IpfKW0Lt6c0IuIeEPwy0vBY4i6aK8Frkxf1ck9oHAoGBAKFQg/c36J6tjnttpmes +R/zijp1ROE+z+dMmm3icDhCDvvR6MnHa2Y9ittNWdEUosZk9FsFn62YNtJJV2SIN +DDn0ASLtBkeCd8yad5uzUb7Umci9V7TP5c0NE3DK95FmciLGOuRbFyq1Z8edHnaS +zgLnf4yb25eCMLEG0Z2ugN3C +-----END PRIVATE KEY----- diff --git a/files/Code-Create Limited.merchant.aqs.public.key.pem b/files/Code-Create Limited.merchant.aqs.public.key.pem new file mode 100644 index 00000000..d6a27eee --- /dev/null +++ b/files/Code-Create Limited.merchant.aqs.public.key.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw/jVHboSyXG9ma8i8LSB +3Zo34elp+9xPbph5nT3+sheyGw6EwwZiAH2j1P6Ii4K5Gt3yhgpJ/8h71kHC/kcv +ev1LvoiDfUmxubz1by7S38fufviBPKd0cXEg0IIKhbifqLHm13lSKznE2bO51wqh +np03GoL9niREoqu9dn3Ab2NcFYIpU+hEVUMvs3b8ADokusFxf+dQLnj/hKzQx7jy +5Bh+iYS7TuC333mIDP04e3gpf1li5IlTEqHibe71hXuG2FfyGFtaiNmkFx9Q2Jr8 +IA3w7/I0TkQ/Q9fdWAaqtZd08O1Uoxa6cnRb0iuOnW1ygY96AOWYifk7Y2QrQUYj +nQIDAQAB +-----END PUBLIC KEY----- diff --git a/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java b/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java index 771f5154..a980e477 100644 --- a/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java +++ b/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java @@ -34,7 +34,8 @@ public class AlipayHKRequestUtil { RequestBody body = RequestBody.create(mediaType, jsonString); Request request = new Request.Builder() - .url("https://aqs-api.sandbox-codpayment.com/v1/service") +// .url("https://aqs-api.sandbox-codpayment.com/v1/service") + .url("https://aqs-api.codpayment.com/v1/service") .method("POST", body) .addHeader("Content-Type", "application/json;charset=utf-8") .build(); diff --git a/src/main/java/com/ai/da/mapper/primary/entity/OrderInfo.java b/src/main/java/com/ai/da/mapper/primary/entity/OrderInfo.java index c3b0be10..98a020b9 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/OrderInfo.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/OrderInfo.java @@ -15,7 +15,7 @@ public class OrderInfo extends BaseEntity{ private Long productId;//支付产品id - private Integer totalFee;//订单金额(元) + private Float totalFee;//订单金额(元) private String codeUrl;//订单二维码连接 diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Product.java b/src/main/java/com/ai/da/mapper/primary/entity/Product.java index ddea327e..1eab75ca 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/Product.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/Product.java @@ -9,7 +9,8 @@ public class Product extends BaseEntity{ private String title; //商品名称 - private Integer price; //价格(分) +// private Integer price; //价格(分) + private Float price; //价格(元) private Integer credits; // 积分 } diff --git a/src/main/java/com/ai/da/mapper/primary/entity/RefundInfo.java b/src/main/java/com/ai/da/mapper/primary/entity/RefundInfo.java index 19719a98..5349fd89 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/RefundInfo.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/RefundInfo.java @@ -13,9 +13,11 @@ public class RefundInfo extends BaseEntity{ private String refundId;//支付系统退款单号(微信) - private Integer totalFee;//原订单金额(分) +// private Integer totalFee;//原订单金额(分) + private Float totalFee;//原订单金额(分) - private Integer refund;//退款金额(分) +// private Integer refund;//退款金额(分) + private Float refund;//退款金额(分) private String reason;//退款原因 diff --git a/src/main/java/com/ai/da/service/impl/AliPayServiceImpl.java b/src/main/java/com/ai/da/service/impl/AliPayServiceImpl.java index e0f5c107..2d886b2d 100644 --- a/src/main/java/com/ai/da/service/impl/AliPayServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AliPayServiceImpl.java @@ -318,7 +318,7 @@ public class AliPayServiceImpl implements AliPayService { CreditsEventsEnum.BUY_CREDITS.getValue(), "positive"); // 更新积分 - creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue())); + creditsService.buyCredits(orderByOrderNo.getAccountId(),(int)(orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()))); } } @@ -390,7 +390,8 @@ public class AliPayServiceImpl implements AliPayService { AliPayTradeStateEnum.REFUND_SUCCESS.getType()); //退款成功 // 更新积分状态 OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(orderNo); - creditsService.creditsRefund(orderByOrderNo.getAccountId(), orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue())); +// creditsService.creditsRefund(orderByOrderNo.getAccountId(), orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue())); + creditsService.creditsRefund(orderByOrderNo.getAccountId(), (int)(orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()))); } else { log.info("调用失败,返回码 ===> " + response.getCode() + ", 返回描述 ===> " + response.getMsg()); diff --git a/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java b/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java index 0876991a..53c58d5d 100644 --- a/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java @@ -21,12 +21,12 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; -import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.concurrent.locks.ReentrantLock; @Service @@ -70,7 +70,7 @@ public class AlipayHKServiceImpl implements AlipayHKService { HashMap 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("amount", Float.parseFloat(CreditsEventsEnum.PRICE.getValue()) * amount); param.put("subject", "AiDA Credits Purchase"); // ALIPAYHK 或者 ALIPAYCN param.put("wallet", wallet); @@ -147,7 +147,7 @@ public class AlipayHKServiceImpl implements AlipayHKService { //2 判断 total_amount 是否确实为该订单的实际金额(即商户订单创建时的金额) Long totalAmount = alipayHKCallbackDTO.getAmount(); Long totalFee = order.getTotalFee().longValue(); - if(totalAmount != totalFee){ + if(!Objects.equals(totalAmount, totalFee)){ log.error("金额校验失败"); return result; } diff --git a/src/main/java/com/ai/da/service/impl/OrderInfoServiceImpl.java b/src/main/java/com/ai/da/service/impl/OrderInfoServiceImpl.java index 36f02676..416d84d2 100644 --- a/src/main/java/com/ai/da/service/impl/OrderInfoServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/OrderInfoServiceImpl.java @@ -54,7 +54,8 @@ public class OrderInfoServiceImpl extends ServiceImpl Date: Mon, 27 May 2024 18:07:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=8D=E7=AD=89=E6=AF=94=E7=BC=A9?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/common/RabbitMQ/MQConfig.java | 8 ++--- .../ai/da/model/dto/DesignSingleItemDTO.java | 2 +- .../ai/da/model/vo/DesignPythonOutfitVO.java | 4 +-- .../com/ai/da/python/vo/DesignPythonItem.java | 4 +-- .../da/python/vo/OutfitDetailPythonItem.java | 4 +-- .../service/impl/DesignItemServiceImpl.java | 3 +- .../ai/da/service/impl/DesignServiceImpl.java | 8 +++-- .../TDesignPythonOutfitDetailServiceImpl.java | 30 ++++++++++++++++++- 8 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java index 637fc94e..7079f02a 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java @@ -12,16 +12,16 @@ public class MQConfig { // public static final String GENERATE_QUEUE = "generate-queue-test"; // ================================================================== // public static final String GENERATE_QUEUE = "generate-queue-local"; - public static final String GENERATE_QUEUE = "generate-queue-prod"; + public static final String GENERATE_QUEUE = "generate-queue-dev"; // public static final String SR_QUEUE = "SR-queue-local"; - public static final String SR_QUEUE = "SR-queue-prod"; + public static final String SR_QUEUE = "SR-queue-dev"; // public static final String SR_RESULT_QUEUE = "SuperResolution-local"; - public static final String SR_RESULT_QUEUE = "SuperResolution-prod"; + public static final String SR_RESULT_QUEUE = "SuperResolution-dev"; // public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local"; - public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod"; + public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev"; public MQConfig() { } diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java index 11bbd0ed..0716bf86 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java @@ -44,7 +44,7 @@ public class DesignSingleItemDTO implements Serializable { private List offset; @ApiModelProperty("图层缩放比例") - private Float scale; + private Float[] scale; @NotNull(message = "priority.cannot.be.empty") @ApiModelProperty("图层优先级") diff --git a/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java b/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java index 37711ff1..ad19d19b 100644 --- a/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java +++ b/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java @@ -23,7 +23,7 @@ public class DesignPythonOutfitVO { private String imageCategory; /** - * 图层大小 + * 图层大小(前后片大小) */ @ApiModelProperty(value = "图层大小") private List imageSize; @@ -55,7 +55,7 @@ public class DesignPythonOutfitVO { * 图层缩放比例 */ @ApiModelProperty(value = "缩放比例") - private Float scale = 1.0f; + private Float[] scale = new Float[]{1.0f,1.0f}; /** * 图层优先级 从10开始,优先级数字越大越靠近上层 */ diff --git a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java index b2416fe8..1139c24a 100644 --- a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java +++ b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java @@ -72,7 +72,7 @@ public class DesignPythonItem { /** * 图层缩放大小 */ - private Float resize_scale; + private Float[] resize_scale; /** * 图层优先级 */ @@ -114,7 +114,7 @@ public class DesignPythonItem { } public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, - Long image_id, List offset, Float resize_scale, Integer priority, String gradient, String gradientString) { + Long image_id, List offset, Float[] resize_scale, Integer priority, String gradient, String gradientString) { this.type = type; this.path = path; this.color = color; diff --git a/src/main/java/com/ai/da/python/vo/OutfitDetailPythonItem.java b/src/main/java/com/ai/da/python/vo/OutfitDetailPythonItem.java index 92c1f7e8..34d21617 100644 --- a/src/main/java/com/ai/da/python/vo/OutfitDetailPythonItem.java +++ b/src/main/java/com/ai/da/python/vo/OutfitDetailPythonItem.java @@ -13,7 +13,7 @@ public class OutfitDetailPythonItem { private List image_size; - private Float scale; + private Float[] scale; private String image_url; @@ -22,7 +22,7 @@ public class OutfitDetailPythonItem { public OutfitDetailPythonItem() { } - public OutfitDetailPythonItem(String image_category, List position, List image_size, Float scale, String image_url, String mask_url) { + public OutfitDetailPythonItem(String image_category, List position, List image_size, Float[] scale, String image_url, String mask_url) { this.image_category = image_category; this.position = position; this.image_size = image_size; diff --git a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java index 691c4a39..afb5d07e 100644 --- a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java @@ -586,7 +586,8 @@ public class DesignItemServiceImpl extends ServiceImpl { ArrayList imageSize = new ArrayList<>(); for (int i = 0; i < layer.getImageSize().size(); i++) { - imageSize.add((long) (layer.getImageSize().get(i) * layer.getScale())); + // todo check这里的计算是否正确 + imageSize.add((long) (layer.getImageSize().get(i) * layer.getScale()[i])); } layer.setImageSize(imageSize); if (!StringUtil.isNullOrEmpty(layer.getImageUrl())) { diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index 97a0553f..3ac8fe25 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -350,7 +350,7 @@ public class DesignServiceImpl extends ServiceImpl impleme list.add(1L); list.add(1L); item.setOffset(list); - item.setResize_scale(1f); + item.setResize_scale(new Float[]{1.0f,1.0f}); String path = item.getPath(); if (StringUtils.isEmpty(path)) { String bodyPath = item.getBody_path(); @@ -434,7 +434,7 @@ public class DesignServiceImpl extends ServiceImpl impleme list.add(1L); list.add(1L); item.setOffset(list); - item.setResize_scale(1f); + item.setResize_scale(new Float[]{1.0f,1.0f}); String path = item.getPath(); if (StringUtils.isEmpty(path)) { String bodyPath = item.getBody_path(); @@ -631,7 +631,9 @@ public class DesignServiceImpl extends ServiceImpl impleme print.setPath(designItemDetail.getPrintPath()); print.setSingleOrOverall("overall"); print.setPosition("[0.0,0.0]"); - print.setScale(1d); +// print.setScale(1d); + // todo mark 将print默认scale置为0.3 + print.setScale(0.3d); print.setAngle(0.0); print.setPriority(1); print.setCreateDate(LocalDateTime.now()); diff --git a/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java b/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java index a83b84d8..875ed0a5 100644 --- a/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java @@ -61,7 +61,8 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl) JSON.parse(detail.getOffset())); designPythonOutfitVO.setPriority(Math.abs(detail.getPriority())); // designPythonOutfitVO.setOffset(CollectionUtil.isEmpty(offset) ? Arrays.asList(0L, 0L) : offset); @@ -77,6 +78,33 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); From 5ff2bf11d74e72918a319d0f64a5bb2acb308781 Mon Sep 17 00:00:00 2001 From: xupei Date: Mon, 27 May 2024 18:10:20 +0800 Subject: [PATCH 5/5] =?UTF-8?q?alipay=20=E5=AF=86=E9=92=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-3015240422190522-merchant.private.key.txt | 28 ------------------- ...CREATE LIMITED.merchant.aqs.public.key.pem | 9 ------ 2 files changed, 37 deletions(-) delete mode 100644 files/CODE-CREATE LIMITED-3015240422190522-merchant.private.key.txt delete mode 100644 files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem diff --git a/files/CODE-CREATE LIMITED-3015240422190522-merchant.private.key.txt b/files/CODE-CREATE LIMITED-3015240422190522-merchant.private.key.txt deleted file mode 100644 index b8487446..00000000 --- a/files/CODE-CREATE LIMITED-3015240422190522-merchant.private.key.txt +++ /dev/null @@ -1,28 +0,0 @@ ------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 -eWEGruMaqSlGyFG7kyaoQaY1X6ECgYEAwsMGiupkNZ/JU3PZd2X2X+37b8BXcIt7 -itL413GDiLwCNII5pArD7GHYFQzN4GaUCt/VjrRXbTY1xYCk2RA0FyBMsxAGa+eH -9iTSLQvDJpxV/44UY3L9ZFcz4t0WjRcsdqPt30yUBNWiAIGcjtae2tMvtfxKICLQ -sYXAS+ciMbECgYEA4tnerV5pfq/7QSpw0y4Ky5ZcPXDqiwF6E3LH1dlleTlgnpqR -fjAVzp0X/+UCWc4P1PsqmjQU5YnzLMIn7MPkkAFHSEnMQJ+sp2U8rcKHhoG3oVQt -s3FOIlwFuAfHmqtLaXuOvM7wSu9R0weLVpdAf8z2AsCXbWlxH86qT4Y0xeECgYBM -NJkbw8i//qx8vciqYjf7oxeNy1mrTLhjQldhnSXVW5MVTpsVJ60vkb1Fx0PK+PgW -JSzfcIsAzYROqh5WXHO1VMsOCUgp8mcNlayzOXX7ZpJzsvkhTH3/Q+umadGIFTgt -l8jcZY9JMPn5br1+WlW/04BImdW7K0QzId1zFZYYkQKBgQDqswTLEpbBDOE/3uk4 -laZ9kTLJMP/hVmDJ0/jbETMdCkzIORnr3xFxmZIHG17E2In9PVumD0ESCh7qbCDE -isbfLSgfJR6ItdOM6W2R0GAsXQ3e0byBpR7qm0j9J3zYRhQwfVbZtkX0uywB9a/4 -q2bz4491ESrbryx16FZKUJeX8g== ------END PRIVATE KEY----- diff --git a/files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem b/files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem deleted file mode 100644 index 39a68d27..00000000 --- a/files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtV6WdPhCKCb0JBhwHaXK -a9+UvlJ8TXThPtbGbCA1rss1xtHerzrnSE5mBU6lcyUWgAK4cKfjUP0fcqJ7LlLB -HNMdqk57ckmDHnR3yNk0peqk7KqR8pEi6+rtBOE7mFIhrP5397dAP6xL5iiujj+L -zYFJQDYTig8IggHZiZIjgRBycC7DdcZXJwZFEdFq/rmrlaPgNKKZDOx6wWl103Mv -oKaJXfrgoAm0cxQog69LirCyYG9wntWl08GvJNnQ4Ops4RNFOucobDc4wgqoPoPL -XxFYWvTa7JneoRtohR55OKwqkV4Y7iNVddBomVKaTFibRg9rY+2StF1yoebAHJbv -UQIDAQAB ------END PUBLIC KEY-----