package com.zm.order.tool.server.handler.refund;

import com.github.dozermapper.core.Mapper;
import com.zm.order.tool.server.enums.BizTypeEnum;
import com.zm.order.tool.server.model.Refund;
import com.zm.order.tool.server.model.refund.BaseRefundIndex;
import com.zm.order.tool.server.model.refund.CyRefundIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 老餐饮退款文档处理器
 *
 * @author zhuxiaofeng
 * @date 2022-11-10 16:07:11
 */
@Component
public class CyRefundDocHandler implements RefundDocHandler {

    @Autowired
    private Mapper mapper;

    @Override
    public Integer bizType() {
        return BizTypeEnum.CY.getType();
    }

    @Override
    public BaseRefundIndex buildRefundDoc(Refund refund) {
        CyRefundIndex refundIndex = mapper.map(refund, CyRefundIndex.class);
        buildBaseInfo(refundIndex, refund);
        return refundIndex;
    }

    private void buildBaseInfo(CyRefundIndex refundIndex, Refund refund) {
        refundIndex.setRefundId(refund.getId());
    }
}
