| 13572 |
kshitij.so |
1 |
import falcon
|
|
|
2 |
import json
|
| 13582 |
amit.gupta |
3 |
from dtr import main
|
| 13572 |
kshitij.so |
4 |
from dtr.storage import Mongo
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
class CategoryDiscountInfo(object):
|
|
|
8 |
|
|
|
9 |
def on_get(self, req, resp):
|
|
|
10 |
|
|
|
11 |
resp.body = str(Mongo.getAllCategoryDiscount())
|
|
|
12 |
|
|
|
13 |
def on_post(self, req, resp):
|
|
|
14 |
|
|
|
15 |
try:
|
|
|
16 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
17 |
except ValueError:
|
|
|
18 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
19 |
'Malformed JSON',
|
|
|
20 |
'Could not decode the request body. The '
|
|
|
21 |
'JSON was incorrect.')
|
|
|
22 |
|
|
|
23 |
result = Mongo.addCategoryDiscount(result_json)
|
|
|
24 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
25 |
|
|
|
26 |
class SkuSchemeDetails(object):
|
|
|
27 |
|
|
|
28 |
def on_get(self, req, resp):
|
|
|
29 |
|
|
|
30 |
resp.body = str(Mongo.getAllSkuWiseSchemeDetails())
|
|
|
31 |
|
|
|
32 |
def on_post(self, req, resp):
|
|
|
33 |
|
|
|
34 |
try:
|
|
|
35 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
36 |
except ValueError:
|
|
|
37 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
38 |
'Malformed JSON',
|
|
|
39 |
'Could not decode the request body. The '
|
|
|
40 |
'JSON was incorrect.')
|
|
|
41 |
|
|
|
42 |
result = Mongo.addSchemeDetailsForSku(result_json)
|
|
|
43 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
44 |
|
|
|
45 |
class SkuDiscountInfo():
|
|
|
46 |
|
|
|
47 |
def on_get(self, req, resp):
|
|
|
48 |
|
|
|
49 |
resp.body = str(Mongo.getallSkuDiscountInfo())
|
|
|
50 |
|
|
|
51 |
def on_post(self, req, resp):
|
|
|
52 |
|
|
|
53 |
try:
|
|
|
54 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
55 |
except ValueError:
|
|
|
56 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
57 |
'Malformed JSON',
|
|
|
58 |
'Could not decode the request body. The '
|
|
|
59 |
'JSON was incorrect.')
|
|
|
60 |
|
|
|
61 |
result = Mongo.addSkuDiscountInfo(result_json)
|
|
|
62 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
63 |
|
|
|
64 |
class ExceptionalNlc():
|
|
|
65 |
|
|
|
66 |
def on_get(self, req, resp):
|
|
|
67 |
|
|
|
68 |
resp.body = str(Mongo.getAllExceptionlNlcItems())
|
|
|
69 |
|
|
|
70 |
def on_post(self, req, resp):
|
|
|
71 |
|
|
|
72 |
try:
|
|
|
73 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
74 |
except ValueError:
|
|
|
75 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
76 |
'Malformed JSON',
|
|
|
77 |
'Could not decode the request body. The '
|
|
|
78 |
'JSON was incorrect.')
|
|
|
79 |
|
|
|
80 |
result = Mongo.addExceptionalNlc(result_json)
|
|
|
81 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
82 |
|
| 13582 |
amit.gupta |
83 |
class StoreOrder():
|
|
|
84 |
def on_post(self, req, resp):
|
|
|
85 |
|
|
|
86 |
try:
|
| 13603 |
amit.gupta |
87 |
req_json = json.loads(req.stream.read(), encoding='utf-8')
|
| 13582 |
amit.gupta |
88 |
except ValueError:
|
|
|
89 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
90 |
'Malformed JSON',
|
|
|
91 |
'Could not decode the request body. The '
|
|
|
92 |
'JSON was incorrect.')
|
|
|
93 |
|
| 13603 |
amit.gupta |
94 |
store = main.getStore(req_json['sourceId'])
|
|
|
95 |
result = store.parseOrderRawHtml(req_json['orderId'], req_json['subTagId'], req_json['userId'], req_json['rawHtml'], req_json['orderSuccessUrl'])
|
| 13582 |
amit.gupta |
96 |
resp.body = json.dumps({"result":result}, encoding='utf-8')
|
|
|
97 |
|
| 13603 |
amit.gupta |
98 |
def on_get(self, req, resp, userId):
|
|
|
99 |
page = req.get_param_as_int("page")
|
|
|
100 |
window = req.get_param_as_int("window")
|
|
|
101 |
result = Mongo.getMerchantOrdersByUser(int(userId), page, window)
|
|
|
102 |
print result
|
|
|
103 |
resp.body = json.dumps(result, encoding='utf-8')
|
| 13582 |
amit.gupta |
104 |
|
|
|
105 |
|