| 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, RechargeType
|
38 |
RechargeOrderStatus, RechargeType, RechargeStatistics
|
| 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 3511... |
Line 3511... |
| 3511 |
orders = RechargeOrder.query.order_by(desc(RechargeOrder.id)).all()
|
3511 |
orders = RechargeOrder.query.order_by(desc(RechargeOrder.id)).all()
|
| 3512 |
else:
|
3512 |
else:
|
| 3513 |
orders = RechargeOrder.query.order_by(desc(RechargeOrder.id)).filter_by(status = status).all()
|
3513 |
orders = RechargeOrder.query.order_by(desc(RechargeOrder.id)).filter_by(status = status).all()
|
| 3514 |
return orders
|
3514 |
return orders
|
| 3515 |
|
3515 |
|
| - |
|
3516 |
def get_recharge_statistics():
|
| - |
|
3517 |
rs = RechargeStatistics()
|
| - |
|
3518 |
statusCounts = {}
|
| - |
|
3519 |
operatorCounts = {}
|
| - |
|
3520 |
currentOrders = {}
|
| - |
|
3521 |
amounts = {}
|
| - |
|
3522 |
|
| - |
|
3523 |
sorders = session.query(RechargeOrder.status, func.count(RechargeOrder.status)).group_by(RechargeOrder.status).all()
|
| - |
|
3524 |
for sorder in sorders:
|
| - |
|
3525 |
statusCounts[sorder.status] = sorder.count
|
| - |
|
3526 |
|
| - |
|
3527 |
oorders = session.query(MobileRechargeOrder.mobileOperatorId, func.count(MobileRechargeOrder.mobileOperatorId)).group_by(MobileRechargeOrder.mobileOperatorId).all()
|
| - |
|
3528 |
for oorder in oorders:
|
| - |
|
3529 |
operatorCounts[oorder.status] = oorder.count
|
| - |
|
3530 |
|
| - |
|
3531 |
oorders = session.query(DTHRechargeOrder.dthOperatorId, func.count(DTHRechargeOrder.dthOperatorId)).group_by(DTHRechargeOrder.dthOperatorId).all()
|
| - |
|
3532 |
for oorder in oorders:
|
| - |
|
3533 |
operatorCounts[oorder.status] = oorder.count
|
| - |
|
3534 |
|
| - |
|
3535 |
forders = RechargeOrder.query.order_by(desc(RechargeOrder.id)).filter_by(status = RechargeOrderStatus.RECHARGE_FAILED).limit(10).all()
|
| - |
|
3536 |
currentOrders[RechargeOrderStatus._VALUES_TO_NAMES.get(RechargeOrderStatus.RECHARGE_FAILED)] = [order.to_thrift_object() for order in forders]
|
| - |
|
3537 |
sorders = RechargeOrder.query.order_by(desc(RechargeOrder.id)).filter_by(status = RechargeOrderStatus.RECHARGE_SUCCESSFUL).limit(20).all()
|
| - |
|
3538 |
currentOrders[RechargeOrderStatus._VALUES_TO_NAMES.get(RechargeOrderStatus.RECHARGE_SUCCESSFUL)] = [order.to_thrift_object() for order in forders]
|
| - |
|
3539 |
|
| - |
|
3540 |
amounts['Total Wallet Amount'] = session.query(func.sum(UserWallet.amount)).all()
|
| - |
|
3541 |
amounts['Recharge Amount'] = session.query(func.sum(RechargeOrder.totalAmount)).filter(RechargeOrder.status == RechargeOrderStatus.RECHARGE_SUCCESSFUL).scaler()
|
| - |
|
3542 |
amounts['Gift Wallet Amount'] = session.query(func.sum(UserWalletHistory.amount)).filter(UserWalletHistory.orderId > 100000).all()
|
| - |
|
3543 |
amounts['Payment Amount'] = session.query(func.sum(UserWalletHistory.amount)).filter(UserWalletHistory.orderId < 100000).all()
|
| - |
|
3544 |
|
| - |
|
3545 |
rs.statusCounts = statusCounts
|
| - |
|
3546 |
rs.operatorCounts = operatorCounts
|
| - |
|
3547 |
rs.currentOrders = currentOrders
|
| - |
|
3548 |
rs.amounts = amounts
|
| - |
|
3549 |
|
| - |
|
3550 |
return rs
|
| - |
|
3551 |
|
| - |
|
3552 |
|
| 3516 |
def get_plans_for_operator(operator_id):
|
3553 |
def get_plans_for_operator(operator_id):
|
| 3517 |
return RechargePlan.query.filter_by(operatorId = operator_id).all()
|
3554 |
return RechargePlan.query.filter_by(operatorId = operator_id).all()
|
| 3518 |
|
3555 |
|
| 3519 |
def get_recharge_orders_for_transaction(txId):
|
3556 |
def get_recharge_orders_for_transaction(txId):
|
| 3520 |
return RechargeOrder.query.filter_by(transaction_id = txId).first()
|
3557 |
return RechargeOrder.query.filter_by(transaction_id = txId).first()
|