package org.springblade.modules.ldt.pointdetail.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.ldt.billrecord.entity.BillRecord;
import org.springblade.modules.ldt.billrecord.service.IBillRecordService;
import org.springblade.modules.ldt.pointdetail.entity.PointDetail;
import org.springblade.modules.ldt.pointdetail.vo.PointDetailVO;

import java.util.Objects;

/**
 * Created By lidexi in 2021/8/13
 **/
public class PointDetailWrapper extends BaseEntityWrapper<PointDetail, PointDetailVO> {

	private IBillRecordService billRecordService;
	private PointDetailWrapper(IBillRecordService billRecordService){
		this.billRecordService = billRecordService;
	}
	public static PointDetailWrapper build(IBillRecordService billRecordService){
		return new PointDetailWrapper(billRecordService);
	}
	@Override
	public PointDetailVO entityVO(PointDetail pointDetail) {
		PointDetailVO pointDetailVO = Objects.requireNonNull(BeanUtil.copy(pointDetail,PointDetailVO.class));
		BillRecord billRecord = billRecordService.getById(pointDetailVO.getBillRecordId());
		if(billRecord != null){
			pointDetailVO.setPayWay(billRecord.getPayWay());
		}
		return pointDetailVO;
	}
}
