Преглед на файлове

[Administration] Commande > édition commande : correctif point de vente par défaut

feature/souke
Guillaume Bourgeois преди 10 месеца
родител
ревизия
69ce4ac46c
променени са 8 файла, в които са добавени 69 реда и са изтрити 10 реда
  1. +4
    -2
      backend/controllers/DistributionController.php
  2. +2
    -0
      backend/views/distribution/index.php
  3. +2
    -1
      backend/web/js/vuejs/distribution-index.js
  4. +8
    -2
      common/logic/Order/Order/Repository/OrderRepository.php
  5. +23
    -2
      common/logic/PointSale/PointSale/Service/PointSaleSolver.php
  6. +8
    -0
      common/logic/PointSale/UserPointSale/Module/UserPointSaleModule.php
  7. +12
    -3
      common/logic/PointSale/UserPointSale/Repository/UserPointSaleRepository.php
  8. +10
    -0
      common/logic/PointSale/UserPointSale/Service/UserPointSaleSolver.php

+ 4
- 2
backend/controllers/DistributionController.php Целия файл

@@ -449,17 +449,19 @@ class DistributionController extends BackendController
return $missingSubscriptionsArray;
}

public function actionAjaxPointSaleFavorite($idUser)
public function actionAjaxPointSaleFavorite($idUser, $idDistribution)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$userModule = $this->getUserModule();
$orderModule = $this->getOrderModule();
$distributionModule = $this->getDistributionModule();

$user = $userModule->findOneUserById($idUser);
$distribution = $distributionModule->getRepository()->findOneDistributionById($idDistribution);
$idFavoritePointSale = 0;

