|
@@ -0,0 +1,75 @@
|
|
|
+package com.zswl.cloud.springBtach.server.core.job.video;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.github.microservice.auth.client.content.ResultContent;
|
|
|
+import com.zhongshu.payment.client.model.order.v2.GoodsResultModel;
|
|
|
+import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
|
+import com.zswl.cloud.shop.client.dto.yqd.OrderDto;
|
|
|
+import com.zswl.cloud.shop.client.service.GoodsService;
|
|
|
+import com.zswl.cloud.shop.client.service.YqdGoodsOperateService;
|
|
|
+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 VideoDeliveryJob {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Delegate
|
|
|
+ StandarDeliveryJob standarDeliveryJob;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ GoodsService goodsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrderService2 orderService2;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ YqdGoodsOperateService yqdGoodsOperateService;
|
|
|
+
|
|
|
+
|
|
|
+ public Step videoDeliveryStep() {
|
|
|
+ return getStepBuilderFactory().get("videoDeliveryStep")
|
|
|
+ .tasklet((contribution, chunkContext) -> {
|
|
|
+ GoodsResultModel goodsResultModel = getParameter().get();
|
|
|
+
|
|
|
+ JSONObject entries = JSONUtil.parseObj(goodsResultModel.getExtend());
|
|
|
+ String account = String.valueOf(entries.get("account"));
|
|
|
+ OrderDto orderDto = new OrderDto();
|
|
|
+ orderDto.setCommodityId(goodsResultModel.getGoodsId());
|
|
|
+ orderDto.setPhone(account);
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent resultContent = yqdGoodsOperateService.create(orderDto);
|
|
|
+ log.info("视频会员响应结果:{}", resultContent.getContent());
|
|
|
+ if (!resultContent.getState().equals(com.zswl.cloud.shop.client.ret.ResultState.Success)) {
|
|
|
+ getResultContent().set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail));
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
+ getResultContent().set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Success));
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+
|
|
|
+ })
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Job videoDelivery() {
|
|
|
+ return getJobBuilderFactory()
|
|
|
+ .get("videoDelivery")
|
|
|
+ .start(videoDeliveryStep())
|
|
|
+ .incrementer(new RunIdIncrementer())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|