|
|
|
@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.bnyer.common.core.utils.StringUtils; |
|
|
|
import com.bnyer.common.redis.service.RedisService; |
|
|
|
import com.bnyer.img.domain.CreatorProfit; |
|
|
|
import com.bnyer.img.domain.InviteLog; |
|
|
|
import com.bnyer.img.dto.CreatorProfitPageDto; |
|
|
|
import com.bnyer.img.dto.ProfitInOrOutDto; |
|
|
|
import com.bnyer.img.dto.ProfitInOrEndDto; |
|
|
|
import com.bnyer.img.mapper.CreatorProfitMapper; |
|
|
|
import com.bnyer.img.mapper.InviteLogMapper; |
|
|
|
import com.bnyer.img.service.CreatorProfitService; |
|
|
|
import com.bnyer.img.service.InviteLogService; |
|
|
|
import com.bnyer.img.service.TiktokImgService; |
|
|
|
import com.bnyer.img.vo.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -16,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
@ -33,15 +38,12 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
@Autowired |
|
|
|
private TiktokImgService tiktokImgService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InviteLogMapper inviteLogMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean checkCreatorProfitExist(Long creatorId, Long imgId,String appType,String platform, String date) { |
|
|
|
LambdaQueryWrapper<CreatorProfit> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(CreatorProfit::getCreatorId, creatorId); |
|
|
|
wrapper.eq(CreatorProfit::getImgId, imgId); |
|
|
|
wrapper.eq(CreatorProfit::getAppType, appType); |
|
|
|
wrapper.eq(CreatorProfit::getPlatform,platform); |
|
|
|
wrapper.eq(CreatorProfit::getCreateTime, date); |
|
|
|
CreatorProfit creatorProfit = creatorProfitMapper.selectOne(wrapper); |
|
|
|
public boolean checkCreatorProfitExist(Long creatorId, Long imgId,String appType,String platform,String type, String date) { |
|
|
|
CreatorProfit creatorProfit = creatorProfitMapper.checkCreatorProfitExist(creatorId, imgId, appType, platform,type, date); |
|
|
|
if(creatorProfit != null){ |
|
|
|
return false; |
|
|
|
}else{ |
|
|
|
@ -52,19 +54,79 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int insertCreatorProfit(CreatorProfit creatorProfit) { |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
long times = System.currentTimeMillis(); |
|
|
|
String date = format.format(times); |
|
|
|
//检查收益表是否存在广告记录,存在则更新次数
|
|
|
|
boolean b = this.checkCreatorProfitExist(creatorProfit.getCreatorId(),creatorProfit.getImgId(),creatorProfit.getAppType(),creatorProfit.getPlatform(),"0",date); |
|
|
|
if(b){ |
|
|
|
int update = this.updateCreatorProfitDownloadNum(creatorProfit.getCreatorId(), creatorProfit.getImgId(), creatorProfit.getAppType(), creatorProfit.getPlatform(),"0", date); |
|
|
|
log.info("更新日期【{}】艺术家【{}】图片【{}】应用【{}】平台【{}】收益下载次数+1",date,creatorProfit.getCreatorId(), creatorProfit.getImgId(), creatorProfit.getAppType(), creatorProfit.getPlatform()); |
|
|
|
return update; |
|
|
|
} |
|
|
|
//不存在则新增广告记录
|
|
|
|
creatorProfit.setCreateTime(new Date()); |
|
|
|
creatorProfit.setUpdateTime(new Date()); |
|
|
|
creatorProfit.setType("0"); |
|
|
|
creatorProfit.setStatus("0"); |
|
|
|
creatorProfit.setIsShow("1"); |
|
|
|
creatorProfit.setSort(0); |
|
|
|
creatorProfit.setDownloadNum(1); |
|
|
|
return creatorProfitMapper.insert(creatorProfit); |
|
|
|
int insert = creatorProfitMapper.insert(creatorProfit); |
|
|
|
log.info("新增艺术家【{}】图片【{}】应用【{}】平台【{}】收益记录",creatorProfit.getCreatorId(), creatorProfit.getImgId(), creatorProfit.getAppType(), creatorProfit.getPlatform()); |
|
|
|
return insert; |
|
|
|
} |
|
|
|
|
|
|
|
private void batchUpdateDownload(List<CreatorProfit> list){ |
|
|
|
creatorProfitMapper.batchUpdateDownload(list); |
|
|
|
} |
|
|
|
|
|
|
|
private void batchInsertInviteProfit(List<CreatorProfit> list){ |
|
|
|
creatorProfitMapper.batchInsertInviteProfit(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int insertInvitedProfit(CreatorProfit creatorProfit) { |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
long times = System.currentTimeMillis(); |
|
|
|
String date = format.format(times); |
|
|
|
//查询邀请表
|
|
|
|
LambdaQueryWrapper<InviteLog> wrapper = new LambdaQueryWrapper<InviteLog>(); |
|
|
|
wrapper.eq(InviteLog::getInvitedCreatorId, creatorProfit.getCreatorId()); |
|
|
|
List<InviteLog> inviteLogs = inviteLogMapper.selectList(wrapper); |
|
|
|
if(inviteLogs.size() > 0){ |
|
|
|
List<Long> updateList = new ArrayList<>(); |
|
|
|
List<Long> insertList = new ArrayList<>(); |
|
|
|
for (InviteLog inviteLog : inviteLogs) { |
|
|
|
//检查收益表是否存在邀请记录,存在则记录更新邀请者Id
|
|
|
|
boolean b = this.checkCreatorProfitExist(inviteLog.getCreatorId(),creatorProfit.getImgId(),creatorProfit.getAppType(),creatorProfit.getPlatform(),"1",date); |
|
|
|
if(b){ |
|
|
|
updateList.add(inviteLog.getCreatorId()); |
|
|
|
} |
|
|
|
//不存在则新增邀请者id
|
|
|
|
insertList.add(inviteLog.getCreatorId()); |
|
|
|
// creatorProfit.setCreatorId(inviteLog.getCreatorId());
|
|
|
|
// creatorProfit.setCreateTime(new Date());
|
|
|
|
// creatorProfit.setUpdateTime(new Date());
|
|
|
|
// creatorProfit.setType("1");
|
|
|
|
// creatorProfit.setStatus("0");
|
|
|
|
// creatorProfit.setIsShow("1");
|
|
|
|
// creatorProfit.setSort(0);
|
|
|
|
// creatorProfit.setDownloadNum(1);
|
|
|
|
} |
|
|
|
//批量更新邀请记录
|
|
|
|
|
|
|
|
//批量新增邀请记录
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int updateCreatorProfitDownloadNum(Long creatorId, Long imgId, String appType, String platform, String date) { |
|
|
|
return creatorProfitMapper.updateDownloadNum(creatorId,imgId,appType,platform,date); |
|
|
|
public int updateCreatorProfitDownloadNum(Long creatorId, Long imgId, String appType, String platform,String type, String date) { |
|
|
|
return creatorProfitMapper.updateDownloadNum(creatorId,imgId,appType,platform,type,date); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -168,32 +230,44 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CreatorProfitCountVo> queryFrontPreCreatorProfitCount(Long creatorId) { |
|
|
|
return creatorProfitMapper.queryFrontPreCreatorProfitCount(creatorId); |
|
|
|
public CreatorProfitPreCountVo queryFrontPreDownloadAndInviteCount(Long creatorId) { |
|
|
|
//下载收益
|
|
|
|
List<CreatorProfitDownloadCountVo> creatorProfitDownloadCountVos = creatorProfitMapper.queryFrontPreDownloadCount(creatorId); |
|
|
|
//邀请收益
|
|
|
|
List<CreatorProfitInviteCountVo> creatorProfitInviteCountVos = creatorProfitMapper.queryFrontPreInviteCount(creatorId); |
|
|
|
CreatorProfitPreCountVo result = new CreatorProfitPreCountVo(); |
|
|
|
result.setCreatorProfitDownloadCount(creatorProfitDownloadCountVos); |
|
|
|
result.setCreatorProfitInviteCount(creatorProfitInviteCountVos); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CreatorProfitPreAdVo> queryFrontPreAdCreatorProfit(Long creatorId) { |
|
|
|
return creatorProfitMapper.queryFrontPreAdCreatorProfit(creatorId); |
|
|
|
public List<CreatorProfitPreVo> queryFrontPreProfit(Long creatorId,String type) { |
|
|
|
return creatorProfitMapper.queryFrontPreProfit(creatorId,type); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public CreatorProfitInAmtVo queryFrontInOrOutProfitAmt(ProfitInOrOutDto params) { |
|
|
|
return creatorProfitMapper.queryFrontInOrOutProfitAmt(params); |
|
|
|
public CreatorProfitInAmtCountVo queryFrontInOrEndProfitAmt(ProfitInOrEndDto params) { |
|
|
|
BigDecimal adAmt = creatorProfitMapper.queryFrontInOrEndAdAmt(params); |
|
|
|
BigDecimal inviteAmt = creatorProfitMapper.queryFrontInOrEndInviteAmt(params); |
|
|
|
CreatorProfitInAmtCountVo result = new CreatorProfitInAmtCountVo(); |
|
|
|
result.setProfit(adAmt); |
|
|
|
result.setInviteProfit(inviteAmt); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CreatorProfitInAdAmtVo> queryFrontInAdProfitAmt(Long creatorId) { |
|
|
|
return creatorProfitMapper.queryFrontInAdProfitAmt(creatorId); |
|
|
|
public List<CreatorProfitInAmtVo> queryFrontInProfitAmt(Long creatorId, String type) { |
|
|
|
return creatorProfitMapper.queryFrontInProfitAmt(creatorId,type); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public CreatorProfitInAdAmtVo queryFrontInAdProfitAmtDetails(Long id) { |
|
|
|
return creatorProfitMapper.queryFrontInAdProfitAmtDetails(id); |
|
|
|
public CreatorProfitInAmtVo queryFrontInProfitAmtDetails(Long id) { |
|
|
|
return creatorProfitMapper.queryFrontInProfitAmtDetails(id); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CreatorProfitEndAdAmtVo> queryFrontEndAdProfitAmt(Long creatorId) { |
|
|
|
return creatorProfitMapper.queryFrontEndAdProfitAmt(creatorId); |
|
|
|
public List<CreatorProfitEndAmtVo> queryFrontEndProfitAmt(Long creatorId, String type) { |
|
|
|
return creatorProfitMapper.queryFrontEndProfitAmt(creatorId,type); |
|
|
|
} |
|
|
|
} |
|
|
|
|