package com.uas.finance.service.Impl;

import com.uas.finance.service.MFCustInfoDetailService;
import com.uas.finance.dao.MFCustInfoDetailDao;
import com.uas.finance.model.MFCustInfoDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * created by shicr on 2017/12/24
 **/
@Service
public class MFCustInfoDetailServiceImpl implements MFCustInfoDetailService {

    @Autowired
    private MFCustInfoDetailDao detailDao;

    @Override
    public MFCustInfoDetail save(MFCustInfoDetail detail) {
        return detailDao.save(detail);
    }

    /**
     * 更新erp传来的买方明细
     *
     * @param detail
     * @return
     */
    @Override
    public List<Map<String, Long>> update(List<MFCustInfoDetail> detail) {
        List<Map<String, Long>> list = new ArrayList<Map<String, Long>>();
        for (MFCustInfoDetail mfCustInfoDetail : detail) {
            Map<String, Long> map = new HashMap<String, Long>();
            MFCustInfoDetail mfCustInfoDetail1 = detailDao.save(mfCustInfoDetail);
            map.put("id", mfCustInfoDetail.getId());
            map.put("mfd_id", mfCustInfoDetail.getErpId());
            list.add(map);
        }
        return list;
    }
}
