Exemplo n.º 1
0
    def post(self, request, manual_service_id):
        order = ServiceUtils.get_order_by_manual_serviceid(
            service_id=manual_service_id
        )
        if not order:
            raise Http404

        user = order.user
        OrderManage.paid_order(
            order_id=order.order_id,
            user=user
        )

        if request.POST.get('pay_status') == 'continue':
            UserManualService.objects.filter(
                id=manual_service_id
            ).update(
                status='continue'
            )

        return JsonResponse({
            'result': 'success',
            'new_data': {'offline_pay': u'操作成功'},
            'new_html': {'offline_pay': u'操作成功'},
        })
Exemplo n.º 2
0
    def post(self, request, op_id):

        user = request.user
        service = get_object_or_none(
            UserManualService,
            id=op_id,
        )
        if not service:
            return JsonResponse({
                'status': 'error',
                'msg': 'not found service',
            })

        order = ServiceUtils.get_service_order(service)
        if not order:
            return JsonResponse({
                'status': 'error',
                'msg': 'not found order',
            })
        order_id = order.order_id

        OrderManage.confirm_refund_order(
            order_id=order_id,
            user=user
        )

        return JsonResponse({
            'status': 'ok',
            'msg': '确认订单退款成功'
        })
Exemplo n.º 3
0
 def post(self, request):
     self.user = request.user
     order_id = request.POST.get('order_id')
     status = request.POST.get('status')
     OrderManage.change_order_status(
         user=self.user,
         order_id=order_id,
         status=status
     )
     return JsonResponse({
         'status': 'ok',
         'msg': '更新订单状态成功'
     })
Exemplo n.º 4
0
    def post(self, request):
        user = request.user
        service_id = request.POST.get('service_id')
        order = ServiceUtils.get_order_by_manual_serviceid(
            service_id=service_id
        )

        ret = OrderManage.refund_order(
            order_id=order.order_id,
            service_id=service_id,
            user=user
        )

        refund_doc = ret.get('refund_info')
        refund_doc['pay_fee'] = order.order_price

        if ret.get('service_result'):
            return JsonResponse({
                'status': 'ok',
                'msg': '申请订单退款成功',
                'data': ret.get('refund_info')
            })
        else:
            return JsonResponse({
                'status': 'error',
                'msg': '申请订单退款失败'
            })
Exemplo n.º 5
0
    def post(self, request):
        user = request.user
        order_id = request.POST.get('order_id')
        service_id = request.POST.get('service_id')

        if service_id:
            order_id = ServiceUtils.get_order_by_manual_serviceid(
                service_id=order_id
            ).order_id

        ret = OrderManage.delete_order(
            order_id=order_id,
            user=user
        )

        if ret:
            return JsonResponse({
                'status': 'ok',
                'msg': '取消订单成功'
            })
        else:
            return JsonResponse({
                'status': 'error',
                'msg': '取消订单失败'
            })
Exemplo n.º 6
0
    def post(self, request):
        user = request.user
        pid = request.POST.get('pid')
        num = request.POST.get('num', 1)
        payment_terms = request.POST.get('payment_terms')
        is_insurance = request.POST.get('is_insurance')
        product_type = request.POST.get('product_type')

        order = OrderManage.create_order(
            user=user,
            pid=pid,
            num=num,
            product_type=product_type,
            payment_terms=payment_terms,
            is_insurance=is_insurance
        )
        if (int(num) < 1):
            return JsonResponse({
                'status': 'error',
                'msg': '商品数量不能小于1',
            })

        if not order:
            return JsonResponse({
                'status': 'error',
                'msg': '支付失败,请勿重新购买!',
            })

        pay_url = ''
        if payment_terms == 'alipay':

            alipay_return_url = request.build_absolute_uri(
                reverse('order-alipay-return')
            )
            alipay_notify_url = request.build_absolute_uri(
                reverse('order-alipay-notify')
            )

            pay_url = AlipayUtils.submit_order_url(
                order,
                return_url=alipay_return_url,
                notify_url=alipay_notify_url,
                order_price=order.order_price,
                extra_common_param=product_type
            )

        if payment_terms == 'coin':
            pay_url = reverse('vip-coin-paid-order')

        return JsonResponse({
            'status': 'ok',
            'msg': '订单生成成功',
            'pay_url': pay_url,
            'order_id': order.order_id,
            'payment_terms': order.payment_terms,
            'order_price': order.order_price
        })
Exemplo n.º 7
0
    def post(self, request, order_id):
        order = OrderManage.get_order_info(
            order_id=order_id
        )
        if order:

            OrderManage.paid_order(
                order_id=order.order_id,
                user=order.user
            )
            order.payment_terms = 'offline'
            order.order_status = 'paid'
            order.save()
        return JsonResponse({
            'result': 'success',
            'new_data': {'offline_pay': u'支付成功'},
            'new_html': {'offline_pay': u'支付成功'},
        })
