zoukankan      html  css  js  c++  java
  • 获取微信用户在微信小店的订单

    获取用户在微信小店的订单

    1. 网页授权得到openid

    2.拉取30天内的订单

    3.循环匹配订单的openid与当前用户openid是否一致

        
        //同步订单列表
        public function order(){
            $openid = "";
            Vendor('Weixin.weixinclass');
            $weixin = new weixin();
            if (!isset($_GET["code"])){
                $redirect_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                $jumpurl = $weixin->oauth2_authorize($redirect_url, "snsapi_base", "123");
                Header("Location: $jumpurl");
                exit();
            }else{
                // var_dump($_GET);
                $access_token_oauth2 = $weixin->oauth2_access_token($_GET["code"]);
                $openid = $access_token_oauth2['openid'];
    
                $curtime = time();
                $orderArr = $weixin->get_detail_by_filter('{ "begintime": '.($curtime - 2592000).',  "endtime": '.$curtime.'}'); //最近30天
                $list = array();
                $express = array('Fsearch_code'=>"邮政EMS",'002shentong'=>"申通快递",'066zhongtong'=>"中通速递",'056yuantong'=>"圆通速递",'042tiantian'=>"天天快递",'003shunfeng'=>"顺丰速运",'059Yunda'=>"韵达快运",'064zhaijisong'=>"宅急送",'020huitong'=>"汇通快运",'zj001yixun'=>"易迅快递");
                foreach ($orderArr["order_list"] as $index => $item){
                    if($item["buyer_openid"] == $openid){
                        $item["product_sku"] = str_replace("$","",$item["product_sku"]);
                        $item["express"] = $express[$item["delivery_company"]];
                        $list[] = $item;
                    }
                }
                // var_dump($list);
                $this->assign('title', "微信订单");
                $this->assign('list', $list);
                $this->display();
            }
        }
  • 相关阅读:
    【个人】排序练习
    lintcode:二叉树的层次遍历
    lintcode:子集 & 带重复元素的子集
    lintcode:全排列&带重复元素的排列
    5.2哈夫曼树——哈夫曼树与哈夫曼编码
    5.1 堆 —— 堆的定义与操作
    04-树7 二叉搜索树的操作集
    04-树6 Complete Binary Search Tree
    04-树5 Root of AVL Tree
    04-树4 是否同一棵二叉搜索树
  • 原文地址:https://www.cnblogs.com/txw1958/p/11142507.html
Copyright © 2011-2022 走看看