0){ $model = $model->where('order.shop_supplier_id', '=', $shop_supplier_id); } return $model->alias('o_product') ->with(['image']) ->field([ '*', 'SUM(total_pay_price) AS sales_volume', 'SUM(total_num) AS total_sales_num' ])->hidden(['content']) ->join('order', 'order.order_id = o_product.order_id') ->where('order.pay_status', '=', OrderPayStatusEnum::SUCCESS) ->where('order.order_status', '<>', OrderStatusEnum::CANCELLED) ->group('o_product.product_id') ->having('total_sales_num>0') ->order(['total_sales_num' => 'DESC']) ->limit(10) ->select(); } /** * 商品浏览榜 */ public function getViewRanking($shop_supplier_id = 0) { $model = new ProductModel(); if($shop_supplier_id > 0){ $model = $model->where('shop_supplier_id', '=', $shop_supplier_id); } return $model->with(['image.file']) ->hidden(['content']) ->where('view_times', '>', 0) ->order(['view_times' => 'DESC']) ->limit(10) ->select(); } /** * 商品退款榜 */ public function getRefundRanking($shop_supplier_id = 0) { $model = new OrderRefundModel(); if($shop_supplier_id > 0){ $model = $model->where('shop_supplier_id', '=', $shop_supplier_id); } return $model->alias('order_refund') ->with(['orderproduct.image']) ->field([ '*', 'count(product_id) AS refund_count', ])->hidden(['content']) ->join('order_product', 'order_product.order_product_id = order_refund.order_product_id') ->group('order_product.product_id') ->having('refund_count>0') ->order(['refund_count' => 'DESC']) ->limit(10) ->select(); } }