365体育备用网址报道10.2.2订单付款通知_365体育备用网址官网资讯

用户在微信中付款胜利后,微信服务器会将订单付款通知推送到开拓者在公众平台网站中设置的回调URL(在开拓模式中设置)中。该通知是一个merchant_order事情通知。
微信推送的merchant_order事情消息内容如下:

<XML>
    <ToUserName><![CDATA[weixin_media1]]></ToUserName>
    <FromUserName><![CDATA[oDF3iYyVlek46AyTBbMRVV8VZVlI]]></FromUserName>
    <CreateTime>1398144192</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[merchant_order]]></Event>
    <OrderId><![CDATA[7197417460812584720]]></OrderId>
    <OrderStatus>2</OrderStatus>
    <ProductId><![CDATA[pDF3iYx7KDQVGzB7kDg6Tge5OKFo]]></ProductId>
    <SkuInfo><![CDATA[10001:1000012;10002:100021]]></SkuInfo>
</xml>

其中的OrderId参数即为该次交易的订单ID号。我们能够依据订单ID查询订单详情。
依据订单ID查询订单详情接口如下所示:
https://api.weixin.qq.com/merchant/order/getbyid?access_token=ACCESS_TOKEN
该接口的POST数据格式如下,参数说明如表10-1所示。

{
    "order_id": "7197417460812584720" 
}

表10-1 订单查询接口参数说明
返回数据格式如下。

{
    "errcode": 0,
    "errmsg": "success",
    "order": {
        "order_id": "7197417460812533543",
        "order_status": 6,
        "order_total_price": 69,
        "order_create_time": 1394635817,
        "order_express_price": 5,
        "buyer_openid": "oDF3iY17NsDAW4UP2qzJXPsz1S9Q",
        "buyer_nick": "方倍",
        "receiver_name": "方倍工作室",
        "receiver_province": "广东省",
        "receiver_city": "深圳市",
        "receiver_address": "华景路一号南方通信大厦5楼",
        "receiver_mobile": "123456789",
        "receiver_phone": "123456789",
        "product_id": "pDF3iYx7KDQVGzB7kDg6Tge5OKFo",
        "product_name": "包邮正版 《微信公众平台开拓最佳实践》 双十一特惠",
        "product_price": 1,
        "product_sku": "10000983:10000995;10001007:10001010",
        "product_count": 1,
        "product_img": "http://img2.paipaiimg.com/00000000/item-52B87243-63CCF66C00000000040100003565C1EA.0.300x300.jpg",
        "delivery_id": "1900659372473",
        "delivery_company": "059Yunda", 
        "trans_id": "1900000109201404103172199813"
    }
}

上述数据的参数说明如表10-2所示。

表10-2 订单查询接口返回内容参数说明
付款通知在事情消息中的实龙虎斗赌博有手机版吗码如下所示。

 1 //接收事情消息
 2 private function receiveEvent($object)
 3 {
 4     $content = "";
 5     switch ($object->Event)
 6     {
 7         case "subscribe":
 8             $content = "欢迎关切 ";
 9             break;
10         case "CLICK":
11             switch ($object->EventKey)
12             {
13                 default:
14                     $content = "点击菜单:".$object->EventKey;
15                     break;
16             }
17             break;
18         case "merchant_order":
19             $orderid = strval($object->OrderId);
20             $openid = strval($object->FromUserName);
21             require_once('weixin.class.PHP');
22             $weixin = new class_weixin();
23             $orderArr0 = $weixin->get_detail_by_order_id($orderid);
24             $orderArr  = $orderArr0["order"];
25             
26             //客服接口发送
27             $orderInfo = "【订单信息】\n单号:".$orderArr["order_id"]."\n时间:".date("Y-m-d H:i:s", ($orderArr["order_create_time"]));
28             $goodsInfo = "【商品信息】\n名称:".$orderArr["product_name"].
29             "\n总价:¥".($orderArr["product_price"] / 100)." × ".$orderArr["product_count"]." + ¥".($orderArr["order_express_price"] / 100)." = ¥".($orderArr["order_total_price"] / 100);
30             $buyerInfo = "【买家信息】\n昵称:".$orderArr["buyer_nick"].
31             "\n地址:".$orderArr["receiver_province"].$orderArr["receiver_city"].$orderArr["receiver_zone"].$orderArr["receiver_address"].
32             "\n姓名:".$orderArr["receiver_name"]." 电话:".((isset($orderArr["receiver_phone"]) && !empty($orderArr["receiver_phone"]))?($orderArr["receiver_phone"]):($orderArr["receiver_mobile"]));
33             $data[] = array("title"=>urlencode("订单通知"), "description"=>"", "picurl"=>"", "url" =>"");
34             $data[] = array("title"=>urlencode($orderInfo), "description"=>"", "picurl"=>"", "url" =>"");
35             $data[] = array("title"=>urlencode($goodsInfo), "description"=>"", "picurl"=>$orderArr["product_img"], "url" =>"");
36             $data[] = array("title"=>urlencode($buyerInfo), "description"=>"", "picurl"=>"", "url" =>"");
37             $result2 = $weixin->send_custom_message($openid, "news", $data);
38 
39             $content = "";
40             break;
41         default:
42             $content = "";
43             break;
44         
45     }
46     if(is_array($content)){
47         if (isset($content[0])){
48             $result = $this->transmitNews($object, $content);
49         }else if (isset($content['MusicUrl'])){
50             $result = $this->transmitMusic($object, $content);
51         }
52     }else{
53         $result = $this->transmitText($object, $content);
54     }
55 
56     return $result;
57 }

上述代码中和订单查询通知相关部分简要说明如下:
第18行:推断是否收到订单付款通知。
第19行~第20行:猎取用户的OpenID及订单ID。
第21行~第24行:引用微信小店SDK,依据订单ID查询订单详情。
第26行~第37行:将订单详情中的内容填充进微信模版消息中并发送。
最后,一个购买胜利通知的图文消息实现如图10-27所示。

图10-27 购买胜利通知

------分隔线----------------------------

公布评论 (119人察看0条评论)
请自觉遵守互联网相关的政策法规,严禁公布色情、暴力、反动的言论。
用户名: 验证码: 点击我更换和记娱乐娱乐城轮盘
最新评论