package com.seeyon.apps.src_ydctdatasync.datamap;

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

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

public class HydropowerRechargeDataMapMode extends AbstractFeeDataMapMode{

    @Override
    public void preProcess(Map<String, Object> map) {
        super.preProcess(map);
        String incomeOrCost = EnumMapUtils.getEnumItemValue(zcRootPcode,agent,"收支类型","收");
        String feeType = EnumMapUtils.getEnumItemValue(zcRootPcode,agent,"住保-费用类型", (String) map.get("水电费"));
        map.put("incomeOrCost",incomeOrCost);
        map.put("feeType",feeType);
    }

    @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")); //填充收支类型
        try {
            targetMap.put("到账日期",df.format(TimeUtils.convertLocalDateTime2Date(sourceMap.get("recharge_time")))); //填充到账日期
            targetMap.put("住保-账单生成日期",df.format(TimeUtils.convertLocalDateTime2Date(sourceMap.get("recharge_time")))); //填充账单生成日期
            targetMap.put("实收日期",df.format(TimeUtils.convertLocalDateTime2Date(sourceMap.get("recharge_time")))); //填充实收日期
        }catch (NullPointerException e) {

        }
        targetMap.put("住保-主键",sourceMap.get("recharge_id")); //主键
        targetMap.put("住保-费用类型",sourceMap.get("feeType")); //填充费用类型
        targetMap.put("住保-支付订单状态",sourceMap.get("recharge_status")); //填充订单状态

    }

}
