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.AssistantRefundIndex;
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 AssistantRefundDocHandler implements RefundDocHandler {
    
    @Autowired
    private Mapper mapper;

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

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

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