fix(ecom-script): 刷单单量按店×天控制,规格随机分配并修正预计条数

This commit is contained in:
小蟑螂
2026-05-30 02:18:33 +08:00
parent ede706a8e0
commit f888a4ac1b
4 changed files with 1110 additions and 18 deletions
File diff suppressed because it is too large Load Diff
+2
View File
@@ -143,6 +143,8 @@ CREATE TABLE `ec_order` (
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_company_shop_time`(`company_id` ASC, `shop_id` ASC, `order_time` ASC) USING BTREE,
INDEX `idx_company_order_time`(`company_id` ASC, `order_time` ASC) USING BTREE COMMENT '覆盖概览/工作台按公司+时间范围查询',
INDEX `idx_company_order_time_status`(`company_id` ASC, `order_time` ASC, `status_id` ASC) USING BTREE COMMENT '覆盖概览/工作台按公司+时间范围+状态查询',
INDEX `idx_status_id`(`status_id` ASC) USING BTREE,
INDEX `idx_platform_order_no`(`platform_order_no` ASC) USING BTREE,
INDEX `idx_product_spec_id`(`product_spec_id` ASC) USING BTREE,
+2 -1
View File
@@ -115,7 +115,8 @@ async function seedHandler(opts) {
const dayCount = Math.floor((endDate - startDate) / 86400000) + 1;
const shopDailyAvg = (dailyMin + dailyMax) / 2;
const estimatedTotal = Math.ceil(specs.length * shops.length * dayCount * shopDailyAvg);
// 预计总量 = 店数 × 天数 × 单店日均(与规格数量无关)
const estimatedTotal = Math.ceil(shops.length * dayCount * shopDailyAvg);
console.log(`\n公司: ${company.name} (${company.id})`);
console.log(`时间: ${formatDate(startDate)} ~ ${formatDate(endDate)} (${dayCount} 天)`);
+17 -17
View File
@@ -95,28 +95,28 @@ export function* iterateOrders(config) {
const cfg = { companyId, confirm };
let total = 0;
for (const spec of specs) {
let current = new Date(startDate);
const end = new Date(endDate);
// 单量按「店 × 天」控制;每笔订单从所选规格中随机挑选
let current = new Date(startDate);
const end = new Date(endDate);
while (current <= end) {
const dayStart = new Date(current);
const dayEnd = new Date(current);
dayEnd.setHours(23, 59, 59, 999);
while (current <= end) {
const dayStart = new Date(current);
const dayEnd = new Date(current);
dayEnd.setHours(23, 59, 59, 999);
for (const shop of shops) {
const count = randInt(dailyMin, dailyMax);
for (let i = 0; i < count; i++) {
const status = statuses[randInt(0, statuses.length - 1)];
const orderTime = randomDate(dayStart, dayEnd);
total++;
for (const shop of shops) {
const count = randInt(dailyMin, dailyMax);
for (let i = 0; i < count; i++) {
const spec = specs[randInt(0, specs.length - 1)];
const status = statuses[randInt(0, statuses.length - 1)];
const orderTime = randomDate(dayStart, dayEnd);
total++;
yield makeOrder(cfg, spec, shop, status, orderTime, seenOrderNos, remarkPool, priceRange);
}
yield makeOrder(cfg, spec, shop, status, orderTime, seenOrderNos, remarkPool, priceRange);
}
current.setDate(current.getDate() + 1);
}
current.setDate(current.getDate() + 1);
}
return total;