From 810d81a44d78bc3e7c42c2f116cc9968ab04baef Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 07 二月 2025 15:57:28 +0800 Subject: [PATCH] 修改门店首页统计bug --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java | 230 +++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 167 insertions(+), 63 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java index ca0d70a..fd9ef5e 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java @@ -1,7 +1,9 @@ package com.ruoyi.other.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.poi.ExcelUtil; @@ -9,20 +11,24 @@ import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.domain.ShopBalanceStatement; import com.ruoyi.other.dto.ShopBalanceDto; +import com.ruoyi.other.mapper.ShopBalanceStatementMapper; import com.ruoyi.other.service.ShopBalanceStatementService; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.vo.ShopCommissionStatisticsVO; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.feignClient.SysUserClient; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Collection; +import java.util.List; import java.util.List; /** @@ -41,6 +47,16 @@ private ShopBalanceStatementService shopBalanceStatementService; @Resource private TokenService tokenService; + @Resource + private ShopBalanceStatementMapper shopBalanceStatementMapper; + @Resource + private ShopService shopService; + @Resource + private SysUserClient sysUserClient; + + + + /** * 门店分佣统计 @@ -53,65 +69,6 @@ ShopCommissionStatisticsVO shopCommissionStatisticsVO = shopBalanceStatementService.shopCommissionStatistics(Page.of(pageNum, pageSize), shopBalanceStatement); return R.ok(shopCommissionStatisticsVO); } - @GetMapping("/commissionStatistics/list") - @ApiOperation(value = "门店余额明细", notes = "门店余额明细", tags = {"门店后台"}) - public R<Page<ShopBalanceStatement>> shopCommissionStatisticslist(@ApiParam("页码") @RequestParam Integer pageNum, - @ApiParam("每一页数据大小") Integer pageSize, - ShopBalanceStatement shopBalanceStatement){ - Integer objectId = tokenService.getLoginUser().getSysUser().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)); - - return R.ok(page); - - - } - - @Resource - private ShopService shopService; - @GetMapping("/commissionStatistics/info") - @ApiOperation(value = "门店余额明细上方数据", notes = "门店余额明细", tags = {"门店后台"}) - public R<ShopBalanceDto> shopCommissionStatisticsinfo(){ - Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); - ShopBalanceDto dto = new ShopBalanceDto(); - 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, 4).list(); - BigDecimal bigDecimal1 = new BigDecimal(0); - for (ShopBalanceStatement shopBalanceStatement : list) { - bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); - } - for (ShopBalanceStatement shopBalanceStatement : list1) { - bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); - } - dto.setBigDecimal1(bigDecimal1); - - BigDecimal bigDecimal2= new BigDecimal(0); - for (ShopBalanceStatement shopBalanceStatement : list) { - bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); - } - dto.setBigDecimal2(bigDecimal2); - - BigDecimal bigDecimal3= new BigDecimal(0); - for (ShopBalanceStatement shopBalanceStatement : list1) { - bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); - } - dto.setBigDecimal3(bigDecimal3); - - List<ShopBalanceStatement> list2 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 2).list(); - BigDecimal bigDecimal4= new BigDecimal(0); - for (ShopBalanceStatement shopBalanceStatement : list2) { - bigDecimal4 = bigDecimal4.add(shopBalanceStatement.getVariableAmount()); - } - dto.setBigDecimal4(bigDecimal4); - - Shop byId = shopService.getById(objectId); - dto.setBigDecimal5(byId.getCanWithdrawMoney()); - dto.setBigDecimal6(byId.getWithdrawMoney()); - return R.ok(dto); - } - - /** * 导出门店分佣统计 */ @@ -123,6 +80,153 @@ ExcelUtil<ShopBalanceStatement> util = new ExcelUtil<>(ShopBalanceStatement.class); util.exportExcel(response, statementIPage.getRecords(), "用户积分统计"); } + @GetMapping("/commissionStatistics/list") + @ApiOperation(value = "门店余额明细", notes = "门店余额明细", tags = {"门店后台"}) + public R<Page<ShopBalanceStatement>> shopCommissionStatisticslist(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + ShopBalanceStatement shopBalanceStatement){ + Long userid = tokenService.getLoginUser().getUserid(); + 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)); + return R.ok(page); + + + } + + + @GetMapping("/commissionStatistics/info") + @ApiOperation(value = "门店余额明细上方数据", notes = "门店余额明细", tags = {"门店后台"}) + public R<ShopBalanceDto> shopCommissionStatisticsinfo(Integer type){ + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + ShopBalanceDto dto = new ShopBalanceDto(); + Shop byId = shopService.getById(objectId); + + 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(); + BigDecimal bigDecimal1 = new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list) { + bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); + } + for (ShopBalanceStatement shopBalanceStatement : list1) { + bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal1(bigDecimal1); + + BigDecimal bigDecimal2= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list) { + bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal2(bigDecimal2); + + BigDecimal bigDecimal3= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list1) { + bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal3(bigDecimal3); + + List<ShopBalanceStatement> list2 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 2).list(); + BigDecimal bigDecimal4= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list2) { + bigDecimal4 = bigDecimal4.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal4(bigDecimal4); + + dto.setBigDecimal5(byId.getCanWithdrawMoney()); + dto.setBigDecimal6(byId.getWithdrawMoney()); + return R.ok(dto); + }else{ + switch (type){ + case 1: + // 关联用户分拥 + BigDecimal bigDecimal = new BigDecimal("0"); + List<ShopBalanceStatement> list1 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 1).list(); + for (ShopBalanceStatement shopBalanceStatement : list1) { + bigDecimal = bigDecimal.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal3(bigDecimal); + dto.setBigDecimal1(bigDecimal); + break; + case 2: + // 下级门店分佣 + BigDecimal bigDecimal2= new BigDecimal(0); + List<ShopBalanceStatement> list2 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 2).list(); + for (ShopBalanceStatement shopBalanceStatement : list2) { + bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal4(bigDecimal2); + dto.setBigDecimal1(bigDecimal2); + break; + case 3: + // 服务费分佣 + List<ShopBalanceStatement> list = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 3).list(); + BigDecimal bigDecimal3= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list) { + bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal2(bigDecimal3); + dto.setBigDecimal1(bigDecimal3); + break; + case 4: + // 余额提现 + dto.setBigDecimal6(byId.getWithdrawMoney()); + break; + } + } + return R.ok(dto); + } + + + + + + + @PostMapping("/getList") + public R<List<ShopBalanceStatement>> getList(@RequestBody ShopBalanceStatement shopBalanceStatement){ + return R.ok(shopBalanceStatementMapper.selectShopBalanceStatementList(shopBalanceStatement)); + } + + + /** + * 保存门店余额流水 + * @param shopBalanceStatement + */ + @PostMapping("/saveShopBalanceStatement") + public void saveShopBalanceStatement(@RequestBody ShopBalanceStatement shopBalanceStatement){ + shopBalanceStatementService.save(shopBalanceStatement); + } + + + /** + * 获取门店流水数据 + * @param types + * @param objectId + * @return + */ + @PostMapping("/getShopBalanceStatementList") + public R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestParam("types") Collection<Integer> types, @RequestParam(value = "objectId",required = false) Long objectId){ + List<ShopBalanceStatement> list = shopBalanceStatementService.list(new LambdaQueryWrapper<ShopBalanceStatement>() + .eq(objectId != null,ShopBalanceStatement::getObjectId, objectId) + .in(types !=null && !types.isEmpty(),ShopBalanceStatement::getType, types)); + return R.ok(list); + } + + @PostMapping("/getShopBalanceStatementList2") + public R<List<ShopBalanceStatement>> getShopBalanceStatementList2(@RequestParam("type") Integer type, @RequestParam(value = "shopId") Integer shopId, + @RequestParam(value = "date") LocalDateTime date){ + LambdaQueryWrapper<ShopBalanceStatement> queryWrapper = new LambdaQueryWrapper<ShopBalanceStatement>() + .eq(ShopBalanceStatement::getType, type) + .between(ShopBalanceStatement::getCreateTime, date.with(LocalTime.MIN), date.with(LocalTime.MAX)); + if(null != shopId && 0 != shopId){ + queryWrapper.eq(ShopBalanceStatement::getShopId, shopId); + } + List<ShopBalanceStatement> list = shopBalanceStatementService.list(queryWrapper); + return R.ok(list); + } } -- Gitblit v1.7.1