コード例 #1
0
    def again_pay(self, request, *args, **kwargs):
        partial = True
        instance = self.get_object()
        serializer = self.get_serializer(instance,
                                         data=request.data,
                                         partial=partial)
        serializer.is_valid(raise_exception=True)
        self.perform_update(serializer)
        data = serializer.data
        # 支付方式为30,并且状态为10时,重新生成支付信息
        wx_order_id = get_wx_order_id(data['order_id'])
        if data['pay_type'] == PayType.weixin and data[
                'order_status'] == OrderStatus.pre_pay and data[
                    'order_type'] == OrderType.hotel:
            detail = data['hotel_order_detail']['room_style_name']
            result = unifiedorder('曼嘉酒店-住宿', wx_order_id, data['order_amount'],
                                  self.request.user.consumer.openid, detail)
            data.update(result)
        elif data['pay_type'] == PayType.weixin and data[
                'order_status'] == OrderStatus.pre_pay and data[
                    'order_type'] == OrderType.market:
            result = unifiedorder('曼嘉酒店-商场', wx_order_id, data['order_amount'],
                                  self.request.user.consumer.openid, '购买商品')
            data.update(result)

        if data['pay_type'] != PayType.weixin and data['order_status'] == 10:
            data.update({"error_message": "余额不足或积分不足,请更换支付方式或者充值"})

        return Response(data)
コード例 #2
0
ファイル: views.py プロジェクト: zhongzhiqiang/hotel-api
    def create(self, request, *args, **kwargs):

        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        self.perform_create(serializer)
        data = serializer.data

        headers = self.get_success_headers(data)
        result = unifiedorder('曼嘉酒店-充值余额', data['order_id'], data['recharge_money'],
                              self.request.user.consumer.openid, '充值余额')
        data.update(result)
        return Response(data, status=status.HTTP_201_CREATED, headers=headers)
コード例 #3
0
ファイル: views.py プロジェクト: zhongzhiqiang/hotel-api
    def again_recharge(self, request, *args, **kwargs):
        partial = True
        instance = self.get_object()
        serializer = self.get_serializer(instance, data=request.data, partial=partial)
        serializer.is_valid(raise_exception=True)
        self.perform_update(serializer)
        data = serializer.data

        if data['recharge_status'] in (20, 30):
            result = unifiedorder('曼嘉酒店-充值余额', data['order_id'], data['recharge_money'],
                                  self.request.user.consumer.openid, '充值余额')
            data.update(result)

        return Response(data)
コード例 #4
0
    def market_order_create(self, request, *args, **kwargs):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        self.perform_create(serializer)

        data = serializer.data
        if data['pay_type'] == PayType.weixin:
            wx_order_id = get_wx_order_id(data['order_id'])
            result = unifiedorder('曼嘉尔酒店-商场', wx_order_id,
                                  data['order_amount'],
                                  self.request.user.consumer.openid, '购买商品')
            data.update(result)
        if data['pay_type'] != PayType.weixin and data['order_status'] == 10:
            data.update({"error_message": "余额不足或积分不足,请更换支付方式或者充值"})
        headers = self.get_success_headers(data)
        return Response(data, status=status.HTTP_201_CREATED, headers=headers)
コード例 #5
0
    def create(self, request, *args, **kwargs):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        self.perform_create(serializer)
        data = serializer.data
        if data['pay_type'] == PayType.weixin:
            # 这里获取wx_order_id
            wx_order_id = get_wx_order_id(data['order_id'])
            detail = data['hotel_order_detail']['room_style_name']
            result = unifiedorder('曼嘉酒店-住宿', wx_order_id, data['order_amount'],
                                  self.request.user.consumer.openid, detail)
            data.update(result)

        if data['pay_type'] != PayType.weixin and data['order_status'] == 10:
            data.update({"error_message": "余额不足或积分不足,请更换支付方式或者充值"})

        headers = self.get_success_headers(data)
        return Response(data, status=status.HTTP_200_OK, headers=headers)