package com.ruoyi.erp.request;

import com.alibaba.fastjson2.JSONObject;

/**
 * 查询订单列表请求
 *
 * 对应接口：POST /api/open/order/list
 */
public class OrderListQueryRequest extends ERPRequestBase {
	public OrderListQueryRequest(IERPAccount erpAccount) {
		super("https://open.goofish.pro/api/open/order/list", erpAccount);
	}

	public void setAuthorizeId(long authorizeId) { ensureBody(); this.requestBody.put("authorize_id", authorizeId); }
	public void setOrderStatus(Integer orderStatus) { putIfNotNull("order_status", orderStatus); }
	public void setRefundStatus(Integer refundStatus) { putIfNotNull("refund_status", refundStatus); }

	public void setOrderTime(long start, long end) { setRange("order_time", start, end); }
	public void setPayTime(long start, long end) { setRange("pay_time", start, end); }
	public void setConsignTime(long start, long end) { setRange("consign_time", start, end); }
	public void setConfirmTime(long start, long end) { setRange("confirm_time", start, end); }
	public void setRefundTime(long start, long end) { setRange("refund_time", start, end); }
	public void setUpdateTime(long start, long end) { setRange("update_time", start, end); }

	public void setPageNo(int pageNo) { ensureBody(); this.requestBody.put("page_no", pageNo); }
	public void setPageSize(int pageSize) { ensureBody(); this.requestBody.put("page_size", pageSize); }
	public void setPage(int pageNo, int pageSize) { ensureBody(); this.requestBody.put("page_no", pageNo); this.requestBody.put("page_size", pageSize); }

	private void setRange(String key, long start, long end) { ensureBody(); this.requestBody.put(key, new long[]{start, end}); }
	private void putIfNotNull(String key, Object value) { if (value != null) { ensureBody(); this.requestBody.put(key, value); } }
	private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
}


