Merge branch 'release/3.1' into dev/3.1_release_merge

# Conflicts:
#	src/main/java/com/ai/da/common/config/MyTaskScheduler.java
#	src/main/java/com/ai/da/common/enums/ProductEnum.java
#	src/main/java/com/ai/da/common/task/PaymentTask.java
#	src/main/java/com/ai/da/common/utils/LocalCacheUtils.java
#	src/main/java/com/ai/da/common/utils/RedisUtil.java
#	src/main/java/com/ai/da/controller/AffiliateController.java
#	src/main/java/com/ai/da/controller/ConvenientInquiryController.java
#	src/main/java/com/ai/da/controller/StripeController.java
#	src/main/java/com/ai/da/mapper/primary/entity/Library.java
#	src/main/java/com/ai/da/mapper/primary/entity/ProductCoupons.java
#	src/main/java/com/ai/da/model/dto/CreateCouponDTO.java
#	src/main/java/com/ai/da/model/vo/CheckCouponsVO.java
#	src/main/java/com/ai/da/service/AffiliateService.java
#	src/main/java/com/ai/da/service/PaymentInfoService.java
#	src/main/java/com/ai/da/service/StripeService.java
#	src/main/java/com/ai/da/service/impl/AccountServiceImpl.java
#	src/main/java/com/ai/da/service/impl/AffiliateServiceImpl.java
#	src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java
#	src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java
#	src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java
#	src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java
#	src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java
#	src/main/java/com/ai/da/service/impl/StripeServiceImpl.java
#	src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java
#	src/main/resources/messages_en.properties
#	src/main/resources/messages_zh.properties
This commit is contained in:
2025-08-31 17:54:44 +08:00
30 changed files with 2571 additions and 2170 deletions

View File

@@ -245,30 +245,26 @@ public class MyTaskScheduler {
try (FileOutputStream fileOut = new FileOutputStream(fileName)) { try (FileOutputStream fileOut = new FileOutputStream(fileName)) {
workbook.write(fileOut); workbook.write(fileOut);
// SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName); // SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName);
// SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
// SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
// SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("ningning@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); // SendEmailUtil.sendExcelEmail("ningning@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("johnnyho@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("ringolau@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("ningning@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("johnnyho@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); SendEmailUtil.sendExcelEmail("johnnyho@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("ringolau@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); SendEmailUtil.sendExcelEmail("ringolau@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
SendEmailUtil.sendExcelEmail("chelseayu@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
}else { }else {
// SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null); // SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null);
// SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null); SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null);
// SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null); SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null);
// SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null); SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("ningning@code-create.com.hk", null); // SendEmailUtil.sendNoExcelEmail("ningning@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("johnnyho@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("ringolau@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("ningning@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("johnnyho@code-create.com.hk", null); SendEmailUtil.sendNoExcelEmail("johnnyho@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("ringolau@code-create.com.hk", null); SendEmailUtil.sendNoExcelEmail("ringolau@code-create.com.hk", null);
SendEmailUtil.sendNoExcelEmail("chelseayu@code-create.com.hk", null);
} }
} }

View File

