Ecshop后臺(tái)的訂單數(shù)據(jù)統(tǒng)計(jì)不正確,問(wèn)題出在order_status.php文件function get_orderinfo($start_date, $end_date)的定義,其中所有的sql都用了下面的代碼:
function get_orderinfo($start_date, $end_date){$order_info = array();/* 未確認(rèn)訂單數(shù) */$sql = 'SELECT COUNT(*) AS unconfirmed_num FROM ' .$GLOBALS['ecs']->table('order_info')." WHERE order_status = '" .OS_UNCONFIRMED. "' AND add_time >= '$start_date'". " AND add_time < '" . ($end_date + 86400) . "'";
很顯然,這里有個(gè)很明顯的邏輯錯(cuò)誤,即$end_date+86400,除非這里用戶選擇的開(kāi)始時(shí)間和結(jié)束時(shí)間是同一天,否則沒(méi)有必要加上86400(86400秒等于1天),這個(gè)錯(cuò)誤結(jié)果會(huì)導(dǎo)致最后的訂單統(tǒng)計(jì)數(shù)量已經(jīng)不是在指定時(shí)間段內(nèi)的數(shù)據(jù),而是指定的時(shí)間后再加上一天。
另外Ecshop自己本身訂單確認(rèn)功能,導(dǎo)致的默認(rèn)訂單統(tǒng)計(jì)頁(yè)面,只顯示未確認(rèn),已確認(rèn),已成交,無(wú)效這四個(gè)信息。這四個(gè)信息都不包括最最重要的已付款的訂單數(shù)的信息
只要將無(wú)用的已確認(rèn)訂單統(tǒng)計(jì)代碼改成已支付的統(tǒng)計(jì)代碼:
/* 已確認(rèn)訂單數(shù) */ $sql = 'SELECT COUNT(*) AS confirmed_num FROM ' .$GLOBALS['ecs']->table('order_info'). " WHERE order_status = '" .OS_CONFIRMED. "' AND shipping_status NOT ". db_create_in(array(SS_SHIPPED, SS_RECEIVED)) . " AND pay_status NOT" . db_create_in(array(PS_PAYED, PS_PAYING)) ." AND add_time >= '$start_date'". " AND add_time < '" . ($end_date + 86400) . "'"; $order_info['confirmed_num'] = $GLOBALS['db']->getOne($sql);
改成:
/* by tiandi 已支付訂單數(shù) */ $sql = 'SELECT COUNT(*) AS confirmed_num FROM ' .$GLOBALS['ecs']->table('order_info'). " WHERE pay_status =" . PS_PAYED ." AND shipping_status NOT" . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) ." AND add_time >= '$start_date'". " AND add_time < $end_date"; $order_info['confirmed_num'] = $GLOBALS['db']->getOne($sql);
即可修復(fù)ecshop統(tǒng)計(jì)不準(zhǔn)備問(wèn)題。
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 修正Ecshop后臺(tái)訂單統(tǒng)計(jì)數(shù)據(jù)不準(zhǔn)確BUG