| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void calculationCommission() { |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getIsCommission, 0).isNotNull(Order::getAfterSaleTime) |
| | | .eq(Order::getDelFlag, 0).last(" and after_sale_time <= now()")); |
| | | .eq(Order::getDelFlag, 0).ne(Order::getPayMethod, 3).last(" and after_sale_time <= now()")); |
| | | List<Long> collect = list.stream().map(Order::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return; |
| | | } |
| | | |
| | | for (Order order : list) { |
| | | if(order.getPayMethod() == 3){ |
| | | continue; |
| | | } |
| | | List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() |
| | | .eq(OrderGood::getOrderId, order.getId())); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | if(null == appUser){ |
| | | return; |
| | | } |
| | | //直推上级分佣金额 |
| | | BigDecimal ztsj_price = BigDecimal.ZERO; |
| | | //直帮上级分佣金额 |
| | |
| | | if(!inviteUser.getBalance().equals(balance)){ |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(inviteUser.getId()); |
| | | balanceChangeRecord.setVipId(inviteUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(4); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | if(!superiorLeader.getBalance().equals(balance)){ |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(superiorLeader.getId()); |
| | | balanceChangeRecord.setVipId(superiorLeader.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(4); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | //添加积分明细 |
| | | if(!shopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(9); |
| | | userPoint.setType(8); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(hxmd_point); |
| | | userPoint.setBalance(shopAppUser.getLavePoint()); |
| | |
| | | Technician technician = technicianClient.shopdetail(order.getTechnicianId()).getData(); |
| | | if(null != technician){ |
| | | AppUser technicianAppUser = appUserClient.getAppUserById(technician.getAppUserId()); |
| | | Integer lavePoint = technicianAppUser.getLavePoint(); |
| | | if(js_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getPersonPointOpen()){ |
| | | earnPoint1 = new BigDecimal(js_point).multiply(pointSetting.getPersonPoint().divide(new BigDecimal(100))).intValue(); |
| | | if(null != technicianAppUser){ |
| | | Integer lavePoint = technicianAppUser.getLavePoint(); |
| | | if(js_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getPersonPointOpen()){ |
| | | earnPoint1 = new BigDecimal(js_point).multiply(pointSetting.getPersonPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | technicianAppUser.setLavePoint(technicianAppUser.getLavePoint() + js_point); |
| | | technicianAppUser.setAvailablePoint(technicianAppUser.getAvailablePoint() + earnPoint1); |
| | | technicianAppUser.setTotalAvailablePoint(technicianAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getPersonPointGift()){ |
| | | technicianAppUser.setTransferablePoint(technicianAppUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | technicianAppUser.setTotalPoint(technicianAppUser.getTotalPoint() + js_point); |
| | | technicianAppUser.setTotalPerformancePoint(technicianAppUser.getTotalPerformancePoint() + js_point); |
| | | } |
| | | technicianAppUser.setLavePoint(technicianAppUser.getLavePoint() + js_point); |
| | | technicianAppUser.setAvailablePoint(technicianAppUser.getAvailablePoint() + earnPoint1); |
| | | technicianAppUser.setTotalAvailablePoint(technicianAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getPersonPointGift()){ |
| | | technicianAppUser.setTransferablePoint(technicianAppUser.getTransferablePoint() + earnPoint1); |
| | | appUserClient.editAppUserById(technicianAppUser); |
| | | //添加积分明细 |
| | | if(!technicianAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(10); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(js_point); |
| | | userPoint.setBalance(technicianAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(technicianAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(technicianAppUser.getId()); |
| | | } |
| | | technicianAppUser.setTotalPoint(technicianAppUser.getTotalPoint() + js_point); |
| | | technicianAppUser.setTotalPerformancePoint(technicianAppUser.getTotalPerformancePoint() + js_point); |
| | | } |
| | | appUserClient.editAppUserById(technicianAppUser); |
| | | //添加积分明细 |
| | | if(!technicianAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(10); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(js_point); |
| | | userPoint.setBalance(technicianAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(technicianAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(technicianAppUser.getId()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //上级门店分佣 |
| | | Integer pid = shop1.getPid(); |
| | | Shop shop2 = shopClient.getShopById(pid).getData(); |
| | | if(null != shop2){ |
| | | AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); |
| | | if(null != sjShopAppUser){ |
| | | BigDecimal shopBalance = shop2.getBalance(); |
| | | Integer lavePoint = sjShopAppUser.getLavePoint(); |
| | | Integer shopLavePoint = shop2.getLavePoint(); |
| | | if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | //门店返佣 |
| | | shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | if(bdmdsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | if(null != shop1){ |
| | | Integer pid = shop1.getPid(); |
| | | Shop shop2 = shopClient.getShopById(pid).getData(); |
| | | if(null != shop2){ |
| | | AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); |
| | | if(null != sjShopAppUser){ |
| | | BigDecimal shopBalance = shop2.getBalance(); |
| | | Integer lavePoint = sjShopAppUser.getLavePoint(); |
| | | Integer shopLavePoint = shop2.getLavePoint(); |
| | | if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | //门店返佣 |
| | | shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); |
| | | sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); |
| | | sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ |
| | | sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); |
| | | if(bdmdsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); |
| | | sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); |
| | | sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ |
| | | sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point); |
| | | sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point); |
| | | //门店返佣 |
| | | shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point); |
| | | shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point); |
| | | shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point); |
| | | } |
| | | sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point); |
| | | sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point); |
| | | //门店返佣 |
| | | shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point); |
| | | shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point); |
| | | shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point); |
| | | } |
| | | appUserClient.editAppUserById(sjShopAppUser); |
| | | shopClient.updateShop(shop2); |
| | | //添加明细记录 |
| | | if(!shop2.getBalance().equals(shopBalance)){ |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setShopId(shop2.getId()); |
| | | shopBalanceStatement.setType(2); |
| | | shopBalanceStatement.setHistoricalBalance(shopBalance); |
| | | shopBalanceStatement.setVariableAmount(bdmdsj_price); |
| | | shopBalanceStatement.setBalance(shop2.getBalance()); |
| | | shopBalanceStatement.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatement.setCreateUserId(order.getAppUserId()); |
| | | shopBalanceStatement.setObjectId(order.getId()); |
| | | shopBalanceStatement.setExtension(order.getOrderNumber()); |
| | | shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); |
| | | } |
| | | //添加积分明细 |
| | | if(!sjShopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(14); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(bdmdsj_point); |
| | | userPoint.setBalance(sjShopAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(sjShopAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(sjShopAppUser.getId()); |
| | | } |
| | | |
| | | if(!shop2.getLavePoint().equals(shopLavePoint)){ |
| | | ShopPoint shopPoint = new ShopPoint(); |
| | | shopPoint.setShopId(shop2.getId()); |
| | | shopPoint.setType(3); |
| | | shopPoint.setHistoricalPoint(shopLavePoint); |
| | | shopPoint.setVariablePoint(bdmdsj_point); |
| | | shopPoint.setBalance(shop2.getLavePoint()); |
| | | shopPoint.setCreateTime(LocalDateTime.now()); |
| | | shopPoint.setCreateUserId(order.getAppUserId()); |
| | | shopPoint.setObjectId(order.getId()); |
| | | shopPoint.setOrderNum(order.getOrderNumber()); |
| | | shopPointClient.saveShopPoint(shopPoint); |
| | | appUserClient.editAppUserById(sjShopAppUser); |
| | | shopClient.updateShop(shop2); |
| | | //添加明细记录 |
| | | if(!shop2.getBalance().equals(shopBalance)){ |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setShopId(shop2.getId()); |
| | | shopBalanceStatement.setType(2); |
| | | shopBalanceStatement.setHistoricalBalance(shopBalance); |
| | | shopBalanceStatement.setVariableAmount(bdmdsj_price); |
| | | shopBalanceStatement.setBalance(shop2.getBalance()); |
| | | shopBalanceStatement.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatement.setCreateUserId(order.getAppUserId()); |
| | | shopBalanceStatement.setObjectId(order.getId()); |
| | | shopBalanceStatement.setExtension(order.getOrderNumber()); |
| | | shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); |
| | | } |
| | | //添加积分明细 |
| | | if(!sjShopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(14); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(bdmdsj_point); |
| | | userPoint.setBalance(sjShopAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(sjShopAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(sjShopAppUser.getId()); |
| | | } |
| | | |
| | | if(!shop2.getLavePoint().equals(shopLavePoint)){ |
| | | ShopPoint shopPoint = new ShopPoint(); |
| | | shopPoint.setShopId(shop2.getId()); |
| | | shopPoint.setType(3); |
| | | shopPoint.setHistoricalPoint(shopLavePoint); |
| | | shopPoint.setVariablePoint(bdmdsj_point); |
| | | shopPoint.setBalance(shop2.getLavePoint()); |
| | | shopPoint.setCreateTime(LocalDateTime.now()); |
| | | shopPoint.setCreateUserId(order.getAppUserId()); |
| | | shopPoint.setObjectId(order.getId()); |
| | | shopPoint.setOrderNum(order.getOrderNumber()); |
| | | shopPointClient.saveShopPoint(shopPoint); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | order.setIsCommission(1); |
| | | orderService.updateById(order); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |