51 $sourceTable = $this->
getTable(
'sales_order');
56 if ($from !==
null || $to !==
null) {
67 $shippingCanceled =
$connection->getIfNullSql(
'base_shipping_canceled', 0);
68 $shippingRefunded =
$connection->getIfNullSql(
'base_shipping_refunded', 0);
70 'period' => $periodExpr,
71 'store_id' =>
'store_id',
72 'order_status' =>
'status',
73 'shipping_description' =>
'shipping_description',
74 'orders_count' => new \Zend_Db_Expr(
'COUNT(entity_id)'),
75 'total_shipping' => new \Zend_Db_Expr(
76 "SUM((base_shipping_amount - {$shippingCanceled}) * base_to_global_rate)" 78 'total_shipping_actual' => new \Zend_Db_Expr(
79 "SUM((base_shipping_invoiced - {$shippingRefunded}) * base_to_global_rate)" 94 if ($subSelect !==
null) {
98 $select->group([$periodExpr,
'store_id',
'status',
'shipping_description']);
99 $select->having(
'orders_count > 0');
105 'period' =>
'period',
106 'store_id' => new \Zend_Db_Expr(\
Magento\Store\Model\Store::DEFAULT_STORE_ID),
107 'order_status' =>
'order_status',
108 'shipping_description' =>
'shipping_description',
109 'orders_count' => new \Zend_Db_Expr(
'SUM(orders_count)'),
110 'total_shipping' => new \Zend_Db_Expr(
'SUM(total_shipping)'),
111 'total_shipping_actual' => new \Zend_Db_Expr(
'SUM(total_shipping_actual)'),
116 if ($subSelect !==
null) {
120 $select->group([
'period',
'order_status',
'shipping_description']);
123 }
catch (\Exception $e) {
144 $sourceTable = $this->
getTable(
'sales_invoice');
145 $orderTable = $this->
getTable(
'sales_order');
150 if ($from !==
null || $to !==
null) {
154 [
'order_id' =>
'entity_id'],
168 [
'source_table' => $sourceTable],
169 'source_table.created_at',
174 $shippingCanceled =
$connection->getIfNullSql(
'order_table.base_shipping_canceled', 0);
175 $shippingRefunded =
$connection->getIfNullSql(
'order_table.base_shipping_refunded', 0);
177 'period' => $periodExpr,
178 'store_id' =>
'order_table.store_id',
179 'order_status' =>
'order_table.status',
180 'shipping_description' =>
'order_table.shipping_description',
181 'orders_count' => new \Zend_Db_Expr(
'COUNT(order_table.entity_id)'),
182 'total_shipping' => new \Zend_Db_Expr(
183 'SUM((order_table.base_shipping_amount - ' .
184 "{$shippingCanceled}) * order_table.base_to_global_rate)" 186 'total_shipping_actual' => new \Zend_Db_Expr(
187 'SUM((order_table.base_shipping_invoiced - ' .
188 "{$shippingRefunded}) * order_table.base_to_global_rate)" 194 [
'source_table' => $sourceTable],
197 [
'order_table' => $orderTable],
199 'source_table.order_id = order_table.entity_id AND order_table.state != ?',
203 )->useStraightJoin();
206 [
'filter_source_table' => $sourceTable],
207 'MIN(filter_source_table.entity_id)' 209 'filter_source_table.order_id = source_table.order_id' 212 if ($subSelect !==
null) {
217 unset($filterSubSelect);
220 [$periodExpr,
'order_table.store_id',
'order_table.status',
'order_table.shipping_description']
228 'period' =>
'period',
229 'store_id' => new \Zend_Db_Expr(\
Magento\Store\Model\Store::DEFAULT_STORE_ID),
230 'order_status' =>
'order_status',
231 'shipping_description' =>
'shipping_description',
232 'orders_count' => new \Zend_Db_Expr(
'SUM(orders_count)'),
233 'total_shipping' => new \Zend_Db_Expr(
'SUM(total_shipping)'),
234 'total_shipping_actual' => new \Zend_Db_Expr(
'SUM(total_shipping_actual)'),
239 if ($subSelect !==
null) {
243 $select->group([
'period',
'order_status',
'shipping_description']);
246 }
catch (\Exception $e) {
_setResource($connections, $tables=null)
_makeConditionFromDateRangeSelect($select, $periodColumn, $connection=null)
getStoreTZOffsetQuery( $table, $column, $from=null, $to=null, $store=null, $connection=null)
_clearTableByDateRange( $table, $from=null, $to=null, $subSelect=null, $doNotUseTruncate=false, $connection=null)
_aggregateByOrderCreatedAt($from, $to)
_setFlagData($code, $value=null)
_aggregateByShippingCreatedAt($from, $to)
const STATE_PENDING_PAYMENT
_getTableDateRangeSelect( $table, $column, $whereColumn, $from=null, $to=null, $additionalWhere=[], $alias='date_range_table')
_getTableDateRangeRelatedSelect( $table, $relatedTable, $joinCondition, $column, $whereColumn, $from=null, $to=null, $additionalWhere=[], $alias='date_range_table', $relatedAlias='related_date_range_table')
aggregate($from=null, $to=null)