diff --git a/.docker/docker-compose/docker-compose.local.prod.yml b/.docker/docker-compose/docker-compose.local.prod.yml index ffbe49621..6f627340d 100644 --- a/.docker/docker-compose/docker-compose.local.prod.yml +++ b/.docker/docker-compose/docker-compose.local.prod.yml @@ -3,6 +3,8 @@ version: '3.7' services: php-fpm: image: ${DOCKER_REGISTRY?}/${DOCKER_NAMESPACE?}/php-fpm-${ENV?}:${TAG?} + environment: + - APP_ENV=prod build: context: ../ # platforms: @@ -15,6 +17,8 @@ services: - TARGET_PHP_VERSION=${PHP_VERSION?} php-cron: image: ${DOCKER_REGISTRY?}/${DOCKER_NAMESPACE?}/php-cron-${ENV?}:${TAG?} + environment: + - APP_ENV=prod build: context: ../ # platforms: @@ -28,6 +32,8 @@ services: web: image: ${DOCKER_REGISTRY?}/${DOCKER_NAMESPACE?}/web-${ENV?}:${TAG?} + environment: + - APP_ENV=prod build: context: ../../ # platforms: diff --git a/.docker/images/php/base/Dockerfile b/.docker/images/php/base/Dockerfile index b59f6a6b9..eef435e88 100644 --- a/.docker/images/php/base/Dockerfile +++ b/.docker/images/php/base/Dockerfile @@ -155,6 +155,8 @@ FROM base as prod COPY --from=codebase --chown=$APP_USER_NAME:$APP_GROUP_NAME /codebase $APP_CODE_PATH +ENV APP_ENV=prod + FROM base as ci COPY --from=codebase --chown=$APP_USER_NAME:$APP_GROUP_NAME /codebase $APP_CODE_PATH @@ -169,3 +171,5 @@ RUN echo "root ALL=(ALL) NOPASSWD: ALL " | tee -a "/etc/sudoers.d/users" && \ echo "${APP_USER_NAME} ALL=(ALL) NOPASSWD: ALL " | tee -a "/etc/sudoers.d/users" RUN pecl install xdebug + +ENV APP_ENV=dev diff --git a/.docker/images/php/cron/conf.d/psc b/.docker/images/php/cron/conf.d/psc index 8a66f383e..1b9c5ab61 100644 --- a/.docker/images/php/cron/conf.d/psc +++ b/.docker/images/php/cron/conf.d/psc @@ -5,5 +5,5 @@ BASH_ENV=/container.env * * * * * root chmod -R 0777 /data/www/old/market/steplayouter >> /var/log/cron.log 2>&1 * * * * * root chmod -R 0777 /data/www/new/web/uploads/media >> /var/log/cron.log 2>&1 * * * * * root chmod -R 0777 /data/www/new/web/media >> /var/log/cron.log 2>&1 -* * * * * www-data cd /data/www/new/web && /usr/local/bin/php /data/www/new/bin/console --env=prod application:queue:do >> /var/log/cron.log 2>&1 +* * * * * www-data cd /data/www/new/web && /usr/local/bin/php /data/www/new/bin/console application:queue:do >> /var/log/cron.log 2>&1 # diff --git a/.make/04-docker.mk b/.make/04-docker.mk index b4a2cb527..3874d5428 100644 --- a/.make/04-docker.mk +++ b/.make/04-docker.mk @@ -33,7 +33,7 @@ ifeq ($(ENV),prod) else ifeq ($(ENV),ci) DOCKER_COMPOSE_FILES:=-f $(DOCKER_COMPOSE_FILE_LOCAL_CI_PROD) -f $(DOCKER_COMPOSE_FILE_LOCAL_CI) -f $(DOCKER_COMPOSE_FILE_LOCAL_PROD) -f $(DOCKER_COMPOSE_FILE_LOCAL) else ifeq ($(ENV),local) - DOCKER_COMPOSE_FILES:=-f $(DOCKER_COMPOSE_FILE_LOCAL_DEV) -f $(DOCKER_COMPOSE_FILE_LOCAL_PROD) -f $(DOCKER_COMPOSE_FILE_LOCAL) + DOCKER_COMPOSE_FILES:=-f $(DOCKER_COMPOSE_FILE_LOCAL_PROD) -f $(DOCKER_COMPOSE_FILE_LOCAL) -f $(DOCKER_COMPOSE_FILE_LOCAL_DEV) endif # We need a couple of environment variables for docker compose so we define a make variable that we can diff --git a/src/new/.env.prod b/src/new/.env.prod index 41fc7f476..55b28e96a 100644 --- a/src/new/.env.prod +++ b/src/new/.env.prod @@ -4,7 +4,7 @@ APP_SECRET=347829efiubvf347fbisdc27f ###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### -DATABASE_URL=mysql://psc:Wichtig1@mysql:3306/psc +DATABASE_URL=mysql://root:Wichtig1@mysql:3306/psc ###< doctrine/doctrine-bundle ### ###> doctrine/mongodb-odm-bundle ### diff --git a/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php b/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php index 30ea8e0b2..f59feb870 100755 --- a/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php +++ b/src/new/src/PSC/Shop/ContactBundle/Controller/Backend/EditController.php @@ -31,7 +31,6 @@ use PSC\Shop\EntityBundle\Entity\ContactRole; use PSC\Shop\EntityBundle\Entity\Product; use PSC\Shop\EntityBundle\Entity\Role; use PSC\Shop\EntityBundle\Entity\ShopContact; -use PSC\Shop\OrderBundle\Form\Backend\Upload\DeleteType; use PSC\Shop\QueueBundle\Event\EventManager; use PSC\Shop\QueueBundle\Service\Event\Manager; use PSC\System\PluginBundle\Form\Chain\Field; diff --git a/src/new/src/PSC/Shop/QueueBundle/Event/Contact/Login.php b/src/new/src/PSC/Shop/QueueBundle/Event/Contact/Login.php new file mode 100644 index 000000000..e214491b8 --- /dev/null +++ b/src/new/src/PSC/Shop/QueueBundle/Event/Contact/Login.php @@ -0,0 +1,57 @@ + $this->contact + ); + } + + public function setData($data) + { + $this->contact = $data['contact']; + } + + /** + * @return string + */ + public function getContact() + { + return $this->contact; + } + + /** + * @param string $contact + */ + public function setContact($contact) + { + $this->contact = $contact; + } + + public function getHelp() + { + return [[ + Shop::getColumn(), + \PSC\Shop\QueueBundle\Help\Contact::getColumn(), + ]]; + } +} diff --git a/src/new/src/PSC/Shop/QueueBundle/Resources/config/services.yml b/src/new/src/PSC/Shop/QueueBundle/Resources/config/services.yml index 04f641f8f..0aa4bbee4 100755 --- a/src/new/src/PSC/Shop/QueueBundle/Resources/config/services.yml +++ b/src/new/src/PSC/Shop/QueueBundle/Resources/config/services.yml @@ -75,6 +75,9 @@ services: PSC\Shop\QueueBundle\Event\Contact\Password\Reset\Finish: tags: - { name: events } + PSC\Shop\QueueBundle\Event\Contact\Login: + tags: + - { name: events } PSC\Shop\QueueBundle\Event\Contact\Create: tags: - { name: events } @@ -114,4 +117,4 @@ services: PSC\Shop\QueueBundle\Service\Event\Registry: tags: - - {name: autoregistry, tag: events } \ No newline at end of file + - {name: autoregistry, tag: events } diff --git a/src/new/src/PSC/Shop/QueueBundle/Type/Mail.php b/src/new/src/PSC/Shop/QueueBundle/Type/Mail.php index 03c0b44c1..7f11b3278 100755 --- a/src/new/src/PSC/Shop/QueueBundle/Type/Mail.php +++ b/src/new/src/PSC/Shop/QueueBundle/Type/Mail.php @@ -312,7 +312,7 @@ class Mail implements QueueInterface, ConfigurableElementInterface return true; } - if ($event instanceof UnLock || $event instanceof \PSC\Shop\QueueBundle\Event\Contact\Create) { + if ($event instanceof UnLock || $event instanceof \PSC\Shop\QueueBundle\Event\Contact\Create || $event instanceof \PSC\Shop\QueueBundle\Event\Contact\Login) { $contactRepo = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Contact'); /** @var Contact $contact */ $contact = $contactRepo->findOneBy(array('uuid' => $event->getContact())); @@ -349,9 +349,17 @@ class Mail implements QueueInterface, ConfigurableElementInterface if ($html) { $message->html($html->render($params)); } - + $this->_logService->createLogEntry($shop, new Contact(), LogEntry::INFO, PSCShopQueueBundle::class, $queue->getName(), "Login Mail send", [ + 'message' => $message->getTextBody(), + 'from' => $from->render($params), + 'to' => $to->render($params), + 'subject' => $subject->render($params) + ]); $this->_mailer->send($message); } catch (\Exception $e) { + $this->_logService->createLogEntry($shop, new Contact(), LogEntry::ERROR, PSCShopQueueBundle::class, $queue->getName(), "Login Mail error", [ + 'error' => $e->getMessage() + ]); $this->_error = $e->getMessage(); return false; } diff --git a/src/new/src/PSC/Shop/QueueBundle/Type/Url.php b/src/new/src/PSC/Shop/QueueBundle/Type/Url.php index da2510be9..69ff2e841 100755 --- a/src/new/src/PSC/Shop/QueueBundle/Type/Url.php +++ b/src/new/src/PSC/Shop/QueueBundle/Type/Url.php @@ -12,6 +12,7 @@ use PSC\Libraries\AceEditorBundle\Form\Extension\AceEditorType; use PSC\Shop\EntityBundle\Document\Queue; use PSC\Shop\QueueBundle\Event\EventInterface; use PSC\Shop\QueueBundle\Event\Order\Create; +use PSC\Shop\QueueBundle\Event\Contact\Login; use PSC\Shop\QueueBundle\Event\Position\Printpartner\Notify; use PSC\System\PluginBundle\Event\EveryRun; use PSC\System\SettingsBundle\Service\TemplateVars; @@ -137,6 +138,39 @@ class Url implements QueueInterface, ConfigurableElementInterface $messageString = $messageTemplate->render($templateVars->getTwigVars()); file_put_contents('/tmp/test.json', $messageString); + $res = $client->request( + 'POST', + $urlString, + [ + 'headers' => [ + 'Accept' => 'application/json', + ], + 'json' => json_decode($messageString) + ] + ); + } + if ($event instanceof Login) { + $client = new Client(); + $urlTemplate = $this->_template->createTemplate($doc->getUrl()); + $messageTemplate = $this->_template->createTemplate($doc->getMessage()); + $contactRepo = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Contact'); + /** @var Contact $contact */ + $contact = $contactRepo->findOneBy(array('uuid' => $event->getContact())); + /** @var \PSC\Shop\EntityBundle\Document\Contact $contactObj */ + $contactObj = $this->_doctrine_mongodb + ->getRepository('PSC\Shop\EntityBundle\Document\Contact') + ->findOneBy(array('uid' => (string) $contact->getId())); + $shopRepo = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Shop'); + /** @var Shop $shop */ + $shop = $shopRepo->findOneBy(array('uid' => $event->getShop())); + $params = array( + 'contact' => $contact, + 'contactDoc' => $contactObj, + 'shop' => $shop, + ); + $urlString = $urlTemplate->render($params); + $messageString = $messageTemplate->render($params); + $res = $client->request( 'POST', $urlString, diff --git a/src/old/application/Bootstrap.php b/src/old/application/Bootstrap.php index 240f5e149..fbf4b2c83 100755 --- a/src/old/application/Bootstrap.php +++ b/src/old/application/Bootstrap.php @@ -55,7 +55,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap );*/ $cacheDriver = new Doctrine_Cache_Array(); if (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] == 'test') { - $dsn = 'mysql:dbname=psc_test;host=mysql'; + $dsn = 'mysql:dbname=psc;host=mysql'; $user = 'psc'; $password = 'psc'; } elseif (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] == 'dev') { diff --git a/src/old/application/data/models/generated/BaseCreditSystem.php b/src/old/application/data/models/generated/BaseCreditSystem.php index 114e0bd01..c227e9d93 100755 --- a/src/old/application/data/models/generated/BaseCreditSystem.php +++ b/src/old/application/data/models/generated/BaseCreditSystem.php @@ -28,7 +28,8 @@ */ abstract class BaseCreditSystem extends Doctrine_Record { - public function setTableDefinition() { + public function setTableDefinition() + { $this->setTableName('credit_system'); $this->hasColumn('id', 'integer', 8, array( 'primary' => true, @@ -100,13 +101,18 @@ abstract class BaseCreditSystem extends Doctrine_Record 'type' => 'float', 'length' => '25', )); + $this->hasColumn('min_basket_value', 'float', 25, array( + 'type' => 'float', + 'length' => '25', + )); $this->hasColumn('more', 'boolean', 1); $this->hasColumn('product_id', 'string', 255); $this->hasColumn('articlegroup_id', 'string', 255); $this->hasColumn('pre_code', 'string', 255); } - public function setUp() { + public function setUp() + { parent::setUp(); $this->hasOne('Install', array( 'local' => 'install_id', diff --git a/src/old/application/modules/default/controllers/BasketController.php b/src/old/application/modules/default/controllers/BasketController.php index 82d80149c..1dfb89427 100755 --- a/src/old/application/modules/default/controllers/BasketController.php +++ b/src/old/application/modules/default/controllers/BasketController.php @@ -2117,6 +2117,7 @@ class BasketController extends TP_Controller_Action } $creditSystemUUID = $creditSystemRecord->id; $creditSystemValue = $creditSystemRecord->wert; + $creditSystemMinBasketValue = $creditSystemRecord->min_basket_value; $creditSystemPercent = (bool)$creditSystemRecord->percent; $creditSystemPayment = (bool)$creditSystemRecord->payment; $creditSystemShipping = (bool)$creditSystemRecord->shipping; @@ -2323,6 +2324,12 @@ class BasketController extends TP_Controller_Action $this->view->productnetto = $netto; $this->view->gutschein = false; + if ($creditSystemMinBasketValue > 0 && $creditSystemMinBasketValue > ($netto+$mwert)) { + $this->view->priorityMessenger('Warenwert zu niedrig', 'success'); + $basket->setGutschein(""); + $creditSystemValue=0; + } + if ($basket->getGutschein() != "") { $this->view->gutscheincode = $basket->getGutschein(); $this->view->gutschein = $creditSystemRecord; diff --git a/src/old/library/TP/Plugin/AuthAdapter.php b/src/old/library/TP/Plugin/AuthAdapter.php index 05347e612..fe4ed6e07 100755 --- a/src/old/library/TP/Plugin/AuthAdapter.php +++ b/src/old/library/TP/Plugin/AuthAdapter.php @@ -2,7 +2,6 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface { - /** * $_identity - Identity value * @@ -56,7 +55,7 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface { $_identity = null; - if($this->_idLogin !== false) { + if ($this->_idLogin !== false) { $row = Doctrine_Query::create() ->from('Contact m') ->where('m.id= ?', array($this->_idLogin)) @@ -67,25 +66,25 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface $shop = Zend_Registry::get('shop'); - if($shop['install_id'] == 4999) { + if ($shop['install_id'] == 4999) { $row = Doctrine_Query::create() ->from('Contact m') ->where('m.self_email = ? AND m.enable = 1 AND m.virtual = 0 AND m.install_id = ?', array($this->_identity, $shop['install_id'])) ->execute()->getFirst(); - }elseif($this->_apiLogin) { + } elseif ($this->_apiLogin) { $row = Doctrine_Query::create() ->from('Contact m') ->leftJoin('m.Shops as s') ->where('m.id = ? AND m.enable = 1 AND s.id = ?', array($this->_identity, $shop['id'])) ->execute()->getFirst(); - }else{ - if($shop['useemailaslogin'] == true) { + } else { + if ($shop['useemailaslogin'] == true) { $row = Doctrine_Query::create() ->from('Contact m') ->leftJoin('m.Shops as s') ->where('m.self_email = ? AND m.enable = 1 AND m.virtual = 0 AND s.id = ?', array($this->_identity, $shop['id'])) ->execute()->getFirst(); - }else{ + } else { $row = Doctrine_Query::create() ->from('Contact m') ->leftJoin('m.Shops as s') @@ -94,14 +93,14 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface } } - if($row->password == "") { + if ($row->password == "") { return new Zend_Auth_Result(false, $_identity, array('empty password')); } // Es darf diesen Benutzer nur genau 1x geben if (!isset($row->id)) { return new Zend_Auth_Result(false, $_identity, array('Login failure')); } - if($row->locked || $row->Account->locked) { + if ($row->locked || $row->Account->locked) { return new Zend_Auth_Result(false, $_identity, array('Sie wurden gesperrt')); } @@ -110,17 +109,41 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface $row->save(); $_identity = $row->toArray(true); $_identity['name1'] = $_identity['self_firstname'].' '.$_identity['self_lastname']; + $dbMongo = TP_Mongo::getInstance(); + $dbMongo->Job->insertOne(array( + "shop" => $shop['id'], + "event" => "contact_login", + "data" => [ "contact" => $row->uuid ], + "created" => new MongoDB\BSON\UTCDateTime(), + "updated" => new MongoDB\BSON\UTCDateTime() + )); return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank')); - }elseif(function_exists('password_verify') && password_verify($this->_credential, $row->password) && !$this->_apiLogin) { + } elseif (function_exists('password_verify') && password_verify($this->_credential, $row->password) && !$this->_apiLogin) { $_identity = $row->toArray(true); $_identity['name1'] = $_identity['self_firstname'].' '.$_identity['self_lastname']; + $dbMongo = TP_Mongo::getInstance(); + $dbMongo->Job->insertOne(array( + "shop" => $shop['id'], + "event" => "contact_login", + "data" => [ "contact" => $row->uuid ], + "created" => new MongoDB\BSON\UTCDateTime(), + "updated" => new MongoDB\BSON\UTCDateTime() + )); return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank')); - }elseif($this->_apiLogin) { + } elseif ($this->_apiLogin) { $_identity = $row->toArray(true); $_identity['name1'] = $_identity['self_firstname'].' '.$_identity['self_lastname']; + $dbMongo = TP_Mongo::getInstance(); + $dbMongo->Job->insertOne(array( + "shop" => $shop['id'], + "event" => "contact_login", + "data" => [ "contact" => $row->uuid ], + "created" => new MongoDB\BSON\UTCDateTime(), + "updated" => new MongoDB\BSON\UTCDateTime() + )); return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank')); - }else{ + } else { return new Zend_Auth_Result(false, $_identity, array('Passwort falsch!')); } }