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.BakingRefundIndex;
import com.zm.order.tool.server.model.refund.BaseRefundIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 烘焙退款文档处理器
 *
 * @author zhuxiaofeng
 * @date 2022-11-10 16:07:11
 */
@Component
public class BakingRefundDocHandler implements RefundDocHandler {

    @Autowired
    private Mapper mapper;

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

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

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