package com.ruoyi.web.modules.trading;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import com.ruoyi.web.modules.trading.domain.BizDistributor;
import com.ruoyi.web.modules.trading.domain.BizSupplier;
import com.ruoyi.web.modules.trading.domain.BizTradeOrder;
import com.ruoyi.web.modules.trading.domain.BizTradeOrderLine;
import com.ruoyi.web.modules.trading.support.DistributorRules;
import com.ruoyi.web.modules.trading.support.SupplierRules;
import com.ruoyi.web.modules.trading.support.TradeOrderRules;

/**
 * 交易订单测试样本。
 */
public final class TradeOrderTestSamples
{
    public static final Long SUPPLIER_ID_1 = 1L;

    public static final Long DISTRIBUTOR_ID_1 = 1L;

    public static final Long ORDER_ID = 2001L;

    public static final String ORDER_NO = "20260520001";

    private TradeOrderTestSamples()
    {
    }

    public static BizSupplier supplierPerHead()
    {
        BizSupplier supplier = new BizSupplier();
        supplier.setId(SUPPLIER_ID_1);
        supplier.setSupplierName("扎西合作社");
        supplier.setDelFlag(SupplierRules.DEL_FLAG_NORMAL);
        supplier.setFeeMethod(SupplierRules.FEE_METHOD_PER_HEAD);
        supplier.setFeeStandard(new BigDecimal("10"));
        return supplier;
    }

    public static BizSupplier supplierNoFee()
    {
        BizSupplier supplier = supplierPerHead();
        supplier.setFeeMethod(null);
        return supplier;
    }

    public static BizDistributor activeDistributor()
    {
        BizDistributor d = new BizDistributor();
        d.setId(DISTRIBUTOR_ID_1);
        d.setDistributorName("扎西承销服务点");
        d.setDelFlag(DistributorRules.DEL_FLAG_NORMAL);
        return d;
    }

    public static BizTradeOrderLine line(String earTag, String weight, String amount)
    {
        BizTradeOrderLine line = new BizTradeOrderLine();
        line.setEarTag(earTag);
        line.setWeight(new BigDecimal(weight));
        line.setAmount(new BigDecimal(amount));
        return line;
    }

    public static BizTradeOrder normalSaveRow()
    {
        BizTradeOrder row = new BizTradeOrder();
        row.setSupplierId(SUPPLIER_ID_1);
        row.setDistributorId(DISTRIBUTOR_ID_1);
        row.setLineList(Collections.singletonList(line("E101", "120.5", "8000.00")));
        return row;
    }

    public static BizTradeOrder twoLineSaveRow()
    {
        BizTradeOrder row = new BizTradeOrder();
        row.setSupplierId(SUPPLIER_ID_1);
        row.setDistributorId(DISTRIBUTOR_ID_1);
        row.setLineList(Arrays.asList(
                line("E101", "120", "8000"),
                line("E104", "115", "7500")));
        return row;
    }

    public static BizTradeOrder pendingRow()
    {
        BizTradeOrder row = normalSaveRow();
        row.setId(ORDER_ID);
        row.setOrderNo(ORDER_NO);
        row.setTotalHeads(1);
        row.setTotalAmount(new BigDecimal("8000.00"));
        row.setOrderStatus(TradeOrderRules.ORDER_STATUS_PENDING);
        row.setDelFlag(TradeOrderRules.DEL_FLAG_NORMAL);
        row.setSupplierName("扎西合作社");
        row.setDistributorName("扎西承销服务点");
        row.setCreateTime(new Date());
        BizTradeOrderLine paidLine = line("E101", "120.5", "8000.00");
        paidLine.setSupplierId(SUPPLIER_ID_1);
        row.setLineList(Collections.singletonList(paidLine));
        return row;
    }

    public static BizTradeOrder payRequest()
    {
        BizTradeOrder row = new BizTradeOrder();
        row.setId(ORDER_ID);
        row.setPayVoucherUrl("/profile/upload/2026/05/voucher.jpg");
        row.setPayVoucherPath("/upload/2026/05/voucher.jpg");
        return row;
    }
}
