zoukankan      html  css  js  c++  java
  • ecshop 获取某个商品的 所有订单信息 或者销量

    把一下代码放到 lib_main.php

    1.统计某个下单商品的人数

    function get_goods_ordernum($goods_id){
     
            $sql = "select count(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 表示确认了的订单才算 
    return $GLOBALS['db']->getAll($sql); 
     
    }

    注意:如果有3个人下单,数量是5 ,那返回结果是3

    2.统计某个下单商品的销量,

    function get_goods_ordernum($goods_id){
     
            $sql = "select sum(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 表示确认了的订单才算 
    return $GLOBALS['db']->getAll($sql); 
     
    }

    注意:如果有3个人下单,数量是5 ,那返回结果是5

    3.统计某个商品商品订单的详细信息

    function get_goods_ordernum($goods_id){
     
            $sql = "select * from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 表示确认了的订单才算 
    return $GLOBALS['db']->getAll($sql); 
     
    }
    order_status in(1,5)   1表示去人订单,5表示已分单


    完整php代码
    /*获取有效订单信息*/
    function sales_goods_order($goods_id){    
        $sql = "select * from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 1表示确认订单,5已分单
    return $GLOBALS['db']->getAll($sql); 
    }
    /*获取某个商品有效订单  销量统计*/
    function sales_goods_number($goods_id){    
        $arr = sales_goods_order($goods_id);
        //return array_sum($arr['goods_number']);
        foreach($arr as $k=>$v){
            $val[] = $v['goods_number'];    
        }
        $count = array_sum($val);
        if(!empty($count)){
            return $count;    
        }else{
            return '0';    
        }
    }
  • 相关阅读:
    遍历Newtonsoft.Json.Linq.JObject
    JSON中JObject和JArray,JValue序列化(Linq)
    RabbitMQ学习系列二:.net 环境下 C#代码使用 RabbitMQ 消息队列
    RabbitMQ学习系列三:.net 环境下 C#代码订阅 RabbitMQ 消息并处理
    RabbitMQ学习系列一:windows下安装RabbitMQ服务
    红帽企业版Linux成为Linux下的.NET Core的参考平台
    LINUX下SYN FLOOD攻击及LINUX下SYN攻防简述
    Linux下tar命令的各种参数选项和他们的作用整理
    异常值监测的方法 Tukey test
    Git如何回滚代码?
  • 原文地址:https://www.cnblogs.com/wesky/p/4861883.html
Copyright © 2011-2022 走看看