|
@@ -4,19 +4,36 @@ import cn.hutool.json.JSONUtil;
|
|
import com.github.microservice.auth.client.content.ResultContent;
|
|
import com.github.microservice.auth.client.content.ResultContent;
|
|
import com.zhongshu.payment.client.model.order.v2.CreateOrder2Model;
|
|
import com.zhongshu.payment.client.model.order.v2.CreateOrder2Model;
|
|
import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
|
|
+import com.zhongshu.payment.client.type.JobFlowMap;
|
|
|
|
+import com.zhongshu.payment.client.type.TransferOwner;
|
|
|
|
+import com.zhongshu.payment.client.type.TransferType;
|
|
|
|
+import com.zswl.cloud.shop.client.dto.life.CalculateCouponDto;
|
|
|
|
+import com.zswl.cloud.shop.client.dto.life.OperateStockDto;
|
|
|
|
+import com.zswl.cloud.shop.client.ret.ResultState;
|
|
|
|
+import com.zswl.cloud.shop.client.service.GoodsService;
|
|
|
|
+import com.zswl.cloud.shop.client.service.ShopService;
|
|
|
|
+import com.zswl.cloud.shop.client.vo.life.CalculateVo;
|
|
|
|
+import com.zswl.cloud.shop.client.vo.life.GoodsInfoVo;
|
|
|
|
+import com.zswl.cloud.shop.client.vo.life.SharePlatformVo;
|
|
|
|
+import com.zswl.cloud.shop.client.vo.life.ShopDetailVo;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import org.springframework.batch.core.Job;
|
|
import org.springframework.batch.core.Job;
|
|
|
|
+import org.springframework.batch.core.JobExecution;
|
|
import org.springframework.batch.core.Step;
|
|
import org.springframework.batch.core.Step;
|
|
|
|
+import org.springframework.batch.core.StepExecution;
|
|
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
|
|
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
|
|
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
|
|
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
|
|
import org.springframework.batch.core.launch.support.RunIdIncrementer;
|
|
import org.springframework.batch.core.launch.support.RunIdIncrementer;
|
|
|
|
+import org.springframework.batch.core.repository.JobRepository;
|
|
import org.springframework.batch.repeat.RepeatStatus;
|
|
import org.springframework.batch.repeat.RepeatStatus;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
@Data
|
|
@Data
|
|
@Configuration
|
|
@Configuration
|
|
@@ -26,23 +43,110 @@ public class StandardOrderJob {
|
|
ThreadLocal<ResultContent> resultContent = new ThreadLocal<>();
|
|
ThreadLocal<ResultContent> resultContent = new ThreadLocal<>();
|
|
|
|
|
|
ThreadLocal<CreateOrder2Model> parameter = new ThreadLocal<>();
|
|
ThreadLocal<CreateOrder2Model> parameter = new ThreadLocal<>();
|
|
|
|
+ ThreadLocal<Boolean> stop = new ThreadLocal<>();
|
|
@Resource
|
|
@Resource
|
|
private StepBuilderFactory stepBuilderFactory;
|
|
private StepBuilderFactory stepBuilderFactory;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private JobBuilderFactory jobBuilderFactory;
|
|
private JobBuilderFactory jobBuilderFactory;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private GoodsService goodsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ShopService shopService;
|
|
|
|
+
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
OrderService2 orderService2;
|
|
OrderService2 orderService2;
|
|
|
|
|
|
public Step checkFrom() {
|
|
public Step checkFrom() {
|
|
return stepBuilderFactory.get("checkFrom")
|
|
return stepBuilderFactory.get("checkFrom")
|
|
.tasklet((contribution, chunkContext) -> {
|
|
.tasklet((contribution, chunkContext) -> {
|
|
|
|
+ stop.set(false);
|
|
|
|
+
|
|
|
|
+ CreateOrder2Model createOrder2Model = getParameter().get();
|
|
|
|
+
|
|
|
|
+ OperateStockDto operateStockDto = new OperateStockDto();
|
|
|
|
+ operateStockDto.setUserId(createOrder2Model.getUserId());
|
|
|
|
+ operateStockDto.setOperate(1);// 暂用库存
|
|
|
|
+ operateStockDto.setShopId(createOrder2Model.getShopId());
|
|
|
|
+ operateStockDto.setGoodsId(createOrder2Model.getGoodsList().get(0).getGoodsId());
|
|
|
|
+ String goodsId = createOrder2Model.getGoodsList().get(0).getGoodsId();
|
|
|
|
+
|
|
|
|
+ // 暂用库存
|
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent resultContent1 = goodsService.operateStock(operateStockDto);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (resultContent1.getState().equals(ResultState.Success)) {
|
|
|
|
+ CreateOrder2Model.Goods goods = createOrder2Model.getGoodsList().get(0);
|
|
|
|
+
|
|
|
|
+ // 计算价格
|
|
|
|
+ CalculateCouponDto calculateCouponDto = new CalculateCouponDto();
|
|
|
|
+ calculateCouponDto.setUserId(createOrder2Model.getUserId());
|
|
|
|
+ calculateCouponDto.setShopId(createOrder2Model.getShopId());
|
|
|
|
+ calculateCouponDto.setGoodsId(goods.getGoodsId());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<CalculateVo> calculate = goodsService.calculate(calculateCouponDto);
|
|
|
|
+ if (!calculate.getState().equals(ResultState.Success)){
|
|
|
|
+ resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail,calculate.getMsg()));
|
|
|
|
+ stop.set(true);
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ }
|
|
|
|
+ CalculateVo calculateVo = calculate.getContent();
|
|
|
|
+ // 设置订单价格
|
|
|
|
+ createOrder2Model.setTotalAmount(calculateVo.getPrice());
|
|
|
|
+ createOrder2Model.setPayAmount(calculateVo.getPrice());
|
|
|
|
+ createOrder2Model.setDiscountAmount(BigDecimal.ZERO);
|
|
|
|
|
|
- log.info("这里是最基本的检查");
|
|
|
|
- log.info("入参数据:{}", JSONUtil.toJsonStr(getParameter().get()));
|
|
|
|
|
|
+ goods.setPayAmount(calculateVo.getPrice());
|
|
|
|
+
|
|
|
|
+ // 店铺详情
|
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<ShopDetailVo> detail1 = shopService.detail(createOrder2Model.getShopId());
|
|
|
|
+ ShopDetailVo shopDetailVo = detail1.getContent();
|
|
|
|
+ createOrder2Model.setShopInfo(JSONUtil.parseObj(shopDetailVo));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 商品详情
|
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<GoodsInfoVo> detail = goodsService.detail(goodsId, 1, createOrder2Model.getUserId());
|
|
|
|
+ GoodsInfoVo goodsInfoVo = detail.getContent();
|
|
|
|
+ SharePlatformVo sharePlatformVo = goodsInfoVo.getSharePlatformVo();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ goods.setTransferType(sharePlatformVo.getShareType() == 1 ? TransferType.RATIO : TransferType.FIXED);
|
|
|
|
+ CreateOrder2Model.Owner platform = new CreateOrder2Model.Owner();
|
|
|
|
+ platform.setOwner(TransferOwner.PLATFORM);
|
|
|
|
+ platform.setValue(sharePlatformVo.getPlatformRate());
|
|
|
|
+
|
|
|
|
+ CreateOrder2Model.Owner byShop = new CreateOrder2Model.Owner();
|
|
|
|
+ byShop.setOwner(TransferOwner.BUY_SHOP);
|
|
|
|
+ byShop.setValue(sharePlatformVo.getBuyShopRate());
|
|
|
|
+
|
|
|
|
+ CreateOrder2Model.Owner useShop = new CreateOrder2Model.Owner();
|
|
|
|
+ useShop.setOwner(TransferOwner.USE_SHOP);
|
|
|
|
+ useShop.setValue(sharePlatformVo.getCheckShopRate());
|
|
|
|
+
|
|
|
|
+ ArrayList<CreateOrder2Model.Owner> rule = new ArrayList<>();
|
|
|
|
+ rule.add(platform);
|
|
|
|
+ rule.add(byShop);
|
|
|
|
+ rule.add(useShop);
|
|
|
|
+
|
|
|
|
+ goods.setTransferRrule(rule);
|
|
|
|
+ goods.setGoodsInfo(JSONUtil.parseObj(goodsInfoVo));
|
|
|
|
+ goods.setJobFlowMap(JobFlowMap.P81);
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail,resultContent1.getMsg()));
|
|
|
|
+ stop.set(true);
|
|
|
|
|
|
return RepeatStatus.FINISHED;
|
|
return RepeatStatus.FINISHED;
|
|
|
|
+
|
|
})
|
|
})
|
|
.build();
|
|
.build();
|
|
}
|
|
}
|
|
@@ -50,6 +154,9 @@ public class StandardOrderJob {
|
|
public Step platformOrder() {
|
|
public Step platformOrder() {
|
|
return stepBuilderFactory.get("standardPlatformOrder")
|
|
return stepBuilderFactory.get("standardPlatformOrder")
|
|
.tasklet((contribution, chunkContext) -> {
|
|
.tasklet((contribution, chunkContext) -> {
|
|
|
|
+ if (stop.get()){
|
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
|
+ }
|
|
getResultContent().set(orderService2.creat(getParameter().get()));
|
|
getResultContent().set(orderService2.creat(getParameter().get()));
|
|
return RepeatStatus.FINISHED;
|
|
return RepeatStatus.FINISHED;
|
|
})
|
|
})
|