write() публичный статический Метод

实时写入日志信息 并支持行为
public static write ( mixed $msg, string $type = 'log', boolean $force = false ) : boolean
$msg mixed 调试信息
$type string 信息类型
$force boolean 是否强制写入
Результат boolean
Пример #1
0
 public function j_email()
 {
     // 如果
     if (isset($_POST['em'])) {
         $email = $_POST['em'];
         $account_model = D('Account');
         // 证明已经注册过
         if ($account_model->judge_account_id_isset($email)) {
             Response::show('-101', '该邮箱已经被注册!');
         } else {
             // 发送给用户的信息
             $rand_string = strtolower(rand_string());
             $title = '欢迎您注册!么么哒。';
             $content = '您好,您的注册验证码是 : ' . $rand_string . '   !, 如果不是本人操作,请忽略!';
             $Memcached = Memcached::getInstance();
             // 暂时不加密了。
             $Memcached->set($email, $rand_string);
             if (SendMail($email, $title, $content) === true) {
                 Response::show('200', '已经发送验证码,请注意查收!');
             } else {
                 Log::write('发送验证码失败,to [--' . $email . '--]', 'WARN');
                 Response::show('-102', '邮件发送失败,未知原因!');
             }
         }
     }
     Response::show('-103', '数据丢失!');
 }
