Merge branch 'test/stable' into release/3.0

# Conflicts:
#	src/main/java/com/ai/da/service/impl/AccountServiceImpl.java
This commit is contained in:
2024-05-28 10:59:34 +08:00
86 changed files with 1874 additions and 363 deletions

View File

@@ -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-----

View File

@@ -1,9 +0,0 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtV6WdPhCKCb0JBhwHaXK
a9+UvlJ8TXThPtbGbCA1rss1xtHerzrnSE5mBU6lcyUWgAK4cKfjUP0fcqJ7LlLB
HNMdqk57ckmDHnR3yNk0peqk7KqR8pEi6+rtBOE7mFIhrP5397dAP6xL5iiujj+L
zYFJQDYTig8IggHZiZIjgRBycC7DdcZXJwZFEdFq/rmrlaPgNKKZDOx6wWl103Mv
oKaJXfrgoAm0cxQog69LirCyYG9wntWl08GvJNnQ4Ops4RNFOucobDc4wgqoPoPL
XxFYWvTa7JneoRtohR55OKwqkV4Y7iNVddBomVKaTFibRg9rY+2StF1yoebAHJbv
UQIDAQAB
-----END PUBLIC KEY-----

View File

@@ -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-----

View File

@@ -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-----

View File

@@ -233,6 +233,12 @@
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>25.0.0</version>
</dependency>
</dependencies>
<build>

View File

@@ -154,63 +154,63 @@ public class GenerateConsumer {
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer1(Message msg, Channel channel) {
generate(msg, channel, "consumer 1");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer2(Message msg, Channel channel) {
generate(msg, channel, "consumer 2");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer3(Message msg, Channel channel) {
generate(msg, channel, "consumer 3");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer4(Message msg, Channel channel) {
generate(msg, channel, "consumer 4");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer5(Message msg, Channel channel) {
generate(msg, channel, "consumer 5");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer6(Message msg, Channel channel) {
generate(msg, channel, "consumer 6");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer7(Message msg, Channel channel) {
generate(msg, channel, "consumer 7");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer8(Message msg, Channel channel) {
generate(msg, channel, "consumer 8");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer9(Message msg, Channel channel) {
generate(msg, channel, "consumer 9");
}
@RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE)
@RabbitHandler
public void getGenerateResult(Message msg, Channel channel) {
processGenerateResult(msg, channel);
}
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer1(Message msg, Channel channel) {
// generate(msg, channel, "consumer 1");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer2(Message msg, Channel channel) {
// generate(msg, channel, "consumer 2");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer3(Message msg, Channel channel) {
// generate(msg, channel, "consumer 3");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer4(Message msg, Channel channel) {
// generate(msg, channel, "consumer 4");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer5(Message msg, Channel channel) {
// generate(msg, channel, "consumer 5");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer6(Message msg, Channel channel) {
// generate(msg, channel, "consumer 6");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer7(Message msg, Channel channel) {
// generate(msg, channel, "consumer 7");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer8(Message msg, Channel channel) {
// generate(msg, channel, "consumer 8");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer9(Message msg, Channel channel) {
// generate(msg, channel, "consumer 9");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE)
// @RabbitHandler
// public void getGenerateResult(Message msg, Channel channel) {
// processGenerateResult(msg, channel);
// }
}

View File

@@ -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() {
}

View File

@@ -218,17 +218,17 @@ public class SRConsumer {
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
}
@RabbitListener(queues = MQConfig.SR_QUEUE)
@RabbitHandler
public void SRConsumer1(Message msg, Channel channel) {
superResolution(msg, channel, "consumer 1");
}
@RabbitListener(queues = MQConfig.SR_RESULT_QUEUE)
@RabbitHandler
public void SRResultConsumer1(Message msg, Channel channel) {
getSRResult(msg, channel, "consumer 1");
}
// @RabbitListener(queues = MQConfig.SR_QUEUE)
// @RabbitHandler
// public void SRConsumer1(Message msg, Channel channel) {
// superResolution(msg, channel, "consumer 1");
// }
//
//
// @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE)
// @RabbitHandler
// public void SRResultConsumer1(Message msg, Channel channel) {
// getSRResult(msg, channel, "consumer 1");
// }
}

View File

@@ -34,7 +34,7 @@ public class MyTaskScheduler {
// 定时任务,每十五天执行一次
// @Scheduled(cron = "0 0 0 ? * MON")
@Scheduled(cron = "0 0 0 */15 * ?")
// @Scheduled(cron = "0 0 0 */15 * ?")
public void checkExpiry() {
// 检测正式用户是否快要过期
QueryWrapper<Account> qw = new QueryWrapper<>();
@@ -68,7 +68,7 @@ public class MyTaskScheduler {
}
}
}
@Scheduled(cron = "0 0 8 * * ?")
// @Scheduled(cron = "0 0 8 * * ?")
public void sendTrialOrderExcelToManagements() {
// 获取前一天日期
LocalDate yesterday = LocalDate.now().minusDays(1);

View File

@@ -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";
}

View File

@@ -27,7 +27,8 @@ public enum LibraryLevel1TypeEnum {
/**
* 模特
*/
MODELS("Models");
MODELS("Models"),
DESIGN_ELEMENTS("DesignElements");
private String realName;

View File

@@ -19,7 +19,12 @@ public enum PayTypeEnum {
/**
* PayPal
*/
PAYPAL("PayPal");
PAYPAL("PayPal"),
/**
* 香港支付宝
*/
ALIPAY_HK("Alipay-HK");
/**
* 类型

View File

@@ -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

View File

@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
@Slf4j
public class GenerateTask {
@Scheduled(cron = "0 0 */1 * * ?")
// @Scheduled(cron = "0 0 */1 * * ?")
public void generateScheduled(){
log.info("测试定时器generate");

View File

@@ -23,7 +23,7 @@ public class PaypalTask {
@Resource
private PayPalCheckoutService payPalCheckoutService;
@Scheduled(cron = "0/30 * * * * ?")
// @Scheduled(cron = "0/30 * * * * ?")
public void orderConfirm() throws SerializeException {
log.info("PayPal orderConfirm 被执行......");

View File

@@ -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<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
public 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
@@ -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);
}
}
}

View File

@@ -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,29 @@ 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")
// .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();
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);
}
}
}

View File

@@ -16,6 +16,7 @@ import java.io.*;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@@ -126,6 +127,26 @@ public class MinioUtil {
return names;
}
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
String fileName = UUID.randomUUID().toString() + "." + imageType; // or any other image format
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
minioClient.putObject(PutObjectArgs.builder()
.bucket(bucketName)
.object(fileName)
.stream(in, in.available(), -1)
.contentType("image/png") // Set the content type according to your image format
.build()
);
return bucketName + "/" + fileName;
} catch (Exception e) {
e.printStackTrace();
return null; // or throw an exception
}
}
/**
* description: 上传文件
*
@@ -415,6 +436,13 @@ public class MinioUtil {
return false;
}
}
public String base64Upload(String base64, String bucketName){
String[] parts = base64.split(",");
String imageType = parts[0].split("/")[1].split(";")[0];
String base64Data = parts[1];
return uploadImageFromBase64(bucketName, base64Data, imageType);
}
}

View File

@@ -362,7 +362,10 @@ public class SendEmailUtil {
}
private final static Long UPGRADE_NOTIFICATION_ID = 118855L;
public static void sendUpgradeNotification(Account account, String senderAddress) {
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID = 118856L;
private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L;
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE = 122899L;
public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) {
try {
// 实例化一个认证对象
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
@@ -381,8 +384,20 @@ public class SendEmailUtil {
// 根据邮件类型设置不同的主题和模板
String subject = "";
Template template = new Template();
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
// if (type == 1) {
// subject = "Upcoming System Upgrade for AiDA 3.0";
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
// }else {
// subject = "即将到来的AiDA 3.0系统升级";
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
// }
if (type == 1) {
subject = "Successful System Upgrade and New Features in AiDA 3.0";
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
}else {
subject = "系统升级成功和AiDA 3.0新功能";
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
}
template.setTemplateData(buildAccountData(account));
req.setSubject(subject);

View File

@@ -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<String> createOrder(){
return Response.success();
@Resource
private AlipayHKService alipayHKService;
@ApiOperation(value = "创建订单")
@PostMapping(value = "/createOrder")
public Response<String> 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<String, String> params){
return alipayHKService.callback(params);
}
}

View File

@@ -0,0 +1,59 @@
package com.ai.da.controller;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response;
import com.ai.da.model.dto.PortfolioDTO;
import com.ai.da.model.dto.QueryPortfolioPageDTO;
import com.ai.da.model.vo.PortfolioVO;
import com.ai.da.model.vo.UserLikeChooseVO;
import com.ai.da.service.PortfolioService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
@Api(tags = "Portfolio模块")
@Slf4j
@RestController
@RequestMapping("/api/portfolio")
public class PortfolioController {
@Resource
private PortfolioService portfolioService;
@ApiOperation(value = "发布作品集")
@PostMapping("/publish")
public Response<Boolean> preLogin(@Valid @RequestBody PortfolioDTO portfolioDTO) {
return Response.success(portfolioService.publish(portfolioDTO));
}
@ApiOperation(value = "作品集page")
@PostMapping("/page")
public Response<PageBaseResponse<PortfolioVO>> page(@Valid @RequestBody QueryPortfolioPageDTO query) {
return Response.success(portfolioService.page(query));
}
@ApiOperation(value = "作品详情")
@PostMapping("/detail")
public Response<PortfolioVO> detail(@Valid @RequestBody PortfolioDTO portfolioDTO) {
return Response.success(portfolioService.detail(portfolioDTO));
}
@ApiOperation(value = "选择作品")
@PostMapping("/choose")
public Response<UserLikeChooseVO> choose(@Valid @RequestBody PortfolioDTO portfolioDTO) {
return Response.success(portfolioService.choose(portfolioDTO));
}
@ApiOperation(value = "更新作品")
@PostMapping("/update")
public Response<PortfolioVO> update(@Valid @RequestBody PortfolioDTO portfolioDTO) {
return Response.success(portfolioService.update(portfolioDTO));
}
}

View File

@@ -1,10 +1,13 @@
package com.ai.da.controller;
import com.ai.da.common.response.Response;
import com.ai.da.mapper.primary.entity.Style;
import com.ai.da.mapper.primary.entity.Workspace;
import com.ai.da.model.dto.WorkspaceDTO;
import com.ai.da.model.dto.WorkspaceSaveDTO;
import com.ai.da.model.enums.BizJson;
import com.ai.da.model.vo.ModelsVO;
import com.ai.da.model.vo.StyleVO;
import com.ai.da.model.vo.WorkspaceVO;
import com.ai.da.service.WorkspaceService;
import io.swagger.annotations.Api;
@@ -66,8 +69,8 @@ public class WorkspaceController {
@PostMapping("/saveOrUpdate")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "新增或编辑", notes = "传入workspace")
public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) {
return Response.success(workspaceService.saveOrUpdate(workspace));
public Response saveOrUpdate(@Valid @RequestBody WorkspaceSaveDTO workspaceDTO) {
return Response.success(workspaceService.saveOrUpdate(workspaceDTO));
}
@@ -115,10 +118,17 @@ public class WorkspaceController {
}
@PostMapping("maleDataInsert")
@ApiOperationSupport(order = 7)
@ApiOperationSupport(order = 8)
@ApiOperation(value = "男装数据入库入minio")
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
workspaceService.maleDataInsert();
return Response.success(true);
}
@PostMapping("styleList")
@ApiOperationSupport(order = 9)
@ApiOperation(value = "获取style列表")
public Response<List<StyleVO>> styleList() {
return Response.success(workspaceService.styleList());
}
}

View File

@@ -0,0 +1,7 @@
package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.Portfolio;
public interface PortfolioMapper extends CommonMapper<Portfolio> {
}

View File

@@ -0,0 +1,17 @@
package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.Style;
import java.util.List;
/**
* Mapper 接口
*
* @author easy-generator
* @since 2022-06-13
*/
public interface StyleMapper extends CommonMapper<Style> {
}

View File

@@ -0,0 +1,15 @@
package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.WorkspaceRelStyle;
/**
* Mapper 接口
*
* @author easy-generator
* @since 2022-06-13
*/
public interface WorkspaceRelStyleMapper extends CommonMapper<WorkspaceRelStyle> {
}

View File

@@ -75,6 +75,8 @@ public class CollectionElement implements Serializable {
*/
private String md5;
private String gradientString;
/**
* 创建时间
*/

View File

@@ -64,6 +64,8 @@ public class DesignItemDetail implements Serializable {
*/
private String color;
private String gradientString;
/**
* 对应的print图片的绝对路径
*/

View File

@@ -0,0 +1,15 @@
package com.ai.da.mapper.primary.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class Gradient implements Serializable {
private List<GradientItem> gradientList;
private int angle;
private int selectIndex;
private boolean gradientShow;
private String colorImg;
}

View File

@@ -0,0 +1,11 @@
package com.ai.da.mapper.primary.entity;
import lombok.Data;
import java.io.Serializable;
@Data
public class GradientItem implements Serializable {
private RGBA rgba;
private String left;
}

View File

@@ -15,7 +15,7 @@ public class OrderInfo extends BaseEntity{
private Long productId;//支付产品id
private Integer totalFee;//订单金额(元)
private Float totalFee;//订单金额(元)
private String codeUrl;//订单二维码连接

View File

@@ -17,7 +17,7 @@ public class PaymentInfo extends BaseEntity{
private String tradeState;//交易状态
private Integer payerTotal;//支付金额()
private Long payerTotal;//支付金额()
private String content;//通知参数
}

View File

@@ -0,0 +1,55 @@
package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@ApiModel(value = "Portfolio对象", description = "作品集")
@TableName("portfolio")
public class Portfolio implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "collection ID")
private Long collectionId;
@ApiModelProperty(value = "userLikeGroup源")
private Long userLikeGroupSourceId;
@ApiModelProperty(value = "作品名称")
private String portfolioName;
@ApiModelProperty(value = "作品描述")
private String portfolioDes;
@ApiModelProperty(value = "作品类型")
private String portfolioType;
@ApiModelProperty(value = "封面ID")
private Long coverId;
@ApiModelProperty(value = "作品状态1公开0隐藏")
private Integer status;
@ApiModelProperty(value = "作品集作者ID")
private Long accountId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createDate;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateDate;
@ApiModelProperty(value = "是否删除")
private Integer isDeleted;
}

View File

@@ -9,7 +9,8 @@ public class Product extends BaseEntity{
private String title; //商品名称
private Integer price; //价格(分)
// private Integer price; //价格(分)
private Float price; //价格(元)
private Integer credits; // 积分
}

View File

@@ -0,0 +1,13 @@
package com.ai.da.mapper.primary.entity;
import lombok.Data;
import java.io.Serializable;
@Data
public class RGBA implements Serializable {
private int r;
private int g;
private int b;
private double a;
}

View File

@@ -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;//退款原因

View File

@@ -0,0 +1,17 @@
package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("style")
public class Style implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String name;
}

View File

@@ -0,0 +1,18 @@
package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("workspace_rel_style")
public class WorkspaceRelStyle implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long workspaceId;
private Long styleId;
}

View File

@@ -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;
}