Exemplo n.º 8
0
    def get(self, request, order_status):
        self.user = request.user

        if order_status:
            order_list = OrderManage.get_order_list(
                user=self.user,
                order_status=order_status
            )
        else:
            order_list = OrderManage.get_order_list(
                user=self.user
            )

        return render(
            request,
            self.template_name,
            {
                'order_list': order_list,
            }
        )
Exemplo n.º 9
0
    def post(self, request, op_id):
        user = request.user
        order_id = op_id

        ret = OrderManage.confirm_refund_order(
            order_id=order_id,
            user=user
        )

        if ret:
            return JsonResponse({
                'status': 'ok',
                'msg': '确认订单退款成功'
            })
Exemplo n.º 10
0
    def make_order_success(self):

        order_id = self.request.REQUEST.get('out_trade_no')

        success_order = self.order_already_success(order_id)
        if success_order:
            return success_order

        order_obj = get_object_or_none(UserOrder, order_id=order_id)
        ret = OrderManage.paid_order(
            order_id=order_id,
            user=order_obj.user
        )
        return ret
Exemplo n.º 11
0
 def get(self, request):
     alipay_success = AlipayUtils.verify_alipay_notify(request.REQUEST)
     self.make_order_success() if alipay_success else None
     order_id = self.request.REQUEST.get('out_trade_no')
     extra_common_param = self.request.REQUEST.get('extra_common_param')
     order = OrderManage.get_order_info(
         order_id=order_id
     )
     return render(
         request,
         self.template_name,
         {
             'order': order,
             'extra_common_param': extra_common_param
         },
     )
Exemplo n.º 12
0
    def post(self, request):
        username = request.POST.get('username', '')
        user = get_object_or_none(
            User,
            username=username,
        )
        if not user:
            return JsonResponse({
                'status': 'user_not_found',
                'msg': '用户不存在',
            })

        pid = request.POST.get('pid')
        num = request.POST.get('num', 1)
        payment_terms = request.POST.get('payment_terms')
        is_insurance = request.POST.get('is_insurance')
        product_type = request.POST.get('product_type')

        order = OrderManage.create_order(
            user=user,
            pid=pid,
            num=num,
            product_type=product_type,
            payment_terms=payment_terms,
            is_insurance=is_insurance
        )
        if (int(num) < 1):
            return JsonResponse({
                'status': 'error',
                'msg': '商品数量不能小于1',
            })

        if not order:
            return JsonResponse({
                'status': 'error',
                'msg': '支付失败,请勿重新购买!',
            })

        return JsonResponse({
            'status': 'ok',
            'msg': '订单生成成功',
            'pay_url': '',
            'order_id': order.order_id,
            'payment_terms': order.payment_terms,
            'order_price': order.order_price
        })
Exemplo n.º 13
0
    def post(self, request):
        user = request.user
        order_id = request.POST.get('order_id')

        order = OrderManage.get_order_info(
            order_id=order_id,
            user=user,
        )
        payment_terms = order.payment_terms

        if order.order_status != 'unpay':
            return JsonResponse({
                'status': 'error',
                'msg': '申请重新支付失败',
            })

        pay_url = ''

        if payment_terms == 'alipay':

            alipay_return_url = request.build_absolute_uri(
                reverse('order-alipay-return')
            )
            alipay_notify_url = request.build_absolute_uri(
                reverse('order-alipay-notify')
            )

            pay_url = AlipayUtils.submit_order_url(
                order,
                return_url=alipay_return_url,
                notify_url=alipay_notify_url,
                order_price=order.order_price,
                extra_common_param=order.item.get_product_type
            )

        if payment_terms == 'coin':
            pay_url = reverse('vip-coin-paid-order')

        return JsonResponse({
            'status': 'ok',
            'msg': '申请重新支付订单成功',
            'pay_url': pay_url,
            'order_id': order.order_id,
            'payment_terms': order.payment_terms
        })
Exemplo n.º 14
0
    def post(self, request):
        user = request.user
        order_id = request.POST.get('order_id')

        ret = OrderManage.paid_order(
            order_id=order_id,
            user=user
        )

        if ret:
            return JsonResponse({
                'status': 'ok',
                'msg': '订单支付成功'
            })
        else:
            return JsonResponse({
                'status': 'error',
                'msg': '订单支付失败'
            })
Exemplo n.º 15
0
    def post(self, request):
        order_id = request.POST.get('order_id')
        user = request.user

        order = OrderManage.get_order_info(
            order_id=order_id,
            user=user,
        )
        if not order:
            return JsonResponse({
                'status': 'error',
                'msg': '权限错误',
            })

        return JsonResponse({
            'status': 'ok',
            'msg': 'ok',
            'order_id': order_id,
            'order_status': order.order_status,
        })
