Blame view

src/lib/models/spyEvent.php 1.37 KB
ef60cd4d   Administrator   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <?php
  use Phalcon\Mvc\Model;
  
  class SpyEvent extends \Phalcon\Mvc\Model
  {
      public function getSource()
      {
          return "spy_event";
      }
  
  
      public function spyTimeAfter($project,$customer_id){
          return  self::query()
              ->columns(['customer_id', 'st.id, st.item_id', 'st.item_name', 'st.item_image', 'st.quantity', 'st.price', 'st.item_url', 'st.item_image'])
              ->rightJoin('spyStore', 'st.spy_event_id = SpyEvent.id', 'st')
              ->where("project_id = :project_id:")
              ->andWhere("action ='order_add'")
              ->andWhere("customer_id =$customer_id")
              ->bind(array("project_id" => $project->id))
              ->execute();
  
      }
  
2dfdc329   Administrator   change request to...
24
25
      public function getSpyUsers($modelsManager, $project)
      {
ef60cd4d   Administrator   first commit
26
27
  
          $now = date("Y-m-d H:i:s");
ef60cd4d   Administrator   first commit
28
  
2dfdc329   Administrator   change request to...
29
30
31
32
33
34
35
36
37
38
39
          $date1 = new DateTime($now);
          $date1->modify('-3 hours');
          $date1 = $date1->format('Y-m-d H:i:s');
  
          $date2 = new DateTime($now);
          $date2->modify('-11 hours');
          $date2 = $date2->format('Y-m-d H:i:s');
  
          $phql = "SELECT DISTINCT (customer_id) as id FROM SpyEvent WHERE project_id = {$project->id} AND action = 'order_add' AND date <=  '{$date1}' OR date <=  '{$date2}'";
          //äîáàâèòü êîä íèæå äëÿ ïðîâåðêè âðåìåíè
          // AND action = 'order_add' AND date <=  '{$date}'
ef60cd4d   Administrator   first commit
40
41
42
43
44
  
          return $modelsManager->executeQuery($phql)->toArray();
  
      }
  }