| Line 90... |
Line 90... |
| 90 |
cursor = collection.find()
|
90 |
cursor = collection.find()
|
| 91 |
for val in cursor:
|
91 |
for val in cursor:
|
| 92 |
data.append(val)
|
92 |
data.append(val)
|
| 93 |
return data
|
93 |
return data
|
| 94 |
|
94 |
|
| - |
|
95 |
def __getBundledSkusfromSku(sku):
|
| - |
|
96 |
masterData = get_mongo_connection().Catalog.MasterData.find_one({"_id":sku},{"skuBundleId":1})
|
| - |
|
97 |
if masterData is not None:
|
| - |
|
98 |
return list(get_mongo_connection().Catalog.MasterData.find({"skuBundleId":masterData.get('skuBundleId')},{'_id':1,'skuBundleId':1}))
|
| - |
|
99 |
else:
|
| - |
|
100 |
return []
|
| - |
|
101 |
|
| 95 |
def addSchemeDetailsForSku(data):
|
102 |
def addSchemeDetailsForSku(data, multi):
|
| - |
|
103 |
if multi ==1:
|
| - |
|
104 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
105 |
for sku in skuIds:
|
| - |
|
106 |
collection = get_mongo_connection().Catalog.SkuSchemeDetails
|
| - |
|
107 |
data['sku'] = sku.get('_id')
|
| - |
|
108 |
data['addedOn'] = to_java_date(datetime.now())
|
| - |
|
109 |
collection.insert(data)
|
| - |
|
110 |
get_mongo_connection().Catalog.MasterData.update({'skuBundleId':sku.get('skuBundleId')},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
|
| - |
|
111 |
else:
|
| 96 |
collection = get_mongo_connection().Catalog.SkuSchemeDetails
|
112 |
collection = get_mongo_connection().Catalog.SkuSchemeDetails
|
| 97 |
data['addedOn'] = to_java_date(datetime.now())
|
113 |
data['addedOn'] = to_java_date(datetime.now())
|
| 98 |
collection.insert(data)
|
114 |
collection.insert(data)
|
| - |
|
115 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
| 99 |
return {1:"Data added successfully"}
|
116 |
return {1:"Data added successfully"}
|
| 100 |
|
117 |
|
| 101 |
def getAllSkuWiseSchemeDetails(offset, limit):
|
118 |
def getAllSkuWiseSchemeDetails(offset, limit):
|
| 102 |
data = []
|
119 |
data = []
|
| 103 |
collection = get_mongo_connection().Catalog.SkuSchemeDetails
|
120 |
collection = get_mongo_connection().Catalog.SkuSchemeDetails
|
| 104 |
cursor = collection.find().skip(offset).limit(limit)
|
121 |
cursor = collection.find().skip(offset).limit(limit)
|
| Line 113... |
Line 130... |
| 113 |
val['source_product_name'] = ""
|
130 |
val['source_product_name'] = ""
|
| 114 |
val['skuBundleId'] = ""
|
131 |
val['skuBundleId'] = ""
|
| 115 |
data.append(val)
|
132 |
data.append(val)
|
| 116 |
return data
|
133 |
return data
|
| 117 |
|
134 |
|
| 118 |
def addSkuDiscountInfo(data):
|
135 |
def addSkuDiscountInfo(data, multi):
|
| - |
|
136 |
if multi != 1:
|
| 119 |
collection = get_mongo_connection().Catalog.SkuDiscountInfo
|
137 |
collection = get_mongo_connection().Catalog.SkuDiscountInfo
|
| 120 |
cursor = collection.find({"sku":data['sku']})
|
138 |
cursor = collection.find({"sku":data['sku']})
|
| 121 |
if cursor.count() > 0:
|
139 |
if cursor.count() > 0:
|
| 122 |
return {0:"Sku information already present."}
|
140 |
return {0:"Sku information already present."}
|
| - |
|
141 |
else:
|
| - |
|
142 |
collection.insert(data)
|
| - |
|
143 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
| - |
|
144 |
return {1:"Data added successfully"}
|
| 123 |
else:
|
145 |
else:
|
| - |
|
146 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
147 |
for sku in skuIds:
|
| - |
|
148 |
data['sku'] = sku.get('_id')
|
| - |
|
149 |
collection = get_mongo_connection().Catalog.SkuDiscountInfo
|
| - |
|
150 |
cursor = collection.find({"sku":data['sku']})
|
| - |
|
151 |
if cursor.count() > 0:
|
| - |
|
152 |
continue
|
| - |
|
153 |
else:
|
| 124 |
collection.insert(data)
|
154 |
collection.insert(data)
|
| 125 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
155 |
get_mongo_connection().Catalog.MasterData.update({'skuBundleId':sku.get('skuBundleId')},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
|
| 126 |
return {1:"Data added successfully"}
|
156 |
return {1:"Data added successfully"}
|
| 127 |
|
157 |
|
| 128 |
def getallSkuDiscountInfo(offset, limit):
|
158 |
def getallSkuDiscountInfo(offset, limit):
|
| 129 |
data = []
|
159 |
data = []
|
| 130 |
collection = get_mongo_connection().Catalog.SkuDiscountInfo
|
160 |
collection = get_mongo_connection().Catalog.SkuDiscountInfo
|
| Line 150... |
Line 180... |
| 150 |
return {1:"Data updated successfully"}
|
180 |
return {1:"Data updated successfully"}
|
| 151 |
except:
|
181 |
except:
|
| 152 |
return {0:"Data not updated."}
|
182 |
return {0:"Data not updated."}
|
| 153 |
|
183 |
|
| 154 |
|
184 |
|
| 155 |
def addExceptionalNlc(data):
|
185 |
def addExceptionalNlc(data, multi):
|
| - |
|
186 |
if multi!=1:
|
| 156 |
collection = get_mongo_connection().Catalog.ExceptionalNlc
|
187 |
collection = get_mongo_connection().Catalog.ExceptionalNlc
|
| 157 |
cursor = collection.find({"sku":data['sku']})
|
188 |
cursor = collection.find({"sku":data['sku']})
|
| 158 |
if cursor.count() > 0:
|
189 |
if cursor.count() > 0:
|
| 159 |
return {0:"Sku information already present."}
|
190 |
return {0:"Sku information already present."}
|
| - |
|
191 |
else:
|
| - |
|
192 |
collection.insert(data)
|
| - |
|
193 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
| - |
|
194 |
return {1:"Data added successfully"}
|
| 160 |
else:
|
195 |
else:
|
| - |
|
196 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
197 |
for sku in skuIds:
|
| - |
|
198 |
data['sku'] = sku.get('_id')
|
| - |
|
199 |
collection = get_mongo_connection().Catalog.ExceptionalNlc
|
| - |
|
200 |
cursor = collection.find({"sku":data['sku']})
|
| - |
|
201 |
if cursor.count() > 0:
|
| - |
|
202 |
continue
|
| - |
|
203 |
else:
|
| 161 |
collection.insert(data)
|
204 |
collection.insert(data)
|
| 162 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
205 |
get_mongo_connection().Catalog.MasterData.update({'skuBundleId':sku.get('skuBundleId')},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
|
| 163 |
return {1:"Data added successfully"}
|
206 |
return {1:"Data added successfully"}
|
| - |
|
207 |
|
| - |
|
208 |
|
| 164 |
|
209 |
|
| 165 |
def getAllExceptionlNlcItems(offset, limit):
|
210 |
def getAllExceptionlNlcItems(offset, limit):
|
| 166 |
data = []
|
211 |
data = []
|
| 167 |
collection = get_mongo_connection().Catalog.ExceptionalNlc
|
212 |
collection = get_mongo_connection().Catalog.ExceptionalNlc
|
| 168 |
cursor = collection.find().skip(offset).limit(limit)
|
213 |
cursor = collection.find().skip(offset).limit(limit)
|
| Line 562... |
Line 607... |
| 562 |
val['source_product_name'] = ""
|
607 |
val['source_product_name'] = ""
|
| 563 |
val['skuBundleId'] = ""
|
608 |
val['skuBundleId'] = ""
|
| 564 |
data.append(val)
|
609 |
data.append(val)
|
| 565 |
return data
|
610 |
return data
|
| 566 |
|
611 |
|
| 567 |
def addSkuDealerPrice(data):
|
612 |
def addSkuDealerPrice(data, multi):
|
| - |
|
613 |
if multi != 1:
|
| 568 |
collection = get_mongo_connection().Catalog.SkuDealerPrices
|
614 |
collection = get_mongo_connection().Catalog.SkuDealerPrices
|
| 569 |
cursor = collection.find({"sku":data['sku']})
|
615 |
cursor = collection.find({"sku":data['sku']})
|
| 570 |
if cursor.count() > 0:
|
616 |
if cursor.count() > 0:
|
| 571 |
return {0:"Sku information already present."}
|
617 |
return {0:"Sku information already present."}
|
| - |
|
618 |
else:
|
| - |
|
619 |
collection.insert(data)
|
| - |
|
620 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
| - |
|
621 |
return {1:"Data added successfully"}
|
| 572 |
else:
|
622 |
else:
|
| - |
|
623 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
624 |
for sku in skuIds:
|
| - |
|
625 |
data['sku'] = sku.get('_id')
|
| - |
|
626 |
collection = get_mongo_connection().Catalog.SkuDealerPrices
|
| - |
|
627 |
cursor = collection.find({"sku":data['sku']})
|
| - |
|
628 |
if cursor.count() > 0:
|
| - |
|
629 |
continue
|
| - |
|
630 |
else:
|
| 573 |
collection.insert(data)
|
631 |
collection.insert(data)
|
| 574 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
632 |
get_mongo_connection().Catalog.MasterData.update({'skuBundleId':sku.get('skuBundleId')},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
|
| 575 |
return {1:"Data added successfully"}
|
633 |
return {1:"Data added successfully"}
|
| - |
|
634 |
|
| - |
|
635 |
|
| 576 |
|
636 |
|
| 577 |
def updateSkuDealerPrice(data, _id):
|
637 |
def updateSkuDealerPrice(data, _id):
|
| 578 |
try:
|
638 |
try:
|
| 579 |
collection = get_mongo_connection().Catalog.SkuDealerPrices
|
639 |
collection = get_mongo_connection().Catalog.SkuDealerPrices
|
| 580 |
collection.update({'_id':ObjectId(_id)},{"$set":{'dp':data['dp']}},upsert=False, multi = False)
|
640 |
collection.update({'_id':ObjectId(_id)},{"$set":{'dp':data['dp']}},upsert=False, multi = False)
|
| Line 617... |
Line 677... |
| 617 |
return {1:"Data updated successfully"}
|
677 |
return {1:"Data updated successfully"}
|
| 618 |
except Exception as e:
|
678 |
except Exception as e:
|
| 619 |
print e
|
679 |
print e
|
| 620 |
return {0:"Data not updated."}
|
680 |
return {0:"Data not updated."}
|
| 621 |
|
681 |
|
| 622 |
def addNegativeDeals(data):
|
682 |
def addNegativeDeals(data, multi):
|
| - |
|
683 |
if multi !=1:
|
| 623 |
collection = get_mongo_connection().Catalog.NegativeDeals
|
684 |
collection = get_mongo_connection().Catalog.NegativeDeals
|
| 624 |
cursor = collection.find({"sku":data['sku']})
|
685 |
cursor = collection.find({"sku":data['sku']})
|
| 625 |
if cursor.count() > 0:
|
686 |
if cursor.count() > 0:
|
| 626 |
return {0:"Sku information already present."}
|
687 |
return {0:"Sku information already present."}
|
| - |
|
688 |
else:
|
| - |
|
689 |
collection.insert(data)
|
| - |
|
690 |
return {1:"Data added successfully"}
|
| 627 |
else:
|
691 |
else:
|
| - |
|
692 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
693 |
for sku in skuIds:
|
| - |
|
694 |
data['sku'] = sku.get('_id')
|
| - |
|
695 |
collection = get_mongo_connection().Catalog.NegativeDeals
|
| - |
|
696 |
cursor = collection.find({"sku":data['sku']})
|
| - |
|
697 |
if cursor.count() > 0:
|
| - |
|
698 |
continue
|
| - |
|
699 |
else:
|
| 628 |
collection.insert(data)
|
700 |
collection.insert(data)
|
| 629 |
return {1:"Data added successfully"}
|
701 |
return {1:"Data added successfully"}
|
| 630 |
|
702 |
|
| 631 |
def getAllNegativeDeals(offset, limit):
|
703 |
def getAllNegativeDeals(offset, limit):
|
| 632 |
data = []
|
704 |
data = []
|
| 633 |
collection = get_mongo_connection().Catalog.NegativeDeals
|
705 |
collection = get_mongo_connection().Catalog.NegativeDeals
|
| Line 660... |
Line 732... |
| 660 |
val['source_product_name'] = ""
|
732 |
val['source_product_name'] = ""
|
| 661 |
val['skuBundleId'] = ""
|
733 |
val['skuBundleId'] = ""
|
| 662 |
data.append(val)
|
734 |
data.append(val)
|
| 663 |
return data
|
735 |
return data
|
| 664 |
|
736 |
|
| 665 |
def addManualDeal(data):
|
737 |
def addManualDeal(data, multi):
|
| - |
|
738 |
if multi !=1:
|
| 666 |
collection = get_mongo_connection().Catalog.ManualDeals
|
739 |
collection = get_mongo_connection().Catalog.ManualDeals
|
| 667 |
cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
|
740 |
cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
|
| 668 |
if cursor.count() > 0:
|
741 |
if cursor.count() > 0:
|
| 669 |
return {0:"Sku information already present."}
|
742 |
return {0:"Sku information already present."}
|
| - |
|
743 |
else:
|
| - |
|
744 |
collection.insert(data)
|
| - |
|
745 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
| - |
|
746 |
return {1:"Data added successfully"}
|
| 670 |
else:
|
747 |
else:
|
| - |
|
748 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
749 |
for sku in skuIds:
|
| - |
|
750 |
data['sku'] = sku.get('_id')
|
| - |
|
751 |
collection = get_mongo_connection().Catalog.ManualDeals
|
| - |
|
752 |
cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
|
| - |
|
753 |
if cursor.count() > 0:
|
| - |
|
754 |
continue
|
| - |
|
755 |
else:
|
| 671 |
collection.insert(data)
|
756 |
collection.insert(data)
|
| 672 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
757 |
get_mongo_connection().Catalog.MasterData.update({'skuBundleId':sku.get('skuBundleId')},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
|
| 673 |
return {1:"Data added successfully"}
|
758 |
return {1:"Data added successfully"}
|
| 674 |
|
759 |
|
| 675 |
def deleteDocument(data):
|
760 |
def deleteDocument(data):
|
| 676 |
print data
|
761 |
print data
|
| 677 |
try:
|
762 |
try:
|
| 678 |
collection = get_mongo_connection().Catalog[data['class']]
|
763 |
collection = get_mongo_connection().Catalog[data['class']]
|
| 679 |
class_name = data.pop('class')
|
764 |
class_name = data.pop('class')
|
| Line 724... |
Line 809... |
| 724 |
val['source_product_name'] = ""
|
809 |
val['source_product_name'] = ""
|
| 725 |
val['skuBundleId'] = ""
|
810 |
val['skuBundleId'] = ""
|
| 726 |
data.append(val)
|
811 |
data.append(val)
|
| 727 |
return data
|
812 |
return data
|
| 728 |
|
813 |
|
| 729 |
def addFeaturedDeal(data):
|
814 |
def addFeaturedDeal(data, multi):
|
| - |
|
815 |
if multi !=1:
|
| 730 |
collection = get_mongo_connection().Catalog.FeaturedDeals
|
816 |
collection = get_mongo_connection().Catalog.FeaturedDeals
|
| 731 |
cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
|
817 |
cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
|
| 732 |
if cursor.count() > 0:
|
818 |
if cursor.count() > 0:
|
| 733 |
return {0:"Sku information already present."}
|
819 |
return {0:"Sku information already present."}
|
| - |
|
820 |
else:
|
| - |
|
821 |
collection.insert(data)
|
| - |
|
822 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
| - |
|
823 |
return {1:"Data added successfully"}
|
| 734 |
else:
|
824 |
else:
|
| - |
|
825 |
skuIds = __getBundledSkusfromSku(data['sku'])
|
| - |
|
826 |
for sku in skuIds:
|
| - |
|
827 |
data['sku'] = sku.get('_id')
|
| - |
|
828 |
collection = get_mongo_connection().Catalog.FeaturedDeals
|
| - |
|
829 |
cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
|
| - |
|
830 |
if cursor.count() > 0:
|
| - |
|
831 |
continue
|
| - |
|
832 |
else:
|
| 735 |
collection.insert(data)
|
833 |
collection.insert(data)
|
| 736 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
|
834 |
get_mongo_connection().Catalog.MasterData.update({'skuBundleId':sku.get('skuBundleId')},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
|
| 737 |
return {1:"Data added successfully"}
|
835 |
return {1:"Data added successfully"}
|
| 738 |
|
836 |
|
| 739 |
def searchCollection(class_name, sku, skuBundleId):
|
837 |
def searchCollection(class_name, sku, skuBundleId):
|
| 740 |
data = []
|
838 |
data = []
|
| 741 |
collection = get_mongo_connection().Catalog[class_name]
|
839 |
collection = get_mongo_connection().Catalog[class_name]
|
| Line 769... |
Line 867... |
| 769 |
val['skuBundleId'] = ""
|
867 |
val['skuBundleId'] = ""
|
| 770 |
data.append(val)
|
868 |
data.append(val)
|
| 771 |
return data
|
869 |
return data
|
| 772 |
|
870 |
|
| 773 |
def main():
|
871 |
def main():
|
| 774 |
print searchMaster(0, 10, "samsung e5")
|
872 |
print __getBundledSkusfromSku(1)
|
| 775 |
|
873 |
|
| 776 |
|
874 |
|
| 777 |
if __name__=='__main__':
|
875 |
if __name__=='__main__':
|
| 778 |
main()
|
876 |
main()
|