/**
  * 获取经纪人返现记录
  *
  * @param int $cityId
  * @param int $brokerId
  * @return array
  */
 public static function getBrokerChoiceConsumeCashBackLog($cityId, $brokerId)
 {
     $cacheKey = sprintf('ajk_broker_choice_consume_cash_back_log_%d_%d', $cityId, $brokerId);
     $memcache = APF_Cache_Factory::get_instance()->get_memcache();
     $brokerConsumeCashBackLog = $memcache->get($cacheKey);
     if (is_array($brokerConsumeCashBackLog) && !empty($brokerConsumeCashBackLog)) {
         return $brokerConsumeCashBackLog;
     }
     $brokerConsumeCashBackLog = Model_Choice_AjkBrokerChoiceConsumeCashBackLog::getBrokerChoiceConsumeCashBackLog($cityId, $brokerId);
     $memcache->set($cacheKey, $brokerConsumeCashBackLog, 0, 1800);
     return $brokerConsumeCashBackLog;
 }
 /**
  * 写返现日志和返现队列
  *
  * @param int $cityId
  * @param int $brokerId
  * @param int $amount
  * @param string $note
  * @param int $cashBackType
  * @return bool
  */
 private function doCashBack($cityId, $brokerId, $amount, $note, $cashBackType)
 {
     $cashBackLog = array('cityId' => $cityId, 'brokerId' => $brokerId, 'amount' => $amount, 'remark' => $note, 'createTime' => date('Y-m-d H:i:s'));
     $effectRowCount = Model_Choice_AjkBrokerChoiceConsumeCashBackLog::create($cashBackLog)->save();
     if ($effectRowCount != 1) {
         $this->logMsg(sprintf('保存经纪人返现日志失败 %s', json_encode($cashBackLog)));
         return false;
     }
     $this->logMsg(sprintf('保存经纪人返现日志成功 %s', json_encode($cashBackLog)));
     /** 写返现队列开始 */
     $cashBackTypeId = intval($this->getCashBackTypeId($cashBackType, $this->_calculateDate));
     if ($cashBackTypeId == 0) {
         $this->logMsg(sprintf('获取经纪人返现队列类型ID失败, actType=%d typeDate=%d', $cashBackType, $this->_calculateDate));
         return false;
     }
     /** 获取经纪人返现队列中是否已经存在 */
     $cashBackQueue = Model_Broker_AjkPppccoinQueen::getBrokerQueue($brokerId, $cashBackTypeId, true);
     if (!empty($cashBackQueue)) {
         $this->logMsg(sprintf('经纪人[%d] 返现[%d] 队列已经存在 %s', $brokerId, $amount, json_encode($cashBackQueue)));
         return false;
     }
     $cashBackQueueData = array('typeid' => $cashBackTypeId, 'brokerid' => $brokerId, 'accounttype' => 1, 'amount' => $amount, 'remark' => $note, 'addtime' => time(), 'cityid' => $cityId);
     try {
         if (1 != Model_Broker_AjkPppccoinQueen::create($cashBackQueueData)->save()) {
             $this->logMsg(sprintf('经纪人[%d] 返现[%d] 写返现队列失败 %s', $brokerId, $amount, json_encode($cashBackQueueData)));
             return false;
         }
     } catch (Exception $e) {
         $this->logMsg(sprintf('经纪人[%d] 返现[%d] 写返现队列失败 %s', $brokerId, $amount, json_encode($cashBackQueueData)));
         $this->logMsg(sprintf('经纪人[%d] 返现[%d] 写返现队列异常 %s', $brokerId, $amount, $e->getMessage()));
         return false;
     }
     return true;
 }