]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Запись писем
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 24 Mar 2025 11:43:47 +0000 (14:43 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 24 Mar 2025 11:43:47 +0000 (14:43 +0300)
erp24/commands/MarketplaceController.php
erp24/media/controllers/FlowwowController.php
erp24/migrations/m250321_134458_create_marketplace_flowwow_emails_table.php
erp24/records/MarketplaceFlowwowEmails.php
erp24/records/MarketplaceFlowwowEmailsSearch.php
erp24/services/MarketplaceService.php
erp24/views/marketplace-flowwow-emails/_form.php
erp24/views/marketplace-flowwow-emails/_search.php
erp24/views/marketplace-flowwow-emails/index.php
erp24/views/marketplace-flowwow-emails/view.php

index a1af78ca467b9a00f51861fc69744e58282079b6..11d0ec3cfe3703a46b6d2fc8adbb9e40166e07db 100644 (file)
@@ -34,9 +34,13 @@ class MarketplaceController extends Controller
      */
     public $oldMail;
     /**
-     * @var int|null передаем 0 (false), чтобы забирать все письма а не только непросмотренные UNSEEN
+     * @var int|null передаем 1 (true), чтобы забирать все письма SEEN
      */
     public $seen;
+    /**
+     * @var int|null передаем 1 (true), чтобы забирать все письма UNSEEN
+     */
+    public $unseen;
 
     public function actionYandex() {
         $infoForMarketplace = MarketplaceService::infoForMarketplace(2);
@@ -94,6 +98,7 @@ class MarketplaceController extends Controller
         $since = (bool)($this->since ?? 0);
         $oldMail = (bool)($this->oldMail ?? 0);
         $seen = (bool)($this->seen ?? 0);
+        $unseen = (bool)($this->unseen ?? 0);
 
         $countMessages = 0;
         $count = 0;
@@ -102,7 +107,7 @@ class MarketplaceController extends Controller
             $this->stdout($message . "\n", BaseConsole::FG_YELLOW);
         };
 
-        $messages = MarketplaceService::getFlowwowOrdersFromMail($date, $since, $oldMail, $progressCallback, $seen);
+        $messages = MarketplaceService::getFlowwowOrdersFromMail($date, $since, $oldMail, $progressCallback, $seen, $unseen);
 
         $countMessages = count($messages);
         $count = MarketplaceService::processMessages($messages);
@@ -122,6 +127,7 @@ class MarketplaceController extends Controller
         $options[] = 'since';
         $options[] = 'oldMail';
         $options[] = 'seen';
+        $options[] = 'unseen';
 
         return $options;
     }
index 76ea851b277b794f091238dea186f8418cafc24a..d1170115e4a46fdaa90f6b4fde9717bc2363c1a7 100644 (file)
@@ -78,13 +78,1080 @@ class FlowwowController extends Controller
         set_time_limit(300);
         Yii::$app->response->format = Response::FORMAT_JSON;
 
