Code Monkey home page Code Monkey logo

xzncit / a3mall Goto Github PK

View Code? Open in Web Editor NEW
181.0 2.0 58.0 175.75 MB

A3Mall B2C开源商城系统使用Thinkphp6开源框架,前端采用uniapp开发,支持微信公众号商城、H5商城、小程序商城、APP商城、PC商城,前后端源码100%开源,支持免费商用。

Home Page: https://www.a3-mall.com

License: GNU General Public License v3.0

PHP 5.77% Hack 5.37% HTML 0.49% CSS 2.70% Vue 3.47% JavaScript 82.17% SCSS 0.03%
thinkphp admin php shop mall alipay wechat uniapp wechat-pay

a3mall's Issues

可以讲一讲为什么后台的首页sql全都是错了的么

三条sql

        // 会员订单总数和订单总购物额
        // $order = OrderModel::field("COUNT(*) AS order_num,order_amount")->where("status",5)->find();
        $order = OrderModel::fieldRaw("COUNT(*) AS order_num,SUM(order_amount) AS order_amount")->where("status", 5)->find();
        // $usersGoodsCount = OrderModel::withJoin("users")->field("COUNT(DISTINCT order.user_id) as count")->where("order.status",5)->find();
        $usersGoodsCount = OrderModel::field('user_id')->distinct("user_id")->where("status", 5)->count();
        // 订单排行
        // $orderHot = OrderModel::withJoin("users")->field("SUM(order.order_amount) as total,COUNT(order.id) as count,users.username")->where("order.status",5)->group("order.user_id")->order("total","DESC")->limit(10)->select()->toArray();
        $orderHot = OrderModel::
            hasWhere(
                'users',
                ["Order.status" => 5],
                'Users.username,SUM(Order.order_amount) as total,COUNT(Order.id) as count'
            )
            ->group('Order.user_id')->order("total", "DESC")->limit(10)->select()->toArray();

        foreach ($orderHot as $k => $v) {
            $orderHot[$k]['p'] = $k + 1;
        }

        // $data = OrderModel::field('SUM(order_amount) as amount,count(*) as total,create_time,FROM_UNIXTIME(create_time,"%Y%m%d") as days')
        //     ->where("status", "in", "2,5")
        //     ->group('days having create_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime("-30 day"))) . ' and create_time <= ' . strtotime(date('Y-m-d 23:59:59', time())))->select()->toArray();

        $data = OrderModel::fieldRaw('SUM(order_amount) as amount,count(*) as total,FROM_UNIXTIME(create_time,"%Y%m%d") as days')
            ->where("status", "in", "2,5")
            ->where('create_time >= ' . strtotime(date('Y-m-d 00:00:00', strtotime("-30 day"))))
            ->where('create_time <= ' . strtotime(date('Y-m-d 23:59:59', time())))
            ->group('days')->select()->toArray();

一条return

        // "f"                      => empty($order["order_amount"]) ? "0.00" : number_format(($order["order_amount"] > 0 && $usersGoodsCount["count"] > 0 ? $order["order_amount"] / $usersGoodsCount["count"] : 0), 2),
        "f"                      => empty($order["order_amount"]) ? "0.00" : number_format(($order["order_amount"] > 0 && $usersGoodsCount > 0 ? $order["order_amount"] / $usersGoodsCount : 0), 2),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.