|
|
@@ -1,6 +1,7 @@
|
|
|
package com.cyksj.service.register.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@@ -183,31 +184,60 @@ public class RegisterOrderDonServiceImpl extends ServiceImpl<RegisterOrderDonMap
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CouponUserView spotifyUnLimit(SpotifyUnLimitRecord spotifyUnLimitRecord) {
|
|
|
+ RegisterOrderDon registerOrderDon = this.getOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
+ .eq(RegisterOrderDon::getUserId, spotifyUnLimitRecord.getUserId())
|
|
|
+ .eq(RegisterOrderDon::getEmail, spotifyUnLimitRecord.getAccount())
|
|
|
+ .eq(RegisterOrderDon::getPlatform, "spotify")
|
|
|
+ .eq(RegisterOrderDon::getStatus, RegisterOrderDon.Status.complete)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (registerOrderDon == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("仅接受银河录像局注册成功的Spotify邮箱");
|
|
|
+ }
|
|
|
+ Boolean isFlag = false;
|
|
|
+ Long spotifyUnLimitCouponId = null;
|
|
|
+ //是否配置了优惠券
|
|
|
+ SysConfig spotify_unLimit_cid = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, "spotify_unLimit_cid").last("limit 1"));
|
|
|
+ if (spotify_unLimit_cid != null && StrUtil.isNotBlank(spotify_unLimit_cid.getSysValue())) {
|
|
|
+ spotifyUnLimitCouponId = Long.parseLong(spotify_unLimit_cid.getSysValue());
|
|
|
+ Coupon coupon = couponMapper.selectById(spotifyUnLimitCouponId);
|
|
|
+ if (coupon != null) {
|
|
|
+ isFlag = couponCommonService.sendCouponToUser(spotifyUnLimitRecord.getUserId(), spotifyUnLimitCouponId, null, null, null, CouponUser.Channel.manual);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //14天内是否重复提交过该账号
|
|
|
+ SpotifyUnLimitRecord exists = spotifyUnLimitRecordMapper.selectOne(Wrappers.lambdaQuery(SpotifyUnLimitRecord.class)
|
|
|
+ .eq(SpotifyUnLimitRecord::getUserId, spotifyUnLimitRecord.getUserId())
|
|
|
+ .eq(SpotifyUnLimitRecord::getAccount, spotifyUnLimitRecord.getAccount())
|
|
|
+ .gt(SpotifyUnLimitRecord::getCreatedTime, DateUtil.offsetDay(DateTime.now(), -14))
|
|
|
+ .last("limit 1"));
|
|
|
+ if (exists != null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("您已提交过,请勿重复提交");
|
|
|
+ }
|
|
|
+ spotifyUnLimitRecordMapper.insert(spotifyUnLimitRecord);
|
|
|
+ return isFlag ? beanSearcher.searchFirst(CouponUserView.class, MapUtils.builder()
|
|
|
+ .field(CouponUserView::getUserId, spotifyUnLimitRecord.getUserId()).op(Operator.Equal)
|
|
|
+ .field(CouponUserView::getCouponId, spotifyUnLimitCouponId).op(Operator.Equal)
|
|
|
+ .build()) : null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public CouponUserView spotifyUnLimit(SpotifyUnLimitRecord spotifyUnLimitRecord) {
|
|
|
- RegisterOrderDon registerOrderDon = this.getOne(Wrappers.lambdaQuery(RegisterOrderDon.class).eq(RegisterOrderDon::getUserId, spotifyUnLimitRecord.getUserId()).eq(RegisterOrderDon::getEmail, spotifyUnLimitRecord.getAccount()).select(RegisterOrderDon::getPassword, RegisterOrderDon::getUsername).last("limit 1"));
|
|
|
- if (registerOrderDon == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("仅接受银河录像局注册成功的Spotify邮箱");
|
|
|
- }
|
|
|
- if (registerOrderDon.getStatus() != RegisterOrderDon.Status.complete) {
|
|
|
- throw BusinessRuntimeException.getInstance("您的Spotify账号暂未注册成功");
|
|
|
- }
|
|
|
- Boolean isFlag = false;
|
|
|
- Long spotifyCouponId = null;
|
|
|
- //是否配置了优惠券
|
|
|
- SysConfig spotify_coupon_id = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, "spotify_coupon_id").last("limit 1"));
|
|
|
- if (spotify_coupon_id != null) {
|
|
|
- spotifyCouponId = Long.parseLong(spotify_coupon_id.getSysValue());
|
|
|
- Coupon coupon = couponMapper.selectById(spotifyCouponId);
|
|
|
- if (coupon != null) {
|
|
|
- isFlag = couponCommonService.sendCouponToUser(spotifyUnLimitRecord.getUserId(), spotifyCouponId, null, null, null, CouponUser.Channel.manual);
|
|
|
- }
|
|
|
+ public CouponUserView getAvailableSpotifyCoupon(long userId) {
|
|
|
+ SysConfig spotify_register_success_cid = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, "spotify_register_success_cid").last("limit 1"));
|
|
|
+ CouponUserView couponUserView = null;
|
|
|
+ if (spotify_register_success_cid != null && StrUtil.isNotBlank(spotify_register_success_cid.getSysValue())) {
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ Long spotifyRegisterSucCid = Long.parseLong(spotify_register_success_cid.getSysValue());
|
|
|
+ couponUserView = beanSearcher.searchFirst(CouponUserView.class, MapUtils.builder()
|
|
|
+ .field(CouponUserView::getUserId, userId).op(Operator.Equal)
|
|
|
+ .field(CouponUserView::getCouponId, spotifyRegisterSucCid).op(Operator.Equal)
|
|
|
+ .field(CouponUserView::getCouponUserStatus, CouponUser.Status.unused.name()).op(Operator.Equal)
|
|
|
+ .field(CouponUserView::getValidStartTime, now).op(Operator.LessThan)
|
|
|
+ .field(Coupon::getValidEndTime, now).op(Operator.GreaterThan)
|
|
|
+ .build());
|
|
|
}
|
|
|
- spotifyUnLimitRecordMapper.insert(spotifyUnLimitRecord);
|
|
|
- return isFlag ? beanSearcher.searchFirst(CouponUserView.class, MapUtils.builder()
|
|
|
- .field(CouponUserView::getUserId, spotifyUnLimitRecord.getUserId()).op(Operator.Equal)
|
|
|
- .field(CouponUserView::getCouponId, spotifyCouponId).op(Operator.Equal)
|
|
|
- .build()) : null;
|
|
|
+ return couponUserView;
|
|
|
}
|
|
|
|
|
|
@Override
|