| | |
| | | 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.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | 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); |
| | | |
| | | |
| | |
| | | if (type == null) { |
| | | List<ShopBalanceStatement> list = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(ShopBalanceStatement::getType, 3).list(); |
| | | List<ShopBalanceStatement> list1 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(ShopBalanceStatement::getType, 1).list(); |
| | | List<ShopBalanceStatementCopy> list3 = shopBalanceStatementCopyMapper.selectList(new LambdaQueryWrapper<ShopBalanceStatementCopy>().eq(ShopBalanceStatementCopy::getShopId, objectId).eq(ShopBalanceStatementCopy::getType, 3)); |
| | | List<ShopBalanceStatementCopy> list4 = shopBalanceStatementCopyMapper.selectList(new LambdaQueryWrapper<ShopBalanceStatementCopy>().eq(ShopBalanceStatementCopy::getShopId, objectId).eq(ShopBalanceStatementCopy::getType, 1)); |
| | | |
| | | BigDecimal bigDecimal1 = new BigDecimal(0); |
| | | for (ShopBalanceStatement shopBalanceStatement : list) { |
| | | bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list3) { |
| | | bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatement shopBalanceStatement : list1) { |
| | | bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list4) { |
| | | bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal1(bigDecimal1); |
| | |
| | | for (ShopBalanceStatement shopBalanceStatement : list) { |
| | | bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list3) { |
| | | bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal2(bigDecimal2); |
| | | |
| | | BigDecimal bigDecimal3 = new BigDecimal(0); |
| | | for (ShopBalanceStatement shopBalanceStatement : list1) { |
| | | bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list4) { |
| | | bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal3(bigDecimal3); |
| | | |
| | | List<ShopBalanceStatement> list2 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(ShopBalanceStatement::getType, 2).list(); |
| | | List<ShopBalanceStatementCopy> list5 = shopBalanceStatementCopyMapper.selectList(new LambdaQueryWrapper<ShopBalanceStatementCopy>().eq(ShopBalanceStatementCopy::getShopId, objectId).eq(ShopBalanceStatementCopy::getType, 2)); |
| | | BigDecimal bigDecimal4 = new BigDecimal(0); |
| | | for (ShopBalanceStatement shopBalanceStatement : list2) { |
| | | bigDecimal4 = bigDecimal4.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list5) { |
| | | bigDecimal4 = bigDecimal4.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal4(bigDecimal4); |
| | |
| | | // 关联用户分拥 |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | List<ShopBalanceStatement> list1 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(ShopBalanceStatement::getType, 1).list(); |
| | | List<ShopBalanceStatementCopy> list4 = shopBalanceStatementCopyMapper.selectList(new LambdaQueryWrapper<ShopBalanceStatementCopy>().eq(ShopBalanceStatementCopy::getShopId, objectId).eq(ShopBalanceStatementCopy::getType, 1)); |
| | | for (ShopBalanceStatement shopBalanceStatement : list1) { |
| | | bigDecimal = bigDecimal.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list4) { |
| | | bigDecimal = bigDecimal.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal3(bigDecimal); |
| | |
| | | // 下级门店分佣 |
| | | BigDecimal bigDecimal2 = new BigDecimal(0); |
| | | List<ShopBalanceStatement> list2 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(ShopBalanceStatement::getType, 2).list(); |
| | | List<ShopBalanceStatementCopy> list5 = shopBalanceStatementCopyMapper.selectList(new LambdaQueryWrapper<ShopBalanceStatementCopy>().eq(ShopBalanceStatementCopy::getShopId, objectId).eq(ShopBalanceStatementCopy::getType, 2)); |
| | | for (ShopBalanceStatement shopBalanceStatement : list2) { |
| | | bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list5) { |
| | | bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal4(bigDecimal2); |
| | |
| | | case 3: |
| | | // 服务费分佣 |
| | | List<ShopBalanceStatement> list = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(ShopBalanceStatement::getType, 3).list(); |
| | | List<ShopBalanceStatementCopy> list6 = shopBalanceStatementCopyMapper.selectList(new LambdaQueryWrapper<ShopBalanceStatementCopy>().eq(ShopBalanceStatementCopy::getShopId, objectId).eq(ShopBalanceStatementCopy::getType, 3)); |
| | | BigDecimal bigDecimal3 = new BigDecimal(0); |
| | | for (ShopBalanceStatement shopBalanceStatement : list) { |
| | | bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | for (ShopBalanceStatementCopy shopBalanceStatement : list6) { |
| | | bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); |
| | | } |
| | | dto.setBigDecimal2(bigDecimal3); |
| | |
| | | .eq(ShopBalanceStatementCopy::getObjectId, orderId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @DeleteMapping("/deleteShopBalanceStatementCopyByIds") |
| | | public R<Boolean> deleteShopBalanceStatementCopyByIds(@RequestParam("ids") List<Long> ids){ |
| | | shopBalanceStatementCopyMapper.deleteBatchIds(ids); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/getShopBalanceStatementCopy") |
| | | public R<List<ShopBalanceStatementCopy>> getShopBalanceStatementCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type) { |
| | |
| | | .between(ShopBalanceStatement::getCreateTime, date.with(LocalTime.MIN), date.with(LocalTime.MAX)); |
| | | if (null != shopId && 0 != shopId) { |
| | | queryWrapper.eq(ShopBalanceStatement::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){ |
| | | queryWrapper.in(ShopBalanceStatement::getShopId, shipIds); |
| | | }else{ |
| | | queryWrapper.eq(ShopBalanceStatement::getShopId, -1); |
| | | } |
| | | } |
| | | 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); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("getShopCommission") |
| | | @ApiOperation(value = "获取门店佣金", notes = "获取门店佣金", tags = {"小程序-个人中心-门店管理-门店钱包"}) |
| | | @Transactional |
| | | public R<ShopCommission> getShopCommission(@RequestParam("shopId") Integer shopId) { |
| | | // 合并查询逻辑 |
| | | List<ShopBalanceStatementCopy> copies = shopBalanceStatementCopyMapper.selectList( |
| | |
| | | |
| | | // 合并计算 |
| | | 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); |
| | | } |
| | | |
| | |
| | | detail.setTime(copy.getCreateTime()); |
| | | detail.setAmount(copy.getVariableAmount()); |
| | | |
| | | BigDecimal beforeAmount = copy.getHistoricalBalance(); |
| | | BigDecimal afterAmount = copy.getBalance(); |
| | | if (beforeAmount.compareTo(afterAmount) > 0) { |
| | | if (copy.getChangeDirection() == -1) { |
| | | detail.setType(2); |
| | | } else { |
| | | detail.setType(1); |
| | |
| | | detail.setTime(statement.getCreateTime()); |
| | | detail.setAmount(statement.getVariableAmount()); |
| | | |
| | | BigDecimal beforeAmount = statement.getHistoricalBalance(); |
| | | BigDecimal afterAmount = statement.getBalance(); |
| | | if (beforeAmount.compareTo(afterAmount) > 0) { |
| | | if (statement.getChangeDirection() == -1) { |
| | | detail.setType(2); |
| | | } else { |
| | | detail.setType(1); |