-
Notifications
You must be signed in to change notification settings - Fork 1
/
recharge.mod.php
182 lines (177 loc) · 4.73 KB
/
recharge.mod.php
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
<?php
/**
* 模块:帐户充值
* @copyright (C)2011 Cenwor Inc.
* @author Moyo <dev@uuland.org>
* @package module
* @name recharge.mod.php
* @version 1.0
*/
class ModuleObject extends MasterObject
{
function ModuleObject( $config )
{
$this->MasterObject($config);
if (MEMBER_ID < 1)
{
$this->Messager(__('请先登录!'), '?mod=account&code=login');
}
$runCode = Load::moduleCode($this);
$this->$runCode();
}
public function main()
{
$upcfg = ini('recharge');
include handler('template')->file('recharge');
}
public function del()
{
$id = $this->__orderid();
$order = logic('recharge')->GetOne($id);
if (!$order)
{
$this->Messager('订单编号无效!', -1);
}
if ($order['userid'] != MEMBER_ID)
{
$this->Messager('您无权操作此订单!', -1);
}
if ($order['paytime'] > 0)
{
$this->Messager('已经充值成功订单,无法删除!', -1);
}
logic('recharge')->del($id);
$this->Messager('删除成功!');
}
public function order()
{
if($_GET['id']){
$navcss1 = '1';$navcss2 = '2';
$id = $this->__orderid();
$order = logic('recharge')->GetOne($id);
if (!$order)
{
$this->Messager('订单编号无效!', -1);
}
if ($order['userid'] != MEMBER_ID)
{
$this->Messager('您无权操作此订单!', -1);
}
}else{
$navcss1 = '2';$navcss2 = '1';$tabcssall = $tabcssno = $tabcssyes = '3';
$order_list = true;
$paystatus = get('pay');
$where = ' ptype = 1 AND userid = ' . MEMBER_ID;
if ($paystatus)
{
if ($paystatus == 'no')
{
$where .= ' AND paytime = 0';
$tabcssno = '2';
}
elseif($paystatus == 'yes')
{
$where .= ' AND paytime > 0';
$tabcssyes = '2';
}
else
{
$tabcssall = '2';
}
}
else
{
$tabcssall = '2';
}
$list = logic('recharge')->GetList($where);
}
include handler('template')->file('recharge_order');
}
public function order_save()
{
$money = round((float)post('money'), 2);
if (!$money || $money <= 0)
{
$this->Messager('充值金额无效!', -1);
}
$order = logic('recharge')->GetFree($money,1);
header('Location: '.rewrite('?mod=recharge&code=order&id='.$order['orderid']));
}
public function payment_save()
{
$id = $this->__orderid();
$pid = post('payment_id', 'int');
$ibank = post('PaymentType', 'txt');
$test = logic('recharge')->GetOne($id);
if (!$test)
{
$this->Messager('订单编号无效!', -1);
}
logic('recharge')->Update($id, array('payment'=>$pid));
header('Location: '.rewrite('?mod=recharge&code=pay&id='.$id.'&ibank='.$ibank));
}
public function card_redirect()
{
$payment = logic('pay')->GetOne('recharge');
if ($payment['enabled'] != 'true')
{
$this->Messager('本站没有开放充值卡功能,请返回使用其他支付方式!', -1);
}
$order = logic('recharge')->GetFree(0);
logic('recharge')->Update($order['orderid'], array('payment'=>$payment['id']));
header('Location: '.rewrite('?mod=recharge&code=pay&id='.$order['orderid']));
}
public function pay()
{
$id = $this->__orderid();
$order = logic('recharge')->GetOne($id);
if (!$order)
{
$this->Messager('订单编号无效!', -1);
}
if ($order['payment'] == 0)
{
$this->Messager('请选择充值方式!', '?mod=recharge&code=order&id='.$id);
}
if ($order['paytime'] > 0 || $order['status'] != RECHARGE_STA_Blank)
{
$this->Messager('此订单已经充值过了!', '?mod=me&code=bill');
}
$pay = logic('pay')->GetOne($order['payment']);
$pay['code']=='yeepay' && $pay['site'] = 'pc_web';
if (!$pay)
{
$this->Messager('无效的充值方式!', -1);
}
if ($order['userid'] != MEMBER_ID)
{
$this->Messager('您无权操作此订单!', -1);
}
$parameter = array(
'name' => '账户充值('.$id.')',
'detail' => '充值:'.$order['money'].'元,充值编号:'.$id,
'price' => $order['money'],
'sign' => $order['orderid'],
'notify_url' => ini('settings.site_url').'/index.php?mod=callback&pid='.$pay['id'],
'product_url' => ini('settings.site_url').'/index.php?mod=me&code=bill'
);
if ($pay['code']== 'bankdirect') {
$orderinfo['price'] = $order['money'];
$orderinfo['sign'] = $order['orderid'];
echo logic('pay')->apiz($pay['code'])->CreatForm($pay, $orderinfo);
exit;
}
$payment_linker = logic('pay')->Linker($pay, $parameter);
include handler('template')->file('recharge_pay');
}
private function __orderid()
{
$id = get('id', 'number');
if (!$id || strlen($id) != 13)
{
$this->Messager('请输入正确的订单编号!', -1);
}
return $id;
}
}
?>