Commit 7b111c53188b0543e3a454ef2f758ee3d46288ee
1 parent
3c014fd3
generating task base
Showing
2 changed files
with
30 additions
and
22 deletions
Show diff stats
src/app/tasks/abadoned_basket.php
... | ... | @@ -23,29 +23,20 @@ class BasketTask extends \Phalcon\CLI\Task |
23 | 23 | |
24 | 24 | public function sendAction(){ |
25 | 25 | |
26 | - $subscribers = $this->models->getSubscribe()->getAllData(); | |
27 | - | |
28 | - foreach ($subscribers as $subscriber) { | |
29 | - $id = $subscriber['id']; | |
30 | - $name = $subscriber['name']; | |
31 | - $email = $subscriber['email']; | |
32 | - $date = strtotime($subscriber['date']); | |
33 | - $greeting_status = $subscriber['greeting']; | |
34 | - | |
35 | - $two_days_before = time() - (3600*24*2); | |
36 | - | |
37 | - $header = | |
38 | - 'From: '.self::$from."\n". | |
39 | - 'Reply-To: '.self::$reply_to."\n". | |
40 | - 'Return-Path: '.self::$reply_to."\n". | |
41 | - 'MIME-Version: 1.0'."\n". | |
42 | - 'Content-type: text/html; charset=UTF-8'."\n". | |
43 | - 'Content-Transfer-Encoding: 8bit'."\n". | |
44 | - 'X-Mailer: PHP/' . phpversion(); | |
45 | - $msg['staus'] = '0'; | |
46 | - $msg['text'] = ''; | |
26 | + $abandoned_users = $this->models->getBasket()->getAbandonedUsers(); | |
27 | + | |
28 | + foreach ($abandoned_users as $item) { | |
29 | + | |
30 | + $user_id = $item['user_id']; | |
31 | + $user = $this->models->getCustomers()->getOneData($user_id); | |
32 | + if (!empty($user['email'])) { | |
33 | + | |
34 | + echo $user['email']; | |
35 | + | |
36 | + } | |
47 | 37 | |
48 | 38 | } |
39 | + | |
49 | 40 | } |
50 | 41 | |
51 | 42 | } |
52 | 43 | \ No newline at end of file | ... | ... |
src/lib/models/basket.php
... | ... | @@ -303,7 +303,7 @@ class basket extends \db |
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
306 | - * @param $user_id | |
306 | + * @param int $user_id | |
307 | 307 | */ |
308 | 308 | public function deleteBasket($user_id) { |
309 | 309 | |
... | ... | @@ -312,4 +312,21 @@ class basket extends \db |
312 | 312 | |
313 | 313 | } |
314 | 314 | |
315 | + /** | |
316 | + * @return array | |
317 | + */ | |
318 | + public function getAbandonedUsers() { | |
319 | + | |
320 | + return $this->get( | |
321 | + ' | |
322 | + SELECT user_id | |
323 | + FROM public.basket | |
324 | + WHERE | |
325 | + last_mod < CURRENT_TIMESTAMP + INTERVAL 1 DAY | |
326 | + ', | |
327 | + [], | |
328 | + -1 | |
329 | + ); | |
330 | + | |
331 | + } | |
315 | 332 | } |
316 | 333 | \ No newline at end of file | ... | ... |