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


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

    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();
            }
        }
  • 相关阅读:
    C++中virtual(虚函数)的用法
    testlins
    MATLAB——matlab特殊符号表【转载】
    VS-按F12无法跳转到函数定义,点击右键也无法跳转
    fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
    Matlab7.1——启动时只显示Logo
    CANopen——总线基本知识
    CANopen——笔记
    ASCII表格
    Codesys——AD_DA在PID控制中的作用
  • 原文地址:https://www.cnblogs.com/txw1958/p/11142507.html
Copyright © 2020-2023  润新知