Example #1
0
 function checkUncertainNotifyAction()
 {
     $tblTrans = new DB_Udo_TransNotify();
     //ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
     set_time_limit(0);
     // 通过set_time_limit(0)可以让程序无限制的执行下去
     $interval = 5;
     // 每隔半小时运行
     $isSolid = Common_Config::NOTIFY_UNCERTAIN;
     $now = time();
     $diff = 60 * 60;
     //do{
     $result = $tblTrans->fetchAll("uid,transNo,createTime", "where isSolid = {$isSolid} and ({$now}-createTime)< {$diff}");
     //$result = $tblTrans->scalar("*","where isSolid = {$isSolid} and ({$now}-createTime)< {$diff}");
     //这里是你要执行的代码
     //sleep($interval);// 等待5分钟
     //}while(true);
 }
Example #2
0
 function checkUncertainNotify()
 {
     $tblTrans = new DB_Udo_TransNotify();
     $messageModel = new MessageModel();
     //ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
     set_time_limit(0);
     // 通过set_time_limit(0)可以让程序无限制的执行下去
     $interval = 5;
     // 每隔半小时运行
     $isSolid = Common_Config::NOTIFY_UNCERTAIN;
     $now = time();
     $diff = 60 * 60;
     do {
         //查询是否存在限时内未确认的交易状态
         $result = $tblTrans->fetchAll("uid,transNo,createTime", "where isSolid = {$isSolid} and ({$now}-createTime)<= {$diff}");
         if ($result) {
             $userArray = [];
             foreach ($result as $k => $value) {
                 $notify = $this->getOrderResult($value['uid'], $value['transNo']);
                 //如果存在状态改变的,就将接收消息的用户列表中插入一条数据
                 if ($notify != Common_Error::ERROR_TRANS_UNKNOWN) {
                     array_push($userArray, $value['uid']);
                 }
             }
             //如果有接收用户,那么发送消息
             if ($userArray) {
                 $type = 1;
                 $custom_data = "";
                 $title = "支付状态确认";
                 $text = "您有一笔订单的交易状态已经确认";
                 $messageModel->sendMessage($type, $custom_data, $userArray, $custom_data, $title, $text);
             }
         } else {
             $result = $tblTrans->fetchAll("id,uid,transNo,createTime", "where isSolid = {$isSolid} and ({$now}-createTime)> {$diff}");
             $userArray = [];
             foreach ($result as $k => $value) {
                 array_push($userArray, $value['id']);
                 $notifySolid = Common_Config::NOTIFY_SOLID;
                 //$update = $tblTrans->update("{$value['id']}",array("transNo = {$notifySolid}"));
                 $update = $tblTrans->query("update udo_trans_notify set isSolid = {$notifySolid} where id = {$value['id']}");
             }
             //如果有接收用户,那么发送消息
             if ($userArray) {
                 $type = 1;
                 $custom_data = "";
                 $title = "支付状态确认";
                 $text = "您有一笔订单的交易已经关闭";
                 $messageModel->sendMessage($type, $custom_data, $userArray, $custom_data, $title, $text);
             }
         }
         //$result = $tblTrans->scalar("*","where isSolid = {$isSolid} and ({$now}-createTime)< {$diff}");
         //这里是你要执行的代码
         //sleep($interval);// 等待5分钟
     } while (true);
 }