package com.chaozhanggui.admin.system.service;


import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantProfitMapper;
import com.chaozhanggui.dao.system.dao.TbPlussVoiceboxProfitMapper;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantProfit;
import com.chaozhanggui.dao.system.entity.TbPlussVoiceboxProfit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author lyf
 */
@Service
@Slf4j
public class PromotionService {
    @Resource
    private TbPlussMerchantProfitMapper merchantProfitMapper;
    @Resource
    private TbPlussVoiceboxProfitMapper voiceBoxProfitMapper;

    public RespBody uploadFile(List<ArrayList<String>> list){
        if (!list.isEmpty()){
            List<TbPlussVoiceboxProfit> voiceboxProfitList = new ArrayList<>();
            for (int i = 0; i < list.size(); i++) {
                List<String> arrayLists = list.get(i);
                //拿到二维数组里具体值
                TbPlussVoiceboxProfit voiceBoxProfit = new TbPlussVoiceboxProfit();
                voiceBoxProfit.setMerchantCode(arrayLists.get(0));
                voiceBoxProfit.setAmount(arrayLists.get(1));
                voiceBoxProfit.setRemarks(arrayLists.get(2));
                voiceboxProfitList.add(voiceBoxProfit);
            }
            Integer integer = voiceBoxProfitMapper.insertList(voiceboxProfitList);
            HashMap<String, Object> map = new HashMap<>();
            map.put("row",list.size());
            map.put("success",integer);
            return new RespBody("000000",map);
        }
        return new RespBody("999950");
    }

}