View File

@@ -1,5 +1,6 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.Gradient;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -25,4 +26,10 @@ public class CollectionColorDTO {
@ApiModelProperty("潘通RGB值")
private String rgbValue;
private Gradient gradient;
private String gradientString;
private String gradientMinioUrl;
}

View File

@@ -1,5 +1,6 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.Gradient;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

View File

@@ -5,10 +5,11 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@Data
public class DesignSingleIncludeLayersDTO {
public class DesignSingleIncludeLayersDTO implements Serializable {
@ApiModelProperty("designItemId")
@NotNull(message = "designItemId.cannot.be.empty")

View File

@@ -1,15 +1,17 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.Gradient;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@Data
public class DesignSingleItemDTO {
public class DesignSingleItemDTO implements Serializable {
@NotNull(message = "id.cannot.be.empty")
@ApiModelProperty("切换图片对应的id")
@@ -42,15 +44,13 @@ public class DesignSingleItemDTO {
private List<Long> offset;
@ApiModelProperty("图层缩放比例")
private Float scale;
private Float[] scale;
@NotNull(message = "priority.cannot.be.empty")
@ApiModelProperty("图层优先级")
private Integer priority;
// @ApiModelProperty("渐变 起始/目标 颜色")
// private List<List<Integer>> gradient;
//
// @ApiModelProperty("渐变角度")
// private Float gradient_angle;
@ApiModelProperty("渐变 颜色")
private Gradient gradient;
}

View File

@@ -5,11 +5,12 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("design single 印花请求信息")
public class DesignSinglePrintDTO {
public class DesignSinglePrintDTO implements Serializable {
// @ApiModelProperty("印花url")
// private String path;

View File

@@ -0,0 +1,10 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.Portfolio;
import lombok.Data;
@Data
public class PortfolioDTO extends Portfolio {
private Long userLikeGroupId;
}

View File

@@ -0,0 +1,14 @@
package com.ai.da.model.dto;
import com.ai.da.model.vo.PageQueryBaseVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("作品集分页查询")
public class QueryPortfolioPageDTO extends PageQueryBaseVo {
}

View File

@@ -0,0 +1,22 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.Workspace;
import com.ai.da.model.vo.PageQueryBaseVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 数据传输对象实体类
*
* @author SHAHAIBO
* @since 2023-08-01
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WorkspaceSaveDTO extends Workspace {
private static final long serialVersionUID = 1L;
private Long styleId;
}

View File

@@ -0,0 +1,48 @@
package com.ai.da.model.enums;
import com.fasterxml.jackson.annotation.JsonValue;
public enum DesignElementsEnum {
EMBROIDERY("刺绣", "Embroidery"),
BEADING("钉珠", "Beading"),
PEARL("珍珠", "Pearl"),
RIVET("铆钉", "Rivet"),
BUTTON("纽扣", "Button"),
BELT("腰带", "Belt"),
CORSAGE("胸花", "Corsage"),
ZIPPER("拉链", "Zipper"),
POCKET("口袋", "Pocket");
private final String chinese;
private final String english;
// 构造函数
DesignElementsEnum(String chinese, String english) {
this.chinese = chinese;
this.english = english;
}
// 获取中文描述
public String getChinese() {
return chinese;
}
// 获取英文描述
public String getEnglish() {
return english;
}
// 重写toString方法返回格式化的描述
@Override
public String toString() {
return chinese + " (" + english + ")";
}
public static DesignElementsEnum fromName(String name) {
for (DesignElementsEnum designElement : DesignElementsEnum.values()) {
if (designElement.name().equals(name)) {
return designElement;
}
}
throw new IllegalArgumentException("No enum constant for name: " + name);
}
}

View File

@@ -8,6 +8,7 @@ import lombok.Getter;
* @Date: 2023/10/31 14:16
* @Description: 语言
*/
@Getter
public enum Language implements IEnumDisplay {
ENGLISH("en", "US"), // 英文
@@ -29,7 +30,7 @@ public enum Language implements IEnumDisplay {
ITALIAN("it", "IT"); // 意大利语
private String languageCode;
@Getter
private String countryCode;
Language(String languageCode, String countryCode) {

View File

@@ -0,0 +1,42 @@
package com.ai.da.model.enums;
public enum PrintboardLevel2TypeEnum {
SLOGAN("标语", "Slogan"),
LOGO("标志", "Logo"),
PATTERN("图案", "Pattern");
private final String chinese;
private final String english;
// 构造函数
PrintboardLevel2TypeEnum(String chinese, String english) {
this.chinese = chinese;
this.english = english;
}
// 获取中文描述
public String getChinese() {
return chinese;
}
// 获取英文描述
public String getEnglish() {
return english;
}
// 重写toString方法返回格式化的描述
@Override
public String toString() {
return chinese + " (" + english + ")";
}
// 根据名称获取枚举值
public static PrintboardLevel2TypeEnum fromName(String name) {
for (PrintboardLevel2TypeEnum designElement : PrintboardLevel2TypeEnum.values()) {
if (designElement.name().equals(name)) {
return designElement;
}
}
throw new IllegalArgumentException("No enum constant for name: " + name);
}
}

View File

@@ -0,0 +1,57 @@
package com.ai.da.model.enums;
import lombok.Data;
import lombok.Getter;
@Getter
public enum StyleEnum {
// 定义风格及其对应的中英文描述
NEO_CHINESE("新中式", "Neo Chinese"),
COUNTRY_STYLE("田园风", "Country Style"),
FUTURISM("未来主义", "Futurism"),
MINIMALISM("极简风", "Minimalism"),
LOLITA("洛丽塔", "Lolita"),
Y2K("Y2K", "Y2K"),
BUSINESS("商务风", "Business"),
MERLAD("美拉德", "Merlad"),
OUTDOOR_FUNCTIONAL("户外机能", "Outdoor Functional"),
ROCK("摇滚", "Rock"),
DOPAMINE("多巴胺", "Dopamine"),
GOTHIC("哥特风", "Gothic"),
POST_APOCALYPTIC("废土", "Post-apocalyptic"),
ROMANTIC("浪漫", "Romantic"),
WABI_SABI("侘寂", "Wabi-sabi");
private final String chinese;
private final String english;
// 构造函数
StyleEnum(String chinese, String english) {
this.chinese = chinese;
this.english = english;
}
// 获取中文描述
public String getChinese() {
return chinese;
}
// 获取英文描述
public String getEnglish() {
return english;
}
// 重写toString方法返回格式化的描述
@Override
public String toString() {
return chinese + " (" + english + ")";
}
public static StyleEnum fromName(String name) {
for (StyleEnum style : StyleEnum.values()) {
if (style.name().equals(name)) {
return style;
}
}
throw new IllegalArgumentException("No enum constant for name: " + name);
}
}

View File

@@ -1,5 +1,6 @@
package com.ai.da.model.vo;
import com.ai.da.mapper.primary.entity.Gradient;
import com.ai.da.model.dto.DesignSinglePrintDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -51,6 +52,9 @@ public class DesignItemClothesDetailVO {
@ApiModelProperty("衣服所在图层")
private Integer priority;
@ApiModelProperty("渐变色信息")
private Gradient gradient;
public DesignItemClothesDetailVO() {
}

View File

@@ -23,7 +23,7 @@ public class DesignPythonOutfitVO {
private String imageCategory;
/**
* 图层大小
* 图层大小(前后片大小)
*/
@ApiModelProperty(value = "图层大小")
private List<Long> 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开始优先级数字越大越靠近上层
*/

View File

@@ -6,11 +6,12 @@ import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("design single 印花详情")
public class DesignSinglePrint {
public class DesignSinglePrint implements Serializable {
@ApiModelProperty("印花是用户上传的还是从library中选的 collection/library")
private String designType;

View File

@@ -0,0 +1,16 @@
package com.ai.da.model.vo;
import com.ai.da.mapper.primary.entity.CollectionElement;
import com.ai.da.mapper.primary.entity.Portfolio;
import com.ai.da.mapper.primary.entity.TDesignPythonOutfit;
import lombok.Data;
import java.util.List;
@Data
public class PortfolioVO extends Portfolio {
private String designPythonOutfitUrl;
private List<CollectionElement> collectionElementList;
private List<TDesignPythonOutfit> designPythonOutfitList;
}

View File

@@ -0,0 +1,16 @@
package com.ai.da.model.vo;
import com.ai.da.mapper.primary.entity.Style;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
public class StyleVO extends Style {
private static final long serialVersionUID = 1L;
private String value;
}

View File

@@ -33,4 +33,6 @@ public class WorkspaceVO extends Workspace {
private BizJson positionEnum;
private String styleName;
}

View File

@@ -31,6 +31,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Value;
@@ -67,10 +68,15 @@ public class PythonService {
private String accessPythonPort;
@Value("${access.python.sr}")
private String srPythonPort;
@Value("${minio.bucketName.gradient}")
private String gradientBucketName;
@Resource
private PythonTAllInfoService pythonTAllInfoService;
@Resource
private MinioUtil minioUtil;
/**
* 生成打印的图片 二合一 (废弃于2024/01/02)
*
@@ -1548,7 +1554,10 @@ public class PythonService {
pythonItem.setPath(sysFileVO.getUrl());
pythonItem.setBusinessId(sysFileVO.getId());
if (SysFileLevel2TypeEnum.SHOES.getRealName().equals(type)) {
pythonItem.setColor(getRandomColor(elementVO.getColorBoards()));
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
pythonItem.setColor(randomColor.getRgbValue());
pythonItem.setGradient(randomColor.getGradientMinioUrl());
pythonItem.setGradientString(randomColor.getGradientString());
}
}
}
@@ -1911,7 +1920,10 @@ public class PythonService {
designPythonItemBlouse.setPath(path);
//所有的icon都是none
designPythonItemBlouse.setIcon("none");
designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards()));
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
designPythonItemBlouse.setColor(randomColor.getRgbValue());
designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
designPythonItemBlouse.setGradientString(randomColor.getGradientString());
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) {
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
@@ -1937,7 +1949,10 @@ public class PythonService {
designPythonItemBlouse.setPath(collectionElement.getUrl());
//所有的icon都是none
designPythonItemBlouse.setIcon("none");
designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards()));
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
designPythonItemBlouse.setColor(randomColor.getRgbValue());
designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
designPythonItemBlouse.setGradientString(randomColor.getGradientString());
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) {
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
@@ -2216,14 +2231,14 @@ public class PythonService {
return sysFileVo.get(key.intValue());
}
private String getRandomColor(List<CollectionColorDTO> colorBoards) {
private CollectionColorDTO getRandomColor(List<CollectionColorDTO> colorBoards) {
if (colorBoards.size() == 1) {
return colorBoards.get(0).getRgbValue();
return colorBoards.get(0);
}
long maxColor = colorBoards.size();
long minColor = 0;
Long randomIndex = RandomsUtil.randomSysFile(minColor, maxColor);
return colorBoards.get(randomIndex.intValue()).getRgbValue();
return colorBoards.get(randomIndex.intValue());
}
private CollectionElement getRandomSketchLibrary(List<CollectionElement> sketchBoardElementOlds, List<String> hasUseMd5List) {
@@ -2602,6 +2617,22 @@ public class PythonService {
}else {
businessId = designSingleItem.getId();
}
// 判断是否是渐变色
String minioPath = null;
String gradientString = null;
if (!Objects.isNull(designSingleItem.getGradient())){
String colorImg = designSingleItem.getGradient().getColorImg();
if (StringUtil.isNullOrEmpty(colorImg)){
throw new BusinessException("The base64 data of the image is empty");
}
minioPath = minioUtil.base64Upload(colorImg, gradientBucketName);
designSingleItem.getGradient().setColorImg(null);
gradientString = JSONObject.toJSONString(designSingleItem.getGradient());
// todo 当渐变色不为空时,是否需要将颜色置为 0 0 0
}
response.add(new DesignPythonItem(
designSingleItem.getType(),
designSingleItem.getPath(),
@@ -2613,7 +2644,9 @@ public class PythonService {
pythonTAllInfoService.getImageIdByPath(designSingleItem.getPath()),
designSingleItem.getOffset(),
designSingleItem.getScale(),
designSingleItem.getPriority()));
designSingleItem.getPriority(),
minioPath,
gradientString));
});

View File

@@ -28,6 +28,10 @@ public class DesignPythonItem {
*/
private String color;
private String gradient;
private String gradientString;
/**
* 对应的print图片的绝对路径
*/
@@ -68,19 +72,12 @@ public class DesignPythonItem {
/**
* 图层缩放大小
*/
private Float resize_scale;
private Float[] resize_scale;
/**
* 图层优先级
*/
private Integer priority;
/**
* 渐变图片的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());
@@ -116,7 +113,8 @@ public class DesignPythonItem {
this.image_id = image_id;
}
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List<Long> offset, Float resize_scale,Integer priority) {
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId,
Long image_id, List<Long> offset, Float[] resize_scale, Integer priority, String gradient, String gradientString) {
this.type = type;
this.path = path;
this.color = color;
@@ -127,23 +125,10 @@ public class DesignPythonItem {
this.offset = offset;
this.resize_scale = resize_scale;
this.priority = priority;
this.gradient = gradient;
this.gradientString = gradientString;
}
// 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;
this.path = path;

View File

@@ -13,7 +13,7 @@ public class OutfitDetailPythonItem {
private List<Long> 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<Long> position, List<Long> image_size, Float scale, String image_url, String mask_url) {
public OutfitDetailPythonItem(String image_category, List<Long> position, List<Long> image_size, Float[] scale, String image_url, String mask_url) {
this.image_category = image_category;
this.position = position;
this.image_size = image_size;

View File

@@ -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<String, String> params);
void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO);
}

View File

@@ -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<String, String> params);
void createPaymentInfoForPayPal(Order order);
void createPaymentInfoForAliPayHK(AlipayHKCallbackDTO alipayHKCallbackDTO);
}

View File

@@ -0,0 +1,21 @@
package com.ai.da.service;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.mapper.primary.entity.Portfolio;
import com.ai.da.model.dto.PortfolioDTO;
import com.ai.da.model.dto.QueryPortfolioPageDTO;
import com.ai.da.model.vo.PortfolioVO;
import com.ai.da.model.vo.UserLikeChooseVO;
import com.baomidou.mybatisplus.extension.service.IService;
public interface PortfolioService extends IService<Portfolio> {
Boolean publish(PortfolioDTO portfolioDTO);
PortfolioVO update(PortfolioDTO portfolioDTO);
PageBaseResponse<PortfolioVO> page(QueryPortfolioPageDTO query);
PortfolioVO detail(PortfolioDTO portfolioDTO);
UserLikeChooseVO choose(PortfolioDTO portfolioDTO);
}

View File

@@ -23,4 +23,6 @@ public interface UserLikeService extends IService<UserLike> {
UserLike getByDesignItemId(Long designItemId);
void updateDate(Long designItemId,String timeZone);
List<UserLike> getUserLikeList(Long id);
}

View File

@@ -1,10 +1,13 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.Style;
import com.ai.da.mapper.primary.entity.Workspace;
import com.ai.da.model.dto.WorkspaceDTO;
import com.ai.da.model.dto.WorkspaceSaveDTO;
import com.ai.da.model.enums.BizJson;
import com.ai.da.model.vo.ModelsVO;
import com.ai.da.model.vo.StyleVO;
import com.ai.da.model.vo.WorkspaceVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -29,7 +32,7 @@ public interface WorkspaceService extends IService<Workspace> {
*/
IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace);
boolean saveOrUpdate(Workspace workspace);
boolean saveOrUpdate(WorkspaceSaveDTO workspaceDTO);
WorkspaceVO getPage(WorkspaceDTO query);
@@ -46,4 +49,8 @@ public interface WorkspaceService extends IService<Workspace> {
void maleDataInsert() throws FileNotFoundException;
List<Long> delete(List<Workspace> workspaceList);
Workspace getCurrentWorkspace();
List<StyleVO> styleList();
}

View File

@@ -519,6 +519,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
account.setIsTrial(1);
account.setIsBeginner(1);
account.setValidStartTime(System.currentTimeMillis());
if (link) {
account.setValidEndTime(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli());
}else {
@@ -904,15 +905,23 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Override
public void upgradeNotification() {
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("id", 88L);
queryWrapper.and(wrapper ->
wrapper.gt("valid_end_time", 1709515797000L)
wrapper.gt("valid_end_time", 1715817600000L)
.or().isNull("valid_end_time"))
.isNotNull("user_email");
List<Account> accountList = accountMapper.selectList(queryWrapper);
System.out.println(accountList);
for (Account account : accountList) {
SendEmailUtil.sendUpgradeNotification(account, null);
// SendEmailUtil.sendUpgradeNotification(account, null, 0);
// SendEmailUtil.sendUpgradeNotification(account, null, 1);
if (account.getLanguage().equals(Language.CHINESE_SIMPLIFIED.name())) {
SendEmailUtil.sendUpgradeNotification(account, null, 0);
}else {
// 英文
SendEmailUtil.sendUpgradeNotification(account, null, 1);
}
}
}

View File

@@ -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());

View File

@@ -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.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
@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<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");
try{
HashMap<String, Object> param = new HashMap<>();
String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
param.put("order_ref", orderRef);
param.put("amount", Float.parseFloat(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<String, String> 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(!Objects.equals(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];
}
}

View File

@@ -13,6 +13,8 @@ import com.ai.da.mapper.primary.ClassificationRelLibraryMapper;
import com.ai.da.mapper.primary.entity.Classification;
import com.ai.da.mapper.primary.entity.ClassificationRelLibrary;
import com.ai.da.model.dto.ClassificationDTO;
import com.ai.da.model.enums.DesignElementsEnum;
import com.ai.da.model.enums.Language;
import com.ai.da.model.vo.AuthPrincipalVo;
import com.ai.da.model.vo.ClassificationVO;
import com.ai.da.service.ClassificationService;
@@ -106,7 +108,19 @@ public class ClassificationServiceImpl implements ClassificationService {
List<Classification> classificationList = classificationMapper.selectList(qw);
if (CollectionUtil.isNotEmpty(classificationList)) {
// 获取结果集
return getClassificationVOList(classificationList);
List<ClassificationVO> classificationVOList = getClassificationVOList(classificationList);
if (classificationDTO.getType().equals("DesignElements")) {
for (ClassificationVO classificationVO : classificationVOList) {
String classificationName = classificationVO.getClassificationName();
DesignElementsEnum designElementsEnum = DesignElementsEnum.fromName(classificationName);
if (userHolder.getLanguage().equals(Language.ENGLISH.name())) {
classificationVO.setClassificationName(designElementsEnum.getEnglish());
}else {
classificationVO.setClassificationName(designElementsEnum.getChinese());
}
}
}
return classificationVOList;
}
return new ArrayList<>();
}

View File

@@ -35,6 +35,7 @@ import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -76,6 +77,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Value("${minio.bucketName.collectionElement}")
private String collectionElement;
@Value("${minio.bucketName.gradient}")
private String gradientBucketName;
@Transactional
@Override
@@ -348,7 +351,20 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Override
public ValidateElementVO validateElement(DesignCollectionDTO designDTO) {
ValidateElementVO elementVO = CopyUtil.copyObject(designDTO, ValidateElementVO.class);
List<CollectionColorDTO> colorBoards = elementVO.getColorBoards();
for (CollectionColorDTO colorBoard : colorBoards) {
if (Objects.nonNull(colorBoard.getGradient())) {
String colorImg = colorBoard.getGradient().getColorImg();
String[] parts = colorImg.split(",");
String imageType = parts[0].split("/")[1].split(";")[0];
String base64Data = parts[1];
String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType);
colorBoard.setGradientMinioUrl(gradientMinioUrl);
colorBoard.getGradient().setColorImg(null);
colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient()));
}
}
elementVO.setColorBoards(colorBoards);
List<Long> usedElementIds = elementVO.getUsedElementIds();
List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements();
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements();
@@ -767,7 +783,10 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
element.setColorRgb(color.getRgbValue());
//按时区计算
element.setCreateDate(DateUtil.getByTimeZone(timeZone));
if (Objects.nonNull(color.getGradient())) {
color.getGradient().setColorImg(null);
}
element.setGradientString(JSON.toJSONString(color.getGradient()));
elements.add(element);
});
return elements;

View File

@@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -309,7 +310,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}
private List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects
, Long designId, Long designItemId, AuthPrincipalVo userInfo
, Long designId, Long designItemId, Long userId
, JSONObject outfit, String timeZone, List<DesignSingleItemDTO> designSingleItemDTOList) {
DesignItem designItem = new DesignItem();
@@ -328,7 +329,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
return;
}
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail, DesignItemDetail.class);
designItemDetail.setAccountId(userInfo.getId());
designItemDetail.setAccountId(userId);
designItemDetail.setDesignId(designId);
designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId());
@@ -367,12 +368,9 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 7、将新生成的图层信息存入designPythonOutfitDetail表
JSONArray layers = outfit.getJSONArray("layers");
// 需要将request中的offset也存入数据库通过priority与image_category将sketch与layers关联
// Map<String, List<Long>> typeOffset = designSingleItemDTOList.stream()
// .collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
Map<Integer, List<Long>> priorityOffset = designSingleItemDTOList.stream()
.collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset));
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId(), priorityOffset);
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userId, priorityOffset);
designPythonOutfitDetailService.saveBatch(list);
@@ -418,9 +416,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
@Override
@Transactional(rollbackFor = Exception.class)
public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
log.info("designSingle request入参 ==> " + designSingleIncludeLayersDTO.toString());
// 记录入参 base64数据太长所以这里去掉
DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO);
clone.getDesignSingleItemDTOList().forEach( i -> {
if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())){
i.getGradient().setColorImg(null);
}
});
AuthPrincipalVo userInfo = UserContext.getUserHolder();
log.info("designSingle request入参 ==> " + JSONObject.toJSONString(clone));
Long userId = UserContext.getUserHolder().getId();
DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId());
if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found");
@@ -477,8 +483,6 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}
JSONObject outfit = data.getJSONObject("0");
// 通过priority将offset关联到layers
// Map<String, List<Long>> typeOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
// .collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
Map<Integer, List<Long>> priorityOffset = new HashMap<>();
try{
priorityOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
@@ -492,12 +496,12 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (!designSingleIncludeLayersDTO.getIsPreview()) {
// 更新及保存图层信息
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(),
userInfo, outfit, designSingleIncludeLayersDTO.getTimeZone(), designSingleIncludeLayersDTO.getDesignSingleItemDTOList());
userId, outfit, designSingleIncludeLayersDTO.getTimeZone(), designSingleIncludeLayersDTO.getDesignSingleItemDTOList());
saveCollectionElement(designSingleIncludeLayersDTO);
} else {
JSONArray layers = outfit.getJSONArray("layers");
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers, designItem.getDesignId(), null, userInfo.getId(), priorityOffset);
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers, designItem.getDesignId(), null, userId, priorityOffset);
}
List<DesignPythonOutfitVO> detailsVO = new ArrayList<>();
@@ -582,7 +586,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemLayer.getLayers().forEach(layer -> {
ArrayList<Long> 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())) {
@@ -644,6 +649,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
layers -> (singleItem.getType().toLowerCase().equals(layers.getImageCategory().split("_")[0])
&& (flag ? Boolean.TRUE : singleItem.getPriority().equals(layers.getPriority())))
).collect(Collectors.toList()));
designItemClothesDetailVO.setGradient(singleItem.getGradient());
body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList()));
clothes.add(designItemClothesDetailVO);

