public function pay()
 {
     $id = intval($_REQUEST['id']);
     $res = pay_referrals($id);
     if ($res) {
         save_log("ID:" . $id . l("REFERRALS_PAY_SUCCESS"), 1);
         $this->success(l("REFERRALS_PAY_SUCCESS"));
     } else {
         save_log("ID:" . $id . l("REFERRALS_PAY_FAILED"), 0);
         $this->error(l("REFERRALS_PAY_FAILED"));
     }
 }
Exemplo n.º 2
0
 public function deal_msg_list()
 {
     set_time_limit(0);
     $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 1 where name = 'DEAL_MSG_LOCK' and `value` = 0");
     $rs = $GLOBALS['db']->affected_rows();
     if ($rs) {
         //业务队列中处理返利发放
         $rid = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "referrals where " . NOW_TIME . "-create_time > " . intval(app_conf('REFERRALS_DELAY')) * 60 . " and pay_time = 0");
         if ($rid) {
             pay_referrals(intval($rid));
         }
         $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_msg_list where is_send = 0 order by id asc limit 1");
         if ($msg_item) {
             //优先改变发送状态,不论有没有发送成功
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_msg_list set is_send = 1,send_time='" . NOW_TIME . "' where id =" . intval($msg_item['id']));
             if ($msg_item['send_type'] == 0) {
                 //短信
                 require_once APP_ROOT_PATH . "system/utils/es_sms.php";
                 $sms = new sms_sender();
                 $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
                 //发送结束,更新当前消息状态
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_msg_list set is_success = " . intval($result['status']) . ",result='" . $result['msg'] . "' where id =" . intval($msg_item['id']));
             }
             if ($msg_item['send_type'] == 1) {
                 //邮件
                 require_once APP_ROOT_PATH . "system/utils/es_mail.php";
                 $mail = new mail_sender();
                 $mail->AddAddress($msg_item['dest']);
                 $mail->IsHTML($msg_item['is_html']);
                 // 设置邮件格式为 HTML
                 $mail->Subject = $msg_item['title'];
                 // 标题
                 $mail->Body = $msg_item['content'];
                 // 内容
                 $is_success = $mail->Send();
                 $result = $mail->ErrorInfo;
                 //发送结束,更新当前消息状态
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_msg_list set is_success = " . intval($is_success) . ",result='" . $result . "' where id =" . intval($msg_item['id']));
             }
         }
         $count = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_msg_list where is_send = 0"));
         if ($count == 0) {
             $count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "referrals where pay_time = 0");
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 0 where name = 'DEAL_MSG_LOCK'");
     } else {
         $count = 0;
     }
     $data['count'] = $count;
     ajax_return($data, true);
 }
Exemplo n.º 3
0
 function foreach_pay($page = 1)
 {
     $log_begin_time = trim($_REQUEST['log_begin_time']) == '' ? 0 : to_timespan($_REQUEST['log_begin_time']);
     $log_end_time = trim($_REQUEST['log_end_time']) == '' ? 0 : to_timespan($_REQUEST['log_end_time']);
     $condtion = " AND (r.pay_time is null OR r.pay_time = 0) ";
     if ($log_begin_time > 0 && $log_end_time == 0) {
         $condtion .= " and r.repay_time > {$log_begin_time} ";
     } elseif ($log_begin_time == 0 && $log_end_time > 0) {
         $condtion .= " and r.repay_time < {$log_begin_time} ";
     } elseif ($log_begin_time > 0 && $log_end_time > 0) {
         $condtion .= " and (r.repay_time between {$log_begin_time} and {$log_end_time} )";
     }
     $sql_count = "SELECT count(r.id) FROM " . DB_PREFIX . "referrals r WHERE 1=1 {$condtion} ";
     $count = $GLOBALS['db']->getOne($sql_count);
     if (!empty($_REQUEST['listRows'])) {
         $listRows = $_REQUEST['listRows'];
     } else {
         $listRows = '';
     }
     $p = new Page($count, $listRows);
     if ($count > 0) {
         $sql = "SELECT r.id FROM " . DB_PREFIX . "referrals r WHERE 1=1 {$condtion} ORDER BY r.id DESC LIMIT " . ($p->firstRow . ',' . $p->listRows);
         $list = $GLOBALS['db']->getAll($sql);
         foreach ($list as $k => $v) {
             if ($v['pay_time'] == 0) {
                 $res = pay_referrals($v['id']);
                 if ($res) {
                     save_log("ID:" . $v['id'] . l("REFERRALS_PAY_SUCCESS"), 1);
                 } else {
                     save_log("ID:" . $v['id'] . l("REFERRALS_PAY_FAILED"), 0);
                 }
             }
         }
     }
     if ($p->nowPage >= $p->totalPages) {
         $this->success(l("REFERRALS_PAY_SUCCESS"));
     } else {
         register_shutdown_function(array(&$this, 'foreach_pay'), $page + 1);
     }
 }
