Browse Source

Refactoring services #885

refactoring
Guillaume 1 year ago
parent
commit
8c04298775
8 changed files with 21 additions and 24 deletions
  1. +8
    -6
      backend/controllers/DistributionController.php
  2. +2
    -2
      common/components/BusinessLogicTrait.php
  3. +3
    -4
      common/helpers/CSV.php
  4. +3
    -3
      common/helpers/Mailjet.php
  5. +0
    -1
      common/helpers/MeanPayment.php
  6. +0
    -2
      common/helpers/Opendistrib.php
  7. +2
    -3
      common/helpers/Tiller.php
  8. +3
    -3
      common/helpers/Url.php

+ 8
- 6
backend/controllers/DistributionController.php View File

$creditHistoryManager = $this->getCreditHistoryManager(); $creditHistoryManager = $this->getCreditHistoryManager();
$userManager = $this->getUserManager(); $userManager = $this->getUserManager();
$subscriptionManager = $this->getSubscriptionManager(); $subscriptionManager = $this->getSubscriptionManager();
$pointSaleManager = $this->getPointSaleManager();

$producer = $this->getProducerCurrent();


$json = [ $json = [
'distribution' => [], 'distribution' => [],
$dateEnd = strtotime('+' . $numberOfLoadedMonthes); $dateEnd = strtotime('+' . $numberOfLoadedMonthes);
} }


$producer = $this->getProducerCurrent();
$json['producer'] = [ $json['producer'] = [
'credit' => $producer->credit, 'credit' => $producer->credit,
'tiller' => $producer->tiller, 'tiller' => $producer->tiller,
} }
]) ])
->where([ ->where([
'id_producer' => GlobalParam::getCurrentProducerId(),
'id_producer' => $producer->id,
]) ])
->asArray() ->asArray()
->all(); ->all();
$json['missing_subscriptions'] = []; $json['missing_subscriptions'] = [];
if ($distribution->active) { if ($distribution->active) {
foreach ($arraySubscriptions as $subscription) { foreach ($arraySubscriptions as $subscription) {
if (!$subscription->hasOrderAlreadyExist($ordersArrayObject)
if (!$subscriptionManager->hasOrderAlreadyExist($subscription, $ordersArrayObject)
&& $subscription->productSubscription && count($subscription->productSubscription) && $subscription->productSubscription && count($subscription->productSubscription)
&& $subscription->id_point_sale && $subscription->id_point_sale > 0) { && $subscription->id_point_sale && $subscription->id_point_sale > 0) {
$json['missing_subscriptions'][] = [ $json['missing_subscriptions'][] = [
'username' => $subscription->getUsername()
'username' => $subscriptionManager->getUsername($subscription)
]; ];
} }
} }
$deliveryNoteManager->initTaxCalculationMethod($deliveryNote); $deliveryNoteManager->initTaxCalculationMethod($deliveryNote);
$deliveryNote->id_producer = GlobalParam::getCurrentProducerId(); $deliveryNote->id_producer = GlobalParam::getCurrentProducerId();
$deliveryNote->id_user = $order->id_user; $deliveryNote->id_user = $order->id_user;
$deliveryNote->name = 'Bon de livraison ' . $order->getUsername() . ' (' . date(
$deliveryNote->name = 'Bon de livraison ' . $orderManager->getOrderUsername($order) . ' (' . date(
'd/m/Y', 'd/m/Y',
strtotime( strtotime(
$order->distribution->date $order->distribution->date
) )
) . ')'; ) . ')';
$deliveryNote->address = $order->user->getFullAddress();
$deliveryNote->address = $userManager->getFullAddress($order->user);
$deliveryNote->save(); $deliveryNote->save();
} }



+ 2
- 2
common/components/BusinessLogicTrait.php View File



namespace common\components; namespace common\components;


