package com.hzs.report.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.domain.report.stat.CuLianchuangDataStat;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.report.member.mapper.CuLianchuangDataStatMapper;
import com.hzs.report.member.service.ICuLianchuangDataStatService;
import com.hzs.report.member.vo.AbroadDataStatVO;
import com.hzs.report.member.vo.CuLianchuangDataStatVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 联创报表统计 服务实现类
 * </p>
 *
 * @author zhangjing
 * @since 2023-10-19
 */
@Service
public class CuLianchuangDataStatServiceImpl extends ServiceImpl<CuLianchuangDataStatMapper, CuLianchuangDataStat> implements ICuLianchuangDataStatService {

    /**
     * @description: 查询联创数据报表
     * @author: zhang jing
     * @date: 2023/10/19 16:01
     * @param: [lcVO]
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public List<CuLianchuangDataStatVO> lcStatList(List<CuLianchuangDataStat> lcList) {
        return baseMapper.lcStatList(lcList);
    }
    @Override
    public List<CuLianchuangDataStatVO> lcStatListByOrdeType(List<Integer> orderTypeList,Integer orderType,CuLianchuangDataStat lcDate) {
        return baseMapper.lcStatListByOrdeType(orderTypeList,orderType,lcDate);
    }

    /**
     * @description: 联创数据查询
     * @author: zhang jing
     * @date: 2024/7/17 16:40
     * @param: [orderTypeList, orderType, lcDate]
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public List<CuLianchuangDataStatVO> newLcStatListByOrdeType(CuLianchuangDataStatVO lcDate,Long pkMember) {
        return baseMapper.newLcStatListByOrdeType(lcDate,pkMember);
    }

    /**
     * @description: 数据报表-联创统计历史业绩数据
     * @author: zhang jing
     * @date: 2024/5/30 10:16
     * @param: [orderTypeList, orderType, lcDate]
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public List<CuLianchuangDataStatVO> lcStatOrdeHistoryList(CuLianchuangDataStatVO cds,CuLianchuangDataStat lcDate) {
        return baseMapper.lcStatOrdeHistoryList(cds,lcDate);
    }

    /**
     * @description:数据报表-联创统计历史业绩累计数据
     * @author: zhang jing
     * @date: 2024/5/31 11:34
     * @param: [cds, lcDate]
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public List<CuLianchuangDataStatVO> lcStatOrderHistorySumList(CuLianchuangDataStatVO cds,CuLianchuangDataStat lcDate) {
        return baseMapper.lcStatOrderHistorySumList(cds,lcDate);
    }







    /**
     * @description: 查询国外数据报表
     * @author: zhang jing
     * @date: 2023/12/5 10:38
     * @param: [pkCountryList, startDate, endDate]
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public List<AbroadDataStatVO> abroadStatList(List<CuLianchuangDataStatVO> pkCountryList,
                                                 String startDate,
                                                 String endDate) {
        return baseMapper.abroadStatList(pkCountryList, startDate, endDate);
    }

    /**
     * @description: 国家列表
     * @author: zhang jing
     * @date: 2023/12/5 11:22
     * @param: []
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public List<CuLianchuangDataStatVO> countryList() {
        return baseMapper.countryList();
    }



    /**
     * @description: 删除查询联创数据报表条件
     * @author: zhang jing
     * @date: 2023/10/20 9:46
     * @param: [pkIdList]
     * @return: boolean
     **/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteLcStat(List<Long> pkIdList) {
        for (Long l : pkIdList) {
            UpdateWrapper<CuLianchuangDataStat> updateWrapper = new UpdateWrapper();
            updateWrapper.set("DEL_FLAG", EDelFlag.DELETE.getValue());
            updateWrapper.set("PK_MODIFIED", SecurityUtils.getUserId());
            updateWrapper.set("MODIFIED_TIME", new Date());
            updateWrapper.eq("PK_ID", l);
            baseMapper.update(null, updateWrapper);
        }
        return true;
    }

    /**
     * @description: 新联创查询会员金额和业绩
     * @author: zhang jing
     * @date: 2025/3/4 17:09
     * @param: [addRegion, reduceRegion]
     * @return: java.util.List<com.hzs.report.member.vo.CuLianchuangDataStatVO>
     **/
    @Override
    public CuLianchuangDataStatVO getLianchuangDifference(CuLianchuangDataStatVO clds,CuLianchuangDataStatVO member) {
        return baseMapper.getLianchuangDifference(clds,member);
    }
}