Пример #2
0
 public function index()
 {
     if (!isset($_GET['code'])) {
         $redirect_uri = URL2;
         $scope = 'snsapi_base';
         $log = new Log();
         $log->write("order请求", 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y/m/d') . '.log');
         $this->oauth($redirect_uri, $scope);
         // $this->get_city();
     } else {
         $code = (string) $_GET['code'];
         $open_id = $this->get_oauth_openid($code);
         $log = new Log();
         $log->write("order微信回调", 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y/m/d') . '.log');
     }
     $user_model = M("User");
     $where = array('openid' => (string) $open_id);
     $user = $user_model->where($where)->find();
     $user_id = $user['id'];
     $orderlist = $this->get_user_order($user_id);
     /*
      * $msg = $this->get_endorsement (); print_r ( $msg );
      */
     $order_status = array(1 => '未支付', 2 => '确认中', 3 => '处理中', 5 => '已处理', 6 => '退款中', 7 => '已退款', 8 => '已取消');
     $this->assign('user_id', $user_id);
     $this->assign('order_status', $order_status);
     $this->assign('orderlist', $orderlist);
     $this->display(":order");
 }
Пример #3
0
 protected function _sock_post($url, $query)
 {
     $data = "";
     $info = parse_url($url);
     $fp = fsockopen($info["host"], 80, $errno, $errstr, 30);
     if (!$fp) {
         return $data;
     }
     $head = "POST " . $info['path'] . " HTTP/1.0\r\n";
     $head .= "Host: " . $info['host'] . "\r\n";
     $head .= "Referer: http://" . $info['host'] . $info['path'] . "\r\n";
     $head .= "Content-type: application/x-www-form-urlencoded\r\n";
     $head .= "Content-Length: " . strlen(trim($query)) . "\r\n";
     $head .= "\r\n";
     $head .= trim($query);
     $write = fputs($fp, $head);
     $header = "";
     while ($str = trim(fgets($fp, 4096))) {
         $header .= $str;
     }
     while (!feof($fp)) {
         $data .= fgets($fp, 4096);
     }
     $ret = json_decode($data, true);
     if (!$ret) {
         \Think\Log::write('无法解析短信接口返回值:' . $data);
         return false;
     }
     return $ret;
 }
Пример #4
0
 public function testWrite()
 {
     Log::init(['type' => 'test']);
     Log::clear();
     $this->assertTrue(Log::write('hello', 'info'));
     $this->assertTrue(Log::write([1, 2, 3], 'log'));
 }
Пример #5
0
 public function sendsms()
 {
     if (IS_POST) {
         $mac = md5($_POST['time'] . C('SMSKEY'));
         if ($mac != $_POST['mac']) {
             return false;
         }
         if (empty($_POST['content']) || empty($_POST['phone'])) {
             return false;
         }
         $path = C('LOG_PATH') . 'sms.txt';
         Log::write($_POST['phone'] . ':' . $_POST['content'], 'SMS-CONTENT', '', $path);
         $data = array('userid' => 416, 'account' => 'HY-jmzc', 'password' => 'Hj1234', 'mobile' => $_POST['phone'], 'content' => $_POST['content'], 'sendTime' => '', 'action' => 'send', 'checkcontent' => '0', 'taskName' => '', 'countnumber' => $_POST['count'], 'mobilenumber' => $_POST['count'], 'telephonenumber' => 0);
         // 短信发送
         $xml = curlPost($this->url, $data);
         Log::write($xml, 'SMS-CONTENT', '', $path);
         $res = simplexml_load_string($xml);
         $arr = json_decode(json_encode($res), true);
         if ($arr['returnstatus'] == 'Success') {
             echo true;
         } else {
             echo false;
         }
     }
 }
 public function NotifyProcess($data, &$msg)
 {
     Log::write(json_encode($data));
     //记录下支付信息
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性
     if (!$this->Queryorder($data["transaction_id"])) {
         $msg = "订单查询失败";
         return false;
     }
     $order = D('Order');
     $order_info = $order->getOne(array('order_id' => $data['out_trade_no'], 'phone' => $data['attach']));
     if ($order_info && $order_info['status'] == 0) {
         $order_info['status'] = 1;
         $result = $order->editData($order_info);
         if ($result == CommonModel::MSUCCESS) {
             $point = D('Pointlog');
             $point->log($order_info['user_id'], $order_info['point'], "订单" . $order_info['order_id'] . " 使用了" . $order_info['point'] . "积分", PointlogModel::DEC);
             $money = $order_info['total'] / 100;
             $addpiont = intval($money / C('DEVPOINT'));
             $point->log($order_info['user_id'], $addpiont, "订单" . $order_info['order_id'] . " 获得了" . $addpiont . "积分", PointlogModel::ADD);
         }
     }
     return true;
 }
 public function index($arr = array())
 {
     Log::write('开始调用ResponseUnknowMessageController@index并获得参数' . json_encode($arr));
     $fromusername = $arr['fromusername'];
     $tousername = $arr['tousername'];
     $content = '[Cry][Cry][Cry]暂时不支持处理您的消息类型';
     $this->sendTextMessage($fromusername, $tousername, $content);
 }
 public function index($arr = array())
 {
     Log::write('开始调用ResponseImageMessageController@index并获得参数' . json_encode($arr));
     $fromusername = $arr['fromusername'];
     $tousername = $arr['tousername'];
     $mediaid = $arr['mediaid'];
     $this->sendImageMessage($fromusername, $tousername, $mediaid);
 }
Пример #9
0
 public function buildRequestForm(\Org\Util\Pay\PayVo $vo)
 {
     $param = array('nonce_str' => (string) mt_rand(), 'spbill_create_ip' => get_client_ip(), 'device_info' => 'WEB', 'appid' => $this->config['appid'], 'mch_id' => $this->config['mch_id'], 'notify_url' => $this->config['notify_url'], 'out_trade_no' => $vo->getOrderNo(), 'body' => $vo->getTitle(), 'detail' => $vo->getBody(), 'total_fee' => $vo->getFee(), 'trade_type' => $vo->getType(), 'product_id' => $vo->getId(), 'openid' => $vo->getOpenid());
     \Think\Log::write("11111" . $this->config['notify_url']);
     $param['sign'] = $this->signatureArithmetic($param);
     $param = $this->xml_encode($param);
     $order = $this->fsockOpen($this->gateway, 0, $param);
     return (array) simplexml_load_string($order, 'SimpleXMLElement', LIBXML_NOCDATA);
 }
 public function setForeverImageSource()
 {
     $access_token = $this->getAccessToken();
     $path = "/var/www/v.vxndy.com/Public/images/shasha.jpg";
     $vars = array('media' => '@' . $path);
     $url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=" . $access_token;
     $result = postCURL($url, $vars);
     Log::write('新增永久素材返回信息:' . $result);
 }
 public function createMenu()
 {
     Log::write("开始创建自定义菜单");
     $access_token = $this->getAccessToken();
     $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token;
     $vars = C('MENU_ONE');
     $result = postCURL($url, $vars);
     Log::write("创建自定义菜单返回消息:" . $result);
 }
 public function getForverQrcodeTicket()
 {
     $token = $this->getAccessToken();
     $scene_id = mt_rand(0, 100000);
     $vars = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": ' . $scene_id . '}}}';
     Log::write('获得永久二维码ticket需要的参数:' . $vars);
     $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $token;
     $result = postCURL($url, $vars);
     Log::write('获得永久二维码返回ticket返回值:' . $result);
     return json_decode($result, TRUE);
 }
Пример #13
0
 /**
  * 获取Access Token
  * @return null | string
  */
 private function _fetchAccessToken()
 {
     $Curl = new Curl();
     $params['grant_type'] = 'client_credential';
     $params['appid'] = get_opinion('Weixin_appid');
     $params['secret'] = get_opinion('Weixin_secret');
     $accessToken = $Curl->callApi($this::$AccessTokenURL, $params, 'GET');
     if (!isset($accessToken['access_token'])) {
         Log::write("Error occurred when call AccessToken Api");
         return null;
     }
     return $accessToken['access_token'];
 }
Пример #14
0
 public function sendWeiXin($touser, $template_id, $url, $data, $topcolor = '#7B68EE')
 {
     $log = new Log();
     $template = array('touser' => $touser, 'template_id' => $template_id, 'url' => $url, 'topcolor' => $topcolor, 'data' => $data);
     $json_template = json_encode($template);
     $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $this->get_access_token();
     $dataRes = $this->request_post($url, urldecode($json_template));
     $log->write(serialize($dataRes), 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y_m_d') . '.log');
     if ($dataRes['errcode'] == 0) {
         return true;
     } else {
         return false;
     }
 }
Пример #15
0
 /**
  * log overwrite
  * @see Wechat::log()
  */
 protected function log($log)
 {
     if ($this->debug) {
         if (function_exists($this->logcallback)) {
             if (is_array($log)) {
                 $log = print_r($log, true);
             }
             return call_user_func($this->logcallback, $log);
         } elseif (class_exists('\\Think\\Log')) {
             \Think\Log::write('wechat:' . $log, \Think\Log::DEBUG);
         }
     }
     return false;
 }
 public function run(&$params)
 {
     // 锁定自动执行
     $lockfile = RUNTIME_PATH . 'cron.lock';
     if (is_writable($lockfile) && filemtime($lockfile) > $_SERVER['REQUEST_TIME'] - C('CRON_MAX_TIME', null, 60)) {
         return;
     } else {
         touch($lockfile);
     }
     set_time_limit(1000);
     ignore_user_abort(true);
     // 载入cron配置文件
     // 格式 return array(
     // 'cronname'=>array('filename',intervals,nextruntime),...
     // );
     if (is_file(RUNTIME_PATH . '~crons.php')) {
         $crons = (include RUNTIME_PATH . '~crons.php');
     } elseif (is_file(COMMON_PATH . 'Conf/crons.php')) {
         $crons = (include COMMON_PATH . 'Conf/crons.php');
     }
     if (isset($crons) && is_array($crons)) {
         $update = false;
         $log = array();
         foreach ($crons as $key => $cron) {
             if (empty($cron[2]) || $_SERVER['REQUEST_TIME'] >= $cron[2]) {
                 // 到达时间 执行cron文件
                 G('cronStart');
                 include COMMON_PATH . 'Cron/' . $cron[0] . '.php';
                 G('cronEnd');
                 $_useTime = G('cronStart', 'cronEnd', 6);
                 // 更新cron记录
                 $cron[2] = $_SERVER['REQUEST_TIME'] + $cron[1];
                 $crons[$key] = $cron;
                 $log[] = "Cron:{$key} Runat " . date('Y-m-d H:i:s') . " Use {$_useTime} s\n";
                 $update = true;
             }
         }
         if ($update) {
             // 记录Cron执行日志
             \Think\Log::write(implode('', $log) . 'Cronrun  CC56');
             // 更新cron文件
             $content = "<?php\nreturn " . var_export($crons, true) . ";\n?>";
             file_put_contents(RUNTIME_PATH . '~crons.php', $content);
         }
     }
     // 解除锁定
     unlink($lockfile);
     return;
 }
 public function excel()
 {
     $_scenedata = M('scenedata');
     $_scenedatadetail = M('scenedatadetail');
     $where['sceneid_bigint'] = I('get.id', 0);
     $where['userid_int'] = intval(session('userid'));
     $_scene_list = $_scenedata->where($where)->order('dataid_bigint asc')->select();
     $wheredetail['sceneid_bigint'] = I('get.id', 0);
     $_scenedatadetail_list = $_scenedatadetail->where($wheredetail)->order('detailid_bigint desc')->select();
     $_scene_count = $_scenedatadetail->where($wheredetail)->count();
     $jsonstr = ',,,,,,,,,,,,' . utf2gb('技术支持 By 一秀') . ',' . "\n";
     $jsonstr .= ',total:' . $_scene_count . ',,,,,,,,,,,,' . "\n";
     $jsonstrtemp = '';
     $listkey = '';
     foreach ($_scene_list as $vo) {
         //$data .=  utf2gb('姓名').','.utf2gb('性别') ;
         $jsonstrtemp = $jsonstrtemp . utf2gb($vo["elementtitle_varchar"]) . ',';
         //''.json_encode($vo["elementtitle_varchar"]).',';
         $listkey = $listkey . $vo["elementid_int"] . ',';
     }
     $listkey = explode(',', rtrim($listkey, ','));
     $jsonstr = $jsonstr . $jsonstrtemp . utf2gb('提交时间') . "\n";
     $jsonstrtemp = '';
     foreach ($_scenedatadetail_list as $vo2) {
         $tempjson = json_decode($vo2["content_varchar"], true);
         $jsonstrtemp = $jsonstrtemp;
         foreach ($listkey as $vo3) {
             $jsonstrtemp = $jsonstrtemp . utf2gb($tempjson['eq']['f_' . $vo3]) . ',';
         }
         $jsonstrtemp = $jsonstrtemp . $vo2['createtime_time'] . "\n";
     }
     $jsonstr = $jsonstr . $jsonstrtemp;
     \Think\Log::write('excel' . $jsonstr);
     $filename = '我的场景数据-' . date('YmdHis') . ".csv";
     //文件名
     header("Content-type:text/csv");
     header("Content-Disposition:attachment;filename=" . $filename);
     header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
     header('Expires:0');
     header('Pragma:public');
     exit($jsonstr);
 }
Пример #18
0
 public function invest($id)
 {
     $data = $this->find($id);
     $uid = M('UsersDetail')->where(array('phone' => $data['phone']))->getField('id');
     if ($uid) {
         $invest = M('ProjectInvestor')->where(array('project_id' => $data['pid'], 'investor_id' => $uid, 'status' => array('egt', 0)))->find();
         if ($invest) {
             $this->error = '该用户已在聚募投资该项目';
             return false;
         }
         $invest = array('investor_id' => $uid, 'project_id' => $data['pid'], 'fund' => $data['fund'], 'step' => 4, 'status' => 9, 'pay_way' => 0, 'bak' => $data['from_way']);
         D('ProjectInvestor')->invest($invest);
     } else {
         $api = new UserApi();
         $ret = $api->register($data['phone'], substr($data['cardid'], -6), $data['phone']);
         if ($ret < 0) {
             Log::write('用户注册失败:(' . $ret . ')');
             $this->error = '新用户注册失败,请联系管理员';
             return false;
         } else {
             $uid = $ret;
         }
         $Member = M('Users');
         $temp = array('id' => $uid, 'nickname' => $data['phone'], 'status' => 1, 'photo_url' => '/Public/Home/images/default_face/' . rand(1, 14) . '.jpg', 'reg_ip' => get_client_ip(1), 'create_time' => NOW_TIME, 'reg_time' => NOW_TIME);
         $temp = $Member->create($temp);
         $ret = $Member->add($temp);
         $detail = array('id' => $uid, 'phone' => $data['phone'], 'name' => $data['real_name'], 'card_id' => $data['cardid'], 'create_time' => NOW_TIME, 'update_time' => NOW_TIME);
         M('UsersDetail')->add($detail);
         $auth = array('uid' => $uid, 'auth_id' => 0, 'status' => 9);
         M('UserAuth')->add($auth);
         $auth['auth_id'] = 1;
         M('UserAuth')->add($auth);
         $invest = array('investor_id' => $uid, 'project_id' => $data['pid'], 'fund' => $data['fund'], 'step' => 4, 'status' => 9, 'pay_way' => '0', 'bak' => $data['from_way']);
         D('ProjectInvestor')->invest($invest);
     }
     $this->save(array('id' => $id, 'uid' => $uid, 'state' => 1));
     return true;
 }
Пример #19
0
 public function index()
 {
     if (!isset($_GET['code'])) {
         $redirect_uri = URL1;
         $scope = 'snsapi_base';
         $log = new Log();
         $log->write("sub请求", 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y/m/d') . '.log');
         $this->oauth($redirect_uri, $scope);
     } else {
         $code = (string) $_GET['code'];
         $open_id = $this->get_oauth_openid($code);
         $log = new Log();
         $log->write("sub微信回调", 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y/m/d') . '.log');
     }
     $user_model = M("User");
     $where = array('openid' => (string) $open_id);
     $user = $user_model->where($where)->find();
     $user_id = $user['id'];
     $carlist = $this->get_user_car($user_id);
     $this->assign('versions', versions);
     $this->assign('user_id', $user_id);
     $this->assign('carlist', $carlist);
     $this->display(":index");
 }
Пример #20
0
    /**
     * 图文 - 先调用self::newsItem()再调用本方法
     * @param $fromusername
     * @param $tousername
     * @param $item 数组,每个项由self::newsItem()返回
     * @param int|\Weixin\Util\默认为0 $funcFlag 默认为0,设为1时星标刚才收到的消息
     * @return string
     */
    public function news($fromusername, $tousername, $item, $funcFlag = 0)
    {
        //多条图文消息信息,默认第一个item为大图,注意,如果图文数超过10,则将会无响应
        if (count($item) >= 10) {
            $request = array('fromusername' => $fromusername, 'tousername' => $tousername);
            //return Msg::returnErrMsg(MsgConstant::ERROR_NEWS_ITEM_COUNT_MORE_TEN, '图文消息的项数不能超过10条', $request);
            Log::write("图文消息的项数不能超过10条");
        }
        $template = <<<XML
<xml>
    <ToUserName><![CDATA[%s]]></ToUserName>
    <FromUserName><![CDATA[%s]]></FromUserName>
    <CreateTime>%s</CreateTime>
    <MsgType><![CDATA[news]]></MsgType>
    <ArticleCount>%s</ArticleCount>
    <Articles>
    %s
    </Articles>
    <FuncFlag>%s</FuncFlag>
</xml>
XML;
        return sprintf($template, $fromusername, $tousername, time(), count($item), implode($item), $funcFlag);
    }
Пример #21
0
 public function notify()
 {
     $order_sn = $_REQUEST['out_trade_no'];
     $log = new Log();
     $log->write(json_encode($_REQUEST));
     $order_model = M("Order");
     $order = $order_model->where("order_sn='{$order_sn}'")->find();
     if ($order['order_status'] != 1) {
         return true;
     }
     // 修改订单状态
     $data = array("order_status" => 2, "last_time" => time(), "pay_type" => 2, "pay_sn" => $_REQUEST['transaction_id']);
     $order_model->where("order_sn='{$order_sn}'")->save($data);
     $order = $order_model->where("order_sn='{$order_sn}'")->find();
     $data = array("order_id" => $order['id'], "sod_id" => $order['so_id'], "state" => '0', "c_time" => time(), "l_time" => time());
     $to_model = M("Turn_order");
     $to_model->add($data);
     $services_model = M("services");
     $services_info = $services_model->where("id='{$order['services_id']}'")->find();
     if (!empty($services_info)) {
         $data = array("all_nums" => $services_info['all_nums'] + 1);
         $services_model->where("id='{$order['services_id']}'")->save();
     }
     // 修改违章状态
     $data = array("is_manage" => 1, "manage_time" => time());
     $endorsement_model = M("Endorsement");
     $endorsement_model->where("id={$order['endorsement_id']}")->save($data);
     $log_model = M("Endorsement_log");
     $data = array("end_id" => $order['endorsement_id'], "state" => 2, "c_time" => time(), "type" => 1);
     $log_model->add($data);
     // 使用优惠券
     if ($order['ucoupon_id'] > 0) {
         $data = array("is_used" => 1, "use_time" => time());
         $uc_model = M("User_coupon");
         $uc_model->where("id={$order['ucoupon_id']}")->save($data);
     }
     return true;
 }
Пример #22
0
 public function unionpay()
 {
     $data = json_encode($_POST);
     Log::write($data);
 }
Пример #23
0
 function find_fuwu($car_id, $code, $money, $points, $area, $exclude_list = null)
 {
     $log = new Log();
     $fuwu = array();
     $region_model = M("Region");
     $where = array("city" => $area, "level" => 2, "is_dredge" => 0);
     $region = $region_model->where($where)->order('id')->find();
     if (empty($region)) {
         $city_id1 = 0;
     } else {
         $city_id1 = $region['id'];
     }
     $where = array("id" => $car_id);
     $car_model = M("Car");
     $car = $car_model->where($where)->find();
     $a_class = array("京", "沪", "津", "渝");
     $l_nums = "";
     $l_nums_a = mb_substr($car['license_number'], 0, 1, 'utf-8');
     if (in_array($l_nums_a, $a_class)) {
         $l_nums = $l_nums_a;
     } else {
         $l_nums = mb_substr($car['license_number'], 0, 2, 'utf-8');
     }
     $region_model = M("Region");
     $region = $region_model->where("nums = '{$l_nums}'")->find();
     $region = $region_model->where("city = '{$region['city']}'")->order("id")->find();
     if (empty($region)) {
         $city_id2 = 0;
     } else {
         $city_id2 = $region['id'];
     }
     $violation_model = M("violation");
     $violation = $violation_model->field("money, points")->where("code = '{$code}'")->find();
     if (empty($violation) || $violation['state'] == 1) {
         return $fuwu;
     }
     $where = "";
     if (!empty($exclude_list)) {
         $where = "srv.id not in (" . implode(",", $exclude_list) . ") and ";
     }
     $s_code = substr($code, 0, 4);
     $so_model = M('');
     // 1.a
     $so_sql = "select srv.id as services_id, so.id as so_id, so.money from cw_services as srv, cw_services_city as scity, cw_services_code as scode, cw_services_order as so where {$where} srv.id = scity.services_id and srv.id = scode.services_id and srv.id = so.services_id and srv.state = 0 and srv.grade > 4 and ((scity.code = {$city_id1} and scity.state = 0) or (scity.code = {$city_id2} and scity.state = 0)) and ((scode.code = '{$code}' or scode.code = '{$s_code}') and scode.state = 0 ) and so.violation = '{$code}' and (so.code = {$city_id1} or so.code = {$city_id2})group by srv.id order by money asc ";
     $log->write($so_sql);
     $solist = $so_model->query($so_sql);
     $sd_model = M('');
     // 1.b
     $sd_sql = "select * from (select dyna.services_id, dyna.id as so_id, ({$money} + dyna.fee + dyna.point_fee * {$points}) dyna_fee from cw_services as srv, cw_services_city as scity, cw_services_code as scode, cw_services_dyna as dyna where   {$where} srv.id = scity.services_id and srv.id = scode.services_id and srv.id = dyna.services_id and srv.state = 0 and srv.grade > 4 and ((scity.code = {$city_id1} and scity.state = 0) or (scity.code = {$city_id2} and scity.state = 0)) and (scode.code = '{$code}' or scode.code = '{$s_code}') and scode.state = 0 and (dyna.code = {$city_id1} or dyna.code = {$city_id2}) ORDER BY dyna_fee ASC) as service_dyna group by services_id order by dyna_fee asc";
     $log->write($sd_sql);
     $sdlist = $sd_model->query($sd_sql);
     // we now get the lowest price
     $lowest_price = -1;
     $so_id = -1;
     $so_type = -1;
     if (!empty($solist)) {
         $lowest_price = $solist[0]['money'];
         $so_id = $solist[0]['so_id'];
         $so_type = 1;
     }
     if (!empty($sdlist)) {
         if ($lowest_price > -1) {
             if ($lowest_price > $sdlist[0]['dyna_fee']) {
                 $lowest_price = $sdlist[0]['dyna_fee'];
                 $so_id = $sdlist[0]['so_id'];
                 $so_type = 2;
             }
         } else {
             $lowest_price = $sdlist[0]['dyna_fee'];
             $so_id = $sdlist[0]['so_id'];
             $so_type = 2;
         }
     }
     //$log->write ( "lowest_price=". $lowest_price );
     if ($lowest_price == -1) {
         return $fuwu;
     }
     $where = "";
     $firstCondition = false;
     $services_id_by_money = array();
     if (!empty($solist)) {
         foreach ($solist as $p => $c) {
             if ($c['money'] == $lowest_price) {
                 if ($firstCondition == false) {
                     $where .= " services_id = {$c['services_id']}";
                     $firstCondition = true;
                 } else {
                     $where .= " or services_id = {$c['services_id']}";
                 }
                 $services_id_by_money[] = $c['services_id'];
             } else {
                 break;
             }
         }
     }
     if (!empty($sdlist)) {
         foreach ($sdlist as $p => $c) {
             if ($c['dyna_fee'] == $lowest_price) {
                 if ($firstCondition == false) {
                     $where .= " services_id = '{$c['services_id']}'";
                     $firstCondition = true;
                 } else {
                     $where .= " or services_id = '{$c['services_id']}'";
                 }
                 $services_id_by_money[] = $c['services_id'];
             } else {
                 break;
             }
         }
     }
     $order_model = M('');
     // 2
     $sql = "SELECT COUNT(*) as nums, `services_id` FROM `cw_order` WHERE {$where} GROUP BY `services_id` ORDER BY nums";
     //$log->write ( $sql);
     $orderlist = $order_model->query($sql);
     $services_id_by_ordernum = array();
     foreach ($orderlist as $p => $c) {
         $services_id_by_ordernum[] = $c['services_id'];
     }
     $services = array_diff($services_id_by_money, $services_id_by_ordernum);
     if (!empty($services)) {
         foreach ($services as $r) {
             $services_id = $r;
             break;
         }
     } else {
         $services_id = $orderlist[0]['services_id'];
     }
     //$log->write ( "services_id=". $services_id );
     // 3
     $fuwu['s_id'] = $services_id;
     $fuwu['so_id'] = $so_id;
     $fuwu['so_type'] = $so_type;
     $fuwu['so_money'] = $lowest_price;
     return $fuwu;
 }
<?php

use Think\Log;
$message = "欢迎光临本站,现在时间是:" . date('Y-m-d H:i:s', time() . "--定时任务demo");
Log::write($message);
echo $message;
die;
Пример #25
0
 public function notify()
 {
     $order_sn = $_REQUEST['out_trade_no'];
     $log = new Log();
     $log->write(json_encode($_REQUEST));
     $order_model = M("Order");
     $order = $order_model->where("order_sn='{$order_sn}'")->find();
     if ($order['order_status'] != 1) {
         return true;
     }
     // 修改订单状态
     $data = array("order_status" => 2, "last_time" => time(), "pay_type" => 2, "pay_sn" => $_REQUEST['transaction_id']);
     $order_model->where("order_sn='{$order_sn}'")->save($data);
     $order = $order_model->where("order_sn='{$order_sn}'")->find();
     $data = array("order_id" => $order['id'], "services_id" => $order['services_id'], "sod_id" => $order['so_id'], "so_type" => $order['so_type'], "money" => $order['money'], "state" => '0', "c_time" => time(), "l_time" => time());
     $to_model = M("Turn_order");
     $to_model->add($data);
     // 修改违章状态
     $data = array("is_manage" => 1, "manage_time" => time());
     $endorsement_model = M("Endorsement");
     $endorsement_model->where("id={$order['endorsement_id']}")->save($data);
     $log_model = M("Endorsement_log");
     $data = array("end_id" => $order['endorsement_id'], "state" => 2, "c_time" => time(), "type" => 1);
     $log_model->add($data);
     // 使用优惠券
     if ($order['ucoupon_id'] > 0) {
         $data = array("is_used" => 1, "use_time" => time());
         $uc_model = M("User_coupon");
         $uc_model->where("id={$order['ucoupon_id']}")->save($data);
     }
     $services_model = M("services");
     $services_info = $services_model->where("id='{$order['services_id']}'")->find();
     if (!empty($services_info)) {
         $data = array("all_nums" => $services_info['all_nums'] + 1);
         $services_model->where("id='{$order['services_id']}'")->save($data);
     }
     /*
     // 服务商收入
     $s_model = M ( "bank" );
     $s_info = $s_model->where ( "bank_id = '{$order['services_id']}'" )->find ();
     if (! empty ( $s_info )) {
     	$data = array (
     			"money" => $s_info ['money'] + $order ['money'],
     			"end_money" => $s_info ['end_money'] + $order ['money']
     	);
     	$re = $s_model->where ( "id='{$s_info['id']}'" )->save ( $data );
     } else {
     	$data = array (
     			"bank_id" => $order ['services_id'],
     			"name" => 0,
     			"user_bank" => 0,
     			"user_number" => 0,
     			"money" => $order ['money'],
     			"end_money" => $order ['money'],
     			"user_money" => 0,
     			"create_time" => time ()
     	);
     	$s_model->add ( $data );
     }
     */
     /* start 增加新订单提醒推送*/
     $turn_order_model = M('turn_order');
     $t_info = $turn_order_model->field('tos.c_time')->table("cw_turn_order as tos")->join("cw_order as o on o.id=tos.order_id", 'left')->join("cw_services as s on s.id=o.services_id", 'left')->where("o.order_sn='{$order_sn}'")->find();
     $order_sn_to = $order_sn . substr($t_info['c_time'], -2) . $order['services_id'];
     $content = sprintf(content4, $order_sn_to);
     $title = title4;
     $tz_content = sprintf(content4, $order_sn_to);
     $model_mes = M("message");
     $info = $model_mes->where("content = '{$content}'")->find();
     if (empty($info)) {
         $this->pushMessageToSingle($content, $title, $tz_content, $services_info['phone']);
         //插入消息表
         $this->add_message($services_info['id'], 3, 4, '', $content);
     }
     /* end */
     /*
     // 记录
     $data = array (
     		"services_id" => $s_info ['bank_id'],
     		"income_money" => $order ['money'],
     		"pay_money" => 0,
     		"end_money" => $s_info ['end_money'] + $order ['money'],
     		"user_money" => $s_info ['user_money'],
     		"money" => $s_info ['money'] + $order ['money'],
     		"order_id" => $order ['id'],
     		"c_time" => time () 
     );
     $jl_model = M ( "services_jilu" );
     $jl_model->add ( $data );
     */
     return true;
 }
Пример #26
0
 /**
  * 远程抓取
  * @param $uri
  * @param $config
  */
 public function getRemoteImage2($uri, $config)
 {
     //忽略抓取时间限制
     set_time_limit(0);
     //ue_separate_ue  ue用于传递数据分割符号
     $imgUrls = explode("ue_separate_ue", $uri);
     $tmpNames = array();
     foreach ($imgUrls as $imgUrl) {
         //http开头验证
         if (strpos($imgUrl, "http") !== 0) {
             array_push($tmpNames, "https error");
             continue;
         }
         //sae环境 不兼容
         if (!defined('SAE_TMP_PATH')) {
             //获取请求头
             $heads = get_headers($imgUrl);
             //死链检测
             if (!(stristr($heads[0], "200") && stristr($heads[0], "OK"))) {
                 array_push($tmpNames, "get_headers error");
                 continue;
             }
         }
         //格式验证(扩展名验证和Content-Type验证)
         $fileType = strtolower(strrchr($imgUrl, '.'));
         if (!in_array($fileType, $config['allowFiles']) || stristr($heads['Content-Type'], "image")) {
             array_push($tmpNames, "Content-Type error");
             continue;
         }
         //打开输出缓冲区并获取远程图片
         ob_start();
         $context = stream_context_create(array('http' => array('follow_location' => false)));
         //请确保php.ini中的fopen wrappers已经激活
         readfile($imgUrl, false, $context);
         $img = ob_get_contents();
         ob_end_clean();
         //大小验证
         $uriSize = strlen($img);
         //得到图片大小
         $allowSize = 1024 * $config['maxSize'];
         if ($uriSize > $allowSize) {
             array_push($tmpNames, "maxSize error");
             continue;
         }
         $savePath = $config['savePath'];
         if (!defined('SAE_TMP_PATH')) {
             //非SAE
             //创建保存位置
             if (!file_exists($savePath)) {
                 mkdir($savePath, 0777, true);
             }
             //写入文件
             $tmpName = $savePath . rand(1, 10000) . time() . strrchr($imgUrl, '.');
             try {
                 File::writeFile($tmpName, $img, "a");
                 array_push($tmpNames, __ROOT__ . '/' . $tmpName);
             } catch (\Exception $e) {
                 array_push($tmpNames, "error");
             }
         } else {
             //SAE
             $Storage = new \SaeStorage();
             $domain = get_opinion('SaeStorage');
             $destFileName = 'remote/' . date('Y') . '/' . date('m') . '/' . rand(1, 10000) . time() . strrchr($imgUrl, '.');
             $result = $Storage->write($domain, $destFileName, $img, -1);
             Log::write('$destFileName:' . $destFileName);
             if ($result) {
                 array_push($tmpNames, $result);
             } else {
                 array_push($tmpNames, "not supported");
             }
         }
     }
     /**
      * 返回数据格式
      * {
      *   'url'   : '新地址一ue_separate_ue新地址二ue_separate_ue新地址三',
      *   'srcUrl': '原始地址一ue_separate_ue原始地址二ue_separate_ue原始地址三',
      *   'tip'   : '状态提示'
      * }
      */
     //save file info here
     $return_data['url'] = implode("ue_separate_ue", $tmpNames);
     $return_data['tip'] = '远程图片抓取成功!';
     $return_data['srcUrl'] = $uri;
     $this->ajaxReturn($return_data);
     //      echo "{'url':'" . implode("ue_separate_ue", $tmpNames) . "','tip':'远程图片抓取成功!','srcUrl':'" . $uri . "'}";
 }
Пример #27
0
 /**
  * 关注事件
  */
 function eventSubscribe()
 {
     /** @var WeChat $wx */
     $wx = $this->weChat;
     $FromUserName = $wx->getRevFrom();
     $CreateTime = $wx->getRevCtime();
     $str = "EventSubscribe:FromUserName:{$FromUserName},CreateTime:{$CreateTime}";
     Log::write("-------{$str}", Log::ERR);
     $wx->text("关注:{$str}")->reply();
 }
Пример #28
0
 public function myout($contract_id, $club_id)
 {
     $contract = M("Contract")->find($contract_id);
     $card = M("Card")->find($contract['card_id']);
     $card["check_status"] = 0;
     $card["last_check_out_time"] = date('Y-m-d H:i:s');
     M("Card")->data($card)->save();
     //record list
     M("CheckHistory")->data(array("brand_id" => $contract["brand_id"], "member_id" => $card["member_id"], "status" => 0, "club_id" => $club_id, "card_id" => $card['id'], "contract_id" => $contract["id"]))->add();
     //清理柜子
     M("Lock")->where(array("club_id" => $club_id, "last_use_card" => $card['card_number']))->setField(array("is_use" => 0));
     M("LockUseHistory")->data(array("card_id" => "0", "lock_id" => $value, "status" => 0, "via" => 1, "create_time" => getDbTime()))->add;
     $lock = M("Lock")->where(array("club_id" => $club_id, "last_use_card" => $card['card_number']))->find();
     if (!empty($lock)) {
         \Think\Log::write("free lock by checkout " . $lock['locknum'], 'DEBUG');
     }
     return true;
 }
Пример #29
0
 public function logDebug($message)
 {
     Log::write($message, 'DEBUG');
     Log::save();
 }
 /**
  * 商家修改
  *
  * @return [type] [description]
  */
 public function modMerchantV2()
 {
     $style = isset($_POST['style']) ? htmlspecialchars(trim($_POST['style'])) : '0';
     //为了web能修改资料
     $mer_session_id = isset($_POST['mer_session_id']) ? htmlspecialchars(trim($_POST['mer_session_id'])) : '';
     if ($style == 0) {
         $merchant_id = $this->session_handle->getsession_userid($mer_session_id);
     } else {
         $mobile = isset($_POST['moblie']) ? htmlspecialchars($_POST['moblie']) : '';
         //根据 手机号 session_id 验证是否能编辑商户
         $ver = M('Verifycode')->where(array('mobile' => $mobile, 'session_id' => $mer_session_id))->getField('expire');
         if ($ver >= time()) {
             $merchant_id = $this->dao->where(array('mobile' => $mobile))->getField('id');
         } else {
             $this->jsonUtils->echo_json_msg(4, '注册后半小时,无法在编辑资料');
             exit;
         }
     }
     $wifi_enable = isset($_POST['wifi_enable']) ? htmlspecialchars(trim($_POST['wifi_enable'])) : '0';
     $tel = isset($_POST['tel']) ? htmlspecialchars(trim($_POST['tel'])) : '';
     $area_id = isset($_POST['area_id']) ? htmlspecialchars(trim($_POST['area_id'])) : '';
     $device = isset($_POST['device']) ? htmlspecialchars(trim($_POST['device'])) : '';
     $intro = isset($_POST['intro']) ? htmlspecialchars(trim($_POST['intro'])) : '';
     $address = isset($_POST['address']) ? htmlspecialchars(trim($_POST['address'])) : '';
     $business_time = isset($_POST['business_time']) ? htmlspecialchars(trim($_POST['business_time'])) : '';
     $pics = isset($_POST['pics']) ? trim($_POST['pics']) : '';
     if (!empty($tel)) {
         $data['tel'] = $tel;
     }
     if (!empty($intro)) {
         $data['intro'] = $intro;
     }
     if (!empty($address)) {
         $data['address'] = $address;
     }
     if (!empty($business_time)) {
         $data['business_time'] = $business_time;
     }
     if (isset($wifi_enable)) {
         $data['wifi_enable'] = $wifi_enable;
     }
     if (!empty($area_id) && $device == 'web') {
         $area = CityController::getAreaIdPreId($area_id);
         $data['province_id'] = $area['province'];
         $data['city_id'] = $area['city'];
         $data['area_id'] = $area_id;
     }
     Log::write($pics, 'ERR');
     if (!empty($pics)) {
         $arr_decode = json_decode($pics, true);
         if (!empty($arr_decode)) {
             foreach ($arr_decode as $key => $row) {
                 if (!empty($row)) {
                     $temp[$key]['hs'] = str_replace(C('ROOT_UPLOADS'), '', $row['hs']);
                     $temp[$key]['hb'] = str_replace(C('ROOT_UPLOADS'), '', $row['hb']);
                 }
             }
             foreach ($temp as $row) {
                 $data['pics'][] = $row;
             }
         } else {
             $data['pics'] = array();
         }
     } else {
         $data['pics'] = array();
     }
     if ($_FILES) {
         $f_arr = mul_upload('/Merchant/', 1);
         if ($f_arr) {
             $data['pics'] = array_merge($data['pics'], $f_arr);
             // 把多张图片数组格式转json保存数据库
         }
     }
     $data['pics'] = json_encode($data['pics']);
     $result = $this->dao->where("id={$merchant_id}")->save($data);
     $this->jsonUtils->echo_json_msg(0, '修改成功!');
     exit;
 }