Subversion Repositories SmartDukaan

Rev

Rev 7292 | Rev 7303 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7292 Rev 7293
Line 60... Line 60...
60
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
60
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
61
    InventoryServiceException, WarehouseType, InventoryType
61
    InventoryServiceException, WarehouseType, InventoryType
62
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
62
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
63
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
63
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
64
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
64
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
65
    RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod
65
    RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, OrderSource
66
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
66
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
67
from shop2020.thriftpy.payments.ttypes import PaymentException
67
from shop2020.thriftpy.payments.ttypes import PaymentException
68
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
68
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
69
    WarehouseServiceException
69
    WarehouseServiceException
70
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
70
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
Line 170... Line 170...
170
        insuranceDetail.dob = t_order.dob
170
        insuranceDetail.dob = t_order.dob
171
        insuranceDetail.guardianName = t_order.guardianName
171
        insuranceDetail.guardianName = t_order.guardianName
172
        insuranceDetail.order = order
172
        insuranceDetail.order = order
173
    if t_order.freebieItemId:
173
    if t_order.freebieItemId:
174
        order.freebieItemId = t_order.freebieItemId
174
        order.freebieItemId = t_order.freebieItemId
-
 
175
    order.source = t_order.source
-
 
176
    order.advanceAmount = t_order.advanceAmount
-
 
177
    order.storeId = t_order.storeId
175
    return order
178
    return order
176
    
179
    
177
def create_transaction(t_transaction):
180
def create_transaction(t_transaction):
178
    t_orders = t_transaction.orders
181
    t_orders = t_transaction.orders
179
    if not t_orders:
182
    if not t_orders:
Line 289... Line 292...
289
    
292
    
290
    transaction = get_transaction(transaction_id)
293
    transaction = get_transaction(transaction_id)
291
    
294
    
292
    return transaction.status
295
    return transaction.status
293
 
296
 
294
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType):
297
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
295
    transaction = get_transaction(transaction_id)
298
    transaction = get_transaction(transaction_id)
296
    transaction.status = new_status
299
    transaction.status = new_status
297
    transaction.status_message = description
300
    transaction.status_message = description
298
    ## Assign runner in case of delhi pincodes
301
    ## Assign runner in case of delhi pincodes
299
    if transaction.orders[0].pickupStoreId:
302
    if transaction.orders[0].pickupStoreId:
Line 376... Line 379...
376
                # Will not provide OTG in pickup store
379
                # Will not provide OTG in pickup store
377
                order.otg = False
380
                order.otg = False
378
            else:
381
            else:
379
                logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.COD, pickUp)
382
                logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.COD, pickUp)
380
                order.otg = logistics_info.otgAvailable
383
                order.otg = logistics_info.otgAvailable
-
 
384
                
-
 
385
            if order.source == OrderSource.STORE:
-
 
386
                catalog_client = CatalogClient().get_client() 
-
 
387
                sourcePricing = catalog_client.getStorePricing(item_id)
-
 
388
                if order.total_amount > sourcePricing.maxPrice:
-
 
389
                    raise TransactionServiceException(199, "Order amount exceeded max price for item")
-
 
390
                elif order.total_amount > sourcePricing.minPrice:
-
 
391
                    order.status = OrderStatus.SUBMITTED_FOR_PROCESSING
381
 
392
 
382
            current_time = datetime.datetime.now()
393
            current_time = datetime.datetime.now()
383
            logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
394
            logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
384
            logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
395
            logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
385
            logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
396
            logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
Line 1166... Line 1177...
1166
    try:
1177
    try:
1167
        payment_client = PaymentClient().get_client()
1178
        payment_client = PaymentClient().get_client()
1168
        capture_result = payment_client.capturePayment(txnId)
1179
        capture_result = payment_client.capturePayment(txnId)
1169
        if capture_result:
1180
        if capture_result:
1170
            logging.info("Successfully captured payment for merchant txn:" + str(txnId))
1181
            logging.info("Successfully captured payment for merchant txn:" + str(txnId))
1171
            change_transaction_status(txnId, TransactionStatus.IN_PROCESS, "Payment received", PickUpType.COURIER, order.orderType)
1182
            change_transaction_status(txnId, TransactionStatus.IN_PROCESS, "Payment received", PickUpType.COURIER, order.orderType, order.source)
1172
        else:
1183
        else:
1173
            raise TransactionServiceException(115, "Payment capture failed.")
1184
            raise TransactionServiceException(115, "Payment capture failed.")
1174
    except PaymentException as e:
1185
    except PaymentException as e:
1175
        if e.error_code == 106:
1186
        if e.error_code == 106:
1176
            order.status = OrderStatus.CAPTURE_IN_PROCESS
1187
            order.status = OrderStatus.CAPTURE_IN_PROCESS