|
|
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.bnyer.common.redis.service.RedisService; |
|
|
|
import com.bnyer.img.domain.CreatorProfit; |
|
|
|
import com.bnyer.img.domain.InviteLog; |
|
|
|
import com.bnyer.img.dto.BatchUpdateInviteDto; |
|
|
|
import com.bnyer.img.dto.CreatorProfitPageDto; |
|
|
|
import com.bnyer.img.dto.ProfitInOrEndDto; |
|
|
|
import com.bnyer.img.mapper.CreatorProfitMapper; |
|
|
|
@ -15,7 +14,6 @@ import com.bnyer.img.service.CreatorProfitService; |
|
|
|
import com.bnyer.img.service.TiktokImgService; |
|
|
|
import com.bnyer.img.vo.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.ibatis.annotations.Param; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -43,8 +41,8 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
private InviteLogMapper inviteLogMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
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); |
|
|
|
public boolean checkCreatorProfitExist(String mark) { |
|
|
|
CreatorProfit creatorProfit = creatorProfitMapper.checkCreatorProfitExist(mark); |
|
|
|
if(creatorProfit != null){ |
|
|
|
return true; |
|
|
|
}else{ |
|
|
|
@ -58,13 +56,15 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
long times = System.currentTimeMillis(); |
|
|
|
String date = format.format(times); |
|
|
|
String mark = creatorProfit.getCreatorId()+creatorProfit.getImgId()+creatorProfit.getAppType()+creatorProfit.getPlatform()+ |
|
|
|
"0"+date.replace("-",""); |
|
|
|
//缓存中下载总数+1
|
|
|
|
tiktokImgService.writeDownloadTotalNum(creatorProfit.getAppType(),creatorProfit.getPlatform()); |
|
|
|
//检查收益表是否存在广告记录,存在则更新次数
|
|
|
|
boolean b = this.checkCreatorProfitExist(creatorProfit.getCreatorId(),creatorProfit.getImgId(),creatorProfit.getAppType(),creatorProfit.getPlatform(),"0",date); |
|
|
|
boolean b = this.checkCreatorProfitExist(mark); |
|
|
|
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()); |
|
|
|
int update = this.updateCreatorProfitDownloadNum(mark); |
|
|
|
log.info("唯一标识【{}】收益下载次数+1",mark); |
|
|
|
return update; |
|
|
|
} |
|
|
|
//不存在则新增广告记录
|
|
|
|
@ -75,6 +75,7 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
creatorProfit.setIsShow("1"); |
|
|
|
creatorProfit.setSort(0); |
|
|
|
creatorProfit.setDownloadNum(1); |
|
|
|
creatorProfit.setMark(mark); |
|
|
|
//根据平台生成订单号
|
|
|
|
switch (creatorProfit.getPlatform()){ |
|
|
|
case "0" : |
|
|
|
@ -106,20 +107,15 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
wrapper.eq(InviteLog::getInvitedCreatorId, creatorProfit.getCreatorId()); |
|
|
|
List<InviteLog> inviteLogs = inviteLogMapper.selectList(wrapper); |
|
|
|
if(inviteLogs.size() > 0){ |
|
|
|
List<BatchUpdateInviteDto> updateList = new ArrayList<>(); |
|
|
|
List<String> updateList = new ArrayList<>(); |
|
|
|
List<CreatorProfit> insertList = new ArrayList<>(); |
|
|
|
for (InviteLog inviteLog : inviteLogs) { |
|
|
|
String mark = inviteLog.getCreatorId()+creatorProfit.getImgId()+creatorProfit.getAppType()+creatorProfit.getPlatform()+ |
|
|
|
"1"+date.replace("-",""); |
|
|
|
//检查收益表是否存在邀请记录,存在则记录更新邀请者Id
|
|
|
|
boolean b = this.checkCreatorProfitExist(inviteLog.getCreatorId(),creatorProfit.getImgId(),creatorProfit.getAppType(),creatorProfit.getPlatform(),"1",date); |
|
|
|
boolean b = this.checkCreatorProfitExist(mark); |
|
|
|
if(b){ |
|
|
|
BatchUpdateInviteDto dto = new BatchUpdateInviteDto(); |
|
|
|
dto.setCreatorId(inviteLog.getCreatorId()); |
|
|
|
dto.setAppType(creatorProfit.getAppType()); |
|
|
|
dto.setImgId(creatorProfit.getImgId()); |
|
|
|
dto.setPlatform(creatorProfit.getPlatform()); |
|
|
|
dto.setDate(date); |
|
|
|
dto.setType("1"); |
|
|
|
updateList.add(dto); |
|
|
|
updateList.add(mark); |
|
|
|
}else{ |
|
|
|
//不存在则新增邀请者id
|
|
|
|
creatorProfit.setCreatorId(inviteLog.getCreatorId()); |
|
|
|
@ -130,6 +126,7 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
creatorProfit.setIsShow("1"); |
|
|
|
creatorProfit.setSort(0); |
|
|
|
creatorProfit.setDownloadNum(1); |
|
|
|
creatorProfit.setMark(mark); |
|
|
|
//根据平台生成订单号
|
|
|
|
switch (creatorProfit.getPlatform()){ |
|
|
|
case "0" : |
|
|
|
@ -150,6 +147,7 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
} |
|
|
|
if(updateList.size() > 0){ |
|
|
|
//批量更新邀请记录
|
|
|
|
//TODO 修改此处BUG
|
|
|
|
creatorProfitMapper.batchUpdateDownload(updateList); |
|
|
|
} |
|
|
|
if(insertList.size() > 0){ |
|
|
|
@ -161,8 +159,8 @@ public class CreatorProfitServiceImpl implements CreatorProfitService { |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int updateCreatorProfitDownloadNum(Long creatorId, Long imgId, String appType, String platform,String type, String date) { |
|
|
|
return creatorProfitMapper.updateDownloadNum(creatorId,imgId,appType,platform,type,date); |
|
|
|
public int updateCreatorProfitDownloadNum(String mark) { |
|
|
|
return creatorProfitMapper.updateDownloadNum(mark); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|