示例#1
0
 protected function parse_filter(array $filters = null, array $options = array())
 {
     $defaults = ['to_string' => true];
     $options = array_merge($defaults, $options);
     if (isset($filters['start'])) {
         $filters['stat_date'][] = array('operator' => '>=', 'data' => $filters['start']);
         unset($filters['start']);
     }
     if (isset($filters['end'])) {
         $filters['stat_date'][] = array('operator' => '<=', 'data' => $filters['end']);
         unset($filters['end']);
     }
     $spec = array('date');
     $pick = Utils::array_pick($filters, $spec);
     $filters = Utils::array_omit($filters, $spec);
     list($conditions, $params) = parent::parse_filter($filters, ['to_string' => false]);
     foreach ($pick as $key => $value) {
         switch ($key) {
             case 'date':
                 $conditions[] = "DATE(`stat_date`)=:date";
                 $params[':date'] = $value;
                 break;
         }
     }
     $conditions = $options['to_string'] ? ($options['is_append'] ? ' and ' : '') . implode(' AND ', $conditions) : $options;
     return array($conditions, $params);
 }
示例#2
0
 protected function parse_filter(array $filters = null, array $options = array())
 {
     if (isset($filters['start'])) {
         $filters['transfer_date'][] = array('operator' => '>=', 'data' => $filters['start']);
         unset($filters['start']);
     }
     if (isset($filters['end'])) {
         $filters['transfer_date'][] = array('operator' => '<=', 'data' => $filters['end']);
         unset($filters['end']);
     }
     if (isset($filters['date'])) {
         $filters['transfer_date'] = $filters['date'];
         unset($filters['date']);
     }
     return parent::parse_filter($filters, $options);
 }
示例#3
0
 protected function parse_filter(array $filters = null, array $options = array())
 {
     $defaults = ['to_string' => true];
     $options = array_merge($defaults, $options);
     if (isset($filters['salesman'])) {
         $filters['applicant'] = $filters['salesman'];
         unset($filters['salesman']);
     }
     if (isset($filters['start'])) {
         $filters['apply_time'][] = array('operator' => '>=', 'data' => $filters['start']);
         unset($filters['start']);
     }
     if (isset($filters['end'])) {
         $filters['apply_time'][] = array('operator' => '<=', 'data' => $filters['end']);
         unset($filters['end']);
     }
     if (isset($filters['pass_status'])) {
         $filters['a.status'][] = array('operator' => '>=', 'data' => $filters['pass_status']);
         unset($filters['pass_status']);
     }
     $spec = array('keyword');
     $pick = Utils::array_pick($filters, $spec);
     $filters = Utils::array_omit($filters, $spec);
     list($conditions, $params) = parent::parse_filter($filters, array('to_string' => false));
     foreach ($pick as $key => $value) {
         switch ($key) {
             case 'keyword':
                 if ($value) {
                     $conditions[] = "(`express_number` LIKE :keyword OR `full_name` LIKE :keyword OR `company` LIKE :keyword)";
                     $params[':keyword'] = "%{$value}%";
                 }
                 break;
         }
     }
     $conditions = $options['to_string'] ? ($options['is_append'] ? ' and ' : '') . implode(' AND ', $conditions) : $options;
     return array($conditions, $params);
 }
