| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- """临时脚本:在本地库插入与线上一致的优惠券/充值套餐对照数据(仅用于接口对比)。"""
- import datetime
- import json
- import re
- from pathlib import Path
- import pymysql
- from _root import ROOT
- YML = Path(str(ROOT / "yoshop-java/src/main/resources/application.yml"))
- text = YML.read_text(encoding="utf-8")
- pwd = re.findall(r"password:\s*(.+)", text)[0].strip().strip('"').strip("'")
- CST = datetime.timezone(datetime.timedelta(hours=8))
- created = int(datetime.datetime(2026, 10, 17, 17, 8, 41, tzinfo=CST).timestamp())
- start_ts = int(datetime.datetime(2026, 10, 1, tzinfo=CST).timestamp())
- end_ts = int(datetime.datetime(2026, 10, 31, tzinfo=CST).timestamp()) + 86399
- conn = pymysql.connect(host="192.168.1.177", port=3306, user="root", password=pwd,
- database="shop", autocommit=True, charset="utf8mb4")
- cur = conn.cursor()
- cur.execute("delete from yoshop_coupon where coupon_id in (10001,10002)")
- cur.execute("""
- insert into yoshop_coupon
- (coupon_id,name,coupon_type,reduce_price,discount,min_price,expire_type,expire_day,
- start_time,end_time,apply_range,apply_range_config,total_num,receive_num,`describe`,
- status,sort,is_delete,store_id,create_time,update_time)
- values
- (10001,'TESTJ满减券',10,10.00,0,100.00,10,7,0,0,10,'[]',-1,0,'自动测试用',1,100,0,10001,%s,%s),
- (10002,'TESTJ折扣券',20,0.00,99,50.00,20,1,%s,%s,20,%s,5,0,'',1,90,0,10001,%s,%s)
- """, (created, created, start_ts, end_ts,
- json.dumps({"goodsIds": ["10004"]}, ensure_ascii=False), created, created))
- cur.execute("delete from yoshop_recharge_plan where plan_id=10001")
- cur.execute("""
- insert into yoshop_recharge_plan
- (plan_id,plan_name,money,gift_money,sort,is_delete,store_id,create_time,update_time)
- values (10001,'TESTJ充值套餐',100.00,10.00,100,0,10001,%s,%s)
- """, (created, created))
- print("inserted coupons + plan")
- cur.execute("select coupon_id,name,discount,start_time,end_time,apply_range_config from yoshop_coupon")
- for row in cur.fetchall():
- print(row)
- conn.close()
|