package com.ruixuan.bytedance.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruixuan.bytedance.entity.BytedancePromoterOrderList;
import com.ruixuan.bytedance.mapper.BytedancePromoterOrderListMapper;
import com.ruixuan.bytedance.service.IBytedancePromoterOrderListService;
import com.ruixuan.common.utils.Check;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 团长订单Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-28
 */
@Service
public class BytedancePromoterOrderListServiceImpl implements IBytedancePromoterOrderListService {
    @Autowired
    private BytedancePromoterOrderListMapper bytedancePromoterOrderListMapper;

    /**
     * 查询团长订单
     *
     * @param orderId 团长订单主键
     * @return 团长订单
     */
    @Override
    public BytedancePromoterOrderList selectBytedancePromoterOrderListByOrderId(Long orderId) {
        return bytedancePromoterOrderListMapper.selectBytedancePromoterOrderListByOrderId(orderId);
    }

    /**
     * 查询团长订单列表
     *
     * @param bytedancePromoterOrderList 团长订单
     * @return 团长订单
     */
    @Override
    public List<BytedancePromoterOrderList> selectBytedancePromoterOrderListList(BytedancePromoterOrderList bytedancePromoterOrderList) {
        return bytedancePromoterOrderListMapper.selectBytedancePromoterOrderListList(bytedancePromoterOrderList);
    }

    @Override
    public List<JSONObject> getBytedanceOrderList(Map<String, Object> requestMap, boolean flag) {
        List<JSONObject> list = bytedancePromoterOrderListMapper.getBytedanceOrderList(requestMap);
        if (Check.isNotNull(list) && flag) {
            for (int i = 0; i < list.size(); i++) {
                JSONObject jsonObject = list.get(i);
                requestMap.put("promoterId", jsonObject.getString("promoterId"));
                List<JSONObject> topOrders = bytedancePromoterOrderListMapper.getTopOrders(requestMap);
                jsonObject.put("topOrders", topOrders);
            }
        }
        return list;
    }

    @Override
    public List<JSONObject> bytedanceBDReportList(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceBDReportList(requestMap);
    }

    @Override
    public List<JSONObject> anchorBytedanceOrderDetail(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.anchorBytedanceOrderDetail(requestMap);
    }

    @Override
    public List<JSONObject> bytedanceItemList(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceItemList(requestMap);
    }

    @Override
    public List<JSONObject> adminBytedanceReportList(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.adminBytedanceReportList(requestMap);
    }

    @Override
    public List<JSONObject> adminBytedanceReportListByBind(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.adminBytedanceReportListByBind(requestMap);
    }

    @Override
    public List<JSONObject> getBytedanceTopPromoterByItemId(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.getBytedanceTopPromoterByItemId(requestMap);
    }

    @Override
    public List<JSONObject> bytedanceOrderStatistics(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceOrderStatistics(requestMap);
    }

    @Override
    public List<JSONObject> bytedanceItemDetail(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceItemDetail(requestMap);
    }

    @Override
    public List<JSONObject> bytedanceBDTotal(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceBDTotal(requestMap);
    }

    @Override
    public List<JSONObject> bytedanceBDDetailList(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceBDDetailList(requestMap);
    }

    @Override
    public JSONObject bytedanceUserItemTotal(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceUserItemTotal(requestMap);
    }

    @Override
    public List<JSONObject> bytedanceUserItemDetail(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.bytedanceUserItemDetail(requestMap);
    }

    @Override
    public List<JSONObject> exportBytedancePromoter(Map<String, Object> requestMap) {
        return bytedancePromoterOrderListMapper.exportBytedancePromoter(requestMap);
    }
}