关于帝国的内置商城常见问题
1、订单金额为负数
如果购买金额为1.99,优惠券的金额为3,那么在使用优惠券的时候,帝国默认是存入1.99 和 3,那么 购买金额则为 1.99 - 3 = - 1.01 ,这个时候就会造成负金额订单,处理加入订单的逻辑,使之如果减掉优惠券以后的金额小于0,那么优惠金额 等同于 购买金额
修改几个地方,将所有涉及到金额的部分,作保留两位小数处理:
PHP Code复制内容到剪贴板
- $price = number_format($price,2);
增加订单function:
/e/ShopSys/class/
PHP Code复制内容到剪贴板
- function AddDd($add){
//支付金额
$buyallfen=$alltotalfen+$pr['price'];
$buyallmoney = $alltotal+$pr['price']+$fptotal-$pretotal;
$buyallmoney = number_format($buyallmoney,2);
//如果支付金额为负,那么优惠金额 等于 购买金额,金额处理为0
if($buyallmoney < 0)
{
$pretotal = $alltotal;
$buyallmoney = 0;
}
/e/payapi/payfun.php
PHP Code复制内容到剪贴板
- //商城订单金额
- function PayApiShopDdMoney($ddid){
$r['tmoney'] = $r['alltotal']+$r['pstotal']+$r['fptotal']-$r['pretotal'];
$r['tmoney'] = number_format($r['tmoney'],2);
return $r;
2、新增发送邮件通知函数:
传$dd的数组,和订单ID,这里还要传一个数组,是因为之前的函数中应该已经对订单表查询过了,这里就不再重复查询
PHP Code复制内容到剪贴板
- /**
- * @param array $dd
- * @param $ddid
- * @return bool
- */
- function sendMail($dd = array(),$ddid){
- global $dbtbpre,$empire;
- require(ECMS_PATH.'e/class/SendEmail.inc.php');
- $email = array('398927951@qq.com','xxxx@qq.com');
- $addr=$empire->fetch1("select buycar,bz from {$dbtbpre}enewsshopdd_add where ddid='$ddid' limit 1");
- $buycar = $addr['buycar'];
- $beizhu = $addr['bz'];
- $payby=$dd['payby'];
- $shop = '';
- $record="!";
- $field="|";
- $totalmoney=0;
- $totalfen=0;
- $buycarr=explode($record,$buycar);
- $bcount=count($buycarr);
- $j=0;
- for($i=0;$i<$bcount-1;$i++) {
- $j++;
- $pr = explode($field, $buycarr[$i]);
- $productid = $pr[1];
- $fr = explode(",", $pr[1]);
- //ID
- $classid = (int)$fr[0];
- $id = (int)$fr[1];
- //属性
- $addatt = '';
- if ($pr[2]) {
- $addatt = $pr[2];
- }
- //数量
- $pnum = (int)$pr[3];
- if ($pnum < 1) {
- $pnum = 1;
- }
- //单价
- $price = $pr[4];
- $thistotal = $price * $pnum;
- $buyfen = $pr[5];
- $thistotalfen = $buyfen * $pnum;
- if ($payby == 1) {
- $showprice = $buyfen . " 点";
- $showthistotal = $thistotalfen . " 点";
- } else {
- $showprice = $price;
- $showthistotal = $thistotal;
- }
- //产品名称
- $title = stripSlashes($pr[6]);
- //返回链接
- $titleurl = "../../public/InfoUrl/?classid=$classid&id=$id";
- $totalmoney += $thistotal;
- $totalfen += $thistotalfen;
- $add = $addatt?' - '.$addatt:'';
- $shop .= $title.$add.'('.$showprice.' * '.$pnum.')= '.$showthistotal.'<br>';
- }
- $title = '您有新的水果订单,订单ID:'.$ddid;
- $text = '订单ID:'.$ddid.'<br>';
- $text .= '订单号:'.$dd['ddno'].'<br>';
- $text .= '下单时间:'.$dd['ddtime'].'<br>';
- $text .= '真实姓名:'.$dd['truename'].'<br>';
- $text .= '移动电话:'.$dd['phone'].'<br>';
- $text .= '固定电话:'.$dd['mycall'].'<br>';
- $text .= '发货地址:'.$dd['address'].'<br>';
- $text .= '指定送货时间:'.$dd['besttime'].'<br>';
- $text .= '订单金额:'.$dd['alltotal'].'<br>';
- $text .= '优惠金额 :'.$dd['pretotal'].'<br>';
- $text .= '实付金额 :'.number_format($dd['alltotal']-$dd['pretotal'],2).'<br>';
- $text .= '备注:'.$beizhu.'<br>';
- $text .= "商品清单:<br><br>";
- $text .= $shop;
- $text .= "<br>订单号若重复,请忽略此邮件!";
- $sm = EcmsToSendMail($email,$title,$text);
- if(!$sm){
- EcmsToSendMail($email,$title,$text);
- };
- return true;
- }
3、关于同一个订单号发送支付请求时,由于修改了价格,支付端返回错误:商户订单号重复,在发起未支付继续支付的请求时,同时改变订单号即可:
/e/ShopSys/class/ShopSysFun.php
//未付款的继续支付
function ShopDdToPay($ddid){
PHP Code复制内容到剪贴板
- /* 重新生成订单号并更新入库,更新失败提示信息 */
- $new_ddno = ShopSys_ReturnDdNo();
- $new_ddno = RepPostVar($new_ddno);
- $res = $empire->query("update {$dbtbpre}enewsshopdd set `ddno`='{$new_ddno}' where `ddid`=$ddid");
- if(!$res){
- printerror2('重新发起支付操作失败,请联系管理员',"history.go(-1)");
- };
- /* 修改完毕 */
- //支付方式
- $payr=$empire->fetch1("select payid,payurl from {$dbtbpre}enewsshoppayfs where payid='$r[payfsid]' and isclose=0");
- if(!$payr['payid']||!$payr['payurl'])
- {
- printerror("NotPayfsid","history.go(-1)",1);
- }
4、 关于获取不到cookie中的payphome操作
e/payapi/BuyGroupPay.php :
PHP Code复制内容到剪贴板
- esetcookie("payphome","BuyGroupPay",0);
- esetcookie("paymoneybgid",$id,0);
- $payphome = getcvar("payphome");
- if(!$payphome) {
- $payphome = "BuyGroupPay";
- $paymoneybgid = $id;
- }
e/payapi/ShopPay.php:
PHP Code复制内容到剪贴板
- esetcookie("payphome","ShopPay",0);
- $payphome = getcvar("payphome");
- if(!$payphome) {
- $payphome = "ShopPay";
- }
e/payapi/pay.php:
PHP Code复制内容到剪贴板
- esetcookie("payphome",$phome,0);
- $payphome = getcvar("payphome");
- if(!$payphome) {
- $payphome = $phome;
- }