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.RetailRefundIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 零售退款文档处理器
 *
 * @author zhuxiaofeng
 * @date 2022-11-10 16:07:11
 */
@Component
public class RetailRefundDocHandler implements RefundDocHandler {
    
    @Autowired
    private Mapper mapper;

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

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

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