package com.kym.service.wechat.impl;

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

import java.util.Map;

/**
 * 退款申请消息模板参数构建器
 */
public class RefundApplyParamBuilder implements TemplateParamBuilder {
    private static final String REFUND_ID = "character_string3";
    private static final String REFUND_AMOUNT = "amount2";
    private static final String CREATE_TIME = "time4";
    private static final String USER_STATION = "thing5";

    @Override
    public Map<String, String> buildParams(Object... args) {
        if (args.length == 0 || !(args[0] instanceof RefundLog refundLog)) {
            throw new IllegalArgumentException("需要传入有效的参数");
        }
        return Map.of(
                REFUND_ID, refundLog.getRefundId(),
                REFUND_AMOUNT, formatAmount(refundLog.getRefund()),
                CREATE_TIME, refundLog.getCreateTime().format(formatter),
                USER_STATION, KymCache.INSTANCE.getUserStationName(refundLog.getUserId())
        );
    }
}
