payfun.php
5.99 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
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
<?php
//購買點數處理
function PayApiBuyFen($fen,$money,$paybz,$orderid,$userid,$username,$ecms_paytype){
global $empire,$dbtbpre;
$fen=(int)$fen;
$money=(float)$money;
$paybz=RepPostStr($paybz);
$userid=(int)$userid;
$username=RepPostVar($username);
$ecms_paytype=RepPostVar($ecms_paytype);
//驗證是否重複提交
$orderid=RepPostVar($orderid);
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
if($num)
{
printerror('您已成功購買 '.$fen.' 點','../../../',1,0,1);
}
if($fen)
{
$sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userfen')."=".egetmf('userfen')."+".$fen." where ".egetmf('userid')."='$userid'");
$posttime=date("Y-m-d H:i:s");
$payip=egetip();
$empire->query("insert into {$dbtbpre}enewspayrecord(id,userid,username,orderid,money,posttime,paybz,type,payip) values(NULL,'$userid','$username','$orderid','$money','$posttime','$paybz','$ecms_paytype','$payip');");
//備份充值記錄
BakBuy($userid,$username,$orderid,$fen,$money,0,2);
}
printerror('您已成功購買 '.$fen.' 點','../../../',1,0,1);
}
//預付款處理
function PayApiPayMoney($money,$paybz,$orderid,$userid,$username,$ecms_paytype){
global $empire,$dbtbpre;
$money=(float)$money;
$paybz=RepPostStr($paybz);
$userid=(int)$userid;
$username=RepPostVar($username);
$ecms_paytype=RepPostVar($ecms_paytype);
//驗證是否重複提交
$orderid=RepPostVar($orderid);
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
if($num)
{
printerror('您已成功存預付款 '.$money.' 元','../../../',1,0,1);
}
if($money)
{
$sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('money')."=".egetmf('money')."+".$money." where ".egetmf('userid')."='$userid'");
$posttime=date("Y-m-d H:i:s");
$payip=egetip();
$empire->query("insert into {$dbtbpre}enewspayrecord(id,userid,username,orderid,money,posttime,paybz,type,payip) values(NULL,'$userid','$username','$orderid','$money','$posttime','$paybz','$ecms_paytype','$payip');");
//備份充值記錄
BakBuy($userid,$username,$orderid,0,$money,0,3);
}
printerror('您已成功存預付款 '.$money.' 元','../../../',1,0,1);
}
//商城支付
function PayApiShopPay($ddid,$money,$paybz,$orderid,$userid,$username,$ecms_paytype){
global $empire,$dbtbpre;
$ddid=(int)$ddid;
$userid=(int)$userid;
$username=RepPostVar($username);
$ecms_paytype=RepPostVar($ecms_paytype);
//驗證是否重複提交
$orderid=RepPostVar($orderid);
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
if($num)
{
printerror('您已成功購買此訂單','../../ShopSys/buycar/',1,0,1);
}
$ddr=PayApiShopDdMoney($ddid);
if($money==$ddr['tmoney'])
{
include('../../ShopSys/class/ShopSysFun.php');
$money=(float)$money;
$sql=$empire->query("update {$dbtbpre}enewsshopdd set haveprice=1 where ddid='$ddid'");
//減少庫存
$shoppr=ShopSys_ReturnSet();
if($shoppr['cutnumtype']==1)
{
$buycarr=$empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='$ddid'");
Shopsys_CutMaxnum($ddid,$buycarr['buycar'],$ddr['havecutnum'],$shoppr,0);
}
$posttime=date("Y-m-d H:i:s");
$payip=egetip();
$userid=(int)$ddr[userid];
$username=$ddr[username]?$ddr[username]:$ddr[truename];
$username=RepPostStr($username);
$paybz=str_replace('[!--ddno--]',$ddr[ddno],$paybz);
$paybz=RepPostStr($paybz);
$empire->query("insert into {$dbtbpre}enewspayrecord(id,userid,username,orderid,money,posttime,paybz,type,payip) values(NULL,'$userid','$username','$orderid','$money','$posttime','$paybz','$ecms_paytype','$payip');");
}
printerror('您已成功購買此訂單','../../ShopSys/buycar/',1,0,1);
}
//商城訂單金額
function PayApiShopDdMoney($ddid){
global $empire,$dbtbpre;
$ddid=(int)$ddid;
if(empty($ddid))
{
printerror('訂單不存在','../../../',1,0,1);
}
$r=$empire->fetch1("select ddid,ddno,userid,username,truename,pstotal,alltotal,fptotal,pretotal,fp,payby,havecutnum from {$dbtbpre}enewsshopdd where ddid='$ddid'");
if(empty($r['ddid']))
{
printerror('訂單不存在','../../../',1,0,1);
}
//是否現金購買
if($r['payby']!=0)
{
printerror('此訂單為非現金支付','../../../',1,0,1);
}
$r['tmoney']=$r['alltotal']+$r['pstotal']+$r['fptotal']-$r['pretotal'];
return $r;
}
//充值類型支付
function PayApiBuyGroupPay($bgid,$money,$orderid,$userid,$username,$groupid,$ecms_paytype){
global $empire,$dbtbpre,$level_r;
$bgid=(int)$bgid;
$userid=(int)$userid;
$username=RepPostVar($username);
$groupid=(int)$groupid;
$ecms_paytype=RepPostVar($ecms_paytype);
//驗證是否重複提交
$orderid=RepPostVar($orderid);
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
if($num)
{
printerror('您已成功充值','../../../',1,0,1);
}
$buyr=$empire->fetch1("select * from {$dbtbpre}enewsbuygroup where id='$bgid'");
if($buyr['id']&&$money==$buyr['gmoney']&&$level_r[$buyr[buygroupid]][level]<=$level_r[$groupid][level])
{
$money=(float)$money;
//充值
$user=$empire->fetch1("select ".eReturnSelectMemberF('userdate,userid,username')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid'");
eAddFenToUser($buyr['gfen'],$buyr['gdate'],$buyr['ggroupid'],$buyr['gzgroupid'],$user);
$posttime=date("Y-m-d H:i:s");
$payip=egetip();
$paybz="充值類型:".addslashes($buyr['gname']);
$paybz=RepPostStr($paybz);
$empire->query("insert into {$dbtbpre}enewspayrecord(id,userid,username,orderid,money,posttime,paybz,type,payip) values(NULL,'$userid','$username','$orderid','$money','$posttime','$paybz','$ecms_paytype','$payip');");
//備份充值記錄
BakBuy($userid,$username,$buyr['gname'],$buyr['gfen'],$money,$buyr['gdate'],1);
}
printerror('您已成功充值','../../../',1,0,1);
}
?>