소스 검색

[Boutique] Commander : refonte paiement

feature/rotating_product
Guillaume Bourgeois 7 달 전
부모
커밋
0e9f8ad0a9
21개의 변경된 파일227개의 추가작업 그리고 108개의 파일을 삭제
  1. +9
    -0
      backend/controllers/PointSaleController.php
  2. +3
    -3
      backend/views/distribution/index.php
  3. +2
    -2
      backend/views/distribution/report-bourlingue.php
  4. +3
    -3
      backend/views/order/report.php
  5. +3
    -3
      backend/views/point-sale/index.php
  6. +2
    -1
      backend/web/css/screen.css
  7. +2
    -1
      backend/web/sass/point_sale/_index.scss
  8. +3
    -3
      domain/Distribution/Distribution/Export/DistributionReportPdfGenerator.php
  9. +1
    -1
      domain/Order/Order/OrderBuilder.php
  10. +4
    -4
      domain/Order/Order/OrderRepository.php
  11. +23
    -0
      domain/PointSale/PointSale/PointSaleBuilder.php
  12. +3
    -3
      domain/Producer/Producer/Producer.php
  13. +10
    -7
      producer/controllers/OrderController.php
  14. +1
    -1
      producer/views/order/_form.php
  15. +1
    -1
      producer/views/order/confirm.php
  16. +3
    -5
      producer/views/order/history.php
  17. +82
    -58
      producer/views/order/order.php
  18. +12
    -7
      producer/web/css/screen.css
  19. +51
    -2
      producer/web/js/vuejs/order-order.js
  20. +1
    -1
      producer/web/sass/order/_form.scss
  21. +8
    -2
      producer/web/sass/order/_order.scss

+ 9
- 0
backend/controllers/PointSaleController.php 파일 보기

@@ -99,6 +99,7 @@ class PointSaleController extends BackendController
if ($pointSale->load(\Yii::$app->request->post()) && $pointSale->save()) {
$pointSaleModule->updatePointSalePointProduction($pointSale);
$pointSaleModule->processRestrictedAccess($pointSale);
$this->initPaymentMethodOnsiteByCreditFunctioning($pointSale);
$distributionModule->addPointSaleIncomingDistributions($pointSale);

return $this->redirect(['index']);
@@ -127,6 +128,7 @@ class PointSaleController extends BackendController

$pointSaleModule->updatePointSalePointProduction($model);
$pointSaleModule->processRestrictedAccess($model);
$this->initPaymentMethodOnsiteByCreditFunctioning($model);
$distributionModule->addPointSaleIncomingDistributions($model);

$this->setFlash('success', 'Point de vente modifié.');
@@ -139,6 +141,13 @@ class PointSaleController extends BackendController
}
}

public function initPaymentMethodOnsiteByCreditFunctioning(PointSale $pointSale)
{
if($this->getPointSaleModule()->getBuilder()->initPaymentMethodOnsiteByCreditFunctioning($pointSale)) {
$this->addFlash('info', 'Le paiement sur place a été ajusté par rapport au fonctionnement de la cagnotte.');
}
}

/**
* Initialise le formulaire de création/modification.
*/

+ 3
- 3
backend/views/distribution/index.php 파일 보기

