package com.cusc.nirvana.user.rnr.fp.service.impl;

import com.alibaba.fastjson.JSON;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.fp.dto.BulkBackDTO;
import com.cusc.nirvana.user.rnr.fp.dto.FpT1UploadStatusDTO;
import com.cusc.nirvana.user.rnr.fp.dto.T1CompletionReqDTO;
import com.cusc.nirvana.user.rnr.fp.service.T1ReportCompletionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @className: T1ReportCompletionServiceImpl
 * @description:
 * @author: jk
 * @date: 2022/8/23 11:03
 * @version: 1.0
 **/
@Service
public class T1ReportCompletionServiceImpl implements T1ReportCompletionService {

    @Resource
    private FpT1UploadStatusServiceImpl fpT1UploadStatusService;

    @Override
    public Response T1ReportCompletionCmcc(T1CompletionReqDTO t1CompletionReqDTO) {

        BulkBackDTO bulkBackDTO =  (BulkBackDTO)t1CompletionReqDTO.getCallbackData();
        FpT1UploadStatusDTO fpT1UploadStatusDTO = new FpT1UploadStatusDTO();
        fpT1UploadStatusDTO.setRequestId(t1CompletionReqDTO.getRequestID());
        if("1".equals(bulkBackDTO.getOprRst())){
            fpT1UploadStatusDTO.setReportCompletion(1);
        }else {
            fpT1UploadStatusDTO.setReportCompletion(2);
        }
        fpT1UploadStatusDTO.setReportCompletionResp(JSON.toJSONString(bulkBackDTO));

        fpT1UploadStatusService.update(fpT1UploadStatusDTO);
        return Response.createSuccess();
    }

}
