網(LieHuo.Net)教程 大家都知道,會員在會員中心預定了廣告,默認是不會扣除相應的資金的,現在我給大家暫時解決了這個BUG。下面是解決方法:
第一步; 打開ads/include/ads.class.php找到$this->table = DB_PRE.'ads';
在其下添加$this->pay = load('pay_api.class.php', 'pay', 'api');
第二步; 找到function __destruct()
{
}
在其下添加function adsamount($adsid)
{
$adsid = intval($adsid);
$price=$this->db->get_one("SELECT a.username,a.passed,b.price FROM `".DB_PRE."ads` `a` ,`".DB_PRE."ads_place` `b` WHERE a.placeid=b.placeid AND a.adsid=$adsid");
if($price['price']>0 && $price['passed']==0 && $price['username'] !='phpcms')//這里的PHPcms 請改為管理員的用戶名
{
$userid=$this->db->get_one("SELECT userid FROM ".DB_PRE."member_cache WHERE username='$price[username]'");
$this->pay->update_exchange('ads', 'amount',-$price['price'], "廣告位預定扣費",$userid[userid]);//amount 為資金 point為點數
}
return TRUE;
}
這一句有個小修改 注意看注釋哦
第三步;找到$where = ' adsid='.$this->adsid;
在其上 添加$this->adsamount($adsid);
第四步; 找到function update($arrid, $val)
{
$val = intval($val);
if(is_array($arrid))
{
$ids = implode(',', $arrid);
}
else
{
$ids = intval($arrid);
}
$this->db->query("UPDATE $this->table SET passed=$val WHERE adsid IN ($ids)");
return TRUE;
}
替換成function update($arrid, $val)
{
$val = intval($val);
if(is_array($arrid))
{
foreach($arrid as $adsid)
{
$adsid=intval($adsid);
$this->adsamount($adsid);
$this->db->query("UPDATE $this->table SET passed=$val WHERE adsid=$adsid");
}
return TRUE;
}
else
{
$adsid=intval($adsid);
$this->adsamount($adsid);
$this->db->query("UPDATE $this->table SET passed=$val WHERE adsid=$adsid");
return TRUE;
}
}
好了 到這里扣點數的文件已經完全改好了,可以測試了,下面的用于前臺資金不足以支付廣告位時的判斷
打開 ads/sign.php 找到if(!$priv_group->check('p_adsid', $placeid, 'input', $_groupid)) showmessage($LANG['not_add'], 'goback');
在其下添加$price=$db->get_one("SELECT price FROM `".DB_PRE."ads_place` WHERE placeid=$placeid");
if($price['price']>$_amount)showmessage('對不起,您的余額不足,請充值以后再試', 'goback');
打開廣告模板 templates/default/ads/index.html 找到<a href="{$M[url]}sign.php?placeid={$place['placeid']}">我要預訂</A>
替換成{if $_amount>=$place['price']}<a href="{$M[url]}sign.php?placeid={$place['placeid']}">我要預訂</A> {else}<a href="/pay/pay.php" title="對比起,您的余額不注意支付本訂單,請先充值">余額不足</a>{/if}
OK 完工 測試去吧
上一篇 php正則表達式匹配中文