package com.seeyon.apps.src_ydctdatasync.datamap;

import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import java.util.function.Function;

public class RefundDataMapMode extends AbstractFeeDataMapMode{

    @Override
    public void preProcess(Map<String, Object> map) {
        super.preProcess(map);
        String incomeOrCost = EnumMapUtils.getEnumItemValue(cwRootPcode,agent,"收支类型","支");
        map.put("incomeOrCost",incomeOrCost);
    }

    @Override
    public Map<String, Function<Object, Object>> getFieldProcessors() {
        return Collections.emptyMap();
    }

    @Override
    public boolean support() {
        return false;
    }

    @Override
    public void transfer(Object target, Object source) {
        commonAttrTransfer(target,source);
        Map<String, Object> targetMap = (Map<String, Object>) target;
        Map<String, Object> sourceMap = (Map<String, Object>) source;
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        targetMap.put("收支类型",sourceMap.get("incomeOrCost")); //填充收支类型
        targetMap.put("住保-费用类型",sourceMap.get("refund_type")); //填充费用类型
        targetMap.put("住保-支付订单状态",sourceMap.get("refund_status")); //填充订单状态
        targetMap.put("订单描述说明",sourceMap.get("recharge_desc")); //填充订单说明
        targetMap.put("本次实付金额",sourceMap.get("refund_amount")); //填充本次实付金额
        try {
            targetMap.put("住保-退还账单时间",df.format((Date) sourceMap.get("refund_bill_time"))); //填充退还账单时间
            targetMap.put("实付日期",df.format((Date)sourceMap.get("refund_time"))); //填充实付日期
        } catch (NullPointerException e) {

        }
    }
}
