【调度系统】广东民航医疗快线调度系统源代码
wzp
2024-12-06 0df39a8c5a45c6ff25411eace15d40a606f9769c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/* *
 * 功能:支付宝手机网站alipay.trade.query (统一收单线下交易查询)调试入口页面
 * 版本:2.0
 * 修改日期:2016-11-01
 * 说明:
 * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
 请确保项目文件有可写权限,不然打印不了日志。
 */
 
header("Content-type: text/html; charset=utf-8");
function object_array($array) {  
    if(is_object($array)) {  
        $array = (array)$array;  
     } if(is_array($array)) {  
         foreach($array as $key=>$value) {  
             $array[$key] = object_array($value);  
             }  
     }  
     return $array;  
}
 
 
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'service/AlipayTradeService.php';
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'buildermodel/AlipayTradeQueryContentBuilder.php';
require dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../config.php';
if (!empty($_GET['out_trade_no'])){
 
    //商户订单号和支付宝交易号不能同时为空。 trade_no、  out_trade_no如果同时存在优先取trade_no
    //商户订单号,和支付宝交易号二选一
    $out_trade_no = trim($_GET['out_trade_no']);
    $ShopOrdID = $out_trade_no;
    $RequestBuilder = new AlipayTradeQueryContentBuilder();
    $RequestBuilder->setOutTradeNo($out_trade_no);
 
    $Response = new AlipayTradeService($config);
    $result = $Response->Query($RequestBuilder);
    $result = object_array($result);
    // var_dump($result);exit;
    if(!empty($result) && $result["code"] != "40004"){
        //支付宝交易号
        $trade_no = !empty($result['trade_no'])?$result['trade_no']:"";
 
        //交易状态
        $trade_status = $result['trade_status'];
        if ($trade_status == 'TRADE_SUCCESS') {
            //判断该笔订单是否在商户网站中已经做过处理
                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                //请务必判断请求时的total_amount与通知时获取的total_fee为一致的
                //如果有做过处理,不执行商户的业务程序            
            //注意:
            //付款完成后,支付宝系统发送该交易状态通知
            //查后台订单状态
            
            $key='apivcomcn20170421';
            $ShopUserID=urlencode("实体店-白马星汇良仓");
                
            $method = "Order_AddressEdit";
            $NewShopUserID = $ShopUserID;
            $ShopUserID = $ShopUserID;
            $arr = array("method"=>$method,"ShopOrdID"=>$ShopOrdID,"ShopUserID"=>$ShopUserID,"NewShopUserID"=>$NewShopUserID);
            
            
            ksort($arr);
            $i=0;
            $stringA='';
            foreach($arr as $k=>$v){
                $stringA=$stringA.$k.$v;
            }
            
            $stringSignTemp=$stringA.$key;
            $stringSignTemp=str_replace(" ", "%20", $stringSignTemp);
            
            $sign=MD5($stringSignTemp);
            $content = "";
            $content = 'method='.$method.'&ShopOrdID='.$ShopOrdID.'&ShopUserID='.$ShopUserID."&NewShopUserID=".$NewShopUserID;
            
            
            $content .= '&Sign='.$sign;
            $order_url='http://api.v.com.cn/order/?'.$content;
            $order_url=str_replace(" ", "%20", $order_url);
            // var_dump($url);exit;
            $orderinfo_change=file_get_contents($order_url);
            $orderinfo_change=json_decode($orderinfo_change,true);
            
            
            $method = "Order_detail";
        
            $arr = array("method"=>$method,"ShopOrdID"=>$ShopOrdID);
            ksort($arr);
            $i=0;
            $stringA='';
            foreach($arr as $k=>$v){
                $stringA=$stringA.$k.$v;
            }
            $stringSignTemp=$stringA.$key;
            $stringSignTemp=str_replace(" ", "%20", $stringSignTemp);
 
            $sign=MD5($stringSignTemp);
            $content = 'method='.$method.'&ShopOrdID='.$ShopOrdID;
            $content .= '&Sign='.$sign;
            $order_url='http://api.v.com.cn/order/?'.$content;
            $order_url=str_replace(" ", "%20", $order_url);
            // var_dump($url);exit;
            $orderinfo=file_get_contents($order_url);
            $orderinfo=json_decode($orderinfo,true);
            if(!empty($orderinfo["ProgressE"]) && $orderinfo["ProgressE"] != "0"){
                $status = $orderinfo["ProgressE"];
            }elseif($orderinfo["ProgressD"] === "0" || $orderinfo["ProgressD"] === "2"){
                if($orderinfo["ProgressM"] === "1"){
                    $status = "已支付";
                }elseif($orderinfo["ProgressM"] === "0"){
                    $status = "未支付";
                }elseif($orderinfo["ProgressM"] === "4"){
                    $status = "已取消";
                }
            }elseif($orderinfo["ProgressD"] === "4"){
                $status = "已取消";
            }elseif($orderinfo["ProgressD"] === "3"){
                $status = "已下发";
            }
            if($status == "未支付"){
                $trade_no = $result["trade_no"];
                $total_amount = $result["total_amount"];
                $method = "Order_PayNotify";
                $transaction_id = $trade_no;
                $mch_id = "2016090601857165";
                $total_fee = number_format($total_amount,2,'.','');
                $ShopOrdID = $out_trade_no;
                $PayMono = urlencode("支付宝");
                $arr = array("method"=>$method,"transaction_id"=>$transaction_id,"mch_id"=>$mch_id,"out_trade_no"=>$out_trade_no,"total_fee"=>$total_fee,"ShopOrdID"=>$ShopOrdID,"PayMono"=>$PayMono,"openid"=>$openid);
                ksort($arr);
                $i=0;
                $stringA='';
                foreach($arr as $k=>$v){
                    $stringA=$stringA.$k.$v;
                }
                $stringSignTemp=$stringA.$key;
                $stringSignTemp=str_replace(" ", "%20", $stringSignTemp);
 
                $sign=MD5($stringSignTemp);
                $content = 'method='.$method.'&transaction_id='.$transaction_id.'&mch_id='.$mch_id.'&out_trade_no='.$out_trade_no.'&total_fee='.$total_fee.'&ShopOrdID='.$ShopOrdID.'&PayMono='.$PayMono."&openid=".$openid;
                $content .= '&Sign='.$sign;
                $order_url='http://api.v.com.cn/order/?'.$content;
                $order_url=str_replace(" ", "%20", $order_url);
                $orderinfo=file_get_contents($order_url);
                $orderinfo=json_decode($orderinfo,true);
                if($orderinfo["result"] == "1"){
                    header("Location: http://vadmin.v.com.cn/ccShop/OrderDetail.php?ShopOrdID=$ShopOrdID");exit;
                }else{
                    header("Location: http://vadmin.v.com.cn/ccShop/OrderDetail.php?ShopOrdID=$ShopOrdID");exit;
                }
            }
        }
    }else{
        header("Location: http://vadmin.v.com.cn/ccShop/OrderDetail.php?ShopOrdID=$ShopOrdID");exit;
    }
    
    return;
}
?>