View File

@@ -350,7 +350,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> 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<DesignMapper, Design> 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<DesignMapper, Design> 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());
@@ -996,6 +998,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60));
d.setMinIOPath(o.getPath());
d.setLevel1Type(converTypeToLevel1(o.getType()));
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));
// 根据designItemDetailId获取印花
List<DesignItemDetailPrint> prints = designItemDetailPrintService.getByDesignItemDetailId(o.getId());
// 判断有无印花
@@ -1003,13 +1006,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// 有印花
d.setPrintObject(convertToDesignSinglePrintDTO(prints));
}
// String printJson = o.getPrintJson();
// if (StringUtils.isEmpty(printJson)) {
// d.setPrintObject(new DesignPythonItemPrint(o.getPrintPath(),
// CollectionLevel1TypeEnum.PRINT_BOARD.getRealName(), 0.3f, Boolean.FALSE));
// } else {
// d.setPrintObject(JSON.parseObject(printJson, DesignPythonItemPrint.class));
// }
}));
//single 和 Models(模特)时候 系统元素为空
List<DesignItemDetail> filterDetail2 = designItemDetails.stream()

View File

@@ -259,7 +259,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> 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<GenerateMapper, Generate> 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;

View File

@@ -130,10 +130,10 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
queryWrapper.eq("level2_type", query.getModelSex());
}
if (!StringUtils.isEmpty(query.getLevel2Type())) {
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(query.getLevel2Type());
if (Objects.isNull(level2TypeEnum)) {
throw new BusinessException("unknown.parameter.level2Type");
}
// CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(query.getLevel2Type());
// if (Objects.isNull(level2TypeEnum)) {
// throw new BusinessException("unknown.parameter.level2Type");
// }
queryWrapper.eq("level2_type", query.getLevel2Type());
}
if (!StringUtils.isEmpty(query.getType())) {
@@ -228,13 +228,13 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
if (Objects.isNull(level1TypeEnum)) {
throw new BusinessException("unknown.parameter.level1Type");
}
if (!StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())) {
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(libraryUploadDTO.getLevel2Type());
if (Objects.isNull(level2TypeEnum)) {
throw new BusinessException("unknown.parameter.level2Type");
}
}
if (level1TypeEnum.equals(LibraryLevel1TypeEnum.SKETCH_BOARD) && StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())) {
// if (!StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())) {
// CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(libraryUploadDTO.getLevel2Type());
// if (Objects.isNull(level2TypeEnum)) {
// throw new BusinessException("unknown.parameter.level2Type");
// }
// }
if ((level1TypeEnum.equals(LibraryLevel1TypeEnum.SKETCH_BOARD) || level1TypeEnum.equals(LibraryLevel1TypeEnum.PRINT_BOARD) || level1TypeEnum.equals(LibraryLevel1TypeEnum.DESIGN_ELEMENTS)) && StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())) {
throw new BusinessException("level2Type.cannot.be.empty");
}
String path = calculateFileUrl(level1TypeEnum, libraryUploadDTO.getLevel2Type(), libraryUploadDTO.getModelSex(), userInfo.getId());
@@ -244,6 +244,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
case MOOD_BOARD:
case PRINT_BOARD:
case SKETCH_BOARD:
case DESIGN_ELEMENTS:
bucketName = users;
break;
case MARKETING_SKETCH:

