Pay.php
2.26 KB
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
<?php
use Action\WebAction;
use Shopping\PayModel;
use WebPlugin\Helpers;
use LibModels\Web\Home\UserData;
/**
* 支付相关的控制器
*
* @name PayController
* @package shopping
* @copyright yoho.inc
* @version 1.0 (2016-3-21 16:23:19)
* @author fei.hong <fei.hong@yoho.cn>
*/
class PayController extends WebAction
{
// 存储的UID键名
const SESSION_UID_KEY = 'payUserid';
/**
* 订单已完成,跳到支付
*/
public function indexAction()
{
/* 判断用户是否登录 */
$uid = $this->getUid(true);
if (!$uid) {
$this->go( Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))) );
}
// 将用户UID存入session中以便支付成功回调使用
$this->setSession(self::SESSION_UID_KEY, $uid);
// 订单号
$orderCode = $this->get('order_code', $this->get('ordercode'));
//支付宝快捷支付
$alipayToken = $this->getSession('alipay_user_token');
if (!empty($alipayToken)) {
$this->go(Helpers::url('/pay/index/index', array('order_code' => $orderCode, 'payment_type' => '2_platform')));
}
$data = PayModel::getPayTypeData($uid, $orderCode);
//不存在订单时
if (isset($data['noOrder'])) {
$this->helpJsRedirect('没有找到该订单');
}
$view = 'index';
// 无需付款时
if (isset($data['notNeedPay'])) {
$view = 'notneedpay';
}
// 是货到付款时
if (isset($data['finish'])) {
$view = 'cashondelivery';
}
// 用户名
$UserData = UserData::getUserInfo($uid);
$data['userName'] = isset($UserData['code']) && $UserData['code'] === 200 ? $UserData['data']['profile_name'] : $this->_uname;
$this->setSimpleHeader();
$this->_view->display($view, array(
'shoppingpay' =>$data,
'pinyou' => array(
'orderNum' => $data['orderNum'],
'count' => $data['count'],
'productList' => $data['pinyouGoods']
),
'payPage' => true
));
}
}