renlok / WeBid

The official WeBid github fork
http://www.webidsupport.com
114 stars 125 forks source link

Lower bids added to winners table? #499

Open robberteggermont opened 6 years ago

robberteggermont commented 6 years ago

After an item sold, all the bids (both the highest and all lower bids) were added to the winners table). This happened for a lot of items. I've no clue yet what went wrong (I've looked at the code in cron.php but on first sight couldn't see a problem).

MESWEB commented 6 years ago

Here should be a problem:

 // get an order list of bids of the item (high to low)
    $winner_present = false;
    $query = "SELECT u.* FROM " . $DBPrefix . "bids b
            LEFT JOIN " . $DBPrefix . "users u ON (b.bidder = u.id)
            WHERE auction = :auc_id ORDER BY b.bid DESC, b.quantity DESC, b.id DESC";
    $params = array();
    $params[] = array(':auc_id', $Auction['id'], 'int');
    $db->query($query, $params);
    $num_bids = $db->numrows();

    // send email to seller - to notify him
    // create a "report" to seller depending of what kind auction is
    // Standard auction
    if ($Auction['auction_type'] == 1) {
        if ($num_bids > 0 && ($Auction['current_bid'] >= $Auction['reserve_price'] || $Auction['sold'] == 's')) {
            $Winner = $db->result();
            $Winner['quantity'] = $Auction['quantity'];
            $WINNING_BID = $Auction['current_bid'];
            $winner_present = true;
        }

        if ($winner_present && $Auction['bn_only'] == 0) {
            $report_text = $Winner['nick'] . "\n";
            if ($system->SETTINGS['users_email'] == 'n') {
                $report_text .= ' (<a href="mailto:' . $Winner['email'] . '">' . $Winner['email'] . '</a>)' . "\n";
            }
            if ($Winner['address'] != '') {
                $report_text .= $MSG['30_0086'] . $Winner['address'] . ' ' . $Winner['city'] . ' ' . $Winner['prov'] . ' ' . $Winner['zip'] . ', ' . $Winner['country'];
            }
            $bf_paid = 1; // buyer fee payed?
            $ff_paid = 1; // auction end fee payed?
            // work out & add fee
            if ($system->SETTINGS['fees'] == 'y') {
                sortFees();
            }

            // Add winner's data to "winners" table
            $query = "INSERT INTO " . $DBPrefix . "winners
                (auction, seller, winner, bid, feedback_win, feedback_sel, qty, paid, bf_paid, ff_paid, shipped, auc_title, auc_shipping_cost, auc_payment) VALUES
                (:auc_id, :seller_id, :winner_id, :current_bid, 0, 0, 1, 0, :bf_paid, :ff_paid, 0, :auc_title, :auc_shipping_cost, :auc_payment)";
            $params = array();
            $params[] = array(':auc_id', $Auction['id'], 'int');
            $params[] = array(':seller_id', $Seller['id'], 'int');
            $params[] = array(':winner_id', $Winner['id'], 'int');
            $params[] = array(':current_bid', $Auction['current_bid'], 'float');
            $params[] = array(':bf_paid', $bf_paid, 'int');
            $params[] = array(':ff_paid', $ff_paid, 'int');
            $params[] = array(':auc_title', $Auction['title'], 'str');
            $params[] = array(':auc_shipping_cost', calculate_shipping_data($Auction), 'float');
            $params[] = array(':auc_payment', $Auction['payment'], 'str');
            $db->query($query, $params);

Here is missing if statement

if ($Auction['auction_type'] == 1 && MAX($num_bids))

Or something like that.

robberteggermont commented 6 years ago

For clearity, you're referring to cron.php line 98 onwards.

I focussed on this code, but I see only one insert there, and no loop over all bids.

I (still) don't see the problem in this code...?

On 29-10-17 23:25, MESWEB wrote:

Here should be a problem:

// get an order list of bids of the item (high to low) $winner_present = false; $query = "SELECT u.* FROM " . $DBPrefix . "bids b LEFT JOIN " . $DBPrefix . "users u ON (b.bidder = u.id) WHERE auction = :auc_id ORDER BY b.bid DESC, b.quantity DESC, b.id DESC"; $params = array(); $params[] = array(':auc_id', $Auction['id'], 'int'); $db->query($query, $params); $num_bids = $db->numrows();

// send email to seller - to notify him // create a "report" to seller depending of what kind auction is // Standard auction if ($Auction['auction_type'] == 1) { if ($num_bids > 0 && ($Auction['current_bid'] >= $Auction['reserve_price'] || $Auction['sold'] == 's')) { $Winner = $db->result(); $Winner['quantity'] = $Auction['quantity']; $WINNING_BID = $Auction['current_bid']; $winner_present = true; }

if ($winner_present && $Auction['bn_only'] == 0) { $report_text = $Winner['nick'] . "\n"; if ($system->SETTINGS['users_email'] == 'n') { $report_text .= ' (' . $Winner['email'] . ')' . "\n"; } if ($Winner['address'] != '') { $report_text .= $MSG['30_0086'] . $Winner['address'] . ' ' . $Winner['city'] . ' ' . $Winner['prov'] . ' ' . $Winner['zip'] . ', ' . $Winner['country']; } $bf_paid = 1; // buyer fee payed? $ff_paid = 1; // auction end fee payed? // work out & add fee if ($system->SETTINGS['fees'] == 'y') { sortFees(); }

// Add winner's data to "winners" table $query = "INSERT INTO " . $DBPrefix . "winners (auction, seller, winner, bid, feedback_win, feedback_sel, qty, paid, bf_paid, ff_paid, shipped, auc_title, auc_shipping_cost, auc_payment) VALUES (:auc_id, :seller_id, :winner_id, :current_bid, 0, 0, 1, 0, :bf_paid, :ff_paid, 0, :auc_title, :auc_shipping_cost, :auc_payment)"; $params = array(); $params[] = array(':auc_id', $Auction['id'], 'int'); $params[] = array(':seller_id', $Seller['id'], 'int'); $params[] = array(':winner_id', $Winner['id'], 'int'); $params[] = array(':current_bid', $Auction['current_bid'], 'float'); $params[] = array(':bf_paid', $bf_paid, 'int'); $params[] = array(':ff_paid', $ff_paid, 'int'); $params[] = array(':auc_title', $Auction['title'], 'str'); $params[] = array(':auc_shipping_cost', calculate_shipping_data($Auction), 'float'); $params[] = array(':auc_payment', $Auction['payment'], 'str'); $db->query($query, $params);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/renlok/WeBid/issues/499#issuecomment-340308134, or mute the thread https://github.com/notifications/unsubscribe-auth/AMS3W3usPorJZO5VGnGCbn0Ig46BiIcnks5sxPtegaJpZM4QKaHH.

-- Robbert Eggermont Intelligent Systems Support & Data Steward R.Eggermont@tudelft.nl Electr.Eng., Mathematics & Comp.Science +31 15 27 83234 Delft University of Technology