wlzboy
2025-07-09 ab0742bf945b5de8554761de6fa4ecda29f640e0
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
<?php require '../inc/odbc.php';?>
<?php
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'alipay/wappay/service/AlipayTradeService.php';
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
require dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'alipay/config.php';
 
$ServiceOrdID=empty($_REQUEST['ServiceOrdID'])!=false ? "" : addslashes($_REQUEST['ServiceOrdID']);
$DispatchOrdID=empty($_REQUEST['DispatchOrdID'])!=false ? "" : addslashes($_REQUEST['DispatchOrdID']);
$Total_fee=empty($_REQUEST['Total_fee'])!=false ? "" : addslashes($_REQUEST['Total_fee']);
$attach=empty($_REQUEST['attach'])!=false ? "" : addslashes($_REQUEST['attach']);
$body = "医疗服务费用";
 
if (!empty($ServiceOrdID) && trim($ServiceOrdID)!="" && !empty($Total_fee) && trim($Total_fee)!="" && trim($Total_fee)!="0"){
    //$sql = "select ServiceOrdID,ServiceOrdClass,ServiceOrd_CC_Time=CONVERT(varchar(100),ServiceOrd_CC_Time,23),ServiceOrdTraTxnPrice,ServiceOrdTraPaidPrice,ServiceOrdTraPrePayment,Guest_Reward from ServiceOrder where ServiceOrdID=".$ServiceOrdID ;
    $sql = "select * from ServiceOrder where ServiceOrdID=".$ServiceOrdID ;
    $data = sqlsrv_query($conn,$sql);
    if($data == true){
        while($rs = sqlsrv_fetch_array( $data) ) {
            $ServiceOrdID        = $rs['ServiceOrdID'];        //服务单号
            $ServiceOrdClass    = $rs['ServiceOrdClass'];    //单据类型
            $ServiceOrd_CC_Time    = date_format($rs['ServiceOrd_CC_Time'],'Y-m-d H:i:s');    //订单时间
            //$date = new DateTime ( '2000-01-01' );
            //echo $ServiceOrd_CC_Time -> format ( 'Y-m-d H:i:s' ); 
            //echo $rs[2];
 
            $ServiceOrdTraTxnPrice    = $rs['ServiceOrdTraTxnPrice'];    //成交价
            $ServiceOrdTraPaidPrice    = $rs['ServiceOrdTraPaidPrice'];    //已支付金额
            $ServiceOrdTraPrePayment= $rs['ServiceOrdTraPrePayment'];    //需预付款
            $Guest_Reward        = $rs['Guest_Reward'];    //打赏金额
            If (empty($ServiceOrdTraTxnPrice)) {$ServiceOrdTraTxnPrice=0;}
            If (empty($ServiceOrdTraPrePayment)) {$ServiceOrdTraPrePayment=0;}
            If (empty($Guest_Reward)) {$Guest_Reward=0;}
 
            $ServiceOrdNo        = $ServiceOrdClass.date_format($rs['ServiceOrd_CC_Time'],'Ymd')."-".substr("00".$rs['ServiceOrdNo'],-3);
            If ($attach=="打赏" And Total_fee>0) {
                $body="打赏";        //商品描述
            }
            ElseIf ($ServiceOrdTraTxnPrice<=$ServiceOrdTraPaidPrice And $Guest_Reward<>$Total_fee) {
                $errmsg="支付已完成,请不要重复提交。"&$attach;
            }Else{
                If ($Total_fee==0) { $Total_fee=$ServiceOrdTraTxnPrice-$ServiceOrdTraPaidPrice;}
                $body="医疗服务费用";        //商品描述
            }    
        }
    }
    
    //商户订单号,商户网站订单系统中唯一订单号,必填
    $out_trade_no = $ServiceOrdID."_".date("his");
 
    //订单名称,必填
    //$subject = $ServiceOrdNo."-W".date("mdHis");
    $subject = $body;
 
    //付款金额,必填
    $total_amount = $Total_fee;
 
    //超时时间
    $timeout_express="30m";
 
    //$business_params="{\"ServiceOrdID\":\"$ServiceOrdID\"}";
//echo $business_params;
//exit;
    $payRequestBuilder = new AlipayTradeWapPayContentBuilder();
    $payRequestBuilder->setBody($body);
    $payRequestBuilder->setSubject($subject);
    $payRequestBuilder->setOutTradeNo($out_trade_no);
    $payRequestBuilder->setTotalAmount($total_amount);
    $payRequestBuilder->setTimeExpress($timeout_express);
 
    $payResponse = new AlipayTradeService($config);
    $result=$payResponse->wapPay($payRequestBuilder,$config['return_url'],$config['notify_url']);
 
    return ;
}
?>