コード例 #1
0
ファイル: views.py プロジェクト: jkbrother/three_3d_ilove
def good_custom(request):
    custom_id = request.POST.get('custom_id')
    custom_info = GoodsCustomization.objects.get(id = custom_id)
    custom_state = custom_info.custom_state
    custom_bill_thirty = custom_info.bill_id_thirty
    custom_bill_seventy = custom_info.bill_id_seventy
    custom_price = custom_info.custom_price

    #支付30保证金
    if custom_state == '1':
        custom_bill_thirty = cart_views.random_str()
        goodsbill = Goodsbill.objects.filter(bill_id = custom_bill_thirty)
        if(not goodsbill):
            #将保证金信息存入Goodsbill表
            goodsbill = Goodsbill(bill_id=custom_bill_thirty,
                subject='保证金支付',
                bill_body='支付30%保证金',
                total_fee=0.3*custom_price,
                trade_status='init',
                start_date=datetime.datetime.now(),
                expire_date=datetime.datetime.now(),
                add_time=datetime.datetime.now(),
                bill_state = 'cus',
                custom_id = custom_id
             )
        goodsbill.save()
        custom_info.save()
        return HttpResponse(json.dumps({'state': custom_bill_thirty}))
    #70保证金
    elif custom_state == '3':
        custom_bill_seventy = cart_views.random_str()
        goodsbill = Goodsbill.objects.filter(bill_id = custom_bill_seventy)
        if(not goodsbill):
            goodsbill = Goodsbill(bill_id=custom_bill_seventy,
                subject='保证金支付',
                bill_body='支付70%保证金',
                total_fee=0.7*custom_price,
                trade_status='init',
                start_date=datetime.datetime.now(),
                expire_date=datetime.datetime.now(),
                add_time=datetime.datetime.now(),
                bill_state = 'cus',
                custom_id = custom_id
            )
        goodsbill.save()
        custom_info.save()
        return HttpResponse(json.dumps({'state': custom_bill_seventy}))
    return HttpResponse('fail to add goodsbill')
コード例 #2
0
ファイル: views.py プロジェクト: jkbrother/three_3d_ilove
def test_good_order(request):
    #以后传的是链表
    import datetime
    goods_list = request.POST.get('goods_id')
    order_id = request.POST.get('order_id')
    order_id = json.loads(order_id)
    goods_list = json.loads(goods_list)
    price = request.POST.get('price')
    #去除[91l,92l,93l]的[]
    '''
    arr = goods_list.split(',')
    lenarr = len(arr[0])
    arr[0]=arr[0][1:lenarr]
    lenarr = len(arr[len(arr)-1])
    arr[len(arr)-1]=arr[len(arr)-1][0:lenarr-1]
    if (len(arr) > 0):
        lenarr = len(arr[0].strip())
        goods = Goods.objects.get(id = arr[0].strip()[0:lenarr-1])
    #goods = goods_list.split('.')
    #good = Goods.objects.filter(id =goods[1])
    bill_id = request.POST.get('bill_id')
    goodsbill = Goodsbill(bill_id=bill_id,
        subject=goods.name,
        bill_body="首饰描述:"+goods.describe,
        total_fee=price,
        trade_status='init',
        order_list=order_id
    )

    goodsbill.save()
    '''
    goods = get_object_or_404(Goods,id =goods_list[0])
    bill_id = request.POST.get('bill_id')
    goodsbill = Goodsbill.objects.filter(bill_id = bill_id)
    if(not goodsbill):
        goodsbill = Goodsbill(bill_id=bill_id,
            subject=goods.name,
            bill_body="首饰描述:"+goods.describe,
            total_fee=price,
            trade_status='init',
            order_list=order_id,
            start_date=datetime.datetime.now(),
            expire_date=datetime.datetime.now(),
            add_time=datetime.datetime.now(),
            bill_state = 'buy'
        )
        goodsbill.save()
    return HttpResponse(json.dumps({'state': bill_id}))