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 = (double) $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 ShopSys_TimeCutMaxnum($userid, $shoppr) { global $empire, $dbtbpre, $class_r; if ($shoppr['cutnumtype'] == 1 || $shoppr['cutnumtime'] == 0) { return ''; } $userid = (int) $userid; $where = $userid ? "userid='{$userid}' and " : ""; $time = time() - $shoppr['cutnumtime'] * 60; $ddsql = $empire->query("select ddid,havecutnum from {$dbtbpre}enewsshopdd where " . $where . "haveprice=0 and checked=0 and havecutnum=1 and ddtruetime<{$time}"); while ($ddr = $empire->fetch($ddsql)) { $ddaddr = $empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='{$ddr['ddid']}'"); Shopsys_CutMaxnum($ddr['ddid'], $ddaddr['buycar'], $ddr['havecutnum'], $shoppr, 1); } $empire->query("update {$dbtbpre}enewsshopdd set checked=2 where " . $where . "haveprice=0 and checked=0 and havecutnum=1 and ddtruetime<{$time}"); }