@@ -13,6 +13,8 @@ public class CommonConstant {
public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60; public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60;
// 单位 秒 一天过期 in redis // 单位 秒 一天过期 in redis
public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L; public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L;
// 单位 秒 7天过期
public static final Long REDIS_SET_EXPIRE_TIME = 24 * 60 * 60 * 7L;
public static class Numbers{ public static class Numbers{
public static final Integer NUMBER_10 = 10; public static final Integer NUMBER_10 = 10;
@@ -81,6 +83,8 @@ public class CommonConstant {
public static final String TIME_FORMAT_MMM_dd_yyyy = "MMM. dd, yyyy"; public static final String TIME_FORMAT_MMM_dd_yyyy = "MMM. dd, yyyy";
public static final String TIME_FORMAT_yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
public static final String AFFILIATE_LINK = "https://www.aida.com.hk?ref="; public static final String AFFILIATE_LINK = "https://www.aida.com.hk?ref=";
public static final String PARTIAL_DESIGN_FILENAME = "PartialDesign"; public static final String PARTIAL_DESIGN_FILENAME = "PartialDesign";

View File

@@ -31,7 +31,9 @@ public enum AuthenticationOperationTypeEnum {
/** /**
* 填写用户国家和职业 * 填写用户国家和职业
*/ */
UPDATE_USERINFO; UPDATE_USERINFO,
REGISTER;
public static AuthenticationOperationTypeEnum of(String name) { public static AuthenticationOperationTypeEnum of(String name) {
return Stream.of(AuthenticationOperationTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null); return Stream.of(AuthenticationOperationTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
public enum ProductEnum { public enum ProductEnum {
// 积分购买 // 积分购买
CreditsProduct("AiDA credits purchase", 10L, 60L), CreditsProduct("AiDA credits purchase", 10L, 50L),
// 年度订阅 // 年度订阅
AnnualSubscription("AiDA Annual Subscription", 5000L, 50000L), AnnualSubscription("AiDA Annual Subscription", 5000L, 50000L),
// 月度订阅订阅费500每月3500 积分) // 月度订阅订阅费500每月3500 积分)

View File

@@ -0,0 +1,15 @@
package com.ai.da.common.response;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@ApiModel("交易记录分页响应结果")
public class TransactionPageResponse<T> extends PageBaseResponse<T> {
private BigDecimal totalAmount;
}

View File

@@ -84,6 +84,7 @@ public class PaymentTask {
}*/ }*/
} }
// !!关闭此定时器,改为提前三天站内信提醒!!
// 提前7天向用户发送提醒邮件,每天早上8点执行 // 提前7天向用户发送提醒邮件,每天早上8点执行
// @Scheduled(cron = "0 0 8 * * ?") // @Scheduled(cron = "0 0 8 * * ?")
public void subscriptionReminder(){ public void subscriptionReminder(){

View File

@@ -0,0 +1,88 @@
package com.ai.da.common.utils;
import java.util.HashMap;
import java.util.Map;
public class ComprehensivePunctuationConverter {
private static final Map<Character, Character> FULL_TO_HALF_MAP = new HashMap<>();
static {
// 中文标点到英文标点的映射(扩展版)
FULL_TO_HALF_MAP.put('', ',');
FULL_TO_HALF_MAP.put('。', '.');
FULL_TO_HALF_MAP.put('', ';');
FULL_TO_HALF_MAP.put('', ':');
FULL_TO_HALF_MAP.put('', '?');
FULL_TO_HALF_MAP.put('', '!');
FULL_TO_HALF_MAP.put('', '(');
FULL_TO_HALF_MAP.put('', ')');
FULL_TO_HALF_MAP.put('【', '[');
FULL_TO_HALF_MAP.put('】', ']');
FULL_TO_HALF_MAP.put('「', '\'');
FULL_TO_HALF_MAP.put('」', '\'');
FULL_TO_HALF_MAP.put('『', '"');
FULL_TO_HALF_MAP.put('』', '"');
FULL_TO_HALF_MAP.put('、', '\\');
FULL_TO_HALF_MAP.put('', '~');
FULL_TO_HALF_MAP.put('—', '-');
FULL_TO_HALF_MAP.put('', '.');
FULL_TO_HALF_MAP.put('〈', '<');
FULL_TO_HALF_MAP.put('〉', '>');
FULL_TO_HALF_MAP.put('《', '«');
FULL_TO_HALF_MAP.put('》', '»');
FULL_TO_HALF_MAP.put('〝', '"');
FULL_TO_HALF_MAP.put('〞', '"');
FULL_TO_HALF_MAP.put('﹁', '"');
FULL_TO_HALF_MAP.put('﹂', '"');
FULL_TO_HALF_MAP.put('…', '.');
FULL_TO_HALF_MAP.put('', '_');
// 全角字母和数字
for (char c = ''; c <= ''; c++) {
FULL_TO_HALF_MAP.put(c, (char)(c - '' + 'A'));
}
for (char c = ''; c <= ''; c++) {
FULL_TO_HALF_MAP.put(c, (char)(c - '' + 'a'));
}
for (char c = ''; c <= ''; c++) {
FULL_TO_HALF_MAP.put(c, (char)(c - '' + '0'));
}
}
/**
* 将字符串中的全角字符(包括标点、字母、数字)转换为半角字符
*/
public static String convertToHalfWidth(String input) {
if (input == null || input.isEmpty()) {
return input;
}
StringBuilder result = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
// 检查映射表
if (FULL_TO_HALF_MAP.containsKey(c)) {
result.append(FULL_TO_HALF_MAP.get(c));
}
// 处理全角空格Unicode 12288
else if (c == ' ') {
result.append(' ');
}
// 其他字符保持不变
else {
result.append(c);
}
}
return result.toString();
}
public static void main(String[] args) {
// String text = "这是一个全角示例,包含:中文标点、全角字母(ABC)、全角数字(123) 还有全角空格!";
String text = "birdsyellow";
String converted = convertToHalfWidth(text);
System.out.println("原始文本: " + text);
System.out.println("转换后: " + converted);
}
}

View File

@@ -100,8 +100,10 @@ public class RedisUtil {
/** /**
* 将数据放入set缓存 * 将数据放入set缓存
*/ */
public void addToSet(String key, String value) { public void addToSet(String key, String value, Long expiresIn) {
redisTemplate.opsForSet().add(key, value); redisTemplate.opsForSet().add(key, value);
// 设置过期时间
redisTemplate.expire(key, expiresIn, TimeUnit.SECONDS);
} }
/** /**
@@ -503,6 +505,7 @@ public class RedisUtil {
public final static String IMAGE_SEGMENTATION = "ImageSegmentation:"; public final static String IMAGE_SEGMENTATION = "ImageSegmentation:";
public final static String STRIPE_EXCEPTION_LOG = "StripeException:"; public final static String STRIPE_EXCEPTION_LOG = "StripeException:";
public final static String SUBSCRIPTION_SENT_EMAIL_TYPE = "SubscriptionEmailSentType:";
public void batchDeleteKeysWithSamePrefix(String prefix){ public void batchDeleteKeysWithSamePrefix(String prefix){
Set<String> keys = redisTemplate.keys(prefix + "*"); Set<String> keys = redisTemplate.keys(prefix + "*");

View File

@@ -611,7 +611,6 @@ public class SendEmailUtil {
public static void uploadTimeoutReminder(String userName, String time) { public static void uploadTimeoutReminder(String userName, String time) {
String xp = "xupei3360@163.com"; String xp = "xupei3360@163.com";
String shb = "shahaibodd99@gmail.com";
String wxd = "X1627315083@163.com"; String wxd = "X1627315083@163.com";
String pkc = "kaicpang.pang@connect.polyu.hk"; String pkc = "kaicpang.pang@connect.polyu.hk";
try { try {
@@ -630,7 +629,7 @@ public class SendEmailUtil {
// 实例化一个请求对象,每个接口都会对应一个request对象 // 实例化一个请求对象,每个接口都会对应一个request对象
SendEmailRequest req = new SendEmailRequest(); SendEmailRequest req = new SendEmailRequest();
req.setFromEmailAddress(SEND_ADDRESS); req.setFromEmailAddress(SEND_ADDRESS);
req.setDestination(new String[]{shb, xp, wxd, pkc}); req.setDestination(new String[]{xp, wxd, pkc});
Template template = new Template(); Template template = new Template();
req.setSubject("上传图片超时提醒"); req.setSubject("上传图片超时提醒");
template.setTemplateID(UPLOAD_TIMEOUT_REMINDER); template.setTemplateID(UPLOAD_TIMEOUT_REMINDER);
@@ -745,9 +744,12 @@ public class SendEmailUtil {
// private final static Long NEW_MERCHANT_EN = 130721L; // private final static Long NEW_MERCHANT_EN = 130721L;
// private final static Long NEW_USER_EN = 130722L; // private final static Long NEW_USER_EN = 130722L;
// private final static Long NEW_USER_CN = 130723L; // private final static Long NEW_USER_CN = 130723L;
private final static Long NEW_MERCHANT_EN = 135190L; private final static Long NEW_MERCHANT_EN = 140335L;
private final static Long NEW_USER_EN = 135189L; // private final static Long NEW_MERCHANT_EN = 135190L;
private final static Long NEW_USER_CN = 135186L; // private final static Long NEW_USER_EN = 135189L;
// private final static Long NEW_USER_CN = 135186L;
private final static Long NEW_USER_EN = 140316L;
private final static Long NEW_USER_CN = 140317L;
private final static Long RENEWAL_MERCHANT_EN = 130724L; private final static Long RENEWAL_MERCHANT_EN = 130724L;
private final static Long RENEWAL_USER_EN = 130725L; private final static Long RENEWAL_USER_EN = 130725L;
private final static Long RENEWAL_USER_CN = 130726L; private final static Long RENEWAL_USER_CN = 130726L;

View File

@@ -49,7 +49,9 @@ public class ConvenientInquiryController {
String userEmail = accountService.getById(accountId).getUserEmail(); String userEmail = accountService.getById(accountId).getUserEmail();
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|| userEmail.equals("joho8228@hotmail.com") || userEmail.equals("wanninghua160@gmail.com") || userEmail.equals("joho8228@hotmail.com")
|| userEmail.equals("chelseayu@code-create.com.hk")
|| userEmail.equals("cheungzt007@gmail.com")
) { ) {
return Response.success(convenientInquiryService.getTrial(queryUserConditionsVO)); return Response.success(convenientInquiryService.getTrial(queryUserConditionsVO));
} else { } else {
@@ -61,7 +63,28 @@ public class ConvenientInquiryController {
@GetMapping("/getDesignStatistic") @GetMapping("/getDesignStatistic")
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
@RequestParam(required = false) List<Long> ids, @RequestParam(required = false) String email) { @RequestParam(required = false) List<Long> ids, @RequestParam(required = false) String email) {
return Response.success(convenientInquiryService.getDesignStatistic(startTime, endTime, ids, email)); Long accountId = UserContext.getUserHolder().getId();
String userEmail = accountService.getById(accountId).getUserEmail();
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|| userEmail.equals("joho8228@hotmail.com")
|| userEmail.equals("chelseayu@code-create.com.hk")
|| userEmail.equals("cheungzt007@gmail.com")
) {
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
if (StringUtil.isNullOrEmpty(endTime)) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = new Date();
endTime = simpleDateFormat.format(date);
}
if (!StringUtil.isNullOrEmpty(email)){
email = email.trim();
}
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime, ids, email);
return Response.success(designStatistic);
} else {
return Response.fail("Sorry, you don't have permission");
}
} }
@@ -163,7 +186,9 @@ public class ConvenientInquiryController {
String userEmail = accountService.getById(accountId).getUserEmail(); String userEmail = accountService.getById(accountId).getUserEmail();
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|| userEmail.equals("joho8228@hotmail.com") || userEmail.equals("wanninghua160@gmail.com") || userEmail.equals("joho8228@hotmail.com")
|| userEmail.equals("chelseayu@code-create.com.hk")
|| userEmail.equals("cheungzt007@gmail.com")
) { ) {
return Response.success(convenientInquiryService.getUserInfo(queryUserConditionsVO)); return Response.success(convenientInquiryService.getUserInfo(queryUserConditionsVO));
} else { } else {

View File

@@ -137,9 +137,11 @@ public class StripeController {
@ApiOperation("更新推广码信息") @ApiOperation("更新推广码信息")
@GetMapping("/updatePromCodeInfo") @GetMapping("/updatePromCodeInfo")
public Response<ProductCoupons> updateCouponsInfo(@RequestParam Long id, @RequestParam(required = false) Long paidCommission, public Response<ProductCoupons> updateCouponsInfo(@RequestParam Long id, @RequestParam(required = false) String paidCommission,
@RequestParam(required = false) String cooperator, @RequestParam(required = false) String remark){ @RequestParam(required = false) String cooperator,
return Response.success(stripeService.updateCouponsInfo(id, paidCommission, cooperator, remark)); @RequestParam(required = false) String remark,
@RequestParam(required = false) Long startTime){
return Response.success(stripeService.updateCouponsInfo(id, paidCommission, cooperator, remark, startTime));
} }
@ApiOperation("删除推广码") @ApiOperation("删除推广码")

View File

@@ -6,6 +6,7 @@ import com.ai.da.model.vo.PaymentInfoVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -24,6 +25,10 @@ public interface PaymentInfoMapper extends BaseMapper<PaymentInfo> {
String country, String city, String startTime, String endTime, String payer String country, String city, String startTime, String endTime, String payer
); );
BigDecimal queryTotalPaymentAmount(String paymentType,String payerTotal, String type, String status,
String country, String city, String startTime, String endTime, String payer
);
List<Map<String, String>> getCities(); List<Map<String, String>> getCities();
List<Map<String, String>> getCountries(); List<Map<String, String>> getCountries();

View File

@@ -7,6 +7,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@TableName("t_product_coupons") @TableName("t_product_coupons")
@@ -20,6 +22,8 @@ public class ProductCoupons extends BaseEntity{
private String promotionCodeId; private String promotionCodeId;
// 对应的推广码 // 对应的推广码
private String promotionCode; private String promotionCode;
// 优惠券有效期开始时间
private Long startTime;
// 最大兑换次数 // 最大兑换次数
private Long maxRedemptions; private Long maxRedemptions;
// 优惠券的折扣 // 优惠券的折扣
@@ -29,13 +33,13 @@ public class ProductCoupons extends BaseEntity{
// 合作者 // 合作者
private String cooperator; private String cooperator;
// 使用了该优惠券支付的总金额 // 使用了该优惠券支付的总金额
private float totalEarnings; private BigDecimal totalEarnings = BigDecimal.ZERO;
// 佣金 // 佣金
private float commission; private BigDecimal commission = BigDecimal.ZERO;
// 已付佣金 // 已付佣金
private float paidCommission; private BigDecimal paidCommission = BigDecimal.ZERO;
// 未付佣金 // 未付佣金
private float unpaidCommission; private BigDecimal unpaidCommission = BigDecimal.ZERO;
// 备注 // 备注
private String remark; private String remark;

View File

@@ -14,7 +14,9 @@ public class CreateCouponDTO {
@NotNull(message = "Please set the commissionRate.") @NotNull(message = "Please set the commissionRate.")
private Float commissionRate; private Float commissionRate;
@ApiModelProperty("推广码到期时间 秒级时间戳") @ApiModelProperty("推广码到期时间 秒级时间戳")
private Long timestamp; private Long endTime;
@ApiModelProperty("推广码开始时间 秒级时间戳")
private Long startTime;
@ApiModelProperty("推广码最大使用次数") @ApiModelProperty("推广码最大使用次数")
private Long maxRedemptions; private Long maxRedemptions;
@ApiModelProperty("合作者/机构名") @ApiModelProperty("合作者/机构名")

View File

@@ -15,8 +15,8 @@ public class EmailSendDTO {
private String email; private String email;
@NotBlank(message = "operationType.cannot.be.empty") @NotBlank(message = "operationType.cannot.be.empty")
@ApiModelProperty("操作类型 LOGIN 注册 FORGET_PWD 忘记密码 BIND_MAILBOX 绑定邮箱 " + @ApiModelProperty("操作类型 LOGIN 登录 FORGET_PWD 忘记密码 BIND_MAILBOX 绑定邮箱 " +
"CHANGE_MAILBOX 更改邮箱 UPDATE_USERINFO 仅填写国家、职业(不发送邮件)") "CHANGE_MAILBOX 更改邮箱 UPDATE_USERINFO 仅填写国家、职业(不发送邮件) REGISTER 注册")
private String operationType; private String operationType;
@ApiModelProperty("异常ip") @ApiModelProperty("异常ip")

View File

@@ -23,6 +23,9 @@ public class GenerateModifyDTO {
@ApiModelProperty(value = "sketch所属分类", required = true) @ApiModelProperty(value = "sketch所属分类", required = true)
private String category; private String category;
@ApiModelProperty(value = "originalId的来源 Library || Generate(默认为空)", required = true)
private String originalIdSource;
@NotNull(message = "id cannot be empty") @NotNull(message = "id cannot be empty")
@ApiModelProperty(value = "原图id", required = true) @ApiModelProperty(value = "原图id", required = true)
private Long originalId; private Long originalId;

View File

@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class CheckCouponsVO { public class CheckCouponsVO {
@ApiModelProperty("expired || invalid || valid") @ApiModelProperty("expired 过期 || invalid 无效 || valid 有效 || pending 尚未生效")
private String status; private String status;
private String message; private String message;

View File

@@ -13,6 +13,8 @@ public class PaymentInfoVO {
private Long id; private Long id;
@ApiModelProperty("付款用户名") @ApiModelProperty("付款用户名")
private String payer; private String payer;
@ApiModelProperty("付款者邮箱")
private String email;
@ApiModelProperty("选择的支付平台 PayPal || Stripe || Alipay-HK") @ApiModelProperty("选择的支付平台 PayPal || Stripe || Alipay-HK")
private String platform; private String platform;
@ApiModelProperty("支付的金额 单位:HKD") @ApiModelProperty("支付的金额 单位:HKD")

View File

@@ -53,6 +53,8 @@ public interface DesignItemService extends IService<DesignItem> {
DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO); DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO);
Map<String, String> setPriorityAndUndividedLayer(JSONArray layers);
Map<String, String> setTypeAndUndividedLayer(JSONArray layers); Map<String, String> setTypeAndUndividedLayer(JSONArray layers);
ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException; ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException;

View File

@@ -61,7 +61,7 @@ public interface StripeService {
CheckCouponsVO checkProductCoupon(String promotionCode, Long price); CheckCouponsVO checkProductCoupon(String promotionCode, Long price);
ProductCoupons updateCouponsInfo(Long id, Long paidCommission, String cooperator, String remark); ProductCoupons updateCouponsInfo(Long id, String paidCommission, String cooperator, String remark, Long startTime);
ProductCoupons getProductCoupon(String promotionCode, String promotionCodeId); ProductCoupons getProductCoupon(String promotionCode, String promotionCodeId);

View File

@@ -549,11 +549,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
result = true; result = true;
} }
break; break;
case REGISTER:
result = SendEmailUtil.designWorksRegister(emailSendDTO.getEmail(), randomVerifyCode);
break;
default: default:
} }
if (!result) { if (!result) {
throw new BusinessException("failed.to.send.mail"); throw new BusinessException("failed.to.send.mail");
} }
log.info("向邮箱 {} 发送验证码为:{}, 邮件类型:{}", emailSendDTO.getEmail(), randomVerifyCode, authenticationOperationTypeEnum);
return Boolean.TRUE; return Boolean.TRUE;
} }
@@ -1182,13 +1186,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
} }
String randomVerifyCode = RandomsUtil.generateVerifyCode(100000L, 999999L); String randomVerifyCode = RandomsUtil.generateVerifyCode(100000L, 999999L);
LocalCacheUtils.setVerifyCodeCache("DesignWorksRegister" + "_" + accountDesignWorksRegisterDTO.getUserEmail(), randomVerifyCode); LocalCacheUtils.setVerifyCodeCache("REGISTER" + "_" + userEmail, randomVerifyCode);
Boolean b = SendEmailUtil.designWorksRegister(accountDesignWorksRegisterDTO.getUserEmail(), randomVerifyCode); Boolean b = SendEmailUtil.designWorksRegister(userEmail, randomVerifyCode);
if (!b) { if (!b) {
throw new BusinessException("failed.to.send.mail"); throw new BusinessException("failed.to.send.mail");
} }
log.info("注册账号。成功向 {} 账号发送验证码:{}", accountDesignWorksRegisterDTO.getUserEmail(), randomVerifyCode); log.info("邮箱 {} 发送验证码:{}, 邮件类型REGISTER", userEmail, randomVerifyCode);
return Boolean.TRUE; return Boolean.TRUE;
} }
@@ -1196,7 +1200,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
public AccountLoginVO designWorksRegisterCode(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO, public AccountLoginVO designWorksRegisterCode(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO,
HttpServletRequest request) { HttpServletRequest request) {
String verifyCode = LocalCacheUtils.getVerifyCodeCache("DesignWorksRegister" + "_" + accountDesignWorksRegisterDTO.getUserEmail()); String verifyCode = LocalCacheUtils.getVerifyCodeCache("REGISTER" + "_" + accountDesignWorksRegisterDTO.getUserEmail());
if (StringUtils.isBlank(verifyCode)) { if (StringUtils.isBlank(verifyCode)) {
throw new BusinessException("the.verification.code.has.expired", ResultEnum.PROMPT.getCode()); throw new BusinessException("the.verification.code.has.expired", ResultEnum.PROMPT.getCode());
} }
@@ -1260,9 +1264,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
config.setJdbcUrl("jdbc:mysql://code-create.com.hk:3306/db1nfvsgmjp3b8"); config.setJdbcUrl("jdbc:mysql://code-create.com.hk:3306/db1nfvsgmjp3b8");
config.setUsername("uafqtz4gsvfrw"); config.setUsername("uafqtz4gsvfrw");
config.setPassword("aida123456."); config.setPassword("aida123456.");
// config.setJdbcUrl("jdbc:mysql://18.167.251.121:33008/aida");
// config.setUsername("aida_con");
// config.setPassword("123456");
// config.setJdbcUrl("jdbc:mysql://localhost:3306/code-create-local?serverTimezone=UTC"); // config.setJdbcUrl("jdbc:mysql://localhost:3306/code-create-local?serverTimezone=UTC");
// config.setUsername("root"); // config.setUsername("root");
// config.setPassword("root"); // config.setPassword("root");

View File

@@ -30,9 +30,13 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import static com.ai.da.common.utils.RedisUtil.AFFILIATE_LINK_VIEW_KEY; import static com.ai.da.common.utils.RedisUtil.AFFILIATE_LINK_VIEW_KEY;
@@ -444,5 +448,108 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
return baseMapper.selectAllAffiliateUsername(); return baseMapper.selectAllAffiliateUsername();
} }
/*public void calcCouponsCommission() {
String lastTime = redisUtil.getFromString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME);
log.info("优惠券佣金计算,上次执行时间:{}", lastTime);
String currentTime = LocalDateTime.now().toString();
// 1. 查询新增的优惠券订单
QueryWrapper<PaymentInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("trade_state", "paid")
.lt("create_time", currentTime)
.isNotNull("promotion_code");
Optional.ofNullable(lastTime)
.filter(time -> !time.isEmpty())
.ifPresent(time -> queryWrapper.gt("create_time", time));
List<PaymentInfo> paymentInfos = paymentInfoService.list(queryWrapper);
log.info("目前,新增使用优惠券的订单数:{}", paymentInfos.size());
// 2. 按推广码汇总支付金额
Map<String, BigDecimal> codeAmount = paymentInfos.stream()
.collect(Collectors.toMap(
PaymentInfo::getPromotionCode,
payment -> new BigDecimal(payment.getPayerTotal()),
BigDecimal::add
));
// 3. 更新佣金数据
codeAmount.forEach((promotionCode, amount) -> {
ProductCoupons coupon = stripeService.getProductCoupon(promotionCode, null);
if (coupon != null) {
updateCouponCommission(coupon, amount);
productCouponsMapper.updateById(coupon);
}
});
// 4. 更新最后执行时间
redisUtil.addToString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME, currentTime);
}*/
public void calcCouponsCommission() {
// 1. 获取并格式化时间
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String lastTime = redisUtil.getFromString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME);
log.info("优惠券佣金计算,上次执行时间:{}", lastTime);
// 2. 查询新增订单(使用>=和<
QueryWrapper<PaymentInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("trade_state", "paid")
.isNotNull("promotion_code");
if (!StringUtils.isNullOrEmpty(lastTime)) {
queryWrapper.ge("create_time", lastTime); // 关键修复:>=代替>
}
queryWrapper.lt("create_time", LocalDateTime.now().format(formatter));
List<PaymentInfo> paymentInfos = paymentInfoService.list(queryWrapper);
log.info("扫描时间范围: {} - {}, 新增订单数: {}",
lastTime, LocalDateTime.now().format(formatter), paymentInfos.size());
// 3. 按推广码汇总支付金额
Map<String, BigDecimal> codeAmount = paymentInfos.stream()
.collect(Collectors.toMap(
PaymentInfo::getPromotionCode,
payment -> new BigDecimal(payment.getPayerTotal()),
BigDecimal::add
));
// 4. 更新佣金数据
codeAmount.forEach((promotionCode, amount) -> {
ProductCoupons coupon = stripeService.getProductCoupon(promotionCode, null);
if (coupon != null) {
updateCouponCommission(coupon, amount);
productCouponsMapper.updateById(coupon);
}
});
// 5. 结束时更新Redis时间
String newLastTime = LocalDateTime.now().format(formatter);
redisUtil.addToString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME, newLastTime);
}
/**
* 更新优惠券的佣金数据
*/
private void updateCouponCommission(ProductCoupons coupon, BigDecimal newAmount) {
// 总收益 = 原收益默认0 + 新增金额
BigDecimal totalEarnings = Optional.ofNullable(coupon.getTotalEarnings())
.orElse(BigDecimal.ZERO)
.add(newAmount);
coupon.setTotalEarnings(totalEarnings);
// 佣金 = 总收益 × 佣金比例需除以100
BigDecimal commission = totalEarnings.multiply(
BigDecimal.valueOf(coupon.getCommissionRate())
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
coupon.setCommission(commission);
// 未支付佣金 = 总佣金 - 已支付佣金默认0
BigDecimal unpaidCommission = commission.subtract(
Optional.ofNullable(coupon.getPaidCommission())
.orElse(BigDecimal.ZERO));
coupon.setUnpaidCommission(unpaidCommission);
}
} }

View File

@@ -5,6 +5,7 @@ import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CreditsEventsEnum; import com.ai.da.common.enums.CreditsEventsEnum;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.TransactionPageResponse;
import com.ai.da.common.response.ResultEnum; import com.ai.da.common.response.ResultEnum;
import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.DateUtil; import com.ai.da.common.utils.DateUtil;
@@ -695,16 +696,21 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
queryPaymentInfoDTO.getType(), queryPaymentInfoDTO.getStatus(), queryPaymentInfoDTO.getType(), queryPaymentInfoDTO.getStatus(),
queryPaymentInfoDTO.getCountry(), queryPaymentInfoDTO.getCity(), queryPaymentInfoDTO.getCountry(), queryPaymentInfoDTO.getCity(),
queryPaymentInfoDTO.getStartTime(), queryPaymentInfoDTO.getEndTime(), queryPaymentInfoDTO.getPayer()); queryPaymentInfoDTO.getStartTime(), queryPaymentInfoDTO.getEndTime(), queryPaymentInfoDTO.getPayer());
// 查询符合查询条件的总金额
BigDecimal payerTotal = paymentInfoMapper.queryTotalPaymentAmount(queryPaymentInfoDTO.getPlatform(), queryPaymentInfoDTO.getPayerTotal(),
queryPaymentInfoDTO.getType(), queryPaymentInfoDTO.getStatus(),
queryPaymentInfoDTO.getCountry(), queryPaymentInfoDTO.getCity(),
queryPaymentInfoDTO.getStartTime(), queryPaymentInfoDTO.getEndTime(), queryPaymentInfoDTO.getPayer());
// 总页数 // 总页数
double totalPage = Math.ceil((double) total / size); double totalPage = Math.ceil((double) total / size);
// 组装返回参数 // 组装返回参数
PageBaseResponse<PaymentInfoVO> response = new PageBaseResponse<>(); TransactionPageResponse<PaymentInfoVO> response = new TransactionPageResponse<>();
response.setContent(paymentInfoVOS); response.setContent(paymentInfoVOS);
response.setPage(queryPaymentInfoDTO.getPage()); response.setPage(queryPaymentInfoDTO.getPage());
response.setSize(size); response.setSize(size);
response.setTotal(total); response.setTotal(total);
response.setPages((long) totalPage); response.setPages((long) totalPage);
response.setTotalAmount(Objects.isNull(payerTotal) ? BigDecimal.ZERO : payerTotal);
return response; return response;
} }

View File

@@ -336,7 +336,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
public List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects public List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects
, Long designId, Long designItemId, Long userId , Long designId, Long designItemId, Long userId
, JSONObject outfit, String timeZone, List<DesignSingleItemDTO> designSingleItemDTOList , JSONObject outfit, String timeZone, List<DesignSingleItemDTO> designSingleItemDTOList
, Map<String, String> categoryAndUndividedLayer , Map<String, String> priorityAndUndividedLayer
, boolean changeModelFlag , boolean changeModelFlag
, Long modelId, String modelType, boolean isSingleCollectionFlag) { , Long modelId, String modelType, boolean isSingleCollectionFlag) {
@@ -374,7 +374,14 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetail.setPriority(0); designItemDetail.setPriority(0);
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setUndividedLayer(categoryAndUndividedLayer.get(detail.getType().toLowerCase())); // designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")) designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()));
// 印花存储在design_item_detail_print表中 这里还要存吗?
// DesignPythonItemPrint printObject = detail.getPrintToPython();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
// 当有多个印花后返回的printObject太长导致存储到数据库时报错
// designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetail.setPartialDesign(Objects.isNull(detail.getPrint()) ? null : detail.getPrint().getPartial()); designItemDetail.setPartialDesign(Objects.isNull(detail.getPrint()) ? null : detail.getPrint().getPartial());
designItemDetails.add(designItemDetail); designItemDetails.add(designItemDetail);
}); });
@@ -593,13 +600,13 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
JSONObject outfit = data.getJSONObject("0"); JSONObject outfit = data.getJSONObject("0");
JSONArray layers = outfit.getJSONArray("layers"); JSONArray layers = outfit.getJSONArray("layers");
Map<String, String> categoryAndUndividedLayer = setTypeAndUndividedLayer(layers); Map<String, String> priorityAndUndividedLayer = setPriorityAndUndividedLayer(layers);
if (!designSingleIncludeLayersDTO.getIsPreview()) { if (!designSingleIncludeLayersDTO.getIsPreview()) {
// 更新及保存图层信息 // 更新及保存图层信息
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId() tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId()
, userId, outfit, designSingleIncludeLayersDTO.getTimeZone() , userId, outfit, designSingleIncludeLayersDTO.getTimeZone()
, designSingleIncludeLayersDTO.getDesignSingleItemDTOList() , designSingleIncludeLayersDTO.getDesignSingleItemDTOList()
, categoryAndUndividedLayer, changeModelFlag, modelId, modelType, isSingleCollectionFlag); , priorityAndUndividedLayer, changeModelFlag, modelId, modelType, isSingleCollectionFlag);
saveCollectionElement(designSingleIncludeLayersDTO); saveCollectionElement(designSingleIncludeLayersDTO);
} else { } else {
@@ -627,13 +634,14 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}else { }else {
updateUserLikeConvertStatus(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone()); updateUserLikeConvertStatus(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone());
} }
return assembleDesignSingleResponse(designItem.getId(), return assembleDesignSingleResponse(designItem.getId(),
minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60), minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60),
outfit.getString("synthesis_url"), outfit.getString("synthesis_url"),
designSingleIncludeLayersDTO.getDesignSingleItemDTOList(), designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),
detailsVO, detailsVO,
design.getSingleOverall(), design.getSingleOverall(),
categoryAndUndividedLayer); priorityAndUndividedLayer);
} }
// 方法1仅查询无事务 // 方法1仅查询无事务
@@ -718,15 +726,28 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
} }
@Override
public Map<String, String> setPriorityAndUndividedLayer(JSONArray layers){
HashMap<String, String> priorityAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i);
String priority = jsonObject.getString("priority");
String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !priorityAndLayer.containsKey(priority)) priorityAndLayer.put(priority, jsonObject.getString("pattern_image_url"));
}
return priorityAndLayer;
}
// 由于在design过程中没有priority 优先级的概念并且在design时不会出现上下两件使用相同服装类型的情况所以这里依然保留这个方法。
@Override @Override
public Map<String, String> setTypeAndUndividedLayer(JSONArray layers){ public Map<String, String> setTypeAndUndividedLayer(JSONArray layers){
HashMap<String, String> categoryAndLayer = new HashMap<>(); HashMap<String, String> typeAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) { for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i); JSONObject jsonObject = layers.getJSONObject(i);
String category = jsonObject.getString("image_category").split("_")[0]; String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !categoryAndLayer.containsKey(category)) categoryAndLayer.put(category, jsonObject.getString("pattern_image_url")); if (!category.equals("body") && !typeAndLayer.containsKey(category)) typeAndLayer.put(category, jsonObject.getString("pattern_image_url"));
} }
return categoryAndLayer; return typeAndLayer;
} }
@Override @Override
@@ -827,7 +848,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
List<DesignSingleItemDTO> designSingleItemDTOList, List<DesignSingleItemDTO> designSingleItemDTOList,
List<DesignPythonOutfitVO> layersObject, List<DesignPythonOutfitVO> layersObject,
String singleOrOverall, String singleOrOverall,
Map<String, String> categoryAndUndividedLayer) { Map<String, String> priorityAndUndividedLayer) {
DesignSingleVO designSingleVO = new DesignSingleVO(); DesignSingleVO designSingleVO = new DesignSingleVO();
ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>(); ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>();
@@ -865,7 +886,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
String partialDesignMinioPath = singleItem.getPartialDesign().getPartialDesignMinioPath(); String partialDesignMinioPath = singleItem.getPartialDesign().getPartialDesignMinioPath();
String preSignedUrl = StringUtil.isNullOrEmpty(partialDesignMinioPath) ? null : minioUtil.getPreSignedUrl(partialDesignMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true); String preSignedUrl = StringUtil.isNullOrEmpty(partialDesignMinioPath) ? null : minioUtil.getPreSignedUrl(partialDesignMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true);
designItemClothesDetailVO.setPartialDesign(new PartialDesignDTO(partialDesignMinioPath, preSignedUrl)); designItemClothesDetailVO.setPartialDesign(new PartialDesignDTO(partialDesignMinioPath, preSignedUrl));
if (categoryAndUndividedLayer.containsKey(singleItem.getType().toLowerCase())) designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(categoryAndUndividedLayer.get(singleItem.getType().toLowerCase()), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true));
if (priorityAndUndividedLayer.containsKey(singleItem.getPriority().toString())) designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true));
body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList())); body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList()));
clothes.add(designItemClothesDetailVO); clothes.add(designItemClothesDetailVO);

