six_001
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
from typing import cast
|
||||
|
||||
from channels.layers import BaseChannelLayer, get_channel_layer
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.viewsets import ViewSet
|
||||
|
||||
from wechat_项目工具包.微信支付工具包.领优惠券工具包 import stock发送代金券功能
|
||||
|
||||
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对象
|
||||
|
||||
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="生成优惠券")
|
||||
def 生成优惠券(self, request: Request):
|
||||
""""""
|
||||
stock发券数据 = stock发送代金券功能(stock_id_代金券批次号="22512292").send发券并返回前端需要的数据()
|
||||
# 4. 生成签名
|
||||
return Response(data=stock发券数据)
|
||||
|
||||
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="返回当前券的状态")
|
||||
def 返回当前券的状态(self, request: Request):
|
||||
pass
|
||||
return Response(data={})
|
||||
Reference in New Issue
Block a user