|
@@ -2,6 +2,7 @@ package com.cyksj.service.register.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
@@ -12,28 +13,23 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
import com.cyksj.common.constant.TemplateEnum;
|
|
import com.cyksj.common.constant.TemplateEnum;
|
|
|
-import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
|
|
import com.cyksj.common.util.Jsons;
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.RedisKey;
|
|
import com.cyksj.dto.RedisKey;
|
|
|
import com.cyksj.mapper.ProxysMapper;
|
|
import com.cyksj.mapper.ProxysMapper;
|
|
|
import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
-import com.cyksj.mapper.manage.coupon.CouponUserMapper;
|
|
|
|
|
import com.cyksj.model.dto.WxMpTemplateData;
|
|
import com.cyksj.model.dto.WxMpTemplateData;
|
|
|
import com.cyksj.model.dto.WxMpTemplateMessage;
|
|
import com.cyksj.model.dto.WxMpTemplateMessage;
|
|
|
-import com.cyksj.model.entity.Coupon;
|
|
|
|
|
-import com.cyksj.model.entity.CouponUser;
|
|
|
|
|
-import com.cyksj.model.entity.Proxys;
|
|
|
|
|
-import com.cyksj.model.entity.RegisterOrderDon;
|
|
|
|
|
|
|
+import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.response.ProxyInfo;
|
|
import com.cyksj.model.response.ProxyInfo;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
-import com.cyksj.service.coupon.CouponFontService;
|
|
|
|
|
|
|
+import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
import com.cyksj.service.register.SpotifyService;
|
|
import com.cyksj.service.register.SpotifyService;
|
|
|
|
|
+import com.cyksj.service.sys.SysConfigService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
@@ -62,9 +58,9 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
|
|
|
|
|
private final CouponMapper couponMapper;
|
|
private final CouponMapper couponMapper;
|
|
|
|
|
|
|
|
- private final CouponUserMapper couponUserMapper;
|
|
|
|
|
|
|
+ private final CouponCommonService couponCommonService;
|
|
|
|
|
|
|
|
- private final CouponFontService couponFontService;
|
|
|
|
|
|
|
+ private final SysConfigService sysConfigService;
|
|
|
|
|
|
|
|
private static final List<String> User_Agent_LIST = List.of(
|
|
private static final List<String> User_Agent_LIST = List.of(
|
|
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
|
@@ -263,25 +259,12 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
//已经拥有声破天年费的不用发
|
|
//已经拥有声破天年费的不用发
|
|
|
Integer exists = registerOrderDonMapper.isPaySpotifyYearTicket(registerOrderDon.getUserId());
|
|
Integer exists = registerOrderDonMapper.isPaySpotifyYearTicket(registerOrderDon.getUserId());
|
|
|
if (exists == null) {
|
|
if (exists == null) {
|
|
|
- //领取过的也不用再次发送
|
|
|
|
|
- Coupon spotifyCoupon = couponMapper.getCouponById(2l);
|
|
|
|
|
- if (spotifyCoupon != null) {
|
|
|
|
|
- CouponUser couponUser = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, registerOrderDon.getUserId()).eq(CouponUser::getCouponId, spotifyCoupon.getId()).select(CouponUser::getId).last("limit 1"));
|
|
|
|
|
- if (couponUser == null) {
|
|
|
|
|
- couponUser = new CouponUser();
|
|
|
|
|
- couponUser.setUserId(registerOrderDon.getUserId());
|
|
|
|
|
- couponUser.setCouponId(spotifyCoupon.getId());
|
|
|
|
|
- //领券中心
|
|
|
|
|
- couponUser.setChannel(CouponUser.Channel.manual);
|
|
|
|
|
- couponUser.setStatus(CouponUser.Status.unused);
|
|
|
|
|
- //优惠券有效时间
|
|
|
|
|
- couponFontService.updateCouponUserValidTime(spotifyCoupon.getId(), couponUser);
|
|
|
|
|
- try {
|
|
|
|
|
- couponUserMapper.insert(couponUser);
|
|
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
|
|
- log.info("用户:{}重复领取声破天优惠券{}插入数据错误", registerOrderDon.getId(), spotifyCoupon.getId());
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("已领取成功");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ SysConfig spotify_register_success_cid = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, "spotify_register_success_cid").last("limit 1"));
|
|
|
|
|
+ if (spotify_register_success_cid != null && StrUtil.isNotBlank(spotify_register_success_cid.getSysValue())) {
|
|
|
|
|
+ Long spotifyRegisterSucCid = Long.parseLong(spotify_register_success_cid.getSysValue());
|
|
|
|
|
+ Coupon coupon = couponMapper.selectById(spotifyRegisterSucCid);
|
|
|
|
|
+ if (coupon != null) {
|
|
|
|
|
+ couponCommonService.sendCouponToUser(registerOrderDon.getUserId(), spotifyRegisterSucCid, null, null, null, CouponUser.Channel.manual);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|