@@ -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.*;
|
||||
@@ -1148,6 +1149,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");
|
||||
@@ -1385,6 +1393,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());
|
||||
@@ -1582,4 +1591,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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user