payfun.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. //购买点数处理
  3. function PayApiBuyFen($fen,$money,$paybz,$orderid,$userid,$username,$ecms_paytype){
  4. global $empire,$dbtbpre;
  5. $fen=(int)$fen;
  6. $money=(float)$money;
  7. $paybz=dgdb_tosave($paybz);
  8. $userid=(int)$userid;
  9. $username=RepPostVar($username);
  10. $ecms_paytype=RepPostVar($ecms_paytype);
  11. //验证是否重复提交
  12. $orderid=RepPostVar($orderid);
  13. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
  14. if($num)
  15. {
  16. printerror('您已成功购买 '.$fen.' 点','../../../',1,0,1);
  17. }
  18. if($fen)
  19. {
  20. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userfen')."=".egetmf('userfen')."+".$fen." where ".egetmf('userid')."='$userid'");
  21. $posttime=date("Y-m-d H:i:s");
  22. $payip=egetip();
  23. $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');");
  24. //备份充值记录
  25. BakBuy($userid,$username,$orderid,$fen,$money,0,2);
  26. }
  27. printerror('您已成功购买 '.$fen.' 点','../../../',1,0,1);
  28. }
  29. //预付款处理
  30. function PayApiPayMoney($money,$paybz,$orderid,$userid,$username,$ecms_paytype){
  31. global $empire,$dbtbpre;
  32. $money=(float)$money;
  33. $paybz=dgdb_tosave($paybz);
  34. $userid=(int)$userid;
  35. $username=RepPostVar($username);
  36. $ecms_paytype=RepPostVar($ecms_paytype);
  37. //验证是否重复提交
  38. $orderid=RepPostVar($orderid);
  39. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
  40. if($num)
  41. {
  42. printerror('您已成功存预付款 '.$money.' 元','../../../',1,0,1);
  43. }
  44. if($money)
  45. {
  46. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('money')."=".egetmf('money')."+".$money." where ".egetmf('userid')."='$userid'");
  47. $posttime=date("Y-m-d H:i:s");
  48. $payip=egetip();
  49. $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');");
  50. //备份充值记录
  51. BakBuy($userid,$username,$orderid,0,$money,0,3);
  52. }
  53. printerror('您已成功存预付款 '.$money.' 元','../../../',1,0,1);
  54. }
  55. //商城支付
  56. function PayApiShopPay($ddid,$money,$paybz,$orderid,$userid,$username,$ecms_paytype){
  57. global $empire,$dbtbpre;
  58. $ddid=(int)$ddid;
  59. $userid=(int)$userid;
  60. $username=RepPostVar($username);
  61. $ecms_paytype=RepPostVar($ecms_paytype);
  62. //验证是否重复提交
  63. $orderid=RepPostVar($orderid);
  64. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
  65. if($num)
  66. {
  67. printerror('您已成功购买此订单','../../ShopSys/buycar/',1,0,1);
  68. }
  69. $ddr=PayApiShopDdMoney($ddid);
  70. if($money==$ddr['tmoney'])
  71. {
  72. include('../../ShopSys/class/ShopSysFun.php');
  73. $money=(float)$money;
  74. $sql=$empire->query("update {$dbtbpre}enewsshopdd set haveprice=1 where ddid='$ddid'");
  75. //减少库存
  76. $shoppr=ShopSys_ReturnSet();
  77. if($shoppr['cutnumtype']==1)
  78. {
  79. $buycarr=$empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='$ddid'");
  80. Shopsys_CutMaxnum($ddid,$buycarr['buycar'],$ddr['havecutnum'],$shoppr,0);
  81. }
  82. $posttime=date("Y-m-d H:i:s");
  83. $payip=egetip();
  84. $userid=(int)$ddr[userid];
  85. $username=$ddr[username]?$ddr[username]:$ddr[truename];
  86. $username=dgdb_tosave($username);
  87. $paybz=str_replace('[!--ddno--]',$ddr[ddno],$paybz);
  88. $paybz=dgdb_tosave($paybz);
  89. $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');");
  90. }
  91. printerror('您已成功购买此订单','../../ShopSys/buycar/',1,0,1);
  92. }
  93. //商城订单金额
  94. function PayApiShopDdMoney($ddid){
  95. global $empire,$dbtbpre;
  96. $ddid=(int)$ddid;
  97. if(empty($ddid))
  98. {
  99. printerror('订单不存在','../../../',1,0,1);
  100. }
  101. $r=$empire->fetch1("select ddid,ddno,userid,username,truename,pstotal,alltotal,fptotal,pretotal,fp,payby,havecutnum from {$dbtbpre}enewsshopdd where ddid='$ddid'");
  102. if(empty($r['ddid']))
  103. {
  104. printerror('订单不存在','../../../',1,0,1);
  105. }
  106. //是否现金购买
  107. if($r['payby']!=0)
  108. {
  109. printerror('此订单为非现金支付','../../../',1,0,1);
  110. }
  111. $r['tmoney']=$r['alltotal']+$r['pstotal']+$r['fptotal']-$r['pretotal'];
  112. return $r;
  113. }
  114. //充值类型支付
  115. function PayApiBuyGroupPay($bgid,$money,$orderid,$userid,$username,$groupid,$ecms_paytype){
  116. global $empire,$dbtbpre,$level_r;
  117. $bgid=(int)$bgid;
  118. $userid=(int)$userid;
  119. $username=RepPostVar($username);
  120. $groupid=(int)$groupid;
  121. $ecms_paytype=RepPostVar($ecms_paytype);
  122. //验证是否重复提交
  123. $orderid=RepPostVar($orderid);
  124. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspayrecord where orderid='$orderid' limit 1");
  125. if($num)
  126. {
  127. printerror('您已成功充值','../../../',1,0,1);
  128. }
  129. $buyr=$empire->fetch1("select * from {$dbtbpre}enewsbuygroup where id='$bgid'");
  130. if($buyr['id']&&$money==$buyr['gmoney']&&$level_r[$buyr[buygroupid]][level]<=$level_r[$groupid][level])
  131. {
  132. $money=(float)$money;
  133. //充值
  134. $user=$empire->fetch1("select ".eReturnSelectMemberF('userdate,userid,username,groupid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid'");
  135. eAddFenToUser($buyr['gfen'],$buyr['gdate'],$buyr['ggroupid'],$buyr['gzgroupid'],$user);
  136. $posttime=date("Y-m-d H:i:s");
  137. $payip=egetip();
  138. $paybz="充值类型:".addslashes($buyr['gname']);
  139. $paybz=dgdb_tosave($paybz);
  140. $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');");
  141. //备份充值记录
  142. BakBuy($userid,$username,$buyr['gname'],$buyr['gfen'],$money,$buyr['gdate'],1);
  143. }
  144. printerror('您已成功充值','../../../',1,0,1);
  145. }
  146. ?>