Add WeChat MP batch props xlsx and CORS-ready prop image URLs.
Generate upload sheet from PRODUCT_OFFERS and serve /props/ with mp.weixin.qq.com CORS. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b845d0bcea
commit
b574a54d4c
BIN
apps/miniprogram/docs/nomadro_wx_props_batch_upload.xlsx
Normal file
BIN
apps/miniprogram/docs/nomadro_wx_props_batch_upload.xlsx
Normal file
Binary file not shown.
@ -48,6 +48,26 @@ WX_PAY_ENV=0
|
||||
3. 端上 `wx.requestVirtualPayment`
|
||||
4. 发货 / 查单走 `/xpay/*`,签名用当前环境 AppKey
|
||||
|
||||
## 微信后台批量上传
|
||||
|
||||
模板:`nomadro_wx_props_batch_upload.xlsx`(桌面 + 本目录)
|
||||
生成脚本:`apps/miniprogram/scripts/gen_wx_props_batch_xlsx.py`
|
||||
|
||||
| 列 | 要求 |
|
||||
|---|---|
|
||||
| 道具id | 必填,≤32 位英文 |
|
||||
| 道具名称 | 必填,≤10 字 |
|
||||
| 道具图片 | 必填,HTTPS 链接;PNG/JPG;200×200;≤200KB;**须允许 CORS** |
|
||||
| 道具价格 | 必填,整数元,≤10000 |
|
||||
| 备注 | 选填,≤50 字、不对外展示 |
|
||||
|
||||
单次最多 200 条;xlsx ≤3MB。
|
||||
|
||||
当前图片 CDN:`https://admin.nomadro.cn/props/{id}.png`
|
||||
已对 `https://mp.weixin.qq.com` 放开 CORS(`Access-Control-Allow-Origin`)。
|
||||
|
||||
本仓库已填 6 个付费道具:`tiktok` / `youtube` / `nomad` / `svip` / `ebook_unlock_default` / `test`。
|
||||
|
||||
## 验收
|
||||
|
||||
- 开发者工具:`WX_PAY_ENV=1` 用沙箱 AppKey
|
||||
|
||||
65
apps/miniprogram/scripts/gen_wx_props_batch_xlsx.py
Normal file
65
apps/miniprogram/scripts/gen_wx_props_batch_xlsx.py
Normal file
@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Generate WeChat MP virtual-pay batch props xlsx (example_batch_add_product format)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import openpyxl
|
||||
from openpyxl.styles import Alignment, Font
|
||||
|
||||
# SoT: apps/api/.../products.py (paid only)
|
||||
# 价格单位:元(整数);图片须可被 mp.weixin.qq.com CORS 拉取
|
||||
IMG_BASE = "https://admin.nomadro.cn/props"
|
||||
|
||||
ROWS = [
|
||||
# (道具id, 道具名称≤10字, 图片URL, 价格元, 备注≤50)
|
||||
("tiktok", "tiktok", f"{IMG_BASE}/tiktok.png", 88, "已发布方案 · 试读30%"),
|
||||
("youtube", "youtube", f"{IMG_BASE}/youtube.png", 188, "默认付费方案 · 试读30%"),
|
||||
("nomad", "nomad", f"{IMG_BASE}/nomad.png", 49, "已发布方案 · 试读30%"),
|
||||
("svip", "svip", f"{IMG_BASE}/svip.png", 998, "已发布方案 · 试读30%"),
|
||||
("ebook_unlock_default", "ebook", f"{IMG_BASE}/ebook.png", 188, "旧默认道具 · 试读30%"),
|
||||
("test", "test", f"{IMG_BASE}/test.png", 1, "联调测试道具 · ¥1"),
|
||||
]
|
||||
|
||||
OUT_DIRS = [
|
||||
Path(r"c:\Users\Administrator\Desktop"),
|
||||
Path(__file__).resolve().parents[1] / "docs",
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
wb = openpyxl.Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "Sheet1"
|
||||
headers = ["道具id", "道具名称", "道具图片", "道具价格", "备注"]
|
||||
ws.append(headers)
|
||||
for cell in ws[1]:
|
||||
cell.font = Font(bold=True)
|
||||
cell.alignment = Alignment(wrap_text=True)
|
||||
|
||||
for row in ROWS:
|
||||
# validate
|
||||
pid, name, url, price, remark = row
|
||||
assert len(pid) <= 32 and pid.isascii() and pid.replace("_", "").isalnum()
|
||||
assert len(name) <= 10
|
||||
assert url.lower().endswith((".png", ".jpg", ".jpeg"))
|
||||
assert isinstance(price, int) and 1 <= price <= 10000
|
||||
assert len(remark) <= 50
|
||||
ws.append(list(row))
|
||||
|
||||
ws.column_dimensions["A"].width = 24
|
||||
ws.column_dimensions["B"].width = 14
|
||||
ws.column_dimensions["C"].width = 56
|
||||
ws.column_dimensions["D"].width = 12
|
||||
ws.column_dimensions["E"].width = 28
|
||||
|
||||
name = "nomadro_wx_props_batch_upload.xlsx"
|
||||
for d in OUT_DIRS:
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
path = d / name
|
||||
wb.save(path)
|
||||
print("wrote", path, "rows", len(ROWS))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user