Skip to content

Instantly share code, notes, and snippets.

@ValeryVerkhoturov
ValeryVerkhoturov / fo_agg.md
Last active August 28, 2026 13:00
Описание сборки агрегатов деталей ФО

Описание сборки агрегатов деталей ФО

Ветвление по docTypeName

Для каждой записи нужно смотреть на поле docTypeName (сравнение регистронезависимое):

1. Если docTypeName == "продажа"

К агрегатам отчёта прибавляются соответствующие поля записи:

package main
import (
"fmt"
"runtime"
"time"
"github.com/xuri/excelize/v2"
)
@ValeryVerkhoturov
ValeryVerkhoturov / bonusTypeName_en_localization.json
Last active August 20, 2026 12:16
Поля ФО ВБ. Нет гарантии, что в этих полях могут прийти только обозначенные значения. Если есть другие значения на английском, для обновления мапингов пишите https://t.me/ValerianaOfficinalis
{
"Возврат брака (К продавцу)": "Return fee for defective items: Outbound logistics",
"Возврат по инициативе продавца (К продавцу)": "Return fee for seller-initiated returns: Outbound logistics",
"Возврат неопознанного товара (К продавцу)": "Return fee for unidentified items: Outbound logistics",
"Возврат заблокированного товара (К продавцу)": "Return fee for banned items: Outbound logistics",
"Возврат товара продавцу по отзыву (К продавцу)": "Return fee for low-rated items to seller: Outbound logistics",
"Возврат товара, который приехал по МП, продавцу (К продавцу)": "Return fee for FBS items: Outbound logistics",
"Возврат КГТ продавцу (К продавцу)": "Return fee for LRG items: Outbound logistics",
"Возврат удаленной карточки продавцу (К продавцу)": "Return fee for items from removed listings: Outbound logistics",
"Возврат по инициативе продавца (Скидка) (К продавцу)": "Return fee for seller-initiated returns: Discount: Outbound logistics",
// $go test -bench=. -benchmem -count=1 -timeout=60m ./bench/
// goos: linux
// goarch: amd64
// pkg: open-api-streaming/bench
// cpu: Intel(R) Core(TM) Ultra 7 165H
// BenchmarkNonStreaming/20k-22 1 4992228793 ns/op 20000 items 343319144 B/op 2021991 allocs/op
// BenchmarkNonStreaming/100k-22 1 22535888759 ns/op 100000 items 1597454152 B/op 10480705 allocs/op
// BenchmarkNonStreaming/1M-22 1 236724331269 ns/op 1000000 items 20456522784 B/op 103956295 allocs/op
// BenchmarkStreaming/20k-22 1 4538066003 ns/op 20000 items 82356144 B/op 1997525 allocs/op
// BenchmarkStreaming/100k-22 1 20280130851 ns/op 100000 items 393346336 B/op 10598465 allocs/op
type ReportDetail struct {
RealizationReportID int64 `json:"realizationreport_id" `
DateFrom string `json:"date_from"`
DateTo string `json:"date_to"`
CreateDate string `json:"create_dt"`
CurrencyName string `json:"currency_name"`
SupplierContractCode *string `json:"suppliercontract_code"`
RrdID int64 `json:"rrd_id"`
GiID int64 `json:"gi_id"` // Номер поставки
SrcOfficeCoefficient decimal.Decimal `json:"dlv_prc"` // Фиксированный коэффициент склада по поставке
@ValeryVerkhoturov
ValeryVerkhoturov / bonusTypeName_ch_localization.json
Last active August 20, 2026 12:11
Поля ФО ВБ. Нет гарантии, что в этих полях могут прийти только обозначенные значения. Если есть другие значения на китайском, для обновления мапингов пишите https://t.me/ValerianaOfficinalis
{
"Возврат брака (К продавцу)": "次品退货(至卖家)",
"Возврат по инициативе продавца (К продавцу)": "卖家主动退货(至卖家)",
"Возврат неопознанного товара (К продавцу)": "未识别商品退货(至卖家)",
"Возврат заблокированного товара (К продавцу)": "封禁商品退货(至卖家)",
"Возврат товара продавцу по отзыву (К продавцу)": "因评论退回卖家的商品(至卖家)",
"Возврат товара, который приехал по МП, продавцу (К продавцу)": "FBS模式到货商品退回卖家(至卖家)",
"Возврат КГТ продавцу (К продавцу)": "大型商品退回卖家(至卖家)",
"Возврат удаленной карточки продавцу (К продавцу)": "已删除商品退回卖家(至卖家)",
"Возврат по инициативе продавца (Скидка) (К продавцу)": "卖家主动退货(折扣)(至卖家)",
@ValeryVerkhoturov
ValeryVerkhoturov / bigint.js
Last active September 22, 2025 05:39
Handle BigInt in JSON serialization & deserialization
const WBNBReportsJSON = (() => {
const noiseValue = /^-?\d+n+$/; // Noise - strings that match the custom format before being converted to it
const originalStringify = JSON.stringify;
const originalParse = JSON.parse;
/*
Function to serialize value to a JSON string.
Converts BigInt values to a custom format (strings with digits and "n" at the end) and then converts them to proper big integers in a JSON string.
*/
const stringify = (value, replacer, space) => {
import random
from decimal import Decimal, getcontext
getcontext().prec = 7
def split_amount_with_error(total_amount, parts=10, error_percent=10):
total_amount = Decimal(str(total_amount))
error_fraction = Decimal(str(error_percent)) / Decimal('100')
base_part = total_amount / Decimal(str(parts))
document.documentElement.style.setProperty('scrollbar-gutter', 'stable');
@ValeryVerkhoturov
ValeryVerkhoturov / Dockerfile
Created April 20, 2025 09:49
Dockerfile for SPA (Ex.: Vite)
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm i --force
COPY . .
RUN npm run build