|
@@ -1,8 +1,11 @@
|
|
|
package com.zswl.cloud.springBtach.server.core.job.standard;
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
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.CreateOrder2Model;
|
|
|
+import com.zhongshu.payment.client.model.order.v2.GoodsResultModel;
|
|
|
import com.zhongshu.payment.client.model.order.v2.VerificationModel;
|
|
|
import com.zhongshu.payment.client.model.payment.SubOrdersConfirmResponseModel;
|
|
|
import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
@@ -30,6 +33,8 @@ public class StandarVerificationJob {
|
|
|
|
|
|
ThreadLocal<VerificationModel> parameter = new ThreadLocal<>();
|
|
|
|
|
|
+ ThreadLocal<Boolean> stop = new ThreadLocal<>();
|
|
|
+
|
|
|
@Autowired
|
|
|
PaymentService2 paymentService2;
|
|
|
@Resource
|
|
@@ -41,10 +46,55 @@ public class StandarVerificationJob {
|
|
|
@Autowired
|
|
|
OrderService2 orderService2;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ AuthHelper authHelper;
|
|
|
+
|
|
|
+
|
|
|
+ public Step verificationCheck() {
|
|
|
+ return stepBuilderFactory.get("verificationCheck")
|
|
|
+ .tasklet((contribution, chunkContext) -> {
|
|
|
+ VerificationModel verificationModel = getParameter().get();
|
|
|
+ String enterPriseId = authHelper.getEnterPriseId();
|
|
|
+
|
|
|
+ ResultContent<GoodsResultModel> result = orderService2.qrGoods(verificationModel.getId());
|
|
|
+ if (!result.getState().equals(ResultState.Success)) {
|
|
|
+ stop.set(true);
|
|
|
+ getResultContent().set(result);
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
+ JSONObject goodsInfo = result.getContent().getGoodsInfo();
|
|
|
+ Integer validEnable = (Integer) goodsInfo.get("validEnable");
|
|
|
+ String validRang = String.valueOf(goodsInfo.get("validRang"));
|
|
|
+ switch (validEnable) {
|
|
|
+ case 1:
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (!validRang.equals(enterPriseId)) {
|
|
|
+ getResultContent().set(ResultContent.build(ResultState.Fail, "请到指定店铺核销"));
|
|
|
+ stop.set(true);
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if (!result.getContent().getShopId().equals(enterPriseId)) {
|
|
|
+ getResultContent().set(ResultContent.build(ResultState.Fail, "请到指定店铺核销"));
|
|
|
+ stop.set(true);
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ })
|
|
|
+ .build();
|
|
|
+ }
|
|
|
|
|
|
public Step standardVerificationStep() {
|
|
|
return stepBuilderFactory.get("standardVerificationStep")
|
|
|
.tasklet((contribution, chunkContext) -> {
|
|
|
+
|
|
|
+ if (stop.get()) {
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
VerificationModel verificationModel = getParameter().get();
|
|
|
|
|
|
ResultContent<SubOrdersConfirmResponseModel> resultContent = paymentService2.subOrdersConfirm(verificationModel.getId(), verificationModel.getShopId());
|
|
@@ -62,7 +112,8 @@ public class StandarVerificationJob {
|
|
|
public Job standardVerificationJob() {
|
|
|
return getJobBuilderFactory()
|
|
|
.get("standardVerificationJob")
|
|
|
- .start(standardVerificationStep())
|
|
|
+ .start(verificationCheck())
|
|
|
+ .next(standardVerificationStep())
|
|
|
.incrementer(new RunIdIncrementer())
|
|
|
.build();
|
|
|
}
|