|
|
|
@ -44,6 +44,7 @@ public class ProfitVerifyOrderServiceImpl implements ProfitVerifyOrderService { |
|
|
|
order.setAmt(params.getAmt()); |
|
|
|
order.setAdminId(params.getAdminId()); |
|
|
|
order.setPlatform(params.getPlatform()); |
|
|
|
order.setAppType(params.getAppType()); |
|
|
|
order.setCreateTime(new Date()); |
|
|
|
order.setVerifyStatus("0"); |
|
|
|
return profitVerifyOrderMapper.insert(order); |
|
|
|
@ -98,78 +99,50 @@ public class ProfitVerifyOrderServiceImpl implements ProfitVerifyOrderService { |
|
|
|
//昨日总收益的10%作为邀请收益
|
|
|
|
BigDecimal yesterdayTotalInviteProfit = params.getAmt().multiply(BigDecimal.valueOf(0.1)); |
|
|
|
//获取昨日日期
|
|
|
|
Date today = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24); |
|
|
|
Date yesterday = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24); |
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String date = simpleDateFormat.format(today); |
|
|
|
String date = simpleDateFormat.format(yesterday); |
|
|
|
String tiktokKey = RedisKeyConstant.TIKTOK_IMG_TOTAL_DOWNLOAD_NUM_KEY + date; |
|
|
|
String hashKey = params.getAppType()+":"+ params.getPlatform(); |
|
|
|
if(params.getPlatform().equals(ProfitOrderConstant.TIKTOK) && params.getAppType().equals(ProfitOrderConstant.BNYER_IMG)){ |
|
|
|
if(redisService.hasHashKey(tiktokKey, hashKey)){ |
|
|
|
//存在昨日平台下载数量
|
|
|
|
Integer platformDownloadNum = (Integer) redisService.getCacheMapValue(tiktokKey, hashKey); |
|
|
|
//广告单价
|
|
|
|
BigDecimal adPrice = yesterdayTotalAdProfit.divide(BigDecimal.valueOf(platformDownloadNum), 3, BigDecimal.ROUND_DOWN); |
|
|
|
//邀请单价
|
|
|
|
BigDecimal invitePrice = yesterdayTotalInviteProfit.divide(BigDecimal.valueOf(platformDownloadNum), 3, BigDecimal.ROUND_DOWN); |
|
|
|
//查出昨日对应平台的所有广告待入账信息
|
|
|
|
List<CreatorProfit> adProfits = creatorProfitService.queryPreProfit(params.getPlatform(), params.getAppType(), "0"); |
|
|
|
if(adProfits.size() > 0){ |
|
|
|
for (CreatorProfit adProfit : adProfits) { |
|
|
|
//设置广告收益
|
|
|
|
adProfit.setProfit(BigDecimal.valueOf(adProfit.getDownloadNum()).multiply(adPrice)); |
|
|
|
adProfit.setConfirmStatus("0"); |
|
|
|
adProfit.setIncomeTime(new Date()); |
|
|
|
adProfit.setUpdateTime(new Date()); |
|
|
|
if(redisService.hasHashKey(tiktokKey, hashKey)){ |
|
|
|
//存在昨日平台下载数量
|
|
|
|
Integer platformDownloadNum = redisService.getCacheMapValue(tiktokKey, hashKey); |
|
|
|
//广告单价
|
|
|
|
BigDecimal adPrice = yesterdayTotalAdProfit.divide(BigDecimal.valueOf(platformDownloadNum), 3, BigDecimal.ROUND_DOWN); |
|
|
|
//邀请单价
|
|
|
|
BigDecimal invitePrice = yesterdayTotalInviteProfit.divide(BigDecimal.valueOf(platformDownloadNum), 3, BigDecimal.ROUND_DOWN); |
|
|
|
//查出昨日对应平台的所有广告待入账信息
|
|
|
|
List<CreatorProfit> adProfits = creatorProfitService.queryPreProfit(params.getPlatform(), params.getAppType(), "0",date); |
|
|
|
if(adProfits.size() > 0){ |
|
|
|
for (CreatorProfit adProfit : adProfits) { |
|
|
|
//设置广告收益
|
|
|
|
adProfit.setProfit(BigDecimal.valueOf(adProfit.getDownloadNum()).multiply(adPrice)); |
|
|
|
adProfit.setConfirmStatus("0"); |
|
|
|
adProfit.setIncomeTime(new Date()); |
|
|
|
adProfit.setStatus("1"); |
|
|
|
creatorProfitService.update(adProfit); |
|
|
|
} |
|
|
|
} |
|
|
|
//查出昨日对应平台的所有邀请待入账信息
|
|
|
|
List<CreatorProfit> inviteProfits = creatorProfitService.queryPreProfit(params.getPlatform(), params.getAppType(), "1"); |
|
|
|
List<CreatorProfit> inviteProfits = creatorProfitService.queryPreProfit(params.getPlatform(), params.getAppType(), "1",date); |
|
|
|
if(inviteProfits.size() > 0){ |
|
|
|
//设置邀请收益
|
|
|
|
for (CreatorProfit inviteProfit : inviteProfits) { |
|
|
|
inviteProfit.setProfit(BigDecimal.valueOf(inviteProfit.getDownloadNum()).multiply(invitePrice)); |
|
|
|
inviteProfit.setConfirmStatus("0"); |
|
|
|
inviteProfit.setIncomeTime(new Date()); |
|
|
|
inviteProfit.setUpdateTime(new Date()); |
|
|
|
inviteProfit.setStatus("1"); |
|
|
|
creatorProfitService.update(inviteProfit); |
|
|
|
} |
|
|
|
//设置完结算收益,删除数量缓存
|
|
|
|
redisService.deleteHashKey(tiktokKey,hashKey); |
|
|
|
//TODO 逻辑待优化
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(params.getPlatform().equals(ProfitOrderConstant.FAST_HAND) && params.getAppType().equals(ProfitOrderConstant.BNYER_IMG)){ |
|
|
|
//昨日快手平台总下载量
|
|
|
|
if(redisService.hasHashKey(tiktokKey, hashKey)){ |
|
|
|
//存在昨日平台下载数量
|
|
|
|
Integer platformDownloadNum = (Integer) redisService.getCacheMapValue(tiktokKey, hashKey); |
|
|
|
//广告单价
|
|
|
|
BigDecimal adPrice = yesterdayTotalAdProfit.divide(BigDecimal.valueOf(platformDownloadNum), 3, BigDecimal.ROUND_DOWN); |
|
|
|
//邀请单价
|
|
|
|
BigDecimal invitePrice = yesterdayTotalInviteProfit.divide(BigDecimal.valueOf(platformDownloadNum), 3, BigDecimal.ROUND_DOWN); |
|
|
|
//查出昨日对应平台的所有广告待入账信息
|
|
|
|
List<CreatorProfit> adProfits = creatorProfitService.queryPreProfit(params.getPlatform(), params.getAppType(), "0"); |
|
|
|
if(adProfits.size() > 0){ |
|
|
|
for (CreatorProfit adProfit : adProfits) { |
|
|
|
//设置广告收益
|
|
|
|
adProfit.setProfit(BigDecimal.valueOf(adProfit.getDownloadNum()).multiply(adPrice)); |
|
|
|
adProfit.setConfirmStatus("0"); |
|
|
|
adProfit.setIncomeTime(new Date()); |
|
|
|
adProfit.setUpdateTime(new Date()); |
|
|
|
} |
|
|
|
} |
|
|
|
//查出昨日对应平台的所有邀请待入账信息
|
|
|
|
List<CreatorProfit> inviteProfits = creatorProfitService.queryPreProfit(params.getPlatform(), params.getAppType(), "1"); |
|
|
|
if(inviteProfits.size() > 0){ |
|
|
|
//设置邀请收益
|
|
|
|
for (CreatorProfit inviteProfit : inviteProfits) { |
|
|
|
inviteProfit.setProfit(BigDecimal.valueOf(inviteProfit.getDownloadNum()).multiply(invitePrice)); |
|
|
|
inviteProfit.setConfirmStatus("0"); |
|
|
|
inviteProfit.setIncomeTime(new Date()); |
|
|
|
inviteProfit.setUpdateTime(new Date()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO 待补充完善结算方法
|
|
|
|
}else{ |
|
|
|
//审核不通过,流程结束
|
|
|
|
return false; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|