six_006
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import requests
|
||||
import yarl
|
||||
from pydantic import BaseModel
|
||||
from ulid import ULID
|
||||
|
||||
from wechat_微信支付证书.江苏六果科技有限公司支付证书.六果公司支付类 import sixWechatPay六果泡泡支付
|
||||
|
||||
|
||||
class MerchantCoupon代金券API(BaseModel):
|
||||
# demo_必填: int = Field(..., description="描述") # 必传属发生
|
||||
|
||||
# demo_可选: Optional[int] = None # 可选值
|
||||
# demo_默认值: int = Field(default=100001, description="描述") # 有默认值
|
||||
# demo_联合类型: Literal["xiao", "zizi"] = Field(..., description="描述") 商家券
|
||||
|
||||
def model_post_init(self, __context):
|
||||
print("初始化完成,自动调用 model_post_init")
|
||||
|
||||
def 发放指定批次的代金券(self, mini_openid):
|
||||
pass
|
||||
uri = f"https://api.mch.weixin.qq.com/v3/marketing/favor/users/{mini_openid}/coupons"
|
||||
out_request_no = str(ULID())
|
||||
body = {
|
||||
"stock_id": "22941326", # 必须为代金券(全场券或单品券)批次号
|
||||
"out_request_no": out_request_no, # 【商户单据号】商户此次发放凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性
|
||||
"appid": sixWechatPay六果泡泡支付().appid, # 公众账号ID】微信为发券方商户分配的公众账号ID
|
||||
"stock_creator_mchid": sixWechatPay六果泡泡支付().mchid, # 创建方商户号。
|
||||
}
|
||||
header = sixWechatPay六果泡泡支付(pay_uri=uri, pay_请求体=body, ).pay_Headers
|
||||
print(header)
|
||||
postData = requests.post(url=uri, json=body, headers=header).json()
|
||||
print(postData)
|
||||
|
||||
def 根据商户号查用户的券(self, mini_openid):
|
||||
pass
|
||||
uri = ""
|
||||
uri = yarl.URL.build(scheme='https', host="api.mch.weixin.qq.com", path=f"/v3/marketing/favor/users/{mini_openid}/coupons",
|
||||
query={"appid": sixWechatPay六果泡泡支付().appid, "creator_mchid": sixWechatPay六果泡泡支付().mchid}
|
||||
) # yarl
|
||||
print(uri.human_repr())
|
||||
headers = sixWechatPay六果泡泡支付(pay_uri=uri.human_repr(), pay_methon方法="GET").pay_Headers
|
||||
print(headers)
|
||||
postData = requests.get(url=uri.human_repr(), headers=headers).json()
|
||||
print(postData)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
print(ULID(), type(ULID()))
|
||||
# MerchantCoupon代金券API().发放指定批次的代金券(mini_openid="ohQkD7NMWkO2aehP9wjBTUXtN7Y0")
|
||||
MerchantCoupon代金券API().根据商户号查用户的券(mini_openid="ohQkD7NMWkO2aehP9wjBTUXtN7Y0")
|
||||
utc_unix_timestamp = int(datetime.now(tz=ZoneInfo("utc")).timestamp())
|
||||
uri = yarl.URL.build(scheme='https', host="xiao.sixgou.com", path="/开票/开票回调接口/",
|
||||
query={"key": "value"}
|
||||
) # yarl
|
||||
Reference in New Issue
Block a user