|
|
@@ -4,6 +4,7 @@ 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 cn.hutool.json.JSONUtil;
|
|
|
import com.alipay.api.AlipayClient;
|
|
|
import com.alipay.api.domain.AlipayTradeRefundModel;
|
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
|
@@ -112,21 +113,28 @@ public class RegisterOrderDonServiceImpl extends ServiceImpl<RegisterOrderDonMap
|
|
|
* @date 2022-11-07 3:34 PM
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean isFree(long userId, String platform) {
|
|
|
+ public boolean isFree(long userId, String platform, String code) {
|
|
|
+ if (StringUtils.isBlank(code)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
int count = count(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
.eq(RegisterOrderDon::getUserId, userId)
|
|
|
- .ne(RegisterOrderDon::getStatus, RegisterOrderDon.Status.noPayment)
|
|
|
+ .notIn(RegisterOrderDon::getStatus, List.of(RegisterOrderDon.Status.noPayment, RegisterOrderDon.Status.error))
|
|
|
.eq(RegisterOrderDon::getIsFree, true));
|
|
|
if(count > 0){
|
|
|
- return false;
|
|
|
+ throw BusinessRuntimeException.getInstance("您已使用过注册码进行注册过啦,如需再次注册请清除注册码再提交哦");
|
|
|
}
|
|
|
- Long num = redisService.decr(RedisKey.SPOTIFY_FREE_NUM, 1L);
|
|
|
- if(num >= 0){
|
|
|
- return true;
|
|
|
+ SysConfig sysConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, "spotify_free_code"));
|
|
|
+ if (sysConfig == null) {
|
|
|
+ return false;
|
|
|
}else {
|
|
|
- redisService.incr(RedisKey.SPOTIFY_FREE_NUM, 1L);
|
|
|
+ if (JSONUtil.isJsonArray(sysConfig.getSysValue())) {
|
|
|
+ List<String> list = JSONUtil.parseArray(sysConfig.getSysValue()).toList(String.class);
|
|
|
+ return list.contains(code);
|
|
|
+ }else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
/**
|