微信小程序后台发货信息同步PHP

//微信小程序后台发货同步

                    require 'wxsendno.php';

                    $user = $db->get_one("SELECT openid,push FROM {$TT}wxsmall_user WHERE username='$td[buyer]'");

                    $openid=$user['openid'];

                    $data =array(

                            'order_key' => array(

                            'order_number_type' => 2,

                            // 'mchid'=>"",//商户号

                            // 'out_trade_no' => $itemid//商户订单号

                            'transaction_id'=>$td[' transaction_id']

                        ),

                        'logistics_type' => 1,//物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提

                        'delivery_mode' => 1,

                        'shipping_list' => array(

                           array(

                                'tracking_no' => $send_no,

                                'express_company' => $td['fee_name'],

                                'item_desc' => $td['title']

                           ),

                       ),

                        'upload_time' => date('Y-m-d\TH:i:sP', time()),

                        'payer' => array(

                            'openid' => $openid

                        )

                        );

                    $iswxsend=sendDelivery($data);

                    if($iswxsend['errcode']){

                        $wxsend="微信小程序官方后台发货错误".$iswxsend['errmsg']."请注意手动处理,订单号".$itemid;

                    }else{

                        $wxsend="微信小程序官方后台同步发货成功!";

                    }

wxsendno.php

<?php

//test($access_token);

function http_get($url) {

    $rec = dcurl($url);

    $arr = json_decode($rec, true);

    return $arr ? $arr : array();

}

function get_token() {

    $access_token=isset($access_token)?$access_token:null;

        if(!$access_token) {

            $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appid.'&secret='.$appsecret;

            $arr = http_get($url);

            $access_token = isset($arr['access_token']) ? $arr['access_token'] : null;

        //  if($access_token) $this->dc->set($this->appid.'_weixinsmall_access_token', $access_token, 7000);

        }

        return $access_token;

    }



 

//获取发货订单信息

function getWxSendOrderStatus($itemid,$access_token)

{

    $url = "https://api.weixin.qq.com/wxa/sec/order/get_order?access_token=" . $access_token;

    $data = array(

        'transaction_id' => $itemid

    );

    $data = json_encode($data);

//test($data);

    $result = mycurl($url, $data);

    $result = json_decode($result, true);

   // test($result);

}

//设置微信发货后,消息跳转地址,不设置为默认

function set_jump_path()

{

    $access_token = $this->$access_token;

    $url = "https://api.weixin.qq.com/wxa/sec/order/set_msg_jump_path?access_token=" . $access_token;

    $data = array(

        'path' => 'pages/order/index'

    );

    $data = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

    dcurl($url, $data);

}

//发货 物流10天自动确认,虚拟商品隔天自动确认

function sendDelivery($data)

{

    $token = get_token();

     $urlss = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" . $token;

     $data = json_encode($data,JSON_UNESCAPED_UNICODE);

    // test($data);

     $results = dcurl($urlss, $data);

     $results = json_decode($results, true);

  return  $results;

 }






 

?>

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值