| Line 4... |
Line 4... |
| 4 |
Created on 29-Mar-2010
|
4 |
Created on 29-Mar-2010
|
| 5 |
|
5 |
|
| 6 |
@author: Chandranshu
|
6 |
@author: Chandranshu
|
| 7 |
'''
|
7 |
'''
|
| 8 |
|
8 |
|
| - |
|
9 |
from suds.client import Client
|
| - |
|
10 |
import base64, re
|
| - |
|
11 |
from xml.dom.minidom import parseString
|
| 9 |
from datetime import date, timedelta
|
12 |
from datetime import date, timedelta
|
| 10 |
from decimal import Decimal
|
13 |
from decimal import Decimal
|
| 11 |
from elixir import *
|
14 |
from elixir import *
|
| 12 |
from math import ceil
|
15 |
from math import ceil
|
| 13 |
from random import randrange
|
16 |
from random import randrange
|
| Line 102... |
Line 105... |
| 102 |
mail_password = '5h0p2o2o'
|
105 |
mail_password = '5h0p2o2o'
|
| 103 |
help_user = 'help@shop2020.in'
|
106 |
help_user = 'help@shop2020.in'
|
| 104 |
help_password = '5h0p2o2o'
|
107 |
help_password = '5h0p2o2o'
|
| 105 |
source_url = 'www.saholic.com'
|
108 |
source_url = 'www.saholic.com'
|
| 106 |
source_name = 'Saholic'
|
109 |
source_name = 'Saholic'
|
| - |
|
110 |
hotspot_store_url ='http://182.71.104.186/loaddetect/service.asmx?WSDL'
|
| - |
|
111 |
aclient = None
|
| 107 |
|
112 |
|
| 108 |
PREPAID_SHIPPING_CUTOFF_TIME = 15
|
113 |
PREPAID_SHIPPING_CUTOFF_TIME = 15
|
| 109 |
COD_SHIPPING_CUTOFF_TIME = 12
|
114 |
COD_SHIPPING_CUTOFF_TIME = 12
|
| 110 |
|
115 |
|
| 111 |
PAGE_HEIGHT=defaultPageSize[1]
|
116 |
PAGE_HEIGHT=defaultPageSize[1]
|
| Line 128... |
Line 133... |
| 128 |
'110087','110088','110089','110091','110092','110093','110094','110095','110096','110101','110103','110104','110105','110106','110107',\
|
133 |
'110087','110088','110089','110091','110092','110093','110094','110095','110096','110101','110103','110104','110105','110106','110107',\
|
| 129 |
'110108','110109','110110','110112','110113','110114','110115','110116','110117','110118','110119','110120','110122','110124','110125',\
|
134 |
'110108','110109','110110','110112','110113','110114','110115','110116','110117','110118','110119','110120','110122','110124','110125',\
|
| 130 |
'110301','110302','110501','110502','110503','110504','110505','110510','110511','110512','110601','110602','110603','110604','110605',\
|
135 |
'110301','110302','110501','110502','110503','110504','110505','110510','110511','110512','110601','110602','110603','110604','110605',\
|
| 131 |
'110606','110607','110608','110609']
|
136 |
'110606','110607','110608','110609']
|
| 132 |
|
137 |
|
| - |
|
138 |
def get_store_account_client():
|
| - |
|
139 |
global aclient
|
| - |
|
140 |
if aclient is None:
|
| - |
|
141 |
aclient = Client(hotspot_store_url, timeout=70)
|
| - |
|
142 |
return aclient
|
| - |
|
143 |
|
| 133 |
def get_new_transaction():
|
144 |
def get_new_transaction():
|
| 134 |
transaction = Transaction()
|
145 |
transaction = Transaction()
|
| 135 |
transaction.createdOn = datetime.datetime.now()
|
146 |
transaction.createdOn = datetime.datetime.now()
|
| 136 |
transaction.status = TransactionStatus.INIT
|
147 |
transaction.status = TransactionStatus.INIT
|
| 137 |
transaction.status_message = "New transaction"
|
148 |
transaction.status_message = "New transaction"
|
| Line 3022... |
Line 3033... |
| 3022 |
session.commit()
|
3033 |
session.commit()
|
| 3023 |
|
3034 |
|
| 3024 |
try:
|
3035 |
try:
|
| 3025 |
rcs = StoreOrderCollection.query.filter(StoreOrderCollection.pushedToOcr == False).all()
|
3036 |
rcs = StoreOrderCollection.query.filter(StoreOrderCollection.pushedToOcr == False).all()
|
| 3026 |
for cs in rcs:
|
3037 |
for cs in rcs:
|
| 3027 |
store_string = "<Store>" + cs.hotspotId + "</Store>"
|
- |
|
| 3028 |
order_string = "<OrderID>" + str(cs.orderId) + "</OrderID>"
|
- |
|
| 3029 |
product_string = "<Product>" + cs.productName + "</Product>"
|
- |
|
| 3030 |
collection_type = "<CollectionType>" + cs.collectionType + "</CollectionType>"
|
- |
|
| 3031 |
amount_string = "<AdvanceAmount>" + str(cs.advanceAmount) + "</AdvanceAmount>"
|
- |
|
| 3032 |
date_string = "<Date>" + cs.addedAt.strftime("%Y%m%d") + "</Date>"
|
- |
|
| 3033 |
time_string = "<Time>" + cs.addedAt.strftime("%H%M%S") + "</Time>"
|
- |
|
| 3034 |
cash_string = "<CashAmount>" + str(cs.cash) + "</CashAmount>"
|
- |
|
| 3035 |
card_string = "<CardAmount>" + str(cs.card) + "</CardAmount>"
|
- |
|
| 3036 |
|
- |
|
| 3037 |
#advance, saleClosure, advanceRefund, cashRefund, cardRefund
|
- |
|
| 3038 |
|
- |
|
| 3039 |
conn = httplib.HTTPConnection("182.71.104.186")
|
- |
|
| 3040 |
XML="""
|
- |
|
| 3041 |
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
3038 |
#SaholicAdvanceTransfer(xs:string Store, xs:string OrderID, xs:string Product, xs:string CollectionType, xs:decimal AdvanceAmount, xs:decimal CashAmount, xs:decimal CardAmount, xs:string Time, xs:string Date, )
|
| 3042 |
<soap:Body>
|
- |
|
| 3043 |
<SaholicAdvanceTransfer xmlns="http://tempuri.org/">
|
- |
|
| 3044 |
"""
|
- |
|
| 3045 |
|
- |
|
| 3046 |
XML = XML + store_string + order_string + product_string + collection_type + amount_string + cash_string + card_string + time_string + date_string
|
3039 |
resp = get_store_account_client().service.SaholicAdvanceTransfer(cs.hotspotId,str(cs.orderId),cs.productName,cs.collectionType,float(cs.advanceAmount),float(cs.cash),float(cs.card),cs.addedAt.strftime("%H%M%S"),cs.addedAt.strftime("%Y%m%d"))
|
| 3047 |
|
- |
|
| 3048 |
footer = """
|
- |
|
| 3049 |
</SaholicAdvanceTransfer>
|
- |
|
| 3050 |
</soap:Body>
|
- |
|
| 3051 |
</soap:Envelope>
|
- |
|
| 3052 |
"""
|
- |
|
| 3053 |
XML = XML + footer
|
- |
|
| 3054 |
|
- |
|
| 3055 |
params = urllib.urlencode({'op': 'SaholicAdvanceTransfer'})
|
- |
|
| 3056 |
headers = { "Content-type": "text/xml", "Content-Length": "%d" % len(XML)}
|
- |
|
| 3057 |
conn.request("POST", "/loaddetect/Service.asmx?"+params, "", headers)
|
- |
|
| 3058 |
conn.send(XML)
|
- |
|
| 3059 |
response = conn.getresponse()
|
- |
|
| 3060 |
print response.status, response.reason
|
- |
|
| 3061 |
resp = response.read()
|
- |
|
| 3062 |
conn.close()
|
- |
|
| 3063 |
print resp
|
3040 |
print resp
|
| 3064 |
if "Saved Successfully" in resp:
|
3041 |
if "Saved Successfully" in resp:
|
| 3065 |
cs.pushedToOcr = True
|
3042 |
cs.pushedToOcr = True
|
| 3066 |
cs.pushedAt = datetime.datetime.now()
|
3043 |
cs.pushedAt = datetime.datetime.now()
|
| 3067 |
session.commit()
|
3044 |
session.commit()
|
| Line 3081... |
Line 3058... |
| 3081 |
storeName = '109'
|
3058 |
storeName = '109'
|
| 3082 |
else:
|
3059 |
else:
|
| 3083 |
logistics_client = LogisticsClient().get_client()
|
3060 |
logistics_client = LogisticsClient().get_client()
|
| 3084 |
store = logistics_client.getPickupStore(order.pickupStoreId)
|
3061 |
store = logistics_client.getPickupStore(order.pickupStoreId)
|
| 3085 |
storeName = store.hotspotId
|
3062 |
storeName = store.hotspotId
|
| 3086 |
store_string = "<store>" + storeName + "</store>"
|
- |
|
| 3087 |
order_string = "<orderno>" + str(order.id) + "</orderno>"
|
- |
|
| 3088 |
collection_type = "<Type>" + type + "</Type>"
|
- |
|
| 3089 |
payment_mode = get_order_attribute_value(order.id, "PAYMENT_MODE")
|
3063 |
payment_mode = get_order_attribute_value(order.id, "PAYMENT_MODE")
|
| 3090 |
if type == "SALE":
|
3064 |
if type == "SALE":
|
| 3091 |
if storeOrder:
|
3065 |
if storeOrder:
|
| 3092 |
amount = int(order.advanceAmount)
|
3066 |
amount = int(order.advanceAmount)
|
| 3093 |
ts = order.created_timestamp
|
3067 |
ts = order.created_timestamp
|
| Line 3099... |
Line 3073... |
| 3099 |
amount = -int(order.advanceAmount)
|
3073 |
amount = -int(order.advanceAmount)
|
| 3100 |
else:
|
3074 |
else:
|
| 3101 |
amount = -int(order.total_amount-order.gvAmount)
|
3075 |
amount = -int(order.total_amount-order.gvAmount)
|
| 3102 |
ts = order.refund_timestamp
|
3076 |
ts = order.refund_timestamp
|
| 3103 |
if payment_mode == "Cash":
|
3077 |
if payment_mode == "Cash":
|
| 3104 |
cash_string = "<cash>" + str(amount) + "</cash>"
|
3078 |
cash_int = amount
|
| 3105 |
card_string = "<hdfc>0</hdfc>"
|
3079 |
card_int = 0
|
| 3106 |
if payment_mode == "Card":
|
3080 |
if payment_mode == "Card":
|
| 3107 |
cash_string = "<cash>0</cash>"
|
3081 |
cash_int = 0
|
| 3108 |
card_string = "<hdfc>" + str(amount) + "</hdfc>"
|
- |
|
| 3109 |
date_string = "<date>" + ts.strftime("%Y%m%d") + "</date>"
|
- |
|
| 3110 |
time_string = "<time>" + ts.strftime("%H%M%S") + "</time>"
|
- |
|
| 3111 |
|
- |
|
| 3112 |
conn = httplib.HTTPConnection("182.71.104.186")
|
- |
|
| 3113 |
XML="""
|
- |
|
| 3114 |
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
- |
|
| 3115 |
<soap:Body>
|
3082 |
card_int = amount
|
| 3116 |
<SaholicDataTransfer xmlns="http://tempuri.org/">
|
- |
|
| 3117 |
"""
|
- |
|
| 3118 |
|
- |
|
| 3119 |
XML = XML + store_string + order_string + collection_type + cash_string + card_string + date_string + time_string
|
3083 |
#SaholicDataTransfer(xs:string store, xs:string orderno, xs:string Type, xs:int cash, xs:int hdfc, xs:int date, xs:int time, )
|
| 3120 |
|
- |
|
| 3121 |
footer = """
|
- |
|
| 3122 |
</SaholicDataTransfer>
|
- |
|
| 3123 |
</soap:Body>
|
- |
|
| 3124 |
</soap:Envelope>
|
- |
|
| 3125 |
"""
|
- |
|
| 3126 |
XML = XML + footer
|
- |
|
| 3127 |
|
- |
|
| 3128 |
params = urllib.urlencode({'op': 'SaholicDataTransfer'})
|
- |
|
| 3129 |
headers = { "Content-type": "text/xml", "Content-Length": "%d" % len(XML)}
|
3084 |
resp = get_store_account_client().service.SaholicDataTransfer(storeName,str(order.id),type,cash_int,card_int,int(ts.strftime("%Y%m%d")),int(ts.strftime("%H%M%S")))
|
| 3130 |
conn.request("POST", "/loaddetect/Service.asmx?"+params, "", headers)
|
- |
|
| 3131 |
conn.send(XML)
|
- |
|
| 3132 |
response = conn.getresponse()
|
- |
|
| 3133 |
print response.status, response.reason
|
- |
|
| 3134 |
resp = response.read()
|
- |
|
| 3135 |
conn.close()
|
- |
|
| 3136 |
print resp
|
3085 |
print resp
|
| 3137 |
if "Saved Successfully" in resp:
|
3086 |
if "Saved Successfully" in resp:
|
| 3138 |
return True
|
3087 |
return True
|
| 3139 |
elif "Error in Saving Data" in resp:
|
3088 |
elif "Error in Saving Data" in resp:
|
| 3140 |
return False
|
3089 |
return False
|