|
@@ -0,0 +1,100 @@
|
|
|
+package com.zswl.cloud.springBtach.server.core.job.ypp;
|
|
|
+
|
|
|
+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.auth.security.helper.AuthHelper;
|
|
|
+import com.zhongshu.payment.client.model.order.v2.GoodsResultModel;
|
|
|
+import com.zhongshu.payment.client.model.order.v2.UpdateGoodsModel;
|
|
|
+import com.zhongshu.payment.client.model.payment.SubOrdersConfirmResponseModel;
|
|
|
+import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
|
+import com.zhongshu.payment.client.service.v2.PaymentService2;
|
|
|
+import com.zhongshu.payment.client.type.OrderType;
|
|
|
+import com.zswl.cloud.shop.client.service.ShopService;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.movie.response.CreateOrder2Response;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.KfcApi;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.YppApi;
|
|
|
+import com.zswl.cloud.springBtach.server.core.helper.RedisHelper;
|
|
|
+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
|
|
|
+@Configuration
|
|
|
+@Log4j2
|
|
|
+public class kfcDeliveryJob {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrderService2 orderService2;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ShopService shopService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AuthHelper authHelper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisHelper redisHelper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KfcApi kfcApi;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PaymentService2 paymentService2;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Delegate
|
|
|
+ StandarDeliveryJob standarDeliveryJob;
|
|
|
+
|
|
|
+
|
|
|
+ public Step yppDeliveryStep() {
|
|
|
+ return getStepBuilderFactory().get("yppDeliveryStep")
|
|
|
+ .tasklet((contribution, chunkContext) -> {
|
|
|
+
|
|
|
+ GoodsResultModel goodsResultModel = getParameter().get();
|
|
|
+ CreateOrder2Response bean = JSONUtil.toBean(goodsResultModel.getExtend(), CreateOrder2Response.class);
|
|
|
+ JSONObject entries = kfcApi.pay_order(bean.getData().getOrderId());
|
|
|
+
|
|
|
+ log.info("kfc响应", entries);
|
|
|
+
|
|
|
+ // 分账
|
|
|
+ ResultContent<SubOrdersConfirmResponseModel> subOrdersConfirmResponseModelResultContent = paymentService2.subOrdersConfirm(goodsResultModel.getId(), goodsResultModel.getShopId());
|
|
|
+ if (!subOrdersConfirmResponseModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
+ log.info("分账失败:{}", JSONUtil.toJsonStr(goodsResultModel));
|
|
|
+ getResultContent().set(ResultContent.build(ResultState.Fail));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ UpdateGoodsModel updateGoodsModel = new UpdateGoodsModel();
|
|
|
+ updateGoodsModel.setId(goodsResultModel.getId());
|
|
|
+ updateGoodsModel.setDelivery(true);
|
|
|
+ updateGoodsModel.setGoodsState(OrderType.WAIT_USE);
|
|
|
+ orderService2.updateGoods(updateGoodsModel);
|
|
|
+
|
|
|
+ getResultContent().set(ResultContent.build(ResultState.Success));
|
|
|
+
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ })
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Job yppDelivery() {
|
|
|
+ return getJobBuilderFactory()
|
|
|
+ .get("yppDelivery")
|
|
|
+ .start(yppDeliveryStep())
|
|
|
+ .incrementer(new RunIdIncrementer())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|