package com.ruoyi.hezhi.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.hezhi.domain.TbExpressKdCode;
import com.ruoyi.hezhi.mapper.TbExpressKdCodeMapper;
import com.ruoyi.hezhi.service.ITbExpressKdCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 快递编码Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-20
 */
@Service
public class TbExpressKdCodeServiceImpl implements ITbExpressKdCodeService
{
    @Autowired
    private TbExpressKdCodeMapper tbExpressKdCodeMapper;

    /**
     * 查询快递编码
     *
     * @param id 快递编码主键
     * @return 快递编码
     */
    @Override
    public TbExpressKdCode selectTbExpressKdCodeById(Long id)
    {
        return tbExpressKdCodeMapper.selectTbExpressKdCodeById(id);
    }

    /**
     * 查询快递编码列表
     *
     * @param tbExpressKdCode 快递编码
     * @return 快递编码
     */
    @Override
    public List<TbExpressKdCode> selectTbExpressKdCodeList(TbExpressKdCode tbExpressKdCode)
    {
        return tbExpressKdCodeMapper.selectTbExpressKdCodeList(tbExpressKdCode);
    }

    /**
     * 新增快递编码
     *
     * @param tbExpressKdCode 快递编码
     * @return 结果
     */
    @Override
    public int insertTbExpressKdCode(TbExpressKdCode tbExpressKdCode)
    {
        tbExpressKdCode.setCreateTime(DateUtils.getNowDate());
        return tbExpressKdCodeMapper.insertTbExpressKdCode(tbExpressKdCode);
    }

    /**
     * 修改快递编码
     *
     * @param tbExpressKdCode 快递编码
     * @return 结果
     */
    @Override
    public int updateTbExpressKdCode(TbExpressKdCode tbExpressKdCode)
    {
        return tbExpressKdCodeMapper.updateTbExpressKdCode(tbExpressKdCode);
    }

    /**
     * 批量删除快递编码
     *
     * @param ids 需要删除的快递编码主键
     * @return 结果
     */
    @Override
    public int deleteTbExpressKdCodeByIds(Long[] ids)
    {
        return tbExpressKdCodeMapper.deleteTbExpressKdCodeByIds(ids);
    }

    /**
     * 删除快递编码信息
     *
     * @param id 快递编码主键
     * @return 结果
     */
    @Override
    public int deleteTbExpressKdCodeById(Long id)
    {
        return tbExpressKdCodeMapper.deleteTbExpressKdCodeById(id);
    }

    /**
     * 查询快递
     *
     * @param code 快递编码
     * @return 快递编码
     */
    @Override
    public TbExpressKdCode selectTbExpressKdCodeByCode(String code) {
        return tbExpressKdCodeMapper.selectTbExpressKdCodeByCode(code);
    }

    // /**
    //  * 查询快递信息
    //  *
    //  * @param shippingMark 快递公司代号
    //  * @param shippingCode 快递单号
    //  * @return 结果
    //  */
    // @Override
    // public List<Map<String, Object>> checkExpressInfoMessage(String shippingMark, String shippingCode) {
    //     JSONObject expressJsonData = AppBeanInjector.kd100Util.getExpressJsonData(shippingMark, shippingCode);
    //
    //     JSONArray data = expressJsonData.getJSONArray("data");
    //     ArrayList<Map<String, Object>> expressList = new ArrayList<>();
    //     for (int i = 0; i < data.size(); i++) {
    //         JSONObject jsonObject = data.getJSONObject(i);
    //
    //         HashMap<String, Object> map = new HashMap<>();
    //         map.put("time", jsonObject.getString("time"))
    //         map.put("context", jsonObject.getString("context"))
    //         expressList.add(map);
    //     }
    //     return expressList;
    // }
}
