• ecshop获取商品销量函数


    以下函数会获取订单状态为已完成的订单中该商品的销量,此函数放在lib_goods.php文件中即可调用

    /**
     * 获取商品销量
     *
     * @access      public
     * @param       string      $goods_id
     * @return      int
     */
    function selled_count($goods_id)
    {
     $sql = 'SELECT SUM(og.goods_number) as count ' .
               'FROM ' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' .
               'LEFT JOIN ' .$GLOBALS['ecs']->table('order_info') . ' AS o ' .
               "ON og.order_id = o.order_id " .
               "WHERE (o.order_status = '" . OS_CONFIRMED .  "' OR o.order_status = '" . OS_SPLITED . "') " .
               "AND (o.pay_status = '" . PS_PAYED . "' OR o.pay_status = '" . PS_PAYING . "') " .
               "AND (o.shipping_status = '" . SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') " .
               "AND og.goods_id ='" .$goods_id . "'";
     $res = $GLOBALS['db']->getOne($sql);
     if($res>0)
     {
      return $res;
     }
     else
     {
      return('0');
     }
    }

  • 相关阅读:
    E
    C
    航空母舰-03
    航空母舰-02
    航空母舰-01
    新概念4-30
    html
    翁凯-编程学习方法
    机器学习Ng-02
    民法-钟秀勇-导学
  • 原文地址:https://www.cnblogs.com/sakura-panda/p/3469898.html
Copyright © 2020-2023  润新知