-        $html = '';
+        $html = '    <!doctype html>
+    <html lang=3D"ru">
+    <head>
+    <meta name=3D"viewport" content=3D"width=3Ddevice-width, =
+initial-scale=3D1.0"/>
+    <meta http-equiv=3D"Content-Type" content=3D"text/html; =
+charset=3DUTF-8"/>
+    <title>=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9 =
+=D0=BE=D0=BF=D0=BB=D0=B0=D1=87=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9 =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7</title>
+        <link rel=3D"preconnect" href=3D"https://fonts.googleapis.com">
+    <link rel=3D"preconnect" href=3D"https://fonts.gstatic.com" =
+crossorigin>
+    <link =
+href=3D"https://fonts.googleapis.com/css2?family=3DNoto+Sans&display=3Dsw=
+ap" rel=3D"stylesheet">
+    <!--START STYLE-->
+    <style>
+        /* -------------------------------------
+            GLOBAL RESETS
+        ------------------------------------- */
+
+        /*All the styling goes here*/
+
+        img {
+            border: none;
+            -ms-interpolation-mode: bicubic;
+            max-width: 100%;
+        }
+
+        body {
+            background-color: #f6f6f6;
+            font-family: sans-serif;
+            -webkit-font-smoothing: antialiased;
+            font-size: 16px;
+            line-height: 1.4;
+            margin: 0;
+            padding: 0;
+            -ms-text-size-adjust: 100%;
+            -webkit-text-size-adjust: 100%;
+        }
+
+        table {
+            border-collapse: separate;
+            mso-table-lspace: 0pt;
+            mso-table-rspace: 0pt;
+            width: 100%;
+        }
+
+        table td {
+            font-family: sans-serif;
+            font-size: 14px;
+            vertical-align: top;
+        }
+
+        /* -------------------------------------
+            BODY & CONTAINER
+        ------------------------------------- */
+
+        .body {
+            background-color: #f6f6f6;
+            width: 100%;
+        }
+
+        /* Set a max-width, and make it display as block so it will =
+automatically stretch to that width, but will also shrink down on a =
+phone or something */
+        .container {
+            display: block;
+            margin: 0 auto !important;
+            /* makes it centered */
+            max-width: 600px;
+            padding: 24px;
+            width: 600px;
+        }
+
+        /* This should also be a block element, so that it will fill =
+100% of the .container */
+        .content {
+            box-sizing: border-box;
+            display: block;
+            margin: 0 auto;
+            max-width: 600px;
+            padding: 16px;
+        }
+
+        /* -------------------------------------
+            HEADER, FOOTER, MAIN
+        ------------------------------------- */
+        .main {
+            background: #ffffff;
+            border-radius: 3px;
+            width: 100%;
+        }
+
+        .wrapper {
+            box-sizing: border-box;
+            padding: 20px;
+        }
+
+        .content-block {
+            padding-bottom: 8px;
+            padding-top: 8px;
+        }
+
+        .card-button {
+            padding-bottom: 12px;
+            padding-top: 12px;
+            padding-left: 16px;
+            padding-right: 16px;
+            background: #FAFAFA;
+            border-radius: 8px;
+            width: auto;
+        }
+
+        .footer {
+            text-align: left;
+            background: #ffffff;
+            padding-left: 24px;
+            padding-right: 24px;
+            padding-bottom: 24px;
+        }
+
+        .footer td,
+        .footer span,
+        .footer p {
+            color: #8c8c8c;
+            font-size: 16px;
+            text-align: left;
+        }
+
+        .footer a {
+            color: #5495ed;
+            font-size: 14px;
+            text-align: left;
+        }
+
+        /* -------------------------------------
+            TYPOGRAPHY
+        ------------------------------------- */
+        h1 {
+            font-size: 24px !important;
+            margin-bottom: 12px !important;
+            color: #111 !important;
+            font-family: sans-serif !important;
+            font-weight: bold;
+        }
+
+        h2,
+        h3,
+        h4 {
+            font-family: "Noto Sans", sans-serif;
+            font-style: normal;
+            font-weight: 700;
+            font-size: 14px;
+            line-height: 20px;
+            margin-bottom: 8px;
+        }
+
+        p,
+        ul,
+        ol {
+            color: #111;
+            font-family: sans-serif;
+            font-size: 16px;
+            font-weight: normal;
+            margin: 0;
+            margin-bottom: 12px;
+        }
+
+        p li,
+        ul li,
+        ol li {
+            list-style-position: inside;
+            margin-left: 5px;
+        }
+
+        a {
+            color: #5495ed;
+            text-decoration: underline;
+        }
+
+        /* -------------------------------------
+            BUTTONS
+        ------------------------------------- */
+        .btn {
+            box-sizing: border-box;
+            width: 100%;
+        }
+
+        .btn > tbody > tr > td {
+            padding-bottom: 16px;
+        }
+
+        .btn table {
+            width: auto;
+        }
+
+        .btn table td {
+            background-color: #ffffff;
+            border-radius: 6px;
+            text-align: center;
+        }
+
+        .btn a {
+            background-color: #ffffff;
+            border: solid 1px #111;
+            border-radius: 5px;
+            box-sizing: border-box;
+            color: #111;
+            cursor: pointer;
+            display: inline-block;
+            font-size: 14px;
+            font-weight: bold;
+            margin: 0;
+            padding: 12px 25px;
+            text-decoration: none;
+        }
+
+        .btn-primary table td {
+            background-color: #111;
+        }
+
+        .btn-primary a {
+            background-color: #111;
+            border-color: #111;
+            color: #ffffff;
+        }
+
+        /* -------------------------------------
+            OTHER STYLES THAT MIGHT BE USEFUL
+        ------------------------------------- */
+        .last {
+            margin-bottom: 0;
+        }
+
+        .first {
+            margin-top: 0;
+        }
+
+        .align-center {
+            text-align: center;
+        }
+
+        .align-right {
+            text-align: right;
+        }
+
+        .align-left {
+            text-align: left;
+        }
+
+        .clear {
+            clear: both;
+        }
+
+        .mt0 {
+            margin-top: 0;
+        }
+
+        .mb0 {
+            margin-bottom: 0;
+        }
+
+        .pre-header {
+            color: transparent;
+            display: none;
+            height: 0;
+            max-height: 0;
+            max-width: 0;
+            opacity: 0;
+            overflow: hidden;
+            mso-hide: all;
+            visibility: hidden;
+            width: 0;
+        }
+
+        .powered-by a {
+            text-decoration: none;
+        }
+
+        hr {
+            border: 0;
+            border-bottom: 1px solid #f6f6f6;
+            margin: 20px 0;
+        }
+
+        /* -------------------------------------
+            RESPONSIVE AND MOBILE FRIENDLY STYLES
+        ------------------------------------- */
+        @media only screen and (max-width: 620px) {
+            table.body h1 {
+                font-size: 24px !important;
+                margin-bottom: 12px !important;
+            }
+
+            table.body p,
+            table.body ul,
+            table.body ol,
+            table.body td,
+            table.body span,
+            table.body a {
+                font-size: 16px !important;
+            }
+
+            table.body .wrapper,
+            table.body .article {
+                padding: 12px !important;
+            }
+
+            table.body .content {
+                padding: 0 !important;
+            }
+
+            table.body .container {
+                padding: 0 !important;
+                width: 100% !important;
+            }
+
+            table.body .main {
+                border-left-width: 0 !important;
+                border-radius: 0 !important;
+                border-right-width: 0 !important;
+            }
+
+            table.body .btn table {
+                width: 100% !important;
+            }
+
+            table.body .btn a {
+                width: 100% !important;
+            }
+
+            table.body .img-responsive {
+                height: auto !important;
+                max-width: 100% !important;
+                width: auto !important;
+            }
+        }
+
+        /* -------------------------------------
+            PRESERVE THESE STYLES IN THE HEAD
+        ------------------------------------- */
+        @media all {
+            .ExternalClass {
+                width: 100%;
+            }
+
+            .ExternalClass,
+            .ExternalClass p,
+            .ExternalClass span,
+            .ExternalClass font,
+            .ExternalClass td,
+            .ExternalClass div {
+                line-height: 100%;
+            }
+
+            .apple-link a {
+                color: inherit !important;
+                font-family: inherit !important;
+                font-size: inherit !important;
+                font-weight: inherit !important;
+                line-height: inherit !important;
+                text-decoration: none !important;
+            }
+
+            #MessageViewBody a {
+                color: inherit;
+                text-decoration: none;
+                font-size: inherit;
+                font-family: inherit;
+                font-weight: inherit;
+                line-height: inherit;
+            }
+
+            .btn-primary table td:hover {
+                background-color: #5495ed !important;
+            }
+
+            .btn-primary a:hover {
+                background-color: #5495ed !important;
+                border-color: #5495ed !important;
+            }
+        }
+    </style>
+    <!-- END STYLE -->
+</head>
+    <body>
+        <span class=3D"pre-header"></span>
+    <table role=3D"presentation" border=3D"0" cellpadding=3D"0" =
+cellspacing=3D"0" class=3D"body">
+        <tr>
+            <td>&nbsp;</td>
+            <td class=3D"container">
+                <div class=3D"content">
+                    <!-- START CENTERED WHITE CONTAINER -->
+                    <table role=3D"presentation" class=3D"main">
+                        <tr>
+    <td style=3D"width: 100%; padding-left: 24px; padding-top: 32px; =
+padding-bottom: 24px;">
+        <a =
+href=3D"https://email.flowwow.com/c/eJxci81q6zAQRp9G2lxukGZGlrzQIsY1FPoE3=
+Y1-3KR1qpI4dpunL1UJmG4OB873JT_m3FqQ2WuL0ACicTKf-Dg9lZfH5BuDVmkkefBAgQi0C8=
+waHSSOTjcBxhCCIdROHn0igxYzc6SAlkkZlXMCRSYCthYEqXEq61rWXSwnOfnDPH9cBO4FDAK=
+GbTv7Z37j2__AN45LnssCJEh98XvKn7vzVV6u4TXH2Yteibb_YfdQCaLXwnXV23-bMFT-BlVH=
+trqp7O_8e7b3gxLdfuNWLh6-AwAA___Jy1VE">
+            <img =
+src=3D"https://content3.flowwow-images.com/images/mail/new-logo.png" =
+width=3D"136"
+                 alt=3D"Logo" border=3D"0" style=3D"max-width:136px;">
+        </a>
+    </td>
+</tr>                        <!-- START MAIN CONTENT AREA -->
+                        <tr>
+    <td class=3D"wrapper">
+        <table role=3D"presentation" border=3D"0" cellpadding=3D"0" =
+cellspacing=3D"0">
+            <tr>
+                <td>
+                    <h1 style=3D"margin: 0; margin-bottom: 12px; color: =
+#111;">
+                        =D0=9D=D0=BE=D0=B2=D1=8B=D0=B9 =
+=D0=BE=D0=BF=D0=BB=D0=B0=D1=87=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9 =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7 =E2=84=9613785415                    =
+</h1>
+                    <p style=3D"margin-bottom: 16px;">
+                        =
+=D0=9F=D0=BE=D0=B6=D0=B0=D0=BB=D1=83=D0=B9=D1=81=D1=82=D0=B0, =
+=D0=BF=D0=B5=D1=80=D0=B5=D0=B9=D0=B4=D0=B8=D1=82=D0=B5 =D0=BF=D0=BE =
+=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B5, =D1=87=D1=82=D0=BE=D0=B1=D1=8B =
+=D0=BF=D1=80=D0=B8=D0=BD=D1=8F=D1=82=D1=8C =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7 =D0=B8=D0=BB=D0=B8 =
+=D0=BE=D1=82=D0=BA=D0=B0=D0=B7=D0=B0=D1=82=D1=8C=D1=81=D1=8F =
+=D0=BE=D1=82 =D0=BD=D0=B5=D0=B3=D0=BE.                    </p>
+
+                    <table role=3D"presentation" border=3D"0" =
+cellpadding=3D"0" cellspacing=3D"0" class=3D"btn btn-primary">
+                        <tbody>
+                        <tr>
+                            <td align=3D"left">
+                                <table role=3D"presentation" =
+border=3D"0" cellpadding=3D"0" cellspacing=3D"0">
+                                    <tbody>
+                                    <tr>
+                                        <td>
+                                            <a =
+href=3D"https://email.flowwow.com/c/eJxci0FOwzAQRU8z3iAqe2YcxwsvWoVISJyAn=
+WNPaKFpUJsm0NMjjCpFbJ6e9P7PoRfxDpUE4wgrJLK1kiEeji_j23MOlSWnDbHah8Sesu1q43=
+WP0ntjTOqI-2yZpKpqdQiZLTmSGBN35CJrq0UyarYJyTsE1v1xXJZx2aRxUMewn6bPC9AWsAV=
+sVw2wjXk4nABbdQ6v8SPeHrt4i2mWaZyRgfV3PGX52pyv6nLt3iVNARoNvvnl7qkQoTFQ74r7=
+h1VoC_-CLiNX3BY2d_4_u_tBw267cqfmgD8BAAD__9uEWHg" target=3D"_blank">
+                                                =
+=D0=9F=D0=B5=D1=80=D0=B5=D0=B9=D1=82=D0=B8 =D0=B2 =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7                                           =
+ </a>
+                                        </td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                            </td>
+                        </tr>
+                        </tbody>
+                    </table>
+
+                    <!-- START ORDER LIST -->
+                    <table>
+                        <p style=3D"font-weight: 700;">
+                            =D0=94=D0=B5=D1=82=D0=B0=D0=BB=D0=B8 =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0                        </p>
+                                                    <!-- START ITEM -->
+                            <tr style=3D"margin-bottom: 12px;">
+                                <td style=3D"width: 56px; =
+padding-right:12px;">
+                                    <img =
+src=3D"https://content3.flowwow-images.com/data/flowers/524x524/79/173101=
+9737_88267979.jpg" width=3D"" alt=3D"img" border=3D"0"
+                                         style=3D"max-width:56px;">
+                                </td>
+                                <td>
+                                    <p style=3D"margin-bottom: 4px;">
+                                        =D0=91=D1=83=D0=BA=D0=B5=D1=82 =
+=D0=B8=D0=B7 35 =D1=80=D0=BE=D0=B7 =D0=9A=D0=B5=D0=BD=D0=B8=D1=8F =
+=D0=BC=D0=B8=D0=BA=D1=81                                    </p>
+                                    <p style=3D"color: #8C8C8C;">
+                                        1 =D1=88=D1=82.                  =
+                  </p>
+                                </td>
+                                <td>
+                                    <p style=3D"text-align: right;">
+                                        5 990&#8381;                     =
+               </p>
+                                </td>
+                            </tr>
+                            <!-- END ITEM -->
+                                                    <!-- START ITEM -->
+                            <tr style=3D"margin-bottom: 12px;">
+                                <td style=3D"width: 56px; =
+padding-right:12px;">
+                                    <img =
+src=3D"https://content3.flowwow-images.com/data/flowers/524x524/14/173131=
+7882_78547614.jpg" width=3D"" alt=3D"img" border=3D"0"
+                                         style=3D"max-width:56px;">
+                                </td>
+                                <td>
+                                    <p style=3D"margin-bottom: 4px;">
+                                        =
+=D0=9E=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=BA=D0=B0                         =
+           </p>
+                                    <p style=3D"color: #8C8C8C;">
+                                        1 =D1=88=D1=82.                  =
+                  </p>
+                                </td>
+                                <td>
+                                    <p style=3D"text-align: right;">
+                                        0&#8381;                         =
+           </p>
+                                </td>
+                            </tr>
+                            <!-- END ITEM -->
+                                            </table>
+
+                    <table>
+                                                    <!-- START DELIVERY =
+-->
+                            <tr>
+                                <td style=3D"width: 70%;">
+                                    <p style=3D"margin-bottom: 4px;">
+                                        =
+=D0=94=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B0                         =
+           </p>
+                                                                         =
+   <p style=3D"color: #8C8C8C;">
+                                            =
+=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B0=D1=82=D0=B5=D0=BB=D1=8E =
+=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82=D1=81=D1=8F =
+=D1=81=D0=BC=D1=81 =D1=81 =
+=D0=BF=D1=80=D0=BE=D1=81=D1=8C=D0=B1=D0=BE=D0=B9 =
+=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D1=82=D1=8C =
+=D0=B0=D0=B4=D1=80=D0=B5=D1=81 =D0=B8 =D0=B2=D1=80=D0=B5=D0=BC=D1=8F =
+=D0=B4=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B8.                        =
+                </p>
+                                                                    =
+</td>
+                                <td style=3D"width: 30%;">
+                                    <p style=3D"text-align: right;">
+                                        350&#8381;                       =
+             </p>
+                                </td>
+                            </tr>
+                            <!-- END DELIVERY -->
+                       =20
+                        <!-- START TOTAL -->
+                        <tr>
+                            <td style=3D"width: 70%;">
+                                <p style=3D"margin-bottom: 4px;">
+                                    =D0=98=D1=82=D0=BE=D0=B3=D0=BE =
+=D0=BE=D0=BF=D0=BB=D0=B0=D1=87=D0=B5=D0=BD=D0=BE                         =
+       </p>
+                            </td>
+                            <td style=3D"width: 30%;">
+                                <p style=3D"text-align: right;">
+                                    6 340&#8381;                         =
+       </p>
+                            </td>
+                        </tr>
+                        <!-- END TOTAL -->
+                    </table>
+                    <p style=3D"margin-bottom: 16px; padding: 12px; =
+background-color:#FAFAFA;">
+                        <b>=D0=92=D0=B0=D0=B6=D0=BD=D0=BE =
+=D1=80=D0=B5=D0=B0=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C =
+=D0=BD=D0=B0 =D0=B7=D0=B0=D0=BA=D0=B0=D0=B7 =D0=BA=D0=B0=D0=BA =
+=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE =
+=D0=B1=D1=8B=D1=81=D1=82=D1=80=D0=B5=D0=B5</b><br>
+                        =D0=9A=D0=BB=D0=B8=D0=B5=D0=BD=D1=82 =
+=D1=83=D0=B6=D0=B5 =D0=BE=D0=BF=D0=BB=D0=B0=D1=82=D0=B8=D0=BB =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7 =D0=B8 =D0=B6=D0=B4=D0=B5=D1=82 =
+=D0=BF=D1=80=D0=B8=D0=BD=D1=8F=D1=82=D0=B8=D1=8F =
+=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0. =D0=B5=D1=81=D0=BB=D0=B8 =
+=D0=B2=D1=8B =
+=D0=BF=D1=80=D0=BE=D0=B8=D0=B3=D0=BD=D0=BE=D1=80=D0=B8=D1=80=D1=83=D0=B5=D1=
+=82=D0=B5 =D0=B7=D0=B0=D0=BA=D0=B0=D0=B7, =D1=82=D0=BE =
+=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD =
+=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B8=D1=82 =
+=D1=88=D1=82=D1=80=D0=B0=D1=84, =D1=82=D0=B0=D0=BA =D0=B6=D0=B5 =
+=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE =
+=D0=B1=D1=83=D0=B4=D0=B5=D1=82 =D1=81=D0=BA=D1=80=D1=8B=D1=82 =
+=D0=BE=D1=82 =D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=BE=D0=B2. =
+=D0=9F=D0=BE=D0=BC=D0=BD=D0=B8=D1=82=D0=B5, =D0=BE=D1=82 =
+=D0=B2=D0=B0=D1=81 =D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D1=82 =
+=D1=80=D0=B5=D0=BF=D1=83=D1=82=D0=B0=D1=86=D0=B8=D1=8F =
+=D0=B2=D0=B0=D1=88=D0=B5=D0=B3=D0=BE =
+=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD=D0=B0 =D0=B8 =
+=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81=D0=B0.                    </p>
+                </td>
+            </tr>
+        </table>
+    </td>
+</tr>
+                        <!-- END MAIN CONTENT AREA -->
+                    </table>
+                    <!-- END CENTERED WHITE CONTAINER -->
+                    <!-- START FOOTER -->
+<div class=3D"footer">
+    <table role=3D"presentation" border=3D"0" cellpadding=3D"0" =
+cellspacing=3D"0">
+        <tr>
+                            <td class=3D"card-button">
+                    <table cellspacing=3D"0" cellpadding=3D"0" =
+border=3D"0" width=3D"100%">
+                        <tr>
+                            <td>
+                                <table align=3D"left" cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0">
+                                    <tr>
+                                        <td width=3D"100%">
+                                            <table cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0" width=3D"100%">
+                                                <tr>
+                                                    <td>
+                                                        <table =
+cellspacing=3D"0" cellpadding=3D"0" border=3D"0" width=3D"100%">
+                                                            <tr>
+                                                                <td =
+style=3D" text-align:left;">
+                                                                    <div =
+style=3D"line-height:20px">
+                                                                        =
+<a =
+href=3D"https://email.flowwow.com/c/eJxci0FOwzAQRU9jbxCVM7Y79sKLViESEidgN=
+7YnbSHFKE0T6OkRRpUiNk9P8-bn0DN7BMmhQQ1b0No6yWc6DS_l8JzD1mpUjTbyGHLy3CQXPS=
+bcup4c-EyWLKlMzkOUp5CN1aiZKJmokYyyijmDMjaB9gjCqH4oy1KWTSpnOYTjNH1ehN4J6AR=
+0qyagi0M51LvuS5l4lGN4pXe6PUa6UZp5KjMYYdQ3fWT-2oxXebnGN05TEK0Svv3l_qkSRNsI=
+t6_uH1ahq_wLqj5hdVvZ3vl_jPeBEvvdylHOAX4CAAD__wB1W_I"
+                                                                         =
+  style=3D"text-decoration: none;">
+                                                                         =
+   <span style=3D"color: #484848;line-height:20px;font-family:Noto Sans, =
+Helvetica, Arial, sans-serif; =
+font-size:14px;text-align:left;font-weight: =
+700;">=D0=96=D1=83=D1=80=D0=BD=D0=B0=D0=BB Flowwow</span>
+                                                                        =
+</a>
+                                                                    =
+</div>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </td>
+                                                    <td width=3D"20">
+                                                        <table =
+width=3D"100%" cellspacing=3D"0" cellpadding=3D"0" border=3D"0">
+                                                            <tr>
+                                                                <td>
+                                                                    =
+<table align=3D"left" cellspacing=3D"0" cellpadding=3D"0"
+                                                                         =
+  border=3D"0">
+                                                                        =
+<tr>
+                                                                         =
+   <td style=3D"padding-left:8px;">
+                                                                         =
+       <img =
+src=3D"https://content2.flowwow-images.com/images/mail/footer/chevron-rig=
+ht.png"
+                                                                         =
+            width=3D"20" border=3D"0"
+                                                                         =
+            style=3D"max-width:20px; =
+height:auto;margin:auto;display:inline; padding-left:8px;">
+                                                                         =
+   </td>
+                                                                        =
+</tr>
+                                                                    =
+</table>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </td>
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <!-- END SUBHEAD -->
+
+                        <!-- START TEXT -->
+                        <tr>
+                            <td>
+                                <table cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0" width=3D"100%">
+                                    <tr>
+                                        <td style=3D"text-align:left;">
+                                            <div =
+style=3D"line-height:16px">
+                                            <span style=3D"color: =
+#8c8c8c;line-height:16px;font-family:Noto Sans, Helvetica, Arial, =
+sans-serif; font-size:12px;text-align:left;">
+                                                =
+=D0=A0=D0=B0=D1=81=D1=81=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC =
+=D0=BA=D0=B0=D0=BA =
+=D1=80=D0=B0=D0=B7=D0=B2=D0=B8=D0=B2=D0=B0=D1=82=D1=8C =
+=D1=81=D0=B2=D0=BE=D0=B9 =D0=B1=D1=80=D0=B5=D0=BD=D0=B4 =D0=B8 =
+=D0=BF=D1=80=D0=B8=D0=B2=D0=BB=D0=B5=D1=87=D1=8C =
+=D0=BF=D0=BE=D0=BA=D1=83=D0=BF=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9       =
+                                     </span>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <!-- END TEXT -->
+                    </table>
+                </td>
+           =20
+            <td width=3D"12">
+                <table cellspacing=3D"0" cellpadding=3D"0" border=3D"0">
+                    <tr>
+                    </tr>
+                </table>
+            </td>
+
+                            <td class=3D"card-button">
+                    <table cellspacing=3D"0" cellpadding=3D"0" =
+border=3D"0">
+                        <tr>
+                            <td>
+                                <table align=3D"left" cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0">
+                                    <tr>
+                                        <td>
+                                            <table cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0">
+                                                <tr>
+                                                    <td>
+                                                        <table =
+cellspacing=3D"0" cellpadding=3D"0" border=3D"0">
+                                                            <tr>
+                                                                <td =
+style=3D"text-align:left;">
+                                                                    <div =
+style=3D"line-height:20px">
+                                                                        =
+<a =
+href=3D"https://email.flowwow.com/c/eJxcy01LxDAQxvFPk1zEMp0kneaQw5ZaELzoY=
+UVveaut21rZ7YvupxcjC4uXH3-YeYJpY9SEPJqcBBYohCp5HG0_PExv98EUShDkQvLOBJm3qi=
+UVXKG1I-dd0OjIWl3o1gPw3gSpBIlorZdOkJWgIMaAIJVHoQmZhHaYtm3aMj-NfDDdPH-emNg=
+xbBg2czbGVFU5Lo_yGfZl93R4wX3Pj-bVHuz51tmz9WucpxUlk_BtP0L8yo4LPy3uPfrZsBqY=
+rn-t7pLI6pyVVWp9c3Vokn8HSE-UWiXri__HdBkAq3ZXTXw1-BMAAP__WchZRQ"
+                                                                         =
+  style=3D"text-decoration: none;">
+                                                                        =
+<span style=3D"color: #484848;line-height:20px;font-family:Noto Sans, =
+Helvetica, Arial, sans-serif; =
+font-size:14px;text-align:left;font-weight: 700;">=D0=A7=D0=B0=D1=82 =
+=D1=81=D0=B5=D0=BB=D0=BB=D0=B5=D1=80=D0=BE=D0=B2 Flowwow</span>
+                                                                        =
+</a>
+                                                                    =
+</div>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </td>
+                                                    <td width=3D"20">
+                                                        <table =
+width=3D"100%" cellspacing=3D"0" cellpadding=3D"0" border=3D"0">
+                                                            <tr>
+                                                                <td>
+                                                                    =
+<table align=3D"left" cellspacing=3D"0" cellpadding=3D"0"
+                                                                         =
+  border=3D"0">
+                                                                        =
+<tr>
+                                                                         =
+   <td style=3D"padding-left:8px;">
+                                                                         =
+       <img =
+src=3D"https://content2.flowwow-images.com/images/mail/footer/chevron-rig=
+ht.png"
+                                                                         =
+            width=3D"20" border=3D"0"
+                                                                         =
+            style=3D"max-width:20px; =
+height:auto;margin:auto;display:inline; padding-left:8px;">
+                                                                         =
+   </td>
+                                                                        =
+</tr>
+                                                                    =
+</table>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </td>
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td>
+                                <table cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0" width=3D"100%">
+                                    <tr>
+                                        <td style=3D"text-align:left;">
+                                            <div =
+style=3D"line-height:16px">
+                                            <span style=3D"color: =
+#8c8c8c;line-height:16px;font-family:Noto Sans, Helvetica, Arial, =
+sans-serif; =
+font-size:12px;text-align:left;">=D0=9E=D0=B1=D0=BC=D0=B5=D0=BD=D0=B8=D0=B2=
+=D0=B0=D0=B9=D1=82=D0=B5=D1=81=D1=8C =
+=D0=BE=D0=BF=D1=8B=D1=82=D0=BE=D0=BC =D0=B2 =
+=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D1=81=D1=82=D0=B2=D0=B5 =
+=D0=BF=D1=80=D0=B5=D0=B4=D0=BF=D1=80=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0=D1=82=D0=
+=B5=D0=BB=D0=B5=D0=B9</span>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                    </table>
+                </td>
+                    </tr>
+
+                    <tr style=3D"height: 8px;"></tr>
+            <tr>
+                <td class=3D"card-button" colspan=3D"3">
+                    <table cellspacing=3D"0" cellpadding=3D"0" =
+border=3D"0">
+                        <tr>
+                            <td>
+                                <table align=3D"left" cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0">
+                                    <tr>
+                                        <td>
+                                            <table cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0">
+                                                <tr>
+                                                    <td>
+                                                        <table =
+cellspacing=3D"0" cellpadding=3D"0" border=3D"0">
+                                                            <tr>
+                                                                <td =
+style=3D"text-align:left;">
+                                                                    <div =
+style=3D"line-height:20px">
+                                                                        =
+<a =
+href=3D"https://email.flowwow.com/c/eJxcy8FOwzAQBNCvsS-Iytm16_jgQ6sQCYkv4=
+Lax1zSQ1ChNE-jXI4wqRVyeRpqZ6BOzsyDZVxZhD4imljxSP7zkt-fo9watqlDLk8fKYe2cJt=
+XVFBlqTpqZYwpBEyDL3kdt0CITBd2hJa2MYo6gtAmAzoLQKg15XfO6C3mUgz_N8-dF4EFAK6D=
+tzynvNgMBbRppmuXkX-mDbo8d3SgsPOcFtNDqm86Rv3bTVV6u3TuH2YtGCdf8enwqgmgqUR9L=
+dg-boi3-FaqMbMmm2Nz9f7b3gxLHwyZbuXj4CQAA__8NgVq2"
+                                                                         =
+  style=3D"text-decoration: none;">
+                                                                        =
+<span style=3D"color: #484848;line-height:20px;font-family:Noto Sans, =
+Helvetica, Arial, sans-serif; =
+font-size:14px;text-align:left;font-weight: 700;">FMART by =
+flowwow</span>
+                                                                        =
+</a>
+                                                                    =
+</div>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </td>
+                                                    <td width=3D"20">
+                                                        <table =
+width=3D"100%" cellspacing=3D"0" cellpadding=3D"0" border=3D"0">
+                                                            <tr>
+                                                                <td>
+                                                                    =
+<table align=3D"left" cellspacing=3D"0" cellpadding=3D"0"
+                                                                         =
+  border=3D"0">
+                                                                        =
+<tr>
+                                                                         =
+   <td style=3D"padding-left:8px;">
+                                                                         =
+       <img =
+src=3D"https://content3.flowwow-images.com/images/mail/footer/chevron-rig=
+ht.png"
+                                                                         =
+            width=3D"20" border=3D"0"
+                                                                         =
+            style=3D"max-width:20px; =
+height:auto;margin:auto;display:inline; padding-left:8px;">
+                                                                         =
+   </td>
+                                                                        =
+</tr>
+                                                                    =
+</table>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </td>
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td>
+                                <table cellspacing=3D"0" =
+cellpadding=3D"0" border=3D"0" width=3D"100%">
+                                    <tr>
+                                        <td style=3D"text-align:left;">
+                                            <div =
+style=3D"line-height:16px">
+                                            <span style=3D"color: =
+#8c8c8c;line-height:16px;font-family:Noto Sans, Helvetica, Arial, =
+sans-serif; =
+font-size:12px;text-align:left;">=D0=97=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=
+ =D0=B0=D0=BD=D0=BA=D0=B5=D1=82=D1=83 =D0=B8 =
+=D0=BE=D1=82=D0=BA=D1=80=D0=BE=D0=B9 =D1=81=D0=B2=D0=BE=D0=B9 =
+=D1=81=D0=BE=D0=B1=D1=81=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9 =
+=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD FMART</span>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                    </table>
+                </td>
+            </tr>
+       =20
+        <table role=3D"presentation" border=3D"0" cellpadding=3D"0" =
+cellspacing=3D"0" style=3D"margin-top:16px;">
+                            <tr>
+                    <td class=3D"content-block">
+                        <span =
+class=3D"p">=D0=9F=D0=BE=D0=BB=D0=B5=D0=B7=D0=BD=D1=8B=D0=B9 =
+=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=BD=D1=82</span>
+                    </td>
+                    <td style=3D"text-align:right; =
+vertical-align:middle; padding-right:8px;">
+                                                    <a =
+href=3D"https://email.flowwow.com/c/eJxci01OwzAQRk9jbxCVMzPO1AsvGoVISJyAD=
+bKdKS1NCUrSBHp6VEOlqpunp--n9VsRx6DFF4xQAqJdazmGfffSvz-3vrTIpkDSO1_GKMkBOA=
+pgU3KUEExMwJGdCJHe-5YsMkoIiSJyIGONSAuGbAJ0DIrMtuuXpV9WqT_qzu-m6WtUuFHQKGj=
+mwyVW0PyP3kbpOhn04F_DIZwfYziHNMvUz0CKzE_4bOV7NZz0eIofkiavaqNcfWH1lAmqLtS6=
+yu4eboom868wecTZbWZ95f2Zrwejqs2Ns549_AYAAP__JElZ8A" =
+style=3D"text-decoration: none;">
+                                <img =
+src=3D"https://content2.flowwow-images.com/images/mail/footer/vk-icon.png=
+"
+                                     alt=3D"VK" width=3D"32" =
+height=3D"32" border=3D"0"
+                                     style=3D"border:0; outline:none; =
+text-decoration:none; display:inline; padding-right:8px;">
+                            </a>
+                            <a =
+href=3D"https://email.flowwow.com/c/eJxcy89O8zAQBPCnWV8-fZGza8f2wYdGIRIST=
+8DNsTe0kDYozR_I0yMMlSouP400M8n3zM6gYF8awgqJtBV8DqfhaXx5TL7SZGRJShy9popKWw=
+XUVjkZbd_F3vWOyWrDGJM4-aQ0GeIQourIBCW1ZE4olY5IziAo2Q_jto1bEcezGPxxnt-vQAf=
+AFrBNO1-KaQFsf1di8s_hLez_u7CHuPI8rqhAyc9wSfxRTIu4Lt0rx9lDI8E139YPWYSmBFvn=
+7P7dFW32p5B5ZHLW2ebm37O5HSTUh7tsxOrxKwAA__8Yklc8" =
+style=3D"text-decoration: none;">
+                                <img =
+src=3D"https://content3.flowwow-images.com/images/mail/footer/zen-logo.pn=
+g"
+                                     alt=3D"Zen" width=3D"62" =
+height=3D"32" border=3D"0"
+                                     style=3D"border:0; outline:none; =
+text-decoration:none; display:inline;">
+                            </a>
+                       =20
+                       =20
+                                            </td>
+                </tr>
+                    </table>
+        <table role=3D"presentation" border=3D"0" cellpadding=3D"0" =
+cellspacing=3D"0">
+            <tr>
+                <td class=3D"content-block">
+                    <span =
+class=3D"p">=D0=A1=D0=BA=D0=B0=D1=87=D0=B0=D1=82=D1=8C =
+=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5</span>
+                </td>
+                <td style=3D"text-align:right; vertical-align:middle; =
+padding-right:8px;">
+                    <a =
+href=3D"https://email.flowwow.com/c/eJxci8FugkAQhp9m9tJolpldBg570FCSJn2C3=
+sbdodpiIYDS-vSNWBPTy5c_882XQqNaMhoNGRPmSOQLo0c5tK_d-0sKuSe2GTmzD5i4yVKOuY=
+-cky0pk0x85KJobGpiNIeQnCcmFYluRyzOequa0DofkUpGcLZpu3nu5nXsjqYN-2nqR6ANYA1=
+YS9-Pa-n7Vq8asB5Otytg_detRm1bHQBrM4Q3-ZTLaicXiWedujM6cPZHvpJ-r4eTGU-7D41T=
+gMpCWV25fV6IUGVQbJddPj2IeuFN2OWJl-0XVnf-j_keWNhuHjabc8DfAAAA___i2GCi" =
+style=3D"text-decoration: none;">
+                        <img =
+src=3D"https://content3.flowwow-images.com/images/mail/footer/app-store-i=
+con.png"
+                             alt=3D"App Store" width=3D"32" =
+height=3D"32" border=3D"0"
+                             style=3D"border:0; outline:none; =
+text-decoration:none; display:inline; padding-right:8px;">
+                    </a>
+                    <a =
+href=3D"https://email.flowwow.com/c/eJxci8Fq6zAQRb9mtHk8I89IVrzQIsEVFPoF3=
+Y2lceLWqUzsxE2-vsQlELo5XDj3JN-J1A6V-NIRVkhkN0qO3A9vef-afGXJ6ZKMOvjamspF03=
+ZdWTFVjsWU7T3QDsluOtX7ZCw5EuZoWnJstNUiCbWxEal2CEZ3Q16WvBQxH9XgD_M8TkBbwAA=
+YxoGvxT7n_SB3DximOZ8EMPA4ToAhycz9MAGFPgE1MR-LbuFxVCf_zp98-9_yjeNF5nxBA0Zf=
+-SvJd3E6q-ncfkicPTQa6ubO3ctKhKaEzW7d9b8nEVb-Cr2e3LrtyubBv7F7BBp226ft1MXjT=
+wAAAP__whlkTA" style=3D"text-decoration: none;">
+                        <img =
+src=3D"https://content3.flowwow-images.com/images/mail/footer/google-play=
+-icon.png"
+                             alt=3D"Google Play Store" width=3D"32" =
+height=3D"32" border=3D"0"
+                             style=3D"border:0; outline:none; =
+text-decoration:none; display:inline;">
+                    </a>
+                </td>
+            </tr>
+
+                            <tr>
+                    <td style=3D"padding-top: 8px;">
+                        <a =
+href=3D"https://email.flowwow.com/c/eJxci8FOwzAMhp8muSCm1Hbq5pDDqlIJiSfg5=
+qQpG3QUtq6FPT1a0KRql0-f9fnvfJ-SY9DJF4xQAqKtdDrIfngZ3547X1pkUyDpnTchQF9Gx-=
+JCRZFdH8ARBKJQCADqve_IImMSiRSQhYw1KXVgyEZAx6DI9MO4LOOyieNBD343TV8nhVsFrYJ=
+21a6XfCto9dG_yodcHoNcJM5pGmcgReZXPrv0szme9ekc3lOcvGqMcs2V9VMmqKZQVZ3dPaxC=
+m_kfTH7i7DazufF-zLeBUfV25axnD38BAAD__xz_V8s">
+                        <span style=3D"color: =
+#8c8c8c;line-height:20px;font-family:Noto Sans, Helvetica, Arial, =
+sans-serif; font-size:16px;text-decoration: underline;text-align:left;">
+                            =D0=A6=D0=B5=D0=BD=D1=82=D1=80 =
+=D0=BF=D0=BE=D0=BC=D0=BE=D1=89=D0=B8                        </span>
+                        </a>
+                    </td>
+                </tr>
+                    </table>
+    </table>
+</div>
+<!-- END FOOTER -->                </div>
+            </td>
+            <td>&nbsp;</td>
+        </tr>
+    </table>
+        <img width=3D"1px" height=3D"1px" alt=3D"" =
+src=3D"https://email.flowwow.com/o/eJxcy8FKAzEQxvGnSS5imc3M7DSHHCyrIPgE3m=
+aTWa22Bmq7q316MVIoXn78YeYraTKLErylTjD0AZHX3va63T3Vl8eSekaBDsm_JgLoVYrwxNK=
+DFKYCGJFH7sokoH6bCjEKmmqmEUUJGMxKAOIcMEpwBNOuLktdVrnu_SE967ueb0c9a57tWOdA=
+juBbP4p9rQ4n_3ka3ywfkxvAxeHXzX0zuKFz603reHN1eGj-HaA9SWtuDhf_j-UyALe5u2rxc=
+wo_AQAA___mAUt0"></body>
+    </html>
+
+';
         //$html = quoted_printable_decode($html);
         if (!empty($html)) {
+            $html = quoted_printable_decode($html);
+            $html = preg_replace('/\s+/', ' ', $html);
+            // Декодируем HTML-сущности
             $html = html_entity_decode($html, ENT_COMPAT, 'UTF-8');
 
-         $doc = new HtmlDomParser($html);
-
+            $doc = new HtmlDomParser($html);
+            $orderNumber = '';
             $main = $doc->findOneOrFalse("body");
 
             if ($main !== false) {
@@ -95,16 +1162,20 @@ class FlowwowController extends Controller
                 }
             }
             $orderDetails['number'] = $orderNumber;
