package com.gree.mall.miniapp.logic.settle;

import com.gree.mall.miniapp.bean.settle.repair.DailyReportBean;
import com.gree.mall.miniapp.bean.settle.repair.DailyWorkerIssueSalaryBean;
import com.gree.mall.miniapp.commonmapper.DailyReportMapper;
import com.gree.mall.miniapp.constant.DailyConstant;
import com.gree.mall.miniapp.plus.entity.SettleDailyIssueSummaryMonthRecord;
import com.gree.mall.miniapp.plus.service.SettleDailyIssueSummaryMonthRecordService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class DailyMyWalletLogic {

    @Resource
    DailyReportMapper dailyReportMapper;

    @Autowired
    SettleDailyIssueSummaryMonthRecordService settleDailyIssueSummaryMonthRecordService;


    public List<DailyReportBean> issueList(String workerNumber, String date, Boolean install) {
        if (StringUtils.isNotEmpty(date)) {
            date = date.replaceAll("-", "");
        }
        Integer status = DailyConstant.ISSUE_STATUS_SUCCESS;
        List<DailyReportBean> list = dailyReportMapper.issueDayList(workerNumber, date, status,install);
        return list;
    }

    public List<DailyWorkerIssueSalaryBean> queryMyOrderList(String workerNumber, String salaryNo, String id, String q) {
        return dailyReportMapper.queryMyOrderList(workerNumber, salaryNo, id, q);
    }

    public List<DailyWorkerIssueSalaryBean> queryMyOrderMonthList(String workerNumber, String summaryBatchNo, String id, String q) {
        return dailyReportMapper.queryMyOrderMonthList(workerNumber, summaryBatchNo, id, q);
    }

    public List<SettleDailyIssueSummaryMonthRecord> issueMonthList(String workerNumber, String month) {
        if (StringUtils.isNotEmpty(month)) {
            month = month.replaceAll("-", "");
        }
        List<SettleDailyIssueSummaryMonthRecord> list = settleDailyIssueSummaryMonthRecordService.lambdaQuery()
                .eq(StringUtils.isNotEmpty(month), SettleDailyIssueSummaryMonthRecord::getMonth, month)
                .eq(SettleDailyIssueSummaryMonthRecord::getStatus, DailyConstant.ISSUE_STATUS_SUCCESS)
                .eq(SettleDailyIssueSummaryMonthRecord::getServiceNumber, workerNumber).list();
        return list;
    }

    public List<DailyWorkerIssueSalaryBean> notIssueList(String workerNumber, String id, String q,Boolean install) {
        List<DailyWorkerIssueSalaryBean> list = dailyReportMapper.notIssueList(workerNumber, id, q, DailyConstant.ISSUE_STATUS_APP_NOT,install);
        return list;
    }
}
