chengkun
2025-05-23 a6f7b382623096b6a00924f418447cf5204e825e
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
 
class fk_controller extends wxapp_controller{
    
    
    function index_action()
    {
        $where['id']  =  intval($_POST['id']);
        if($_POST['from'] != 'once'){
            if ($_POST['uid'] && $_POST['token']){
                $member  =  $this->yztoken($_POST['uid'],$_POST['token']);
                
                $where['uid']  =  $member['uid'];
            }
        }
        
        
        $orderM  =  $this->MODEL('companyorder');
        $order     =    $orderM->getInfo($where,array('field'=>'`order_state`'));
        
        if(empty($order)){
            $this->render_json(2,'订单不存在');
        }elseif ($order['order_state']==2) {
            $this->render_json(0,'ok');
        }else{
            $this->render_json(1,'未付款');
        }
    }
    /**
     * 小程序付款
     */
    function xcxfk_action()
    {
        // 非店铺招聘付款要判断登录状态
        if(!(isset($_POST['fr']) && $_POST['fr'] == 'once')){
            $member = $this->yzToken($_POST['uid'],$_POST['token']);
        }
        $code    =  trim($_POST['code']);
        $id      =  intval($_POST['id']);
        
        $result  =  array();
        if (!empty($code)){
            
            $getdata    =    $this->getOpenid($code);
            
            if($getdata['openid']){
                
                $orderM         =      $this->MODEL('companyorder');
                $order        =    $orderM->getInfo(array('id'=>$id),array('field'=>'`id`,`order_type`,`order_id`,`order_price`'));
               
                if (!empty($order)){
                     $orderM -> upInfo($id, array('port' => '3'));
                    // 跨端支付,生成新订单
                    if($order['order_type'] == 'wxpay' || $order['order_type'] == 'wxh5'){
                        
                        $order  =    $orderM -> wxPayChange($order['id'], array('paytype'=>'wxxcx'));
                    }
                    
                    require_once(LIB_PATH.'wxOrder.function.php');
                    
                    $result  =  wxXcxOrder(array('body'=>'充值','id'=>$order['order_id'],'url'=>$this->config['sy_weburl'],'total_fee'=>$order['order_price'],'openid'=>$getdata['openid']));
                    $msg     =    'ok';
                }else{
                    
                    $msg    =    '没有该订单';
                }
            }else{
                if ($getdata['errcode']){
                    $msg    =    '微信小程序配置错误';
                    $this->MODEL('errlog')->addErrorLog($member['uid'], 10, '微信小程序付款获取openid错误。code:'.$_POST['code'].'。'.$getdata['errcode'].','.$getdata['errmsg']);
                }else{
                    $msg    =    '参数错误';
                }
            }
        }else{
            $msg    =    '微信登录状态获取失败';
        }
        
        $this->render_json(0,$msg,$result);
    }
    /**
     * app付款链接
     */
    function mfk_action()
    {
        if($_POST['from']!='once'){
            if($_POST['uid'] && $_POST['token']){
                $member = $this->yzToken($_POST['uid'],$_POST['token']);
            }
        }
        $orderM    =      $this->MODEL('companyorder');
        $id        =  intval($_POST['id']);
        $orderM -> upInfo($id, array('port' => '4'));
        if ($_POST['fktype'] == 'fkwx'){
            
            $data  =  $this->wxpay($id);
            
        }elseif ($_POST['fktype'] == 'fkal'){
            
            $orderM         =      $this->MODEL('companyorder');
            $order        =    $orderM->getInfo(array('id'=>$id),array('field'=>'`order_id`,`order_price`'));
            
            $data['url']  =  $this->config['sy_weburl'].'/api/wapalipay/alipayto.php?dingdan='.$order['order_id'].'&token='.$_POST['token'].'&uid='.$member['uid'];
 
 
        }
        $data['id'] =   $id;
        $this->render_json(0, 'ok', $data);
    }
    /**
     * 百度小程序付款
     */
    function baidufk_action(){
        // 非店铺招聘付款要判断登录状态
        if(!(isset($_POST['fr']) && $_POST['fr'] == 'once')){
            $member = $this->yzToken($_POST['uid'],$_POST['token']);
        }
        $id       =  intval($_POST['id']);
        $result   =  array();
        
        $orderM      =  $this->MODEL('companyorder');
        $order      =  $orderM->getInfo(array('id'=>$id),array('field'=>'`id`,`order_type`,`order_id`,`order_price`'));
        
        if (!empty($order)){
            $orderM -> upInfo($id, array('port' => '3'));
            require_once(APP_PATH.'api/baiduPay/baiduPay.php');
            
            $result  = baiduOrder(array('tpOrderId'=>$order['order_id'],'totalAmount'=>$order['order_price']));
            $msg     =    'ok';
        }else{
            
            $msg    =    '没有该订单';
        }
        
        $this->render_json(0,$msg,$result);
    }
    /**
     * 支付宝小程序付款
     */
    function zfbfk_action()
    {
        // 非店铺招聘付款要判断登录状态
        if(!(isset($_POST['fr']) && $_POST['fr'] == 'once')){
            $member = $this->yzToken($_POST['uid'],$_POST['token']);
        }
        $id       =  intval($_POST['id']);
        $result   =  array();
        
        $orderM      =  $this->MODEL('companyorder');
        $order      =  $orderM->getInfo(array('id'=>$id),array('field'=>'`id`,`order_type`,`order_id`,`order_price`'));
        
        if (!empty($order)){
            $orderM -> upInfo($id, array('port' => '3'));
            require_once(APP_PATH.'api/aop/AopToYun.php');
            $mini    =  new AlipayMini();
            $result  =  $mini->alipay(array('id'=>$order['order_id'],'total_amount'=>$order['order_price'],'subject'=>'充值','code'=>$_POST['zfbcode']));
            
            if ($result['msg']){
                $msg  =  $result['msg'];
            }else{
                $msg  =  'ok';
            }
        }else{
            
            $msg    =    '没有该订单';
        }
        
        $this->render_json(0,$msg,$result);
    }
    /**
     * 头条小程序付款
     */
    function toutiaofk_action(){
        // 非店铺招聘付款要判断登录状态
        if(!(isset($_POST['fr']) && $_POST['fr'] == 'once')){
            $member = $this->yzToken($_POST['uid'],$_POST['token']);
        }
        $id       =  intval($_POST['id']);
        $result   =  array();
        
        $orderM      =  $this->MODEL('companyorder');
        $order      =  $orderM->getInfo(array('id'=>$id),array('field'=>'`id`,`order_type`,`order_id`,`order_price`'));
        
        if (!empty($order)){
            $orderM -> upInfo($id, array('port' => '3'));
            require_once(APP_PATH.'api/bytedance/ecpay.php');
            $ecpay = new ecpay();
            $res = $ecpay->create_order(array('body'=>'充值','out_order_no'=>$order['order_id'],'notify_url'=>$this->config['sy_weburl'].'/api/bytedance/notify.php','total_amount'=>$order['order_price']));
            
            if ($res['err_no'] == 0){
                $this->render_json(0,'ok',$res['data']);
            }else{
                $this->render_json(-1, $res['err_no'].','.$res['err_tips']);
            }
        }else{
            $this->render_json(-1, '没有该订单');
        }
    }
}
?>