Browse Source

feature-1.0-img: 调整用户下载检测逻辑

feature-1.0-img-prototype
penny 4 years ago
parent
commit
649f3b8f04
  1. 2
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java
  2. 10
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java
  3. 3
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java
  4. 9
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/CreatorProfitService.java
  5. 9
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java
  6. 9
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java
  7. 9
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java
  8. 20
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java
  9. 21
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java
  10. 21
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java
  11. 21
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java

2
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java

@ -210,7 +210,7 @@ public class FhMiniController extends BaseController {
@PostMapping(value = "/checkUserCanDownload") @PostMapping(value = "/checkUserCanDownload")
public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){ public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
log.debug("【快手图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto)); log.debug("【快手图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto));
return AjaxResult.success(creatorProfitService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType())); return AjaxResult.success(fhUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
} }
//@TokenCheck //@TokenCheck

10
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java

@ -1,9 +1,7 @@
package com.bnyer.img.controller; package com.bnyer.img.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bnyer.common.core.exception.ServiceException;
import com.bnyer.common.core.web.controller.BaseController; import com.bnyer.common.core.web.controller.BaseController;
import com.bnyer.common.core.web.domain.AjaxResult; import com.bnyer.common.core.web.domain.AjaxResult;
import com.bnyer.common.core.web.page.TableDataInfo; import com.bnyer.common.core.web.page.TableDataInfo;
@ -11,7 +9,10 @@ import com.bnyer.img.constants.TiktokConstant;
import com.bnyer.img.domain.Feedback; import com.bnyer.img.domain.Feedback;
import com.bnyer.img.dto.*; import com.bnyer.img.dto.*;
import com.bnyer.img.service.*; import com.bnyer.img.service.*;
import com.bnyer.img.vo.*; import com.bnyer.img.vo.CreatorDetailsVo;
import com.bnyer.img.vo.CreatorVo;
import com.bnyer.img.vo.SignImgVo;
import com.bnyer.img.vo.TiktokImgVo;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -21,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -213,7 +213,7 @@ public class TiktokMiniController extends BaseController {
@PostMapping(value = "/checkUserCanDownload") @PostMapping(value = "/checkUserCanDownload")
public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){ public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
log.debug("【抖音图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto)); log.debug("【抖音图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto));
return AjaxResult.success(creatorProfitService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType())); return AjaxResult.success(tiktokUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
} }
//@TokenCheck //@TokenCheck

3
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java

@ -2,7 +2,6 @@ package com.bnyer.img.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bnyer.common.core.domain.R;
import com.bnyer.common.core.web.controller.BaseController; import com.bnyer.common.core.web.controller.BaseController;
import com.bnyer.common.core.web.domain.AjaxResult; import com.bnyer.common.core.web.domain.AjaxResult;
import com.bnyer.common.core.web.page.TableDataInfo; import com.bnyer.common.core.web.page.TableDataInfo;
@ -211,7 +210,7 @@ public class WxMiniController extends BaseController {
@PostMapping(value = "/checkUserCanDownload") @PostMapping(value = "/checkUserCanDownload")
public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){ public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
log.debug("【微信图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto)); log.debug("【微信图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto));
return AjaxResult.success(creatorProfitService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType())); return AjaxResult.success(wxUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
} }
//@TokenCheck //@TokenCheck

9
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/CreatorProfitService.java

@ -179,15 +179,6 @@ public interface CreatorProfitService {
*/ */
int batchUpdate(List<Long> list); int batchUpdate(List<Long> list);
/**
* 检查某平台用户当日下载次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanDownload(Long userId,String platform,String appType);
/** /**
* 查询转入钱包收益详情 * 查询转入钱包收益详情
* @param id 收益id * @param id 收益id

9
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java

@ -51,4 +51,13 @@ public interface FhUserService {
* @return - * @return -
*/ */
int changeStatus(Long id,String status); int changeStatus(Long id,String status);
/**
* 检查某平台用户当日下载次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanDownload(Long userId,String platform,String appType);
} }

9
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java

@ -50,4 +50,13 @@ public interface TiktokUserService {
* @return - * @return -
*/ */
int changeStatus(Long id,String status); int changeStatus(Long id,String status);
/**
* 检查某平台用户当日下载次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanDownload(Long userId,String platform,String appType);
} }

9
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java

@ -51,4 +51,13 @@ public interface WxUserService {
* @return - * @return -
*/ */
int changeStatus(Long id,String status); int changeStatus(Long id,String status);
/**
* 检查某平台用户当日下载次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanDownload(Long userId,String platform,String appType);
} }

20
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java

@ -360,26 +360,6 @@ public class CreatorProfitServiceImpl implements CreatorProfitService {
return creatorProfitMapper.batchUpdateTransInfo(list); return creatorProfitMapper.batchUpdateTransInfo(list);
} }
@Override
public boolean checkUserCanDownload(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
String redisKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(redisKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(redisKey, hashKey);
if(downloadNum >= 5){
return true;
}else{
return false;
}
}else{
//不存在键则可下载
return false;
}
}
@Override @Override
public CreatorProfitEndAmtVo queryFrontEndAmtDetails(Long id) { public CreatorProfitEndAmtVo queryFrontEndAmtDetails(Long id) {
return creatorProfitMapper.queryFrontEndAmtDetails(id); return creatorProfitMapper.queryFrontEndAmtDetails(id);

21
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java

@ -31,6 +31,7 @@ import org.springframework.web.client.RestTemplate;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -201,4 +202,24 @@ public class FhUserServiceImpl implements FhUserService {
user.setIsShow(status); user.setIsShow(status);
return fhUserMapper.update(user, wrapper); return fhUserMapper.update(user, wrapper);
} }
@Override
public boolean checkUserCanDownload(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
String redisKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(redisKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(redisKey, hashKey);
if(downloadNum >= 5){
return true;
}else{
return false;
}
}else{
//不存在键则可下载
return false;
}
}
} }

21
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java

@ -32,6 +32,7 @@ import javax.annotation.Resource;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -210,4 +211,24 @@ public class TiktokUserServiceImpl implements TiktokUserService {
user.setIsShow(status); user.setIsShow(status);
return tiktokUserMapper.update(user,wrapper); return tiktokUserMapper.update(user,wrapper);
} }
@Override
public boolean checkUserCanDownload(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
String redisKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(redisKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(redisKey, hashKey);
if(downloadNum >= 5){
return true;
}else{
return false;
}
}else{
//不存在键则可下载
return false;
}
}
} }

21
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java

@ -31,6 +31,7 @@ import org.springframework.web.client.RestTemplate;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -212,4 +213,24 @@ public class WxUserServiceImpl implements WxUserService {
user.setIsShow(status); user.setIsShow(status);
return wxUserMapper.update(user, wrapper); return wxUserMapper.update(user, wrapper);
} }
@Override
public boolean checkUserCanDownload(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
String redisKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(redisKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(redisKey, hashKey);
if(downloadNum >= 5){
return true;
}else{
return false;
}
}else{
//不存在键则可下载
return false;
}
}
} }

Loading…
Cancel
Save