View File

@@ -54,7 +54,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
orderInfo.setTitle("积分购买 X" + amount );
orderInfo.setOrderNo(OrderNoUtils.getOrderNo()); //订单号 ??
// orderInfo.setProductId(amount);
orderInfo.setTotalFee(Integer.parseInt(CreditsEventsEnum.PRICE.getValue()) * amount); // 元 HKD
// orderInfo.setTotalFee(Integer.parseInt(CreditsEventsEnum.PRICE.getValue()) * amount); // 元 HKD
orderInfo.setTotalFee(Float.parseFloat(CreditsEventsEnum.PRICE.getValue()) * amount); // 元 HKD
orderInfo.setOrderStatus(OrderStatusEnum.NOT_PAY.getType()); //未支付
orderInfo.setPaymentType(paymentType);
baseMapper.insert(orderInfo);

View File

@@ -486,7 +486,8 @@ public class PayPalCheckoutServiceImpl implements PayPalCheckoutService {
// 更新积分状态
OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(orderId);
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())));
log.info("退款成功");
result = Boolean.TRUE;
} else {
@@ -591,7 +592,7 @@ public class PayPalCheckoutServiceImpl implements PayPalCheckoutService {
CreditsEventsEnum.BUY_CREDITS.getValue(),
"positive");
// 更新积分
creditsService.buyCredits(orderInfo.getAccountId(), orderInfo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
creditsService.buyCredits(orderInfo.getAccountId(), (int)(orderInfo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue())));
}
}
@@ -633,7 +634,8 @@ public class PayPalCheckoutServiceImpl implements PayPalCheckoutService {
CreditsEventsEnum.BUY_CREDITS.getValue(),
"positive");
// 更新积分
creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
// creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
creditsService.buyCredits(orderByOrderNo.getAccountId(),(int)(orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue())));
}
}

