<tr> <td height="23" bgcolor="#EFEFEF"><strong>选择的商品</strong></td> </tr> <tr> <td> <?php include 'buycar/buycar_order.php'; $totalr = array(); $totalr['totalmoney'] = $totalmoney; $totalr['buytype'] = $buytype; $totalr['totalfen'] = $totalfen; //优惠码 $prer = array(); $pretotal = 0; if ($r['precode']) { $prer = ShopSys_GetPre($r['precode'], $totalr['totalmoney'], $user, $classids); $pretotal = ShopSys_PreMoney($prer, $totalr['totalmoney']); } $totalr['pretotal'] = $pretotal; $totalr['truetotalmoney'] = $totalr['totalmoney'] - $pretotal; ?> </td> </tr> <tr> <td height="23" bgcolor="#EFEFEF"><strong>收货人信息</strong></td> </tr> <tr> <td><table width="100%%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="20%">真实姓名:</td> <td width="80%">
function AddDd($add) { global $empire, $public_r, $dbtbpre; $shoppr = ShopSys_ReturnSet(); //验证权限 ShopCheckAddDdGroup($shoppr); //购物车无内容 if (!getcvar('mybuycar')) { printerror("EmptyBuycar", "history.go(-1)", 1); } $add[ddno] = RepPostVar($add[ddno]); $add[truename] = RepPostStr($add[truename]); $add[oicq] = RepPostStr($add[oicq]); $add[msn] = RepPostStr($add[msn]); $add[mycall] = RepPostStr($add[mycall]); $add[phone] = RepPostStr($add[phone]); $add[email] = RepPostStr($add[email]); $add[address] = RepPostStr($add[address]); $add[zip] = RepPostStr($add[zip]); $add[signbuild] = RepPostStr($add[signbuild]); $add[besttime] = RepPostStr($add[besttime]); $add[bz] = RepPostStr($add[bz]); $add[fptt] = RepPostStr($add[fptt]); $add[fpname] = RepPostStr($add[fpname]); $add[fp] = (int) $add[fp]; $add[psid] = (int) $add[psid]; $add[payfsid] = (int) $add[payfsid]; $add['precode'] = RepPostVar($add['precode']); //基本必填 if (!$add['ddno']) { printerror("EmptyBuycar", "history.go(-1)", 1); } //必填项 ShopSys_CheckDdMust($add, $shoppr); $mess = "AddDdSuccess"; $haveprice = 0; $payby = 0; //返回购物车存放格式 $buyr = ReturnBuycardd($shoppr); $alltotal = $buyr[2]; $alltotalfen = $buyr[1]; $buycar = $buyr[3]; $classids = $buyr['classids']; //配送方式 $pr = array(); if ($shoppr['shoppsmust']) { $pr = $empire->fetch1("select pid,pname,price from {$dbtbpre}enewsshopps where pid='{$add['psid']}' and isclose=0"); if (empty($pr['pid'])) { printerror("NotPsid", "history.go(-1)", 1); } } //支付方式 $payr = array(); if ($shoppr['shoppayfsmust']) { $payr = $empire->fetch1("select payid,payname,payurl,userpay,userfen from {$dbtbpre}enewsshoppayfs where payid='{$add['payfsid']}' and isclose=0"); if (empty($payr['payid'])) { printerror("NotPayfsid", "history.go(-1)", 1); } } //取得用户信息 $user = array(); $userid = (int) getcvar('mluserid'); $username = RepPostVar(getcvar('mlusername')); if ($userid) { $rnd = RepPostVar(getcvar('mlrnd')); $user = $empire->fetch1("select " . eReturnSelectMemberF('userid,money,userfen,groupid') . " from " . eReturnMemberTable() . " where " . egetmf('userid') . "='{$userid}' and " . egetmf('rnd') . "='{$rnd}' limit 1"); if (!$user['userid']) { printerror("MustSingleUser", "history.go(-1)", 1); } } //优惠 $prer = array(); $pretotal = 0; if ($add['precode']) { $prer = ShopSys_GetPre($add['precode'], $alltotal, $user, $classids); $pretotal = ShopSys_PreMoney($prer, $alltotal); } //运费 $truetotalmoney = $alltotal - $pretotal; if ($pr['pid']) { $pr['price'] = ShopSys_PrePsTotal($pr['pid'], $pr['price'], $truetotalmoney, $shoppr); } //发票 $fptotal = 0; if ($add[fp]) { $fptotal = ($alltotal - $pretotal) * ($shoppr['fpnum'] / 100); } //支付金额 $buyallfen = $alltotalfen + $pr['price']; $buyallmoney = $alltotal + $pr['price'] + $fptotal - $pretotal; if ($buyallmoney < 0) { $buyallmoney = 0; } $location = "buycar/"; if ($payr[userfen]) { if ($buyr[0]) { printerror("NotProductForBuyfen", "history.go(-1)", 1); } else { if ($userid) { $buyallfen = $alltotalfen + $pr[price]; if ($buyallfen > $user['userfen']) { printerror("NotEnoughFenBuy", "history.go(-1)", 1); } //扣除点数 $usql = $empire->query("update " . eReturnMemberTable() . " set " . egetmf('userfen') . "=" . egetmf('userfen') . "-" . $buyallfen . " where " . egetmf('userid') . "='{$userid}'"); if ($usql) { $mess = "AddDdSuccessa"; $payby = 1; $haveprice = 1; } } else { printerror("NotLoginTobuy", "history.go(-1)", 1); } } } elseif ($payr[userpay]) { if ($userid) { $buyallmoney = $alltotal + $pr[price] + $fptotal - $pretotal; if ($buyallmoney < 0) { $buyallmoney = 0; } if ($buyallmoney > $user['money']) { printerror("NotEnoughMoneyBuy", "history.go(-1)", 1); } //扣除金额 $usql = $empire->query("update " . eReturnMemberTable() . " set " . egetmf('money') . "=" . egetmf('money') . "-" . $buyallmoney . " where " . egetmf('userid') . "='{$userid}'"); if ($usql) { $mess = "AddDdSuccessa"; $payby = 2; $haveprice = 1; } } else { printerror("NotLoginTobuy", "history.go(-1)", 1); } } elseif ($payr[payurl]) { $mess = "AddDdAndToPaySuccess"; $location = $payr[payurl]; } else { } $ddtime = date("Y-m-d H:i:s"); $ddtruetime = time(); $ip = egetip(); $pr[price] = (double) $pr[price]; $alltotal = (double) $alltotal; $alltotalfen = (double) $alltotalfen; $fptotal = (double) $fptotal; $pretotal = (double) $pretotal; $sql = $empire->query("insert into {$dbtbpre}enewsshopdd(ddno,ddtime,userid,username,outproduct,haveprice,checked,truename,oicq,msn,email,`mycall`,phone,address,zip,psid,psname,pstotal,alltotal,payfsid,payfsname,payby,alltotalfen,fp,fptt,fptotal,fpname,userip,signbuild,besttime,pretotal,ddtruetime) values('{$add['ddno']}','{$ddtime}',{$userid},'{$username}',0,'{$haveprice}',0,'{$add['truename']}','{$add['oicq']}','{$add['msn']}','{$add['email']}','{$add['mycall']}','{$add['phone']}','{$add['address']}','{$add['zip']}','{$add['psid']}','{$pr['pname']}',{$pr['price']},{$alltotal},'{$add['payfsid']}','{$payr['payname']}','{$payby}',{$alltotalfen},{$add['fp']},'{$add['fptt']}',{$fptotal},'{$add['fpname']}','{$ip}','{$add['signbuild']}','{$add['besttime']}','{$pretotal}','{$ddtruetime}');"); $ddid = $empire->lastid(); $sqladd = $empire->query("insert into {$dbtbpre}enewsshopdd_add(ddid,buycar,bz,retext) values('{$ddid}','" . addslashes($buycar) . "','{$add['bz']}','');"); //减库存 if ($shoppr['cutnumtype'] == 0) { Shopsys_CutMaxnum($ddid, $buycar, 0, $shoppr, 0); } else { if ($haveprice == 1) { Shopsys_CutMaxnum($ddid, $buycar, 0, $shoppr, 0); } } //优惠码 if ($prer['id']) { $prer['id'] = (int) $prer['id']; if ($prer['reuse'] == 0) { $empire->query("delete from {$dbtbpre}enewsshop_precode where id='" . $prer['id'] . "'"); } elseif ($prer['reuse'] && $prer['usenum']) { if ($prer['usenum'] <= $prer['haveusenum'] + 1) { $empire->query("delete from {$dbtbpre}enewsshop_precode where id='" . $prer['id'] . "'"); } else { $empire->query("update {$dbtbpre}enewsshop_precode set haveusenum=haveusenum+1 where id='" . $prer['id'] . "'"); } } } if ($sql) { $set = esetcookie("paymoneyddid", $ddid, 0); SetBuycar(""); printerror($mess, $location, 1); } else { printerror("DbError", "history.go(-1)", 1); } }