package com.kym.service.wechat.impl;


import com.kym.entity.WashOrder;
import com.kym.service.cache.KymCache;
import com.kym.service.wechat.TemplateParamBuilder;

import java.util.Map;

/**
 * 订单完成提醒消息模板参数构建器
 */
public class OrderCompletedParamBuilder implements TemplateParamBuilder {

    private static final String ORDER_ID = "character_string2";
    private static final String STATION_NAME = "thing4";
    private static final String ORDER_AMOUNT = "amount11";
    private static final String BALANCE = "amount12";
    private static final String ENT_TIME = "time5";

    @Override
    public Map<String, String> buildParams(Object... args) {
        if (args.length < 2 || !(args[0] instanceof WashOrder washOrder)) {
            throw new IllegalArgumentException("需要传入有效的参数");
        }
        return Map.of(
                ORDER_ID, washOrder.getOrderId(),
                STATION_NAME, KymCache.INSTANCE.getStationNameById(washOrder.getStationId()),
                ORDER_AMOUNT, formatAmount(washOrder.getAmountReceived()),
                BALANCE, formatAmount(Integer.parseInt(args[1].toString())),
                ENT_TIME, washOrder.getEndTime().format(formatter)
        );
    }
}
