|
@@ -0,0 +1,87 @@
|
|
|
|
+package com.zswl.cloud.springBtach.server.core.job.dfy;
|
|
|
|
+
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.github.microservice.auth.client.content.ResultContent;
|
|
|
|
+import com.github.microservice.auth.client.content.ResultState;
|
|
|
|
+import com.github.microservice.core.util.JsonUtil;
|
|
|
|
+import com.zhongshu.payment.client.model.order.v2.GoodsResultModel;
|
|
|
|
+import com.zhongshu.payment.client.model.payment.zswl.CreatePayment2Model;
|
|
|
|
+import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
|
|
+import com.zhongshu.payment.client.service.v2.PaymentService2;
|
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.OrderDetailRequest;
|
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.response.CreateOrderNewResponse;
|
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.response.OrderDetailResponse;
|
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.dfy.TicketApi;
|
|
|
|
+import com.zswl.cloud.springBtach.server.core.job.standard.StandarPayJob;
|
|
|
|
+import lombok.Data;
|
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
|
+import org.springframework.batch.core.Job;
|
|
|
|
+import org.springframework.batch.core.Step;
|
|
|
|
+import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
|
|
|
|
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
|
|
|
|
+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;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+@Data
|
|
|
|
+@Configuration
|
|
|
|
+@Log4j2
|
|
|
|
+public class TicetPayJob {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StandarPayJob standarPayJob;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private JobBuilderFactory jobBuilderFactory;
|
|
|
|
+ @Resource
|
|
|
|
+ private StepBuilderFactory stepBuilderFactory;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PaymentService2 paymentService2;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ OrderService2 orderService2;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private TicketApi ticketApi;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public Step ticetPaymentStep() {
|
|
|
|
+ return stepBuilderFactory.get("ticetPaymentStep")
|
|
|
|
+ .tasklet((contribution, chunkContext) -> {
|
|
|
|
+ CreatePayment2Model createPayment2Model = standarPayJob.getParameter().get();
|
|
|
|
+ ResultContent<List<GoodsResultModel>> listResultContent = orderService2.goodsDetail(createPayment2Model.getOrderNo());
|
|
|
|
+ String extend = listResultContent.getContent().get(0).getExtend();
|
|
|
|
+ CreateOrderNewResponse.Datas bean = JSONUtil.toBean(extend, CreateOrderNewResponse.Datas.class);
|
|
|
|
+
|
|
|
|
+ OrderDetailRequest orderDetailRequest = new OrderDetailRequest();
|
|
|
|
+ orderDetailRequest.setOrderId(bean.getOrderId());
|
|
|
|
+ OrderDetailResponse orderDetailResponse = ticketApi.orderDetail(orderDetailRequest);
|
|
|
|
+ if (!orderDetailResponse.getData().getCanPay().equals(1)) {
|
|
|
|
+ standarPayJob.getResultContent().set(ResultContent.build(ResultState.Fail, "三方渠道订单不可用"));
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ standarPayJob.getResultContent().set(paymentService2.creatPayOrder(createPayment2Model));
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ })
|
|
|
|
+ .build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Bean
|
|
|
|
+ public Job ticetPay() {
|
|
|
|
+ return getJobBuilderFactory()
|
|
|
|
+ .get("ticetPayJob")
|
|
|
|
+ .start(ticetPaymentStep())
|
|
|
|
+ .incrementer(new RunIdIncrementer())
|
|
|
|
+ .build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|