您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

49 行
2.2KB

  1. <?php
  2. namespace console\commands;
  3. use domain\Distribution\Distribution\DistributionModule;
  4. use domain\PointSale\PointSale\PointSaleModule;
  5. use domain\Producer\Producer\Producer;
  6. use domain\Producer\Producer\ProducerModule;
  7. use yii\console\Controller;
  8. class InitPointSalePaymentMethodsFromSettingsController extends Controller
  9. {
  10. // ./yii init-point-sale-payment-methods-from-settings/index
  11. public function actionIndex()
  12. {
  13. $producerModule = ProducerModule::getInstance();
  14. $pointSaleModule = PointSaleModule::getInstance();
  15. $producersArray = $producerModule->findProducers();
  16. foreach($producersArray as $producer) {
  17. echo '> '.$producer->name."\n";
  18. \Yii::$app->logic->setProducerContext($producer);
  19. $pointSaleArray = $pointSaleModule->getRepository()->findPointSales();
  20. $creditFunctioningProducer = $producerModule->getConfig('credit_functioning');
  21. $isOnlinePaymentActiveAndTypeOrder = $producerModule->isOnlinePaymentActiveAndTypeOrder($producer, false);
  22. foreach($pointSaleArray as $pointSale) {
  23. if($pointSale->payment_method_credit && !$pointSale->credit_functioning) {
  24. $pointSale->credit_functioning = $creditFunctioningProducer;
  25. if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
  26. $pointSale->payment_method_onsite = true;
  27. }
  28. $pointSale->save();
  29. echo 'Point de vente "'.$pointSale->name. '" configuré sur "'.$pointSale->credit_functioning.'"'."\n";
  30. }
  31. $return = $pointSaleModule->getBuilder()->initPaymentMethodsByCreditFunctioning($pointSale);
  32. if($return) {
  33. echo 'Point de vente "'.$pointSale->name. '" : modes de paiements adaptés'."\n";
  34. }
  35. if($isOnlinePaymentActiveAndTypeOrder) {
  36. $pointSale->payment_method_online = true;
  37. $pointSale->save();
  38. echo 'Point de vente "'.$pointSale->name. '" : paiement en ligne activé'."\n";
  39. }
  40. }
  41. }
  42. }
  43. }
  44. ?>