View File

@@ -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<PaymentInfoMapper, Payme
paymentInfo.setTransactionId(transactionId);
paymentInfo.setTradeType(tradeType);
paymentInfo.setTradeState(tradeState);
paymentInfo.setPayerTotal(payerTotal);
// 原来的单位是:分 Int 现改为:元 Long
paymentInfo.setPayerTotal(payerTotal / 100L);
paymentInfo.setContent(plainText);
baseMapper.insert(paymentInfo);
@@ -80,7 +82,8 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
paymentInfo.setTransactionId(transactionId);
paymentInfo.setTradeType("电脑网站支付");
paymentInfo.setTradeState(tradeStatus);
paymentInfo.setPayerTotal(totalAmountInt);
// 原来的单位是分 Int 现改为元 Long
paymentInfo.setPayerTotal(totalAmountInt / 100L);
Gson gson = new Gson();
String json = gson.toJson(params, HashMap.class);
@@ -95,7 +98,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
log.info("记录支付日志");
// int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
int totalAmountInt = new BigDecimal(order.purchaseUnits().get(0).payments().captures().get(0).amount().value()).intValue();
Long totalAmountInt = new BigDecimal(order.purchaseUnits().get(0).payments().captures().get(0).amount().value()).longValue();
PaymentInfo paymentInfo = new PaymentInfo();
paymentInfo.setOrderNo(order.id());
@@ -103,6 +106,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
paymentInfo.setTransactionId(order.id());
paymentInfo.setTradeType("电脑网站支付");
paymentInfo.setTradeState(order.status());
// todo 确认这里的数据单位是不是元
paymentInfo.setPayerTotal(totalAmountInt);
Gson gson = new Gson();
@@ -111,4 +115,35 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
baseMapper.insert(paymentInfo);
}
@Override
public void createPaymentInfoForAliPayHK(AlipayHKCallbackDTO alipayHKCallbackDTO) {
log.info("记录支付日志");
//获取订单号
String orderNo = alipayHKCallbackDTO.getOut_trade_no();
//业务编号
String transactionId = alipayHKCallbackDTO.getTransaction_id();
//交易状态
String tradeStatus = alipayHKCallbackDTO.getStatus();
//交易金额
String totalAmount = alipayHKCallbackDTO.getAmount().toString();
// int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
Long totalAmountInt = new BigDecimal(totalAmount).longValue();
PaymentInfo paymentInfo = new PaymentInfo();
paymentInfo.setOrderNo(orderNo);
paymentInfo.setPaymentType(PayTypeEnum.ALIPAY_HK.getType());
paymentInfo.setTransactionId(transactionId);
paymentInfo.setTradeType("电脑网站支付");
paymentInfo.setTradeState(tradeStatus);
paymentInfo.setPayerTotal(totalAmountInt);
Gson gson = new Gson();
String json = gson.toJson(alipayHKCallbackDTO);
paymentInfo.setContent(json);
baseMapper.insert(paymentInfo);
}
}

