Procházet zdrojové kódy

Paiement à la commande

dev
Guillaume před 3 roky
rodič
revize
a706a99ca9
8 změnil soubory, kde provedl 72 přidání a 32 odebrání
  1. +10
    -0
      common/models/Producer.php
  2. +1
    -1
      console/migrations/m210920_060127_add_field_order_online_payment_url.php
  3. +7
    -4
      producer/controllers/OrderController.php
  4. +19
    -16
      producer/views/order/confirm.php
  5. +13
    -6
      producer/views/order/history.php
  6. +1
    -1
      producer/views/order/order.php
  7. +13
    -4
      producer/web/css/screen.css
  8. +8
    -0
      producer/web/sass/order/_confirm.scss

+ 10
- 0
common/models/Producer.php Zobrazit soubor

@@ -820,5 +820,15 @@ class Producer extends ActiveRecordCommon
return false;
}

public function isOnlinePaymentActive()
{
return $this->online_payment || ($this->option_stripe_mode_test && Yii::$app->user->identity->status > 10);
}

public function isOnlinePaymentActiveAndTypeOrder()
{
return $this->isOnlinePaymentActive() && $this->option_online_payment_type == 'order' ;
}

}

+ 1
- 1
console/migrations/m210920_060127_add_field_order_online_payment_url.php Zobrazit soubor

@@ -10,7 +10,7 @@ class m210920_060127_add_field_order_online_payment_url extends Migration
{
public function safeUp()
{
$this->addColumn('order', 'online_payment_url', Schema::TYPE_STRING);
$this->addColumn('order', 'online_payment_url', Schema::TYPE_TEXT);
}

public function safeDown()

+ 7
- 4
producer/controllers/OrderController.php Zobrazit soubor

@@ -199,7 +199,7 @@ class OrderController extends ProducerBaseController
])
->one();