View File

@@ -838,6 +838,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
d -> Math.abs(d.getPriority()), d -> Math.abs(d.getPriority()),
(existing, replacement) -> replacement)); (existing, replacement) -> replacement));
Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers); Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers);
log.info("all typeLayers Map:{}", typeAndUndividedLayer);
for (DesignPythonItem detail : item.getItems()) { for (DesignPythonItem detail : item.getItems()) {
if (null == detail) { if (null == detail) {
continue; continue;
@@ -848,7 +849,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType().toLowerCase())); log.info("detail.getType():{}", detail.getType());
if (!detail.getType().equals("Body")){
log.info("layer : {}", typeAndUndividedLayer.get(designItemDetail.getType()));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
}
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path()); designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId //BODY不关联businessId
@@ -979,7 +984,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType().toLowerCase())); if (!detail.getType().equals("Body")){
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
}
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path()); designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId //BODY不关联businessId
@@ -2633,7 +2641,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType().toLowerCase())); if (!detail.getType().equals("Body")){
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
}
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path()); designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId //BODY不关联businessId

View File

@@ -184,8 +184,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
public void generateThroughImageText(GenerateThroughImageTextDTO generateThroughImageTextDTO) { public void generateThroughImageText(GenerateThroughImageTextDTO generateThroughImageTextDTO) {
// 1、获取用户信息 // 1、获取用户信息
Long accountId = generateThroughImageTextDTO.getUserId(); Long accountId = generateThroughImageTextDTO.getUserId();
String generateType = generateThroughImageTextDTO.getGenerateType();
GenerateModeEnum modeEnum = getMode(generateThroughImageTextDTO);
String generateType = modeEnum.getValue();
// 2、判断必须入参是否为非空(在prepare阶段已校验) // 2、判断必须入参是否为非空(在prepare阶段已校验)
Generate generate = new Generate(); Generate generate = new Generate();
generate.setAccountId(accountId); generate.setAccountId(accountId);
@@ -214,9 +215,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType()); CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType());
// 3、向模型发起请求 // 3、向模型发起请求
String mode = GenerateModeEnum.TEXT.getValue().equals(generateType) ? String mode = modeEnum.getType();
GenerateModeEnum.TEXT.getType() :
GenerateModeEnum.TEXT_IMAGE.getType();
String category = generateThroughImageTextDTO.getLevel1Type().equals(SKETCH_BOARD.getRealName()) ? "sketch" : String category = generateThroughImageTextDTO.getLevel1Type().equals(SKETCH_BOARD.getRealName()) ? "sketch" :
generateThroughImageTextDTO.getLevel1Type().equals(PRINT_BOARD.getRealName()) ? "print" : "moodboard"; generateThroughImageTextDTO.getLevel1Type().equals(PRINT_BOARD.getRealName()) ? "print" : "moodboard";
String path = CommonConstant.GENERATE_PATH; String path = CommonConstant.GENERATE_PATH;
@@ -261,7 +260,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue); jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
} }
Boolean requestResult = pythonService.generateSketchOrPrint(jsonString, port, path); Boolean requestResult = pythonService.generateSketchOrPrint(jsonString, port, path);
// 4、将请求信息落库,将本次generate的请求信息添加到t_generate表中 // 4、将请求信息落库,将本次generate的请求信息添加到t_generate表中
@@ -280,6 +278,21 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
} }
public GenerateModeEnum getMode(GenerateThroughImageTextDTO generateThroughImageTextDTO){
if (!StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getText())){
if (Objects.nonNull(generateThroughImageTextDTO.getCollectionElementId())){
return GenerateModeEnum.TEXT_IMAGE;
}else {
return GenerateModeEnum.TEXT;
}
}else {
if (Objects.nonNull(generateThroughImageTextDTO.getCollectionElementId())){
return GenerateModeEnum.IMAGE;
}
}
return GenerateModeEnum.TEXT;
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void processGenerateResult(String taskId, String url, String category) { public void processGenerateResult(String taskId, String url, String category) {
@@ -410,6 +423,10 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
prefix = userInput.substring(0, userInput.indexOf(",")) + ", "; prefix = userInput.substring(0, userInput.indexOf(",")) + ", ";
userInput = userInput.substring(userInput.indexOf(",") + 1); userInput = userInput.substring(userInput.indexOf(",") + 1);
} }
// 替换用户输入中的中文字符
log.info("用户输入,处理前:{}", userInput);
userInput = ComprehensivePunctuationConverter.convertToHalfWidth(userInput);
log.info("用户输入,处理后:{}", userInput);
String translated = prefix + pythonService.promptTranslate(userInput); String translated = prefix + pythonService.promptTranslate(userInput);
switch (level1Type) { switch (level1Type) {
case "Moodboard": case "Moodboard":
@@ -1026,7 +1043,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
// todo 取消待优化 // todo 取消待优化
uniqueIdList.forEach(uniqueId -> { uniqueIdList.forEach(uniqueId -> {
// 1、将需要取消的唯一id加入redis以便及时取消生成 // 1、将需要取消的唯一id加入redis以便及时取消生成
redisUtil.addToSet(cancelSetKey, uniqueId); redisUtil.addToSet(cancelSetKey, uniqueId, CommonConstant.REDIS_SET_EXPIRE_TIME);
/*// 1、确认当前消息是否还在排队中 /*// 1、确认当前消息是否还在排队中
Boolean exists = redisUtil.isElementExistsInZSet(consumptionOrderKey, uniqueId); Boolean exists = redisUtil.isElementExistsInZSet(consumptionOrderKey, uniqueId);
@@ -1354,12 +1371,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public GenerateResultVO modifySketch(GenerateModifyDTO generateModifyDTO) { public GenerateResultVO modifySketch(GenerateModifyDTO generateModifyDTO) {
log.info("修改生成或library中的sketch或print"); log.info("修改生成或library中的sketch或print并加入到library");
// 提取常用参数 // 提取常用参数
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
String base64 = generateModifyDTO.getBase64(); String base64 = generateModifyDTO.getBase64();
String gender = generateModifyDTO.getGender(); String gender = generateModifyDTO.getGender().toLowerCase();
String category = generateModifyDTO.getCategory(); String category = generateModifyDTO.getCategory();
Long originalId = generateModifyDTO.getOriginalId(); Long originalId = generateModifyDTO.getOriginalId();
String originalIdSource = generateModifyDTO.getOriginalIdSource(); String originalIdSource = generateModifyDTO.getOriginalIdSource();
@@ -3000,6 +3017,4 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
return null; return null;
} }
} }
} }

View File

@@ -310,6 +310,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
public PaymentInfo createOrUpdatePaymentInfoForStripe(Charge charge){ public PaymentInfo createOrUpdatePaymentInfoForStripe(Charge charge){
Stripe.apiKey = privateKey; Stripe.apiKey = privateKey;
QueryWrapper<PaymentInfo> qw = new QueryWrapper<>(); QueryWrapper<PaymentInfo> qw = new QueryWrapper<>();
// todo 首次支付失败没有invoiceId所以如果这个order之后成功支付后会有多条paymentInfo 是否需要优化??
qw.eq("transaction_id", charge.getInvoice()); qw.eq("transaction_id", charge.getInvoice());
PaymentInfo paymentInfo = baseMapper.selectOne(qw); PaymentInfo paymentInfo = baseMapper.selectOne(qw);
Charge.PaymentMethodDetails paymentMethodDetails = charge.getPaymentMethodDetails(); Charge.PaymentMethodDetails paymentMethodDetails = charge.getPaymentMethodDetails();

View File

@@ -5,6 +5,7 @@ import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.*; import com.ai.da.common.enums.*;
import com.ai.da.common.utils.DateUtil; import com.ai.da.common.utils.DateUtil;
import com.ai.da.common.utils.RedisUtil;
import com.ai.da.common.utils.SendEmailUtil; import com.ai.da.common.utils.SendEmailUtil;
import com.ai.da.mapper.primary.AccountMapper; import com.ai.da.mapper.primary.AccountMapper;
import com.ai.da.mapper.primary.PaymentInfoMapper; import com.ai.da.mapper.primary.PaymentInfoMapper;
@@ -67,7 +68,6 @@ public class StripeServiceImpl implements StripeService {
private RefundInfoService refundInfoService; private RefundInfoService refundInfoService;
@Resource @Resource
private AccountService accountService; private AccountService accountService;
@Resource @Resource
private AccountMapper accountMapper; private AccountMapper accountMapper;
@Resource @Resource
@@ -76,6 +76,8 @@ public class StripeServiceImpl implements StripeService {
private PaymentInfoMapper paymentInfoMapper; private PaymentInfoMapper paymentInfoMapper;
@Resource @Resource
private ProductCouponsMapper productCouponsMapper; private ProductCouponsMapper productCouponsMapper;
@Resource
private RedisUtil redisUtil;
@Value("${stripe.private-key}") @Value("${stripe.private-key}")
private String privateKey; private String privateKey;
@@ -374,8 +376,11 @@ public class StripeServiceImpl implements StripeService {
// 新增支付成功的信息,返回orderNo表示该回调第一次被记录 // 新增支付成功的信息,返回orderNo表示该回调第一次被记录
PaymentInfo paymentInfo = paymentInfoService.createOrUpdatePaymentInfoForStripe(invoice); PaymentInfo paymentInfo = paymentInfoService.createOrUpdatePaymentInfoForStripe(invoice);
/* 在sendEmail方法中有做判断这里的判断取消
// 当前支付没有被通知时才需要发送通知邮件 // 当前支付没有被通知时才需要发送通知邮件
if (paymentInfo.getNotified().equals(0)) { if (paymentInfo.getNotified().equals(0)) {
}*/
// 更新t_order_info中的total_fee,记录该订单的累计付款金额 // 更新t_order_info中的total_fee,记录该订单的累计付款金额
orderInfoService.updateTotalFeeByOrderNo(paymentInfo.getOrderNo()); orderInfoService.updateTotalFeeByOrderNo(paymentInfo.getOrderNo());
// 邮件通知商家和用户 // 邮件通知商家和用户
@@ -395,7 +400,7 @@ public class StripeServiceImpl implements StripeService {
} }
break; break;
} }
}
} else if (event.getType().equals("invoice.payment_failed")) { } else if (event.getType().equals("invoice.payment_failed")) {
// 更新支付信息 // 更新支付信息
QueryWrapper<PaymentInfo> queryWrapper = new QueryWrapper<>(); QueryWrapper<PaymentInfo> queryWrapper = new QueryWrapper<>();
@@ -1043,7 +1048,12 @@ public class StripeServiceImpl implements StripeService {
// 其实这里也可以通过invoiceId查询stripe但是记录在自己的db中可以不用每次都查且方便查看 // 其实这里也可以通过invoiceId查询stripe但是记录在自己的db中可以不用每次都查且方便查看
type = StringUtil.isNullOrEmpty(paymentInfo.getType()) ? "new" : paymentInfo.getType(); type = StringUtil.isNullOrEmpty(paymentInfo.getType()) ? "new" : paymentInfo.getType();
} }
if (!type.equals("reminder") && !type.equals("cancel") && paymentInfo.getNotified() == 1){
// todo 之后这种改成通过email-log来判断
String key = RedisUtil.SUBSCRIPTION_SENT_EMAIL_TYPE + subscriptionInfo.getId();
// 先判断当前订单 这个类型的邮件是否已发送过
Boolean elementExistsInSet = redisUtil.isElementExistsInSet(key, type);
if (!type.equals("reminder") && !type.equals("cancel") && paymentInfo.getNotified() == 1 && elementExistsInSet){
// 已经邮件通知过,直接返回 // 已经邮件通知过,直接返回
log.info("不发送邮件原因【type为{}order_no为{},已经进行邮件通知】", type, orderNo); log.info("不发送邮件原因【type为{}order_no为{},已经进行邮件通知】", type, orderNo);
return true; return true;
@@ -1077,6 +1087,9 @@ public class StripeServiceImpl implements StripeService {
payment.setUpdateTime(LocalDateTime.now()); payment.setUpdateTime(LocalDateTime.now());
paymentInfoMapper.updateById(payment); paymentInfoMapper.updateById(payment);
} }
// 将发成功的邮件类型存入redis 避免同一个订阅重复发送相同类型的邮件 subIdtype
redisUtil.addToSet(key, type, CommonConstant.REDIS_SET_EXPIRE_TIME);
return true; return true;
} }
@@ -1188,11 +1201,13 @@ public class StripeServiceImpl implements StripeService {
emailParamsDTO.setSubscriptionType(subscriptionInfo.getType()); emailParamsDTO.setSubscriptionType(subscriptionInfo.getType());
emailParamsDTO.setStartDate(DateUtil.changeTimeStampFormat(orderByOrderNo.getCreateTime())); emailParamsDTO.setStartDate(DateUtil.changeTimeStampFormat(orderByOrderNo.getCreateTime()));
if (subscriptionInfo.getType().equals("month")){ if (subscriptionInfo.getType().equals("month")){
emailParamsDTO.setRenewalFee(String.valueOf(500)); emailParamsDTO.setRenewalFee(String.valueOf(ProductEnum.MonthlySubscription.getPrice()));
} else if (subscriptionInfo.getType().equals("year")){ } else if (subscriptionInfo.getType().equals("year")){
emailParamsDTO.setRenewalFee(String.valueOf(5000)); emailParamsDTO.setRenewalFee(String.valueOf(ProductEnum.AnnualSubscription.getPrice()));
} else if (subscriptionInfo.getType().equals("day")){
emailParamsDTO.setRenewalFee(String.valueOf(ProductEnum.DailySubscription.getPrice()));
} else { } else {
emailParamsDTO.setRenewalFee(emailParamsDTO.getTotalFee()); emailParamsDTO.setRenewalFee("?");
} }
if (subscriptionInfo.getStatus().equals("active")){ if (subscriptionInfo.getStatus().equals("active")){
if (language.equals("ENGLISH")){ if (language.equals("ENGLISH")){
@@ -1433,8 +1448,8 @@ public class StripeServiceImpl implements StripeService {
.setDuration(CouponCreateParams.Duration.ONCE) .setDuration(CouponCreateParams.Duration.ONCE)
// percent_off 与 amount_off 不能同时设置 // percent_off 与 amount_off 不能同时设置
.setPercentOff(BigDecimal.valueOf(createCouponDTO.getPercentOff())); .setPercentOff(BigDecimal.valueOf(createCouponDTO.getPercentOff()));
if (Objects.nonNull(createCouponDTO.getTimestamp())){ if (Objects.nonNull(createCouponDTO.getEndTime())){
couponParams.setRedeemBy(createCouponDTO.getTimestamp()); couponParams.setRedeemBy(createCouponDTO.getEndTime());
} }
try { try {
// 1、创建优惠券 // 1、创建优惠券
@@ -1442,9 +1457,10 @@ public class StripeServiceImpl implements StripeService {
// 2、创建一个推广码 // 2、创建一个推广码
PromotionCode promotionCode = createPromotionCode(coupon.getId(), createCouponDTO.getMaxRedemptions()); PromotionCode promotionCode = createPromotionCode(coupon.getId(), createCouponDTO.getMaxRedemptions());
// 3、落库 // 3、落库
ProductCoupons productCoupons = new ProductCoupons(coupon.getId(), createCouponDTO.getTimestamp(), promotionCode.getId(), ProductCoupons productCoupons = new ProductCoupons(coupon.getId(), createCouponDTO.getEndTime(), promotionCode.getId(),
promotionCode.getCode(), createCouponDTO.getMaxRedemptions(), createCouponDTO.getPercentOff(), promotionCode.getCode(), createCouponDTO.getMaxRedemptions(), createCouponDTO.getPercentOff(),
createCouponDTO.getCommissionRate(), createCouponDTO.getCooperator(), createCouponDTO.getRemark()); createCouponDTO.getCommissionRate(), createCouponDTO.getCooperator(), createCouponDTO.getRemark());
productCoupons.setStartTime(createCouponDTO.getStartTime());
productCoupons.setCreateTime(LocalDateTime.now()); productCoupons.setCreateTime(LocalDateTime.now());
productCouponsMapper.insert(productCoupons); productCouponsMapper.insert(productCoupons);
@@ -1470,7 +1486,7 @@ public class StripeServiceImpl implements StripeService {
} }
} }
public ProductCoupons updateCouponsInfo(Long id, Long paidCommission, String cooperator, String remark){ public ProductCoupons updateCouponsInfo(Long id, String paidCommission, String cooperator, String remark, Long startTime){
ProductCoupons productCoupons = productCouponsMapper.selectById(id); ProductCoupons productCoupons = productCouponsMapper.selectById(id);
if (Objects.isNull(productCoupons)){ if (Objects.isNull(productCoupons)){
throw new BusinessException("Unknown Promotion Code"); throw new BusinessException("Unknown Promotion Code");
@@ -1485,7 +1501,22 @@ public class StripeServiceImpl implements StripeService {
flag = true; flag = true;
} }
if (Objects.nonNull(paidCommission)){ if (Objects.nonNull(paidCommission)){
productCoupons.setPaidCommission(paidCommission); // 将 paidCommission 从 String 转换为 BigDecimal
if (!paidCommission.matches("-?\\d+(\\.\\d+)?")) {
throw new BusinessException("Invalid paidCommission value: " + paidCommission);
}
BigDecimal paidCommissionBigDecimal = new BigDecimal(paidCommission);
// 设置已支付佣金
productCoupons.setPaidCommission(paidCommissionBigDecimal);
BigDecimal commission = Objects.isNull(productCoupons.getCommission()) ? new BigDecimal(0) : productCoupons.getCommission();
// 计算未支付佣金
BigDecimal unpaidCommission = commission.subtract(paidCommissionBigDecimal);
// 设置未支付佣金,确保其不为负数
productCoupons.setUnpaidCommission(unpaidCommission.compareTo(BigDecimal.ZERO) > 0 ? unpaidCommission : BigDecimal.ZERO);
flag = true;
}
if (Objects.nonNull(startTime)){
productCoupons.setStartTime(startTime);
flag = true; flag = true;
} }
if (flag){ if (flag){
@@ -1498,6 +1529,7 @@ public class StripeServiceImpl implements StripeService {
public ProductCoupons checkProductCoupon(String promotionCode){ public ProductCoupons checkProductCoupon(String promotionCode){
Stripe.apiKey = privateKey; Stripe.apiKey = privateKey;
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
String language = UserContext.getUserHolder().getLanguage();
// 1、从数据库查找promotionCode对应的promotionCodeId // 1、从数据库查找promotionCode对应的promotionCodeId
ProductCoupons productCoupons = productCouponsMapper.selectOne(new QueryWrapper<ProductCoupons>().eq("promotion_code", promotionCode)); ProductCoupons productCoupons = productCouponsMapper.selectOne(new QueryWrapper<ProductCoupons>().eq("promotion_code", promotionCode));
if (Objects.nonNull(productCoupons)){ if (Objects.nonNull(productCoupons)){
@@ -1506,6 +1538,11 @@ public class StripeServiceImpl implements StripeService {
Long redeemBy = productCoupons.getRedeemBy(); Long redeemBy = productCoupons.getRedeemBy();
if (redeemBy < epochSecondNow){ if (redeemBy < epochSecondNow){
throw new BusinessException("this.promotion.code.has.expired"); throw new BusinessException("this.promotion.code.has.expired");
} else if (Objects.nonNull(productCoupons.getStartTime()) && productCoupons.getStartTime() > epochSecondNow) {
String startTime = DateUtil.changeTimeStampFormat(productCoupons.getStartTime(), "seconds", CommonConstant.TIME_FORMAT_yyyy_MM_dd_HH_mm_ss);
String en = "This coupon will become active on " + startTime + ". Please try again then!";
String cn = "该优惠券尚未到生效时间,请在 " + startTime + " 后使用。";
throw new BusinessException(language.equals("ENGLISH") ? en : cn);
} else { } else {
// 判断该用户是否有成功使用过这个推广码 // 判断该用户是否有成功使用过这个推广码
List<PaymentInfo> paymentInfoByPromCode = paymentInfoService.getPaymentInfoByPromCode(accountId, promotionCode); List<PaymentInfo> paymentInfoByPromCode = paymentInfoService.getPaymentInfoByPromCode(accountId, promotionCode);
@@ -1527,6 +1564,7 @@ public class StripeServiceImpl implements StripeService {
public CheckCouponsVO checkProductCoupon(String promotionCode, Long price){ public CheckCouponsVO checkProductCoupon(String promotionCode, Long price){
Stripe.apiKey = privateKey; Stripe.apiKey = privateKey;
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
String language = UserContext.getUserHolder().getLanguage();
CheckCouponsVO checkCouponsVO = new CheckCouponsVO(); CheckCouponsVO checkCouponsVO = new CheckCouponsVO();
// 1、从数据库查找promotionCode对应的promotionCodeId // 1、从数据库查找promotionCode对应的promotionCodeId
ProductCoupons productCoupons = productCouponsMapper.selectOne(new QueryWrapper<ProductCoupons>().eq("promotion_code", promotionCode)); ProductCoupons productCoupons = productCouponsMapper.selectOne(new QueryWrapper<ProductCoupons>().eq("promotion_code", promotionCode));
@@ -1538,7 +1576,13 @@ public class StripeServiceImpl implements StripeService {
String msg = BusinessException.getMessageFromResource("this.promotion.code.has.expired"); String msg = BusinessException.getMessageFromResource("this.promotion.code.has.expired");
checkCouponsVO.setMessage(msg); checkCouponsVO.setMessage(msg);
checkCouponsVO.setStatus("expired"); checkCouponsVO.setStatus("expired");
}else { }else if (Objects.nonNull(productCoupons.getStartTime()) && productCoupons.getStartTime() > epochSecondNow) {
String startTime = DateUtil.changeTimeStampFormat(productCoupons.getStartTime(), "seconds", CommonConstant.TIME_FORMAT_yyyy_MM_dd_HH_mm_ss);
String en = "This coupon will become active on " + startTime + ". Please try again then!";
String cn = "该优惠券尚未到生效时间,请在 " + startTime + " 后使用。";
checkCouponsVO.setMessage(language.equals("ENGLISH") ? en : cn);
checkCouponsVO.setStatus("pending");
} else {
// 判断该用户是否有成功使用过这个推广码 // 判断该用户是否有成功使用过这个推广码
List<PaymentInfo> paymentInfoByPromCode = paymentInfoService.getPaymentInfoByPromCode(accountId, promotionCode); List<PaymentInfo> paymentInfoByPromCode = paymentInfoService.getPaymentInfoByPromCode(accountId, promotionCode);
if (paymentInfoByPromCode.isEmpty()) { if (paymentInfoByPromCode.isEmpty()) {

View File

@@ -50,7 +50,7 @@ access.python.port=9990
access.python.generate_sr_port=9990 access.python.generate_sr_port=9990
access.python.address=http://18.167.251.121:9990 access.python.address=http://18.167.251.121:9990
minio.endpoint=https://www.minio.aida.com.hk:12024 minio.endpoint=https://www.minio-api.aida.com.hk
minio.accessKey=admin minio.accessKey=admin
minio.secretKey=Aidlab123123! minio.secretKey=Aidlab123123!
minio.bucketName.clothing=aida-clothing minio.bucketName.clothing=aida-clothing

View File

@@ -48,6 +48,7 @@
SELECT SELECT
p.id, p.id,
a.user_name payer, a.user_name payer,
a.user_email email,
p.payment_type platform, p.payment_type platform,
p.payer_total, p.payer_total,
p.type, p.type,
@@ -149,6 +150,44 @@
AND p.transaction_id NOT LIKE 'cs_test%' AND p.transaction_id NOT LIKE 'cs_test%'
</select> </select>
<select id="queryTotalPaymentAmount" resultType="java.math.BigDecimal">
SELECT SUM(p.payer_total)
FROM t_payment_info p
LEFT JOIN t_order_info o ON p.order_no = o.order_no
LEFT JOIN t_account a ON a.id = o.account_id
WHERE 1 = 1
<if test="paymentType != null and paymentType != ''">
AND p.payment_type = #{paymentType}
</if>
<if test="payerTotal != null and payerTotal != ''">
AND p.payer_total = #{payerTotal}
</if>
<if test="type != null and type != ''">
AND p.type = #{type}
</if>
<if test="status != null and status != ''">
AND
CASE
WHEN p.trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
WHEN p.trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
ELSE 'Pending'
END = #{status}
</if>
<if test="country != null and country != ''">
AND p.country = #{country}
</if>
<if test="city != null and city != ''">
AND p.city = #{city}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND p.create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if test="payer != null and payer != ''">
AND a.user_name = #{payer}
</if>
AND p.transaction_id NOT LIKE 'cs_test%'
</select>
<select id="getCities" resultType="java.util.Map"> <select id="getCities" resultType="java.util.Map">
SELECT DISTINCT city SELECT DISTINCT city
FROM t_payment_info FROM t_payment_info