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
+5 -42
View File
@@ -104,15 +104,7 @@ class sixmini(ViewSet):
)
def uploadTempMedia(self, request: WSGIRequest | Request, *args, **kwargs):
"""
:param request:
:type request:
:param args:
:type args:
:param kwargs:
:type kwargs:
"""
# 上传图片的接口
uri = f"https://api.weixin.qq.com/cgi-bin/media/upload"
wecom_token = sixToken.get_wecom_token()
@@ -150,10 +142,6 @@ class sixmini(ViewSet):
def 消息解密(self, encrypt: str):
"""
知识点: 微信请求发送过来的 encrypt 是 b64encode编码后的数据, 是由 iv + 编码数据 组成的
:param encrypt:
:type encrypt:
:return:
:rtype:
"""
aes_key = base64.b64decode(self.EncodingAESKey + "=") # 补 全 Base64 编码缺失的 '='
# Step 2: Base64 解码加密数据
@@ -188,22 +176,6 @@ class sixmini(ViewSet):
if 确认收货的方法:
print("确认收货的回请求进来了")
ems邮政物流工具().确认收货(order支付微信侧订单号=order支付微信侧订单号)
确认收货的时候数据 = {
'ToUserName': 'gh_f754c53eb962',
'FromUserName': 'ohQkD7HmLYEYrFjFau6juOhduRU8',
'CreateTime': 1784839115,
'MsgType': 'event', # 类型,微信官方默认的
'Event': 'trade_manage_order_settlement', # 接收到消息的类型, 可以判断是不是当前用户 确认收货
'transaction_id': '4200003120202607191690098150', # 微信官方生成的支付订单号
'merchant_id': '1700383419', # 微信官方的商户号
'sub_merchant_id': '', # 子商户有的商户ID
'merchant_trade_no': '548663656512',
'pay_time': 1784410374, # 接收到消息的时间戳
'shipped_time': 1784666314, # 商家发货的时间
'confirm_receive_method': 2, # 当前用户 确认收货的方式 2:表示是自动确认收货 1:表示用户主动点击收货
'confirm_receive_time': 1784839114, # 当前用户确认收货的时间
'settlement_time': 1784839115, # 微信官方 确认的 结算时间
}
def web_view_auth(self, request: WSGIRequest | Request, ):
""""""
@@ -213,19 +185,14 @@ class sixmini(ViewSet):
return HttpResponse(content="8cfc2017094adff8d7c66b94e209456e")
def api_get(self, request: Request, *args, **kwargs):
"""
:param request:
:param args:
:param kwargs:
:return:
"""
print("认证请求进来了")
"""微信小程序接口的回调"""
signature = request.query_params.get("signature", "")
timestamp = request.query_params.get("timestamp", "")
nonce = request.query_params.get("nonce", "")
echostr = request.query_params.get("echostr", False)
# TODO:sorted([token, timestamp, nonce])这是就是对三个参数进行字典排序
hashstr = "".join(sorted([self.token, timestamp, nonce])) # 这是就是对三个参数进行字典排序
# hashstr = "".join(sorted([self.token, timestamp, nonce])) # 这是就是对三个参数进行字典排序
hashstr = pydash.join(array=sorted([self.token, timestamp, nonce]), separator="")
sig = hashlib.new(name="sha1", data=hashstr.encode("utf-8")).hexdigest()
if sig == signature:
# 当上面的值判断正确后 官方要求原样返回 echostr ;
@@ -244,11 +211,8 @@ class sixmini(ViewSet):
Encrypt = request.data.get("Encrypt", False) #
xml_content = self.消息解密(encrypt=Encrypt)
Event = pydash.get(obj=xml_content, path="Event")
FromUserName = pydash.get(obj=xml_content, path="FromUserName")
MsgType = pydash.get(obj=xml_content, path="MsgType")
print("微信官方到底推送了啥信息啊...........为什么", )
print(xml_content)
print("微信官方到底推送了啥信息啊...........为什么", )
print("小程序官方推送的消息", xml_content)
if Event == "trade_manage_order_settlement":
# 这里的通知是微信官方发过来的, 同时,是用户没有确认收货时 达到时间后自动触发的
self.确认收货(data=xml_content)
@@ -257,7 +221,6 @@ class sixmini(ViewSet):
# subMsgObj = weiuser.objects.get(mini_openid=FromUserName)
if Event == "add_express_path":
# 这里发生回调,是说明物流的快递信息有推送
pass
self.更新物流信息(data=xml_content)
if MsgType == "text":
pass