mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 07:49:20 +08:00
fix(ecom-script): 刷单单量按店×天控制,规格随机分配并修正预计条数
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -143,6 +143,8 @@ CREATE TABLE `ec_order` (
|
|||||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
INDEX `idx_company_shop_time`(`company_id` ASC, `shop_id` ASC, `order_time` ASC) 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_status_id`(`status_id` ASC) USING BTREE,
|
||||||
INDEX `idx_platform_order_no`(`platform_order_no` 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,
|
INDEX `idx_product_spec_id`(`product_spec_id` ASC) USING BTREE,
|
||||||
|
|||||||
+2
-1
@@ -115,7 +115,8 @@ async function seedHandler(opts) {
|
|||||||
|
|
||||||
const dayCount = Math.floor((endDate - startDate) / 86400000) + 1;
|
const dayCount = Math.floor((endDate - startDate) / 86400000) + 1;
|
||||||
const shopDailyAvg = (dailyMin + dailyMax) / 2;
|
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(`\n公司: ${company.name} (${company.id})`);
|
||||||
console.log(`时间: ${formatDate(startDate)} ~ ${formatDate(endDate)} (${dayCount} 天)`);
|
console.log(`时间: ${formatDate(startDate)} ~ ${formatDate(endDate)} (${dayCount} 天)`);
|
||||||
|
|||||||
@@ -95,28 +95,28 @@ export function* iterateOrders(config) {
|
|||||||
const cfg = { companyId, confirm };
|
const cfg = { companyId, confirm };
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
for (const spec of specs) {
|
// 单量按「店 × 天」控制;每笔订单从所选规格中随机挑选
|
||||||
let current = new Date(startDate);
|
let current = new Date(startDate);
|
||||||
const end = new Date(endDate);
|
const end = new Date(endDate);
|
||||||
|
|
||||||
while (current <= end) {
|
while (current <= end) {
|
||||||
const dayStart = new Date(current);
|
const dayStart = new Date(current);
|
||||||
const dayEnd = new Date(current);
|
const dayEnd = new Date(current);
|
||||||
dayEnd.setHours(23, 59, 59, 999);
|
dayEnd.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
for (const shop of shops) {
|
for (const shop of shops) {
|
||||||
const count = randInt(dailyMin, dailyMax);
|
const count = randInt(dailyMin, dailyMax);
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
const status = statuses[randInt(0, statuses.length - 1)];
|
const spec = specs[randInt(0, specs.length - 1)];
|
||||||
const orderTime = randomDate(dayStart, dayEnd);
|
const status = statuses[randInt(0, statuses.length - 1)];
|
||||||
total++;
|
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;
|
return total;
|
||||||
|
|||||||
Reference in New Issue
Block a user