| | |
| | | if(shop!=null&&shop.getShopStatus()!=1){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_CLOSED); |
| | | } |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | // Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | // 初始化订单对象 |
| | | AppSureOrderVo appSureOrderVo = new AppSureOrderVo(); |
| | | // 初始化订单商品列表 |
| | |
| | | appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | | appShopGoodsGetDto.setShopId(appSureOrderDto.getShopId()); |
| | | ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | //商户是否定制价格 |
| | | if (shopGoods != null) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | } else { |
| | | } |
| | | //是否绑定经销商 |
| | | if(shop.getBelongShopId()!=null &&shop.getShopType()==2){ |
| | | //经销商定制价格 |
| | | appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | | appShopGoodsGetDto.setShopId(belongShop.getShopId()); |
| | | shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | AppShopGoodsGetDto shopGoodsGetDto=new AppShopGoodsGetDto(); |
| | | shopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | | shopGoodsGetDto.setShopId(shop.getBelongShopId()); |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | shopGoods = remoteGoodsService.getShopGoods(shopGoodsGetDto).getData(); |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | goodsPrice=shopGoods.getSalesPrice(); |
| | | } |
| | | } |
| | | appSureOrderGoodsVo.setGoodsPrice(goodsPrice); |
| | |
| | | ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | if (shopGoods != null) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | } else { |
| | | } |
| | | //是否绑定经销商 |
| | | if(shop.getBelongShopId()!=null &&shop.getShopType()==2){ |
| | | //经销商定制价格 |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | appShopGoodsGetDto = new AppShopGoodsGetDto(); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | @Transactional // todo 放开分布式事务注解 |
| | | // @GlobalTransactional(rollbackFor = Exception.class) |
| | | public AppPlaceOrderVo placeOrder(AppPlaceOrderDto appPlaceOrderDto) { |
| | | // 获取用户ID |
| | | Long userId = appPlaceOrderDto.getUserId(); |
| | |
| | | //使用优惠券 |
| | | StringJoiner memberCouponSJ = new StringJoiner(","); |
| | | List<String> goodsNameList = new ArrayList<>(); |
| | | Shop shop = remoteShopService.getShop(appPlaceOrderDto.getShopId()).getData(); |
| | | if(shop!=null&&shop.getShopStatus()!=1){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_CLOSED); |
| | | } |
| | | // 遍历购买的商品列表 |
| | | for (AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList) { |
| | | appSureOrderGoodsVo = new AppSureOrderGoodsVo(); |
| | |
| | | if (shopGoods != null) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | serviceNum = shopGoods.getServiceNum(); |
| | | } else { |
| | | } |
| | | //是否绑定经销商 |
| | | if(shop.getBelongShopId()!=null &&shop.getShopType()==2){ |
| | | //经销商定制价格 |
| | | Shop shop = remoteShopService.getShop(appPlaceOrderDto.getShopId()).getData(); |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | appShopGoodsGetDto = new AppShopGoodsGetDto(); |
| | | appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public AppPlaceOrderVo placeActivityOrder(AppPlaceActivityDto appPlaceActivityDto) { |
| | | Long userId = appPlaceActivityDto.getUserId(); |
| | | Member member = remoteMemberService.getMember(userId).getData(); |
| | |
| | | // 返回AppPlaceOrderVo对象 |
| | | List<TLotteryEvent> data = lotteryEventClient.getLotteryEventList(2).getData(); |
| | | if (data.size() > 0) { |
| | | long count = data.stream().filter(s -> s.getPayMoney().compareTo(order.getPayMoney()) >= 0).count(); |
| | | appPlaceOrderVo.setLotteryDraw(count > 0); |
| | | List<TLotteryEvent> collect = data.stream().filter(s -> s.getPayMoney().compareTo(order.getPayMoney()) >= 0).collect(Collectors.toList()); |
| | | appPlaceOrderVo.setLotteryDraw(collect.size() > 0); |
| | | if (collect.size() > 0) { |
| | | appPlaceOrderVo.setLotteryEventId(collect.get(0).getId()); |
| | | } |
| | | } else { |
| | | appPlaceOrderVo.setLotteryDraw(false); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public MerVerifyOrderVo sureVerifyOrder(MerVerifyOrderDto merVerifyOrderDto) { |
| | | String orderId = merVerifyOrderDto.getOrderId(); |
| | | BigDecimal relReceiveMoney = merVerifyOrderDto.getRelReceiveMoney(); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public MerVerifyOrderVo sureVerifyOrderDouYin(MerVerifyOrderDto merVerifyOrderDto) { |
| | | String phone = merVerifyOrderDto.getPhone(); |
| | | String orderId = merVerifyOrderDto.getOrderId(); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public MerVerifyCouponVo sureVerifyCoupon(MerVerifyCouponDto merVerifyCouponDto) { |
| | | R<MerVerifyCouponGetVo> verifyCoupon = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()); |
| | | if(verifyCoupon.getCode() != 200){ |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public MerVerifyAwardVo sureVerifyPrize(MerVerifyPrizeDto merVerifyPrizeDto) { |
| | | MerVerifyAwardVo merVerifyAwardVo = new MerVerifyAwardVo(); |
| | | MemberGiftRecord memberGiftRecord = remoteMemberService.getVerifyPrize(merVerifyPrizeDto.getPrizeId()).getData(); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public void createNewOrder(MerNewOrderDto merNewOrderDto) { |
| | | Long userId = merNewOrderDto.getBuyUserId(); |
| | | Date nowTime = new Date(); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public void autoCancelOrder(String orderId) { |
| | | //更新订单信息 |
| | | Order order = this.getById(orderId); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public void payBack(PartnerTransactionsResult transaction, BigDecimal feeAmount) { |
| | | log.info("订单支付回调---"+transaction.toString()); |
| | | // 更新订单状态 outTradeNo |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | public void refundOrder(String orderId) { |
| | | // 更新订单信息 |
| | | Order order = this.getById(orderId); |
| | |
| | | } |
| | | } |
| | | |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | // @GlobalTransactional(rollbackFor = Exception.class) todo 放开分布式事务注解 |
| | | private void autoTimeCancelOrder(Order order) { |
| | | String orderId = order.getOrderId(); |
| | | order.setOrderStatus(0); |
| | |
| | | } |
| | | return new ArrayList<>(); |
| | | } |
| | | /** |
| | | * 后台取消订单 |
| | | * 订单状态变为已取消 不退款 |
| | | * @param dto |
| | | */ |
| | | @Override |
| | | public R cancelOrderBySys(CancelOrderDTO dto) { |
| | | Order order = this.getById(dto.getOrderId()); |
| | | // 订单状态-1.删除 0.已取消 1.待支付 2.待核销 3.已完成 |
| | | if(null == order || order.getDelFlag() == -1){ |
| | | return R.fail("订单不存在"); |
| | | } |
| | | |
| | | if (order.getOrderStatus() == 0) { |
| | | return R.fail(AppErrorConstant.CANCEL_CANCEL_ORDER); |
| | | } else if (order.getOrderStatus() == 1) { |
| | | //删除待支付超时取消延时任务 |
| | | redisService.deleteObject(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + order.getOrderId()); |
| | | remoteConfigService.deleteDelayTask(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode()+"-"+order.getOrderId()); |
| | | order.setOrderStatus(0); |
| | | order.setCancelTime(new Date()); |
| | | this.saveOrUpdate(order); |
| | | } else if (order.getOrderStatus() == 2) { |
| | | // 2.待核销 |
| | | order.setOrderStatus(0); |
| | | order.setCancelTime(new Date()); |
| | | this.saveOrUpdate(order); |
| | | } else { |
| | | return R.fail(AppErrorConstant.CANCEL_ERROR_ORDER); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R refundOrderBySys(CancelOrderDTO dto) { |
| | | Order order = this.getById(dto.getOrderId()); |
| | | // 订单状态-1.删除 0.已取消 1.待支付 2.待核销 3.已完成 |
| | | if(null == order || order.getDelFlag() == -1){ |
| | | return R.fail("订单不存在"); |
| | | } |
| | | if (order.getOrderStatus() == 0) { |
| | | return R.fail(AppErrorConstant.CANCEL_CANCEL_ORDER); |
| | | }else if (order.getOrderStatus() == 1) { |
| | | //删除待支付超时取消延时任务 |
| | | redisService.deleteObject(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + order.getOrderId()); |
| | | remoteConfigService.deleteDelayTask(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode()+"-"+ order.getOrderId()); |
| | | this.autoCancelOrder( order.getOrderId()); |
| | | } else if (order.getOrderStatus() == 2) { |
| | | // 2.待核销 -> 订单退款 |
| | | this.refundOrder( order.getOrderId()); |
| | | } else { |
| | | return R.fail("已核销订单不能退款"); |
| | | } |
| | | return R.ok(); |
| | | |
| | | } |
| | | } |