|
@@ -0,0 +1,100 @@
|
|
|
|
+package com.zswl.cloud.springBtach.server.core.job.dfy;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.github.microservice.auth.client.content.ResultContent;
|
|
|
|
+import com.github.microservice.auth.client.content.ResultState;
|
|
|
|
+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.Hotel.request.OrderDetailRequest;
|
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Hotel.response.AddOrderResponse;
|
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Hotel.response.OrderDetailResponse;
|
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.dfy.DomesticHotelApi;
|
|
|
|
+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 HotelPayJob {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StandarPayJob standarPayJob;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private JobBuilderFactory jobBuilderFactory;
|
|
|
|
+ @Resource
|
|
|
|
+ private StepBuilderFactory stepBuilderFactory;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PaymentService2 paymentService2;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ OrderService2 orderService2;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DomesticHotelApi domesticHotelApi;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public Step hotelPayStep() {
|
|
|
|
+ return stepBuilderFactory.get("hotelPayStep")
|
|
|
|
+ .tasklet((contribution, chunkContext) -> {
|
|
|
|
+ CreatePayment2Model createPayment2Model = standarPayJob.getParameter().get();
|
|
|
|
+ ResultContent<List<GoodsResultModel>> listResultContent = orderService2.goodsDetail(createPayment2Model.getOrderNo());
|
|
|
|
+ GoodsResultModel goodsResultModel = listResultContent.getContent().get(0);
|
|
|
|
+ String extend = goodsResultModel.getExtend();
|
|
|
|
+ AddOrderResponse.Datas bean = JSONUtil.toBean(extend, AddOrderResponse.Datas.class);
|
|
|
|
+
|
|
|
|
+ OrderDetailRequest orderDetailRequest = new OrderDetailRequest();
|
|
|
|
+ orderDetailRequest.setOrderId(bean.getOrderId());
|
|
|
|
+
|
|
|
|
+ OrderDetailResponse orderDetailResponse = domesticHotelApi.orderDetail(orderDetailRequest);
|
|
|
|
+ OrderDetailResponse.OrderInfo orderInfo = orderDetailResponse.getData().getOrderInfo();
|
|
|
|
+ // 请求不成功
|
|
|
|
+ if (!orderDetailResponse.getSuccess()) {
|
|
|
|
+ standarPayJob.getResultContent().set(ResultContent.build(ResultState.Fail, orderDetailResponse.getMsg()));
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!orderInfo.getOrderStatus().equals("待付款")) {
|
|
|
|
+ standarPayJob.getResultContent().set(ResultContent.build(ResultState.Fail, "渠道订单不可用:" + orderInfo.getOrderStatus()));
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!NumberUtil.equals(orderInfo.getTotalPrice(),goodsResultModel.getPayAmount())){
|
|
|
|
+ standarPayJob.getResultContent().set(ResultContent.build(ResultState.Fail, "支付价格和渠道价格不相等"));
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ standarPayJob.getResultContent().set(paymentService2.creatPayOrder(createPayment2Model));
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ })
|
|
|
|
+ .build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Bean
|
|
|
|
+ public Job hotelPay() {
|
|
|
|
+ return getJobBuilderFactory()
|
|
|
|
+ .get("hotelPayJob")
|
|
|
|
+ .start(hotelPayStep())
|
|
|
|
+ .incrementer(new RunIdIncrementer())
|
|
|
|
+ .build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|