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

import cn.hutool.json.JSONUtil;
import com.github.microservice.auth.security.helper.AuthHelper;
import com.zhongshu.payment.client.service.v2.OrderService2;
import com.zswl.cloud.shop.client.service.ShopService;
import com.zswl.cloud.springBtach.server.core.helper.RedisHelper;
import com.zswl.cloud.springBtach.server.core.job.standard.StandarOrderJob;
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
@Configuration
@Log4j2
public class YppOrderJob {



    @Autowired
    OrderService2 orderService2;

    @Autowired
    ShopService shopService;

    @Autowired
    AuthHelper authHelper;

    @Autowired
    RedisHelper redisHelper;

    @Autowired
    @Delegate
    StandarOrderJob standardOrderJob;

    public Step chk() {
        return getStepBuilderFactory().get("chk").tasklet((it, ii) -> {
            log.info("这个是有票票的创建订单检查流程");

            return RepeatStatus.FINISHED;
        }).build();
    }


    public Step createCommonStep() {
        return getStepBuilderFactory().get("createCommon")
                .tasklet((contribution, chunkContext) -> {

                    log.info("入参数据：{}",JSONUtil.toJsonStr(getParameter().get()));

                    return RepeatStatus.FINISHED;
                })
                .build();
    }

    @Bean
    public Job YppOrder() {
        return getJobBuilderFactory()
                .get("YppOrder")
                .start(chk())
                .next(createCommonStep())
                .incrementer(new RunIdIncrementer())
                .build();
    }

}