+            $orderDetails['date'] = date('Y-m-d H:m:s');
             $deliveryText = '';
-            $commentText = '';
             $clientText = '';
-            $recipientText = '';
             $orderItems = [];
 
 
-            $deliveryBlock = $main->findOne('p:contains("Доставить")');
+            $linkBlock = $main->findOneOrFalse('a:contains("Перейти в заказ ")');
+            if ($linkBlock) {
+                $link = $linkBlock->getAttribute('href');
+                $orderDetails['orderLink'] = $link;
+            }
 
 
+            $deliveryBlock = $main->findOne('p:contains("Доставить")');
             $pickupBlock = $main->findOne('p:contains("Самовывоз")');
 
             if ($deliveryBlock && $deliveryBlock->nextNonWhitespaceSibling()) {
@@ -129,8 +1200,6 @@ class FlowwowController extends Controller
                 $orderDetails['comment'] = trim($commentText);
             }
 
-
-
             $clientBlock = $main->findOne('p:contains("Клиент")');
             $senderBlock = $main->findOne('p:contains("Отправитель")');
 
@@ -163,53 +1232,73 @@ class FlowwowController extends Controller
                 $orderDetails['recipient'] = $recipientText;
             }
 
-
-            $itemsBlock = $main->findOneOrFalse('h2:contains("Детали заказа")') ? $main->findOne('h2:contains("Детали заказа")') : $main->findOneOrFalse('p:contains("Детали заказа")');
+            $itemsBlock = false;
+            if ($main->findOneOrFalse('table h2:contains("Детали заказа")') != false) {
+                $itemsBlock = $main->findOneOrFalse('table h2:contains("Детали заказа")');
+            } elseif ($main->findOneOrFalse('table p:contains("Детали заказа")') != false) {
+                $itemsBlock = $main->findOneOrFalse('table p:contains("Детали заказа")');
+            }
 
             if ($itemsBlock) {
-                $itemsTable = $itemsBlock->parentNode()->find('table', 2);
+               // Yii::warning('Детали заказа 3: ' . json_encode($itemsBlock->parentNode()->innerText(), JSON_UNESCAPED_UNICODE), __METHOD__);
+                // $itemsTable = $itemsBlock->parentNode()->find('table', 2);
+                $itemsTable = $itemsBlock->parentNode();
 
                 $itemsRows = $itemsTable->find('tr');
                 foreach ($itemsRows as $itemsRow) {
-                    Yii::warning('Строка заказа: ' . json_encode($itemsRow->innerText(), JSON_UNESCAPED_UNICODE), __METHOD__);
+                   // Yii::warning('Строка заказа: ' . json_encode($itemsRow->innerText(), JSON_UNESCAPED_UNICODE), __METHOD__);
                     $itemData = [
                         'name' => '',
                         'count' => '',
                         'price' => '',
                     ];
 
-
                     // Извлекаем название и количество из второго <td>
                     $tds = $itemsRow->find('td');
                     if (count($tds) >= 2) {
                         $itemData['name'] = trim(str_replace("\u{00A0}", ' ', strip_tags(preg_replace('/\s+/', ' ',$tds[1]->find('p', 0)->innerText()))));
                         $itemData['count'] = trim(str_replace(["\u{00A0}", 'шт.'], '', strip_tags(preg_replace('/\s+/', '', $tds[1]->find('p', 1)->innerText()))));
                     }
-
                     // Извлекаем цену из третьего <td>
                     if (count($tds) >= 3) {
                         $itemData['price'] = (float)trim(str_replace(["\u{00A0}", '₽' , ' '], '', strip_tags(preg_replace('/\s+/', ' ', $tds[2]->find('p', 0)->innerText()))));
                     }
-
-
                     // Добавляем данные в массив
                     $orderItems[] = $itemData;
                 }
                 $totalSum = 0;
-                $sumBlock = $itemsBlock->parentNode()->find('table', 3);
-                $sumRow = $sumBlock->find('tr');
+                
+                $sumBlock = $main->findOneOrFalse('p:contains("Итого оплачено")');
+
+                if ($sumBlock) {
+                    $sumBlock = $sumBlock->parentNode()->nextNonWhitespaceSibling();
+                        $totalSum = (float)trim(
+                            str_replace(["\u{00A0}", '₽', ' '],
+                                '',
+                                strip_tags(preg_replace('/\s+/', ' ', $sumBlock->innerText())))
+                        );
+                }
 
-                $sumTds = $sumRow->find('td');
-                if (count($sumTds) >= 2) {
-                    $totalSum = (float)trim(str_replace(["\u{00A0}", '₽' , ' '], '', strip_tags(preg_replace('/\s+/', ' ', $sumTds[1]->innerText()))));
+                $deliverySum = 0;
 
+                $devSumBlock = $main->findOneOrFalse('p:contains("Доставка")');
+
+                if ($devSumBlock) {
+                    $devSumBlock = $devSumBlock->parentNode()->nextNonWhitespaceSibling();
+                    $deliverySum = (float)trim(
+                        str_replace(["\u{00A0}", '₽', ' '],
+                            '',
+                            strip_tags(preg_replace('/\s+/', ' ', $devSumBlock->innerText())))
+                    );
                 }
+
                 $orderDetails['items'] = $orderItems;
-                $orderDetails['totalSum'] =  $totalSum;
+                $orderDetails['deliverySum'] = $deliverySum;
+                $orderDetails['totalSum'] = $totalSum;
             }
-
+            $order[$orderNumber] = $orderDetails;
         }
