微信平台小程序 发货接口调用
【代码】微信平台小程序 发货接口调用。
·
<?php
$payInfo = pdo_fetch("select * from " . tablename("core_paylog") . "\r\n where tid = '" . $item["ordersn"] . "' and status=1 and uniacid = " . $_W["uniacid"] . " limit 1 ");
$goodsInfo = pdo_fetch("select a.*,b.title from " . tablename("ewei_shop_order_goods") . "\r\n a left join " . tablename("ewei_shop_goods") . " b on a.goodsid=b.id where a.orderid = '" . $item["id"] . "' and a.uniacid = " . $_W["uniacid"] . " limit 1 ");
$item_desc = $goodsInfo['title'];
$openid = str_replace("sns_wa_", "", $goodsInfo['openid']);
// 指定一个特定的日期时间
$date = new DateTime();
// 设置时区
$date->setTimezone(new DateTimeZone('Asia/Shanghai'));
// 格式化日期时间
$upload_time = $date->format('Y-m-d\TH:i:s.120P');
$tag=unserialize($payInfo['tag']);
if(isset($tag['transaction_id'])){
$transaction_id=$tag['transaction_id'];
$postData=array(
"order_key"=>array(
"order_number_type"=>2,
"transaction_id"=>$transaction_id
),
"delivery_mode"=>1,
"logistics_type"=>4,
"shipping_list"=>array(
array(
"item_desc"=>$item_desc
)
),
"upload_time"=>$upload_time,
"payer"=>array(
"openid"=>$openid
)
);
$accessToken = $this->getAccessToken();
if( is_error($accessToken) )
{
show_json(0, $accessToken["message"]);
}
load()->func("communication");
$request = ihttp_post("https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" . $accessToken, json_encode($postData,JSON_UNESCAPED_UNICODE));
$content = json_decode($request["content"], true);
if( !empty($content["errcode"]) )
{
show_json(0, "(errcode: " . $content["errcode"] . ") " . $content["errmsg"]);
}
}
更多推荐

所有评论(0)