setBaseQuery('order', [ ['order_goods', 'order_id'], ]) ->where('order_goods.user_id', '=', $userId) ->where('order_goods.goods_id', '=', $goodsId) ->where('order.order_source', '=', OrderSourceEnum::SHARP) ->where('order.order_status', '<>', OrderStatusEnum::CANCELLED) ->where('order.is_delete', '=', 0) ->sum('order_goods.total_num'); return $totalNum; } }