-        $order[$orderNumber] = $orderDetails;
+
         return [
             'success' => true,
             'order' => $order
index 15deea5eac0d8d99cf37510f3ac3ba4dd2474db3..dd05fb634eb104b3cb94ee3db562eee38402188d 100644 (file)
@@ -19,7 +19,11 @@ class m250321_134458_create_marketplace_flowwow_emails_table extends Migration
             $this->createTable(self::TABLE_NAME, [
                 'id' => $this->bigPrimaryKey()->comment('ID'),
                 'subject' => $this->string()->notNull()->comment('Тема письма'),
-                'subject_pattern' => $this->string()->null()->comment('Шаблон темы письма'),
+                'email_status' => $this
+                    ->integer(1)
+                    ->notNull()
+                    ->defaultValue(0)
+                    ->comment('Статус письма - разобрано - 1, не разобрано - 2'),
                 'from' => $this->string(255)->notNull()->comment('Отправитель письма'),
                 'to' => $this->string()->notNull()->comment('Получатель письма'),
                 'date' => $this->dateTime()->notNull()->comment('Дата письма'),
index e148ff526b87b663804f4e427894e1b8e9fda391..42f33a22f758fb3bbf9db62db552b6c78c3d58af 100644 (file)
@@ -9,7 +9,7 @@ use Yii;
  *
  * @property int $id ID
  * @property string $subject Тема письма
- * @property string|null $subject_pattern Шаблон темы письма
+ * @property int|null $email_status Статус письма - разобрано - 1, не разобрано - 2
  * @property string $from Отправитель письма
  * @property string $to Получатель письма
  * @property string $date Дата письма
@@ -34,11 +34,12 @@ class MarketplaceFlowwowEmails extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
-            [['subject_pattern'], 'default', 'value' => null],
+            [['email_status'], 'default', 'value' => 0],
             [['subject', 'from', 'to', 'date', 'body'], 'required'],
             [['date', 'created_at'], 'safe'],
             [['body'], 'string'],
-            [['subject', 'subject_pattern', 'from', 'to'], 'string', 'max' => 255],
+            [['email_status'], 'integer'],
+            [['subject',  'from', 'to'], 'string', 'max' => 255],
         ];
     }
 
@@ -50,7 +51,7 @@ class MarketplaceFlowwowEmails extends \yii\db\ActiveRecord
         return [
             'id' => 'ID',
             'subject' => 'Тема письма',
-            'subject_pattern' => 'Шаблон темы письма',
+            'email_status' => 'Статус письма',
             'from' => 'Отправитель письма',
             'to' => 'Получатель письма',
             'date' => 'Дата письма',
index a0426ab5f902c7a2c50300f8368e30f3177ecd42..13f2e8145c97fc7585ad04fe22bc295d0dc0f87a 100644 (file)
@@ -17,8 +17,8 @@ class MarketplaceFlowwowEmailsSearch extends MarketplaceFlowwowEmails
     public function rules()
     {
         return [
-            [['id'], 'integer'],
-            [['subject', 'subject_pattern', 'from', 'to', 'date', 'body', 'created_at'], 'safe'],
+            [['id', 'email_status'], 'integer'],
+            [['subject', 'from', 'to', 'date', 'body', 'created_at', 'email_status'], 'safe'],
         ];
     }
 
@@ -65,7 +65,7 @@ class MarketplaceFlowwowEmailsSearch extends MarketplaceFlowwowEmails
         ]);
 
         $query->andFilterWhere(['ilike', 'subject', $this->subject])
