|
@@ -65,103 +65,112 @@ public class StandarOrderJob {
|
|
|
|
|
|
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();
|
|
|
+ for (CreateOrder2Model.Goods goods : createOrder2Model.getGoodsList()) {
|
|
|
|
|
|
- try {
|
|
|
|
|
|
-
|
|
|
- // 暂用库存
|
|
|
- com.zswl.cloud.shop.client.ret.ResultContent resultContent1 = goodsService.operateStock(operateStockDto);
|
|
|
-
|
|
|
- log.info("锁定商品结果:{}",JSONUtil.toJsonStr(resultContent1));
|
|
|
-
|
|
|
- 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);
|
|
|
- log.info("计算价格:{}",JSONUtil.toJsonStr(calculate));
|
|
|
- CalculateVo calculateVo = calculate.getContent();
|
|
|
- // 设置订单价格 todo 价格处理
|
|
|
- createOrder2Model.setTotalAmount(calculateVo.getPrice());
|
|
|
- createOrder2Model.setPayAmount(calculateVo.getPrice());
|
|
|
- createOrder2Model.setDiscountAmount(calculateVo.getOffset());
|
|
|
-
|
|
|
- goods.setPayAmount(calculateVo.getPrice());
|
|
|
-
|
|
|
- // 店铺详情
|
|
|
- com.zswl.cloud.shop.client.ret.ResultContent<ShopDetailVo> detail1 = shopService.detail(createOrder2Model.getShopId());
|
|
|
- log.info("店铺详情:{}",JSONUtil.toJsonStr(detail1));
|
|
|
- ShopDetailVo shopDetailVo = detail1.getContent();
|
|
|
- createOrder2Model.setShopInfo(JSONUtil.parseObj(shopDetailVo));
|
|
|
- if (ObjectUtil.isEmpty(shopDetailVo.getAuthAccount())){
|
|
|
- resultContent.set( ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail,"分账账户未设置"));
|
|
|
- stop.set(true);
|
|
|
+ OperateStockDto operateStockDto = new OperateStockDto();
|
|
|
+ operateStockDto.setUserId(createOrder2Model.getUserId());
|
|
|
+ operateStockDto.setOperate(1);// 暂用库存
|
|
|
+ operateStockDto.setShopId(createOrder2Model.getShopId());
|
|
|
+ operateStockDto.setGoodsId(goods.getGoodsId());
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 暂用库存
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent resultContent1 = goodsService.operateStock(operateStockDto);
|
|
|
+
|
|
|
+ log.info("锁定商品结果:{}", JSONUtil.toJsonStr(resultContent1));
|
|
|
+ if (resultContent1.getState().equals(ResultState.Success)) {
|
|
|
+
|
|
|
+ // 计算价格
|
|
|
+ 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);
|
|
|
+ log.info("计算价格:{}", JSONUtil.toJsonStr(calculate));
|
|
|
+ CalculateVo calculateVo = calculate.getContent();
|
|
|
+ // 设置订单价格
|
|
|
+ createOrder2Model.setTotalAmount(calculateVo.getPrice());
|
|
|
+ createOrder2Model.setPayAmount(calculateVo.getPrice());
|
|
|
+ createOrder2Model.setDiscountAmount(calculateVo.getOffset());
|
|
|
+
|
|
|
+ goods.setPayAmount(calculateVo.getPrice());
|
|
|
+
|
|
|
+ // 店铺详情
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<ShopDetailVo> detail1 = shopService.detail(createOrder2Model.getShopId());
|
|
|
+ log.info("店铺详情:{}", JSONUtil.toJsonStr(detail1));
|
|
|
+ ShopDetailVo shopDetailVo = detail1.getContent();
|
|
|
+ createOrder2Model.setShopInfo(JSONUtil.parseObj(shopDetailVo));
|
|
|
+ if (ObjectUtil.isEmpty(shopDetailVo.getAuthAccount())) {
|
|
|
+ resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail, "分账账户未设置"));
|
|
|
+ stop.set(true);
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 设置分账账户
|
|
|
+ createOrder2Model.setAccesserUserId(shopDetailVo.getAuthAccount());
|
|
|
+
|
|
|
+ // 商品详情
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<GoodsInfoVo> detail = goodsService.detail(goods.getGoodsId(), 1, createOrder2Model.getUserId());
|
|
|
+ log.info("商品详情:{}", JSONUtil.toJsonStr(detail));
|
|
|
+ GoodsInfoVo goodsInfoVo = detail.getContent();
|
|
|
+ SharePlatformVo sharePlatformVo = goodsInfoVo.getSharePlatformVo();
|
|
|
+ if (ObjectUtil.isEmpty(sharePlatformVo)) {
|
|
|
+ stop.set(true);
|
|
|
+ getResultContent().set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail, "分账规则未配置"));
|
|
|
+ return RepeatStatus.FINISHED;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置有效期
|
|
|
+ createOrder2Model.setValidDay(goodsInfoVo.getValidDay());
|
|
|
+
|
|
|
+
|
|
|
+ // 设置分账规则
|
|
|
+ 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));
|
|
|
return RepeatStatus.FINISHED;
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
- createOrder2Model.setAccesserUserId(shopDetailVo.getAuthAccount());
|
|
|
- // 商品详情
|
|
|
- com.zswl.cloud.shop.client.ret.ResultContent<GoodsInfoVo> detail = goodsService.detail(goodsId, 1, createOrder2Model.getUserId());
|
|
|
- log.info("商品详情:{}",JSONUtil.toJsonStr(detail));
|
|
|
- GoodsInfoVo goodsInfoVo = detail.getContent();
|
|
|
- SharePlatformVo sharePlatformVo = goodsInfoVo.getSharePlatformVo();
|
|
|
- if (ObjectUtil.isEmpty(sharePlatformVo)){
|
|
|
- stop.set(true);
|
|
|
- getResultContent().set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail,"分账规则未配置"));
|
|
|
- return RepeatStatus.FINISHED;
|
|
|
}
|
|
|
|
|
|
- // 设置有效期
|
|
|
- createOrder2Model.setValidDay(goodsInfoVo.getValidDay());
|
|
|
-
|
|
|
-
|
|
|
- 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);
|
|
|
+ stop.set(true);
|
|
|
+ resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail, resultContent1.getMsg()));
|
|
|
return RepeatStatus.FINISHED;
|
|
|
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ stop.set(true);
|
|
|
+ e.printStackTrace();
|
|
|
+ resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail, e.getMessage()));
|
|
|
+ operateStockDto.setOperate(2);
|
|
|
+ goodsService.operateStock(operateStockDto);
|
|
|
}
|
|
|
|
|
|
- stop.set(true);
|
|
|
- resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail,resultContent1.getMsg()));
|
|
|
- return RepeatStatus.FINISHED;
|
|
|
- } catch (Exception e) {
|
|
|
- stop.set(true);
|
|
|
- e.printStackTrace();
|
|
|
- resultContent.set(ResultContent.build(com.github.microservice.auth.client.content.ResultState.Fail, e.getMessage()));
|
|
|
- operateStockDto.setOperate(2);
|
|
|
- goodsService.operateStock(operateStockDto);
|
|
|
}
|
|
|
|
|
|
return RepeatStatus.FINISHED;
|