@@ -4,7 +4,6 @@ namespace common\logic\CreditHistory; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\services\CreditHistory\CreditHistorySolver; | |||
class CreditHistoryBuilder extends BaseService implements BuilderInterface | |||
{ | |||
@@ -15,7 +14,7 @@ class CreditHistoryBuilder extends BaseService implements BuilderInterface | |||
$this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); | |||
} | |||
public function save(CreditHistory $creditHistory): bool | |||
public function save(CreditHistoryModel $creditHistory): bool | |||
{ | |||
if ($creditHistory->getAmount() > -0.01 && $creditHistory->getAmount() < 0.01) { | |||
return false; |
@@ -3,16 +3,12 @@ | |||
namespace common\logic\CreditHistory; | |||
use common\logic\ContainerInterface; | |||
use common\logic\CreditHistory\CreditHistoryBuilder; | |||
use common\logic\CreditHistory\CreditHistoryFactory; | |||
use common\logic\CreditHistory\CreditHistoryRepository; | |||
use common\logic\CreditHistory\CreditHistorySolver; | |||
class CreditHistoryContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return CreditHistory::class; | |||
return CreditHistoryModel::class; | |||
} | |||
public function getServices(): array |
@@ -8,7 +8,7 @@ class CreditHistoryFactory implements FactoryInterface | |||
{ | |||
public function create() | |||
{ | |||
$creditHistory = new CreditHistory(); | |||
$creditHistory = new CreditHistoryModel(); | |||
return $creditHistory; | |||
} |
@@ -17,8 +17,8 @@ class CreditHistoryRepository extends BaseService implements RepositoryInterface | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => CreditHistory::tableName() . '.date ASc', | |||
'attribute_id_producer' => CreditHistory::tableName() . '.id_producer' | |||
'orderby' => CreditHistoryModel::tableName() . '.date ASc', | |||
'attribute_id_producer' => CreditHistoryModel::tableName() . '.id_producer' | |||
]; | |||
} | |||
} |
@@ -13,8 +13,8 @@ class CreditHistorySolver implements SolverInterface | |||
public function isTypeDebit(CreditHistoryModel $creditHistory): bool | |||
{ | |||
return in_array($creditHistory->type, [ | |||
CreditHistory::TYPE_DEBIT, | |||
CreditHistory::TYPE_PAYMENT, | |||
CreditHistoryModel::TYPE_DEBIT, | |||
CreditHistoryModel::TYPE_PAYMENT, | |||
]); | |||
} | |||
@@ -1,14 +1,11 @@ | |||
<?php | |||
namespace common\services\Producer; | |||
namespace common\logic\Producer; | |||
use common\helpers\Password; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\ServiceInterface; | |||
use common\models\Producer; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\repositories\ProducerRepository; | |||
class ProducerBuilder extends BaseService implements BuilderInterface | |||
{ | |||
@@ -19,13 +16,13 @@ class ProducerBuilder extends BaseService implements BuilderInterface | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
} | |||
public function init(Producer $producer): void | |||
public function init(ProducerModel $producer): void | |||
{ | |||
$this->initSlug($producer); | |||
$this->initCode($producer); | |||
} | |||
public function initSlug(Producer $producer): void | |||
public function initSlug(ProducerModel $producer): void | |||
{ | |||
$cptSlug = 0 ; | |||
do { | |||
@@ -38,7 +35,7 @@ class ProducerBuilder extends BaseService implements BuilderInterface | |||
} while($this->producerRepository->getOneBySlug($producer->slug)) ; | |||
} | |||
public function initCode(Producer $producer): void | |||
public function initCode(ProducerModel $producer): void | |||
{ | |||
$producer->code = Password::generate(); | |||
} |
@@ -3,8 +3,6 @@ | |||
namespace common\logic\Producer; | |||
use common\logic\ContainerInterface; | |||
use common\services\Producer\ProducerBuilder; | |||
use common\services\Producer\ProducerFactory; | |||
use common\services\Producer\ProducerUtils; | |||
class ProducerContainer implements ContainerInterface |
@@ -1,16 +1,15 @@ | |||
<?php | |||
namespace common\services\Producer; | |||
namespace common\logic\Producer; | |||
use common\logic\BaseService; | |||
use common\models\Producer; | |||
use common\logic\FactoryInterface; | |||
class ProducerFactory extends BaseService implements FactoryInterface | |||
{ | |||
public function create() | |||
{ | |||
$producer = new Producer; | |||
$producer = new ProducerModel(); | |||
$producer->order_deadline = 20; | |||
$producer->order_delay = 1; |
@@ -3,12 +3,12 @@ | |||
namespace common\services\Producer; | |||
use common\logic\BaseService; | |||
use common\logic\Producer\ProducerModel; | |||
use common\logic\UtilsInterface; | |||
use common\models\Producer; | |||
class ProducerUtils extends BaseService implements UtilsInterface | |||
{ | |||
public function sendEmailNewProducer(Producer $producer) | |||
public function sendEmailNewProducer(ProducerModel $producer) | |||
{ | |||
\Yii::$app->mailer->compose( | |||
[ |
@@ -3,13 +3,12 @@ | |||
namespace common\logic\ProducerPriceRange; | |||
use common\logic\ContainerInterface; | |||
use common\models\ProducerPriceRange; | |||
class ProducerPriceRangeContainer implements ContainerInterface | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return ProducerPriceRange::class; | |||
return ProducerPriceRangeModel::class; | |||
} | |||
public function getServices(): array |
@@ -4,12 +4,11 @@ namespace common\logic\ProducerPriceRange; | |||
use common\logic\BaseService; | |||
use common\logic\RepositoryInterface; | |||
use common\models\ProducerPriceRange; | |||
class ProducerPriceRangeRepository extends BaseService implements RepositoryInterface | |||
{ | |||
public function query() | |||
{ | |||
return ProducerPriceRange::find()->orderBy('range_begin ASC'); | |||
return ProducerPriceRangeModel::find()->orderBy('range_begin ASC'); | |||
} | |||
} |
@@ -1,10 +1,9 @@ | |||
<?php | |||
namespace common\services\User; | |||
namespace common\logic\User; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\models\UserModel; | |||
class UserBuilder extends BaseService implements BuilderInterface | |||
{ |
@@ -3,8 +3,6 @@ | |||
namespace common\logic\User; | |||
use common\logic\ContainerInterface; | |||
use common\logic\User\UserModel; | |||
use common\services\User\UserBuilder; | |||
use common\services\User\UserFactory; | |||
use common\services\User\UserUtils; | |||
@@ -1,10 +1,9 @@ | |||
<?php | |||
namespace common\services\User; | |||
namespace common\logic\User; | |||
use common\logic\BaseService; | |||
use common\logic\FactoryInterface; | |||
use common\models\UserModel; | |||
class UserFactory extends BaseService implements FactoryInterface | |||
{ |
@@ -4,8 +4,8 @@ namespace common\services\User; | |||
use common\logic\BaseService; | |||
use common\logic\Producer\ProducerModel; | |||
use common\logic\User\UserModel; | |||
use common\logic\UtilsInterface; | |||
use common\models\UserModel; | |||
class UserUtils extends BaseService implements UtilsInterface | |||
{ |
@@ -8,9 +8,9 @@ use common\logic\BuilderInterface; | |||
use common\logic\CreditHistory\CreditHistoryModel; | |||
use common\logic\CreditHistory\CreditHistorySolver; | |||
use common\logic\Producer\ProducerModel; | |||
use common\logic\UserProducer\UserProducerRepository; | |||
use common\models\Order; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\repositories\UserProducerRepository; | |||
class UserProducerBuilder extends BaseService implements BuilderInterface | |||
{ | |||
@@ -67,8 +67,8 @@ class UserProducerBuilder extends BaseService implements BuilderInterface | |||
public function sendCreditLimitReminder($userProducer, $creditHistory, $oldCredit) | |||
{ | |||
$userRepository = Yii::$app->logic->getUserContainer()->getRepository(); | |||
$producerRepository = Yii::$app->logic->getProducerContainer()->getRepository(); | |||
$userRepository = \Yii::$app->logic->getUserContainer()->getRepository(); | |||
$producerRepository = \Yii::$app->logic->getProducerContainer()->getRepository(); | |||
$newCredit = $userProducer->credit; | |||
if ($this->isCreditLimitCrossed($oldCredit, $newCredit)) { | |||
@@ -76,7 +76,7 @@ class UserProducerBuilder extends BaseService implements BuilderInterface | |||
$user = $userRepository->getOneById($creditHistory->id_user); | |||
$producer = $producerRepository->getOneById($creditHistory->id_producer); | |||
Yii::$app->mailer->compose( | |||
\Yii::$app->mailer->compose( | |||
[ | |||
'html' => 'creditLimitReminder-html', | |||
'text' => 'creditLimitReminder-text' |
@@ -4,7 +4,7 @@ namespace common\containers; | |||
use common\logic\ContainerInterface; | |||
use common\logic\UserProducer\UserProducerModel; | |||
use common\repositories\UserProducerRepository; | |||
use common\logic\UserProducer\UserProducerRepository; | |||
class UserProducerContainer implements ContainerInterface | |||
{ | |||
@@ -21,7 +21,7 @@ class UserProducerContainer implements ContainerInterface | |||
} | |||
public function getRepository() | |||
public function getRepository(): UserProducerRepository | |||
{ | |||
return new UserProducerRepository(); | |||
} |
@@ -4,7 +4,6 @@ namespace common\logic\UserProducer; | |||
use common\logic\BaseService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\UserProducer\UserProducerModel; | |||
class UserProducerRepository extends BaseService implements RepositoryInterface | |||
{ |
@@ -1,95 +0,0 @@ | |||
<?php | |||
/** | |||
* Copyright distrib (2018) | |||
* | |||
* contact@opendistrib.net | |||
* | |||
* Ce logiciel est un programme informatique servant à aider les producteurs | |||
* à distribuer leur production en circuits courts. | |||
* | |||
* Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
* respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
* utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
* sur le site "http://www.cecill.info". | |||
* | |||
* En contrepartie de l'accessibilité au code source et des droits de copie, | |||
* de modification et de redistribution accordés par cette licence, il n'est | |||
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
* seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
* titulaire des droits patrimoniaux et les concédants successifs. | |||
* | |||
* A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
* associés au chargement, à l'utilisation, à la modification et/ou au | |||
* développement et à la reproduction du logiciel par l'utilisateur étant | |||
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
* manipuler et qui le réserve donc à des développeurs et des professionnels | |||
* avertis possédant des connaissances informatiques approfondies. Les | |||
* utilisateurs sont donc invités à charger et tester l'adéquation du | |||
* logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
* sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
* | |||
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
* pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
* termes. | |||
*/ | |||
namespace common\models; | |||
use common\components\ActiveRecordCommon; | |||
/** | |||
* This is the model class for table "producer_price_range". | |||
* | |||
* @property integer $id | |||
*/ | |||
class ProducerPriceRange extends ActiveRecordCommon | |||
{ | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public static function tableName() | |||
{ | |||
return 'producer_price_range'; | |||
} | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function rules() | |||
{ | |||
return [ | |||
[['range_begin', 'range_end', 'price'], 'double'], | |||
]; | |||
} | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function attributeLabels() | |||
{ | |||
return [ | |||
'id' => 'ID', | |||
'range_begin' => 'Début', | |||
'range_end' => 'Fin', | |||
'price' => 'Tarif (HT)', | |||
]; | |||
} | |||
/** | |||
* Retourne les options de base nécessaires à la fonction de recherche. | |||
* | |||
* @return array | |||
*/ | |||
public static function defaultOptionsSearch() | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
]; | |||
} | |||
} |