use common\logic\Config\TaxRate\TaxRateContainer;
use common\logic\Config\TaxRate\TaxRateManager;
use common\logic\Config\TaxRate\Wrapper\TaxRateContainer;
use common\logic\Config\TaxRate\Wrapper\TaxRateManager;
use common\logic\Distribution\Distribution\Wrapper\DistributionManager; use common\logic\Distribution\Distribution\Wrapper\DistributionManager;
use common\logic\Distribution\Distribution\Wrapper\DistributionContainer; use common\logic\Distribution\Distribution\Wrapper\DistributionContainer;
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionContainer; use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionContainer;

+ 3
- 4
common/helpers/CSV.php View File

* termes. * termes.
*/ */



namespace common\helpers; namespace common\helpers;


use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;


class CSV class CSV
{ {

public static function array2csv(array &$array) public static function array2csv(array &$array)
{ {
$separator = Producer::getConfig('option_csv_separator') ?: ';';
$producerManager = ProducerManager::getInstance();
$separator = $producerManager->getConfig('option_csv_separator') ?: ';';


if (count($array) == 0) { if (count($array) == 0) {
return null; return null;

+ 3
- 3
common/helpers/Mailjet.php View File

] ]
], ],
'Subject' => $params['subject'], 'Subject' => $params['subject'],
'TextPart' => Yii::$app->view->renderFile($params['content_view_text'], $params['content_params']),
'HTMLPart' => Yii::$app->view->renderFile($params['content_view_html'], $params['content_params'])
'TextPart' => \Yii::$app->view->renderFile($params['content_view_text'], $params['content_params']),
'HTMLPart' => \Yii::$app->view->renderFile($params['content_view_html'], $params['content_params'])
] ; ] ;


$response = $mj->post(\Mailjet\Resources::$Email, ['body' => $body]); $response = $mj->post(\Mailjet\Resources::$Email, ['body' => $body]);
$success = $response->success() ; $success = $response->success() ;


if(!$success) { if(!$success) {
Yii::error($response->getBody(), 'Mailjet');
\Yii::error($response->getBody(), 'Mailjet');
} }


return $success ; return $success ;

+ 0
- 1
common/helpers/MeanPayment.php View File

self::CHEQUE => self::getStrBy(self::CHEQUE), self::CHEQUE => self::getStrBy(self::CHEQUE),
self::TRANSFER => self::getStrBy(self::TRANSFER), self::TRANSFER => self::getStrBy(self::TRANSFER),
self::OTHER => self::getStrBy(self::OTHER), self::OTHER => self::getStrBy(self::OTHER),
self::CREDIT => self::getStrBy(self::CREDIT),
] ; ] ;
} }

+ 0
- 2
common/helpers/Opendistrib.php View File

* termes. * termes.
*/ */



namespace common\helpers; namespace common\helpers;


class Opendistrib class Opendistrib
{ {

public static function getVersions() public static function getVersions()
{ {
$versionsArray = []; $versionsArray = [];

+ 2
- 3
common/helpers/Tiller.php View File



namespace common\helpers; namespace common\helpers;


use common\logic\Order\Order\Order;
use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\ProducerManager;
use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use linslin\yii2\curl; use linslin\yii2\curl;


class Tiller class Tiller

+ 3
- 3
common/helpers/Url.php View File

{ {
public static function frontend($action = '') public static function frontend($action = '')
{ {
$server_name = Yii::$app->getRequest()->serverName ;
$server_name = \Yii::$app->getRequest()->serverName ;
$address = '' ; $address = '' ;
if($server_name == 'localhost') if($server_name == 'localhost')
{ {
public static function backend($action = '') public static function backend($action = '')
{ {
$server_name = Yii::$app->getRequest()->serverName ;
$server_name = \Yii::$app->getRequest()->serverName ;
$address = '' ; $address = '' ;
if($server_name == 'localhost') if($server_name == 'localhost')
{ {
public static function env($env, $section) public static function env($env, $section)
{ {
$server_name = Yii::$app->getRequest()->serverName ;
$server_name = \Yii::$app->getRequest()->serverName ;
if($section == 'backend') if($section == 'backend')
{ {

Loading…
Cancel
Save