def get(self, request): auth = Authentication(request) # log.i(f'user_id: {auth.user_id}') user = User.get(user_id=auth.user_id) account = Account.get(user_id=user.user_id, platform_id=user.bind_platform_id) data = account.to_dict() return BihuResponse(data=data)
def get(self, request): serializer = validators.SearchValidator(data=request.GET) serializer.is_valid(raise_exception=True) name = serializer.validated_data.get('name') # data = [] for user in User.search(nickname__contains=name): accounts = Account.search(user_id=user.user_id) for account in accounts: data.append(account.to_dict()) return BihuResponse(data=data)
def post(self, request): # 获取参数 auth = Authentication(request) tariff_name = request.data.get('tariff_name') # user = User.get(user_id=auth.user_id) tariff = Tariff.get_object_or_404(tariff_name=tariff_name) attach = Tariff.tariff_to_attach(tariff=tariff) if settings.is_admin(openid=user.openid): total_fee = 1 * tariff.duration # 1分钱 else: total_fee = tariff.price title = '用户支付提示' client_ip = get_client_ip(request) openid = user.openid out_trade_no = new_uuid() response = WePay.create_jsapi_order( out_trade_no=out_trade_no, openid=openid, total_fee=total_fee, title=title, client_ip=client_ip, attach=attach, notify_url=settings.MP_PAY_NOTIFY_URL) prepay_id = response['prepay_id'] # 订单入库 order = Order.create( user_id=user.user_id, platform_id=user.bind_platform_id, openid=openid, out_trade_no=out_trade_no, attach=attach, total_fee=total_fee, appid=settings.MP_APP_ID, mch_id=settings.MP_MERCHANT_ID, status=Order.Status.UNPAID.value, ) data = { 'order': order.to_dict(), 'param': WePay.get_jsapi_params(prepay_id=prepay_id), } return BihuResponse(data=data)
def post(self, request): log.i(f'POST method') self.detail(request) data = request.data return BihuResponse(data=data)
def get(self, request): log.i(f'GET method') self.detail(request) return BihuResponse()
def get(self, request): return BihuResponse()
def get(self, request, platform_id): platform = Platform.get(platform_id=platform_id) data = {} if platform: data = platform.to_dict() return BihuResponse(data=data)