|  | @@ -1,6 +1,5 @@
 | 
	
		
			
				|  |  |  package com.zanxiang.game.data.serve.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import com.google.common.base.CaseFormat;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.data.serve.pojo.dto.PromotionDayDTO;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.data.serve.pojo.dto.PromotionDayTotalDTO;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
 | 
	
	
		
			
				|  | @@ -9,6 +8,7 @@ import com.zanxiang.game.data.serve.pojo.vo.PromotionDayVO;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.data.serve.pojo.vo.PromotionRechargeTrendVO;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.data.serve.service.IAdsPromotionDayService;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.data.serve.utils.Page;
 | 
	
		
			
				|  |  | +import com.zanxiang.module.util.exception.BaseException;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.nutz.dao.Cnd;
 | 
	
	
		
			
				|  | @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.beans.PropertyDescriptor;
 | 
	
		
			
				|  |  | +import java.lang.reflect.Field;
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.math.RoundingMode;
 | 
	
		
			
				|  |  |  import java.time.LocalDate;
 | 
	
	
		
			
				|  | @@ -43,8 +44,99 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private Dao dao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 广告监控每日数据列表
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param dto
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public Page<PromotionDayVO> getPromotionDayListData(PromotionDayDTO dto) {
 | 
	
		
			
				|  |  | +        //不传递查询条件默认查询当天数据
 | 
	
		
			
				|  |  | +        if (dto.getCostBeginDate() == null || dto.getCostEndDate() == null) {
 | 
	
		
			
				|  |  | +            dto.setCostBeginDate(LocalDate.now());
 | 
	
		
			
				|  |  | +            dto.setCostEndDate(LocalDate.now());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //如果没有排序条件给默认值
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(dto.getSortFiled())) {
 | 
	
		
			
				|  |  | +            dto.setSortFiled("today_cost");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(dto.getSortType())) {
 | 
	
		
			
				|  |  | +            dto.setSortType(OrderByEnum.DESC.getOrderType());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Criteria cri = myCri(dto, false);
 | 
	
		
			
				|  |  | +        //创建sql语句
 | 
	
		
			
				|  |  | +        Sql sql = Sqls.create(getPromotionDayListSql() + cri);
 | 
	
		
			
				|  |  | +        //添加自定义回传对象
 | 
	
		
			
				|  |  | +        sql.setCallback(Sqls.callback.entities());
 | 
	
		
			
				|  |  | +        sql.setEntity(dao.getEntity(PromotionDayVO.class));
 | 
	
		
			
				|  |  | +        //设置pager对象
 | 
	
		
			
				|  |  | +        Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
 | 
	
		
			
				|  |  | +        sql.setPager(pager);
 | 
	
		
			
				|  |  | +        //执行sql
 | 
	
		
			
				|  |  | +        dao.execute(sql);
 | 
	
		
			
				|  |  | +        //获取到结果list
 | 
	
		
			
				|  |  | +        List<PromotionDayVO> list = sql.getList(PromotionDayVO.class);
 | 
	
		
			
				|  |  | +        //分页对象设置总条数
 | 
	
		
			
				|  |  | +        Sql sqlCount = Sqls.create("select count(*) from ads_promotion_day" + cri);
 | 
	
		
			
				|  |  | +        sqlCount.setCallback(Sqls.callback.integer());
 | 
	
		
			
				|  |  | +        //执行sql
 | 
	
		
			
				|  |  | +        dao.execute(sqlCount);
 | 
	
		
			
				|  |  | +        pager.setRecordCount(sqlCount.getInt());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //处理List中的每个vo对象缺少的数据
 | 
	
		
			
				|  |  | +        list.stream().map(vo -> {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //总充值次数成本
 | 
	
		
			
				|  |  | +            vo.setTotalAmountCountCost(vo.getTotalAmountCount() == 0L ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                    vo.getPromotionTotalCost().divide(BigDecimal.valueOf(vo.getTotalAmountCount()), 2, RoundingMode.HALF_UP));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //计算d2(次日)数据
 | 
	
		
			
				|  |  | +            vo.setD2Trend(PromotionRechargeTrendVO.builder()
 | 
	
		
			
				|  |  | +                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD2().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .rechargeMoney(vo.getD2())
 | 
	
		
			
				|  |  | +                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD2().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .build());
 | 
	
		
			
				|  |  | +            //计算d3数据
 | 
	
		
			
				|  |  | +            vo.setD3Trend(PromotionRechargeTrendVO.builder()
 | 
	
		
			
				|  |  | +                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD3().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .rechargeMoney(vo.getD3())
 | 
	
		
			
				|  |  | +                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD3().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .build());
 | 
	
		
			
				|  |  | +            //计算d7数据
 | 
	
		
			
				|  |  | +            vo.setD7Trend(PromotionRechargeTrendVO.builder()
 | 
	
		
			
				|  |  | +                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD7().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .rechargeMoney(vo.getD7())
 | 
	
		
			
				|  |  | +                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD7().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .build());
 | 
	
		
			
				|  |  | +            //计算d15数据
 | 
	
		
			
				|  |  | +            vo.setD15Trend(PromotionRechargeTrendVO.builder()
 | 
	
		
			
				|  |  | +                    .roi(vo.getTodayCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD15().divide(vo.getTodayCost(), 4, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .rechargeMoney(vo.getD15())
 | 
	
		
			
				|  |  | +                    .multiples(vo.getD1().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  | +                            vo.getD15().divide(vo.getD1(), 2, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                    .build());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //返回最终数据
 | 
	
		
			
				|  |  | +            return vo;
 | 
	
		
			
				|  |  | +        }).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //排序
 | 
	
		
			
				|  |  | +        listSort(dto, list);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //返回查询得结果
 | 
	
		
			
				|  |  | +        return new Page<>(list, pager);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 广告监控数据
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param dto
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -62,7 +154,7 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
 | 
	
		
			
				|  |  |          if (StringUtils.isBlank(dto.getSortType())) {
 | 
	
		
			
				|  |  |              dto.setSortType(OrderByEnum.DESC.getOrderType());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Criteria cri = myCri(dto);
 | 
	
		
			
				|  |  | +        Criteria cri = myCri(dto, true);
 | 
	
		
			
				|  |  |          //创建sql语句
 | 
	
		
			
				|  |  |          Sql sql = Sqls.create(getPromotionDayDataSql() + cri);
 | 
	
		
			
				|  |  |          //添加自定义回传对象
 | 
	
	
		
			
				|  | @@ -145,6 +237,9 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
 | 
	
		
			
				|  |  |              return vo;
 | 
	
		
			
				|  |  |          }).collect(Collectors.toList());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        //排序
 | 
	
		
			
				|  |  | +        listSort(dto, list);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          //返回查询得结果
 | 
	
		
			
				|  |  |          return new Page<>(list, pager);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -339,10 +434,11 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 广告监控用到的查询条件
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param dto 前端传递的查询条件
 | 
	
		
			
				|  |  | +     * @param dto         前端传递的查询条件
 | 
	
		
			
				|  |  | +     * @param needGroupBy 需要聚合分组
 | 
	
		
			
				|  |  |       * @return 查询条件
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    private Criteria myCri(PromotionDayDTO dto) {
 | 
	
		
			
				|  |  | +    private Criteria myCri(PromotionDayDTO dto, Boolean needGroupBy) {
 | 
	
		
			
				|  |  |          //创建查询条件
 | 
	
		
			
				|  |  |          Criteria cri = Cnd.cri();
 | 
	
		
			
				|  |  |          if (dto.getAccountId() != null) {
 | 
	
	
		
			
				|  | @@ -393,10 +489,10 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
 | 
	
		
			
				|  |  |          if (StringUtils.isNotBlank(dto.getSourceSystem())) {
 | 
	
		
			
				|  |  |              cri.where().andEquals("source_system", dto.getSourceSystem());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        //拼接分组条件
 | 
	
		
			
				|  |  | -        cri.getGroupBy().groupBy("promotion_id");
 | 
	
		
			
				|  |  | -        //拼接排序条件
 | 
	
		
			
				|  |  | -        cri.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
 | 
	
		
			
				|  |  | +        if (needGroupBy) {
 | 
	
		
			
				|  |  | +            //拼接分组条件
 | 
	
		
			
				|  |  | +            cri.getGroupBy().groupBy("promotion_id");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return cri;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -463,6 +559,165 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
 | 
	
		
			
				|  |  |          return notNullFieldSet.toArray(notNullField);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 排序
 | 
	
		
			
				|  |  | +     * @param dto 前端传递的查询条件
 | 
	
		
			
				|  |  | +     * @param list 排序后的list
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void listSort(PromotionDayDTO dto, List<PromotionDayVO> list) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            //得到排序字段得反射
 | 
	
		
			
				|  |  | +            Field field = PromotionDayVO.class.getDeclaredField(dto.getSortFiled());
 | 
	
		
			
				|  |  | +            field.setAccessible(true);
 | 
	
		
			
				|  |  | +            //是否升序
 | 
	
		
			
				|  |  | +            boolean isASC = !dto.getSortType().equals("desc");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            list.sort((o1, o2) -> {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    //字段属性得get方法得到的值
 | 
	
		
			
				|  |  | +                    Object value1 = field.get(o1);
 | 
	
		
			
				|  |  | +                    Object value2 = field.get(o2);
 | 
	
		
			
				|  |  | +                    if (value1 instanceof BigDecimal num1 && value2 instanceof BigDecimal num2) {
 | 
	
		
			
				|  |  | +                        return isASC ? num1.compareTo(num2) : num2.compareTo(num1);
 | 
	
		
			
				|  |  | +                    } else if (value1 instanceof Long l1 && value2 instanceof Long l2) {
 | 
	
		
			
				|  |  | +                        return isASC ? l1.compareTo(l2) : l2.compareTo(l1);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } catch (IllegalAccessException e) {
 | 
	
		
			
				|  |  | +                    throw new BaseException("排序出错");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                return 0;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        } catch (NoSuchFieldException e) {
 | 
	
		
			
				|  |  | +            throw new BaseException("排序出错");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 广告监控每日数据sql
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return String
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private String getPromotionDayListSql() {
 | 
	
		
			
				|  |  | +        return """
 | 
	
		
			
				|  |  | +                SELECT
 | 
	
		
			
				|  |  | +                    dt,
 | 
	
		
			
				|  |  | +                    status,
 | 
	
		
			
				|  |  | +                    creative_preview,
 | 
	
		
			
				|  |  | +                    landing_type,
 | 
	
		
			
				|  |  | +                    pricing,
 | 
	
		
			
				|  |  | +                    cpa_bid,
 | 
	
		
			
				|  |  | +                    roi_goal,
 | 
	
		
			
				|  |  | +                    budget,
 | 
	
		
			
				|  |  | +                    concat(start_time,'/',end_time) as schedule_time,
 | 
	
		
			
				|  |  | +                    notes,
 | 
	
		
			
				|  |  | +                    service,
 | 
	
		
			
				|  |  | +                    balance,
 | 
	
		
			
				|  |  | +                    promotion_total_cost,
 | 
	
		
			
				|  |  | +                    convert_target,
 | 
	
		
			
				|  |  | +                    reg_total_num,
 | 
	
		
			
				|  |  | +                    role_total_num,
 | 
	
		
			
				|  |  | +                    reg_total_cost,
 | 
	
		
			
				|  |  | +                    role_total_cost,
 | 
	
		
			
				|  |  | +                    role_total_rate,
 | 
	
		
			
				|  |  | +                    total_amount_count,
 | 
	
		
			
				|  |  | +                    total_amount_num,
 | 
	
		
			
				|  |  | +                    total_amount,
 | 
	
		
			
				|  |  | +                    promotion_total_roi,
 | 
	
		
			
				|  |  | +                    total_recharge_cost,
 | 
	
		
			
				|  |  | +                	promotion_id,
 | 
	
		
			
				|  |  | +                	promotion_name,
 | 
	
		
			
				|  |  | +                	project_id,
 | 
	
		
			
				|  |  | +                	project_name,
 | 
	
		
			
				|  |  | +                	account_name,
 | 
	
		
			
				|  |  | +                	account_id,
 | 
	
		
			
				|  |  | +                	account_type,
 | 
	
		
			
				|  |  | +                	pitcher_id,
 | 
	
		
			
				|  |  | +                	pitcher_name,
 | 
	
		
			
				|  |  | +                	agent_id,
 | 
	
		
			
				|  |  | +                	agent_name,
 | 
	
		
			
				|  |  | +                	agent_key,
 | 
	
		
			
				|  |  | +                	cp_name,
 | 
	
		
			
				|  |  | +                	game_id,
 | 
	
		
			
				|  |  | +                	game_name,
 | 
	
		
			
				|  |  | +                	classify,
 | 
	
		
			
				|  |  | +                	today_cost,
 | 
	
		
			
				|  |  | +                	show_count,
 | 
	
		
			
				|  |  | +                	thousand_display_price,
 | 
	
		
			
				|  |  | +                	click_count,
 | 
	
		
			
				|  |  | +                	avg_click_cost,
 | 
	
		
			
				|  |  | +                	ctr,
 | 
	
		
			
				|  |  | +                	convert_count,
 | 
	
		
			
				|  |  | +                	convert_cost,
 | 
	
		
			
				|  |  | +                	convert_rate,
 | 
	
		
			
				|  |  | +                	reg_num,
 | 
	
		
			
				|  |  | +                	first_role_num,
 | 
	
		
			
				|  |  | +                	new_user_total_role_num,
 | 
	
		
			
				|  |  | +                	reg_cost,
 | 
	
		
			
				|  |  | +                	first_role_cost,
 | 
	
		
			
				|  |  | +                	new_user_total_role_cost,
 | 
	
		
			
				|  |  | +                	first_role_rate,
 | 
	
		
			
				|  |  | +                	new_user_total_role_rate,
 | 
	
		
			
				|  |  | +                	first_new_user_amount_count,
 | 
	
		
			
				|  |  | +                	first_new_user_amount_num,
 | 
	
		
			
				|  |  | +                	first_new_user_amount,
 | 
	
		
			
				|  |  | +                	new_user_total_amount_count,
 | 
	
		
			
				|  |  | +                	new_user_total_amount_num,
 | 
	
		
			
				|  |  | +                	new_user_total_amount,
 | 
	
		
			
				|  |  | +                	first_roi,
 | 
	
		
			
				|  |  | +                	twenty_four_hours_amount,
 | 
	
		
			
				|  |  | +                	twenty_four_hours_roi,
 | 
	
		
			
				|  |  | +                	total_roi,
 | 
	
		
			
				|  |  | +                	first_new_user_recharge_cost,
 | 
	
		
			
				|  |  | +                	new_user_total_recharge_cost,
 | 
	
		
			
				|  |  | +                	first_new_user_arppu,
 | 
	
		
			
				|  |  | +                	new_user_total_amount_arppu,
 | 
	
		
			
				|  |  | +                	first_new_user_hundred_user_num,
 | 
	
		
			
				|  |  | +                	first_new_user_hundred_user_cost,
 | 
	
		
			
				|  |  | +                	first_recharge_fifty_hundred_num,
 | 
	
		
			
				|  |  | +                	first_recharge_fifty_hundred_rate,
 | 
	
		
			
				|  |  | +                	first_new_user_two_hundred_user_num,
 | 
	
		
			
				|  |  | +                	first_new_user_two_hundred_user_cost,
 | 
	
		
			
				|  |  | +                	new_user_total_hundred_user_num,
 | 
	
		
			
				|  |  | +                	new_user_total_hundred_user_cost,
 | 
	
		
			
				|  |  | +                	first_ios_amount_num,
 | 
	
		
			
				|  |  | +                	first_ios_amount_count,
 | 
	
		
			
				|  |  | +                	first_ios_amount,
 | 
	
		
			
				|  |  | +                	first_ios_amount_num_rate,
 | 
	
		
			
				|  |  | +                	first_ios_amount_rate,
 | 
	
		
			
				|  |  | +                	first_ios_amount_roi,
 | 
	
		
			
				|  |  | +                	first_android_amount_count,
 | 
	
		
			
				|  |  | +                	first_android_amount_num,
 | 
	
		
			
				|  |  | +                	first_android_amount,
 | 
	
		
			
				|  |  | +                	first_android_amount_num_rate,
 | 
	
		
			
				|  |  | +                	first_android_amount_rate,
 | 
	
		
			
				|  |  | +                	first_android_amount_roi,
 | 
	
		
			
				|  |  | +                	first_amount_rate,
 | 
	
		
			
				|  |  | +                	first_new_user_avg_price,
 | 
	
		
			
				|  |  | +                	new_user_total_avg_price,
 | 
	
		
			
				|  |  | +                	d1,
 | 
	
		
			
				|  |  | +                	d2,
 | 
	
		
			
				|  |  | +                	d3,
 | 
	
		
			
				|  |  | +                	d7,
 | 
	
		
			
				|  |  | +                	d15,
 | 
	
		
			
				|  |  | +                	active,
 | 
	
		
			
				|  |  | +                    active_cost,
 | 
	
		
			
				|  |  | +                    first_convert_count,
 | 
	
		
			
				|  |  | +                    first_convert_cost,
 | 
	
		
			
				|  |  | +                    first_active_pay_rate,
 | 
	
		
			
				|  |  | +                    first_attribution_game_in_app_ltv1day,
 | 
	
		
			
				|  |  | +                    first_attribution_game_in_app_roi1day,
 | 
	
		
			
				|  |  | +                    game_pay_count,
 | 
	
		
			
				|  |  | +                    ROUND(IF(game_pay_count > 0, today_cost / game_pay_count, 0), 2) as game_pay_count_cost,
 | 
	
		
			
				|  |  | +                    ltv_day1,
 | 
	
		
			
				|  |  | +                    sub_order_num,
 | 
	
		
			
				|  |  | +                    sub_order_amount,
 | 
	
		
			
				|  |  | +                    ROUND(IF(first_new_user_amount_count > 0, today_cost / first_new_user_amount_count, 0), 2) as first_new_user_amount_count_cost,
 | 
	
		
			
				|  |  | +                    ROUND(IF(new_user_total_amount_count > 0, today_cost / new_user_total_amount_count, 0), 2) as new_user_total_amount_count_cost
 | 
	
		
			
				|  |  | +                FROM
 | 
	
		
			
				|  |  | +                	game_ads.ads_promotion_day
 | 
	
		
			
				|  |  | +                """;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询广告监控数据sql
 | 
	
		
			
				|  |  |       *
 |