package com.bohuikeji.delivery.backstage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bohuikeji.delivery.backstage.entity.TThirdInfo;
import com.bohuikeji.delivery.backstage.entity.third.OrderDetailDO;
import com.bohuikeji.delivery.backstage.mapper.TThirdInfoMapper;
import com.bohuikeji.delivery.backstage.service.IThirdInfoService;
import com.bohuikeji.frame.module.admin.base.ServiceImplBase;
import com.bohuikeji.frame.module.admin.utils.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class TThirdInfoServiceImpl extends ServiceImplBase<TThirdInfoMapper, TThirdInfo> implements IThirdInfoService {
    /**
     * 添加骑手信息
     *
     * @param detail
     * @return
     */
    @Override
    public TThirdInfo add(OrderDetailDO detail) {
        if (StringUtils.isBlank(detail.getCourierPhone())){
            return null;
        }
        TThirdInfo info=getOne(new QueryWrapper<TThirdInfo>().eq("courier_phone",detail.getCourierPhone()),false);
        if (info==null){
            info=new TThirdInfo();
            info.setCourierPhone(detail.getCourierPhone());
            info.setCourierName(detail.getCourierName());
            info.setThirdName(detail.getThirdName());
        }
        save(info);
        return info;
    }
}
