Ejemplo n.º 1
0
function send_data($val = 0, $device_id = 343089, $sensor_id = 380664, $isnotify = true)
{
    global $key;
    $url = 'http://api.yeelink.net/v1.1/device/' . $device_id . '/sensor/' . $sensor_id . '/datapoints';
    $query = json_encode(array('timestamp' => date('Y-m-d H:i:s', time()), 'value' => $val));
    if ($isnotify == true) {
        file_put_contents('/shell/data.log', $query . "\n", FILE_APPEND);
    }
    $options = array('http' => array('header' => "Content-Type: application/x-www-form-urlencoded\r\n" . "U-ApiKey: {$key}\r\n" . "Content-Length: " . strlen($query) . "\r\n" . "User-Agent:MyAgent/1.0\r\n", 'method' => 'POST', 'content' => $query));
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    if ($isnotify == true) {
        sleep(5);
        send_notify($val);
    }
    return $result;
}
 public function save_repay()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!$GLOBALS['user_info']) {
         showErr("", $ajax, url("user#login"));
     }
     $order_id = intval($_REQUEST['id']);
     $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id . " and order_status = 3 and is_refund = 0");
     if (!$order_info) {
         showErr("无权为该订单设置回报", $ajax);
     }
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $order_info['deal_id'] . " and is_delete = 0 and is_effect = 1 and is_success = 1 and user_id = " . intval($GLOBALS['user_info']['id']));
     if (!$deal_info) {
         showErr("无权为该订单设置回报", $ajax);
     }
     $order_info['repay_time'] = NOW_TIME;
     $order_info['repay_memo'] = strim($_REQUEST['repay_memo']);
     if ($order_info['repay_memo'] == "") {
         showErr("请输入回报内容", $ajax);
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info, "UPDATE", "id=" . $order_info['id']);
     send_notify($order_info['user_id'], "您支持的项目" . $order_info['deal_name'] . "回报已发放", "account#view_order", "id=" . $order_info['id']);
     showSuccess("回报设置成功", $ajax);
 }
Ejemplo n.º 3
0
        $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $deal_id);
        //一次性生成50条
        $deal_notify_items = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_deal_notify where deal_id = " . $deal_id . " order by create_time asc limit 50");
        $ids = array(0);
        foreach ($deal_notify_items as $k => $v) {
            $ids[] = $v['id'];
        }
        $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_deal_notify where id in (" . implode(",", $ids) . ")");
        if ($GLOBALS['db']->affected_rows() == count($deal_notify_items)) {
            $deal_count = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_deal_notify where deal_id = " . $deal_id));
            if ($deal_count == 0) {
                $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_notify where deal_id = " . $deal_id);
            }
            //开始发送通知
            foreach ($deal_notify_items as $k => $v) {
                send_notify($v['user_id'], $deal_info['name'] . " 在 " . to_date($deal_info['success_time']) . " 成功筹到 " . format_price($deal_info['limit_price']), "deal#show", "id=" . $deal_info['id']);
            }
        }
        header("Content-Type:text/html; charset=utf-8");
        echo 1;
    } else {
        header("Content-Type:text/html; charset=utf-8");
        echo 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) {
        $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_msg_list where is_send = 0 order by id asc limit 1");