Beispiel #1
0
list($next_month_year, $next_month_month) = $calc->getMonthAgoDate($check_date, -1);
list($one_month_year, $one_month_month) = $calc->getMonthAgoDate($check_date, 0);
list($two_month_year, $two_month_month) = $calc->getMonthAgoDate($check_date, 1);
list($three_month_year, $three_month_month) = $calc->getMonthAgoDate($check_date, 2);
//print("next_month_year=".$next_month_year."<br>");
//print("next_month_month=".$next_month_month."<br>");
//print("one_month_year=".$one_month_year."<br>");
//print("one_month_month=".$one_month_month."<br>");
//print("two_month_year=".$two_month_year."<br>");
//print("two_month_month=".$two_month_month."<br>");
//print("three_month_year=".$three_month_year."<br>");
//print("three_month_month=".$three_month_month."<br>");
//トップページのアクセス数を取得
$access_sql = "SELECT media_cd AS ad_code, access_count AS access_count FROM media_analyze " . "WHERE analyze_datetime >= " . $check_date . "0000 AND analyze_datetime <= " . $check_date . "5959 " . "AND disable = 0 " . "GROUP BY ad_code";
//print("sql=".$access_sql."<br>");
$access_result = $calc->calcAccess($access_sql);
//var_dump($access_result);
//print_r($access_result);
// 1本目SQL文
$user_sql = "SELECT ";
//媒体名
$user_sql .= "media_cd AS " . $calc->config["access_column_array"]["1"] . "," . "SUM(CASE WHEN regist_status = 0 THEN 1 ELSE 0 END) AS " . $calc->config["user_column_array"]["1"] . "," . "0 AS " . $calc->config["user_column_array"]["2"] . "," . "SUM(CASE WHEN regist_status = 1 THEN 1 ELSE 0 END) AS " . $calc->config["user_column_array"]["3"] . "," . "0 AS " . $calc->config["user_column_array"]["4"] . " " . "FROM user WHERE regist_datetime >= " . $check_date . "0000 AND regist_datetime <= " . $check_date . "5959 " . "GROUP BY " . $calc->config["access_column_array"]["1"];
//print("<br><br>sql=".$user_sql."<br><br><br><br><br>");
$user_result = $calc->calcNewUser($user_sql);
//print_r($user_result);
$trd_sql = "SELECT user.media_cd AS ad_code," . "SUM(CASE WHEN user.regist_datetime < " . $three_month_year . $three_month_month . "01000000 THEN payment_log.receive_money ELSE 0 END) as " . $calc->config["trd_column_array"]["1"] . "," . "0 as before_sales_female," . "SUM(CASE WHEN user.regist_datetime >= " . $three_month_year . $three_month_month . "01000000 AND user.regist_datetime < " . $two_month_year . $two_month_month . "01000000 THEN payment_log.receive_money ELSE 0 END) as " . $calc->config["trd_column_array"]["2"] . "," . "0 as three_month_sales_female," . "SUM(CASE WHEN user.regist_datetime >= " . $two_month_year . $two_month_month . "01000000 AND user.regist_datetime < " . $one_month_year . $one_month_month . "01000000 THEN payment_log.receive_money ELSE 0 END) as " . $calc->config["trd_column_array"]["3"] . "," . "0 as two_month_sales_female," . "SUM(CASE WHEN user.regist_datetime >= " . $one_month_year . $one_month_month . "01000000 AND user.regist_datetime < " . $next_month_year . $next_month_month . "01000000 THEN payment_log.receive_money ELSE 0 END) as " . $calc->config["trd_column_array"]["4"] . "," . "0 as current_month_sales_female," . "SUM(CASE WHEN user.regist_datetime < " . $three_month_year . $three_month_month . "01000000 THEN 1 ELSE 0 END) as " . $calc->config["trd_column_array"]["5"] . "," . "0 as before_count_female," . "SUM(CASE WHEN user.regist_datetime >= " . $three_month_year . $three_month_month . "01000000 AND user.regist_datetime < " . $two_month_year . $two_month_month . "01000000 THEN 1 ELSE 0 END) as " . $calc->config["trd_column_array"]["6"] . "," . "0 as three_month_count_female," . "SUM(CASE WHEN user.regist_datetime >= " . $two_month_year . $two_month_month . "01000000 AND user.regist_datetime < " . $one_month_year . $one_month_month . "01000000 THEN 1 ELSE 0 END) as " . $calc->config["trd_column_array"]["7"] . "," . "0 as two_month_count_female," . "SUM(CASE WHEN user.regist_datetime >= " . $one_month_year . $one_month_month . "01000000 AND user.regist_datetime < " . $next_month_year . $next_month_month . "01000000 THEN 1 ELSE 0 END) as " . $calc->config["trd_column_array"]["8"] . "," . "0 as one_month_count_female " . "FROM payment_log LEFT JOIN user ON payment_log.user_id = user.id AND user.disable = 0 AND user.admin_id = 0 AND payment_log.disable = 0" . " LEFT JOIN ordering ON  payment_log.ordering_id = ordering.id AND ordering.disable = 0 AND ordering.is_paid = 1 AND ordering.is_cancel = 0" . " AND ordering.status IN (11, 12, 13)" . " WHERE payment_log.create_datetime >= " . $check_date . "0000 AND payment_log.create_datetime <= " . $check_date . "5959 " . "GROUP BY user.media_cd";
//print("<br><br>sql=".$trd_sql."<br><br><br><br><br>");
$trd_result = $calc->calcTrd($trd_sql);
//print_r($trd_result);
//exit;
//print("<br><br><br><br><br><br><br>");