if ($order) {
if ($order && !$order->online_payment_url) {
if ($order->id_point_sale != $posts['Order']['id_point_sale']) {
$order->id_point_sale = $posts['Order']['id_point_sale'];
$order->date_update = date('Y-m-d H:i:s');
@@ -258,8 +258,7 @@ class OrderController extends ProducerBaseController
return ['status' => 'error', 'errors' => $errors];
}

if (($producer->online_payment || ($producer->option_stripe_mode_test && $user->status > 10))
&& $producer->option_online_payment_type == 'order') {
if ($producer->isOnlinePaymentActiveAndTypeOrder()) {

$order = Order::searchOne([
'id' => $order->id
@@ -706,7 +705,7 @@ class OrderController extends ProducerBaseController

// Commandes de l'utilisateur
$ordersUserArray = [];
if (User::getCurrentId()) {
if (User::getCurrentId() && !$producer->isOnlinePaymentActiveAndTypeOrder()) {
$conditionsOrdersUser = [
'distribution.date > :date'
];
@@ -768,6 +767,10 @@ class OrderController extends ProducerBaseController
}

$orderUser = Order::searchOne($conditionOrderUser);

if($orderUser && $orderUser->online_payment_url) {
$orderUser = false;
}
}

if ($orderUser) {

+ 19
- 16
producer/views/order/confirm.php Zobrazit soubor

@@ -46,26 +46,29 @@ $producer = GlobalParam::getCurrentProducer() ;

<div id="order-success">

<?php if($returnPayment != 'success'): ?>

<?php if($producer->isOnlinePaymentActive() && $returnPayment != 'success'): ?>
<div class="alert alert-danger">
Le paiement en ligne a échoué.<br />
<strong>Attention</strong>, votre commande sera effective à la réception du paiement.
<h5>Le paiement en ligne a échoué.</h5>
<strong>Attention</strong>, votre commande ne sera effective qu'à la réception du paiement.<br />
<a href="<?= $order->online_payment_url ?>">Cliquez ici</a> pour recommencer votre paiement.
</div>
<?php else: ?>
<div class="alert alert-success">
<span class="glyphicon glyphicon-ok glyphicon-big"></span>
<div class="content">
<h3>Votre commande a bien été prise en compte</h3>
<?php if(!Yii::$app->user->isGuest): ?>
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history']) ?>" class="btn btn-default">
<span class="glyphicon glyphicon-chevron-right"></span>
Voir toutes mes commandes
</a>
<?php endif; ?>
</div>
<div class="clr"></div>
</div>
<?php endif; ?>

<div class="alert alert-success">
<span class="glyphicon glyphicon-ok glyphicon-big"></span>
<div class="content">
<h3>Votre commande a bien été prise en compte</h3>
<?php if(!Yii::$app->user->isGuest): ?>
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history']) ?>" class="btn btn-default">
<span class="glyphicon glyphicon-chevron-right"></span>
Voir toutes mes commandes
</a>
<?php endif; ?>
</div>
<div class="clr"></div>
</div>
<div class="alert alert-info alert-order-summary">
<span class="glyphicon glyphicon-list-alt glyphicon-big"></span>
<div class="content">

+ 13
- 6
producer/views/order/history.php Zobrazit soubor

@@ -39,6 +39,7 @@ termes.
use yii\bootstrap\ActiveForm;
use common\models\Order ;

$producer = $this->context->getProducer();
$this->setTitle('Mes commandes') ;
$this->addButton(['label' => '<span class="glyphicon glyphicon-plus"></span> Ajouter', 'url' => 'order/order', 'class' => 'btn btn-primary']) ;

@@ -137,14 +138,20 @@ GridView::widget([
[
'label' => 'Actions',
'format' => 'raw',
'value' => function($c) {
'value' => function($c) use ($producer) {
$html = '' ;
if($c->getState() == Order::STATE_OPEN) {

$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a> '.
'<a href="'.Yii::$app->urlManager->createUrl(['order/cancel','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></a> '.
(($c->id_subscription) ? '<a href="'.Yii::$app->urlManagerProducer->createUrl(['subscription/form','id'=>$c->id_subscription]).'" class="btn btn-default"><span class="glyphicon glyphicon-repeat"></span></a>' : '') ;
if ($producer->isOnlinePaymentActiveAndTypeOrder()) {
$paymentStatus = $c->getPaymentStatus();
if($paymentStatus == Order::PAYMENT_UNPAID && $c->online_payment_url) {
$html .= '<a href="'.$c->online_payment_url.'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Payer en ligne</a>';
}
}
else {
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a> '.
'<a href="'.Yii::$app->urlManager->createUrl(['order/cancel','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></a> '.
(($c->id_subscription) ? '<a href="'.Yii::$app->urlManagerProducer->createUrl(['subscription/form','id'=>$c->id_subscription]).'" class="btn btn-default"><span class="glyphicon glyphicon-repeat"></span></a>' : '') ;
}
}
return $html ;
}

+ 1
- 1
producer/views/order/order.php Zobrazit soubor

@@ -400,7 +400,7 @@ $producer = GlobalParam::getCurrentProducer() ;
<span class="glyphicon glyphicon-chevron-right"></span>
<?php if($producer->option_payment_info && strlen($producer->option_payment_info) > 0): ?>
Confirmez votre commande et retrouvez les informations liées au paiement sur la page suivante.
<?php elseif($producer->online_payment && $producer->option_online_payment_type == 'order'): ?>
<?php elseif($producer->isOnlinePaymentActiveAndTypeOrder()): ?>
La commande est à payer en ligne lors de l'étape suivante.
<?php else: ?>
La commande sera à régler sur place.

+ 13
- 4
producer/web/css/screen.css Zobrazit soubor

@@ -1664,23 +1664,32 @@ termes.
padding: 0px;
}
/* line 34, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert.alert-danger {
padding: 12px;
}
/* line 36, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert.alert-danger h5 {
margin-top: 10px;
margin-bottom: 10px;
}
/* line 42, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert strong {
font-weight: bold;
}
/* line 38, ../sass/order/_confirm.scss */
/* line 46, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert .glyphicon-big {
font-size: 90px;
color: white;
padding: 30px;
float: left;
}
/* line 45, ../sass/order/_confirm.scss */
/* line 53, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert div.content {
color: #333;
padding: 20px;
margin-left: 151px;
}
/* line 50, ../sass/order/_confirm.scss */
/* line 58, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert div.content h3 {
font-family: "capsuularegular";
font-size: 30px;
@@ -1693,7 +1702,7 @@ termes.
line-height: 35px;
text-transform: none;
}
/* line 63, ../sass/order/_confirm.scss */
/* line 71, ../sass/order/_confirm.scss */
.order-confirm #main #order-success .alert div.content .locality {
color: gray;
}

+ 8
- 0
producer/web/sass/order/_confirm.scss Zobrazit soubor

@@ -31,6 +31,14 @@
.alert {
padding: 0px ;

&.alert-danger {
padding: 12px;
h5 {
margin-top: 10px;
margin-bottom: 10px;
}
}

strong {
font-weight: bold ;
}

Načítá se…
Zrušit
Uložit