Merge branch 'dev/dev_xp' into dev/dev

This commit is contained in:
2025-04-28 14:56:48 +08:00

View File

@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson;
import com.stripe.Stripe;
import com.stripe.exception.InvalidRequestException;
import com.stripe.exception.SignatureVerificationException;
import com.stripe.exception.StripeException;
import com.stripe.model.*;
@@ -1171,6 +1172,13 @@ public class StripeServiceImpl implements StripeService {
emailParamsDTO.setFailMessage(orderByOrderNo.getNote());
emailParamsDTO.setSubscriptionType(subscriptionInfo.getType());
emailParamsDTO.setStartDate(DateUtil.changeTimeStampFormat(orderByOrderNo.getCreateTime()));
if (subscriptionInfo.getType().equals("month")){
emailParamsDTO.setRenewalFee(String.valueOf(500));
} else if (subscriptionInfo.getType().equals("year")){
emailParamsDTO.setRenewalFee(String.valueOf(5000));
} else {
emailParamsDTO.setRenewalFee(emailParamsDTO.getTotalFee());
}
if (subscriptionInfo.getStatus().equals("active")){
if (language.equals("ENGLISH")){
emailParamsDTO.setEndDate("When cancelled");
@@ -1408,6 +1416,7 @@ public class StripeServiceImpl implements StripeService {
CouponCreateParams.Builder couponParams = CouponCreateParams.builder()
// 任何客户只能用一次这个优惠券
.setDuration(CouponCreateParams.Duration.ONCE)
// percent_off 与 amount_off 不能同时设置
.setPercentOff(BigDecimal.valueOf(createCouponDTO.getPercentOff()));
if (Objects.nonNull(createCouponDTO.getTimestamp())){
couponParams.setRedeemBy(createCouponDTO.getTimestamp());
@@ -1605,4 +1614,22 @@ public class StripeServiceImpl implements StripeService {
return productCouponsMapper.selectPage(new Page<>(queryCouponsPageDTO.getPage(), queryCouponsPageDTO.getSize()), queryWrapper);
}
@Transactional
public void deleteCoupon(Long id){
Stripe.apiKey = privateKey;
ProductCoupons productCoupons = productCouponsMapper.selectById(id);
if (Objects.isNull(productCoupons)){
throw new BusinessException("unknown promotion code");
}
try {
Coupon coupon = Coupon.retrieve(productCoupons.getCouponId());
coupon.delete();
log.info("coupon {} 删除成功", productCoupons.getCouponId());
productCouponsMapper.deleteById(id);
} catch (StripeException e) {
log.error("未知coupons,无法通过couponId: {} 获得Coupons", productCoupons.getCouponId());
}
}
}