Esempio n. 1
0
 /**
  * 房源推广变更日志生成 ppc_db.Hp_Pro_Change_Log_
  *
  * <ol>
  * <li>
  * 当房源日志type为房源推广(5)时,对应推广变更日志action=1
  * </li>
  * <li>
  * 当房源日志type为取消推广(6)时,对应推广变更日志action=2
  * </li>
  * <li>
  * 当房源日志type为第二天推广(7)时,对应推广变更日志action=2
  * </li>
  * <li>
  * 当房源日志type为取消推广(14)时,对应精选推广变更日志action=1
  * </li>
  * <li>
  * 当房源日志type为取消推广(15)时,对应精选推广变更日志action=2
  * </li>
  * <li>
  * 其他不处理
  * </li>
  * </ol>
  *
  * @param array $records 定价上下架房源日志数据(二手房)
  */
 public function proSpreadChangeLogCreateAjk($record)
 {
     if ($record['siteType'] != 1) {
         //记录处理日志
         $this->setLog('改网站类型的数据暂不处理(定价推广变更日志) ' . __METHOD__);
         return true;
     }
     $type = $record['type'];
     $date = date('Ymd', strtotime($record['addDate']));
     if ($type == 5) {
         $action = 1;
         $type = 1;
     } elseif ($type == 6) {
         $action = 2;
         $type = 1;
     } elseif ($type == 7) {
         $action = 2;
         $type = 1;
     } elseif ($type == 14) {
         $action = 1;
         $type = 2;
     } elseif ($type == 15) {
         $action = 2;
         $type = 2;
     } elseif ($type == 21) {
         $type = 3;
         $action = 2;
     } elseif ($type == 20) {
         $type = 3;
         $action = 1;
     } else {
         //记录处理日志
         $this->setLog('不需要生成推广变更日志');
         return true;
     }
     $dataObject = new Model_House_HpProChangeLog($date);
     //查询最近的日志
     $ChangeLogInfo = $dataObject->getChangeLogByProId($record['houseId'], $date, $type);
     $Time = 0;
     //展示时间
     if (!empty($ChangeLogInfo)) {
         switch ($ChangeLogInfo['Action']) {
             case 1:
                 //上一条为推广
                 if ($action == 1) {
                     //本次为推广
                     $Time = $ChangeLogInfo['Time'];
                 }
                 if ($action == 2) {
                     //本次为取消推广
                     $Time = $ChangeLogInfo['Time'] + time() - strtotime($ChangeLogInfo['LogTime']);
                 }
                 break;
             case 2:
                 //上一条为取消推广
                 if ($action == 1) {
                     //本次为推广
                     if (empty($ChangeLogInfo['Time'])) {
                         //上一条取消推广时间为0
                         $Time = strtotime($ChangeLogInfo['LogTime']) - strtotime(substr($ChangeLogInfo['LogTime'], 0, 10));
                     } else {
                         $Time = $ChangeLogInfo['Time'];
                     }
                 }
                 if ($action == 2) {
                     //本次为取消推广
                     $Time = $ChangeLogInfo['Time'];
                 }
                 break;
             default:
         }
     }
     $dataObject->ProId = $record['houseId'];
     $dataObject->BrokerId = $record['brokerId'];
     $dataObject->Time = $Time;
     $dataObject->Action = $action;
     $dataObject->Type = $type;
     $dataObject->LogTime = date('Y-m-d H:i:s');
     $dataObject->ActionId = 0;
     //触发动作id
     $dataObject->SpreadId = $record['planId'] ? $record['planId'] : 0;
     //计划id
     if (!$dataObject->save()) {
         //记录处理日志
         $this->setLog('推广变更日志生成失败');
     } else {
         //记录处理日志
         $this->setLog('推广变更日志生成成功');
     }
     //对接竞价房源日志老数据
     if ($type == 2) {
         if ($action == 1) {
             $remark = 'STATUS:11=>1';
             $bidAction = 1;
         } else {
             $remark = $record['changeType'] == 404 ? 'STATUS:1=>5' : 'STATUS:1=>3';
             $bidAction = 4;
         }
         Model_Plan_LogAjkPropspread::addNewLog($record['planId'] ? $record['planId'] : 0, $record['brokerId'], $bidAction, $remark, -10);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * 房源推广变更日志生成 ppc_db.Hp_Pro_Change_Log_
  *
  * <ol>
  * <li>
  * 当房源日志type为房源推广(5)时,对应推广变更日志action=1
  * </li>
  * <li>
  * 当房源日志type为取消推广(6)时,对应推广变更日志action=2
  * </li>
  * <li>
  * 其他不处理
  * </li>
  * </ol>
  *
  * @param $records 定价上下架房源日志数据
  */
 public function proSpreadChangeLogCreate($records)
 {
     foreach ($records as $row) {
         $type = $row->type;
         $id = $row->id;
         $date = date('Ymd', strtotime($row->addDate));
         if ($type == 5) {
             $action = 1;
         } elseif ($type == 6) {
             $action = 2;
         } else {
             $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "不需要生成推广变更日志");
             continue;
         }
         $dataObject = new Model_House_HpProChangeLog($date);
         $dataObject->ProId = $row->houseId;
         $dataObject->BrokerId = $row->brokerId;
         $dataObject->Time = 0;
         $dataObject->Action = $action;
         $dataObject->Type = 1;
         $dataObject->LogTime = time();
         if (!$dataObject->save()) {
             if (!$dataObject->save()) {
                 $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "推广变更日志生成失败");
             } else {
                 $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "推广变更日志生成成功");
             }
         } else {
             $this->addLogger('队列id' . $row->id . "房源" . $row->houseId . "推广变更日志生成成功");
         }
         unset($dataObject);
     }
 }