mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
fixed total sales
This commit is contained in:
parent
2c2511c2d7
commit
aef54dd4bd
@ -15,6 +15,7 @@ use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
||||
use Visiosoft\AdvsModule\Http\Middleware\redirectDiffrentLang;
|
||||
use Visiosoft\AdvsModule\Http\Middleware\SetLang;
|
||||
use Visiosoft\AdvsModule\Listener\AddAdvsSettingsScript;
|
||||
use Visiosoft\AdvsModule\Listener\AddTotalSales;
|
||||
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Option\OptionRepository;
|
||||
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
|
||||
@ -33,6 +34,7 @@ use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||
use Visiosoft\CatsModule\Category\CategoryRepository;
|
||||
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
||||
use Visiosoft\LocationModule\Country\CountryRepository;
|
||||
use Visiosoft\OrdersModule\Orderdetail\Event\CreatedOrderDetail;
|
||||
|
||||
class AdvsModuleServiceProvider extends AddonServiceProvider
|
||||
{
|
||||
@ -245,7 +247,9 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
||||
protected $listeners = [
|
||||
TableIsQuerying::class => [
|
||||
AddAdvsSettingsScript::class,
|
||||
],
|
||||
], CreatedOrderDetail::class => [
|
||||
AddTotalSales::class,
|
||||
]
|
||||
];
|
||||
|
||||
protected $bindings = [
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Listener;
|
||||
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\OrdersModule\Orderdetail\Event\CreatedOrderDetail;
|
||||
|
||||
class AddTotalSales
|
||||
{
|
||||
private $advModel;
|
||||
public function __construct(
|
||||
AdvModel $advModel
|
||||
)
|
||||
{
|
||||
$this->advModel = $advModel;
|
||||
}
|
||||
|
||||
public function handle(CreatedOrderDetail $event)
|
||||
{
|
||||
$item = $event->getOrderItem();
|
||||
$adv = $this->advModel->find($event->getOrderItem()->item_id);
|
||||
$total = $adv->total_sales + $item->piece;
|
||||
$adv->total_sales = $total;
|
||||
$adv->save();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user