Exemplo n.º 16
0
    def post(self, request):
        user = request.user
        service_id = request.POST.get('service_id')
        order_id = ServiceUtils.get_order_by_manual_serviceid(
            service_id=service_id
        ).order_id
        ret = OrderManage.cancel_refund_order(
            order_id=order_id,
            user=user
        )

        if ret:
            return JsonResponse({
                'status': 'ok',
                'msg': '取消订单退款成功'
            })
        else:
            return JsonResponse({
                'status': 'error',
                'msg': '取消订单退款失败'
            })
Exemplo n.º 17
0
    def get(self, request, service_id):
        user = request.user
        order = ServiceUtils.get_order_by_manual_serviceid(
            service_id=service_id
        )
        if not order:
            return JsonResponse(
                {
                    'status': 'error',
                    'msg': '订单未找到!'
                }
            )

        if order.item.get_product_type != 'manual_service':
            return JsonResponse({
                'status': 'error',
                'msg': '非省心型服务无法退款!'
            })

        if order.user != user:
            return JsonResponse({
                'status': 'error',
                'msg': '没有查看权限!'
            })

        refund_doc = OrderManage.get_refund_info(
            service_id=service_id,
        )
        refund_doc['pay_fee'] = order.order_price
        if refund_doc:
            return JsonResponse({
                'status': 'ok',
                'msg': '查看退款申请',
                'data': refund_doc
            })
        else:
            return JsonResponse({
                'status': 'error',
                'msg': '申请订单退款失败'
            })
def trans_advance_user():
    vip_a = VipRoleSetting.objects.get(code_name='experience_user')

    UserVip.objects.filter(
        is_active=True,
        user__username__in=username_list,
    ).update(
        vip_role=vip_a
    )

    manual_service = list(PackageItem.objects.all(
    ).values_list(
        'id',
        'price',
    ))
    manual_mapper = {
        i[1]: i[0]
        for i in manual_service
    }

    user_list = User.objects.filter(
        username__in=username_list,
        manual_roles=None,
    )

    experience_service = VipRoleUtils.get_experience_vip()

    for i in user_list:
        user = i
        username = i.username
        user_price = users_mapper.get(username, {}).get('price', 0)
        if not user_price:
            print 'user %s is valid, no price' % username

        pid = manual_mapper.get(user_price, 0)
        if not pid:
            print 'user %s price %s is valid, valid price' % (username, user_price)

        start_time = str2datetime(users_mapper.get(username, {}).get('start_time', ''))
        end_time = str2datetime(users_mapper.get(username, {}).get('end_time', ''))

        with transaction.atomic():
            if not user.vip_roles.filter(is_active=True).exists():
                srv_meta = {
                    'service_name': 'self_service',
                    'product': experience_service,
                    'user': user,
                }
                experience_srv = SelfService(**srv_meta)
                experience_srv.create_service()
                experience_srv.active_service()

            order = OrderManage.create_order(
                user,
                pid,
                'manual_service',
                1,
                'offline',
            )
            OrderManage.paid_order(order.order_id, user)

            UserManualService.objects.filter(
                user=user,
                is_active=True,
            ).update(
                active_time=start_time,
                expire_time=end_time,
            )
            print 'trans %s success' % username
Exemplo n.º 19
0
def trans_advance_user():
    vip_a = VipRoleSetting.objects.get(code_name='experience_user')

    UserVip.objects.filter(
        is_active=True,
        user__username__in=username_list,
    ).update(vip_role=vip_a)

    manual_service = list(PackageItem.objects.all().values_list(
        'id',
        'price',
    ))
    manual_mapper = {i[1]: i[0] for i in manual_service}

    user_list = User.objects.filter(
        username__in=username_list,
        manual_roles=None,
    )

    experience_service = VipRoleUtils.get_experience_vip()

    for i in user_list:
        user = i
        username = i.username
        user_price = users_mapper.get(username, {}).get('price', 0)
        if not user_price:
            print 'user %s is valid, no price' % username

        pid = manual_mapper.get(user_price, 0)
        if not pid:
            print 'user %s price %s is valid, valid price' % (username,
                                                              user_price)

        start_time = str2datetime(
            users_mapper.get(username, {}).get('start_time', ''))
        end_time = str2datetime(
            users_mapper.get(username, {}).get('end_time', ''))

        with transaction.atomic():
            if not user.vip_roles.filter(is_active=True).exists():
                srv_meta = {
                    'service_name': 'self_service',
                    'product': experience_service,
                    'user': user,
                }
                experience_srv = SelfService(**srv_meta)
                experience_srv.create_service()
                experience_srv.active_service()

            order = OrderManage.create_order(
                user,
                pid,
                'manual_service',
                1,
                'offline',
            )
            OrderManage.paid_order(order.order_id, user)

            UserManualService.objects.filter(
                user=user,
                is_active=True,
            ).update(
                active_time=start_time,
                expire_time=end_time,
            )
            print 'trans %s success' % username