This commit is contained in:
doudou201703
2026-08-10 19:33:59 +08:00
parent 3ff0faebb9
commit 945b120733
28 changed files with 330 additions and 786 deletions
+3 -2
View File
@@ -5,8 +5,9 @@ from wechat_数据库.企业微信数据库 import 推广二维码数据表, 企
from wechat_token import token数据库
from wechat_数据库.地图定位 import 用户定位数据库, 腾讯地图解析数据库
from wechat_数据库.小程序后端数据库 import 订阅消息
from wechat_数据库.微信支付券 import 代金券数据库
from wechat_数据库.支付订单数据库 import 商品订单数据
from wechat_数据库.洗衣液商品数据库 import 六果洗衣液商品
from wechat_数据库.测试数据库 import 测试数据表
from wechat_数据库.用户数据库 import 小程序登陆用户, 小程序用户地址, 小程序积分数据库,企微客服数据库
# Create your models here.
from wechat_数据库.用户数据库 import 小程序登陆用户, 小程序用户地址, 小程序积分数据库, 企微客服数据库
# Create your models here.
+17 -18
View File
@@ -16,6 +16,7 @@ from rest_framework.viewsets import ViewSet
from django_jwt_token.jwt认证接口 import Jwt身份认证
from sixGuoDjango import BaseResponse, ResData, redis_5
from wechat_token.token工具包 import sixToken
default_channel_layer = cast(BaseChannelLayer, get_channel_layer(alias="default"))
@@ -29,21 +30,21 @@ def sync_lock(lock):
def wrapper(*args, **kwargs):
with lock:
return fn(*args, **kwargs)
return wrapper
return decorator
class DemoXiaoViewSets(ViewSet):
lock = threading.Lock() # 所有请求 共享这一个 lock对象
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="zizi")
def 只用于初始化项目测试接口(self, request: Request):
""""""
print("测试接口")
# 可以对用户添加某一类型的积分
# with ThreadPoolExecutor( max_workers=3 ) as executor:
# 返回值 = executor.map( 请求企微, [ 1, 2, 3 ] )
# print( 返回值 )
@@ -51,31 +52,31 @@ class DemoXiaoViewSets(ViewSet):
# print( item )
xiao = request.data.get("xiao", None)
print(xiao)
商品数据 = request.data.get("商品数据", "")
data = orjson.loads(商品数据)
列表 = pydash.get(obj=data, path="列表")
print(列表, 商品数据)
fileDataList: list[InMemoryUploadedFile] = request.FILES.getlist("fileDataList", None) # 接收多个图片或者文件
for file in fileDataList:
default_storage.save(name=file.name, content=file)
httpResData = BaseResponse(resData=ResData(listData=[""], dictData={}), ).model_dump()
return Response(data=httpResData, status=status.HTTP_200_OK)
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="xiao")
def xiao(self, request: Request):
""""""
openid = "oy4Jw6A1T3WkKOOhMxcbQTDSM8rs"
channels_name = redis_5.get(name="xiaozizi")
async_to_sync(awaitable=default_channel_layer.send)(channel=channels_name,
message={"type": "chat_msg",
"data": {"xiao": "zizi"},
})
message={"type": "chat_msg",
"data": {"xiao": "zizi"},
})
httpResData = BaseResponse(resData=ResData(listData=[""], dictData={"demo": "xiaozizi"}), ).model_dump()
return Response(data=httpResData, status=status.HTTP_200_OK)
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="eventSource")
def sse请求处理接口(self, request: Request):
""""""
@@ -83,27 +84,25 @@ class DemoXiaoViewSets(ViewSet):
"sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口sse请求处理接口")
httpResData = BaseResponse(resData=ResData(listData=[""], dictData={"demo": "xiaozizi"}), ).model_dump()
return Response(data=httpResData, status=status.HTTP_200_OK)
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="xiaozizi",
authentication_classes=[Jwt身份认证])
authentication_classes=[Jwt身份认证])
# @sync_lock_线程锁( lock=lock )
def xiaozizi(self, request: Request):
pass
return Response(data={"xiao": "111111111111111111"})
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="redirect")
# @sync_lock_线程锁( lock=lock )
def redirect(self, request: Request):
# 接口是用来测试重定向
pass
return HttpResponseRedirect(redirect_to="https://six.sixgou.com/")
# @sync_lock(lock=lock)
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="中文", )
def 中文(self, request: Request):
print("卡异步的请求")
xiaozizi = request.data.get("xiaozizi", None)
print(xiaozizi)
return Response(data={"msg": xiaozizi})
+7 -10
View File
@@ -13,11 +13,11 @@ from rest_framework.viewsets import ViewSet
from ulid import ULID
from sixGuoDjango import BaseResponse, ResData
from wechat_微信支付证书.江苏六果科技有限公司支付证书.江苏六果科技有限公司支付参数 import sixpay六果科技公司
from wechat_微信支付证书.江苏六果科技有限公司支付证书.六果公司支付类 import sixWechatPay六果泡泡支付
from wechat_数据库.支付订单数据库.商品订单数据 import order订单
from wechat_数据库.用户数据库.小程序登陆用户 import weiuser
from wechat_项目工具包.EMS中国邮政.ems邮政 import ems邮政物流工具
from wechat_项目工具包.微信支付工具包.微信支付类 import paymentCategory, wechatPay
from wechat_项目工具包.微信支付工具包.微信支付类 import paymentCategory
from wechat_项目工具包.数据库的工具包.更新用户积分 import miniUser用户角色, miniUser积分
@@ -84,7 +84,6 @@ class 业务订单接口ViewSets(ViewSet):
order订单类型 = request.data.get("order订单类型", None)
goods标题 = emoji.replace_emoji(pydash.get(obj=pydash.head(order购物车商品数据), path="goods_商品标题"))
goods_detail_支付优惠券的数据 = self.生成单品优惠券的数据(order购物车商品数据=order购物车商品数据)
print("打印一下哪里出问题了", order购物车商品数据)
out_trade_no商家侧的订单号 = f"OAT{ULID()}" # 生成商家侧的订单号
body = {
"mchid": paymentCategory.mchid, # 【直连商户号】 直连商户号
@@ -109,8 +108,7 @@ class 业务订单接口ViewSets(ViewSet):
},
"support_fapiao": True, # 【电子发票入口开放标识】 传入true时,支付成功消息和支付详情页将出现开票入口。需要在微信支付商户平台或微信公众平台开通电子发票功能,传此字段才可生效。
} # 请求的数据
wechat_data = wechatPay(payment=sixpay六果科技公司).getpay_jsapi(uri=url_pay, body_data=body, method="POST")
payData = pydash.get(obj=wechat_data, path="response")
wechat_pay_data = sixWechatPay六果泡泡支付(pay_methon方法="POST", pay_请求体=body, pay_uri=url_pay).getpay_jsapi发起支付()
order订单对象 = order订单.objects.create(order支付商家侧订单号=out_trade_no商家侧的订单号,
order购物车商品总价=order购物车商品总价, order购物车商品数据=order购物车商品数据,
order购物车商品数量=order购物车商品数量,
@@ -121,7 +119,7 @@ class 业务订单接口ViewSets(ViewSet):
order支付者openid=self_mini_openid,
order支付者unionid=self_mini_unionid,
)
httpResData = BaseResponse(resData=ResData(listData=[""], dictData=payData), ).model_dump()
httpResData = BaseResponse(resData=ResData(listData=[""], dictData=wechat_pay_data), ).model_dump()
# httpResData = BaseResponse(resData=ResData(listData=[""], dictData={}), ).model_dump()
return Response(data=httpResData, status=status.HTTP_200_OK)
@@ -129,9 +127,8 @@ class 业务订单接口ViewSets(ViewSet):
@action(detail=False, methods=["post"], url_path="mall_callbakc")
def jsapi支付回调测试接口(self, request: Request) -> Response:
""" 微信支付成功后的回调接口 """
dict_body = request.data
wechat_data支付回调数据 = wechatPay(payment=paymentCategory).callBack回调解密(headers=request.headers,
response_body=dict_body, )
wechat_data支付回调数据 = sixWechatPay六果泡泡支付(pay_uri="", pay_请求体={}, pay_methon方法="POST", ).callBack回调解密(headers=request.headers, response_body=request.data)
print("支付的回调数据", wechat_data支付回调数据)
out_trade_no商家侧支付订单号 = pydash.get(obj=wechat_data支付回调数据, path="out_trade_no") # 商家侧的订单号
trade_state_desc = pydash.get(obj=wechat_data支付回调数据, path="trade_state_desc") # 支付回调的支付状态
transaction_id = pydash.get(obj=wechat_data支付回调数据, path="transaction_id")
@@ -143,7 +140,7 @@ class 业务订单接口ViewSets(ViewSet):
order物流订单号=生成商家侧物流的订单号,
order支付微信官方订单号=transaction_id,
)
(miniUser积分(share分享者unionidID="", click点击者unionidID="")
(miniUser积分(share分享者unionidID="", click点击者unionidID="", bind绑定的企微unionidID="")
.add添加好友助力下单返利积分(order支付商家侧订单号=out_trade_no商家侧支付订单号, share积分类型="好友下单"))
ems邮政物流工具().生成运单(out_trade_no商家侧支付订单号=out_trade_no商家侧支付订单号) # 调用方法,生成真实的物流订单号码;
httpResData = BaseResponse(resData=ResData(listData=[""], dictData={"demo": "xiaozizi"}), ).model_dump()
+1 -2
View File
@@ -36,8 +36,7 @@ class 实时更新物流数据ViewSets(ViewSet):
def 实时更新物流数据(self, request: Request):
"""前端小程序, 物流追踪页面, 左上角 刷新按钮 返回的数据"""
order物流公司订单编号 = request.data.get("order物流公司订单编号", None)
order物流订单号 = request.data.get("order物流订单号", None)
print("实时更新数据请求进来了吗")
ems邮政物流工具().更新物流快递数据(order物流公司订单编号=order物流公司订单编号, )
print("调有了实时更新的数据接口,这里更新的数据为ems的物流的数据")
httpResData = BaseResponse(resData=ResData(listData=[""], dictData={}), ).model_dump()
return Response(data=httpResData, status=status.HTTP_200_OK)
+29 -8
View File
@@ -6,6 +6,7 @@ from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.viewsets import ViewSet
from wechat_数据库.微信支付券.代金券数据库 import stock券数据表
from wechat_项目工具包.微信支付工具包.领优惠券工具包 import stock发送代金券功能
default_channel_layer = cast(BaseChannelLayer, get_channel_layer(alias="default"))
@@ -31,13 +32,33 @@ class 小程序发优惠券到钱包接口ViewSets(ViewSet):
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="生成优惠券")
def 生成优惠券(self, request: Request):
""""""
# stock发券数据 = stock发送代金券功能(stock_id_代金券批次号="22512292").send发券并返回前端需要的数据()
stock发券数据 = stock发送代金券功能(stock_id_代金券批次号="22625737").send发券并返回前端需要的数据()
# 4. 生成签名
return Response(data=stock发券数据)
"""这里的接口就是将,券,直接发送给前端用户,"""
self_mini_openid = request.data.get("self_mini_openid", None)
self_mini_unionid = request.data.get("self_mini_unionid", None)
print(self_mini_openid, self_mini_unionid)
stock查询数据领券成功时的处理: stock券数据表 | None = stock券数据表.objects.filter(mini_unionid=self_mini_unionid, mini_openid=self_mini_openid, stock_use_券状态="已领券").first()
if stock查询数据领券成功时的处理 is not None:
return Response(data={"stock券状态": "已领券", "stock领券数据": {}})
stock查询数据: stock券数据表 | None = stock券数据表.objects.filter(mini_unionid=self_mini_unionid, mini_openid=self_mini_openid, stock_use_券状态="待领券").first()
print(stock查询数据, "在这里查询到的结果")
if stock查询数据 is None:
# 查询数据库,看看用户当前有没有券已发了但是还没有领取的状态
# stock发券数据 = stock发送代金券功能(stock_id_代金券批次号="22512292").send发券并返回前端需要的数据()
stock发券数据 = stock发送代金券功能(stock_id_代金券批次号="22625737", stock券的状态="待领券").send发券并返回前端需要的数据(self_mini_openid=self_mini_openid, self_mini_unionid=self_mini_unionid)
# 4. 生成签名
# return Response(data=stock发券数据)
return Response(data={"stock券状态": "待领券", "stock领券数据": stock发券数据})
else:
pass
print("查询是这里生效了啦")
return Response(data={"stock券状态": stock查询数据.stock_use_券状态, "stock领券数据": stock查询数据.stock_未领取券的数据})
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="返回当前券的状态")
def 返回当前券的状态(self, request: Request):
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="领券后更新当前券的状态")
def 领券后更新当前券的状态(self, request: Request):
pass
return Response(data={})
self_mini_openid = request.data.get("self_mini_openid", None)
self_mini_unionid = request.data.get("self_mini_unionid", None)
stock券状态 = request.data.get("stock券状态", None)
print("用户领券成功了")
stock发送代金券功能(stock_id_代金券批次号="22625737", stock券的状态=stock券状态, stock券已领券="已领券").领券后更新当前券的状态(self_mini_openid=self_mini_openid, self_mini_unionid=self_mini_unionid)
return Response(data={"stock券状态": stock券状态, "stock领券数据": {}})