Open IamIGI opened 2 years ago
Write check to db, if db key "Queue" = [], then take random product to hotShoot promotion
if Queue !== [] then take first item from array as a hotShootPromotion and delete it.
Collection schema:
Queue: [ {productId: <id>, discount: <price>}, . . {productId: <id>, discount: <price>} ], Blocked: [{productId: <id>, date: <date>},....,{productId: <id>, date: <date>}]
The discount is the value of the price, which is subtracted from the normal price, it gives the promotional price.
Item when begin his promotion is getting added to Blocked document with date of begining. After 2 days it's deleted from the blocked list
getHotShoot controller will check is it 10 am or 10 pm. IF it is then product for hotShoot promotion will be changed and the previous product will be added to blocked list with date and hour of being added
promotion: {productData: <Object>, discount: <Number>, date: <String>}
, this key will store actuall HotShoot promotion
For changing promotion will be checked time of the promotion set, if the 12 hours pass, then item will be changed. So it is important that first item in promotion functionality will be set by 10 am or 10 pm time
Blocked List work fine, but after 12 hours disable promotion from last hotShootPromotion product
Each product after HotShoot Promtion have to be banned for one week - when number of products in your list of products id greater than 7