package org.jeecg.ctop.material.service.impl;


import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.ctop.material.constants.Check;
import org.jeecg.ctop.material.mapper.KuaishouPromoterMapper;
import org.jeecg.ctop.material.service.IKuaishouPromoterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class IKuaishouPromoterServiceImpl implements IKuaishouPromoterService {

    @Resource
    private KuaishouPromoterMapper promoterMapper;

    @Override
    public JSONObject getPromoterInfo(Long promoterId) {
        JSONObject data = promoterMapper.getPromoterInfo(promoterId);
        if (!Check.isNull(data)) {
            data.put("hotSaleBrandInfo", data.getJSONArray("hotSaleBrandInfo"));
            data.put("hotSaleChannelInfo", data.getJSONArray("hotSaleChannelInfo"));
            data.put("fanCharacteristic", promoterMapper.getFansCharacteristic(promoterId));
            String today = DateUtils.date2Str();
            Integer startInt = DateUtils.getDateInteger(DateUtils.getLastDay(today, 31));
            Integer endInt = DateUtils.getDateInteger(DateUtils.getLastDay(today, 1));
            data.put("liveInfo", promoterMapper.getPromoterLiveCommerceInfo(promoterId, startInt, endInt));
            data.put("shortVideosInfo", promoterMapper.getPromoterShortVideosCommerceInfo(promoterId, startInt, endInt));
        }
        return data;
    }

    @Override
    public JSONObject getPromoterVideoInfo(Long promoterId) {
        return promoterMapper.getPromoterVideoInfo(promoterId);
    }
}
