@Override
 public String getIndexResult(String[] brands, Date date) {
   if (date != null) {
     DayStatus ds = dataDaoV2.getDayStatus(date);
     if (ds == null || ds.getStatus() == null || ds.getStatus() == 0) {
       SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日");
       return this.getErrorResult(3002, sdf.format(date) + "没有相关数据,请重新选择日期");
     }
   }
   Date yesterday = getYesterday(date);
   Set<String> bSet = new HashSet<String>();
   for (String brand : brands) {
     bSet.add(brand);
   }
   List<BrandResult> indexBrandResults = dataDaoV2.getBrandResult(yesterday, brands);
   for (BrandResult ibr : indexBrandResults) {
     if (springProperty.isMockValue()) {
       ibr.setDayAmount(10000L);
     }
     bSet.remove(ibr.getBrand());
   }
   for (String brand : bSet) {
     BrandResult ibr = new BrandResult(brand, "", 0);
     indexBrandResults.add(ibr);
   }
   IndexStatResult ir = new IndexStatResult();
   ir.setBrands(indexBrandResults);
   ir.setResult(0);
   ir.setDate(yesterday);
   ir.setClientVersion(springProperty.getClientVersion());
   Date realYesterday =
       DateUtils.addDays(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH), -1);
   DayStatus ds = dataDaoV2.getDayStatus(realYesterday);
   if (ds != null && ds.getStatus() != null && ds.getStatus().intValue() != 0) {
     ir.setYesterday(true);
   } else {
     ir.setYesterday(false);
   }
   List<Date> availableDates = dataDaoV2.getAvailableDates(realYesterday);
   List<String> ads = new ArrayList<String>();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   for (Date ad : availableDates) {
     ads.add(sdf.format(ad));
   }
   ir.setAvailableDates(ads);
   JsonConfig jsonConfig = new JsonConfig();
   jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd"));
   jsonConfig.registerJsonValueProcessor(Integer.class, new IntegerJsonValueProcessor());
   String result = JSONObject.fromObject(ir, jsonConfig).toString();
   return result;
 }
  @Override
  public String getBrandResult(String brand, Date date) {
    Date yesterday = getYesterday(date);

    BrandStatResult bsr = new BrandStatResult();
    BrandResult br = new BrandResult(brand, "", 0);
    br.setBrand(brand);
    br.setDate(yesterday);
    Double lastDayAmount = 0.0;
    List<BrandResult> bcr = this.dataDaoV2.getBrandResultByChannel(yesterday, brand);
    for (BrandResult b : bcr) {
      if (springProperty.isMockValue()) {
        b.setDayAmount(10000L);
      }
      if (b.getChannel().equals(Constants.B2C)) {
        // 统计数据不包括电商的
        continue;
      }
      if (b.getPerDayAmount() != null) {
        lastDayAmount += b.getPerDayAmount();
      }
      if (b.getDayAmount() != null) {
        br.setDayAmount(b.getDayAmount() + br.getDayAmount());
      }
    }
    if (lastDayAmount != 0) {
      br.setDayLike(br.getDayAmount() / lastDayAmount - 1);
    }
    Collections.sort(bcr);
    bsr.setBrand(brand);
    bsr.setResult(0);
    bsr.setBrandResult(br);
    if (!brand.equals(Constants.B2C)) {
      bsr.setChannels(bcr);
    }

    Date firstDayOfThisWeek = getCalendarDate(yesterday, Calendar.WEEK_OF_MONTH);
    // daily line chart
    List<BrandLineChartResult> dailyLineChart =
        this.dataDaoV2.getBrandLineChartDayResult(yesterday, brand, "days", 8);
    bsr.setDailyLineChart(dailyLineChart);
    setLineChartColorAndDateStr(dailyLineChart, brand, Calendar.DAY_OF_MONTH, firstDayOfThisWeek);
    List<BrandLineChartResult> weeklyLineChart =
        this.dataDaoV2.getBrandLineChartDayResult(
            this.getCalendarDate(yesterday, Calendar.WEEK_OF_MONTH), brand, "weeks", 8);
    bsr.setWeeklyLineChart(weeklyLineChart);
    setLineChartColorAndDateStr(weeklyLineChart, brand, Calendar.WEEK_OF_MONTH, null);
    List<BrandLineChartResult> monthLineChart =
        this.dataDaoV2.getBrandLineChartDayResult(
            this.getCalendarDate(yesterday, Calendar.MONTH), brand, "months", 12);
    bsr.setMonthlyLineChart(monthLineChart);
    setLineChartColorAndDateStr(monthLineChart, brand, Calendar.MONTH, null);
    List<BrandLineChartResult> yearLineChart =
        this.dataDaoV2.getBrandLineChartDayResult(
            this.getCalendarDate(yesterday, Calendar.YEAR), brand, "years", 3);
    bsr.setYearlyLineChart(yearLineChart);
    setLineChartColorAndDateStr(yearLineChart, brand, Calendar.YEAR, null);
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd"));
    jsonConfig.registerJsonValueProcessor(Integer.class, new IntegerJsonValueProcessor());
    String result = JSONObject.fromObject(bsr, jsonConfig).toString();
    return result;
  }