/b2b/core/model/system/mdl.status.php
PHP | 191 lines | 152 code | 23 blank | 16 comment | 7 complexity | 0927bdb4a959352e12c45a0571a069b0 MD5 | raw file
- <?php
- class mdl_status extends modelFactory {
- function getList(){
- $return = array();
- foreach($this->db->select('select * from sdb_status where date_affect="0000-00-00"') as $row){
- $return[$row['status_key']] = $row['status_value'];
- }
- return $return;
- }
- function add($key,$value=1,$skip_history=false){
- $key = strtoupper($key);
- if(!$skip_history){
- $this->_add_value($key,date('Y-m-d'),$value);
- }
- $this->_add_value($key,'0000-00-00',$value);
- return true;
- }
- function _add_value($key,$date,$value){
- if(false!==$this->get($key,$date)){
- $this->db->exec('update sdb_status set status_value=status_value+'.floatval($value).' where status_key=\''.$key.'\' and date_affect="'.$date.'"');
- }else{
- $this->set($key,$this->get($key,$date)+$value,$date);
- }
- }
- function set($key,$value,$date='0000-00-00'){
- $key = strtoupper($key);
- $rs = $this->db->exec('select * from sdb_status where status_key=\''.$key.'\' and date_affect="'.$date.'"');
- $sql = $this->db->getUpdateSQL($rs,array('status_key'=>$key,'status_value'=>$value,'last_update'=>time(),'date_affect'=>$date),true);
- return $this->db->exec($sql);
- }
- function get($key,$date='0000-00-00'){
- $key = strtoupper($key);
- if($row = $this->db->selectrow('select status_value from sdb_status where status_key=\''.$key.'\' and date_affect="'.$date.'"')){
- return $row['status_value'];
- }else{
- return false;
- }
- }
- function cleanup(){
- return $this->db->exec('delete from sdb_status where date_affect < "'.date('Y-m-d',time()-24*30).'"');
- }
- function update($force_count=false){
- $in_lib = $this->getList();
- foreach(get_class_methods($this) as $func){
- if(substr($func,0,6)=='count_'){
- if($force_count || !isset($in_lib[strtoupper(substr($func,6))])){
- $this->$func();
- }
- }
- }
- }
- function _update_count($func,$count){
- return $this->set(substr($func,6),$count);
- }
- //?????
- function count_order_new(){
- $oOrder = &$this->system->loadModel('trading/order');
- $filter['status'] = 'active';
- $filter['pay_status'] = array(0);
- $filter['ship_status'] = array(0);
- $filter['disabled'] = 'false';
- $filter['confirm'] = 'N';
- $count = $oOrder->count($filter);
- return $this->_update_count(__FUNCTION__,$count);
- }
- //???????
- function count_gnotify(){
- $oNotify = &$this->system->loadModel('goods/goodsNotify');
- $filter['status'] = 'ready';
- $filter['disabled'] = 'false';
- $count = $oNotify->count($filter);
- return $this->_update_count(__FUNCTION__,$count);
- }
- //??????
- function count_galert(){
- $oProduct = &$this->system->loadModel('goods/finderPdt');
- $oGoods = &$this->system->loadModel('goods/products');
- $filter_p['store_alarm'] = $this->system->getConf('system.product.alert.num');
- foreach($oProduct->getList('goods_id', $filter_p, 0, -1) as $row){
- $filter['goods_id'][] = $row['goods_id'];
- }
- $filter['goods_id'] = array_unique($filter['goods_id']);
- if(empty($filter['goods_id'])) $filter['goods_id'][] = -1;
- unset($filter_p);
- $filter['disabled'] = 'false';
- $filter['marketable'] = 'true';
- $count = $oGoods->count($filter);
- return $this->_update_count(__FUNCTION__,$count);
- }
- //???????
- function count_gdiscuss(){
- $oDiscuss = &$this->system->loadModel('comment/discuss');
- $filter['adm_read_status'] = 'false';
- $filter['disabled'] = 'false';
- $count = $oDiscuss->count($filter);
- return $this->_update_count(__FUNCTION__,$count);
- }
- //???????
- function count_gask(){
- $oGask = &$this->system->loadModel('comment/gask');
- $filter['adm_read_status'] = 'false';
- $filter['disabled'] = 'false';
- $count = $oGask->count($filter);
- return $this->_update_count(__FUNCTION__,$count);
- }
- //???????
- function count_messages(){
- $oBBS = &$this->system->loadModel('resources/shopbbs');
- $filter['unread'] = 0;
- $filter['disabled'] = 'false';
- $count = $oBBS->count($filter);
- return $this->_update_count(__FUNCTION__,$count);
- }
-
- // ?????
- // Add By Gesion
- function count_msgbox() {
- $oMsg = &$this->system->loadModel('resources/msgbox');
- $filter['unread'] = 0;
- $filter['disabled'] = 'false';
- $count = $oMsg->count($filter);
- return $this->_update_count(__FUNCTION__, $count);
- }
- //?????
- function count_order_to_pay(){
- $sales = &$this->system->loadModel('utility/salescount');
- $count=$sales->orderWithoutPay();
- return $this->_update_count(__FUNCTION__,$count);
- }
- //????????
- function count_order_to_dly(){
- $sales = &$this->system->loadModel('utility/salescount');
- $count=$sales->playWithoutDeliever();
- return $this->_update_count(__FUNCTION__,$count);
- }
- //????
- function count_goods_online(){
- $oGoods = &$this->system->loadModel('goods/products');
- $count=$oGoods->getMarketGoods('true');
- return $this->_update_count(__FUNCTION__,$count);
- }
- //?????
- function count_goods_hidden(){
- $oGoods = &$this->system->loadModel('goods/products');
- $count=$oGoods->getMarketGoods('false');
- return $this->_update_count(__FUNCTION__,$count);
- }
-
- //????
- function count_drawdeposit_process(){
- $sql = 'SELECT * FROM sdb_drawdeposit_apply WHERE `status` = "progress"';
- return $this->db->_count($sql);
- }
-
- //????
- function count_offlinepay_process(){
- $sql = 'SELECT * FROM sdb_offlinepay_log WHERE `status` = "1"';
- return $this->db->_count($sql);
- }
- //????
- function count_kickback(){
- $sql = 'SELECT * FROM sdb_kickback_setting WHERE end_time > '.time().' AND (begin_time <= '.time().' OR notice_time >0 AND notice_time<= '.time().') AND pub="true"';
- return $this->db->_count($sql);
- }
- //???
- function count_orderactivity(){
- $sql = 'SELECT * FROM sdb_order_activity WHERE end_time > '.time().' AND (begin_time <= '.time().' OR notice_time >0 AND notice_time<= '.time().')';
- return $this->db->_count($sql);
- }
- }
- ?>