View File

@@ -0,0 +1,474 @@
package com.ai.da.service.impl;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response;
import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.PortfolioDTO;
import com.ai.da.model.dto.QueryPortfolioPageDTO;
import com.ai.da.model.enums.Position;
import com.ai.da.model.enums.Sex;
import com.ai.da.model.vo.*;
import com.ai.da.service.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
@Resource
private UserLikeGroupMapper userLikeGroupMapper;
@Resource
private CollectionMapper collectionMapper;
@Resource
private CollectionElementService collectionElementService;
@Resource
private CollectionElementMapper collectionElementMapper;
@Resource
private TCollectionElementRelationMapper collectionElementRelationMapper;
@Resource
private PortfolioMapper portfolioMapper;
@Resource
private UserLikeService userLikeService;
@Resource
private UserLikeMapper userLikeMapper;
@Resource
private TDesignPythonOutfitMapper designPythonOutfitMapper;
@Resource
private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
@Resource
private DesignItemMapper designItemMapper;
@Resource
private DesignItemDetailMapper designItemDetailMapper;
@Resource
private DesignItemDetailPrintMapper designItemDetailPrintMapper;
@Resource
private MinioUtil minioUtil;
@Resource
private WorkspaceService workspaceService;
@Resource
private DesignMapper designMapper;
@Resource
private UserLikeGroupService userLikeGroupService;
@Override
public Boolean publish(PortfolioDTO portfolioDTO) {
if (portfolioDTO.getPortfolioType().equals("History")) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
userLikeGroupNew.setAccountId(-1L);
Long collectionIdOld = userLikeGroup.getCollectionId();
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
collectionOld.setId(null);
collectionMapper.insert(collectionOld);
Long collectionIdNew = collectionOld.getId();
userLikeGroupNew.setCollectionId(collectionIdNew);
userLikeGroupMapper.insert(userLikeGroupNew);
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
for (CollectionElement element : collectionElementListOld) {
element.setCollectionId(collectionIdNew);
element.setId(null);
collectionElementMapper.insert(element);
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
collectionElementRelationNew.setCollectionId(collectionIdNew);
collectionElementRelationNew.setElementId(element.getId());
collectionElementRelationNew.setCreateDate(new Date());
collectionElementRelationMapper.insert(collectionElementRelationNew);
}
Portfolio portfolio = new Portfolio();
Long coverIdOld = portfolioDTO.getCoverId();
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
portfolio.setPortfolioType("History");
portfolio.setCollectionId(collectionIdNew);
portfolio.setAccountId(authPrincipalVo.getId());
portfolio.setCreateDate(LocalDateTime.now());
portfolio.setUpdateDate(LocalDateTime.now());
portfolio.setStatus(1);
portfolio.setIsDeleted(0);
portfolio.setUserLikeGroupSourceId(portfolioDTO.getUserLikeGroupId());
portfolioMapper.insert(portfolio);
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
// List<Long> designPythonOutfitIdList = userLikeList.stream().map(UserLike::getDesignOutfitId).collect(Collectors.toList());
//
// QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
// qw.lambda().in(TDesignPythonOutfit::getId, designPythonOutfitIdList);
// List<TDesignPythonOutfit> designPythonOutfits = designPythonOutfitMapper.selectList(qw);
Long coverIdNew = null;
Boolean flag = false;
for (UserLike userLike : userLikeList) {
Long designOutfitIdOld = userLike.getDesignOutfitId();
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
designPythonOutfit.setDesignId(-1L);
designPythonOutfit.setDesignItemId(-1L);
designPythonOutfit.setCollectionId(collectionIdNew);
if (designPythonOutfit.getId().equals(coverIdOld)) {
flag = true;
}
designPythonOutfit.setId(null);
designPythonOutfitMapper.insert(designPythonOutfit);
Long designOutfitIdNew = designPythonOutfit.getId();
userLike.setDesignOutfitId(designOutfitIdNew);
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
tDesignPythonOutfitDetail.setId(null);
tDesignPythonOutfitDetail.setDesignId(-1L);
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
}
if (flag) {
coverIdNew = designOutfitIdNew;
portfolio.setCoverId(coverIdNew);
portfolioMapper.updateById(portfolio);
flag = false;
}
Long designItemIdOld = userLike.getDesignItemId();
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
designItemOld.setId(null);
designItemOld.setAccountId(-1L);
designItemOld.setDesignId(-1L);
designItemOld.setCollectionId(collectionIdNew);
designItemMapper.insert(designItemOld);
Long designItemIdNew = designItemOld.getDesignId();
designPythonOutfit.setDesignItemId(designItemIdNew);
designPythonOutfitMapper.updateById(designPythonOutfit);
userLike.setDesignItemId(designItemIdNew);
userLike.setId(null);
userLike.setDesignId(-1L);
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
userLikeMapper.insert(userLike);
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld);
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
Long designItemDetailIdOld = designItemDetailOld.getId();
designItemDetailOld.setAccountId(-1L);
designItemDetailOld.setDesignId(-1L);
designItemDetailOld.setDesignItemId(designItemIdNew);
designItemDetailMapper.insert(designItemDetailOld);
Long designItemDetailIdNew = designItemDetailOld.getId();
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
designItemDetailPrintMapper.insert(designItemDetailPrint);
}
}
}else {
}
return Boolean.TRUE;
}
@Override
public PortfolioVO update(PortfolioDTO portfolioDTO) {
if (portfolioDTO.getPortfolioType().equals("History")) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
userLikeGroupNew.setAccountId(-1L);
Long collectionIdOld = userLikeGroup.getCollectionId();
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
collectionOld.setId(null);
collectionMapper.insert(collectionOld);
Long collectionIdNew = collectionOld.getId();
userLikeGroupNew.setCollectionId(collectionIdNew);
userLikeGroupMapper.insert(userLikeGroupNew);
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
for (CollectionElement element : collectionElementListOld) {
element.setCollectionId(collectionIdNew);
element.setId(null);
collectionElementMapper.insert(element);
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
collectionElementRelationNew.setCollectionId(collectionIdNew);
collectionElementRelationNew.setElementId(element.getId());
collectionElementRelationMapper.insert(collectionElementRelationNew);
}
Portfolio portfolio = getPortfolioByUserGroupIdSource(portfolioDTO.getUserLikeGroupId());
Long coverIdOld = portfolioDTO.getCoverId();
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
// portfolio.setPortfolioType("History");
portfolio.setCollectionId(collectionIdNew);
portfolio.setAccountId(authPrincipalVo.getId());
portfolio.setCreateDate(LocalDateTime.now());
portfolio.setUpdateDate(LocalDateTime.now());
portfolio.setStatus(1);
portfolio.setIsDeleted(0);
portfolioMapper.updateById(portfolio);
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
Long coverIdNew = null;
Boolean flag = false;
for (UserLike userLike : userLikeList) {
Long designOutfitIdOld = userLike.getDesignOutfitId();
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
designPythonOutfit.setDesignId(-1L);
designPythonOutfit.setDesignItemId(-1L);
designPythonOutfit.setCollectionId(collectionIdNew);
if (!flag && designPythonOutfit.getId() == coverIdOld) {
flag = true;
}
designPythonOutfit.setId(null);
designPythonOutfitMapper.insert(designPythonOutfit);
Long designOutfitIdNew = designPythonOutfit.getId();
userLike.setDesignOutfitId(designOutfitIdNew);
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
tDesignPythonOutfitDetail.setId(null);
tDesignPythonOutfitDetail.setDesignId(-1L);
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
}
if (flag) {
coverIdNew = designPythonOutfit.getId();
portfolio.setCoverId(coverIdNew);
portfolioMapper.updateById(portfolio);
}
Long designItemIdOld = userLike.getDesignItemId();
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
designItemOld.setId(null);
designItemOld.setAccountId(-1L);
designItemOld.setDesignId(-1L);
designItemOld.setCollectionId(collectionIdNew);
designItemMapper.insert(designItemOld);
Long designItemIdNew = designItemOld.getDesignId();
designPythonOutfit.setDesignItemId(designItemIdNew);
designPythonOutfitMapper.updateById(designPythonOutfit);
userLike.setDesignItemId(designItemIdNew);
userLike.setId(null);
userLike.setDesignId(-1L);
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
userLikeMapper.insert(userLike);
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld);
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
Long designItemDetailIdOld = designItemDetailOld.getId();
designItemDetailOld.setAccountId(-1L);
designItemDetailOld.setDesignId(-1L);
designItemDetailOld.setDesignItemId(designItemIdNew);
designItemDetailMapper.insert(designItemDetailOld);
Long designItemDetailIdNew = designItemDetailOld.getId();
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
designItemDetailPrintMapper.insert(designItemDetailPrint);
}
}
}
return null;
}
private Portfolio getPortfolioByUserGroupIdSource(Long userLikeGroupId) {
QueryWrapper<Portfolio> qw = new QueryWrapper<>();
qw.lambda().eq(Portfolio::getUserLikeGroupSourceId, userLikeGroupId);
return portfolioMapper.selectOne(qw);
}
@Override
public PageBaseResponse<PortfolioVO> page(QueryPortfolioPageDTO query) {
QueryWrapper<Portfolio> qw = new QueryWrapper<>();
qw.lambda().orderByDesc(Portfolio::getUpdateDate);
IPage<Portfolio> page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()),qw);
IPage<PortfolioVO> convert = page.convert((Function<Portfolio, PortfolioVO>) portfolio -> {
if (portfolio != null) {
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(vo.getCoverId());
vo.setDesignPythonOutfitUrl(minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
return vo;
}
return null;
});
return PageBaseResponse.success(convert);
}
@Override
public PortfolioVO detail(PortfolioDTO portfolioDTO) {
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
Long collectionId = portfolio.getCollectionId();
List<CollectionElement> collectionElementList = collectionElementService.getByCollectionId(collectionId);
for (CollectionElement element : collectionElementList) {
if (StringUtils.isEmpty(element.getUrl())) {
continue;
}
element.setUrl(minioUtil.getPresignedUrl(element.getUrl(), 24 * 60));
}
vo.setCollectionElementList(collectionElementList);
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId());
List<TDesignPythonOutfit> designPythonOutfitList = designPythonOutfitMapper.selectList(qw);
for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) {
tDesignPythonOutfit.setDesignUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
}
vo.setDesignPythonOutfitList(designPythonOutfitList);
return vo;
}
@Override
public UserLikeChooseVO choose(PortfolioDTO portfolioDTO) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
userLikeGroupNew.setAccountId(authPrincipalVo.getId());
Long collectionIdOld = userLikeGroup.getCollectionId();
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
collectionOld.setId(null);
collectionMapper.insert(collectionOld);
Long collectionIdNew = collectionOld.getId();
Workspace workspace = workspaceService.getCurrentWorkspace();
Design design = new Design();
design.setCollectionId(collectionIdNew);
design.setAccountId(authPrincipalVo.getId());
if (workspace.getSex().equals(Sex.FEMALE.getValue())) {
design.setTemplateId(workspace.getMannequinFemaleId());
design.setModelType(workspace.getMannequinFemaleType());
}else {
design.setTemplateId(workspace.getMannequinMaleId());
design.setModelType(workspace.getMannequinMaleType());
}
design.setSystemScale(BigDecimal.valueOf(workspace.getSystemDesignerPercentage()));
if (workspace.getPosition().equals(Position.OVERALL.getValue())) {
design.setSingleOverall("overall");
design.setSwitchCategory("");
}else {
design.setSingleOverall("single");
design.setSwitchCategory(workspace.getPosition());
}
design.setCreateDate(new Date());
designMapper.insert(design);
userLikeGroupNew.setCollectionId(collectionIdNew);
userLikeGroupMapper.insert(userLikeGroupNew);
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
for (CollectionElement element : collectionElementListOld) {
element.setCollectionId(collectionIdNew);
element.setId(null);
collectionElementMapper.insert(element);
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
collectionElementRelationNew.setCollectionId(collectionIdNew);
collectionElementRelationNew.setElementId(element.getId());
collectionElementRelationNew.setCreateDate(new Date());
collectionElementRelationMapper.insert(collectionElementRelationNew);
}
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
for (UserLike userLike : userLikeList) {
Long designOutfitIdOld = userLike.getDesignOutfitId();
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
designPythonOutfit.setDesignId(design.getId());
designPythonOutfit.setDesignItemId(-1L);
designPythonOutfit.setCollectionId(collectionIdNew);
designPythonOutfit.setId(null);
designPythonOutfitMapper.insert(designPythonOutfit);
Long designOutfitIdNew = designPythonOutfit.getId();
userLike.setDesignOutfitId(designOutfitIdNew);
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
tDesignPythonOutfitDetail.setId(null);
tDesignPythonOutfitDetail.setDesignId(-1L);
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
}
Long designItemIdOld = userLike.getDesignItemId();
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
designItemOld.setId(null);
designItemOld.setAccountId(-1L);
designItemOld.setDesignId(-1L);
designItemOld.setCollectionId(collectionIdNew);
designItemMapper.insert(designItemOld);
Long designItemIdNew = designItemOld.getDesignId();
designPythonOutfit.setDesignItemId(designItemIdNew);
designPythonOutfitMapper.updateById(designPythonOutfit);
userLike.setDesignItemId(designItemIdNew);
userLike.setId(null);
userLike.setDesignId(design.getId());
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
userLikeMapper.insert(userLike);
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld);
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
Long designItemDetailIdOld = designItemDetailOld.getId();
designItemDetailOld.setAccountId(authPrincipalVo.getId());
designItemDetailOld.setDesignId(design.getId());
designItemDetailOld.setDesignItemId(designItemIdNew);
designItemDetailMapper.insert(designItemDetailOld);
Long designItemDetailIdNew = designItemDetailOld.getId();
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
designItemDetailPrintMapper.insert(designItemDetailPrint);
}
}
return userLikeGroupService.choose(userLikeGroupNew.getId());
}
}

