package com.yd.csf.api.service.impl;

import com.yd.common.exception.BusinessException;
import com.yd.common.result.Result;
import com.yd.csf.api.service.ApiCommissionService;
import com.yd.csf.feign.request.commission.CommissionExpectedEditStatusRequest;
import com.yd.csf.service.model.CommissionExpected;
import com.yd.csf.service.service.CommissionExpectedService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ApiCommissionServiceImpl implements ApiCommissionService {

    @Autowired
    private CommissionExpectedService commissionExpectedService;

    /**
     * 修改入账状态
     * @param request
     * @return
     */
    @Override
    public Result editStatus(CommissionExpectedEditStatusRequest request) {
        CommissionExpected commissionExpected = commissionExpectedService.queryOne(request.getCommissionExpectedBizId());
        if (commissionExpected == null) {
            throw new BusinessException("预计来佣数据不存在");
        }
        commissionExpected.setStatus(request.getStatus());
        commissionExpected.setStatusDesc(request.getStatusDesc());
        commissionExpectedService.saveOrUpdate(commissionExpected);
        return Result.success();
    }
}
