function sendToAddress($address, $amount)
{
    try {
        $amount = round($amount, 8);
        $bitcoin = new jsonRPCClient(kBitcoinURL);
        $txid = $bitcoin->sendtoaddress($address, floatval($amount));
        $log = new MessageLog('log', 255);
        $log->write("mywallet-bitcoin:{$address} BTC:{$amount} txid:{$txid}");
        return $txid;
    } catch (Exception $e) {
        return "Error: " . $e->getMessage();
    }
}
 private function messageLog($postObj)
 {
     $message = new MessageLog();
     $message->openid = $postObj->FromUserName;
     $message->createtime = intval($postObj->CreateTime);
     $message->msgtype = $postObj->MsgType;
     $message->msgid = $postObj->MsgId;
     $message->content = isset($postObj->Content) ? $postObj->Content : '';
     $message->picurl = isset($postObj->PicUrl) ? $postObj->PicUrl : '';
     $message->mediaid = isset($postObj->MediaId) ? $postObj->MediaId : '';
     $message->format = isset($postObj->Format) ? $postObj->Format : '';
     $message->recognition = isset($postObj->Recognition) ? $postObj->Recognition : '';
     $message->thumbmediaid = isset($postObj->ThumbMediaId) ? $postObj->ThumbMediaId : '';
     $message->location_x = floatval(isset($postObj->Location_X) ? $postObj->Location_X : null);
     $message->location_y = floatval(isset($postObj->Location_Y) ? $postObj->Location_Y : null);
     $message->scale = floatval(isset($postObj->Scale) ? $postObj->Scale : null);
     $message->lable = isset($postObj->Label) ? $postObj->Label : '';
     $message->title = isset($postObj->Title) ? $postObj->Title : '';
     $message->description = isset($postObj->Description) ? $postObj->Description : '';
     $message->url = isset($postObj->Url) ? $postObj->Url : '';
     if (!$message->save()) {
         Yii::trace(CVarDumper::dumpAsString($message->errors), 'save message_log error');
     }
 }
示例#3
0
 public static function readAll($senderID)
 {
     if ($senderID == 0) {
         //使当前登录用户所有的系统消息与通知为已读
         //将一对一的系统通知置为已读
         Message::model()->updateAll(array('status' => 1, 'utime' => time()), 'senderID=0 and RecID=:RecId and type=1 and status=0', array(':RecId' => Yii::app()->user->id));
         //将全局系统消息置为已读
         $messages = Message::model()->findAll('senderID=0 and RecID=0 and type=2 and (expireTime > :time or expireTime=0) and status=0 and not exists(select mid from messageLog where mid=t.id and uid=:uid)', array(':time' => time(), ':uid' => Yii::app()->user->id));
         $sql = '';
         foreach ($messages as $message) {
             $sql .= 'insert into messageLog values(' . $message->id . ',' . Yii::app()->user->id . ',' . time() . ') ON DUPLICATE KEY UPDATE ctime=' . time() . ';';
         }
         if ($sql) {
             MessageLog::model()->dbConnection->createCommand($sql)->execute();
         }
     } else {
         //使用当前用户与此人的私聊全部为已读,自己发送的消息不需要置为已读
         Message::model()->updateAll(array('status' => 1, 'utime' => time()), 'senderID=:senderId and RecID=:RecId and type=0 and status=0', array(':senderId' => $senderID, ':RecId' => Yii::app()->user->id));
     }
 }