Browse Source

Merge commit '6882163743907f50ad8755368b1858134e756f87' into dev

ith5 5 months ago
parent
commit
fa310b07f8

+ 0 - 4
app/v1/logic/customer/SdkOrderLogic.php

@@ -65,10 +65,6 @@ class SdkOrderLogic extends BaseLogic
         }
         $sql_parts = [];
         foreach ($table_name_array as $table_name) {
-            // 安全过滤,避免 SQL 注入
-            if (!preg_match('/^\d{6}$/', $table_name)) {
-                continue;
-            }
             $sql_parts[] = "SELECT * FROM sdk_order_{$table_name} WHERE 1=1 {$where_sql}";
         }
         if (empty($sql_parts)) {

+ 3 - 13
app/v1/logic/dataReport/ChannelAnalysisLogic.php

@@ -39,13 +39,10 @@ class ChannelAnalysisLogic extends BaseLogic
         $tableNames = ToolLogic::getMonthlyTableNames('base_total_hour_', $where['reg_date'][0], $where['reg_date'][1]);
         $sqlParts = [];
         foreach ($tableNames as $tableName) {
-            // 安全过滤,避免 SQL 注入
-            if (!preg_match('/^base_total_hour_\\d{6}$/', $tableName)) {
-                continue;
-            }
             $sqlParts[] = "SELECT * FROM {$tableName} WHERE 1=1 {$whereSql}";
         }
         $unionSql = implode(" UNION ALL ", $sqlParts);
+
         // 外层包裹分页、排序
         $finalSql = "
             SELECT {$field} FROM ( {$unionSql} ) AS all_hour
@@ -80,18 +77,16 @@ class ChannelAnalysisLogic extends BaseLogic
 
 
             // 统计数据,每小时的数据
-
             $total[$hourKey]['reg_total'] = !empty($total[$hourKey]['reg_total']) ? ($total[$hourKey]['reg_total'] + $hourRow['reg_total']) : $hourRow['reg_total'];
-            $total[$hourKey]['cost'] = !empty($total[$hourKey]['cost']) ? ($total[$hourKey]['cost'] + $hourRow['cost']) : $hourRow['cost'];
+            $total[$hourKey]['cost'] = !empty($total[$hourKey]['cost']) ? round($total[$hourKey]['cost'] + $hourRow['cost'], 2) : $hourRow['cost'];
             $total[$hourKey]['reg_pay_total'] = !empty($total[$hourKey]['reg_pay_total']) ? ($total[$hourKey]['reg_pay_total'] + $hourRow['reg_pay_total']) : $hourRow['reg_pay_total'];
             $total[$hourKey]['reg_pay_num'] = !empty($total[$hourKey]['reg_pay_num']) ? ($total[$hourKey]['reg_pay_num'] + $hourRow['reg_pay_num']) : $hourRow['reg_pay_num'];
 
             $total['total_raw']['reg_total'] = !empty($total['total_raw']['reg_total']) ? ($total['total_raw']['reg_total'] + $hourRow['reg_total']) : $hourRow['reg_total'];
-            $total['total_raw']['cost'] = !empty($total['total_raw']['cost']) ? ($total['total_raw']['cost'] + $hourRow['cost']) : $hourRow['cost'];
+            $total['total_raw']['cost'] = !empty($total['total_raw']['cost']) ? round($total['total_raw']['cost'] + $hourRow['cost'], 2) : $hourRow['cost'];
             $total['total_raw']['reg_pay_total'] = !empty($total['total_raw']['reg_pay_total']) ? ($total['total_raw']['reg_pay_total'] + $hourRow['reg_pay_total']) : $hourRow['reg_pay_total'];
             $total['total_raw']['reg_pay_num'] = !empty($total['total_raw']['reg_pay_num']) ? ($total['total_raw']['reg_pay_num'] + $hourRow['reg_pay_num']) : $hourRow['reg_pay_num'];
 
-
             $hourResult[$agentId][$hourKey] = $hourRow;
         }
 
@@ -104,7 +99,6 @@ class ChannelAnalysisLogic extends BaseLogic
             $v['roi'] = ToolLogic::getPercent($v['reg_pay_total'], $v['cost']);
         }
 
-
         // 计算行汇总
         foreach ($hourResult as &$item) {
             $item['total_raw']['cost'] = round(array_sum(array_column($item, 'cost')), 2);
@@ -184,10 +178,6 @@ class ChannelAnalysisLogic extends BaseLogic
 
         $baseTotalDaySqlParts = [];
         foreach ($baseTotalDayTableNames as $tableName) {
-            // 安全过滤,避免 SQL 注入
-            if (!preg_match('/^base_total_day_\\d{4}$/', $tableName)) {
-                continue;
-            }
             $baseTotalDaySqlParts[] = "SELECT * FROM {$tableName} WHERE 1=1 {$whereSql}";
         }
         $unionBaseTotalDaySql = implode(" UNION ALL ", $baseTotalDaySqlParts);