Exemplo n.º 4
0
 function foreach_pay($page = 1)
 {
     $log_begin_time = trim($_REQUEST['log_begin_time']) == '' ? 0 : to_timespan($_REQUEST['log_begin_time']);
     $log_end_time = trim($_REQUEST['log_end_time']) == '' ? 0 : to_timespan($_REQUEST['log_end_time']);
     if ($log_end_time == 0) {
         $condtion = " and dlr.repay_time > {$log_begin_time} ";
     } else {
         $condtion = " and (dlr.repay_time between {$log_begin_time} and {$log_end_time} )";
     }
     $sql_count = "SELECT count(dlr.id) FROM " . DB_PREFIX . "deal_load_repay dlr LEFT JOIN " . DB_PREFIX . "user u on u.id = dlr.user_id LEFT JOIN " . DB_PREFIX . "referrals r ON r.rel_user_id= dlr.user_id WHERE u.pid >0 and dlr.has_repay=1 {$condtion} ";
     $count = $GLOBALS['db']->getOne($sql_count);
     if (!empty($_REQUEST['listRows'])) {
         $listRows = $_REQUEST['listRows'];
     } else {
         $listRows = '';
     }
     $p = new Page($count, $listRows);
     if ($count > 0) {
         $sql = "SELECT dlr.*,(dlr.l_key + 1)  as l_key,(dlr.repay_money - dlr.self_money) as lixi,((dlr.repay_money - dlr.self_money) * u.referral_rate * 0.01 ) as smoney,u.referral_rate,u.id as rel_user_id,u.pid as user_id,r.pay_time FROM " . DB_PREFIX . "deal_load_repay dlr LEFT JOIN " . DB_PREFIX . "user u on u.id = dlr.user_id LEFT JOIN " . DB_PREFIX . "referrals r ON r.rel_user_id= dlr.user_id and r.deal_id=dlr.deal_id and r.load_id=dlr.load_id and r.l_key = dlr.l_key WHERE u.pid >0 and dlr.has_repay=1  and (r.id is null or r.id >0) {$condtion} LIMIT " . ($p->firstRow . ',' . $p->listRows);
         $list = $GLOBALS['db']->getAll($sql);
         foreach ($list as $k => $v) {
             if ($v['pay_time'] == 0) {
                 $res = pay_referrals($v['id']);
                 if ($res) {
                     save_log("ID:" . $v['id'] . l("REFERRALS_PAY_SUCCESS"), 1);
                 } else {
                     save_log("ID:" . $v['id'] . l("REFERRALS_PAY_FAILED"), 0);
                 }
             }
         }
     }
     if ($p->nowPage >= $p->totalPages) {
         $this->success(l("REFERRALS_PAY_SUCCESS"));
     } else {
         register_shutdown_function(array(&$this, 'foreach_pay'), $page + 1);
     }
 }
Exemplo n.º 5
0
// | Author: 云淡风轻(88522820@qq.com)
// +----------------------------------------------------------------------
//用于队列的发送
require './system/common.php';
require './app/Lib/common.php';
es_session::close();
set_time_limit(0);
if ($_REQUEST['act'] == 'deal_msg_list') {
    //业务队列的群发
    $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 1 where name = 'DEAL_MSG_LOCK' and `value` = 0");
    $rs = $GLOBALS['db']->affected_rows();
    if ($rs) {
        //业务队列中处理返利发放
        $rid = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "referrals where " . get_gmtime() . "-create_time > " . intval(app_conf('REFERRALS_DELAY')) * 60 . " and pay_time = 0");
        if ($rid) {
            pay_referrals(intval($rid));
        }
        $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_msg_list where is_send = 0 order by id asc limit 1");
        if ($msg_item) {
            //优先改变发送状态,不论有没有发送成功
            $GLOBALS['db']->query("update " . DB_PREFIX . "deal_msg_list set is_send = 1,send_time='" . get_gmtime() . "' where id =" . intval($msg_item['id']));
            if ($msg_item['send_type'] == 0) {
                //短信
                require_once APP_ROOT_PATH . "system/utils/es_sms.php";
                $sms = new sms_sender();
                $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
                //发送结束,更新当前消息状态
                $GLOBALS['db']->query("update " . DB_PREFIX . "deal_msg_list set is_success = " . intval($result['status']) . ",result='" . $result['msg'] . "' where id =" . intval($msg_item['id']));
            }
            if ($msg_item['send_type'] == 1) {
                //邮件