Exemple #1
0
def delete_customer(request):
    try:
        data = json.loads(request.body.decode())
        customer_ids = data.get('ids')
        # 删除买家
        Customer.objects.filter(id__in=customer_ids, seller_id=request.user.id).delete()
    except Exception as e:
        return JSONResponse(msg='删除失败!')
    return JSONResponse()
Exemple #2
0
def delete_order(request):
    try:
        data = json.loads(request.body.decode())
        order_ids = data.get('ids')
        # 删除订单
        Order.objects.filter(id__in=order_ids).delete()
    except Exception as e:
        return JSONResponse(msg='删除失败!')
    return JSONResponse()
Exemple #3
0
def delete_goods(request):
    try:
        data = json.loads(request.body.decode())
        goods_ids = data.get('ids')
        # 删除商品
        Goods.objects.filter(id__in=goods_ids).delete()
    except Exception as e:
        return JSONResponse(msg='删除失败!')
    return JSONResponse()
Exemple #4
0
def delete_task(request):
    try:
        data = json.loads(request.body.decode())
        task_ids = data.get('ids')
        # 删除任务
        CashbackTask.objects.filter(id__in=task_ids,
                                    seller_id=request.user.id).delete()
    except Exception as e:
        return JSONResponse(msg='删除失败!')
    return JSONResponse()
Exemple #5
0
def delete_shops(request):
    try:
        data = json.loads(request.body.decode())
        shop_ids = data.get('ids')

        with transaction.atomic():
            # 删除商品
            Goods.objects.filter(shop_id__in=shop_ids).delete()
            # 删除店铺
            Shop.objects.filter(id__in=shop_ids).delete()
    except Exception as e:
        return JSONResponse(msg='删除失败!')
    return JSONResponse()
Exemple #6
0
    def post(self, request, *args, **kwargs):
        form = kwargs.pop('form')
        commentpic = form.cleaned_data.get('commentpic')
        showpic1 = form.cleaned_data.get('showpic1')
        showpic2 = form.cleaned_data.get('showpic2')

        commentpic = save_file(commentpic)  # 保存文件
        if showpic1:
            showpic1 = save_file(showpic1)
        if showpic2:
            showpic2 = save_file(showpic2)

        cashback = Cashback()
        cashback.task_id = form.cleaned_data.get('id')
        cashback.seller_id = form.task.seller_id
        cashback.customer_id = form.order.customer_id
        cashback.wechat = form.cleaned_data.get('wechat')
        cashback.alipay = form.cleaned_data.get('alipay')
        cashback.orderno = form.cleaned_data.get('orderno')
        cashback.amount = form.task.amount
        cashback.certificate = commentpic
        cashback.showpic1 = showpic1
        cashback.showpic2 = showpic2
        cashback.status = CashbackStatus.Processing.value
        cashback.save()

        return JSONResponse()
Exemple #7
0
    def post(self, request, *args, **kwargs):
        '''批量导入订单'''
        tb_file = request.FILES.get('tb_order')
        jd_file = request.FILES.get('jd_order')

        file = tb_file or jd_file
        platform = 'taobao' if tb_file else 'jd'
        if not file:
            return JSONError('文件上传出错')
        if not file.name.endswith('.csv'):
            return JSONError('文件格式错误')

        filename = str(int(time.time())) + '.csv'
        filename = os.path.join(settings.MEDIA_ROOT, filename)
        with open(filename, 'wb+') as f:
            for chunk in file.chunks():
                f.write(chunk)

        result = OrderService().import_orders(filename, request.user.id, platform)
        return JSONResponse(msg=result[1], success=result[0])