@@ -341,7 +341,7 @@ $this->setPageTitle('Distributions') ;
</div>
<div v-if="producer.credit && pointSaleActive">
<span class="title">Cagnotte</span>
<template v-if="pointSaleActive.credit && pointSaleActive.credit == 1">
<template v-if="pointSaleActive.payment_method_credit && pointSaleActive.payment_method_credit == 1">
<template v-if="pointSaleActive.credit_functioning == 'mandatory'">Obligatoire</template>
<template v-else-if="pointSaleActive.credit_functioning == 'user'">Basé sur l'utilisateur</template>
<template v-else-if="pointSaleActive.credit_functioning == 'optional'">Optionnel</template>
@@ -362,7 +362,7 @@ $this->setPageTitle('Distributions') ;
<th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th>
<th class="column-amount">Montant</th>
<th class="column-state-payment">Paiement</th>
<th class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">Cagnotte</th>
<th class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.payment_method_credit == 1)">Cagnotte</th>
<th class="column-actions">Actions</th>
<th class="column-tiller" v-if="producer && producer.tiller">Tiller</th>
</tr>
@@ -420,7 +420,7 @@ $this->setPageTitle('Distributions') ;
<span class="glyphicon glyphicon-time" title="Débit automatique de la cagnotte la veille de la distribution" v-if="order.amount != 0 && order.isCreditAutoPayment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
</template>
</td>
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.payment_method_credit == 1)">
<template v-if="order.isCreditContext">
<a :href="baseUrl+'/user/credit?id='+order.id_user" target="_blank" :class="order.user.credit >= 0 ? 'positive' : 'negative'">
{{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}

+ 2
- 2
backend/views/distribution/report-bourlingue.php 파일 보기

@@ -142,7 +142,7 @@ foreach ($pointsSaleArray as $pointSale) {
}
$html .= '</td>' ;

if($pointSale->credit) {
if($pointSale->payment_method_credit) {
$credit = '' ;

if(isset($order->user) && $order->user->id) {
@@ -188,7 +188,7 @@ foreach ($pointsSaleArray as $pointSale) {
$strProducts = substr($strProducts, 0, strlen($strProducts) - 6) ;
$html .= '<td>'.$strProducts.'</td><td></td><td></td><td></td>' ;
if($pointSale->credit) {
if($pointSale->payment_method_credit) {
$html .= '<td></td>' ;
}
$html .= '<td><strong>'.Price::format($pointSale->revenues_with_tax) . '</strong></td>';

+ 3
- 3
backend/views/order/report.php 파일 보기

@@ -52,7 +52,7 @@ foreach ($pointsSaleArray as $pointSale) {
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) {
$html .= '<h3>'.$pointSale->name.'</h3>' ;
$colCredit = ($pointSale->credit) ? '<th>Cagnotte</th>' : '' ;
$colCredit = ($pointSale->payment_method_credit) ? '<th>Cagnotte</th>' : '' ;
$html .= '<table class="table table-bordered">'
. '<thead>'
@@ -103,7 +103,7 @@ foreach ($pointsSaleArray as $pointSale) {
$html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 2).'</td>';
$html .= '<td>'.$order->comment.'</td>';
if($pointSale->credit) {
if($pointSale->payment_method_credit) {
$credit = '' ;
if(isset($order->user) && isset($order->user->userProducer)) {
$credit = number_format($order->user->userProducer[0]->credit,2).' €' ;
@@ -147,7 +147,7 @@ foreach ($pointsSaleArray as $pointSale) {
$strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ;
$html .= '<td>'.$strProducts.'</td><td></td>' ;
if($pointSale->credit) {
if($pointSale->payment_method_credit) {
$html .= '<td></td>' ;
}
$html .= '<td><strong>'.number_format($pointSale->revenues, 2) . ' €</strong></td>';

+ 3
- 3
backend/views/point-sale/index.php 파일 보기

@@ -143,13 +143,13 @@ $this->addButton(
'value' => function ($model) {
$html = '<ul>';
if($model->payment_method_onsite) {
$html .= "<li>Sur place</li>";
$html .= '<li><i class="bi bi-wallet2"></i> Sur place</li>';
}
if ($model->payment_method_credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) {
$html .= "<li>Cagnotte (". strtolower(Producer::$creditFunctioningArray[$model->credit_functioning]).")</li>";
$html .= '<li><i class="bi bi-piggy-bank"></i> Cagnotte ('. strtolower(Producer::$creditFunctioningArray[$model->credit_functioning]).')</li>';
}
if ($model->payment_method_online) {
$html .= "<li>Paiement en ligne</li>";
$html .= '<li><i class="bi bi-credit-card"></i> Paiement en ligne</li>';
}
$html .= '</ul>';
return $html;

+ 2
- 1
backend/web/css/screen.css 파일 보기

@@ -2773,8 +2773,9 @@ termes.
}
/* line 8, ../sass/point_sale/_index.scss */
.point-sale-index table .column-payment-method ul {
list-style-type: none;
padding: 0px;
padding-left: 15px;
padding-left: 5px;
margin: 0px;
}


+ 2
- 1
backend/web/sass/point_sale/_index.scss 파일 보기

@@ -6,8 +6,9 @@
}
.column-payment-method {
ul {
list-style-type: none;
padding: 0px;
padding-left: 15px;
padding-left: 5px;
margin: 0px;
}
}

+ 3
- 3
domain/Distribution/Distribution/Export/DistributionReportPdfGenerator.php 파일 보기

@@ -149,7 +149,7 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri

$html .= '<h3>'.$pointSale->name.'</h3>' ;
$columnDeliveryNote = ($producer->option_export_display_column_delivery_note) ? '<th>BL</th>' : '';
$colCredit = ($pointSale->credit) ? '<th>Cagnotte</th>' : '' ;
$colCredit = ($pointSale->payment_method_credit) ? '<th>Cagnotte</th>' : '' ;

$html .= '<table class="">'
. '<thead>'
@@ -197,7 +197,7 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri
}

$html .= '<td>'.$strProducts.'</td><td></td>' ;
if($pointSale->credit) {
if($pointSale->payment_method_credit) {
$html .= '<td></td>' ;
}
if($producer->option_export_display_column_delivery_note) {
@@ -282,7 +282,7 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri

public function columnCredit(Order $order, PointSale $pointSale): string
{
if($pointSale->credit) {
if($pointSale->payment_method_credit) {
$credit = '' ;

if(isset($order->user) && $order->user->id) {

+ 1
- 1
domain/Order/Order/OrderBuilder.php 파일 보기

@@ -176,7 +176,7 @@ class OrderBuilder extends AbstractBuilder

$order->auto_payment = 0;
if ($subscription->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->payment_method_credit) {
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
$order->auto_payment = 0;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {

+ 4
- 4
domain/Order/Order/OrderRepository.php 파일 보기

@@ -357,7 +357,7 @@ class OrderRepository extends AbstractRepository
if($pointSale) {
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale);

if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->payment_method_credit) {
if($order->mean_payment == MeanPayment::CREDIT || $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
return true;
}
@@ -387,7 +387,7 @@ class OrderRepository extends AbstractRepository

if($pointSale) {
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale);
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->payment_method_credit) {
if($order->mean_payment == MeanPayment::CREDIT
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
@@ -665,7 +665,7 @@ class OrderRepository extends AbstractRepository
public function isOrderCreditFunctioningMandatory(Order $order): bool
{
$pointSale = $order->pointSale;
return $pointSale && $pointSale->credit && $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY;
return $pointSale && $pointSale->payment_method_credit && $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY;
}

public function isOrderCreditFunctioningUser(Order $order): bool
@@ -678,7 +678,7 @@ class OrderRepository extends AbstractRepository
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user);

return $pointSale
&& $pointSale->credit
&& $pointSale->payment_method_credit
&& $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_USER
&& $userProducer
&& $userProducer->credit_active;

+ 23
- 0
domain/PointSale/PointSale/PointSaleBuilder.php 파일 보기

@@ -89,4 +89,27 @@ class PointSaleBuilder extends AbstractBuilder
{
return $this->userPointSaleBuilder->createUserPointSaleIfNotExist($user, $pointSale);
}

public function initPaymentMethodOnsiteByCreditFunctioning(PointSale $pointSale): bool
{
if($pointSale->payment_method_credit) {
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && !$pointSale->payment_method_onsite) {
$pointSale->payment_method_onsite = true;
$this->update($pointSale);
return true;
}
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY && $pointSale->payment_method_onsite) {
$pointSale->payment_method_onsite = false;
$this->update($pointSale);
return true;
}
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY && $pointSale->payment_method_online) {
$pointSale->payment_method_online = false;
$this->update($pointSale);
return true;
}
}

return false;
}
}

+ 3
- 3
domain/Producer/Producer/Producer.php 파일 보기

@@ -57,8 +57,8 @@ class Producer extends ActiveRecordCommon
const CREDIT_FUNCTIONING_USER = 'user';

const HINT_CREDIT_FUNCTIONING =
"- Optionnelle : les utilisateurs choisissent s'ils débitent ou non leur cagnotte. L'éventuel restant à payer est à régler sur place.\n
- Obligatoire : tous les utilisateurs payent leurs commandes via la cagnotte. Le paiement sur place ne peut pas être proposé en parallèle.\n
"- Optionnelle : les utilisateurs choisissent s'ils débitent ou non leur cagnotte. L'éventuel restant à payer est à régler sur place. Le paiement sur place est automatiquement proposé en parallèle.\n
- Obligatoire : tous les utilisateurs payent leurs commandes via la cagnotte. Le paiement sur place et le paiement en ligne ne peuvent pas être proposés en parallèle.\n
- Obligatoire par utilisateur : les utilisateurs avec l'option 'Cagnotte obligatoire' activée au niveau de leur profil payent leurs commandes via la cagnotte. Les autres utilisateurs voient simplement une note explicative au sujet de ce mode de paiement.";

public static $creditFunctioningArray = [
@@ -439,7 +439,7 @@ class Producer extends ActiveRecordCommon
'option_allow_user_gift' => 'Autoriser les utilisateurs à effectuer un don à la plateforme lors de leur commande',
'credit_functioning' => 'Fonctionnement de la cagnotte',
'credit_limit' => 'Cagnotte : montant limite',
'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser ma cagnotte" lors de la commande de l\'utilisateur',
'use_credit_checked_default' => 'Sélectionner par défaut le mode de paiement "Cagnotte" lors de la commande de l\'utilisateur (en fonctionnement optionnel)',
'background_color_logo' => 'Couleur de fond du logo',
'option_behavior_cancel_order' => 'Comportement lors de la suppression d\'une commande',
'tiller' => 'Tiller',

+ 10
- 7
producer/controllers/OrderController.php 파일 보기

@@ -239,7 +239,7 @@ class OrderController extends ProducerBaseController
return ['status' => 'error', 'errors' => $errors];
}

if ($producerModule->isOnlinePaymentActiveAndTypeOrder($producer)) {
if ($producerModule->getSolver()->isOnlinePaymentActive($producer) && $posts['payment_method'] == 'online') {
$order = $orderModule->findOneOrderById($order->id);
\Stripe\Stripe::setApiKey(
$producerModule->getPrivateKeyApiStripe($producer)
@@ -457,10 +457,12 @@ class OrderController extends ProducerBaseController
$order = $orderModule->findOneOrderById($order->id);
$orderModule->initOrder($order);

if ($credit && $pointSale->credit &&
(($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && $posts['use_credit']) ||
$creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY ||
($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active)
if ($credit
&& $pointSale->payment_method_credit
&& $posts['payment_method'] == 'credit'
&& ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL ||
$creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY ||
($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active)
)) {
// à payer
if ($orderModule->getPaymentStatus($order) == Order::PAYMENT_UNPAID) {
@@ -709,9 +711,10 @@ class OrderController extends ProducerBaseController

$dateMini = date('Y-m-d');
$ordersUserArray = [];
if (GlobalParam::getCurrentUserId() && !$producerModule->isOnlinePaymentActiveAndTypeOrder($producer)) {
if (GlobalParam::getCurrentUserId()) {
$conditionsOrdersUser = [
'distribution.date > :date'
'distribution.date > :date',
'order.online_payment_url IS NULL'
];
$paramsOrdersUser = [
':date' => $dateMini

+ 1
- 1
producer/views/order/_form.php 파일 보기

@@ -153,7 +153,7 @@ $orderModule = OrderModule::getInstance();
}
}
echo '<li class="block point-sale point-sale-' . $pointSale->id . '" data-code="'.$dataCode.'" data-credit="'.(int) $pointSale->credit.'"><div class="contenu">' .
echo '<li class="block point-sale point-sale-' . $pointSale->id . '" data-code="'.$dataCode.'" data-credit="'.(int) $pointSale->payment_method_credit.'"><div class="contenu">' .
'<span style="display:none;" class="id">' . $pointSale->id . '</span>' .
'<div class="name">' .$htmlCode. Html::encode($pointSale->name) . '</div>' .
'<div class="address">à ' . Html::encode($pointSale->locality) . '</div>' .

+ 1
- 1
producer/views/order/confirm.php 파일 보기

@@ -53,7 +53,7 @@ $producer = GlobalParam::getCurrentProducer() ;
?>

<div id="order-success">
<?php if($producerModule->isOnlinePaymentActiveAndTypeOrder($producer) && $returnPayment != 'success'): ?>
<?php if($producerModule->isOnlinePaymentActive($producer) && $order->online_payment_url && $returnPayment != 'success'): ?>
<div class="alert alert-danger">
<h5>Le paiement en ligne a échoué.</h5>
<strong>Attention</strong>, votre commande ne sera effective qu'à la réception du paiement.<br />

+ 3
- 5
producer/views/order/history.php 파일 보기

@@ -145,11 +145,9 @@ $this->setTitle('Mes commandes') ;
'value' => function($order) use ($producer, $producerModule, $orderModule) {
$html = '' ;
if($orderModule->getState($order) == Order::STATE_OPEN) {
if ($producerModule->isOnlinePaymentActiveAndTypeOrder($producer)) {
$paymentStatus = $orderModule->getPaymentStatus($order);
if($paymentStatus == Order::PAYMENT_UNPAID && $order->online_payment_url) {
$html .= '<a href="'.$order->online_payment_url.'" class="btn btn-default"><i class="bi bi-credit-card"></i> Payer en ligne</a>';
}
$paymentStatus = $orderModule->getPaymentStatus($order);
if ($producerModule->isOnlinePaymentActive($producer) && $paymentStatus == Order::PAYMENT_UNPAID && $order->online_payment_url) {
$html .= '<a href="'.$order->online_payment_url.'" class="btn btn-secondary"><i class="bi bi-credit-card"></i> Payer en ligne</a>';
}
else {
$html .= '<a data-bs-toggle="tooltip" data-bs-placement="top" title="Modifier" href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$order->id]).'" class="btn btn-secondary"><i class="bi bi-pencil"></i></a> '.

+ 82
- 58
producer/views/order/order.php 파일 보기

@@ -479,71 +479,95 @@ $this->setTitle('Commander');
</div>
</div>

<template
v-if="producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)) && !checkCreditLimit(order) ">
<div class="alert alert-danger">
Vous devez
<template v-if="producer.online_payment == 1"><a
href="<?= \Yii::$app->urlManager->createUrl(['credit/add']) ?>">recharger
votre cagnotte</a></template>
<template v-else>recharger votre cagnotte</template>
auprès de votre producteur ou supprimer des produits.</span>
Votre producteur n'autorise pas une cagnotte avec un montant inférieur
à <strong>{{ formatPrice(producer.credit_limit) }}</strong>.
</div>
<div class="block-actions">
<a class="btn btn-primary"
href="<?= \Yii::$app->urlManager->createUrl(['site/index']) ?>">Retour à
l'accueil</a>
</div>
</template>
<template v-else>
<div class="card credit" v-if="user && producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning != 'user' || (pointSaleActive.credit_functioning == 'user' && user.credit_active))">
<div class="card-body">
<h5 class="card-title">
<label for="order-comment">
<i class="bi bi-piggy-bank"></i>
Cagnotte
</label>
</h5>
<div class="card-text">
<input type="checkbox" id="use-credit" v-model="useCredit" disabled="disabled"
v-if="pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)"/>
<input type="checkbox" id="use-credit" v-model="useCredit" v-else/> <label
for="use-credit">Utiliser ma cagnotte ({{ formatPrice(user.credit)
}})</label>

<div class="info" v-if="useCredit">
<template v-if="order == null || order.amount_paid == 0">
<span v-if="checkCreditLimit(order)">{{ priceTotal(true) }} seront débités</span>
<span v-else>
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/>
Restera {{ formatPrice(priceTotal() - user.credit) }} à régler.
</span>
</template>
<template
v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">
<span v-if="checkCreditLimit(order)">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span>
<span v-else>
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/>
Restera {{ formatPrice(priceTotal() - order.amount_paid - user.credit) }} à régler.
</span>
<div id="payment-methods" class="card" v-if="pointSaleActive.payment_method_onsite || pointSaleActive.payment_method_credit || pointSaleActive.payment_method_online">
<div class="card-body">
<h5 class="card-title">
<i class="bi bi-currency-euro"></i>
Paiement
</h5>
<div class="card-text">
<div class="row">
<div class="col-md-4" v-if="isPaymentMethodOnsiteActive()">
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="onsite" id="payment-method-onsite" autocomplete="off">
<label class="btn btn-outline-success" for="payment-method-onsite">
<i class="bi bi-wallet2"></i>
Sur place
</label>
</div>
<div class="col-md-4" v-if="isPaymentMethodCreditActive()">
<template v-if="(pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)) && !checkCreditLimit(order) ">
<div class="alert alert-danger">
<i class="bi bi-piggy-bank"></i>
Vous devez
<template v-if="producer.online_payment == 1">
<a href="<?= \Yii::$app->urlManager->createUrl(['credit/add']) ?>">
recharger votre cagnotte</a>
</template>
<template v-else>recharger votre cagnotte</template>
auprès de votre producteur ou supprimer des produits.</span>
Votre producteur n'autorise pas une cagnotte avec un montant inférieur
à {{ formatPrice(producer.credit_limit) }}.<br />
Montant de votre cagnotte : {{ formatPrice(user.credit) }}<br />
Montant de votre commande : {{ priceTotal(true) }}
</div>
</template>
<template v-else-if="order != null && order.amount_paid > priceTotal()">
<span>{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span>
<template v-else>
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="credit" id="payment-method-credit" autocomplete="off">
<label class="btn btn-outline-success" for="payment-method-credit">
<i class="bi bi-piggy-bank"></i>
Cagnotte
</label>
<div class="infos">
Montant de ma cagnotte : {{ formatPrice(user.credit) }}<br />
<template v-if="paymentMethod == 'credit'">
<template v-if="order == null || order.amount_paid == 0">
<span v-if="checkCreditLimit(order)">{{ priceTotal(true) }} seront débités</span>
<span v-else>
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/>
Restera {{ formatPrice(priceTotal() - user.credit) }} à régler.
</span>
</template>
<template v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">
<span v-if="checkCreditLimit(order)">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span>
<span v-else>
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/>
Restera {{ formatPrice(priceTotal() - order.amount_paid - user.credit) }} à régler.
</span>
</template>
<template v-else-if="order != null && order.amount_paid > priceTotal()">
<span>{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span>
</template>
</template>
</div>
</template>
</div>
<div class="col-md-4" v-if="isPaymentMethodCreditActiveFunctioningUser(false)">
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="credit" id="payment-method-credit" autocomplete="off" disabled>
<label class="btn btn-outline-success" for="payment-method-credit">
<i class="bi bi-piggy-bank"></i>
Cagnotte
</label>
<div class="infos">
Sur demande, vous pouvez mettre en place une cagnotte
chez votre producteur, n'hésitez pas à lui en parler.
</div>
</div>
<div class="col-md-4" v-if="isPaymentMethodOnlineActive()">
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="online" id="payment-method-online" autocomplete="off">
<label class="btn btn-outline-success" for="payment-method-online">
<i class="bi bi-credit-card"></i>
Carte bancaire
</label>
<div class="infos">
Paiement sécurisé via la plateforme Stripe.
</div>
</div>
</div>
</div>
</div>
</div>

<?php if ($producerModule->isOnlinePaymentActiveAndTypeOrder($producer)): ?>
<div class="alert alert-info">
<i class="bi bi-credit-card"></i>
La commande est à payer en ligne lors de l'étape suivante.
</div>
<?php endif; ?>

<template>
<div id="signup-guest" class="card" v-if="!user && producer.option_allow_order_guest">
<div class="card-title">
<h5>Informations personnelles</h5>

+ 12
- 7
producer/web/css/screen.css 파일 보기

@@ -1046,7 +1046,7 @@ termes.
.order-create #main #content .order-form #bar-fixed #block-confirm-order,
.order-update #main #content .order-form #bar-fixed #block-confirm-order {
text-align: right;
margin-top: 20px;
margin-top: 40px;
}
/* line 377, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #block-confirm-order button,
@@ -1403,7 +1403,7 @@ termes.
/* line 211, ../sass/order/_order.scss */
.order-order #main #app-order-order .block-actions {
text-align: center;
margin-top: 20px;
margin-top: 40px;
}
/* line 218, ../sass/order/_order.scss */
.order-order #main #app-order-order table#points-sale td.name .the-name {
@@ -1599,25 +1599,30 @@ termes.
color: white;
font-size: 1.2rem;
}
/* line 436, ../sass/order/_order.scss */
/* line 435, ../sass/order/_order.scss */
.order-order #main #app-order-order #payment-methods .infos {
margin-top: 10px;
color: gray;
}
/* line 442, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .delivery {
margin-bottom: 20px;
}
/* line 439, ../sass/order/_order.scss */
/* line 445, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .delivery .delivery-home {
margin-bottom: 20px;
}
/* line 448, ../sass/order/_order.scss */
/* line 454, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .comment {
margin-bottom: 20px;
}
/* line 453, ../sass/order/_order.scss */
/* line 459, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .credit .info {
margin-left: 20px;
color: gray;
}

/* line 466, ../sass/order/_order.scss */
/* line 472, ../sass/order/_order.scss */
#main #content .panel h3 {
font-family: "worksans_bold";
margin: 0px;

+ 51
- 2
producer/web/js/vuejs/order-order.js 파일 보기

@@ -23,6 +23,7 @@ var app = new Vue({
categoryCurrent: null,
comment: '',
creditCheckbox: false,
paymentMethod: 'onsite',
useCredit: false,
errors: [],
disableConfirmButton: false,
@@ -209,6 +210,7 @@ var app = new Vue({
app.user = response.data.user;
app.useCredit = response.data.producer.use_credit_checked_default;


if (response.data.points_sale) {
app.pointsSale = [];
var orderPointSale = 0;
@@ -227,6 +229,21 @@ var app = new Vue({
app.pointSaleActive = app.getPointSale(app.pointSaleActiveId);
}

if(app.pointSaleActive) {
if(app.pointSaleActive.payment_method_credit
&& (app.pointSaleActive.credit_functioning == 'mandatory'
|| (app.pointSaleActive.credit_functioning == 'user' && app.user.credit_active)
|| (app.pointSaleActive.credit_functioning == 'optional' && response.data.producer.use_credit_checked_default))) {
app.paymentMethod = 'credit';
}
else if(app.pointSaleActive.payment_method_onsite) {
app.paymentMethod = 'onsite';
}
else if(app.pointSaleActive.payment_method_online) {
app.paymentMethod = 'online';
}
}

if(app.isChangeState('point-sale', 'point-sale', 'date')) {
app.date = null ;
app.dateFormat = null ;
@@ -529,7 +546,39 @@ var app = new Vue({
return thePriceWithTax;
}
},

isPaymentMethodOnsiteActive: function() {
return this.pointSaleActive && this.pointSaleActive.payment_method_onsite
&& !this.isPaymentMethodCreditActiveFunctioningUser(true)
&& !this.isPaymentMethodCreditActiveFunctioningMandatory();
},
isPaymentMethodCreditActive: function() {
return this.isPaymentMethodCreditActiveFunctioningOptional()
|| this.isPaymentMethodCreditActiveFunctioningMandatory()
|| this.isPaymentMethodCreditActiveFunctioningUser(true);
},
isPaymentMethodCreditActiveCheckBase: function() {
return this.producer && this.producer.credit
&& this.pointSaleActive && this.pointSaleActive.payment_method_credit;
},
isPaymentMethodCreditActiveFunctioningUser: function(userCreditActive) {
return this.isPaymentMethodCreditActiveCheckBase()
&& this.pointSaleActive.credit_functioning == 'user'
&& this.user && this.user.credit_active == userCreditActive;
},
isPaymentMethodCreditActiveFunctioningMandatory: function() {
return this.isPaymentMethodCreditActiveCheckBase()
&& this.pointSaleActive.credit_functioning == 'mandatory';
},
isPaymentMethodCreditActiveFunctioningOptional: function() {
return this.isPaymentMethodCreditActiveCheckBase()
&& this.pointSaleActive.credit_functioning == 'optional';
},
isPaymentMethodOnlineActive: function() {
return this.producer && this.producer.online_payment
&& this.pointSaleActive && this.pointSaleActive.payment_method_online
&& !this.isPaymentMethodCreditActiveFunctioningUser(true)
&& !this.isPaymentMethodCreditActiveFunctioningMandatory()
},
confirmClick: function() {

var app = this ;
@@ -589,7 +638,7 @@ var app = new Vue({
},
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id],
products: productsArray,
use_credit: Number(this.useCredit),
payment_method: this.paymentMethod,
user: user
}).then(function(response) {
if(response.data.status == 'success') {

+ 1
- 1
producer/web/sass/order/_form.scss 파일 보기

@@ -372,7 +372,7 @@ termes.

#block-confirm-order {
text-align: right ;
margin-top: 20px ;
margin-top: 40px ;

button {
width: 340px ;

+ 8
- 2
producer/web/sass/order/_order.scss 파일 보기

@@ -210,7 +210,7 @@
.block-actions {
text-align: center ;
margin-top: 20px ;
margin-top: 40px ;
}
table#points-sale {
@@ -430,9 +430,15 @@
}
}
}

#payment-methods {
.infos {
margin-top: 10px;
color: gray;
}
}
#content-step-payment {

.delivery {
margin-bottom: 20px ;


Loading…
취소
저장