nili
5 months ago
7 changed files with 272 additions and 18 deletions
@ -0,0 +1,21 @@ |
|||||
|
package awesome.group.game.dao.bean; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.sql.Timestamp; |
||||
|
|
||||
|
@Data |
||||
|
public class MatrixAdvAggregationSub { |
||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||
|
private Integer id; |
||||
|
private Integer appId; |
||||
|
private Integer adminId; |
||||
|
private Integer date; |
||||
|
private Integer platform;//1穿山甲,2腾讯,3百度联盟,4 Mintegral,5 快手,6游可赢,7 Sigmob,8 Admob
|
||||
|
private Long income;//ecpm, 单位:分
|
||||
|
private Long incomeReal;//抽成后ecpm,单位:分
|
||||
|
private Integer incomeRate;//单位:分
|
||||
|
private Timestamp createdAt; |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package awesome.group.game.dao.mapper; |
||||
|
|
||||
|
import awesome.group.game.dao.bean.MatrixAdvAggregationSub; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Insert; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface MatrixAdvAggregationSubMapper extends BaseMapper<MatrixAdvAggregationSub> { |
||||
|
@Insert("<script>" + |
||||
|
"insert ignore into matrix_adv_aggregation_sub(app_id, admin_id, date, platform, income, income_real, income_rate) values " + |
||||
|
"<foreach item = 'd' index = 'index' collection = 'data' separator =',' >" + |
||||
|
"(#{d.appId}, #{d.adminId}, #{d.date}, #{d.platform}, #{d.income}, #{d.incomeReal}, #{d.incomeRate})" + |
||||
|
"</foreach>" + |
||||
|
"</script>") |
||||
|
int insertBatch(List<MatrixAdvAggregationSub> data); |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package awesome.group.game.service; |
||||
|
|
||||
|
import awesome.group.game.dao.bean.MatrixAdvAggregationSub; |
||||
|
import awesome.group.game.dao.mapper.MatrixAdvAggregationSubMapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class AggregationSubService { |
||||
|
@Resource |
||||
|
private MatrixAdvAggregationSubMapper subMapper; |
||||
|
|
||||
|
public long getIncome(int adminId, List<Integer> appIds, int startDate, int endDate) { |
||||
|
if (CollectionUtils.isEmpty(appIds)) { |
||||
|
return 0L; |
||||
|
} |
||||
|
LambdaQueryWrapper<MatrixAdvAggregationSub> query = new QueryWrapper<MatrixAdvAggregationSub>() |
||||
|
.select("sum(income_real) as income").lambda(); |
||||
|
query.in(MatrixAdvAggregationSub::getAppId, appIds); |
||||
|
query.between(MatrixAdvAggregationSub::getDate, startDate, endDate); |
||||
|
query.eq(MatrixAdvAggregationSub::getAdminId, adminId); |
||||
|
MatrixAdvAggregationSub data = subMapper.selectOne(query); |
||||
|
if (data == null) { |
||||
|
return 0L; |
||||
|
} |
||||
|
return data.getIncome(); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue