Browse Source

Liaison utilisateur / point de vente au moment de chaque commande (par l'utilisateur, dans l'admin, lors de la génération des commandes via les abonnements)

dev
Guillaume Bourgeois 5 years ago
parent
commit
215690832e
4 changed files with 37 additions and 0 deletions
  1. +5
    -0
      backend/controllers/OrderController.php
  2. +23
    -0
      common/models/PointSale.php
  3. +6
    -0
      common/models/Subscription.php
  4. +3
    -0
      producer/controllers/OrderController.php

+ 5
- 0
backend/controllers/OrderController.php View File

if($order && $processCredit) { if($order && $processCredit) {
$order->processCredit() ; $order->processCredit() ;
} }
// lien utilisateur / point de vente
if($idUser && $pointSale) {
$pointSale->linkUser($idUser) ;
}
} }
return ['success'] ; return ['success'] ;

+ 23
- 0
common/models/PointSale.php View File

{ {
return $this->credit_functioning ? $this->credit_functioning : Producer::getConfig('credit_functioning') ; return $this->credit_functioning ? $this->credit_functioning : Producer::getConfig('credit_functioning') ;
} }
/**
* Lie un utilisateur au point de vente.
*
* @param integer $idUser
*/
public function linkUser($idUser)
{
if($idUser) {
$userPointSale = UserPointSale::find()
->where([
'id_user' => $idUser,
'id_point_sale' => $this->id
])->one() ;

if(!$userPointSale) {
$userPointSale = new UserPointSale ;
$userPointSale->id_user = $idUser ;
$userPointSale->id_point_sale = $this->id ;
$userPointSale->save() ;
}
}
}
} }

+ 6
- 0
common/models/Subscription.php View File



$order->save(); $order->save();


// liaison utilisateur / point de vente
if($order->id_user) {
$pointSale = PointSale::findOne($this->id_point_sale) ;
$pointSale->linkUser($order->id_user) ;
}
// produits // produits
$amountTotal = 0; $amountTotal = 0;
$productsAdd = false; $productsAdd = false;

+ 3
- 0
producer/controllers/OrderController.php View File

$productOrder->save(); $productOrder->save();
} }
} }
// lien utilisateur / point de vente
$pointSale->linkUser(User::getCurrentId()) ;


// credit // credit
$credit = Producer::getConfig('credit'); $credit = Producer::getConfig('credit');

Loading…
Cancel
Save