if($user) {
$favoritePointSale = $orderModule->getUserFavoritePointSale($user);
$favoritePointSale = $orderModule->getUserFavoritePointSale($user, $distribution);
if ($favoritePointSale) {
$idFavoritePointSale = $favoritePointSale->id;
}

+ 2
- 0
backend/views/distribution/index.php Целия файл

@@ -249,6 +249,7 @@ $this->setPageTitle('Distributions') ;
v-if="showModalFormOrderCreate"
create="1"
:date="date"
:distribution="distribution"
:order="orderCreate"
:points-sale="pointsSale"
:id-active-point-sale="idActivePointSale"
@@ -505,6 +506,7 @@ $this->setPageTitle('Distributions') ;
<order-form
v-if="showModalFormOrderUpdate && idOrderUpdate == order.id"
create="0"
:distribution="distribution"
:date="date"
:date-format="dateFormat"
:points-sale="pointsSale"

+ 2
- 1
backend/web/js/vuejs/distribution-index.js Целия файл

@@ -971,7 +971,7 @@ Vue.component('modal', {
});

Vue.component('order-form', {
props: ['date', 'dateFormat', 'pointsSale', 'idActivePointSale', 'meansPayment', 'users', 'products', 'order', 'orders', 'producer', 'loadingUpdateProductOrder', 'create', 'units'],
props: ['distribution', 'date', 'dateFormat', 'pointsSale', 'idActivePointSale', 'meansPayment', 'users', 'products', 'order', 'orders', 'producer', 'loadingUpdateProductOrder', 'create', 'units'],
emits: ['updateProductPrice', 'updateInvoicePrices'],
data: function () {
return {
@@ -1166,6 +1166,7 @@ Vue.component('order-form', {
axios.get(UrlManager.getBaseUrlAbsolute() + "distribution/ajax-point-sale-favorite", {
params: {
idUser: app.order.id_user,
idDistribution: app.distribution.id
}
})
.then(function (response) {

+ 8
- 2
common/logic/Order/Order/Repository/OrderRepository.php Целия файл

@@ -20,6 +20,7 @@ use common\logic\Payment\Model\Payment;
use common\logic\Payment\Service\PaymentSolver;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Repository\PointSaleRepository;
use common\logic\PointSale\PointSale\Service\PointSaleSolver;
use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Repository\ProducerRepository;
@@ -46,6 +47,7 @@ class OrderRepository extends AbstractRepository
protected InvoiceSolver $invoiceSolver;
protected PaymentSolver $paymentSolver;
protected ProducerSolver $producerSolver;
protected PointSaleSolver $pointSaleSolver;

public function loadDependencies(): void
{
@@ -63,6 +65,7 @@ class OrderRepository extends AbstractRepository
$this->invoiceSolver = $this->loadService(InvoiceSolver::class);
$this->paymentSolver = $this->loadService(PaymentSolver::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
$this->pointSaleSolver = $this->loadService(PointSaleSolver::class);
}

public function getDefaultOptionsSearch(): array
@@ -409,10 +412,10 @@ class OrderRepository extends AbstractRepository
* Retourne le point de vente favoris d'un utilisateur : le point de vente auquel le client est lié,
* le point de vente de la dernière commande sinon.
*/
public function getUserFavoritePointSale(User $user): ?PointSale
public function getUserFavoritePointSale(User $user, Distribution $distribution = null): ?PointSale
{
$pointSale = null;
$arrayUserPointSale = $this->userPointSaleRepository->findUserPointSalesByUser($user);
$arrayUserPointSale = $this->userPointSaleRepository->findUserPointSalesByUser($user, $distribution);

if (count($arrayUserPointSale) == 1) {
$pointSale = $this->pointSaleRepository->findOnePointSaleById($arrayUserPointSale[0]->id_point_sale);
@@ -420,6 +423,9 @@ class OrderRepository extends AbstractRepository
$lastOrder = $this->findOneOrderLastByUser($user);
if ($lastOrder) {
$pointSale = $this->pointSaleRepository->findOnePointSaleById($lastOrder->id_point_sale);
if($distribution && !$this->pointSaleSolver->isDelivered($pointSale, $distribution)) {
$pointSale = null;
}
}
}


+ 23
- 2
common/logic/PointSale/PointSale/Service/PointSaleSolver.php Целия файл

@@ -4,14 +4,35 @@ namespace common\logic\PointSale\PointSale\Service;

use common\helpers\GlobalParam;
use common\logic\AbstractService;
use common\logic\Order\Order\Model\Order;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\SolverInterface;
use yii\helpers\Html;

class PointSaleSolver extends AbstractService implements SolverInterface
{
public function filterUserPointSalesByDistribution(array $userPointSaleArray, Distribution $distribution): array
{
foreach($userPointSaleArray as $key => $userPointSale) {
if(!$this->isDelivered($userPointSale->pointSale, $distribution)) {
unset($userPointSaleArray[$key]);
}
}

return $userPointSaleArray;
}

public function isDelivered(PointSale $pointSale, Distribution $distribution): bool
{
foreach($distribution->pointSaleDistribution as $pointSaleDistribution) {
if($pointSaleDistribution->pointSale->id == $pointSale->id && $pointSaleDistribution->delivery) {
return true;
}
}

return false;
}

/**
* Retourne le commentaire de l'utilisateur courant lié au point de vente.
*/

+ 8
- 0
common/logic/PointSale/UserPointSale/Module/UserPointSaleModule.php Целия файл

@@ -6,11 +6,13 @@ use common\logic\AbstractModule;
use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository;
use common\logic\PointSale\UserPointSale\Service\UserPointSaleBuilder;
use common\logic\PointSale\UserPointSale\Service\UserPointSaleDefinition;
use common\logic\PointSale\UserPointSale\Service\UserPointSaleSolver;

/**
* @mixin UserPointSaleDefinition
* @mixin UserPointSaleRepository
* @mixin UserPointSaleBuilder
* @mixin UserPointSaleSolver
*/
class UserPointSaleModule extends AbstractModule
{
@@ -20,6 +22,7 @@ class UserPointSaleModule extends AbstractModule
UserPointSaleDefinition::class,
UserPointSaleRepository::class,
UserPointSaleBuilder::class,
UserPointSaleSolver::class
];
}

@@ -37,4 +40,9 @@ class UserPointSaleModule extends AbstractModule
{
return UserPointSaleBuilder::getInstance();
}

public function getSolver(): UserPointSaleSolver
{
return UserPointSaleSolver::getInstance();
}
}

+ 12
- 3
common/logic/PointSale/UserPointSale/Repository/UserPointSaleRepository.php Целия файл

@@ -3,17 +3,20 @@
namespace common\logic\PointSale\UserPointSale\Repository;

use common\logic\AbstractRepository;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\UserPointSale\Model\UserPointSale;
use common\logic\PointSale\PointSale\Service\PointSaleSolver;
use common\logic\User\User\Model\User;

class UserPointSaleRepository extends AbstractRepository
{
protected UserPointSaleRepositoryQuery $query;
protected PointSaleSolver $pointSaleSolver;

public function loadDependencies(): void
{
$this->loadQuery(UserPointSaleRepositoryQuery::class);
$this->pointSaleSolver = $this->loadService(PointSaleSolver::class);
}

public function getDefaultOptionsSearch(): array
@@ -26,12 +29,18 @@ class UserPointSaleRepository extends AbstractRepository
] ;
}

public function findUserPointSalesByUser(User $user): array
public function findUserPointSalesByUser(User $user, Distribution $distribution = null): array
{
return $this->createDefaultQuery()
$userPointSalesArray = $this->createDefaultQuery()
->joinPointSale()
->filterByUser($user)
->find();

if($distribution) {
$userPointSalesArray = $this->pointSaleSolver->filterUserPointSalesByDistribution($userPointSalesArray, $distribution);
}

return $userPointSalesArray;
}

public function findOneUserPointSale(User $user = null, PointSale $pointSale = null)

+ 10
- 0
common/logic/PointSale/UserPointSale/Service/UserPointSaleSolver.php Целия файл

@@ -0,0 +1,10 @@
<?php

namespace common\logic\PointSale\UserPointSale\Service;

use common\logic\AbstractSolver;

class UserPointSaleSolver extends AbstractSolver
{

}

Loading…
Отказ
Запис