Merge pull request #3728 from rahulcs0082/development

Issue #3561 fixed
This commit is contained in:
Jitendra Singh 2020-08-12 11:38:34 +05:30 committed by GitHub
commit b76f83bd5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -236,9 +236,10 @@ class DashboardController extends Controller
public function getCustomerWithMostSales()
{
return $this->orderRepository->getModel()
->select(DB::raw('SUM(base_grand_total) as total_base_grand_total'))
->addSelect(DB::raw('COUNT(id) as total_orders'))
->addSelect('id', 'customer_id', 'customer_email', 'customer_first_name', 'customer_last_name')
->leftJoin('refunds', 'orders.id', 'refunds.order_id')
->select(DB::raw('(SUM(orders.base_grand_total) - SUM(IFNULL(refunds.base_grand_total, 0))) as total_base_grand_total'))
->addSelect(DB::raw('COUNT(orders.id) as total_orders'))
->addSelect('orders.id', 'customer_id', 'customer_email', 'customer_first_name', 'customer_last_name')
->where('orders.created_at', '>=', $this->startDate)
->where('orders.created_at', '<=', $this->endDate)
->where('orders.status', '<>', 'closed')