登录
  • 欢迎访问薛敬官方网站!每天分享技术和创业干货,与大家共同学习共同进步!!! QQ群
  • Git主题现已支持滚动公告栏功能,兼容其他浏览器,看到的就是咯,在后台最新消息那里用li标签添加即可。
  • 最新版xuejing主题已支持说说碎语功能,可像添加文章一样直接添加说说,新建说说页面即可,最后重新保存固定连接,演示地址
  • 百度口碑求点赞啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊http://koubei.baidu.com/s/googlo.xj
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏薛敬官网吧
  • 薛敬的淘宝店铺已经开张了哦,传送门:http://shop1111111.taobao.com

php微信公众号物联网开发

php admin 445次浏览 0个评论 扫描二维码
<?php
//$dd_noa=$_GET[“dd_no”];//订单号
session_start();
$dd_noa=$_SESSION[“order_number”];
//echo $dd_noa;
include “../inc/conn.php”;
$query=”select * from t_order where order_number=’$dd_noa'”;
$result=mysql_query($query);
$info=mysql_fetch_array($result);
$ret_fee=$info[“ret_fee”];//合计金额
$start_time=$info[“starttime”];//开始时间
$newstart_time=date(“YmdHis”,strtotime($start_time));
$newend_time=date(“YmdHis”,strtotime(“+600”,strtotime($start_time)));
$duration=$info[“duration”];//预计时长
$rbChargeMode=$info[“rbChargeMode”];//计费方式
$dd_content=”『”.$info[“CabinetLabel”].”』柜&nbsp;”.$info[“box_no”].”号箱”;//订单内容
?>
<?php
/**
*
* example目录下为简单的支付样例,仅能用于搭建快速体验微信支付使用
* 薛敬自主研发,版权所有
*
**/
require_once “wx_pay/WxPay.Api.php”;
require_once “wx_pay/WxPay.JsApiPay.php”;
require_once “wx_pay/WxPay.Config.php”;
require_once ‘wx_pay/log.php’;
//初始化日志
$logHandler= new CLogFileHandler(“wx_logs/”.date(‘Y-m-d’).’.log’);
$log = Log::Init($logHandler, 15);
//打印输出数组信息
function printf_info($data)
{
    foreach($data as $key=>$value){
        echo “<font color=’#00ff55;’>$key</font> :  “.htmlspecialchars($value, ENT_QUOTES).” <br/>”;
    }
}
//①、获取用户openid
try{
    $tools = new JsApiPay();
    $openId = $tools->GetOpenid();
    //②、统一下单
    $input = new WxPayUnifiedOrder();
    $input->SetBody($dd_content);
    $input->SetAttach(“test”);
    $input->SetOut_trade_no($dd_noa);
    $input->SetTotal_fee($ret_fee*100);
    $input->SetTime_start($newstart_time);
    $input->SetTime_expire($newend_time);
    //$input->SetTime_start(date(“YmdHis”));
    //$input->SetTime_expire(date(“YmdHis”, time() + 600));
    $input->SetGoods_tag(“test”);
    $input->SetNotify_url(“http://www.xuejing.org/mobile/notify.php”);
    $input->SetTrade_type(“JSAPI”);
    $input->SetOpenid($openId);
    $config = new WxPayConfig();
    $order = WxPayApi::unifiedOrder($config, $input);
    //echo ‘<font color=”#f00″><b>统一下单支付单信息</b></font><br/>’;
    printf_info($order);
    $jsApiParameters = $tools->GetJsApiParameters($order);
    //获取共享收货地址js函数参数
    $editAddress = $tools->GetEditAddressParameters();
} catch(Exception $e) {
    Log::ERROR(json_encode($e));
}
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
/**
 * 注意:
 * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
 * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
 * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
 */
?>
<html>
<head>
    <meta charset=”UTF-8″>
  <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
  <meta http-equiv=”X-UA-Compatible” content=”ie=edge”>
    <title>星星寄存-支付台</title>
    <script type=”text/javascript”>
    //调用微信JS api 支付
    /*function jsApiCall()
    {
        WeixinJSBridge.invoke(
            ‘getBrandWCPayRequest’,
            <?php //echo $jsApiParameters; ?>,
            function(res){
                WeixinJSBridge.log(res.err_msg);
                alert(res.err_code+res.err_desc+res.err_msg);
            }
        );
    }
    */
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
        ‘getBrandWCPayRequest’,
        <?php echo $jsApiParameters; ?>,
   function(res){
       //WeixinJSBridge.log(res.err_msg);
    var msg = res.err_msg;
    if (msg == “get_brand_wcpay_request:ok”)
    {
        //alert(“支付成功,跳转到订单详情页”);
<?php
session_start();
$dd_noa=$_SESSION[“order_number”];
$openid=$_SESSION[“openid”];
//echo $dd_noa;
include “../inc/conn.php”;
$query=”select * from t_order where order_number=’$dd_noa'”;
$result=mysql_query($query);
$info=mysql_fetch_array($result);
$ret_fee=$info[“ret_fee”];//合计金额
$start_time=$info[“starttime”];//开始时间
$duration=$info[“duration”];//预计
$rbChargeMode=$info[“rbChargeMode”];//
$cabinet_bs=$info[“CabinetLabel”];
$box_no=$info[“box_no”];
$dd_content=”『”.$info[“CabinetLabel”].”』柜”.$info[“box_no”].”号箱”;//
$open_box_time=date(“Y-m-d G:i:s”);//开箱时间
?>
<?php
$queryg=”select * from t_cabinet_list where txtCabinetLabel=’$cabinet_bs'”;
$resultg=mysql_query($queryg);
$infog=mysql_fetch_array($resultg);
$pub_address=$infog[“pub_address”];
?>
<?php
$sql1=”update t_order SET status=1 where order_number=’$dd_noa'”;
mysql_query($sql1);
 $sql2=”insert into box_recode(openid,  cab_flg,box_no,open_box_time,dd_no)values(‘$openid’,’$cabinet_bs’,’$box_no’,’$open_box_time’,’$dd_noa’)”;
mysql_query($sql2);
$sql3=”update t_box_list SET box_status=1 where box_no=’$box_no’ and cabinet_bs=’$cabinet_bs'”;
mysql_query($sql3);
?>
<?php
$s1=”select * from t_box_list where box_guige=3 and box_status=0 and cabinet_bs=’$cabinet_bs'”;
$r1=mysql_query($s1);
$bigbox_num=mysql_num_rows($r1);//
$s2=”select * from t_box_list where box_guige=2 and box_status=0 and cabinet_bs=’$cabinet_bs'”;
$r2=mysql_query($s2);
$midbox_num=mysql_num_rows($r2);//
$s3=”select * from t_box_list where box_guige=1 and box_status=0 and cabinet_bs=’$cabinet_bs'”;
$r3=mysql_query($s3);
$smallbox_num=mysql_num_rows($r3);//
require(“../phpMQTT.php”);
  $mseg=”;
  $mytopic=”;
  $flg=0;
  $host = “47.90.100.99”; //主机
  $port = 1883; //端口
  $username = “WeChatLockerHost”; //如果没有则为空
  $password = “”; //如果没有则为空
  $message = “Hello12345”; //要发送的消息
  $ClientID=’WeChatLockerHost’;
  $sub_host_Reg=’wechatlocker/server1/reg’;
  $sub_host_Run=’wechatlocker/server1/Run’;
  $sub_host_kil=’wechatlocker/server1/kil’;
   $pub_pre=’wechatlocker/client/’;//推送前缀
    class SndMsg {
       public $ToUserName = “”;
       public $FromUserName  = “”;
       public $MsgType =””;
       public $Msgresult =””;
       public $cabID  = “”;
       public $cabflg = “”;
       public $cabbar = “”;
       public $mobil  = “”;
       public $pass = “”;
       public $bigbox =””;
       public $midbox  =””;
       public $smlbox = “”;
       public $Hour =””;
       public $Minut  =””;
       public $Scnd = “”;
      }
      $MySndMsg = new SndMsg();
        $MySndMsg->ToUserName=$FromUserName;
        $MySndMsg->FromUserName=$ToUserName;
        $MySndMsg->MsgType=”open”;
        $MySndMsg->Msgresult=”OK”;//大写
        $MySndMsg->bigbox=$bigbox_num;
        $MySndMsg->midbox=$midbox_num;
        $MySndMsg->smlbox=$smallbox_num;
        $MySndMsg->Hour=date(‘H’);
        $MySndMsg->Minut=date(‘m’);
        $MySndMsg->Scnd=date(‘s’);
        $Sndtmp=json_encode($MySndMsg);
      $mqtt = new phpMQTT($host, $port, $ClientID.rand());
  //连接
  if ($mqtt->connect(true,NULL,$username,$password))
 {
      $mqtt->publish($pub_address,$MySndMsg,0);
     $mqtt->close(); //关闭
  }
?>
        location.href = “mobile/success.php”;
    }
     else
     {
      if (msg == “get_brand_wcpay_request:cancel”)
      {
            var err_msg = “您取消了微信支付”;
        }
        else if (res.err_code == 3)
         {
            var err_msg = “您正在进行跨号支付正在为您转入扫码支付……”;
        }
        else if (msg == “get_brand_wcpay_request:fail”)
         {
            var err_msg = “微信支付失败错误信息:” + res.err_desc;
        }
     else
         {
            var err_msg = msg + “” + res.err_desc;
        }
       alert(err_msg);
     }
        }
   );
}
    function callpay()
    {
        if (typeof WeixinJSBridge == “undefined”){
            if( document.addEventListener ){
                document.addEventListener(‘WeixinJSBridgeReady’, jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent(‘WeixinJSBridgeReady’, jsApiCall);
                document.attachEvent(‘onWeixinJSBridgeReady’, jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
    </script>
    <script type=”text/javascript”>
    //获取共享地址
    function editAddress()
    {
        WeixinJSBridge.invoke(
            ‘editAddress’,
            <?php echo $editAddress; ?>,
            function(res){
                var value1 = res.proviceFirstStageName;
                var value2 = res.addressCitySecondStageName;
                var value3 = res.addressCountiesThirdStageName;
                var value4 = res.addressDetailInfo;
                var tel = res.telNumber;
                //alert(value1 + value2 + value3 + value4 + “:” + tel);
            }
        );
    }
    window.onload = function(){
        if (typeof WeixinJSBridge == “undefined”){
            if( document.addEventListener ){
                document.addEventListener(‘WeixinJSBridgeReady’, editAddress, false);
            }else if (document.attachEvent){
                document.attachEvent(‘WeixinJSBridgeReady’, editAddress);
                document.attachEvent(‘onWeixinJSBridgeReady’, editAddress);
            }
        }else{
            editAddress();
        }
    };
    </script>
      <link rel=”stylesheet” href=”csss/weui.css”/>
  <link rel=”stylesheet” href=”csss/weuix.css”/>
  <link rel=”stylesheet” href=”csss/style.css”>
  <script src=”common/zepto.min.js”></script>
  <script src=”common/zepto.weui.js”></script>
  <script src=”common/common.js”></script>
</head>
<body>
    <!–<br/>
    <font color=”#9ACD32″><b>该笔订单编号是<span style=”color:#f00;font-size:50px”><?php echo $dd_noa;?></span>元</b></font><br/><br/>
    <font color=”#9ACD32″><b>该笔订单支付金额为<span style=”color:#f00;font-size:50px”><?php echo $ret_fee;?></span>元</b></font><br/><br/>
    <font color=”#9ACD32″><b>该笔订单内容<span style=”color:#f00;font-size:50px”><?php echo $dd_content;?></span>元</b></font><br/><br/>
     <font color=”#9ACD32″><b>该笔订单预计时长<span style=”color:#f00;font-size:50px”><?php echo $duration;?></span></b></font><br/><br/>
      <font color=”#9ACD32″><b>该笔订单计费方式<span style=”color:#f00;font-size:50px”><?php echo $rbChargeMode;?></span></b></font><br/><br/>
    <div align=”center”>
        <button style=”width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;” type=”button” onClick=”callpay()” >立即支付</button>
    </div>–>
    <div class=”page-bd”>
    <div style=”height:50px; line-height:50px; font-size:20px; padding-left:10px;”>
                寄存费预支付
    </div>
     </div>
    <div class=”page-bd”>
        <div class=”weui-form-preview”>
            <div class=”weui-form-preview__hd”>
                <label class=”weui-form-preview__label”>合计金额</label>
                <em class=”weui-form-preview__value”>¥ <?php echo $ret_fee;?>元</em>
            </div>
            <div class=”weui-form-preview__bd”>
                <div class=”weui-form-preview__item”>
                    <label class=”weui-form-preview__label”>订单编号</label>
                    <span class=”weui-form-preview__value”><?php echo $dd_noa;?></span>
                </div>
                <div class=”weui-form-preview__item”>
                    <label class=”weui-form-preview__label”>订单内容</label>
                    <span class=”weui-form-preview__value”><?php echo $dd_content;?></span>
                </div>
                <div class=”weui-form-preview__item”>
                    <label class=”weui-form-preview__label”>预计时长</label>
                    <span class=”weui-form-preview__value”><?php echo $duration;?></span>
                </div>
                <div class=”weui-form-preview__item”>
                    <label class=”weui-form-preview__label”>计费方式</label>
                    <span class=”weui-form-preview__value”><?php echo $duration;?></span>
                </div>
                <div class=”weui-form-preview__item”>
                    <label class=”weui-form-preview__label”>计费说明</label>
                    <span class=”weui-form-preview__value”><?php echo $duration;?></span>
                </div>
            </div>
            <div class=”weui-form-preview__ft”>
                <a class=”weui-form-preview__btn weui-form-preview__btn_default” href=”javascript:”>取消订单</a>
                <button type=”button” class=”weui-form-preview__btn weui-form-preview__btn_primary” onClick=”callpay()”>确认支付</button>
            </div>
        </div>
    </div>
</body>
</html>
打赏

薛敬官网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明php微信公众号物联网开发
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址