46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from typing import cast
|
|
|
|
import pydash
|
|
from channels.layers import BaseChannelLayer, get_channel_layer
|
|
from django.http.response import HttpResponse
|
|
from rest_framework.decorators import action
|
|
from rest_framework.request import Request
|
|
from rest_framework.viewsets import ViewSet
|
|
|
|
from wechat_微信支付证书.江苏六果科技有限公司支付证书.江苏六果科技有限公司支付参数 import sixpay六果科技公司
|
|
from wechat_项目工具包.微信支付工具包.微信支付类 import wechatPay
|
|
|
|
default_channel_layer = cast(BaseChannelLayer, get_channel_layer(alias="default"))
|
|
|
|
from functools import wraps
|
|
import threading
|
|
|
|
|
|
def sync_lock(lock):
|
|
def decorator(fn):
|
|
@wraps(fn)
|
|
def wrapper(*args, **kwargs):
|
|
with lock:
|
|
return fn(*args, **kwargs)
|
|
|
|
return wrapper
|
|
|
|
return decorator
|
|
|
|
|
|
class 电子发票管理接口ViewSets(ViewSet):
|
|
lock = threading.Lock() # 所有请求 共享这一个 lock对象
|
|
|
|
@sync_lock(lock=lock) # 锁住这个接口所有并发请求,
|
|
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="callback")
|
|
def 电子发票回调接口(self, request: Request):
|
|
""""""
|
|
print("电子发票请求进来了没有")
|
|
print(request.data)
|
|
print(request.query_params)
|
|
电子发票回调解密后的数据 = wechatPay(payment=sixpay六果科技公司).callBack回调解密(headers=request.headers, response_body=request.data)
|
|
|
|
print(电子发票回调解密后的数据, "=======================")
|
|
fapiao_apply_id = pydash.get(obj=电子发票回调解密后的数据, path="fapiao_apply_id")
|
|
return HttpResponse(content="OK")
|