Exemplo n.º 1
0
 /**
  * @param $attr
  */
 private function translate($attr)
 {
     $ad = new AD();
     $types = $ad->get_all_labels(PDO::FETCH_KEY_PAIR);
     $attr['code'] = md5($attr['id'] . BAOBEI_SALT);
     $attr['quote_rmb'] = number_format($attr['quote_rmb'] / 100, 2);
     $attr['ad_type'] = $types[$attr['ad_type']];
     $attr['cate'] = ADModel::$CATE[$attr['cate']];
     $permissions = $ad->get_permissions(['ad_id' => $attr['id']]);
     $permissions = array_values($permissions);
     $attr['permissions'] = implode("\n<br>", $permissions);
     $attr['feedback'] = ADModel::$FEEDBACK[$attr['feedback']];
     $attr['ad_desc'] = preg_replace('/<span style="color: rgb\\(255, 0, 0\\);">(.*?)<\\/span>/', '', $attr['ad_desc']);
     // 过滤掉标红文字
     if (is_numeric($attr['channel'])) {
         $channel = new Channel();
         $attr['channel'] = $channel->get_channel(array('id' => $attr['channel']))[$attr['channel']];
     }
     if ($attr['agreement_id']) {
         $agreement = new Agreement();
         $agreements = $agreement->get_agreements_basic(['id' => $attr['agreement_id']]);
         $agreement = $agreements[$attr['agreement_id']];
         $attr['agreement'] = $agreement['company_short'] ? $agreement['company_short'] : $agreement['company'];
     }
     return $attr;
 }
Exemplo n.º 2
0
 private function get_ad_agreements(array $list)
 {
     $agreements = array();
     foreach ($list as $ad) {
         if ($ad['agreement_id']) {
             $agreements[] = $ad['agreement_id'];
         }
     }
     if ($agreements) {
         $service = new Agreement();
         $agreements = $service->get_agreements_basic(['id' => $agreements]);
         foreach ($list as $key => $ad) {
             if ($ad['agreement_id']) {
                 $list[$key]['agreement'] = $agreements[$ad['agreement_id']]['company_short'];
                 $list[$key]['company'] = $agreements[$ad['agreement_id']]['company'];
             }
         }
     }
     return $list;
 }