| | |
| | | |
| | | @Resource |
| | | private BalanceChangeRecordClient balanceChangeRecordClient; |
| | | |
| | | |
| | | @Resource |
| | | private UserPointClient userPointClient; |
| | |
| | | if (200 == r.getCode()) { |
| | | this.updateById(order); |
| | | } |
| | | |
| | | R r1 = balanceChangeRecordClient.deleteBalanceChangeRecordCopy(orderId, Arrays.asList(4)); |
| | | if (200 != r1.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 |
| | | throw new RuntimeException("订单取消失败"); |
| | | } |
| | | R r2 = userPointClient.deleteUserPointCopy(orderId, Arrays.asList(2,8,9,10,14)); |
| | | if (200 != r2.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 |
| | | throw new RuntimeException("订单取消失败"); |
| | | } |
| | | R<Boolean> r3 = shopBalanceStatementClient.deleteShopBalanceStatementCopy(orderId, Arrays.asList(1,2,3)); |
| | | if (200 != r3.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 |
| | | throw new RuntimeException("订单取消失败"); |
| | | } |
| | | shopPointClient.deleteShopPointCopy(orderId, Arrays.asList(1,2,3)); |
| | | appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(orderId); |
| | | shopGiveawayTemporaryClient.delShopGiveawayTemporary(orderId); |
| | | return r; |
| | | } |
| | | |
| | |
| | | OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId())); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | if (null != orderBalancePayment) { |
| | | //回加红包金额 |
| | | appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | // appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | //回加账户余额 |
| | | appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //扣减门店消费金额 |
| | | appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //查询最后一次的消费订单 |
| | | Order order1 = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, order.getAppUserId()).eq(Order::getPayStatus, 2) |
| | |
| | | appUser.setLastShopTime(null); |
| | | } |
| | | |
| | | //构建账户余额流水明细 |
| | | //构建账户余额流水明细(账户支付订单的流水,不属于冻结数据) |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setAppUserId(order.getAppUserId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(6); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(paymentAmount); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | |
| | | |
| | | //退回获得的消费积分 |
| | | //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置 |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | |
| | | UserPoint userPoint1 = new UserPoint(); |
| | | userPoint1.setType(1); |
| | | userPoint1.setAppUserId(appUser.getId()); |
| | |
| | | } |
| | | appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint); |
| | | |
| | | //构建积分流水明细 |
| | | //构建积分流水明细(消费金额,不属于冻结数据) |
| | | if (shopPoint > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(shopPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | //回退优惠券状态 |
| | | if (null != order.getUserCouponId()) { |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | |
| | | // appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | appUser.setBalance(balance.add(expressAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //构建账户余额流水明细 |
| | | //构建账户余额流水明细(消费支付的余额流水) |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setAppUserId(order.getAppUserId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(6); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(expressAmount); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | } |
| | | } |
| | |
| | | } |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint); |
| | | |
| | | //构建积分流水明细 |
| | | //构建积分流水明细(支付的积分,不属于冻结数据) |
| | | if (order.getPoint() > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(order.getPoint()); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUserClient.editAppUserById(appUser); |
| | |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | |
| | | shopPointClient.deleteShopPointCopy(order.getId(), Arrays.asList(1,2,3)); |
| | | shopBalanceStatementClient.deleteShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)); |
| | | //生成反向冻结流水数据 |
| | | List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData(); |
| | | for (UserPointCopy userPointCopy : data2) { |
| | | userPointCopy.setId(null); |
| | | userPointCopy.setCreateTime(LocalDateTime.now()); |
| | | userPointCopy.setChangeDirection(-1); |
| | | userPointClient.saveUserPointCopy(userPointCopy); |
| | | } |
| | | List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData(); |
| | | for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) { |
| | | balanceChangeRecordCopy.setId(null); |
| | | balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordCopy.setChangeDirection(-1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); |
| | | } |
| | | List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopPointCopy datum : data) { |
| | | datum.setId(null); |
| | | datum.setCreateTime(LocalDateTime.now()); |
| | | datum.setChangeDirection(-1); |
| | | shopPointClient.saveShopPointCopy(datum); |
| | | } |
| | | List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) { |
| | | shopBalanceStatementCopy.setId(null); |
| | | shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatementCopy.setChangeDirection(-1); |
| | | shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); |
| | | } |
| | | //删除用户和门店添加的汇总数据(冻结数据) |
| | | appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); |
| | | shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | if (shopPoint > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(shopPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | |
| | | //回退优惠券状态 |
| | | if (null != order.getUserCouponId()) { |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | userCoupon.setUseTime(null); |
| | | userCouponClient.editReturnUse(userCoupon); |
| | | } |
| | | |
| | | //生成反向冻结流水数据 |
| | | List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData(); |
| | | for (UserPointCopy userPointCopy : data2) { |
| | | userPointCopy.setId(null); |
| | | userPointCopy.setCreateTime(LocalDateTime.now()); |
| | | userPointCopy.setChangeDirection(-1); |
| | | userPointClient.saveUserPointCopy(userPointCopy); |
| | | } |
| | | List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData(); |
| | | for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) { |
| | | balanceChangeRecordCopy.setId(null); |
| | | balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordCopy.setChangeDirection(-1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); |
| | | } |
| | | List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopPointCopy datum : data) { |
| | | datum.setId(null); |
| | | datum.setCreateTime(LocalDateTime.now()); |
| | | datum.setChangeDirection(-1); |
| | | shopPointClient.saveShopPointCopy(datum); |
| | | } |
| | | List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) { |
| | | shopBalanceStatementCopy.setId(null); |
| | | shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatementCopy.setChangeDirection(-1); |
| | | shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); |
| | | } |
| | | //删除用户和门店添加的汇总数据(冻结数据) |
| | | appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); |
| | | shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | if (order.getPoint() > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(order.getPoint()); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | return R.ok(); |
| | |
| | | Long days = jsonObject.getLong("days"); |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | this.updateById(order); |
| | | commissionService.calculationCommissionShop(order.getId()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | public List<OrderExport> getOrderExportList(OrderPageList orderPageList) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询给定用户在给定门店核销的订单 |
| | | * @param shopId |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Order> getOrderByAppUserIdsAndWriteOffShop(Integer shopId, Set<Long> appUserId) { |
| | | return this.baseMapper.getOrderByAppUserIdsAndWriteOffShop(shopId, appUserId); |
| | | } |
| | | } |