Пример #1
0
def process_command():
	Now = datetime.now()
        admin_system = User.objects.get(id = 1)
        for item in  CardP2PTransfers.objects.filter(status = "auto"):
		time.sleep(1)
                print "process withdraw %s to card %s date %s amnt is %s" %   (item.user.username,
                                                                               item.CardNumber,
                                                                               item.pub_date,
                                                                               item.amnt )
                if (Now - item.pub_date) > timedelta(seconds = 1800):
                        P24 = get_p24()
                        item.status = "processed"
                        item.save()
                        print "start process" 
			Result = None
                        CardNumber = item.CardNumber
                        CardNumber.replace(" ","")
                        try :
                                NewAmnt = get_comisP2P(CardNumber, item.amnt )
                                Result = P24.pay2p(item.id, CardNumber, NewAmnt)
                        except TransError as e:
                                item.status = "processing"
                                item.save()
                                notify_admin_withdraw_fail(item, e.value)
                        except Exception as e:
                                        i.status = "processing"
                                        i.save()
                                        notify_admin_withdraw_fail(i, str(e) )
                                        continue         
                        if Result :
                                p2p_inner_process(admin_system, item)
                        else:
                                item.status = "core_error"
                                item.save()
                                notify_admin_withdraw_fail(item, "bad_status")
                                
                	                
                        time.sleep(1)
                else :
                        print "it's not a time " 
Пример #2
0
def pay2p(item, P24):
    admin_system = User.objects.get(id=1)
    item.status = "processed"
    item.save()
    Result = None
    CardNumber = item.CardNumber
    CardNumber.replace(" ", "")
    try:
        NewAmnt = get_comisP2P(CardNumber, item.amnt)
        Result = P24.pay2p(item.id, CardNumber, NewAmnt)
    except TransError as e:
        item.status = "core_error"
        item.save()
    except Exception as e:
        i.status = "core_error"
        i.save()

    if Result:
        p2p_inner_process(admin_system, item)
    else:
        item.status = "core_error"
        item.save()