| Line 17... |
Line 17... |
| 17 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
17 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 18 |
from shop2020.clients.PaymentClient import PaymentClient
|
18 |
from shop2020.clients.PaymentClient import PaymentClient
|
| 19 |
from shop2020.clients.UserClient import UserClient
|
19 |
from shop2020.clients.UserClient import UserClient
|
| 20 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
20 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
| 21 |
from shop2020.model.v1 import order
|
21 |
from shop2020.model.v1 import order
|
| 22 |
from shop2020.model.v1.order.impl import DataService
|
22 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
| 23 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
23 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
| 24 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
24 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
| 25 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
25 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
| 26 |
CodVerificationAgent, Attribute, RechargeVoucherTracker
|
26 |
CodVerificationAgent, Attribute, RechargeVoucherTracker
|
| 27 |
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
|
27 |
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
|
| Line 33... |
Line 33... |
| 33 |
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
|
33 |
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
|
| 34 |
InventoryServiceException, WarehouseType, InventoryType
|
34 |
InventoryServiceException, WarehouseType, InventoryType
|
| 35 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
35 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
| 36 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
36 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
| 37 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType,\
|
37 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType,\
|
| 38 |
RechargeOrderStatus
|
38 |
RechargeOrderStatus, RechargeType
|
| 39 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
|
39 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
|
| 40 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
40 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 41 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
41 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
| 42 |
WarehouseServiceException
|
42 |
WarehouseServiceException
|
| 43 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
43 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
| Line 57... |
Line 57... |
| 57 |
import urllib
|
57 |
import urllib
|
| 58 |
from shop2020.config.client.ConfigClient import ConfigClient
|
58 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 59 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
59 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
| 60 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
60 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
| 61 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import UserWalletHistory
|
61 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import UserWalletHistory
|
| - |
|
62 |
from shop2020.model.v1.order.impl.model.ServiceProvider import ServiceProvider
|
| - |
|
63 |
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
|
| 62 |
|
64 |
|
| 63 |
logging.basicConfig(level=logging.DEBUG)
|
65 |
logging.basicConfig(level=logging.DEBUG)
|
| 64 |
|
66 |
|
| 65 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
67 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
| 66 |
mail_user = 'cnc.center@shop2020.in'
|
68 |
mail_user = 'cnc.center@shop2020.in'
|
| Line 451... |
Line 453... |
| 451 |
<td colspan=5>Total Amount</td>
|
453 |
<td colspan=5>Total Amount</td>
|
| 452 |
<td> Rs. $total_amount</td>
|
454 |
<td> Rs. $total_amount</td>
|
| 453 |
</tr>
|
455 |
</tr>
|
| 454 |
</table>
|
456 |
</table>
|
| 455 |
</div>
|
457 |
</div>
|
| 456 |
<br>Congratulations, your order qualifies for the <b><i>Oh My God Contest</i></b>. Please check the details at <a href="$source_url/static/oh-my-god-contest"> T & C page </a> . We will get in touch with you on the Prize announcement dates, if you are the Lucky Winner.<br>
|
- |
|
| 457 |
"""
|
458 |
"""
|
| 458 |
|
459 |
|
| 459 |
store_address = ""
|
460 |
store_address = ""
|
| 460 |
if orders[0].pickupStoreId:
|
461 |
if orders[0].pickupStoreId:
|
| 461 |
store = LogisticsClient().get_client().getPickupStore(orders[0].pickupStoreId)
|
462 |
store = LogisticsClient().get_client().getPickupStore(orders[0].pickupStoreId)
|
| Line 3358... |
Line 3359... |
| 3358 |
session.commit()
|
3359 |
session.commit()
|
| 3359 |
if not quantity:
|
3360 |
if not quantity:
|
| 3360 |
break
|
3361 |
break
|
| 3361 |
|
3362 |
|
| 3362 |
def get_recharge_order(rechargeOrderId):
|
3363 |
def get_recharge_order(rechargeOrderId):
|
| 3363 |
return RechargeOrder.get_by(id = rechargeOrderId).to_thrift_object()
|
3364 |
return RechargeOrder.get_by(id = rechargeOrderId)
|
| 3364 |
|
3365 |
|
| 3365 |
def get_recharge_orders(userId):
|
3366 |
def get_recharge_orders(userId):
|
| 3366 |
return RechargeOrder.query.filter_by(userId = userId).all()
|
3367 |
return RechargeOrder.query.filter_by(userId = userId).all()
|
| 3367 |
|
3368 |
|
| 3368 |
def update_recharge_order_status(rechargeOrderId, rechargeOrderStatus):
|
3369 |
def update_recharge_order_status(rechargeOrderId, rechargeOrderStatus):
|
| Line 3382... |
Line 3383... |
| 3382 |
recharge_order.status = RechargeOrderStatus.PAYMENT_SUCCESSFUL
|
3383 |
recharge_order.status = RechargeOrderStatus.PAYMENT_SUCCESSFUL
|
| 3383 |
session.commit()
|
3384 |
session.commit()
|
| 3384 |
raise TransactionServiceException(103, 'Wallet amount has already been used')
|
3385 |
raise TransactionServiceException(103, 'Wallet amount has already been used')
|
| 3385 |
|
3386 |
|
| 3386 |
|
3387 |
|
| 3387 |
if activate_recharge_txn(rechargeOrderId):
|
3388 |
if activate_recharge_txn(recharge_order):
|
| 3388 |
rechargeOrderStatus = RechargeOrderStatus.RECHARGE_SUCCESSFUL
|
3389 |
recharge_order.rechargeOrderStatus = RechargeOrderStatus.RECHARGE_SUCCESSFUL
|
| 3389 |
session.commit()
|
3390 |
session.commit()
|
| 3390 |
return True
|
3391 |
return True
|
| 3391 |
else:
|
3392 |
else:
|
| 3392 |
rechargeOrderStatus = RechargeOrderStatus.RECHARGE_FAILED
|
3393 |
recharge_order.rechargeOrderStatus = RechargeOrderStatus.RECHARGE_FAILED
|
| 3393 |
update_amount_in_wallet(recharge_order.userId, recharge_order.walletAmount, recharge_order.id)
|
3394 |
update_amount_in_wallet(recharge_order.userId, recharge_order.walletAmount, recharge_order.id)
|
| 3394 |
update_amount_in_wallet(recharge_order.userId, recharge_order.totalAmount - recharge_order.walletAmount, recharge_order.id)
|
3395 |
update_amount_in_wallet(recharge_order.userId, recharge_order.totalAmount - recharge_order.walletAmount, recharge_order.id)
|
| 3395 |
session.commit()
|
3396 |
session.commit()
|
| 3396 |
return False
|
3397 |
return False
|
| 3397 |
|
3398 |
|
| 3398 |
def activate_recharge_txn(rechargeOrderId):
|
3399 |
def activate_recharge_txn(recharge_order):
|
| - |
|
3400 |
print type(recharge_order)
|
| - |
|
3401 |
if isinstance(recharge_order, MobileRechargeOrder):
|
| - |
|
3402 |
rechargeType = 'MTP'
|
| - |
|
3403 |
deviceNumber = recharge_order.mobileNumber
|
| - |
|
3404 |
strProviderCode = get_provider_code(recharge_order.mobileOperatorId)
|
| - |
|
3405 |
if isinstance(recharge_order, DTHRechargeOrder):
|
| - |
|
3406 |
rechargeType = 'RCH'
|
| - |
|
3407 |
deviceNumber = recharge_order.dthAccountNumber
|
| - |
|
3408 |
strProviderCode = get_provider_code(recharge_order.dthOperatorId)
|
| - |
|
3409 |
|
| - |
|
3410 |
try:
|
| - |
|
3411 |
retStatus, retCode, spiceTID = RechargeService.rechargeDevice(recharge_order.id, rechargeType, strProviderCode, deviceNumber, recharge_order.totalAmount)
|
| - |
|
3412 |
if retCode == '00' and retStatus == 'S':
|
| - |
|
3413 |
recharge_order.spiceTID = spiceTID
|
| - |
|
3414 |
recharge_order.responseTimestamp = datetime.datetime.now()
|
| - |
|
3415 |
session.commit()
|
| - |
|
3416 |
return True
|
| - |
|
3417 |
else:
|
| - |
|
3418 |
recharge_order.spiceTID = spiceTID
|
| - |
|
3419 |
recharge_order.responseTimestamp = datetime.datetime.now()
|
| - |
|
3420 |
session.commit()
|
| - |
|
3421 |
return False
|
| - |
|
3422 |
except:
|
| 3399 |
return False
|
3423 |
return False
|
| 3400 |
|
3424 |
|
| 3401 |
def get_user_wallet(userId):
|
3425 |
def get_user_wallet(userId):
|
| 3402 |
wallet = UserWallet.get_by(userId = userId)
|
3426 |
wallet = UserWallet.get_by(userId = userId)
|
| 3403 |
if not wallet:
|
3427 |
if not wallet:
|
| 3404 |
wallet = UserWallet()
|
3428 |
wallet = UserWallet()
|
| Line 3411... |
Line 3435... |
| 3411 |
if wallet.id:
|
3435 |
if wallet.id:
|
| 3412 |
return UserWalletHistory.query.filter_by(wallet = wallet).all()
|
3436 |
return UserWalletHistory.query.filter_by(wallet = wallet).all()
|
| 3413 |
else:
|
3437 |
else:
|
| 3414 |
return []
|
3438 |
return []
|
| 3415 |
|
3439 |
|
| - |
|
3440 |
def get_provider_code(providerId):
|
| - |
|
3441 |
return ServiceProvider.query.filter_by(id = providerId).one().code
|
| 3416 |
|
3442 |
|
| - |
|
3443 |
def get_service_providers(recharge_type):
|
| - |
|
3444 |
providers = ServiceProvider.query.filter_by(type = recharge_type, status = 1).all()
|
| - |
|
3445 |
serviceProviders = {}
|
| - |
|
3446 |
for provider in providers:
|
| - |
|
3447 |
serviceProviders[provider.id] = provider.name
|
| - |
|
3448 |
return serviceProviders
|
| - |
|
3449 |
|
| - |
|
3450 |
def get_service_provider_for_device(deviceNumber):
|
| - |
|
3451 |
return 0
|
| - |
|
3452 |
|
| 3417 |
def update_amount_in_wallet(userId, amount, orderId):
|
3453 |
def update_amount_in_wallet(userId, amount, orderId):
|
| 3418 |
if amount == 0:
|
3454 |
if amount == 0:
|
| 3419 |
return
|
3455 |
return
|
| 3420 |
wallet = get_user_wallet(userId)
|
3456 |
wallet = get_user_wallet(userId)
|
| 3421 |
wallet.amount = wallet.amount + amount
|
3457 |
wallet.amount = wallet.amount + amount
|
| Line 3424... |
Line 3460... |
| 3424 |
history.amount = amount
|
3460 |
history.amount = amount
|
| 3425 |
history.orderId = orderId
|
3461 |
history.orderId = orderId
|
| 3426 |
history.wallet = wallet
|
3462 |
history.wallet = wallet
|
| 3427 |
history.timestamp = datetime.datetime.now()
|
3463 |
history.timestamp = datetime.datetime.now()
|
| 3428 |
session.commit()
|
3464 |
session.commit()
|
| - |
|
3465 |
|
| 3429 |
|
3466 |
|
| 3430 |
|
3467 |
|
| 3431 |
def close_session():
|
3468 |
def close_session():
|
| 3432 |
if session.is_active:
|
3469 |
if session.is_active:
|
| 3433 |
print "session is active. closing it."
|
3470 |
print "session is active. closing it."
|