sum('stock-num'); $holdNum = ProductOrder::where('product_id', $productId)->where('status', ProductOrder::Paid)->sum('num'); return bcadd($popularNum, $holdNum); } //获取产品流通量 public static function getProductCirculation(int $productId): int { return Loader::model('ProductOrder')::where('product_id', $productId)->where('status', ProductOrder::Paid)->count(); } //获取产品有效的订单 public static function getUserProductOrder(int $uid, int $productId,string $lan): array { return Loader::model('ProductOrder')->alias('a') ->join("product_list b", "a.product_id = b.id", "left") ->field('a.id,'.'b.'.$lan.'_name as name,b.thum as img_url,a.order_no') ->where('a.product_id', $productId) ->where('a.user_id', $uid) ->where('a.status', ProductOrder::Paid) ->order('id desc') ->select(); } }