package com.uas.finance.service.Impl;

import com.uas.finance.dao.MFCustInfoDetailDao;
import com.uas.finance.model.MFCustInfo;
import com.uas.finance.dao.MFCustInfoDao;
import com.uas.finance.model.MFCustInfo;
import com.uas.finance.model.MFCustInfoDetail;
import com.uas.finance.service.MFCustInfoService;
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/21
 **/
@Service
public class MFCustInfoServiceImpl implements MFCustInfoService {

    @Autowired
    private MFCustInfoDao mfCustInfoDao;

    @Autowired
    private MFCustInfoDetailDao mfCustInfoDetailDao;

    /**
     * 保存买方
     *
     * @param info
     * @return
     */
    public MFCustInfo save(MFCustInfo info) {
        return mfCustInfoDao.save(info);
    }

    /**
     * 根据id找到买方
     *
     * @param id
     * @return
     */
    public MFCustInfo findOne(Long id) {
        return mfCustInfoDao.findOne(id);
    }

    /**
     * 更新买方资料
     *
     * @param mfCustInfoList
     */
    @Override
    public List<Map<String, Long>> update(List<MFCustInfo> mfCustInfoList) {
        List<Map<String, Long>> list = new ArrayList<Map<String, Long>>();
        for (MFCustInfo mfCustInfo : mfCustInfoList) {
            Map<String, Long> map = new HashMap<String, Long>();
            MFCustInfo mfCustInfo1 = mfCustInfoDao.save(mfCustInfo);
            map.put("id", mfCustInfo.getId());
            map.put("mf_id", mfCustInfo.getErpId());
            list.add(map);
        }
        return list;
    }
}
