| 13572 |
kshitij.so |
1 |
import json
|
| 13582 |
amit.gupta |
2 |
from dtr import main
|
| 13629 |
kshitij.so |
3 |
from dtr.storage import Mongo
|
|
|
4 |
from bson import json_util
|
|
|
5 |
import falcon
|
| 13572 |
kshitij.so |
6 |
|
|
|
7 |
|
|
|
8 |
class CategoryDiscountInfo(object):
|
|
|
9 |
|
|
|
10 |
def on_get(self, req, resp):
|
|
|
11 |
|
| 13629 |
kshitij.so |
12 |
result = Mongo.getAllCategoryDiscount()
|
|
|
13 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
14 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
15 |
|
|
|
16 |
def on_post(self, req, resp):
|
|
|
17 |
|
|
|
18 |
try:
|
|
|
19 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
20 |
except ValueError:
|
|
|
21 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
22 |
'Malformed JSON',
|
|
|
23 |
'Could not decode the request body. The '
|
|
|
24 |
'JSON was incorrect.')
|
|
|
25 |
|
|
|
26 |
result = Mongo.addCategoryDiscount(result_json)
|
|
|
27 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
28 |
|
|
|
29 |
class SkuSchemeDetails(object):
|
|
|
30 |
|
|
|
31 |
def on_get(self, req, resp):
|
| 13629 |
kshitij.so |
32 |
|
| 13635 |
kshitij.so |
33 |
result = Mongo.getAllSkuWiseSchemeDetails()
|
| 13629 |
kshitij.so |
34 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
35 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
36 |
|
|
|
37 |
|
|
|
38 |
def on_post(self, req, resp):
|
|
|
39 |
|
|
|
40 |
try:
|
|
|
41 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
42 |
except ValueError:
|
|
|
43 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
44 |
'Malformed JSON',
|
|
|
45 |
'Could not decode the request body. The '
|
|
|
46 |
'JSON was incorrect.')
|
|
|
47 |
|
|
|
48 |
result = Mongo.addSchemeDetailsForSku(result_json)
|
|
|
49 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
50 |
|
|
|
51 |
class SkuDiscountInfo():
|
|
|
52 |
|
|
|
53 |
def on_get(self, req, resp):
|
| 13629 |
kshitij.so |
54 |
|
|
|
55 |
result = Mongo.getallSkuDiscountInfo()
|
|
|
56 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
57 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
58 |
|
|
|
59 |
|
|
|
60 |
def on_post(self, req, resp):
|
|
|
61 |
|
|
|
62 |
try:
|
|
|
63 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
64 |
except ValueError:
|
|
|
65 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
66 |
'Malformed JSON',
|
|
|
67 |
'Could not decode the request body. The '
|
|
|
68 |
'JSON was incorrect.')
|
|
|
69 |
|
|
|
70 |
result = Mongo.addSkuDiscountInfo(result_json)
|
|
|
71 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
72 |
|
|
|
73 |
class ExceptionalNlc():
|
|
|
74 |
|
|
|
75 |
def on_get(self, req, resp):
|
| 13629 |
kshitij.so |
76 |
|
|
|
77 |
result = Mongo.getAllExceptionlNlcItems()
|
|
|
78 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
79 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
80 |
|
|
|
81 |
def on_post(self, req, resp):
|
|
|
82 |
|
|
|
83 |
try:
|
|
|
84 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
85 |
except ValueError:
|
|
|
86 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
87 |
'Malformed JSON',
|
|
|
88 |
'Could not decode the request body. The '
|
|
|
89 |
'JSON was incorrect.')
|
|
|
90 |
|
|
|
91 |
result = Mongo.addExceptionalNlc(result_json)
|
|
|
92 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
93 |
|
| 13582 |
amit.gupta |
94 |
class StoreOrder():
|
|
|
95 |
def on_post(self, req, resp):
|
|
|
96 |
|
|
|
97 |
try:
|
| 13631 |
amit.gupta |
98 |
string1 = req.stream.read()
|
|
|
99 |
req_json = json.loads(string1, encoding='utf-8')
|
| 13582 |
amit.gupta |
100 |
except ValueError:
|
|
|
101 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
102 |
'Malformed JSON',
|
|
|
103 |
'Could not decode the request body. The '
|
|
|
104 |
'JSON was incorrect.')
|
|
|
105 |
|
| 13631 |
amit.gupta |
106 |
store = main.getStore(int(req_json['sourceId']))
|
|
|
107 |
result = store.parseOrderRawHtml(int(req_json['orderId']), req_json['subTagId'], int(req_json['userId']), req_json['rawHtml'], req_json['orderSuccessUrl'])
|
| 13790 |
kshitij.so |
108 |
resp.body = json.dumps({"result":result}, encoding='utf-8')
|
| 13582 |
amit.gupta |
109 |
|
| 13603 |
amit.gupta |
110 |
def on_get(self, req, resp, userId):
|
|
|
111 |
page = req.get_param_as_int("page")
|
|
|
112 |
window = req.get_param_as_int("window")
|
|
|
113 |
result = Mongo.getMerchantOrdersByUser(int(userId), page, window)
|
|
|
114 |
print result
|
|
|
115 |
resp.body = json.dumps(result, encoding='utf-8')
|
| 13582 |
amit.gupta |
116 |
|
| 13772 |
kshitij.so |
117 |
class Deals():
|
| 13779 |
kshitij.so |
118 |
def on_get(self,req, resp, userId):
|
|
|
119 |
categoryId = req.get_param_as_int("categoryId")
|
|
|
120 |
offset = req.get_param_as_int("offset")
|
|
|
121 |
limit = req.get_param_as_int("limit")
|
| 13772 |
kshitij.so |
122 |
result = Mongo.getDeals(categoryId, offset, limit)
|
|
|
123 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
124 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13790 |
kshitij.so |
125 |
|
|
|
126 |
class MasterData():
|
|
|
127 |
def on_get(self,req, resp, skuId):
|
|
|
128 |
result = Mongo.getItem(skuId)
|
|
|
129 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
130 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
|
|
131 |
|
| 13582 |
amit.gupta |
132 |
|