/**
 * 商品订单请求参数（对齐 PC product-order/config/search.ts）
 */

import { buildSearchTimeQueryParams } from './reconciliationParams.js'

export function buildOrderListParams({
	page = 1,
	pageSize = 15,
	orderNo = '',
	status,
	deliveryMethod,
	prescriptionType,
	dateStart,
	dateEnd,
}) {
	const params = {
		page,
		pageSize,
		...buildSearchTimeQueryParams(dateStart, dateEnd),
	}
	if (orderNo) params.order_no = orderNo
	if (status !== '' && status != null) params.status = status
	if (deliveryMethod !== '' && deliveryMethod != null) params.delivery_method = deliveryMethod
	if (prescriptionType !== '' && prescriptionType != null) params.prescription_type = prescriptionType
	return params
}

export function buildOrderSaleAmountParams(opts) {
	const { page, pageSize, ...rest } = opts || {}
	return buildOrderListParams(rest)
}
