标签:
把一下代码放到 lib_main.php
/*获取有效订单信息*/ function sales_goods_order($goods_id){ $sql = ‘select order_id from ‘ . $GLOBALS[‘ecs‘]->table(‘order_goods‘).‘where goods_id=‘.$goods_id; /*order_goods 提取order_id*/ $res = $GLOBALS[‘db‘]->getAll($sql); foreach($res as $k=>$v){ $order_id_arr[] = $v[‘order_id‘]; } $order_status = ‘1,5‘; /*1:已分单,5:已确认 满足条件中的任何一个 ,就计算销量*/ $order_id = implode(‘,‘,$order_id_arr); $sql = ‘select * from ‘ . $GLOBALS[‘ecs‘]->table(‘order_info‘).‘where order_status in(‘.$order_status.‘) and order_id in (‘.$order_id.‘)‘; $result = $GLOBALS[‘db‘]->getAll($sql); return $result; /*返回有效的订单信息*/ } /*获取某个商品有效订单 销量统计*/ function sales_goods_number($goods_id){ return count(sales_goods_order($goods_id)); }
标签:
原文地址:http://www.cnblogs.com/wesky/p/4861883.html