View File

@@ -61,7 +61,8 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl());
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(detail.getMaskUrl(), 24 * 60));
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
// designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
designPythonOutfitVO.setScale(modifyScale(detail.getScale()));
designPythonOutfitVO.setOffset(StringUtil.isNullOrEmpty(detail.getOffset()) ? Arrays.asList(0L, 0L) : (List<Long>) 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<TDesignPyt
return designPythonOutfitVO;
}
private Float[] modifyScale(String scale){
Float[] scaleFloat = new Float[2];
if (!StringUtil.isNullOrEmpty(scale)){
if (scale.startsWith("[")){
// 去除中括号并去掉多余的空格
scale = scale.trim().replaceAll("^\\[|\\]$", "");
// 根据逗号和可选的空格拆分字符串
String[] parts = scale.split("\\s*,\\s*");
// Float[] floatArray = new Float[parts.length];
// 转换每个字符串为 Float 并添加到数组中
for (int i = 0; i < parts.length; i++) {
try {
scaleFloat[i] = Float.parseFloat(parts[i]);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + parts[i]);
return new Float[0]; // 返回一个空数组或者其他错误处理逻辑
}
}
}else {
scaleFloat = new Float[]{Float.parseFloat(scale),Float.parseFloat(scale)};
}
}
return scaleFloat;
}
@Override
public void deleteByDesignPythonOutfitId(Long designPythonOutfitId) {
// QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();

View File

@@ -123,15 +123,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId);
String sex = null;
// if (CollectionUtil.isNotEmpty(userLikeVOS)) {
// Long designId = userLikeVOS.get(0).getDesignId();
// Design design = designMapper.selectById(designId);
// if (design.getModelType().equals(ModelType.SYSTEM.getValue())) {
// sex = sysFileMapper.selectById(design.getTemplateId()).getLevel2Type();
// }else {
// sex = libraryMapper.selectById(design.getTemplateId()).getLevel2Type();
// }
// }
userLikeVOS.forEach(o -> {
TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId());
o.setUrl(tDesignPythonOutfit1.getDesignUrl());

View File

@@ -81,4 +81,11 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
baseMapper.update(null,uw);
}
@Override
public List<UserLike> getUserLikeList(Long id) {
QueryWrapper<UserLike> qw = new QueryWrapper<>();
qw.lambda().eq(UserLike::getUserLikeGroupId, id);
return userLikeMapper.selectList(qw);
}
}

View File

