From 3a2253f1cef221587519da66c32e0708e7b0c2d9 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Sun, 28 Jan 2024 11:08:53 +0800 Subject: [PATCH 01/18] =?UTF-8?q?TASK:=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-prod.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 59ce6439..6a2b9d4d 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -2,9 +2,9 @@ server.port=5567 #datasource spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.datasource.username=aida_con -spring.datasource.password=123456 +spring.datasource.url=jdbc:mysql://18.167.251.121:3306/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true +spring.datasource.username=root +spring.datasource.password=QWa998345 #spring.datasource.password=QWa998345 #security From ae6692523b52f67133a580bc3316403192d4ccbc Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:16:59 +0800 Subject: [PATCH 02/18] Update docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a37c5319..a8d0345f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ version: "3" services: aida_back: - container_name: stable-version-aida-back + container_name: produce-version-aida-back build: . # volumes: # # 数据挂载 # - /workspace/home/aida/file/:/workspace/home/aida/file/ ports: - - "10086:5567" \ No newline at end of file + - "10010:5567" From abcad626f6c439c82440f469d9bcb2ae81f28ff7 Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:19:03 +0800 Subject: [PATCH 03/18] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index a8d0345f..fbc671ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3" services: aida_back: - container_name: produce-version-aida-back + container_name: prod-version-aida-back build: . # volumes: # # 数据挂载 From e539a931f9e85e6856c606f66c9dcdcadf1fb8a2 Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:18:47 +0800 Subject: [PATCH 04/18] Update docker-compose.yml --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index fbc671ff..69600a52 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,8 @@ services: aida_back: container_name: prod-version-aida-back build: . -# volumes: -# # 数据挂载 -# - /workspace/home/aida/file/:/workspace/home/aida/file/ + volumes: + # 数据挂载 + - ./logs/:/logs/ ports: - "10010:5567" From 4f68fbcff14d25abebf0113a192a2ebcdd1f068e Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:19:36 +0800 Subject: [PATCH 05/18] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 69600a52..0b6683cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,6 @@ services: build: . volumes: # 数据挂载 - - ./logs/:/logs/ + - ./logs:/logs ports: - "10010:5567" From c74c7376cc7a6e971cd93bb0cbd7c5c884712314 Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:25:02 +0800 Subject: [PATCH 06/18] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0b6683cf..3f890499 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,6 @@ services: build: . volumes: # 数据挂载 - - ./logs:/logs + - ./logs:/log ports: - "10010:5567" From 12190f88c878f65ede3c9f4f43ee62507c4be8c0 Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:26:47 +0800 Subject: [PATCH 07/18] Update docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3f890499..3438ccfc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,8 @@ services: aida_back: container_name: prod-version-aida-back build: . - volumes: + # volumes: # 数据挂载 - - ./logs:/log + # - ./logs:/log ports: - "10010:5567" From 41919c44c9759dc35286b12d8a0428c212ab406a Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 29 Jan 2024 09:50:48 +0800 Subject: [PATCH 08/18] =?UTF-8?q?BUGFIX:=E8=AF=95=E7=94=A8=E7=94=A8?= =?UTF-8?q?=E6=88=B7;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/service/impl/AccountServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 30295880..7715cf12 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -478,12 +478,12 @@ public class AccountServiceImpl extends ServiceImpl impl if (CollectionUtil.isNotEmpty(accountList)) { if (accountList.get(0).getIsTrial() == 1) { throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode()); + }else { + Account account = accountList.get(0); + if (account.getValidEndTime() > System.currentTimeMillis()) { + throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode()); + } } -// else { -// Account account = accountList.get(0); -// account.setIsTrial(1); -// accountMapper.updateById(account); -// } } // 接收到数据后要形成一条使用订单信息 TrialOrder trialOrder = CopyUtil.copyObject(accountTrialDTO, TrialOrder.class); From 17e7ebc8fe8f7fc2cdbbabc2041b042b55595893 Mon Sep 17 00:00:00 2001 From: zchengrong <124802516+zchengrong@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:02:45 +0800 Subject: [PATCH 09/18] Update docker-compose.yml --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3438ccfc..5b64e5f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,8 @@ services: aida_back: container_name: prod-version-aida-back build: . - # volumes: - # 数据挂载 - # - ./logs:/log + volumes: + # 日志目录映射 + - ./log:/log ports: - "10010:5567" From ee2a8ac3cec65c4e328f2188c87c350e0f4127a1 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 29 Jan 2024 10:06:48 +0800 Subject: [PATCH 10/18] =?UTF-8?q?BUGFIX:=E8=AF=95=E7=94=A8=E7=94=A8?= =?UTF-8?q?=E6=88=B7;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/service/impl/AccountServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 7715cf12..a386cdc3 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -480,7 +480,7 @@ public class AccountServiceImpl extends ServiceImpl impl throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode()); }else { Account account = accountList.get(0); - if (account.getValidEndTime() > System.currentTimeMillis()) { + if (null == account.getValidEndTime() || account.getValidEndTime() > System.currentTimeMillis()) { throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode()); } } From 7386f4427dba2164e000b252ef714aed909b2a5d Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 29 Jan 2024 11:30:39 +0800 Subject: [PATCH 11/18] =?UTF-8?q?TASK:=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/application-test.properties | 22 +++++-------------- src/main/resources/application.properties | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 01678779..59ce6439 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -5,11 +5,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.datasource.username=aida_con spring.datasource.password=123456 - -#??? -spring.datasource.hikari.minimum-idle=5 -spring.datasource.hikari.maximum-pool-size=40 -spring.datasource.hikari.idle-timeout=60000 +#spring.datasource.password=QWa998345 #security spring.security.jwtSecret=JWTSECRET @@ -38,26 +34,21 @@ spring.mvc.pathmatch.matching-strategy=ant_path_matcher file.mac.path=~/file/ file.linux.path=/workspace/home/aida/file/ #linux服务器域名(预览和下载用) -#file.linuxDomain=http://18.162.111.141:5568/download/ -#file.linuxDomain=http://18.167.251.121:5568/download/ file.linuxDomain=https://www.aida.com.hk/download/ file.windows.path=D:\\upload\\ - -spring.servlet.multipart.max-file-size = 5MB -spring.servlet.multipart.max-request-size= 5MB - +spring.servlet.multipart.max-file-size = 10MB +spring.servlet.multipart.max-request-size= 10MB #访问python服务的ip(对应环境) #access.python.ip=http://43.198.80.117 access.python.ip=http://18.167.251.121 #access.python.ip=http://18.167.251.121:9991/ -access.python.port=9992 -#access.python.port=9991 +access.python.port=9990 -# minIO服务配置之信息 minio.endpoint=https://www.minio.aida.com.hk:9000 minio.accessKey=admin minio.secretKey=admin123 minio.bucketName.clothing=aida-clothing +minio.bucketName.mannequins=aida-mannequins minio.bucketName.results=aida-results minio.bucketName.sysImage=aida-sys-image minio.bucketName.users=aida-users @@ -83,5 +74,4 @@ spring.redis.lettuce.pool.max-wait=5 redis.key.consumptionOrder=ConsumptionOrder redis.key.cancelSet=CancelSet redis.key.exceptionMap=ExceptionMap -redis.key.resultMap=ResultMap - +redis.key.resultMap=ResultMap \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f00b793a..47a99eb3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,7 +2,7 @@ #spring.profiles.active=test #����application-prod�ļ�(��������) -spring.profiles.active=dev +spring.profiles.active=test #����application-dev�ļ�(��������) #spring.profiles.active=dev From 533b54a7680417d7ecf230f58a1a885bd2a0c8cc Mon Sep 17 00:00:00 2001 From: xupei Date: Mon, 29 Jan 2024 17:03:10 +0800 Subject: [PATCH 12/18] =?UTF-8?q?MQ=20=E6=B6=88=E6=81=AF=E9=98=9F=E5=88=97?= =?UTF-8?q?=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java index d4e24508..208075fd 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java @@ -16,7 +16,8 @@ import org.springframework.beans.factory.annotation.Value; public class MQConfig { public static final String GENERATE_EXCHANGE_FANOUT = "generate-exchange"; - public static final String GENERATE_QUEUE = "generate-queue-prod"; +// public static final String GENERATE_QUEUE = "generate-queue-prod"; + public static final String GENERATE_QUEUE = "generate-queue-test"; public MQConfig() { } From 9e653595a9fc49829c7733ff4133e673652e8411 Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 30 Jan 2024 11:48:26 +0800 Subject: [PATCH 13/18] =?UTF-8?q?generate=20=E6=B7=BB=E5=8A=A0=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E7=94=A8=E6=88=B7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/controller/GenerateController.java | 3 +- .../dto/GenerateThroughImageTextDTO.java | 3 ++ .../ai/da/model/vo/PrepareForGenerateVO.java | 25 ++++++++++++ .../com/ai/da/service/GenerateService.java | 3 +- .../da/service/impl/GenerateServiceImpl.java | 38 ++++++++++++++++++- 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/ai/da/model/vo/PrepareForGenerateVO.java diff --git a/src/main/java/com/ai/da/controller/GenerateController.java b/src/main/java/com/ai/da/controller/GenerateController.java index b3f6fb5b..c752fbc0 100644 --- a/src/main/java/com/ai/da/controller/GenerateController.java +++ b/src/main/java/com/ai/da/controller/GenerateController.java @@ -6,6 +6,7 @@ import com.ai.da.model.dto.GenerateThroughImageTextDTO; import com.ai.da.model.vo.GenerateCaptionVO; import com.ai.da.model.vo.GenerateCollectionVO; import com.ai.da.model.vo.GenerateLikeVO; +import com.ai.da.model.vo.PrepareForGenerateVO; import com.ai.da.service.GenerateService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -55,7 +56,7 @@ public class GenerateController { @ApiOperation(value = "发起生成请求,异步获取结果") @PostMapping("/prepare") - public Response prepareForGenerate(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) { + public Response prepareForGenerate(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) { return Response.success(generateService.prepareForGenerate(generateThroughImageTextDTO)); } diff --git a/src/main/java/com/ai/da/model/dto/GenerateThroughImageTextDTO.java b/src/main/java/com/ai/da/model/dto/GenerateThroughImageTextDTO.java index fd45533c..1adfdbef 100644 --- a/src/main/java/com/ai/da/model/dto/GenerateThroughImageTextDTO.java +++ b/src/main/java/com/ai/da/model/dto/GenerateThroughImageTextDTO.java @@ -47,4 +47,7 @@ public class GenerateThroughImageTextDTO { @ApiModelProperty("唯一id,用于保持消息唯一性") String uniqueId; + + @ApiModelProperty("是否是测试用户") + Boolean isTestUser; } diff --git a/src/main/java/com/ai/da/model/vo/PrepareForGenerateVO.java b/src/main/java/com/ai/da/model/vo/PrepareForGenerateVO.java new file mode 100644 index 00000000..438d94db --- /dev/null +++ b/src/main/java/com/ai/da/model/vo/PrepareForGenerateVO.java @@ -0,0 +1,25 @@ +package com.ai.da.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("prepare for generate响应vo") +public class PrepareForGenerateVO { + + @ApiModelProperty("uniqueId") + private String uniqueId; + + @ApiModelProperty("剩余使用次数") + private Integer leftUsageCount; + + public PrepareForGenerateVO(String uniqueId, Integer leftUsageCount) { + this.uniqueId = uniqueId; + this.leftUsageCount = leftUsageCount; + } + + public PrepareForGenerateVO(Integer leftUsageCount) { + this.leftUsageCount = leftUsageCount; + } +} diff --git a/src/main/java/com/ai/da/service/GenerateService.java b/src/main/java/com/ai/da/service/GenerateService.java index d1a327bd..06ca4122 100644 --- a/src/main/java/com/ai/da/service/GenerateService.java +++ b/src/main/java/com/ai/da/service/GenerateService.java @@ -7,6 +7,7 @@ import com.ai.da.model.dto.GenerateThroughImageTextDTO; import com.ai.da.model.vo.GenerateCaptionVO; import com.ai.da.model.vo.GenerateCollectionVO; import com.ai.da.model.vo.GenerateLikeVO; +import com.ai.da.model.vo.PrepareForGenerateVO; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -27,7 +28,7 @@ public interface GenerateService extends IService { GenerateCollectionVO getGenerateResult(String uniqueId); - String prepareForGenerate(GenerateThroughImageTextDTO generateThroughImageTextDTO); + PrepareForGenerateVO prepareForGenerate(GenerateThroughImageTextDTO generateThroughImageTextDTO); Long getRankPosition(String uniqueId); diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 095db937..0ea8e713 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -314,7 +314,7 @@ public class GenerateServiceImpl extends ServiceImpl i } @Override - public String prepareForGenerate(GenerateThroughImageTextDTO generateThroughImageTextDTO) { + public PrepareForGenerateVO prepareForGenerate(GenerateThroughImageTextDTO generateThroughImageTextDTO) { // 1、参数检查,判断必须参数是否为空 if (Objects.isNull(generateThroughImageTextDTO.getUserId())) { throw new BusinessException("userId cannot be empty"); @@ -323,6 +323,16 @@ public class GenerateServiceImpl extends ServiceImpl i if (!GenerateModeEnum.getGenerateModeList().contains(generateType)) { throw new BusinessException("unknown.generate.type"); } + + // 判断试用用户是否还有剩余试用机会 + int trialsCount = 0; + if (generateThroughImageTextDTO.getIsTestUser()){ + trialsCount = getTrialsCount(generateThroughImageTextDTO.getUserId(), generateThroughImageTextDTO.getLevel1Type()); + if (trialsCount >= 2){ + return new PrepareForGenerateVO(0); + } + } + String text = generateThroughImageTextDTO.getText(); Long elementId = generateThroughImageTextDTO.getCollectionElementId(); validateGeneraType(new Generate(), text, elementId, generateType); @@ -361,7 +371,7 @@ public class GenerateServiceImpl extends ServiceImpl i rabbitMQService.publishMessage(jsonString); // 5、返回唯一id - return uuid; + return new PrepareForGenerateVO(uuid, 2 - trialsCount); } @Override @@ -458,4 +468,28 @@ public class GenerateServiceImpl extends ServiceImpl i GenerateCancel generateCancel = new GenerateCancel(userId, uniqueId, DateUtil.getByTimeZone(timeZone)); generateCancelMapper.insert(generateCancel); } + + // 判断试用用户试用generate机会是否使用完毕 + private int getTrialsCount(Long userId, String level1Type){ + List getGenerateList = getGenerateByAccountId(userId, level1Type); + int trialsCount ; + if (getGenerateList.isEmpty()){ + trialsCount = 0; + } else if (getGenerateList.size() == 1) { + trialsCount = 1; + } else if (getGenerateList.size() == 2) { + trialsCount = 2; + }else { + trialsCount = 2; + } + return trialsCount; + } + + public List getGenerateByAccountId(Long accountId, String level1Type){ + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("account_id",accountId); + qw.eq("level1_type", level1Type); + + return baseMapper.selectList(qw); + } } From ec9b60e1d609839a99d9c24a80252719d346d9da Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 30 Jan 2024 12:38:56 +0800 Subject: [PATCH 14/18] docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5b64e5f0..6857a1da 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ version: "3" services: aida_back: - container_name: prod-version-aida-back + container_name: stable-version-aida-back build: . volumes: # 日志目录映射 - ./log:/log ports: - - "10010:5567" + - "10090:5567" From 5975519c39dd8e2a929f4603ccdcbbde06b2621d Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 30 Jan 2024 12:43:36 +0800 Subject: [PATCH 15/18] docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6857a1da..8325f62d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,4 +7,4 @@ services: # 日志目录映射 - ./log:/log ports: - - "10090:5567" + - "10086:5567" From 878b5a129ce6bf6cd36f1ada196ed8aac54eb75e Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 30 Jan 2024 14:20:01 +0800 Subject: [PATCH 16/18] =?UTF-8?q?TASK:=E8=AF=95=E7=94=A8=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E4=BD=99=E9=A2=9D;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/service/impl/ChatRobotServiceImpl.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java index 5f06a194..1300292f 100644 --- a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java @@ -9,7 +9,9 @@ import com.ai.da.common.enums.LibraryLevel1TypeEnum; import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.MD5Utils; import com.ai.da.common.utils.MinioUtil; +import com.ai.da.mapper.AccountMapper; import com.ai.da.mapper.LibraryMapper; +import com.ai.da.mapper.entity.Account; import com.ai.da.mapper.entity.ChatRobot; import com.ai.da.mapper.ChatRobotMapper; import com.ai.da.mapper.entity.Library; @@ -74,6 +76,8 @@ public class ChatRobotServiceImpl implements ChatRobotService { @Value("${minio.bucketName.sysImage}") private String sysImage; + @Resource + private AccountMapper accountMapper; Gson gson = new GsonBuilder().create(); private final ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -257,8 +261,15 @@ public class ChatRobotServiceImpl implements ChatRobotService { List chatRobots = chatRobotMapper.selectList(queryWrapper); if (!CollectionUtils.isEmpty(chatRobots)) { BigDecimal totalCostUsed = chatRobots.get(0).getTotalCost(); - if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) { - throw new BusinessException("Your balance is insufficient"); + Account account = accountMapper.selectById(userId); + if (account.getIsTrial() == 1) { + if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(0.1)) > 0) { + throw new BusinessException("Your balance is insufficient"); + } + }else { + if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) { + throw new BusinessException("Your balance is insufficient"); + } } } } @@ -323,9 +334,13 @@ public class ChatRobotServiceImpl implements ChatRobotService { if (CollectionUtils.isEmpty(chatRobots)) { return BigDecimal.ONE; } else { + Account account = accountMapper.selectById(userId); BigDecimal totalCost = BigDecimal.valueOf(5).subtract(chatRobots.get(0).getTotalCost()); - BigDecimal result = totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP); - return result; + if (account.getIsTrial() == 1) { + return totalCost.divide(BigDecimal.valueOf(0.1), 4, RoundingMode.HALF_UP); + }else { + return totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP); + } } } From 5e1573ae0966a6b933e78080cee669e283a750bd Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 30 Jan 2024 15:07:34 +0800 Subject: [PATCH 17/18] =?UTF-8?q?TASK:=E8=AF=95=E7=94=A8=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E4=BD=99=E9=A2=9D;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java index 1300292f..650deb4c 100644 --- a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java @@ -337,6 +337,7 @@ public class ChatRobotServiceImpl implements ChatRobotService { Account account = accountMapper.selectById(userId); BigDecimal totalCost = BigDecimal.valueOf(5).subtract(chatRobots.get(0).getTotalCost()); if (account.getIsTrial() == 1) { + totalCost = BigDecimal.valueOf(0.1).subtract(chatRobots.get(0).getTotalCost()); return totalCost.divide(BigDecimal.valueOf(0.1), 4, RoundingMode.HALF_UP); }else { return totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP); From 8f832ec441d79d6d9f4d0483798cefca7983062f Mon Sep 17 00:00:00 2001 From: xupei Date: Wed, 31 Jan 2024 14:59:19 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E5=88=B0=E6=9C=9F=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/filter/AuthenticationFilter.java | 2 +- .../da/service/impl/ChatRobotServiceImpl.java | 17 +++++++++++++---- src/main/resources/application.properties | 4 ++-- src/main/resources/messages_en.properties | 2 ++ src/main/resources/messages_zh.properties | 2 ++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java index c2625612..6efefd84 100644 --- a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java +++ b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java @@ -47,7 +47,7 @@ public class AuthenticationFilter extends OncePerRequestFilter { "/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile", "/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew", "/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl", - "/api/python/chatStream", +// "/api/python/chatStream", "/api/python/flush", "/api/account/healthy" ); diff --git a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java index 650deb4c..9cfffaf1 100644 --- a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java @@ -182,7 +182,8 @@ public class ChatRobotServiceImpl implements ChatRobotService { chatRobot.setSessionId(data.getString("session_id")); BigDecimal totalCost = data.getBigDecimal("total_cost"); // 校验本次余额够不够 - checkBalance(totalCost, chatSendDTO.getUser_id()); + ChatRobotVO balance = checkBalance(totalCost, chatSendDTO.getUser_id()); + if (!Objects.isNull(balance)) return balance; chatRobot.setTotalCost(totalCost); chatRobot.setTotalTokens(data.getLong("total_tokens")); chatRobot.setUserId(chatSendDTO.getUser_id()); @@ -252,7 +253,7 @@ public class ChatRobotServiceImpl implements ChatRobotService { throw new BusinessException("chat-bot.interface.exception"); } - private void checkBalance(BigDecimal totalCost, Long userId) { + private ChatRobotVO checkBalance(BigDecimal totalCost, Long userId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id", userId); queryWrapper.ge("create_time", LocalDateTime.now().withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0)); @@ -262,16 +263,24 @@ public class ChatRobotServiceImpl implements ChatRobotService { if (!CollectionUtils.isEmpty(chatRobots)) { BigDecimal totalCostUsed = chatRobots.get(0).getTotalCost(); Account account = accountMapper.selectById(userId); + ChatRobot chatRobot = new ChatRobot(); if (account.getIsTrial() == 1) { if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(0.1)) > 0) { - throw new BusinessException("Your balance is insufficient"); + String messageFromResource = BusinessException.getMessageFromResource("balance.insufficient.for.trial"); + chatRobot.setOutput(messageFromResource); +// throw new BusinessException("Your balance is insufficient"); + return CopyUtil.copyObject(chatRobot, ChatRobotVO.class); } }else { if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) { - throw new BusinessException("Your balance is insufficient"); + String messageFromResource = BusinessException.getMessageFromResource("balance.insufficient.for.paying"); + chatRobot.setOutput(messageFromResource); +// throw new BusinessException("Your balance is insufficient"); + return CopyUtil.copyObject(chatRobot, ChatRobotVO.class); } } } + return null; } @Override diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 47a99eb3..ec94939b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,8 +1,8 @@ #����application-test�ļ�(���Ի���) -#spring.profiles.active=test +spring.profiles.active=test #����application-prod�ļ�(��������) -spring.profiles.active=test +#spring.profiles.active=prod #����application-dev�ļ�(��������) #spring.profiles.active=dev diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 3fa4295a..ca17378d 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -152,6 +152,8 @@ classificationName.already.exists=The label name you've entered already exists. # 用来提醒用户可能会导致不良后果的操作,但不一定是错误。用户需要认真考虑是否继续当前操作。 the.classification.you.deleted.has.associated.library=The label you are attempting to delete is associated with existing data. Are you sure you wish to proceed with deletion? the.model.has.been.referenced.by.the.workspace=This model is currently in use by a workspace. Deleting it might affect the workspace. Confirm deletion only if you are sure. +balance.insufficient.for.trial=Want to continue using it immediately? Please consider upgrading to our subscription plan to get more quota. +balance.insufficient.for.paying=You have reached your usage limit for this month. # Errors: # 这类错误是由系统内部错误引起的,用户通常无法自行解决,需要联系支持或等待系统管理员介入。 diff --git a/src/main/resources/messages_zh.properties b/src/main/resources/messages_zh.properties index 6f330d93..8fecb5f9 100644 --- a/src/main/resources/messages_zh.properties +++ b/src/main/resources/messages_zh.properties @@ -150,6 +150,8 @@ classificationName.already.exists=您输入的标签名已存在。请输入不 # 用来提醒用户可能会导致不良后果的操作,但不一定是错误。用户需要认真考虑是否继续当前操作。 the.classification.you.deleted.has.associated.library=您正在尝试删除的标签与现有数据相关联。您确定要继续删除吗? the.model.has.been.referenced.by.the.workspace=此模型当前正在工作区中使用。删除它可能会影响工作区。仅在确信后再确认删除。 +balance.insufficient.for.trial=想要立即继续使用?请考虑升级到我们的订阅计划,以获得更多额度。 +balance.insufficient.for.paying=您已达到本月的使用额度限制。 # Errors: # 这类错误是由系统内部错误引起的,用户通常无法自行解决,需要联系支持或等待系统管理员介入。