Exemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        """
        post请求
        by: 范俊伟 at:2015-02-11
        逻辑修改
        by: 范俊伟 at:2015-02-13
        修改逻辑
        by: 尚宗凯 at:2015-03-25
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        kwargs.update(self.request.POST.dict())
        if '__state_1' in request.POST:
            self.step = 1
        elif '__state_2' in request.POST:
            project_id = request.REQUEST.get('project_id')
            if not project_id:
                messages.error(request, '未选择项目')
                self.step = 1
                return self.get(request, *args, **kwargs)
            self.step = 2
        elif '__state_3' in request.POST:
            product_id = request.REQUEST.get('product_id')
            if not product_id:
                messages.error(request, '未选套餐')
                self.step = 2
                return self.get(request, *args, **kwargs)
            self.step = 3
        elif '__state_4' in request.POST:
            self.step = 4
        elif '__state_5' in request.POST:
            project_id = request.REQUEST.get('project_id')
            if not project_id:
                messages.error(request, '未选择项目')
                return self.get(request, *args, **kwargs)
            try:
                project = Project.objects.get(id=project_id)
            except Product.DoesNotExist:
                messages.error(request, '项目不存在')
                return self.get(request, *args, **kwargs)
            product_id = request.REQUEST.get('product_id')
            if not product_id:
                messages.error(request, '未选套餐')
                return self.get(request, *args, **kwargs)
            try:
                product = Product.objects.get(id=product_id)
            except Product.DoesNotExist:
                messages.error(request, '套餐不存在')
                return self.get(request, *args, **kwargs)

            if project and project:
                tax = None
                if (kwargs.get('has_fp') == '1'):
                    address = Address()
                    address.username = kwargs.get('addr_username')
                    address.address_v2 = kwargs.get('addr_address')
                    address.address_detail = kwargs.get('addr_address_detail')
                    address.phone = kwargs.get('addr_phone')
                    address.user = self.request.user
                    address.save()
                    tax = Tax()
                    tax.fptt = kwargs.get('fptt')
                    tax.address = address
                    tax.user = self.request.user
                    tax.save()
                order = Order()
                order.user = self.request.user
                order.product = product
                order.price = order.real_price = product.price
                if tax:
                    order.is_mail = True
                else:
                    order.is_mail = False
                if (kwargs.get('has_fp') == '1'):
                    order.address = tax.address
                    order.tax = tax
                else:
                    order.address = None
                    order.tax = None
                order.project = project
                order.save()

                if self.isPhoneRequest():
                    url = '%s?pay_type=0&order_id=%s' % (
                        reverse('zhifubao_pay'), order.id)
                else:
                    url = '%s?pay_type=0&order_id=%s' % (
                        reverse('zhifubao_pay_pc'), order.id)
                return HttpResponseRedirect(url)

        if '__back_state_1' in request.POST:
            self.step = 1
        elif '__back_state_2' in request.POST:
            self.step = 2
        elif '__back_state_3' in request.POST:
            self.step = 3

        return self.get(request, *args, **kwargs)
Exemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        """
        post请求
        by: 范俊伟 at:2015-02-11
        逻辑修改
        by: 范俊伟 at:2015-02-13
        修改逻辑
        by: 尚宗凯 at:2015-03-25
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        kwargs.update(self.request.POST.dict())
        if '__state_1' in request.POST:
            self.step = 1
        elif '__state_2' in request.POST:
            project_id = request.REQUEST.get('project_id')
            if not project_id:
                messages.error(request, '未选择项目')
                self.step = 1
                return self.get(request, *args, **kwargs)
            self.step = 2
        elif '__state_3' in request.POST:
            product_id = request.REQUEST.get('product_id')
            if not product_id:
                messages.error(request, '未选套餐')
                self.step = 2
                return self.get(request, *args, **kwargs)
            self.step = 3
        elif '__state_4' in request.POST:
            self.step = 4
        elif '__state_5' in request.POST:
            project_id = request.REQUEST.get('project_id')
            if not project_id:
                messages.error(request, '未选择项目')
                return self.get(request, *args, **kwargs)
            try:
                project = Project.objects.get(id=project_id)
            except Product.DoesNotExist:
                messages.error(request, '项目不存在')
                return self.get(request, *args, **kwargs)
            product_id = request.REQUEST.get('product_id')
            if not product_id:
                messages.error(request, '未选套餐')
                return self.get(request, *args, **kwargs)
            try:
                product = Product.objects.get(id=product_id)
            except Product.DoesNotExist:
                messages.error(request, '套餐不存在')
                return self.get(request, *args, **kwargs)

            if project and project:
                tax = None
                if (kwargs.get('has_fp') == '1'):
                    address = Address()
                    address.username = kwargs.get('addr_username')
                    address.address_v2 = kwargs.get('addr_address')
                    address.address_detail = kwargs.get('addr_address_detail')
                    address.phone = kwargs.get('addr_phone')
                    address.user = self.request.user
                    address.save()
                    tax = Tax()
                    tax.fptt = kwargs.get('fptt')
                    tax.address = address
                    tax.user = self.request.user
                    tax.save()
                order = Order()
                order.user = self.request.user
                order.product = product
                order.price = order.real_price = product.price
                if tax:
                    order.is_mail = True
                else:
                    order.is_mail = False
                if (kwargs.get('has_fp') == '1'):
                    order.address = tax.address
                    order.tax = tax
                else:
                    order.address = None
                    order.tax = None
                order.project = project
                order.save()

                if self.isPhoneRequest():
                    url = '%s?pay_type=0&order_id=%s' % (reverse('zhifubao_pay'), order.id)
                else:
                    url = '%s?pay_type=0&order_id=%s' % (reverse('zhifubao_pay_pc'), order.id)
                return HttpResponseRedirect(url)

        if '__back_state_1' in request.POST:
            self.step = 1
        elif '__back_state_2' in request.POST:
            self.step = 2
        elif '__back_state_3' in request.POST:
            self.step = 3

        return self.get(request, *args, **kwargs)
Exemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        """
        post请求
        by:尚宗凯 at:2015-04-21
        充值界面修改
        by: 范俊伟 at:2015-05-13
        """

        project_id = request.REQUEST.get('project_id')
        if not project_id:
            kwargs['message'] = '未选择项目'
            return self.get(request, *args, **kwargs)
        try:
            project = Project.objects.get(id=project_id)
        except Product.DoesNotExist:
            kwargs['message'] = '项目不存在'
            return self.get(request, *args, **kwargs)
        product_id = request.REQUEST.get('product_id')
        if not product_id:
            kwargs['message'] = '未选套餐'
            return self.get(request, *args, **kwargs)
        try:
            product = Product.objects.get(id=int(product_id))
        except Product.DoesNotExist:
            kwargs['message'] = '套餐不存在'
            return self.get(request, *args, **kwargs)

        if project and project:
            tax = None
            # if (kwargs.get('has_fp') == '1'):
            if self.request.REQUEST.get(
                    "fp_check") == "yes" and self.request.REQUEST.get(
                        'fa_piao_tian_xie') == "True":
                address = Address()
                address.username = request.REQUEST.get('lxr')
                address.address_v2 = request.REQUEST.get('address')
                address.address_detail = request.REQUEST.get('jdxqdz')
                address.phone = request.REQUEST.get('lxdh')
                address.zip_code = request.REQUEST.get('yzbm')
                address.user = self.request.user
                address.save()
                tax = Tax()
                tax.fptt = request.REQUEST.get('fptt')
                tax.address = address
                tax.user = self.request.user
                tax.save()
            order = Order()
            order.user = self.request.user
            order.product = product
            order.price = order.real_price = product.price
            kwargs['origin'] = product.price - product.gift
            if tax:
                order.is_mail = True
            else:
                order.is_mail = False
            # if (kwargs.get('has_fp') == '1'):
            if self.request.REQUEST.get(
                    "fp_check") == "yes" and self.request.REQUEST.get(
                        'fa_piao_tian_xie') == "True":
                order.address = tax.address
                order.tax = tax
            else:
                order.address = None
                order.tax = None
            order.project = project
            order.save()

            if self.isPhoneRequest():
                url = '%s?pay_type=0&order_id=%s' % (reverse('zhifubao_pay'),
                                                     order.id)
            else:
                url = '%s?pay_type=0&order_id=%s' % (
                    reverse('zhifubao_pay_pc'), order.id)
            return HttpResponseRedirect(url)
Exemplo n.º 4
0
    def post(self, request, *args, **kwargs):
        """
        post请求
        by:尚宗凯 at:2015-04-21
        充值界面修改
        by: 范俊伟 at:2015-05-13
        """

        project_id = request.REQUEST.get('project_id')
        if not project_id:
            kwargs['message'] = '未选择项目'
            return self.get(request, *args, **kwargs)
        try:
            project = Project.objects.get(id=project_id)
        except Product.DoesNotExist:
            kwargs['message'] = '项目不存在'
            return self.get(request, *args, **kwargs)
        product_id = request.REQUEST.get('product_id')
        if not product_id:
            kwargs['message'] = '未选套餐'
            return self.get(request, *args, **kwargs)
        try:
            product = Product.objects.get(id=int(product_id))
        except Product.DoesNotExist:
            kwargs['message'] = '套餐不存在'
            return self.get(request, *args, **kwargs)

        if project and project:
            tax = None
            # if (kwargs.get('has_fp') == '1'):
            if self.request.REQUEST.get("fp_check") == "yes" and self.request.REQUEST.get('fa_piao_tian_xie') == "True":
                address = Address()
                address.username = request.REQUEST.get('lxr')
                address.address_v2 = request.REQUEST.get('address')
                address.address_detail = request.REQUEST.get('jdxqdz')
                address.phone = request.REQUEST.get('lxdh')
                address.zip_code = request.REQUEST.get('yzbm')
                address.user = self.request.user
                address.save()
                tax = Tax()
                tax.fptt = request.REQUEST.get('fptt')
                tax.address = address
                tax.user = self.request.user
                tax.save()
            order = Order()
            order.user = self.request.user
            order.product = product
            order.price = order.real_price = product.price
            kwargs['origin'] = product.price - product.gift
            if tax:
                order.is_mail = True
            else:
                order.is_mail = False
            # if (kwargs.get('has_fp') == '1'):
            if self.request.REQUEST.get("fp_check") == "yes" and self.request.REQUEST.get('fa_piao_tian_xie') == "True":
                order.address = tax.address
                order.tax = tax
            else:
                order.address = None
                order.tax = None
            order.project = project
            order.save()

            if self.isPhoneRequest():
                url = '%s?pay_type=0&order_id=%s' % (reverse('zhifubao_pay'), order.id)
            else:
                url = '%s?pay_type=0&order_id=%s' % (reverse('zhifubao_pay_pc'), order.id)
            return HttpResponseRedirect(url)