예제 #1
0
    def post(self, request):
        money = get_int(request.POST.get('money') or 0)
        if money <= 0:
            return JsonResponse({
                'status': 'money_error',
                'msg': '提现金额必须是大于0的整数',
            })

        user = request.user
        pinbot_point = coin_utils._get_pinbot_point(user)

        if money > pinbot_point.coin:
            return JsonResponse({
                'status': 'no_coin',
                'msg': '金币不足',
            })

        now = datetime.datetime.now()
        has_withdraw = get_object_or_none(
            WithdrawRecord,
            user=user,
            verify_status__in=(0, 1),
            create_time__year=now.year,
            create_time__month=now.month,
        )

        if has_withdraw:
            return JsonResponse({
                'status': 'has_withdraw',
                'msg': '您本月已经提现过一次,请下个月再来',
            })

        withdraw = WithdrawRecord.objects.create(
            user=user,
            money=money,
        )

        order = UserOrder.objects.create(
            user=user,
            order_price=-money,
            actual_price=-money,
            item=withdraw,
            order_desc='提现',
            order_type=5,
        )
        order.order_id = create_order_id()
        order.save()

        ItemRecord.objects.create(
            num=1,
            total_price=order.order_price,
            order=order,
            item=withdraw,
        )

        return JsonResponse({
            'status': 'ok',
            'msg': '提现请求提交成功',
        })
예제 #2
0
    def post(self, request):
        money = get_int(request.POST.get('money') or 0)
        if money <= 0:
            return JsonResponse({
                'status': 'money_error',
                'msg': '提现金额必须是大于0的整数',
            })

        user = request.user
        pinbot_point = coin_utils._get_pinbot_point(user)

        if money > pinbot_point.coin:
            return JsonResponse({
                'status': 'no_coin',
                'msg': '金币不足',
            })

        now = datetime.datetime.now()
        has_withdraw = get_object_or_none(
            WithdrawRecord,
            user=user,
            verify_status__in=(0, 1),
            create_time__year=now.year,
            create_time__month=now.month,
        )

        if has_withdraw:
            return JsonResponse({
                'status': 'has_withdraw',
                'msg': '您本月已经提现过一次,请下个月再来',
            })

        withdraw = WithdrawRecord.objects.create(
            user=user,
            money=money,
        )

        order = UserOrder.objects.create(
            user=user,
            order_price=-money,
            actual_price=-money,
            item=withdraw,
            order_desc='提现',
            order_type=5,
        )
        order.order_id = create_order_id()
        order.save()

        ItemRecord.objects.create(
            num=1,
            total_price=order.order_price,
            order=order,
            item=withdraw,
        )

        return JsonResponse({
            'status': 'ok',
            'msg': '提现请求提交成功',
        })
예제 #3
0
    def post(self, request, record_id):
        operation = get_int(request.POST.get('operation') or 0)
        verify_remark = request.POST.get('verify_remark', '')

        if operation not in (1, 2):
            return JsonResponse({
                'result': 'fail',
                'new_data': {
                    'offline_pay': u'请选择操作'
                },
                'new_html': {
                    'offline_pay': u'请选择操作'
                },
            })

        withdraw_record = get_object_or_none(
            WithdrawRecord,
            id=record_id,
        )

        if not withdraw_record:
            return JsonResponse({
                'result': 'fail',
                'new_data': {
                    'offline_pay': u'无法找到记录'
                },
                'new_html': {
                    'offline_pay': u'无法找到记录'
                },
            })

        user = withdraw_record.user
        pinbot_point = coin_utils._get_pinbot_point(user)
        if operation == 1 and pinbot_point.coin - withdraw_record.money < 0:
            return JsonResponse({
                'result': 'fail',
                'new_data': {
                    'offline_pay': u'金币数不够'
                },
                'new_html': {
                    'offline_pay': u'金币数不够'
                },
            })

        self.save_withdraw_record(withdraw_record, operation, verify_remark)
        self.save_userorder(withdraw_record, operation, verify_remark)
        self.save_pinbot_coin(withdraw_record, operation)

        return JsonResponse({
            'result': 'success',
            'new_data': {
                'offline_pay': u'操作成功'
            },
            'new_html': {
                'offline_pay': u'操作成功'
            },
        })
예제 #4
0
    def post(self, request, record_id):
        operation = get_int(request.POST.get('operation') or 0)
        verify_remark = request.POST.get('verify_remark', '')

        if operation not in (1, 2):
            return JsonResponse({
                'result': 'fail',
                'new_data': {'offline_pay': u'请选择操作'},
                'new_html': {'offline_pay': u'请选择操作'},
            })

        withdraw_record = get_object_or_none(
            WithdrawRecord,
            id=record_id,
        )

        if not withdraw_record:
            return JsonResponse({
                'result': 'fail',
                'new_data': {'offline_pay': u'无法找到记录'},
                'new_html': {'offline_pay': u'无法找到记录'},
            })

        user = withdraw_record.user
        pinbot_point = coin_utils._get_pinbot_point(user)
        if operation == 1 and pinbot_point.coin - withdraw_record.money < 0:
            return JsonResponse({
                'result': 'fail',
                'new_data': {'offline_pay': u'金币数不够'},
                'new_html': {'offline_pay': u'金币数不够'},
            })

        self.save_withdraw_record(withdraw_record, operation, verify_remark)
        self.save_userorder(withdraw_record, operation, verify_remark)
        self.save_pinbot_coin(withdraw_record, operation)

        return JsonResponse({
            'result': 'success',
            'new_data': {'offline_pay': u'操作成功'},
            'new_html': {'offline_pay': u'操作成功'},
        })