@@ -9,18 +9,12 @@ import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.FileUtil;
import com.ai.da.common.utils.MD5Utils;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.LibraryMapper;
import com.ai.da.mapper.primary.SysFileMapper;
import com.ai.da.mapper.primary.WorkspaceMapper;
import com.ai.da.mapper.primary.entity.Library;
import com.ai.da.mapper.primary.entity.SysFile;
import com.ai.da.mapper.primary.entity.Workspace;
import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.WorkspaceDTO;
import com.ai.da.model.dto.WorkspaceSaveDTO;
import com.ai.da.model.enums.*;
import com.ai.da.model.vo.AuthPrincipalVo;
import com.ai.da.model.vo.ModelVO;
import com.ai.da.model.vo.ModelsVO;
import com.ai.da.model.vo.WorkspaceVO;
import com.ai.da.model.vo.*;
import com.ai.da.service.WorkspaceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -37,11 +31,13 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import javax.naming.Context;
import java.io.*;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -57,6 +53,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
@Resource
private WorkspaceMapper workspaceMapper;
@Resource
private StyleMapper styleMapper;
@Resource
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
@Resource
private LibraryMapper libraryMapper;
@@ -82,7 +84,8 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
private final static Integer SYSTEM_DESIGNER_PERCENTAGE = 30;
@Override
public boolean saveOrUpdate(Workspace workspace) {
public boolean saveOrUpdate(WorkspaceSaveDTO workspaceDTO) {
Workspace workspace = CopyUtil.copyObject(workspaceDTO, Workspace.class);
// 防止前端传值修改标识
workspace.setIsLastIndex(null);
AuthPrincipalVo userInfo = UserContext.getUserHolder();
@@ -113,12 +116,35 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
if (insert <= 0) {
throw new BusinessException("save.workspace.failed");
}
if (workspaceDTO.getStyleId() != null) {
WorkspaceRelStyle rel = new WorkspaceRelStyle();
rel.setWorkspaceId(workspace.getId());
rel.setStyleId(workspaceDTO.getStyleId());
workspaceRelStyleMapper.insert(rel);
}
return true;
} else {
int update = workspaceMapper.updateById(workspace);
if (update <= 0) {
throw new BusinessException("update.workspace.failed");
}
if (workspaceDTO.getStyleId() != null) {
QueryWrapper<WorkspaceRelStyle> qw = new QueryWrapper<>();
qw.lambda().eq(WorkspaceRelStyle::getWorkspaceId, workspace.getId());
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(qw);
if (CollectionUtils.isEmpty(workspaceRelStyles)) {
WorkspaceRelStyle rel = new WorkspaceRelStyle();
rel.setWorkspaceId(workspace.getId());
rel.setStyleId(workspaceDTO.getStyleId());
workspaceRelStyleMapper.insert(rel);
}else {
WorkspaceRelStyle workspaceRelStyle = workspaceRelStyles.get(0);
if (!Objects.equals(workspaceRelStyle.getStyleId(), workspaceDTO.getStyleId())) {
workspaceRelStyle.setStyleId(workspaceRelStyle.getStyleId());
workspaceRelStyleMapper.updateById(workspaceRelStyle);
}
}
}
return true;
}
}
@@ -502,44 +528,36 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return deleteIds;
}
// public static void main(String[] args) throws FileNotFoundException {
// String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png";
// File pngFile = new File(b);
// SysFile sysFile = new SysFile();
// String fileName = pngFile.getName();
// sysFile.setName(fileName);
// sysFile.setLevel1Type("Images");
// sysFile.setLevel3Type("Male");
// StringBuilder sb = new StringBuilder();
// sb.append("aida-sys-image/images/male");
// String absolutePath = pngFile.getAbsolutePath();
// if (absolutePath.contains("bottom")) {
// sysFile.setLevel2Type("Bottoms");
// sb.append("/bottoms/");
// }else if(absolutePath.contains("top")) {
// sysFile.setLevel2Type("Tops");
// sb.append("/tops/");
// }else if(absolutePath.contains("outer")) {
// sysFile.setLevel2Type("Outwear");
// sb.append("/outwear/");
// }
// sb.append(fileName);
// String url = sb.toString();
// sysFile.setUrl(url);
// sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile)));
//// boolean b = minioUtil.doesObjectExist("aida-sys-image", uploadMinioPath);
//// if (!b) {
//// FileItem a = getMultipartFile(file, file.getName());
//// MultipartFile multipartFile = new CommonsMultipartFile(a);
//// minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
//// }
// FileItem a = getMultipartFile(pngFile, fileName);
// MultipartFile multipartFile = new CommonsMultipartFile(a);
// System.out.println(url.substring(0,14));
// System.out.println(url.substring(15));
//// minioUtil.upload(url.substring(0,14), url.substring(15), multipartFile, "");
// sysFile.setCreateDate(new Date());
// }
@Override
public Workspace getCurrentWorkspace() {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
QueryWrapper<Workspace> qw = new QueryWrapper<>();
qw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId());
qw.lambda().eq(Workspace::getIsLastIndex, 1);
// qw.lambda().eq(Workspace::getIsDeleted, 0);
List<Workspace> workspaces = workspaceMapper.selectList(qw);
if (CollectionUtils.isEmpty(workspaces)) {
throw new BusinessException("workspace not found.");
}
return workspaces.get(0);
}
@Override
public List<StyleVO> styleList() {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
QueryWrapper<Style> qw = new QueryWrapper<>();
List<Style> styles = styleMapper.selectList(qw);
List<StyleVO> styleVOS = CopyUtil.copyList(styles, StyleVO.class);
for (StyleVO styleVO : styleVOS) {
StyleEnum styleEnum = StyleEnum.fromName(styleVO.getName());
if (authPrincipalVo.getLanguage().equals(Language.ENGLISH.name())) {
styleVO.setValue(styleEnum.getEnglish());
}else {
styleVO.setValue(styleEnum.getChinese());
}
}
return styleVOS;
}
public static List<File> getPNGFiles(String directoryPath) {
List<File> pngFiles = new ArrayList<>();

View File

@@ -1,11 +0,0 @@
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/

View File

@@ -34,6 +34,17 @@ alipay.notify-url=http://18.167.251.121:10090/api/ali-pay/trade/notify
#alipay.notify-url=https://3b38-18-167-251-121.ngrok-free.app/api/ali-pay/trade/notify
#alipayHK.merchantId=3015240422190522
#alipayHK.segmentId=2971373831
#alipayHK.AESKey=UzRC2CncDUP6VlEd
alipayHK.merchantId=2088841167357411
alipayHK.segmentId=1771653121
alipayHK.AESKey=uTEbeOZBgXKbSqGz
alipayHK.rsaPrivateKey=files/Code-Create Limited-2088841167357411-merchant.private.key.txt
alipayHK.rsaPublicKey=files/Code-Create Limited.merchant.aqs.public.key.pem
alipayHK.api.url=https://aqs-api.sandbox-codpayment.com/

View File

@@ -1,6 +1,5 @@
server.port=5567
#datasource
spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.primary.username=aida_con
@@ -20,7 +19,7 @@ spring.security.jwtExpiration=8640000000
#spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/alipay-hk/**,/api/portfolio/**
spring.security.authApi=/auth/login
@@ -56,6 +55,7 @@ minio.bucketName.results=aida-results
minio.bucketName.sysImage=aida-sys-image
minio.bucketName.users=aida-users
minio.bucketName.collectionElement=aida-collection-element
minio.bucketName.gradient=aida-gradient
redirect_url=http://18.167.251.121:7788
spring.rabbitmq.host=18.167.251.121

View File

@@ -5,4 +5,4 @@
#spring.profiles.active=prod
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
spring.profiles.active=prod
spring.profiles.active=dev

View File

@@ -9,16 +9,16 @@
#paypal.webhook_id=51V87014T6406322F
# aida-sandbox-kim
#paypal.client-id=AbDDH8jnTrKqjnWLFgEu6LogYzVz2ZLuirE4W54t1M4lrofrP5OzXfhbxqktLLFB-rAO9KeYQVYFJ_tO
#paypal.client-secret=EOOoiIAe_dyR2YhY7qCIqWipZvYXCDrmBlFYchphuvkPFms1spsBGTlStlrx580y4hN-EukWwF9m_LAs
#paypal.receiver.email=sb-4xe8i29784722@business.example.com
#paypal.mode=sandbox
#paypal.webhook_id=1WH327112B602422N
paypal.client-id=AbDDH8jnTrKqjnWLFgEu6LogYzVz2ZLuirE4W54t1M4lrofrP5OzXfhbxqktLLFB-rAO9KeYQVYFJ_tO
paypal.client-secret=EOOoiIAe_dyR2YhY7qCIqWipZvYXCDrmBlFYchphuvkPFms1spsBGTlStlrx580y4hN-EukWwF9m_LAs
paypal.receiver.email=sb-4xe8i29784722@business.example.com
paypal.mode=sandbox
paypal.webhook_id=1WH327112B602422N
# aida-live-kim
paypal.client-id=ASWSIZ3MXJU5w5VOeOHeigWcSw6iinl30ZCipruziKpHclxP0ryf8-7VKG1Ba2VwZwa2DMvGEzTfCTgz
paypal.client-secret=EHQg_K5PSqmp4FJlzEcOEH_kFkmq4aBzaI7jridw53L6cOQRULBAnfv2KakRfrsqaU1PDSkO4Co9Vyxc
paypal.receiver.email=kimwong@code-create.com.hk
paypal.mode=live
#paypal.client-id=ASWSIZ3MXJU5w5VOeOHeigWcSw6iinl30ZCipruziKpHclxP0ryf8-7VKG1Ba2VwZwa2DMvGEzTfCTgz
#paypal.client-secret=EHQg_K5PSqmp4FJlzEcOEH_kFkmq4aBzaI7jridw53L6cOQRULBAnfv2KakRfrsqaU1PDSkO4Co9Vyxc
#paypal.receiver.email=kimwong@code-create.com.hk
#paypal.mode=live
#paypal.webhook_id=41L14847MC833625B
paypal.webhook_id=1D107312EX592781K
#paypal.webhook_id=1D107312EX592781K