Book Pricing

download Book Pricing

of 17

Transcript of Book Pricing

  • 7/31/2019 Book Pricing

    1/17

    $v = {};#version$ourVersion = 1.40;#1.40 Refinement by MVS to optimise#1.39 Refinement by MVS to include signing items#1.38 Refinement by MVS to create subroutines#1.37 Removed maximum Drop from Script - commented out in case we want to add itagain. Kept price from#going up more than 2x#1.36 over14 days bug if it is 0 then it won't re price books that are not yet listed.#1.35 found bug with over14 days.#1.34 added ability to re price mass paperbacks if older than 180 days#1.33 Bug when a book was looking for under 14 days. If it wasn't listed yet itwas under 14 days...duh.#Changed to look to see if it is 0 days...it isn't listed yet#1.32 Excluded DVD/CD's from re pricing. Also excluded books from being re priced if less than 14 days.#1.31 AOB has bug with listDate if we haven't listed yet. This was causing non-listed books to show up listed#longer than 180 days.#1.30 bug needed to set ourBooksLowestPrice if a condition better was found cheaper.#1.29 Allowed acceptable books to be re priced and offers compared.

    #1.28 Added function to re price above condition if we didn't have a price in our condition#1.27 added the no_manual_reprice flag if we change the price#1.26 changed the lowest price of a condition above ours to 65% of lowest listing so that we ensure we are always 35%#lower then the rank above us.#1.25 changed minimum new to .99....book over 180 days will get bumped down onecondition so it prices and moves.#Rating cut off changed to 250,000 from 500,000#1.24 Changed multiplier to X2 for books that we found no price to match#1.21 fixed bug determining what is a hardbound book#1.22 changed the price of hardbound books to .99#

    #***********************Definitions********************************************################ These are used incase there are no other items ########################$min_new_price = 4.99; #Minimum New Price used for no other items to compete against$min_new_oz_price = 5.99; #Minimum New Oversized Price$min_ln_price = 2.99; #Minimum Used:Like New Price$min_ln_oz_price = 3.99; #Minimum Used:Like New Oversized Price$min_vg_price = 1.99; #Minimum Used:Very Good Price$min_vg_oz_price = 2.99; #Minimum Used:Very Good Oversized Price$min_g_price = .99; #Minimum Used:Good Price$min_g_oz_price = 1.99; #Minimum Used:Good Oversized Price$min_a_price = .99; #Minimum Used:Acceptable Price

    $min_a_oz_price = 1.99; #Minimum Used:Acceptable Oversized Price$aged_days = 180; #Set this to the number of days you wantto use for changing aging.#our minimums for types of books$min_hardBack = .99; #Minimum of a hard back book.$min_hardBack_180 = .01; #Minimum of hardback book after 180 days.$min_paperBack = .99; #Minimum of a paper back$min_paperBack_180 = .01; #Minimum of a paper back after 180 days.$min_new_180 = .01; #Minimum of a new Book after 180 days.$ratingCutoff = 250000; #Cut off for different sales rating minimums

  • 7/31/2019 Book Pricing

    2/17

    $maximumDrop = .65; #This is the maximum drop from our current price...#if the amount of new_pr

    ice is greater than .65 X OurCurrentPrice then leave current price alone.$maximumCDDrop = .80; #this is the maximum drop from our current price forCD/DVD's$min_Price_RankValue = 5000000;#Above this rank, the price sets to minimum$min_price_3yr_over_above5000000 = 0.01;#minimum Price over 3 yrs and above rank5000000$min_price_3yr_over_low5000000 = 0.99;#minimum Price over 3 yrs and below rank 5000000$min_price__a_g_above5000000 = 0.99;#minimum Price above rank 5000000 and acceptable or good$min_price__ln_vg_above5000000 = 0.99;#minimum Price above rank 5000000 and likenew or verygood

    #############################################################################33# These are for the TODO of pricing DVD's/CD's Should follow same guidlines of books ###$min_DVD = .99; #Minimum DVD Price$min_DVD_180 = .01; #Minimum DVD Price after 180 days.$min_CD = .99; #Minimum CD Price$min_CD_180 = .01; #Minimum CD Price after 180 days.#################################################################################################

    ################# These are my definitions for easier manipulation ##############################$signedBookMultipler = .65; #Multiplier for signed books$excludeBookMaxPrice = 50; #Used to exclude books with this price or abovefrom repricing.$isBookOversized = 0; #Flag to tell us if this book is oversized$isBookHard = 0; #Flag to tell us if this item isa hardback or not$isBookSigned = 0; #Flag to tell us status of signed$ageOfOurListing = 0; #Flag for listing age$Over14Days = 0; #Flag for over 14 days

    $rateIndex; #Index used with the arrays of offers. Set by the rating cutoff number@source_ignore_string=("Erin","CONSIGNED"); #Used to ignore in source- change this if you want to ignore another source#if their are no other items to compare against, make minimum be 2x minimum condition#******************************Values******************************************

    $my_price = $market->{my_item}->{core_price}; #My Price$my_cond = $market->{my_item}->{condition}; #My Condition$my_source = $market->{my_item}->{source}; #My Source$my_ch = $c_h{$my_cond};$amz_price = 0;

    #Clear Amazon Price$salesRank = $market->{sales_rank}; #sales ranking from Amazon

    if ($salesRank < $ratingCutoff) {$rateIndex = 1;

    } else {$rateIndex = 0;

    }

  • 7/31/2019 Book Pricing

    3/17

    #******************************** Common Prints *************************************#print out the version$v->{comments} .= sprintf(qq[Running Version %1.2f
    ],$ourVersion);#Display Amazon Sales Rank$v->{comments} .= sprintf(qq[Sales rank = %1d
    ],$salesRank);#Display our current price$v->{comments} .= sprintf(qq[Our Current price = %1.2f
    ],$my_price);#Display Condition$v->{comments} .= sprintf(qq[This book is %1d
    ],$my_cond);#**************************************************************************************

    #Oversized books have a minimum.if(($market->{my_item}->{notes} =~ /oversized/i) || ($market->{my_item}->{P0} =~/oversized/i)) {

    $isBookOverSized = 1;$v->{comments} .= qq[This is an Oversized Book
    ];#3_13 don't return....go through and price but make sure it has a minimum of

    the oversized price. return $v;}#Signed books have a multiplier.if(($market->{my_item}->{notes} =~ /Signed/i) or

    ($market->{my_item}->{Signature} =~ /Signed/i) or

    ($market->{my_item}->{Keyword} =~ /Signed/i)) {$isBookSigned = 1;$v->{comments} .= qq[This is a Signed Book
    ];

    }

    #Type of book. 1 = Hardback 0 = Softback(default) #note: Is paper back if this is not trueif(($market->{my_item}->{media} =~ /hardcover/i) ||

    ($market->{my_item}->{media} =~ /hard cover/i) ||($market->{my_item}->{media} =~ /unknown/i)) {

    $isOurBookHard = 1;$v->{comments} .= qq[This is a Hardback Book
    ];

    } elsif(($market->{my_item}->{media} =~ /paperback/i) or

    ($market->{my_item}->{media} =~ /softcover/i)) {$isOurBookHard = 0;$v->{comments} .= qq[This is a Paperback Book
    ];

    } elsif(($market->{my_item}->{media} =~ /dvd/i) or($market->{my_item}->{media} =~ /cd/i)) {$isThisDVD_CD = 1;$v->{comments} .= qq[This is a CD/DVD
    ];

    }

    #determine where we got this book$inventory_source = $market->{my_item}->{source};$v->{comments} .= qq[Inventory source = $inventory_source
    ];

    #Display How long book has been listed#setting the age of our book in daysif ($market->{my_item}->{listed_time} > 0) {

    $ageOfOurListing= ($market->{my_item}->{current_time} - $market->{my_item}->{listed_t

    ime})/86400;} else {

    $ageOfOurListing = 0;}#determine if this is over 180 and 14 days.

  • 7/31/2019 Book Pricing

    4/17

    if( $ageOfOurListing > 14 ) {$Over14Days = 1;$v->{comments} .= qq[This Book is over 14 days
    ];

    } else {$Over14Days = 0;$v->{comments} .= qq[This Book is less than 14 days
    ];

    }#if the age of our book is 0 this means we haven't listed yet. So we need to turn over14days on so we can get it manually listed#this is a hack and I'm not sure how to fix it because we can't tell if it has been listed yet or not...sighif($ageOfOurListing == 0) {# So ageOfOurListing is needs to be 14 days

    $ageOfOurListing = 14;}if( $ageOfOurListing > $aged_days ) {

    $Over180Days = 1;} else {

    $Over180Days = 0;}$v->{comments} .= sprintf(qq[Our Book has been listed for %1d days
    ], $ageOfOurListing);#set whether this is a heavy book over 16 ozif($market->{my_item}->{weight} > 16) {

    $isOurBookHeavy = 1;$v->{comments} .= sprintf(qq[Our Book is Heavy
    ]);}#Our condition of the book$my_cond = $market->{my_item}->{condition};#We reset the levels going from worse to best 1 - 4 ... 4 being the best as in NEW!if ( $isBookOverSized == 1) {

    if ( $my_cond == 1 ) {$MinPrice = $min_a_oz_price;

    } elsif ( $my_cond == 2 ) {$MinPrice = $min_g_oz_price;

    } elsif ( $my_cond == 3 ) {

    $MinPrice = $min_vg_oz_price;} elsif ( $my_cond == 4 ) {$MinPrice = $min_ln_oz_price;

    }} else {

    if ( $my_cond == 1 ) {$MinPrice = $min_a_price;

    } elsif ( $my_cond == 2 ) {$MinPrice = $min_g_price;

    } elsif ( $my_cond == 3 ) {$MinPrice = $min_vg_price;

    } elsif ( $my_cond == 4 ) {$MinPrice = $min_ln_price;

    }}#$v->{comments} .= sprintf(qq[Our Book has been minimum Price %1d days
    ], $MinPrice);

    if ( $isBookSigned == 1 ) {$new_price = $my_price * $signedBookMultipler + $my_price;$v->{price}->{core} = $new_price;$v->{comments} .= sprintf ( qq[Changing to Price %1.2f because book is s

    igned
    ], $new_price);

  • 7/31/2019 Book Pricing

    5/17

    $v->{changed} = 'y';return $v;

    }#Our condition of the book$my_cond = $market->{my_item}->{condition};#We reset the levels going from worse to best 1 - 4 ... 4 being the best as in NEW!if( $my_cond == 11 ) {

    $ourBookConditionLevel = 4;} elsif ( $my_cond == 4 ) {

    $ourBookConditionLevel = 0; #3_29_10} elsif ( $my_cond == 3 ) {

    $ourBookConditionLevel = 1;} elsif ( $my_cond == 2 ) {

    $ourBookConditionLevel = 2;} elsif( $my_cond == 1 ) {

    $ourBookConditionLevel = 3;}#if we have had this book for more than 180 days then bump down condition of like new to very good and very good to good.if( $Over180Days == 1 ) {

    if ($ourBookConditionLevel == 4) {$ourBookConditionLevel = 3;

    } elsif( $ourBookConditionLevel == 3 ) {

    $ourBookConditionLevel = 2;} elsif ( $ourBookConditionLevel == 2 ) {$ourBookConditionLevel = 1;

    } else {$ourBookConditionLevel = 0;

    }}$v->{comments} .= sprintf(qq[Our Books level is %1d
    ], $ourBookConditionLevel);

    #used or New "U" I don't like this so setting another...note this can be "C" which means collector too.$my_ch = $c_h{$my_cond};

    #set new if condition is 11if( $my_cond == 11 ) {$isOurBookNew = 1;

    }

    #*********************Exclusions******************************************#This has to be here for some reasonif ( $market->{my_item}->{autoreprice_exclude} eq 'y') {

    $v->{changed} = 'n';$v->{comments} .= "Excluded from Auto Repricing
    ";return $v;

    }# Exclude if our source has our ignore source words (These words are passed in s

    ource ignore string)$v = excludeIfIgnoreStringFound($inventory_source, @source_ignore_string, $v);

    # If we have DNR in P2 variable returnif ( $market->{my_item}->{p2} =~ /DNR/i ) {

    $v->{comments} .= qq[Excluding since we have DNR in the P2 variable
    ];if( $v->{no_manual_reprice} != 1 ){

    $v->{no_manual_reprice} = 1;$v->{changed} = 'y';

    }

  • 7/31/2019 Book Pricing

    6/17

    return $v;}

    # Exclude books that are less than 14 daysif( $Over14Days == 0 ){ #item is 14 or under days.

    $v->{comments} .= qq[Excluding since this book hasn't been listed for more than 14 days
    ];

    if( $v->{no_manual_reprice} != 1 ){$v->{no_manual_reprice} = 1;$v->{changed} = 'y';

    }return $v;

    }

    # Exclude via price greater than excludeBookMaxPriceif ( ( $market->{my_item}->{core_price} > $excludeBookMaxPrice ) &&

    (!$market->{my_item}->{slp_mode} )) {$v->{comments} .= qq[Excluding since price is greater than than $excludeBook

    MaxPrice
    ];if( $v->{no_manual_reprice} != 1 ) {

    $v->{no_manual_reprice} = 1;$v->{changed} = 'y';

    }return $v;

    }

    #TODO - reprice DVD's/CD's differently....for now we won't price them.if( $isThisDVD_CD == 1 ) {

    $v->{comments} .= qq[Excluding since this is a DVD/CD
    ];if( $v->{no_manual_reprice} != 1 ) {

    $v->{no_manual_reprice} = 1;$v->{changed} = 'y';

    }return $v;

    }# Exclude condition class: Collectableif ($my_ch eq 'C') {

    $v->{comments} .= qq[Exluding since condition class is collectible
    ];if( $v->{no_manual_reprice} != 1 ) {$v->{no_manual_reprice} = 1;$v->{changed} = 'y';

    }return $v;

    }

    ########Code from the previous logic , if you need, then keep this ############### __________________All Offers__________________________________________________

    ____#

    #@o_list = ();@o_like_new = ();@o_new = ();@o_good = ();@o_very_good = ();@o_acceptable = ();OFFERS:foreach my $o ( @{$market->{offers}} ){

  • 7/31/2019 Book Pricing

    7/17

    ## Exclude Acceptables##3_29_10 allowed acceptable next if ( ( $o->{condition} == 4 ) || ( $o->{con

    dition} == 8 ) );next if ( $o->{condition} == 8 );## Exclude our books from the offers#next if ( $o->{nickname} =~ /^(rrbooksca)$/i );## Exclude via condition class is collectible#next if $c_h{$o->{condition}} eq 'C';# switch on the type of condition and add to the array = we have arrays for

    each type of book condition$found = 0;if ( $o->{condition} == 4 ) {

    $found = offerPriceFound(@o_acceptable, $o->{price},$found);if( $found == 0 ) {

    push @o_acceptable, $o;}

    } elsif ( $o->{condition} == 1) {$found = offerPriceFound(@od_like_new, $o->{price},$found);

    if( $found == 0 ) {push @o_like_new, $o;}

    }#very Goodelsif ( $o->{condition} == 2) {

    $found = offerPriceFound(@o_very_good, $o->{price},$found);if( $found == 0 ) {

    push @o_very_good, $o;}

    }#Goodelsif ( $o->{condition} == 3 ) {

    $found = offerPriceFound(@o_good, $o->{price},$found);if( $found == 0 ){push @o_good, $o;}

    }#Darn thing is spank'n brand newelsif ( $o->{condition} == 11 ) {

    $found = offerPriceFound(@o_new, $o->{price},$found);if( $found == 0 ) {push @o_new, $o;}

    }}

    #end of all offers##______________Determine the correct price for this book________________________

    _______________#$new_price = 0.00;#if this is a new bookif( $isOurBookNew ) {

    if ( defined ( $o_new[0] ) ) {

  • 7/31/2019 Book Pricing

    8/17

    #If we found any new book offers. [0] is the lowest book price.#TODO If we have more than 5 of this new book in inventory then be the l

    owest dude.#Need to find the $v->{QtyArgument} in their script

    if( defined ( $o_new[$rateIndex] ) ) {

    #3_13 took this out...not sure why put it in ?? --if( $ourCurrentPrice > $o_new[$rateIndex]->{price} ){

    $new_price = $o_new[$rateIndex]->{price}; #set the price of thenew book

    #}} elsif( defined ( $o_new[$rateIndex - 1] ) ) {

    $new_price = $o_new[$rateIndex - 1]->{price};} else{ #we have to look at lowest price and raise it up by the lowest a

    mount * a multiplier#TODO

    }}

    }#This is a used bookelse{

    #*****************************************************#find our books lowest price#*****************************************************

    #acceptableif ( $ourBookConditionLevel == 0 ) {if( defined ($o_acceptable[$ratingIndex]) ) {

    $ourBookLowestPrice = $o_acceptable[$ratingIndex]->{price};} elsif ( defined ($o_acceptable[$ratingIndex - 1]) ) {

    $ourBookLowestPrice = $o_acceptable[$ratingIndex - 1]->{price};}

    }#Goodelsif ( $ourBookConditionLevel == 1 ) {

    if( defined ($o_good[$ratingIndex]) ){$ourBookLowestPrice = $o_good[$ratingIndex]->{price};

    } elsif( defined ($o_good[$ratingIndex - 1]) ) {$ourBookLowestPrice = $o_good[$ratingIndex - 1]->{price};}

    }#Very Goodelsif ($ourBookConditionLevel == 2 ) {

    if( defined ($o_very_good[$ratingIndex]) ) {$ourBookLowestPrice = $o_very_good[$ratingIndex]->{price};

    } elsif( defined ($o_very_good[$ratingIndex - 1]) ) {$ourBookLowestPrice = $o_very_good[$ratingIndex - 1]->{price};

    }

    }#like Newelsif ($ourBookConditionLevel == 3 ) {

    if( defined ($o_like_new[$ratingIndex]) ){$ourBookLowestPrice = $o_like_new[$ratingIndex]->{price};

    } elsif( defined ($o_like_new[$ratingIndex - 1]) ) {$ourBookLowestPrice = $o_like_new[$ratingIndex - 1]->{price};

    }}#New

  • 7/31/2019 Book Pricing

    9/17

    elsif ($ourBookConditionLevel == 4 ) {if( defined ($o_new[$ratingIndex]) ){

    $ourBookLowestPrice = $o_new[$ratingIndex]->{price};}elsif( defined ($o_new[$ratingIndex - 1]) ) {

    $ourBookLowestPrice = $o_new[$ratingIndex - 1]->{price};}

    }else { #couldn't find any price

    $ourBookLowestPrice = $my_price;$v->{comments} .= qq[Price was set to our current price because nothing

    found in same condition
    ];}$v->{comments} .= sprintf ( qq[OurBookLowestPrice to be found in same condit

    ion is %1.2f
    ], $ourBookLowestPrice);#*****************************************************#Now we need to find the lowest price for each level.#*****************************************************#level 0 Acceptableif ( defined ($o_acceptable[$rateIndex]) ) {

    $level0_low = $o_acceptable[$ratingIndex]->{price};$v->{comments} .= sprintf ( qq[level 0 lowest price to be found is %1.2f


    ], $level0_low);}

    #level 1 Goodif( defined ($o_good[$rateIndex]) ) {$level1_low = $o_good[$ratingIndex]->{price};$v->{comments} .= sprintf ( qq[level 1 lowest price to be found is %1.2f


    ], $level1_low);}elsif(defined ($o_good[$rateIndex - 1])) {

    $level1_low = $o_good[$ratingIndex - 1]->{price};$v->{comments} .= sprintf ( qq[level 1 lowest price to be found is %1.2f


    ], $level1_low);}

    #level 2 Very Good

    if( defined ($o_very_good[$rateIndex]) ) {$level2_low = $o_very_good[$ratingIndex]->{price};$v->{comments} .= sprintf ( qq[level 2 lowest price to be found is %1.2f


    ], $level2_low);}elsif(defined ($o_very_good[$rateIndex - 1])) {

    $level2_low = $o_very_good[$ratingIndex - 1]->{price};$v->{comments} .= sprintf ( qq[level 2 lowest price to be found is %1.2f


    ], $level2_low);}

    #level 3 Like newif( defined ($o_like_new[$rateIndex]) ) {

    $level3_low = $o_like_new[$ratingIndex]->{price};$v->{comments} .= sprintf ( qq[level 3 lowest price to be found is %1.2f


    ], $level3_low);}elsif(defined ($o_like_new[$rateIndex - 1])) {

    $level3_low = $o_like_new[$ratingIndex - 1]->{price};$v->{comments} .= sprintf ( qq[level 3 lowest price to be found is %1.2f


    ], $level3_low);}

  • 7/31/2019 Book Pricing

    10/17

    #level 4 Newif( defined ($o_new[$rateIndex]) ) {

    $level4_low = $o_new[$ratingIndex]->{price};$v->{comments} .= sprintf ( qq[level 4 lowest price to be found is %1.2f


    ], $level4_low);}elsif(defined ($o_new[$rateIndex - 1])){

    $level4_low = $o_new[$ratingIndex - 1]->{price};$v->{comments} .= sprintf ( qq[level 4 lowest price to be found is %1.2f


    ], $level4_low);}

    #*****************************************************#Now start checking pricing of different levels. See if any level (starting

    from top) is less than our current price#*****************************************************if( $ourBookConditionLevel < 4 && ($level4_low * .65) {comments} .= qq[Book in level 4 found cheaper
    ];$levelPriceFound = 4;

    }

    if( $ourBookConditionLevel < 3 && ($level3_low * .65) {comments} .= qq[Book in level 3 found cheaper
    ];$levelPriceFound = 3;

    }if( $ourBookConditionLevel < 2 && ($level2_low * .65) {comments} .= qq[Book in level 2 found cheaper
    ];$levelPriceFound = 2;

    }if( $ourBookConditionLevel < 1 && ($level1_low * .65) {comments} .= qq[Book in level 1 found cheaper
    ];$levelPriceFound = 1;

    }

    #*****************************************************#now that we found the lowest price at the level we need to calculate the le

    vel offset#ie: if we are at 3 and the lowest level is at 4#(above our condition then we need to use that price times a multiplier)#*****************************************************if ( $new_price != 0 ) #only use the multiplier if the cheaper level was a b

    etter condition than our condition

  • 7/31/2019 Book Pricing

    11/17

    {if( $ourBookConditionLevel - $levelPriceFound == -1 ) {

    $new_price = $new_price * .65;$v->{comments} .= qq[Higher Level book found that is cheaper and is

    calculated using .65 multiplier
    ];} elsif( $ourBookConditionLevel - $levelPriceFound == -2 ) {

    $new_price = $new_price * .50;$v->{comments} .= qq[Higher Level book found that is cheaper and is

    calculated using .50 multiplier
    ];} elsif( $ourBookConditionLevel - $levelPriceFound == -3 ) {

    $new_price = $new_price * .30;$v->{comments} .= qq[Higher Level book found that is cheaper and is

    calculated using .30 multiplier
    ];} elsif( $ourBookConditionLevel - $levelPriceFound == -4 ) {

    $new_price = $new_price * .20;$v->{comments} .= qq[Higher Level book found that is cheaper and is

    calculated using .20 multiplier
    ];}

    }

    #***************************************************** Added 3_29_10#If we do not have a book in our condition to price against we need to look

    in condition above

    #*****************************************************if ( $ourBookLowestPrice == 0 && $new_price == 0 ) {if( $ourBookConditionLevel < 4 && ($level4_low * .65) {comments} .= qq[Higher Level book priced used because there was

    none at our condition
    ];}elsif( $ourBookConditionLevel < 3 && ($level3_low * .65) {comments} .= qq[Higher Level book priced used because there was

    none at our condition
    ];

    }elsif( $ourBookConditionLevel < 2 && ($level2_low * .65) {comments} .= qq[Higher Level book priced used because there was

    none at our condition
    ];}elsif( $ourBookConditionLevel < 1 && ($level1_low * .65) {comments} .= qq[Higher Level book priced used because there was

    none at our condition
    ];}

    }

    #*****************************************************#If ourBooksLowest price is 0 and $new_price is 0 then we couldn't find a bo

    ok at our level nor above. So we need to look below#*****************************************************if ( $ourBookLowestPrice == 0 && $new_price == 0 ) {

    #Level 4 Newif ( $ourBookConditionLevel == 4 ) {

    if (defined($o_like_new[$rateIndex])) {

  • 7/31/2019 Book Pricing

    12/17

    if ( $o_like_new[$rateIndex]->{price} < 2 ) {#if the price is less than 2 bucks then the multiplier i

    s less$new_price = $o_like_new[$rateIndex]->{price} * 2;

    } else {$new_price = $o_like_new[$rateIndex]->{price} * 3;

    }$v->{comments} .= sprintf(qq[Lower level book found from 4 to 3

    like_new price found is %1.2f
    ],$o_like_new[$rateIndex]->{price}) ;} elsif (defined($o_like_new[$rateIndex - 1])) {

    if( $o_like_new[$rateIndex - 1]->{price} < 2 ) {#if the price is less than 2 bucks then the multiplier is less

    $new_price = $o_like_new[$rateIndex - 1]->{price} * 2;}else{

    $new_price = $o_like_new[$rateIndex - 1]->{price} * 3;}$v->{comments} .= sprintf(qq[Lower level book found from 4 to 3

    like_new price found is %1.2f
    ],$o_like_new[$rateIndex - 1]->{price}) ;}

    }

    #Level 3 Like Newelsif( $ourBookConditionLevel == 3 ) {

    if(defined($o_very_good[$rateIndex])) {#if( $o_very_good[$rateIndex]->{price} < 2 ) { #if the price isless than 2 bucks then the multiplier is less

    # $new_price = $o_very_good[$rateIndex]->{price} * 2;#}#else{# $new_price = $o_very_good[$rateIndex]->{price} * 3;#}$new_price = $o_very_good[$rateIndex]->{price} * 2;$v->{comments} .= sprintf(qq[Lower level book found from 3 to 2

    like_new price found is %1.2f -- New price = %1.2f
    ],$o_very_good[$rateIndex]->{price}, $new_price);

    } elsif (defined($o_very_good[$rateIndex - 1])) {

    #if( $o_very_good[$rateIndex - 1]->{price} < 2 ){ #if the priceis less than 2 bucks then the multiplier is less# $new_price = $o_very_good[$rateIndex - 1]->{price} * 2;#}#else{# $new_price = $o_very_good[$rateIndex - 1]->{price} * 3;#}$new_price = $o_very_good[$rateIndex - 1]->{price} * 2;$v->{comments} .= sprintf(qq[Lower level book found from 3 to 2

    like_new price found is %1.2f -- New price = %1.2f
    ],$o_very_good[$rateIndex- 1]->{price}, $new_price);

    }}

    #Level 2 Very Goodelsif ( $ourBookConditionLevel == 2 ) {

    if (defined($o_good[$rateIndex])) {#if( $o_good[$rateIndex]->{price} < 2 ){ #if the price is less t

    han 2 bucks then the multiplier is less# $new_price = $o_good[$rateIndex]->{price} * 2;#}#else{# $new_price = $o_good[$rateIndex]->{price} * 3;

  • 7/31/2019 Book Pricing

    13/17

    #}$new_price = $o_good[$rateIndex]->{price} * 2;$v->{comments} .= qq[Lower level book found from 2 to 1
    ];

    }elsif (defined($o_good[$rateIndex - 1])) {

    #if( $o_good[$rateIndex - 1]->{price} < 2 ){ #if the price is less than 2 bucks then the multiplier is less

    # $new_price = $o_good[$rateIndex - 1]->{price} * 2;#}#else{# $new_price = $o_good[$rateIndex - 1]->{price} * 3;#}$new_price = $o_good[$rateIndex - 1]->{price} * 2;$v->{comments} .= qq[Lower level book found from 2 to 1
    ];

    }}

    #Level 1 Goodelsif( $ourBookConditionLevel == 1 ) {

    if(defined($o_acceptable[$rateIndex])) {$new_price = $o_acceptable[$rateIndex]->{price} * 2;$v->{comments} .= qq[Lower level book found from 1 to 0
    ];

    }elsif(defined($o_acceptable[$rateIndex - 1])) {

    $new_price = $o_acceptable[$rateIndex - 1]->{price} * 2;$v->{comments} .= qq[Lower level book found from 1 to 0
    ];

    }}#TODO How do we price a book we have nothing to compare too? (see requir

    ements)}

    #*****************************************************

    #Now check ourbookslowest price from it's same condition.#If it is lower than the one's we found above then use that one.#*****************************************************if ( $new_price == 0 && $ourBookLowestPrice > 0 ) {

    if( $ourBookLowestPrice < $new_price or $ourBookLowestPrice > 0 ) {$new_price = $ourBookLowestPrice;$v->{comments} .= qq[We calculated a new price from our waterfall tr

    ee and our book's condition is still the lowest
    ];}

    }}# __________What should we do with the price now that we have it.

    #if ( $new_price == 0 ) {

    $v->{comments} .= qq[Unable to determine a new price
    ];return $v;

    } else {$v->{comments} .= sprintf ( qq[Calculated New price is %1.2f ---

    changed from %1.2f
    ], $new_price, $my_price );$v->{price}->{core} = $new_price;$v->{changed} = 'y';

    }

  • 7/31/2019 Book Pricing

    14/17

    ############################The logic ends here which are from the previous script ########## setting the min price as per the needif ($isBookOversized == 0) {

    if ( ($v->{price}->{core} < $min_new_price) && ($my_cond = 11) ) {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $m

    in_new_price );$v->{price}->{core} = $min_new_price;

    } elsif ( ($v->{price}->{core} < $min_ln_price) && ($my_cond = 4) ) {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $m

    in_ln_price );$v->{price}->{core} = $min_ln_price;

    } elsif ( ($v->{price}->{core} < $min_vg_price) && ($my_cond = 3) ) {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $m

    in_ln_price );$v->{price}->{core} = $min_vg_price;

    } elsif ( ($v->{price}->{core} < $min_g_price ) && ($my_cond = 2) ) {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $$

    min_g_price );$v->{price}->{core} = $min_g_price;

    } elsif ( ($v->{price}->{core} < $min_a_price ) && ($my_cond = 1) ) {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $$

    min_g_price );

    $v->{price}->{core} = $min_a_price;}} elsif ($isBookOversized == 1) {

    if ( ($v->{price}->{core} < $$min_new_oz_price) && ($my_cond = 11) ) {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $$

    min_new_oz_price );$v->{price}->{core} = $$min_new_oz_price;

    } elsif ( ($v->{price}->{core} < $$min_ln_oz_price) && ($my_cond = 4) ){

    $v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $$min_ln_oz_price);

    $v->{price}->{core} = $min_ln_price;} elsif ( ($v->{price}->{core} < $min_vg_oz_price) && ($my_cond = 3) ) {

    $v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $min_vg_oz_price );$v->{price}->{core} = $min_vg_price;

    } elsif ( ($v->{price}->{core} < $min_g_oz_price ) && ($my_cond = 2) ){

    $v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $min_g_oz_price );

    $v->{price}->{core} = $min_g_price;} elsif ( ($v->{price}->{core} < $min_a_oz_price ) && ($my_cond = 1) )

    {$v->{comments} .= sprintf ( qq[Setting to min of %1.2f.
    ], $$

    min_a_oz_price );$v->{price}->{core} = $min_a_price;

    }}

    if (($ageOfOurListing >= 1095) && ( $salesRank >= $min_Price_RankValue )) {

    # If the sales Rank > 5,000,000 && 3 yrs old book conditions$new_price = $min_price_3yr_over_above5000000;$v->{price}->{core} = $new_price;$v->{comments} .= sprintf ( qq[Changing to Price %1.2f because w

    e have Sales Rank > 5000000
    ], $new_price);$v->{changed} = 'y';

  • 7/31/2019 Book Pricing

    15/17

    return $v;} elsif (($ageOfOurListing >= 1095) && ( $salesRank < $min_Price_RankVal

    ue )) {# If the sales Rank < 5,000,000 && 3 yrs old book conditions

    $new_price = $min_price_3yr_over_low5000000;$v->{price}->{core} = $new_price;$v->{comments} .= sprintf ( qq[Changing to Price %1.2f because w

    e have 3 yrs old book > 5000000
    ], $new_price);$v->{changed} = 'y';return $v;

    } elsif (( $salesRank >= $min_Price_RankValue ) && (($my_cond = 4) || ($my_cond = 3))) {

    # If the sales Rank >= 5,000,000 && book condition is good or acceptable$new_price = $min_price__a_g_above5000000;$v->{price}->{core} = $new_price;$v->{comments} .= sprintf ( qq[Changing to Price %1.2f because w

    e have Sales Rank > 5000000
    ], $new_price);$v->{changed} = 'y';return $v;

    } elsif (( $salesRank >= $min_Price_RankValue ) && (($my_cond = 2) || ($my_cond = 1))) {

    # If the sales Rank >= 5,000,000 && book condition is new like New or very good condition

    $new_price = $min_price__ln_vg_above5000000;

    $v->{price}->{core} = $new_price;$v->{comments} .= sprintf ( qq[Changing to Price %1.2f because we have Sales Rank > 5000000
    ], $new_price);

    $v->{changed} = 'y';return $v;

    }

    if ( $v->{changed} eq 'y' ) {if ( $new_price < $min_new_price ) {

    $v->{price}->{core} = $min_new_price;#$new_price = $min_price;$v->{comments} .= sprintf ( qq[Changing to %1.2f because we have a minim

    um
    ], $min_new_price);

    $v->{changed} = 'y';$v->{no_manual_reprice} = 1;}if( $isBookOverSized == 1 && $new_price < $min_new_oz_price ){

    $v->{price}->{core} = $min_oversized;#$new_price = $min_oversized;$v->{comments} .= sprintf ( qq[Changing to %1.2f because this is oversiz

    ed
    ],$min_new_oz_price);$v->{changed} = 'y';$v->{no_manual_reprice} = 1;

    }if( $isOurBookHard == 1 && $new_price < $min_hardBack ){

    $v->{price}->{core} = $min_hardBack;

    #$new_price = $min_hardBack;$v->{comments} .= sprintf ( qq[Changing to %1.2f because this is a hardB

    ound book
    ],$min_hardBack);$v->{changed} = 'y';$v->{no_manual_reprice} = 1;

    }if( $isOurBookNew == 1 && $new_price < $min_new_price ){

    $v->{price}->{core} = $min_new_price;#$new_price = $min_new_price;$v->{comments} .= sprintf ( qq[Changing to %1.2f because this is a new b

  • 7/31/2019 Book Pricing

    16/17

    ook
    ],$min_new_price);$v->{changed} = 'y';$v->{no_manual_reprice} = 1;

    }if( $Over180Days == 1 && $turn_on_masspaper == 1 && $my_price != $new_price

    ) {$v->{price}->{core} = $new_price;$v->{comments} .= sprintf ( qq[Changing to %1.2f because we are in the m

    ood to price mass paperbacks
    ], $new_price);$v->{changed} = 'y';$v->{no_manual_reprice} = 1;return $v;

    }#1.37 make sure that the price doesn't go up too much due to some moron putt

    ing in some price.if( $new_price > ($my_price * 2 ) ) {

    $v->{comments} .= sprintf ( qq[The new price is more than 2x of current,not going to reprice to %1.2f
    ],$new_price);

    $v->{changed} = 'n';return $v;

    }#Check about of price drop from ourCurrentPrice to new price...it it exceeds

    our maximum forget about repricing.if( $new_price < ($my_price * $maximumDrop) ){

    $v->{price}->{core} = $my_price;$v->{changed} = 'y';$v->{comments} .= sprintf ( qq[The new price exceeded more than our maxi

    mum allowed drop...leaving at %1.2f
    ],$my_price);;$v->{no_manual_reprice} = 0;return $v;

    }if( $my_price == $new_price ) { #it is the same price no sense modifying it

    because will take longer to run$v->{changed} = 'n';$v->{comments} .= qq[Not going to change this record because the new pri

    ce is same as current price
    ];}

    }return $v;

    ######################################This is from the old script #################################

    #****************************************Subroutines Done by MVS************************

    sub excludeIfIgnoreStringFound($inventory_source, @source_ignore_string, $v) {foreach $i (@source_ignore_string) {

    if( index($inventory_source, $i) >= 0 ) {$v->{comments} .= "This Book is being ignored because so

    urce is $i
    ";if( $v->{no_manual_reprice} != 1 ) {

    $v->{no_manual_reprice} = 1;$v->{changed} = 'y';

    break;}}

    }return $v;

    }

  • 7/31/2019 Book Pricing

    17/17

    sub offerPriceFound(@offer_array, $o->{price},$found) {$found = 0;foreach my $offer (@offer_arrray) {

    if($offer->{price} == $o->{price} ) {$found = 1;last;

    }}return $found;

    }

    #*****************************************************************************************