-            ->andFilterWhere(['ilike', 'subject_pattern', $this->subject_pattern])
+            ->andFilterWhere(['email_status' => $this->email_status])
             ->andFilterWhere(['ilike', 'from', $this->from])
             ->andFilterWhere(['ilike', 'to', $this->to])
             ->andFilterWhere(['ilike', 'body', $this->body]);
index a2d48528ba6a93c216e799615be7a5a62fc87f82..c6d3e58d233f14eb23864dd5862a247d1deb7a5b 100644 (file)
@@ -78,11 +78,11 @@ class MarketplaceService
         ]
     ];
 
-    const SUBJECT_NEW = '/^Новый_оплаченный_заказ$/';
-    const SUBJECT_APPROVED = '/^Заказ_№\d+_принят!$/';
-    const SUBJECT_CANCELLED = '/^Заказ_№\d+_отменён$/';
-    const SUBJECT_CHANGED = '/^Изменения_в_заказе_№\d+$/';
-    const SUBJECT_DELIVERED = '/^Flowwow. Заказ_выполнен._Напишите_отзыв_о_клиенте$/';
+    const SUBJECT_NEW = '/^Новый оплаченный заказ$/';
+    const SUBJECT_APPROVED = '/^Заказ №\d+ принят!$/';
+    const SUBJECT_CANCELLED = '/^Заказ №\d+ отменён$/';
+    const SUBJECT_CHANGED = '/^Изменения в заказе №\d+$/';
+    const SUBJECT_DELIVERED = '/^Flowwow. Заказ выполнен. Напишите отзыв о клиенте$/';
 
 
     const SUBJECT_INDEX = [
@@ -1350,7 +1350,8 @@ class MarketplaceService
         $useSince = false,
         $useAlternateMailbox = false,
         $progressCallback = null,
-        $seen = false
+        $seen = false,
+        $unseen = false
     ) {
         imap_errors();
         imap_alerts(); 
@@ -1364,7 +1365,7 @@ class MarketplaceService
         imap_timeout(IMAP_CLOSETIMEOUT, 120);
 
         $searchCriteria = '';
-        $searchCriteria .= ($useSince ? 'SINCE ' : 'ON ');
+        $searchCriteria = ($useSince ? 'SINCE ' : 'ON ');
 
         if (!$date) {
             $date = date('d-M-Y');
@@ -1374,7 +1375,13 @@ class MarketplaceService
             $searchCriteria .= '"' . $date . '" ';
         }
 
-        $searchCriteria .= ($seen ? 'SEEN ' : 'UNSEEN ');
+        if ($seen) {
+            $searchCriteria .= 'SEEN ';
+        }
+
+        if ($unseen) {
+            $searchCriteria .= 'UNSEEN ';
+        }
 
         $subjectPatterns = [
             self::SUBJECT_NEW,
@@ -1418,6 +1425,9 @@ class MarketplaceService
         $messages = [];
 
         foreach ($folders as $folder) {
+            if ($folder == '{imap.yandex.ru:993/imap/ssl}Drafts') {
+                continue;
+            }
             $inbox = imap_open($folder, $username, $password);
 
             if (!$inbox) {
@@ -1441,9 +1451,24 @@ class MarketplaceService
                     $overview = imap_fetch_overview($inbox, $email_number, 0);
                     $structure = imap_fetchstructure($inbox, $email_number);
                     $htmlMessage = '';
+                    if (!isset($overview[0]->subject)) {
+                        continue;
+                    }
                     $subject = mb_decode_mimeheader($overview[0]->subject);
+                   // $subject = mb_convert_encoding($subject, 'UTF-8', mb_detect_encoding($subject, 'UTF-8, ISO-8859-1, Windows-1251', true));
+                    $subject = str_replace('_', ' ', $subject);
+
                     $from = mb_decode_mimeheader($overview[0]->from);
-                    $to = mb_decode_mimeheader($overview[0]->to);
+                    if (isset($overview[0]->to)) {
+                        $to = mb_decode_mimeheader($overview[0]->to);
+                    } else {
+                        if ($useAlternateMailbox) {
+                            $to = 'Zakaz-bazacvetov24@yandex.ru';
+                        } else {
+                            $to = 'flow@bazacvetov24.ru';
+                        }
+                    }
+
                     $date = date('Y-m-d H:i:s', strtotime(mb_decode_mimeheader($overview[0]->date)));
                     if (isset($structure->parts) && count($structure->parts)) {
                         foreach ($structure->parts as $partNum => $part) {
@@ -1459,7 +1484,7 @@ class MarketplaceService
                         if (preg_match($pattern, $subject)) {
                             $subjectIndex = self::SUBJECT_INDEX[$pattern];
                             if ($savedEmail !== null) {
-                                $savedEmail->subject_pattern = $pattern;
+                                $savedEmail->email_status = 1;
                                 $savedEmail->save();
                             }
                             $messages[] = [
@@ -1470,20 +1495,23 @@ class MarketplaceService
                                 'date' => $date,
                                 'body' => $htmlMessage,
                             ];
-                            self::imap_debug_log("Установка флага SEEN для сообшения #" . $email_number, $debugMode, $progressCallback);
-                            $result = imap_setflag_full($inbox, $email_number, "\\Seen");
-                            if (!$result) {
-                                self::imap_debug_log("Не удалось установить SEEN flag: " . imap_last_error(), $debugMode, $progressCallback);
-                            } else {
-                                self::imap_debug_log("SEEN установлен успешно", $debugMode, $progressCallback);
-                            }
-                            self::check_imap_errors($debugMode, $progressCallback);
 
-                            $overview_after = imap_fetch_overview($inbox, $email_number, 0);
-                            if (isset($overview_after[0]->seen) && $overview_after[0]->seen) {
-                                self::imap_debug_log("Сообщение #" . $email_number . "  помечено SEEN", $debugMode, $progressCallback);
-                            } else {
-                                self::imap_debug_log("WARNING: Сообщение #" . $email_number . " не удалось пометить как  SEEN", $debugMode, $progressCallback);
+                            if ($unseen) {
+                                self::imap_debug_log("Установка флага SEEN для сообшения #" . $email_number, $debugMode, $progressCallback);
+                                $result = imap_setflag_full($inbox, $email_number, "\\Seen");
+                                if (!$result) {
+                                    self::imap_debug_log("Не удалось установить SEEN flag: " . imap_last_error(), $debugMode, $progressCallback);
+                                } else {
+                                    self::imap_debug_log("SEEN установлен успешно", $debugMode, $progressCallback);
+                                }
+                                self::check_imap_errors($debugMode, $progressCallback);
+
+                                $overview_after = imap_fetch_overview($inbox, $email_number, 0);
+                                if (isset($overview_after[0]->seen) && $overview_after[0]->seen) {
+                                    self::imap_debug_log("Сообщение #" . $email_number . "  помечено SEEN", $debugMode, $progressCallback);
+                                } else {
+                                    self::imap_debug_log("WARNING: Сообщение #" . $email_number . " не удалось пометить как  SEEN", $debugMode, $progressCallback);
+                                }
                             }
 
                             if ($progressCallback) {
@@ -1525,7 +1553,7 @@ class MarketplaceService
         if (!$exists) {
             $email = new MarketplaceFlowwowEmails();
             $email->subject = $subject;
-            $email->subject_pattern = $subjectPattern;
+            $email->email_status = 0;
             $email->from = $from;
             $email->to = $to;
             $email->date = $date;
@@ -1538,7 +1566,6 @@ class MarketplaceService
                 Yii::error('Письмо не сохранено' . json_encode($email->errors), __METHOD__);
                 return null;
             }
-
         }
     }
 
@@ -1549,7 +1576,7 @@ class MarketplaceService
             if ($progressCallback) {
                 call_user_func($progressCallback, "DEBUG: " . $message);
             }
-            Yii::info($message, 'imap_debug');
+            Yii::warning($message, 'imap_debug');
         }
     }
 
@@ -1629,7 +1656,8 @@ class MarketplaceService
             $deliveryText = '';
             $clientText = '';
             $orderItems = [];
-
+            $totalSum = 0;
+            $deliverySum = 0;
 
             $linkBlock = $main->findOneOrFalse('a:contains("Перейти в заказ ")');
             if ($linkBlock) {
@@ -1731,18 +1759,43 @@ class MarketplaceService
                     // Добавляем данные в массив
                     $orderItems[] = $itemData;
                 }
-                $totalSum = 0;
-                $sumBlock = $itemsBlock->parentNode()->nextNonWhitespaceSibling();
-                $sumRow = $sumBlock->find('tr');
 
-                $sumTds = $sumRow->find('td');
-                if ($sumTds && count($sumTds) >= 2) {
-                    $totalSum = (float)trim(str_replace(["\u{00A0}", '₽' , ' '], '', strip_tags(preg_replace('/\s+/', ' ', $sumTds[1]->innerText()))));
+                $sumBlock = $main->findOneOrFalse('p:contains("Итого оплачено")');
+
+                if ($sumBlock) {
+                    $sumBlock = $sumBlock->parentNode()->nextNonWhitespaceSibling();
+                    $totalSum = (float)trim
+                    (
+                        str_replace(
+                            ["\u{00A0}", '₽', ' '],
+                            '',
+                            strip_tags
+                            (
+                                preg_replace
+                                (
+                                '/\s+/',
+                                ' ',
+                                $sumBlock->innerText()
+                                )
+                            )
+                        )
+                    );
+                }
+
+                $devSumBlock = $main->findOneOrFalse('p:contains("Доставка")');
+
+                if ($devSumBlock) {
+                    $devSumBlock = $devSumBlock->parentNode()->nextNonWhitespaceSibling();
+                    $deliverySum = (float)trim(
+                        str_replace(["\u{00A0}", '₽', ' '],
+                            '',
+                            strip_tags(preg_replace('/\s+/', ' ', $devSumBlock->innerText())))
+                    );
                 }
-                $orderDetails['items'] = $orderItems;
-                $orderDetails['totalSum'] =  $totalSum;
             }
-
+            $orderDetails['items'] = $orderItems;
+            $orderDetails['deliverySum'] = $deliverySum;
+            $orderDetails['totalSum'] = $totalSum;
             $order[$orderNumber] = $orderDetails;
             return $order;
         }
@@ -1875,7 +1928,7 @@ class MarketplaceService
         $marketplaceOrder->updated_at = date('Y-m-d H:i:s');
         $marketplaceOrder->warehouse_guid = (string)$campaignId;
         $marketplaceOrder->total = $order['totalSum'];
-        $marketplaceOrder->delivery_total = 0;
+        $marketplaceOrder->delivery_total = $order['deliverySum'];
         $marketplaceOrder->buyer_total_before_discount = $order['totalSum'];
         $marketplaceOrder->tax_system = 'UNKNOWN';
         $marketplaceOrder->payment_type = 'UNKNOWN';
index 9bc491a24b881f274acd7c9814088c8fd96824c1..b8fedb1dd9c8b7628accdafeb490e7b4944a9cbc 100644 (file)
@@ -14,7 +14,7 @@ use yii\widgets\ActiveForm;
 
     <?= $form->field($model, 'subject')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($model, 'subject_pattern')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'email_status')->textInput(['type' => 'number', 'readonly' => true]) ?>
 
     <?= $form->field($model, 'from')->textInput(['maxlength' => true]) ?>
 
index dbae395126ed37dd6d7d56e82332df6041c3cdc5..1b75aad893730aac66e05b4a4d5e52779564b668 100644 (file)
@@ -19,7 +19,7 @@ use yii\widgets\ActiveForm;
 
     <?= $form->field($model, 'subject') ?>
 
-    <?= $form->field($model, 'subject_pattern') ?>
+    <?= $form->field($model, 'email_status') ?>
 
     <?= $form->field($model, 'from') ?>
 
index 07861ce3d70a329f821565bb099ef465f28159d5..a5ec2d45a12e9444d0f38385b127a40c3edb0f24 100644 (file)
@@ -10,16 +10,15 @@ use yii\grid\GridView;
 /** @var yii_app\records\MarketplaceFlowwowEmailsSearch $searchModel */
 /** @var yii\data\ActiveDataProvider $dataProvider */
 
-$this->title = 'Marketplace Flowwow Emails';
+$this->title = 'Письма по заказам Flowwow';
 $this->params['breadcrumbs'][] = $this->title;
 ?>
-<div class="marketplace-flowwow-emails-index">
+<div class="marketplace-flowwow-emails-index p-4">
 
+    <?= Html::a('к Заказам', ['/marketplace-orders/index'], ['class' => 'btn btn-primary my-4']) ?>
     <h1><?= Html::encode($this->title) ?></h1>
 
-    <p>
-        <?= Html::a('Create Marketplace Flowwow Emails', ['create'], ['class' => 'btn btn-success']) ?>
-    </p>
+
 
     <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
 
@@ -31,14 +30,15 @@ $this->params['breadcrumbs'][] = $this->title;
 
             'id',
             'subject',
-            'subject_pattern',
+            'email_status',
             'from',
             'to',
-            //'date',
+            'date',
             //'body:ntext',
-            //'created_at',
+            'created_at',
             [
-                'class' => ActionColumn::className(),
+                'template' => '{view}',
+                'class' => ActionColumn::class,
                 'urlCreator' => function ($action, MarketplaceFlowwowEmails $model, $key, $index, $column) {
                     return Url::toRoute([$action, 'id' => $model->id]);
                  }
index 2e94d5d43bdccb1d1804e7e37af5ed566adf31b7..7acb820be90ebc82108002925d0cfec347437667 100644 (file)
@@ -6,32 +6,22 @@ use yii\widgets\DetailView;
 /** @var yii\web\View $this */
 /** @var yii_app\records\MarketplaceFlowwowEmails $model */
 
-$this->title = $model->id;
+$this->title = 'Письмо' .  $model->subject . ' от ' . $model->date;
 $this->params['breadcrumbs'][] = ['label' => 'Marketplace Flowwow Emails', 'url' => ['index']];
 $this->params['breadcrumbs'][] = $this->title;
 \yii\web\YiiAsset::register($this);
 ?>
-<div class="marketplace-flowwow-emails-view">
-
+<div class="marketplace-flowwow-emails-view p-4">
+    <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary my-4']) ?>
     <h1><?= Html::encode($this->title) ?></h1>
 
-    <p>
-        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
-        <?= Html::a('Delete', ['delete', 'id' => $model->id], [
-            'class' => 'btn btn-danger',
-            'data' => [
-                'confirm' => 'Are you sure you want to delete this item?',
-                'method' => 'post',
-            ],
-        ]) ?>
-    </p>
 
     <?= DetailView::widget([
         'model' => $model,
         'attributes' => [
             'id',
             'subject',
-            'subject_pattern',
+            'email_status',
             'from',
             'to',
             'date',