| | |
| | | @Resource |
| | | private BalanceChangeRecordService balanceChangeRecordService; |
| | | @Resource |
| | | private BalanceChangeRecordCopyService balanceChangeRecordCopyService; |
| | | @Resource |
| | | private UserChangeLogService userChangeLogService; |
| | | @Resource |
| | | private RedisService redisService; |
| | |
| | | appUser.setExcludeStatus(3); |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | List<AppUserGiveawayTemporary> list = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getAppUserId, record.getId())); |
| | | int sum = list.stream().mapToInt(AppUserGiveawayTemporary::getTotalPoint).sum(); |
| | | if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | | if (byId1!=null) { |
| | |
| | | record.setShopName(shop1.getName()); |
| | | record.setShopId(shop1.getId()); |
| | | } |
| | | record.setTotalPoint(record.getUserTotalPoint()); |
| | | record.setTotalPoint(record.getUserTotalPoint() + sum); |
| | | } |
| | | return R.ok(appuserPage); |
| | | } |
| | |
| | | Integer shopId = data.getObjectId(); |
| | | List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); |
| | | List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); |
| | | Set<Long> shopServerUser = getShopServerUser(shopId); |
| | | userIds.addAll(shopServerUser); |
| | | if(userIds.size() == 0){ |
| | | userIds.add(-1L); |
| | | } |
| | | queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds); // userIds 不为空时,查询 id 在 userIds 中 |
| | | } |
| | | queryWrapper.eq("del_flag", 0); |
| | |
| | | queryWrapper.in(BalanceChangeRecord::getAppUserId, appUserIds); |
| | | } |
| | | List<BalanceChangeRecord> list = balanceChangeRecordService.list(queryWrapper); |
| | | for (BalanceChangeRecord balanceChangeRecord : list) { |
| | | balanceChangeRecord.setChangeAmount(balanceChangeRecord.getChangeAmount().multiply(new BigDecimal(balanceChangeRecord.getChangeDirection()))); |
| | | } |
| | | |
| | | LambdaQueryWrapper<BalanceChangeRecordCopy> queryWrapper1 = new LambdaQueryWrapper<BalanceChangeRecordCopy>() |
| | | .between(BalanceChangeRecordCopy::getCreateTime, date, date.plusDays(1)) |
| | | .eq(BalanceChangeRecordCopy::getChangeType, 4) |
| | | .eq(BalanceChangeRecordCopy::getVipId, i); |
| | | if(sysUser.getRoleType() == 2){ |
| | | Integer objectId = sysUser.getObjectId(); |
| | | List<AppUser> list1 = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 1)); |
| | | List<Long> appUserIds = list1.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | Set<Long> data = orderClient.getAppUserByShoppingShop(objectId).getData(); |
| | | if(null != data){ |
| | | appUserIds.addAll(data); |
| | | } |
| | | if(appUserIds.size() == 0){ |
| | | appUserIds.add(-1L); |
| | | } |
| | | queryWrapper1.in(BalanceChangeRecordCopy::getAppUserId, appUserIds); |
| | | } |
| | | List<BalanceChangeRecordCopy> list2 = balanceChangeRecordCopyService.list(queryWrapper1); |
| | | for (BalanceChangeRecordCopy balanceChangeRecordCopy : list2) { |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | BeanUtils.copyProperties(balanceChangeRecordCopy, balanceChangeRecord); |
| | | balanceChangeRecord.setChangeAmount(balanceChangeRecord.getChangeAmount().multiply(new BigDecimal(balanceChangeRecord.getChangeDirection()))); |
| | | list.add(balanceChangeRecord); |
| | | } |
| | | |
| | | BigDecimal reduce = list.stream().map(BalanceChangeRecord::getChangeAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | String dateKey = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) |
| | |
| | | @Resource |
| | | private UserPointCopyMapper userPointCopyMapper; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | /** |
| | |
| | | IPage<UserPoint> userPointPage = userPointService.getUserPointPage(Page.of(userPoint.getPageNum(), userPoint.getPageSize()), userPoint); |
| | | return R.ok(userPointPage); |
| | | } |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | @GetMapping("/user/list") |
| | | @ApiOperation(value = "积分管理-用户积分明细(必传用户id)", tags = "后台") |
| | |
| | | appUserService.updateById(appUser); |
| | | |
| | | //添加积分变动记录 |
| | | if(signPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(5); |
| | | userPoint.setVariablePoint(signPoint); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointService.save(userPoint); |
| | | } |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(5); |
| | | userPoint.setVariablePoint(signPoint); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointService.save(userPoint); |
| | | //变更等级 |
| | | appUserService.vipUpgrade(appUser.getId()); |
| | | |
| | | R<BigDecimal> bigDecimalR = systemConfigClient.redPackegeSet(); |
| | | BigDecimal data = bigDecimalR.getData(); |
| | | if(data.compareTo(BigDecimal.ZERO) > 0){ |
| | | userSignRecord.setRedAmount(data); |
| | | userSignRecord.setSignDay(LocalDate.now()); |
| | | BigDecimal sum = appUser.getTotalRedPacketAmount().add(bigDecimalR.getData()); |
| | | appUser.setTotalRedPacketAmount(sum); |
| | | BigDecimal sum2 = appUser.getBalance().add(bigDecimalR.getData()); |
| | | appUser.setBalance(sum2); |
| | | appUserService.updateById(appUser); |
| | | // 增加一条余额明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(3); |
| | | balanceChangeRecord.setChangeAmount(bigDecimalR.getData()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(1); |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | } |
| | | userSignRecordService.save(userSignRecord); |
| | | SignBackRDto signBackRDto = new SignBackRDto(); |
| | | signBackRDto.setPoint(userSignRecord.getPoint()); |
| | | signBackRDto.setRedAmount(userSignRecord.getRedAmount()); |
| | | return R.ok(signBackRDto); |
| | | } |
| | | }else { |
| | | userSignRecord.setPoint(0); |
| | | } |
| | | R<BigDecimal> bigDecimalR = systemConfigClient.redPackegeSet(); |
| | | userSignRecord.setRedAmount(bigDecimalR.getData()); |
| | | userSignRecord.setSignDay(LocalDate.now()); |
| | | BigDecimal sum = appUser.getTotalRedPacketAmount().add(bigDecimalR.getData()); |
| | | appUser.setTotalRedPacketAmount(sum); |
| | | BigDecimal sum2 = appUser.getBalance().add(bigDecimalR.getData()); |
| | | appUser.setBalance(sum2); |
| | | appUserService.updateById(appUser); |
| | | // 增加一条余额明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(3); |
| | | balanceChangeRecord.setChangeAmount(bigDecimalR.getData()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(1); |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | SignBackRDto signBackRDto = new SignBackRDto(); |
| | | signBackRDto.setPoint(userSignRecord.getPoint()); |
| | | signBackRDto.setRedAmount(userSignRecord.getRedAmount()); |
| | | userSignRecordService.save(userSignRecord); |
| | | return R.ok(signBackRDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | @Resource |
| | | private IAppUserGiveawayTemporaryService appUserGiveawayTemporaryService; |
| | | |
| | | |
| | | /** |
| | |
| | | //钻石会员 |
| | | VipSetting vipSetting3 = vipSettingClient.getVipSetting(3).getData(); |
| | | //消费积分满足升级 |
| | | if(1 == vipSetting3.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting3.getVipLevelUpShop() && appUser.getVipId() < 3){ |
| | | if(1 == vipSetting3.getVipLevelUpShopRole() && appUser.getShopPoint().compareTo(vipSetting3.getVipLevelUpShop()) >= 0 && appUser.getVipId() < 3){ |
| | | appUser.setVipId(3); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | |
| | | return; |
| | | } |
| | | //返佣积分满足升级 |
| | | if(1 == vipSetting3.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting3.getVipLevelUpShare() && appUser.getVipId() < 3){ |
| | | List<AppUserGiveawayTemporary> list = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getAppUserId, appUser.getId())); |
| | | int sum = list.stream().mapToInt(AppUserGiveawayTemporary::getSharePoint).sum(); |
| | | int sharePoin = appUser.getSharePoint() + sum; |
| | | if(1 == vipSetting3.getVipLevelUpShareRole() && sharePoin >= vipSetting3.getVipLevelUpShare() && appUser.getVipId() < 3){ |
| | | appUser.setVipId(3); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | |
| | | //黄金会员 |
| | | VipSetting vipSetting2 = vipSettingClient.getVipSetting(2).getData(); |
| | | //消费积分满足升级 |
| | | if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting2.getVipLevelUpShop() && appUser.getVipId() < 2){ |
| | | if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint().compareTo(vipSetting2.getVipLevelUpShop()) >= 0 && appUser.getVipId() < 2){ |
| | | appUser.setVipId(2); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | |
| | | return; |
| | | } |
| | | //返佣积分满足升级 |
| | | if(1 == vipSetting2.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting2.getVipLevelUpShare() && appUser.getVipId() < 2){ |
| | | if(1 == vipSetting2.getVipLevelUpShareRole() && appUser.getSharePoint().compareTo(vipSetting2.getVipLevelUpShare()) >= 0 && appUser.getVipId() < 2){ |
| | | appUser.setVipId(2); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogService.save(userChangeLog); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | |
| | | public void vipDemotion(Long appUserId) { |
| | | AppUser appUser = this.getById(appUserId); |
| | | Integer vipId = appUser.getVipId(); |
| | | //钻石会员 |
| | | VipSetting vipSetting3 = vipSettingClient.getVipSetting(3).getData(); |
| | | if(1 == vipSetting3.getVipLevelUpShopRole() && appUser.getShopPoint().compareTo(vipSetting3.getVipLevelUpShop()) >= 0 && appUser.getVipId() == 3){ |
| | | return; |
| | | } |
| | | //返佣积分满足升级 |
| | | List<AppUserGiveawayTemporary> list = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getAppUserId, appUser.getId())); |
| | | int sum = list.stream().mapToInt(AppUserGiveawayTemporary::getSharePoint).sum(); |
| | | int sharePoin = appUser.getSharePoint() + sum; |
| | | if(1 == vipSetting3.getVipLevelUpShareRole() && sharePoin >= vipSetting3.getVipLevelUpShare() && appUser.getVipId() == 3){ |
| | | return; |
| | | } |
| | | //下级人数满足升级 |
| | | Integer vipLevelUpNumRole = vipSetting3.getVipLevelUpNumRole(); |
| | | Integer vipDirectNum = vipSetting3.getVipDirectNum(); |
| | | Integer vipTeamNum = vipSetting3.getVipTeamNum(); |
| | | if(1 == vipLevelUpNumRole && appUser.getVipId() == 3){ |
| | | //查询直推用户达到X人或者团队人数达到X人后,可升级 |
| | | //直推用户数 |
| | | long count = this.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1).eq(AppUser::getInviteUserId, appUserId)); |
| | | //团队用户数 |
| | | List<AppUser> subordinate = getSubordinate(appUserId); |
| | | if(vipDirectNum <= count || vipTeamNum <= subordinate.size()){ |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | //黄金会员 |
| | | VipSetting vipSetting2 = vipSettingClient.getVipSetting(2).getData(); |
| | | //消费积分满足升级 |
| | | if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting2.getVipLevelUpShop() && appUser.getVipId() > 2){ |
| | | if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint().compareTo(vipSetting2.getVipLevelUpShop()) >= 0 && appUser.getVipId() >= 2){ |
| | | appUser.setVipId(2); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | |
| | | return; |
| | | } |
| | | //返佣积分满足升级 |
| | | if(1 == vipSetting2.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting2.getVipLevelUpShare() && appUser.getVipId() > 2){ |
| | | if(1 == vipSetting2.getVipLevelUpShareRole() && sharePoin >= vipSetting2.getVipLevelUpShare() && appUser.getVipId() >= 2){ |
| | | appUser.setVipId(2); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | |
| | | return; |
| | | } |
| | | //下级人数满足升级 |
| | | Integer vipLevelUpNumRole = vipSetting2.getVipLevelUpNumRole(); |
| | | Integer vipDirectNum = vipSetting2.getVipDirectNum(); |
| | | Integer vipTeamNum = vipSetting2.getVipTeamNum(); |
| | | if(1 == vipLevelUpNumRole && appUser.getVipId() > 2){ |
| | | vipLevelUpNumRole = vipSetting2.getVipLevelUpNumRole(); |
| | | vipDirectNum = vipSetting2.getVipDirectNum(); |
| | | vipTeamNum = vipSetting2.getVipTeamNum(); |
| | | if(1 == vipLevelUpNumRole && appUser.getVipId() >= 2){ |
| | | //查询直推用户达到X人或者团队人数达到X人后,可升级 |
| | | //直推用户数 |
| | | long count = this.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1).eq(AppUser::getInviteUserId, appUserId)); |
| | |
| | | return; |
| | | } |
| | | } |
| | | if(appUser.getVipId() >= 2){ |
| | | appUser.setVipId(1); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(0); |
| | | userChangeLogService.save(userChangeLog); |
| | | } |
| | | appUser.setVipId(1); |
| | | this.updateById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(0); |
| | | userChangeLogService.save(userChangeLog); |
| | | } |
| | | |
| | | /** |
| | |
| | | public CommissionStatistics commissionStatistics(Page<BalanceChangeRecord> page, BalanceChangeRecord balanceChangeRecord) { |
| | | balanceChangeRecord.setChangeType(4); |
| | | List<BalanceChangeRecord> balanceChangeRecordList = this.baseMapper.selectBalanceChangeRecordList(balanceChangeRecord); |
| | | |
| | | balanceChangeRecordList.forEach(s->s.setChangeAmount(s.getChangeAmount().multiply(new BigDecimal(s.getChangeDirection())))); |
| | | BigDecimal totalCommission = balanceChangeRecordList.stream() |
| | | .filter(item -> !(item.getChangeType().equals(2) && item.getChangeType().equals(5))) |
| | | .map(BalanceChangeRecord::getChangeAmount) |
| | |
| | | List<WalletStatisticsDetail> walletStatisticsDetailList2 = walletStatisticsDetailList.subList(fromIndex, toIndex); |
| | | for (WalletStatisticsDetail changeRecord : walletStatisticsDetailList2) { |
| | | Integer flag = changeRecord.getFlag(); |
| | | if (flag.equals(1)){ |
| | | if (flag == 1){ |
| | | changeRecord.setChangeAmountString("+¥"+changeRecord.getChangeAmount()); |
| | | }else { |
| | | changeRecord.setChangeAmountString("-¥"+changeRecord.getChangeAmount()); |
| | |
| | | AppUser appUser = appUserService.getById(userPointDetailVO.getTransferUserId()); |
| | | userPointDetailVO.setName(appUser.getName()); |
| | | } |
| | | Integer historicalPoint = userPointDetailVO.getHistoricalPoint(); |
| | | Integer balance = userPointDetailVO.getBalance(); |
| | | if (historicalPoint != null && balance != null) { |
| | | userPointDetailVO.setFlag(historicalPoint > balance ? 2 : 1); |
| | | } |
| | | userPointDetailVO.setFlag(userPointDetailVO.getChangeDirection() == -1 ? 2 : 1); |
| | | } |
| | | |
| | | pageInfo.setRecords(userPointDetail); |
| | |
| | | private BigDecimal serviceChargeCommission; |
| | | |
| | | /** |
| | | * 关联用户分佣 |
| | | * 绑定门店分佣 |
| | | */ |
| | | private BigDecimal associatedUserCommission; |
| | | |
| | |
| | | private Integer historicalPoint; |
| | | |
| | | private Integer balance; |
| | | |
| | | private Integer changeDirection; |
| | | } |
| | |
| | | </select> |
| | | <select id="getUserStatisticsDetail" resultType="com.ruoyi.account.vo.UserStatisticsDetail"> |
| | | SELECT |
| | | ifnull(SUM(tau.shop_point+tau.share_point+tau.total_invite_point+tau.total_register_point+tau.total_share_point+tau.total_sign_point+tau.total_hour_point+total_performance_point), 0) totalScore, |
| | | ifnull(SUM(tau.shop_point+tau.share_point+tau.total_invite_point+tau.total_register_point+tau.total_share_point+tau.total_sign_point+tau.total_hour_point+tau.total_performance_point + |
| | | ifnull(tat.share_point+tat.total_performance_point, 0)), 0) totalScore, |
| | | ifnull(SUM(tau.shop_point), 0) consumeScore, |
| | | ifnull(SUM(tau.share_point), 0) rebateScore, |
| | | ifnull(SUM(tau.share_point + ifnull(tat.share_point, 0)), 0) rebateScore, |
| | | ifnull(SUM(tau.total_invite_point), 0) inviteScore, |
| | | ifnull(SUM(tau.total_register_point), 0) registerScore, |
| | | ifnull(SUM(tau.total_share_point+tau.total_sign_point+tau.total_hour_point), 0) workScore, |
| | | ifnull(SUM(tau.total_performance_point), 0) achievementScore, |
| | | ifnull(SUM(tau.total_distribution_amount), 0) totalRebate, |
| | | ifnull(SUM(tau.total_performance_point + ifnull(tat.total_performance_point, 0)), 0) achievementScore, |
| | | ifnull(SUM(tau.total_distribution_amount + ifnull(tat.total_distribution_amount, 0)), 0) totalRebate, |
| | | ifnull(SUM(tau.total_recharge_amount), 0) totalRecharge, |
| | | ifnull(SUM(tau.withdrawn_amount), 0) totalWithdraw |
| | | FROM |
| | | t_app_user tau |
| | | left join ( |
| | | select |
| | | app_user_id, |
| | | sum(share_point) as share_point, |
| | | sum(shop_share_point) as shop_share_point, |
| | | sum(shop_achievement_point) as shop_achievement_point, |
| | | sum(lower_level_share_point) as lower_level_share_point, |
| | | sum(total_performance_point) as total_performance_point, |
| | | sum(lave_point) as lave_point, |
| | | sum(available_point) as available_point, |
| | | sum(transferable_point) as transferable_point, |
| | | sum(total_available_point) as total_available_point, |
| | | sum(total_point) as total_point, |
| | | sum(withdrawable_amount) as withdrawable_amount, |
| | | sum(total_distribution_amount) as total_distribution_amount, |
| | | sum(shop_service_fee) as shop_service_fee, |
| | | sum(shop_commission) as shop_commission, |
| | | sum(balance) as balance |
| | | from t_app_user_giveaway_temporary group by app_user_id |
| | | ) as tat on (tau.id = tat.app_user_id) |
| | | <where> |
| | | tau.del_flag = 0 and tau.status != 3 |
| | | <if test="null != shopId"> |
| | |
| | | tbcr.create_time, |
| | | tbcr.change_amount, |
| | | tbcr.before_amount, |
| | | tbcr.after_amount |
| | | tbcr.after_amount, |
| | | tbcr.change_direction |
| | | FROM |
| | | t_balance_change_record tbcr |
| | | (select * from t_balance_change_record union all select * from t_balance_change_record_copy) tbcr |
| | | LEFT JOIN t_app_user tau ON tbcr.app_user_id = tau.id |
| | | <where> |
| | | <if test="changeRecord.changeType == null"> |
| | |
| | | tbcr.create_time, |
| | | tbcr.change_amount, |
| | | tbcr.before_amount, |
| | | tbcr.after_amount |
| | | tbcr.after_amount, |
| | | tbcr.change_direction |
| | | FROM |
| | | t_balance_change_record tbcr |
| | | LEFT JOIN t_app_user tau ON tbcr.app_user_id = tau.id and tau.del_flag = 0 |
| | |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.account.api.model.UserPoint"> |
| | | <id column="id" property="id" /> |
| | | <result column="type" property="type" /> |
| | | <result column="historical_point" property="historicalPoint" /> |
| | | <result column="change_direction" property="changeDirection" /> |
| | | <result column="variable_point" property="variablePoint" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="app_user_id" property="appUserId" /> |
| | |
| | | tup.type, |
| | | tup.create_time, |
| | | tup.variable_point, |
| | | tup.historical_point, |
| | | tup.balance |
| | | tup.change_direction |
| | | FROM |
| | | t_user_point tup |
| | | LEFT JOIN t_app_user tau ON tup.app_user_id = tau.id |
| | |
| | | historical_point as historicalPoint, |
| | | balance, |
| | | variable_point as variablePoint, |
| | | change_direction as changeDirection, |
| | | DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime, |
| | | transfer_user_id as transferUserId, |
| | | receive_user_id as receiveUserId, |
| | |
| | | historical_point as historicalPoint, |
| | | balance, |
| | | variable_point as variablePoint, |
| | | change_direction as changeDirection, |
| | | DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime, |
| | | transfer_user_id as transferUserId, |
| | | receive_user_id as receiveUserId, |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void calculationCommissionShop(Long orderId) { |
| | | Order order = orderService.getById(orderId); |
| | | //快递单品不进行分佣 |
| | | if(order.getOrderType() == 2 && order.getDistributionMode() == 2){ |
| | | return; |
| | | } |
| | | List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() |
| | | .eq(OrderGood::getOrderId, order.getId())); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | |
| | | 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("订单取消失败"); |
| | | } |
| | | return r; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | //删除用户和门店添加的汇总数据(冻结数据) |
| | | appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); |
| | | shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | 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(); |
| | | } |
| | |
| | | Long days = jsonObject.getLong("days"); |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | this.updateById(order); |
| | | commissionService.calculationCommissionShop(order.getId()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.apache.commons.lang3.tuple.Pair; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | R<SysUser> sysUserR = sysUserClient.getSysUser(userid); |
| | | SysUser sysUser = sysUserR.getData(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | Page<ShopBalanceStatement> page = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(shopBalanceStatement.getType() != null, ShopBalanceStatement::getType, shopBalanceStatement.getType()) |
| | | .orderByDesc(ShopBalanceStatement::getCreateTime) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | |
| | | Page<ShopBalanceStatement> page = shopBalanceStatementService.shopCommissionStatisticslist(objectId, shopBalanceStatement.getType(), pageNum, pageSize); |
| | | page.getRecords().forEach(s->s.setVariableAmount(s.getVariableAmount().multiply(new BigDecimal(s.getChangeDirection())))); |
| | | return R.ok(page); |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | List<ShopBalanceStatement> list = shopBalanceStatementService.list(queryWrapper); |
| | | for (ShopBalanceStatement shopBalanceStatement : list) { |
| | | shopBalanceStatement.setVariableAmount(shopBalanceStatement.getVariableAmount().multiply(new BigDecimal(shopBalanceStatement.getChangeDirection()))); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ShopBalanceStatementCopy> queryWrapper1 = new LambdaQueryWrapper<ShopBalanceStatementCopy>() |
| | | .eq(ShopBalanceStatementCopy::getType, type) |
| | | .between(ShopBalanceStatementCopy::getCreateTime, date.with(LocalTime.MIN), date.with(LocalTime.MAX)); |
| | | if (null != shopId && 0 != shopId) { |
| | | queryWrapper1.eq(ShopBalanceStatementCopy::getShopId, shopId); |
| | | }else{ |
| | | List<Integer> shipIds = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0)).stream().map(Shop::getId).collect(Collectors.toList()); |
| | | if(shipIds.size() > 0){ |
| | | queryWrapper1.in(ShopBalanceStatementCopy::getShopId, shipIds); |
| | | }else{ |
| | | queryWrapper1.eq(ShopBalanceStatementCopy::getShopId, -1); |
| | | } |
| | | } |
| | | List<ShopBalanceStatementCopy> list1 = shopBalanceStatementCopyMapper.selectList(queryWrapper1); |
| | | for (ShopBalanceStatementCopy shopBalanceStatementCopy : list1) { |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | BeanUtils.copyProperties(shopBalanceStatementCopy, shopBalanceStatement); |
| | | shopBalanceStatement.setVariableAmount(shopBalanceStatement.getVariableAmount().multiply(new BigDecimal(shopBalanceStatement.getChangeDirection()))); |
| | | list.add(shopBalanceStatement); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | |
| | | |
| | | // 合并计算 |
| | | Map<Integer, BigDecimal> result = Stream.concat( |
| | | copies.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount())), |
| | | statements.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount())) |
| | | copies.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount().multiply(new BigDecimal(e.getChangeDirection())))), |
| | | statements.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount().multiply(new BigDecimal(e.getChangeDirection())))) |
| | | ).collect(Collectors.groupingBy( |
| | | Pair::getKey, |
| | | Collectors.mapping(Pair::getValue, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)) |
| | |
| | | } |
| | | |
| | | // 构建结果 |
| | | |
| | | List<ShopWithdraw> list = shopWithdrawService.lambdaQuery().eq(ShopWithdraw::getShopId, shopId) |
| | | .eq(ShopWithdraw::getAuditStatus, 0).list(); |
| | | BigDecimal withdrawAuditMoney = list.stream().map(ShopWithdraw::getMoney).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); |
| | |
| | | )); |
| | | commission.setWaitingAuditCommission(waitingAudit); |
| | | commission.setTotalAmount(commission.getCommissionAmount()); |
| | | |
| | | return R.ok(commission); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.order.vo.OrderSaleNum; |
| | | import com.ruoyi.order.vo.VerifiableShopVo; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.mapper.ShopBalanceStatementCopyMapper; |
| | | import com.ruoyi.other.mapper.ShopGiveawayTemporaryMapper; |
| | | import com.ruoyi.other.mapper.ShopMapper; |
| | | import com.ruoyi.other.service.*; |
| | | import com.ruoyi.other.util.GeodesyUtil; |
| | |
| | | private TechnicianService technicianService; |
| | | @Resource |
| | | private ReceiverBankChannelService receiverBankChannelService; |
| | | |
| | | @Resource |
| | | private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper; |
| | | |
| | | |
| | | |
| | |
| | | serverGiveawayMoney = serverGiveawayMoney.add(shop.getServerGiveawayMoney()); |
| | | giveawayMoney = giveawayMoney.add(shop.getGiveawayMoney().add(shop.getLowerLevelGiveawayMoney())); |
| | | } |
| | | LambdaQueryWrapper<ShopGiveawayTemporary> wrapper = new LambdaQueryWrapper<>(); |
| | | if(null != shopId && 0 != shopId){ |
| | | wrapper.eq(ShopGiveawayTemporary::getShopId, shopId); |
| | | } |
| | | List<ShopGiveawayTemporary> list = shopGiveawayTemporaryMapper.selectList(wrapper); |
| | | BigDecimal reduce = list.stream().map(ShopGiveawayTemporary::getServerGiveawayMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | serverGiveawayMoney = serverGiveawayMoney.add(reduce); |
| | | BigDecimal reduce1 = list.stream().map(ShopGiveawayTemporary::getGiveawayMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | giveawayMoney = giveawayMoney.add(reduce1); |
| | | Map<String, BigDecimal> map = new HashMap<>(); |
| | | map.put("serverGiveawayMoney", serverGiveawayMoney); |
| | | map.put("giveawayMoney", giveawayMoney); |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.ShopBalanceStatement; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | @Param("bs") ShopBalanceStatement shopBalanceStatement); |
| | | |
| | | List<ShopBalanceStatement> selectShopBalanceStatementList(@Param("bs") ShopBalanceStatement shopBalanceStatement); |
| | | |
| | | |
| | | /** |
| | | * 获取余额明细列表 |
| | | * @param pageInfo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | PageInfo<ShopBalanceStatement> shopCommissionStatisticslist(PageInfo<ShopBalanceStatement> pageInfo, @Param("shopId") Integer shopId, @Param("type") Integer type); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.ShopBalanceStatement; |
| | | import com.ruoyi.other.vo.ShopCommissionStatisticsVO; |
| | | |
| | |
| | | */ |
| | | public interface ShopBalanceStatementService extends IService<ShopBalanceStatement> { |
| | | ShopCommissionStatisticsVO shopCommissionStatistics(IPage<ShopBalanceStatement> page, ShopBalanceStatement shopBalanceStatement); |
| | | |
| | | |
| | | /** |
| | | * 获取门店余额明细列表 |
| | | * @param type |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | PageInfo<ShopBalanceStatement> shopCommissionStatisticslist(Integer shopId, Integer type, Integer pageNum, Integer pageSize); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.ShopBalanceStatement; |
| | | import com.ruoyi.other.api.domain.ShopPoint; |
| | | import com.ruoyi.other.mapper.ShopBalanceStatementMapper; |
| | |
| | | public ShopCommissionStatisticsVO shopCommissionStatistics(IPage<ShopBalanceStatement> page, ShopBalanceStatement shopBalanceStatement) { |
| | | ShopCommissionStatisticsVO shopCommissionStatisticsVO = new ShopCommissionStatisticsVO(); |
| | | List<ShopBalanceStatement> shopBalanceStatements = this.baseMapper.selectShopBalanceStatementList(shopBalanceStatement); |
| | | |
| | | |
| | | shopBalanceStatements.forEach(s->s.setVariableAmount(s.getVariableAmount().multiply(new BigDecimal(s.getChangeDirection())))); |
| | | Map<Integer, BigDecimal> shopCommissionMap = shopBalanceStatements.stream() |
| | | .collect(Collectors.groupingBy( |
| | | ShopBalanceStatement::getType, |
| | |
| | | shopCommissionStatisticsVO.setTotalServiceCharge(totalServiceCharge); |
| | | BigDecimal totalAmount = totalCommission.add(totalSubordinateCommission).add(totalServiceCharge); |
| | | shopCommissionStatisticsVO.setTotalAmount(totalAmount); |
| | | |
| | | IPage<ShopBalanceStatement> statementIPage = this.baseMapper.queryShopBalanceStatementPage(page, shopBalanceStatement); |
| | | for (ShopBalanceStatement record : statementIPage.getRecords()) { |
| | | if (record.getChangeDirection() == -1){ |
| | |
| | | shopCommissionStatisticsVO.setStatementIPage(statementIPage); |
| | | return shopCommissionStatisticsVO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取余额明细列表 |
| | | * @param type |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageInfo<ShopBalanceStatement> shopCommissionStatisticslist(Integer shopId, Integer type, Integer pageNum, Integer pageSize) { |
| | | PageInfo<ShopBalanceStatement> pageInfo = new PageInfo<>(pageNum, pageSize); |
| | | return this.baseMapper.shopCommissionStatisticslist(pageInfo, shopId, type); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.domain.ShopGiveawayTemporary; |
| | | import com.ruoyi.other.api.domain.ShopPoint; |
| | | import com.ruoyi.other.api.domain.ShopPointCopy; |
| | | import com.ruoyi.other.api.enums.PointChangeType; |
| | | import com.ruoyi.other.mapper.ShopGiveawayTemporaryMapper; |
| | | import com.ruoyi.other.mapper.ShopPointCopyMapper; |
| | | import com.ruoyi.other.mapper.ShopPointMapper; |
| | | import com.ruoyi.other.service.ShopPointService; |
| | | import com.ruoyi.other.service.ShopService; |
| | |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private ShopService shopService; |
| | | @Resource |
| | | private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper; |
| | | |
| | | @Resource |
| | | private ShopPointCopyMapper shopPointCopyMapper; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | ShopPointStatistics shopPointStatistics = new ShopPointStatistics(); |
| | | IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); |
| | | shopPointIPage.getRecords().forEach(s->s.setVariablePoint(s.getVariablePoint() * s.getChangeDirection())); |
| | | shopPointStatistics.setShopPointIPage(shopPointIPage); |
| | | |
| | | |
| | |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | Integer point = shopPointStatistics.getShopPoint() == null ? 0 : shopPointStatistics.getShopPoint(); |
| | | Integer shopCommissionPoint = shopPointStatistics.getShopCommissionPoint() == null ? 0 : shopPointStatistics.getShopCommissionPoint(); |
| | | Integer setSubShopCommissionPoint = shopPointStatistics.getSubShopCommissionPoint() == null ? 0 : shopPointStatistics.getSubShopCommissionPoint(); |
| | | |
| | | List<ShopPointCopy> shopPointCopyList = shopPointCopyMapper.selectList(null); |
| | | Map<Integer, List<ShopPointCopy>> shopPointByTypeMaps = shopPointCopyList.stream().collect(Collectors.groupingBy(ShopPointCopy::getType)); |
| | | shopPointByTypeMaps.forEach((type, shopPoints) -> { |
| | | shopPoints.stream().map(ShopPointCopy::getVariablePoint).reduce(Integer::sum).ifPresent(sum -> { |
| | | switch (type) { |
| | | case 1: |
| | | shopPointStatistics.setShopPoint((null == shopPointStatistics.getShopPoint() ? 0 : shopPointStatistics.getShopPoint()) + sum); |
| | | break; |
| | | case 2: |
| | | shopPointStatistics.setShopCommissionPoint((null == shopPointStatistics.getShopCommissionPoint() ? 0 : shopPointStatistics.getShopCommissionPoint()) + sum); |
| | | break; |
| | | case 3: |
| | | shopPointStatistics.setSubShopCommissionPoint((null == shopPointStatistics.getSubShopCommissionPoint() ? 0 : shopPointStatistics.getSubShopCommissionPoint()) + sum); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | |
| | | List<ShopGiveawayTemporary> list1 = shopGiveawayTemporaryMapper.selectList(null); |
| | | int serverPointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getServerPoint).sum(); |
| | | int sharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getSharePoint).sum(); |
| | | int lowerLevelSharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getLowerLevelSharePoint).sum(); |
| | | Integer point = shopPointStatistics.getShopPoint() == null ? 0 : shopPointStatistics.getShopPoint() + serverPointCopy; |
| | | Integer shopCommissionPoint = shopPointStatistics.getShopCommissionPoint() == null ? 0 : shopPointStatistics.getShopCommissionPoint() + sharePointCopy; |
| | | Integer setSubShopCommissionPoint = shopPointStatistics.getSubShopCommissionPoint() == null ? 0 : shopPointStatistics.getSubShopCommissionPoint() + lowerLevelSharePointCopy; |
| | | Integer totalPoint = point + shopCommissionPoint + setSubShopCommissionPoint; |
| | | shopPointStatistics.setShopPoint(point); |
| | | shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); |
| | | shopPointStatistics.setSubShopCommissionPoint(setSubShopCommissionPoint); |
| | | shopPointStatistics.setTotalPoint(totalPoint); |
| | | |
| | | |
| | |
| | | return shopPointStatistics; |
| | | }else{ |
| | | Shop shop = shopService.getById(sysUser.getObjectId()); |
| | | Integer serverPoint = shop.getServerPoint(); |
| | | Integer sharePoint = shop.getSharePoint(); |
| | | Integer lowerLevelSharePoint = shop.getLowerLevelSharePoint(); |
| | | List<ShopGiveawayTemporary> list1 = shopGiveawayTemporaryMapper.selectList(new LambdaQueryWrapper<ShopGiveawayTemporary>().eq(ShopGiveawayTemporary::getShopId, shop.getId())); |
| | | int serverPointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getServerPoint).sum(); |
| | | int sharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getSharePoint).sum(); |
| | | int lowerLevelSharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getLowerLevelSharePoint).sum(); |
| | | shopPoint.setShopId(shop.getId()); |
| | | Integer serverPoint = shop.getServerPoint() + serverPointCopy; |
| | | Integer sharePoint = shop.getSharePoint() + sharePointCopy; |
| | | Integer lowerLevelSharePoint = shop.getLowerLevelSharePoint() + lowerLevelSharePointCopy; |
| | | ShopPointStatistics shopPointStatistics = new ShopPointStatistics(); |
| | | shopPointStatistics.setTotalPoint(serverPoint + sharePoint + lowerLevelSharePoint); |
| | | shopPointStatistics.setShopPoint(serverPoint); |
| | |
| | | shopPointStatistics.setSubShopCommissionPoint(lowerLevelSharePoint); |
| | | |
| | | IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); |
| | | shopPointIPage.getRecords().forEach(s->s.setVariablePoint(s.getVariablePoint() * s.getChangeDirection())); |
| | | shopPointStatistics.setShopPointIPage(shopPointIPage); |
| | | |
| | | LocalDateTime startTime = shopPoint.getStartTime(); |
| | |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.domain.ShopGiveawayTemporary; |
| | | import com.ruoyi.other.api.domain.ShopPointCopy; |
| | | import com.ruoyi.other.api.domain.ShopScore; |
| | | import com.ruoyi.other.mapper.ShopGiveawayTemporaryMapper; |
| | | import com.ruoyi.other.mapper.ShopMapper; |
| | | import com.ruoyi.other.mapper.ShopPointCopyMapper; |
| | | import com.ruoyi.other.service.ShopScoreService; |
| | | import com.ruoyi.other.service.ShopService; |
| | | import com.ruoyi.other.vo.NearbyShopVO; |
| | |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | Page<Shop> page = new Page<>(); |
| | | page.setCurrent(PageNum); |
| | | page.setSize(pageSize); |
| | | return shopMapper.selectShopList(page, shop); |
| | | IPage<Shop> shopIPage = shopMapper.selectShopList(page, shop); |
| | | for (Shop record : shopIPage.getRecords()) { |
| | | List<ShopGiveawayTemporary> shopPointCopies = shopGiveawayTemporaryMapper.selectList(new LambdaQueryWrapper<ShopGiveawayTemporary>().eq(ShopGiveawayTemporary::getShopId, record.getId())); |
| | | int shopAllPoint = shopPointCopies.stream().mapToInt(ShopGiveawayTemporary::getShopAllPoint).sum(); |
| | | record.setShopAllPoint(record.getShopAllPoint() + shopAllPoint); |
| | | } |
| | | return shopIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | ts.shop_manager shopManagerName, |
| | | ts.phone |
| | | FROM |
| | | t_shop_balance_statement tsbs |
| | | ( |
| | | select * from t_shop_balance_statement |
| | | union all |
| | | select * from t_shop_balance_statement_copy |
| | | ) tsbs |
| | | INNER JOIN t_shop ts ON ts.id = tsbs.shop_id |
| | | <where> |
| | | tsbs.type != 4 and ts.del_flag = 0 |
| | |
| | | AND tsbs.create_time BETWEEN #{bs.startTime} AND #{bs.endTime} |
| | | </if> |
| | | </where> |
| | | order by tsbs.create_time desc |
| | | </sql> |
| | | |
| | | <select id="queryShopBalanceStatementPage" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement"> |
| | |
| | | <select id="selectShopBalanceStatementList" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement"> |
| | | <include refid="shopBalanceStatementList"/> |
| | | </select> |
| | | |
| | | |
| | | <select id="shopCommissionStatisticslist" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement"> |
| | | select * from ( |
| | | select * from t_shop_balance_statement where shop_id = #{shopId} |
| | | union all |
| | | select * from t_shop_balance_statement_copy where shop_id = #{shopId} |
| | | ) as aa |
| | | <where> |
| | | <if test="null != type"> |
| | | and aa.type = #{type} |
| | | </if> |
| | | </where> |
| | | order by aa.create_time desc |
| | | </select> |
| | | </mapper> |
| | |
| | | </select> |
| | | <select id="getShopStatistics" resultType="com.ruoyi.other.vo.ShopStatistics"> |
| | | SELECT |
| | | SUM(ts.shop_all_point) totalPoint, |
| | | SUM(ts.share_point) commissionPoint, |
| | | SUM(ts.server_point) servicePoint, |
| | | SUM(ts.lower_level_share_point) bindCommissionPoint, |
| | | SUM(ts.giveaway_all_money) totalCommissionMoney, |
| | | SUM(ts.giveaway_money) commissionMoney, |
| | | SUM(ts.lower_level_giveaway_money) bindCommissionMoney, |
| | | SUM(ts.server_giveaway_money) serviceCommissionMoney, |
| | | SUM(ts.shop_all_point + tt.shop_all_point) totalPoint, |
| | | SUM(ts.share_point + tt.share_point) commissionPoint, |
| | | SUM(ts.server_point + tt.server_point) servicePoint, |
| | | SUM(ts.lower_level_share_point + tt.lower_level_share_point) bindCommissionPoint, |
| | | SUM(ts.giveaway_all_money + tt.giveaway_all_money) totalCommissionMoney, |
| | | SUM(ts.giveaway_money + tt.giveaway_money) commissionMoney, |
| | | SUM(ts.lower_level_giveaway_money + tt.lower_level_giveaway_money) bindCommissionMoney, |
| | | SUM(ts.server_giveaway_money + tt.server_giveaway_money) serviceCommissionMoney, |
| | | SUM(ts.order_number) totalOrder, |
| | | SUM(ts.server_order_number) serviceOrder, |
| | | SUM(ts.custom_order_number) goodsOrder, |
| | | SUM(ts.can_withdraw_money) canWithdrawMoney, |
| | | SUM(ts.withdraw_money) alreadyWithdrawMoney |
| | | FROM |
| | | t_shop ts where ts.del_flag = 0 |
| | | t_shop ts |
| | | left join (select |
| | | shop_id, |
| | | ifnull(sum(shop_all_point), 0) as shop_all_point, |
| | | ifnull(sum(lower_level_share_point), 0) as lower_level_share_point, |
| | | ifnull(sum(share_point), 0) as share_point, |
| | | ifnull(sum(server_point), 0) as server_point, |
| | | ifnull(sum(giveaway_all_money), 0) as giveaway_all_money, |
| | | ifnull(sum(giveaway_money), 0) as giveaway_money, |
| | | ifnull(sum(lower_level_giveaway_money), 0) as lower_level_giveaway_money, |
| | | ifnull(sum(server_giveaway_money), 0) as server_giveaway_money |
| | | from t_shop_giveaway_temporary group by shop_id) tt on (ts.id = tt.shop_id) |
| | | where ts.del_flag = 0 |
| | | <if test="null != shopId"> |
| | | and ts.id = #{shopId} |
| | | </if> |
| | |
| | | tsp.type, |
| | | tsp.create_time, |
| | | tsp.variable_point, |
| | | tsp.change_direction, |
| | | tsp.order_num as orderNum |
| | | FROM |
| | | t_shop_point tsp |
| | | (select * from t_shop_point union all select * from t_shop_point_copy) tsp |
| | | LEFT JOIN t_shop ts ON tsp.shop_id = ts.id |
| | | <where> |
| | | <if test="shopPoint.shopName != null and shopPoint.shopName != ''"> |