package com.zswl.cloud.springBtach.server.core.job.pcod;

import com.github.microservice.auth.client.content.ResultContent;
import com.github.microservice.auth.client.content.ResultState;
import com.zswl.cloud.springBtach.server.core.job.standard.StandarDeliveryJob;
import lombok.Data;
import lombok.experimental.Delegate;
import lombok.extern.log4j.Log4j2;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Log4j2
@Configuration
public class PcodeDeliveryJob  {

    @Autowired
    @Delegate
    StandarDeliveryJob standarDeliveryJob;

    public Step pcodDeliveryStep() {

        return getStepBuilderFactory().get("pcodDeliveryStep").tasklet((it,ii)->{

            log.info("二维码订单已支付");
            getResultContent().set(ResultContent.build(ResultState.Success));
            return RepeatStatus.FINISHED;

        }).build();


    }

    @Bean
    public Job pcod111DeliveryJob() {
        return getJobBuilderFactory()
                .get("pcod111DeliveryJob")
                .start(pcodDeliveryStep())
                .incrementer(new RunIdIncrementer())
                .build();
    }

}
