package com.sckw.contract.service;
import java.util.Date;

import com.sckw.contract.dao.KwcContractLogisticsTrackMapper;
import com.sckw.contract.model.entity.KwcContractLogisticsTrack;
import com.sckw.core.exception.SystemException;
import com.sckw.core.model.constant.Global;
import com.sckw.core.model.enums.ContractTrackEnum;
import com.sckw.core.utils.IdWorker;
import com.sckw.core.web.constant.HttpStatus;
import com.sckw.core.web.context.LoginUserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author PC
* @description 针对表【kwc_contract_logistics_track(物流合同（承运合同/托运合同）-物流订单)】的数据库操作Service实现
* @createDate 2023-07-13 13:36:19
*/
@Service
public class KwcContractLogisticsTrackService {

    @Autowired
    private KwcContractLogisticsTrackMapper kwcContractLogisticsTrackMapper;

    /**
     * @param contractId 合同id
     * @desc: 存审批记录
     * @author: czh
     * @date: 2023/7/14
     */
    public void saveContractLogisticsTrack(Long contractId) {
        KwcContractLogisticsTrack kwcContractLogisticsTrack = new KwcContractLogisticsTrack();
        Date date = new Date();
        kwcContractLogisticsTrack.setId(new IdWorker(1L).nextId());
        kwcContractLogisticsTrack.setContractId(contractId);
        kwcContractLogisticsTrack.setType(ContractTrackEnum.SIGNING.getCode());
        kwcContractLogisticsTrack.setRemark("");
        kwcContractLogisticsTrack.setStatus(Global.NO);
        kwcContractLogisticsTrack.setCreateBy(LoginUserHolder.getUserId());
        kwcContractLogisticsTrack.setCreateTime(date);
        kwcContractLogisticsTrack.setUpdateBy(LoginUserHolder.getUserId());
        kwcContractLogisticsTrack.setUpdateTime(date);
        kwcContractLogisticsTrack.setDelFlag(Global.NO);
        if (kwcContractLogisticsTrackMapper.insert(kwcContractLogisticsTrack) <= 0) {
            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
        }
    }

}