示例#4
0
 protected function parse_admin_filter(array $filters = null, array $options = array())
 {
     $defaults = ['to_string' => true];
     $options = array_merge($defaults, $options);
     $spec = array('keyword', 'salesman', 'channel', 'follow');
     if (isset($filters['ad_name'])) {
         $filters['a.ad_name'] = $filters['ad_name'];
         unset($filters['ad_name']);
     }
     if (isset($filters['start'])) {
         $filters['create_time'][] = array('operator' => '>=', 'data' => $filters['start']);
         unset($filters['start']);
     }
     if (isset($filters['end'])) {
         $filters['create_time'][] = array('operator' => '<=', 'data' => $filters['start']);
         unset($filters['end']);
     }
     if (isset($filters['owner'])) {
         $filters['b.owner'] = $filters['owner'];
         unset($filters['owner']);
     }
     $pick = Utils::array_pick($filters, $spec);
     $filters = Utils::array_omit($filters, $spec);
     list($conditions, $params) = parent::parse_filter($filters, array('to_string' => false));
     foreach ($pick as $key => $value) {
         switch ($key) {
             case 'keyword':
                 $conditions[] = " (a.`ad_name` LIKE :keyword OR ifnull(h.company_short,ifnull(c.alias,b.channel)) LIKE :keyword)";
                 $params[':keyword'] = '%' . $value . '%';
                 break;
             case 'salesman':
                 $conditions[] = " (b.`owner`=:salesman OR `execute_owner`=:salesman)";
                 $params[':salesman'] = $value;
                 break;
             case 'channel':
                 $conditions[] = " ifnull(h.company_short,ifnull(c.alias,b.channel))=:channel";
                 $params[':channel'] = $value;
                 break;
             case 'follow':
                 $conditions[] = ' b.owner!=execute_owner';
                 break;
         }
     }
     $conditions = $options['to_string'] ? ($options['is_append'] ? ' and ' : '') . implode(' AND ', $conditions) : $options;
     return array($conditions, $params);
 }
示例#5
0
 /**
  * @param array $filters
  * @param array $options
  *
  * @return array
  */
 protected function parse_filter(array $filters = null, array $options = array())
 {
     $defaults = ['to_string' => true];
     $options = array_merge($defaults, $options);
     $spec = array('keyword', 'today');
     $pick = Utils::array_pick($filters, $spec);
     $filters = Utils::array_omit($filters, $spec);
     list($conditions, $params) = parent::parse_filter($filters, array('to_string' => false));
     foreach ($pick as $key => $value) {
         switch ($key) {
             case 'keyword':
                 if ($value) {
                     $conditions[] = "(`company` LIKE :keyword OR `company_short` LIKE :keyword OR a.`agreement_id` LIKE\n            :keyword)";
                     $params[':keyword'] = '%' . $value . '%';
                 }
                 break;
             case 'today':
                 $value = date('Y-m-d', strtotime($value) - 86400 * 60);
                 $conditions[] = '(`doc_date`>=:protection_begin OR c.`status`=' . ADModel::ONLINE . '
         OR (c.`status`=' . ADModel::OFFLINE . ' AND `status_time`>=:protection_begin))';
                 $params[':protection_begin'] = $value;
                 break;
         }
     }
     $conditions = $options['to_string'] ? ($options['is_append'] ? ' and ' : '') . implode(' AND ', $conditions) : $conditions;
     return array($conditions, $params);
 }
示例#6
0
 /**
  * @param array $filters
  * @param array $options
  *
  * @return array
  */
 protected function parse_filter(array $filters = null, array $options = array())
 {
     $defaults = ['to_string' => true];
     $options = array_merge($defaults, $options);
     $spec = array('keyword', 'salesman');
     $pick = Utils::array_pick($filters, $spec);
     $filters = Utils::array_omit($filters, $spec);
     list($conditions, $params) = parent::parse_filter($filters, array('to_string' => false));
     foreach ($pick as $key => $value) {
         switch ($key) {
             case 'keyword':
                 if ($value) {
                     $conditions[] = "(`alias` LIKE :keyword OR `full_name` LIKE :keyword)";
                     $params[':keyword'] = "%{$value}%";
                 }
                 break;
             case 'salesman':
                 if ($value) {
                     $conditions[] = "(b.`owner`=:salesman OR b.`execute_owner`=:salesman)";
                     $params[':salesman'] = $value;
                 }
                 break;
         }
     }
     $conditions = $options['to_string'] ? ($options['is_append'] ? ' and ' : '') . implode(' AND ', $conditions) : $options;
     return array($conditions, $params);
 }