selectPayDetails app sql查询缩小查询范围

This commit is contained in:
张松
2025-01-02 19:51:24 +08:00
parent 5e4aaf78ce
commit eac53e57b0
6 changed files with 18 additions and 14 deletions

View File

@@ -197,7 +197,7 @@ public class CashController {
@ApiOperation("查询提现记录列表")
@ResponseBody
public Result selectHelpProfit(int page, int limit, CashOut cashOut) {
return Result.success().put("data", cashOutService.selectCashOutList(page, limit, cashOut));
return Result.success().put("data", cashOutService.selectCashOutList(page, limit, cashOut, false));
}
@RequestMapping(value = "/excelPayDetails", method = RequestMethod.GET)

View File

@@ -66,7 +66,7 @@ public class AppCashController {
public Result selectHelpProfit(int page, int limit, @RequestAttribute("userId") Long userId) {
CashOut cashOut = new CashOut();
cashOut.setUserId(userId);
PageUtils pageUtils = cashOutService.selectCashOutList(page, limit, cashOut);
PageUtils pageUtils = cashOutService.selectCashOutList(page, limit, cashOut, true);
return Result.success().put("data", pageUtils);
}

View File

@@ -42,7 +42,7 @@ public interface CashOutDao extends BaseMapper<CashOut> {
Double selectMayMoney(@Param("userId") Long userId);
IPage<CashOut> selectCashOutPage(Page<CashOut> page, CashOut cashOut);
IPage<CashOut> selectCashOutPage(Page<CashOut> page, CashOut cashOut,@Param("isApp") boolean isApp);
List<CashOut> selectCashOutList(@Param("cashOut") CashOut cashOut);

View File

@@ -13,7 +13,7 @@ import java.util.Map;
public interface CashOutService {
PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut);
PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut, boolean isApp);
ExcelData excelPayDetails(CashOut cashOut);

View File

@@ -106,8 +106,8 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
}
@Override
public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut) {
return new PageUtils(baseMapper.selectCashOutPage(new Page<>(page, limit), cashOut));
public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut, boolean isApp) {
return new PageUtils(baseMapper.selectCashOutPage(new Page<>(page, limit), cashOut, isApp));
}
@@ -550,7 +550,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
//cashOut.setState(3);
long pageNum = proxy.getLong(Constant.PAGE, 1L);
long pageSize = proxy.getLong(Constant.LIMIT, 10L);
IPage<CashOut> page = baseMapper.selectCashOutPage(new Page<>(pageNum, pageSize), cashOut);
IPage<CashOut> page = baseMapper.selectCashOutPage(new Page<>(pageNum, pageSize), cashOut, false);
return new PageUtils(page);
}

View File

@@ -48,16 +48,20 @@
<select id="selectCashOutPage" resultType="com.sqx.modules.pay.entity.CashOut">
SELECT c.*,
ifnull(u.user_name,"用户不存在") as userName,
s.username as sysUserName,
ifnull(t.total,0.00) as total,
ifnull(t.count,0) as count,
ifnull(t1.total,0.00) as verifyTotal,
ifnull(t1.count,0) as verifyCount
s.username as sysUserName
<if test="isApp == false">
,ifnull(t.total,0.00) as total,
ifnull(t.count,0) as count,
ifnull(t1.total,0.00) as verifyTotal,
ifnull(t1.count,0) as verifyCount
</if>
FROM cash_out c
left join tb_user u on c.user_id = u.user_id
left join sys_user s on s.user_id= c.sys_user_id
left join (select user_id,ROUND(sum(money),2) as total,count(*) as count from cash_out where state = 1 GROUP BY user_id) t on c.user_id = t.user_id
left join (select user_id,ROUND(sum(money),2) as total,count(*) as count from cash_out where state = 3 GROUP BY user_id) t1 on c.user_id = t1.user_id
<if test="isApp == false">
left join (select user_id,ROUND(sum(money),2) as total,count(*) as count from cash_out where state = 1 GROUP BY user_id) t on c.user_id = t.user_id
left join (select user_id,ROUND(sum(money),2) as total,count(*) as count from cash_out where state = 3 GROUP BY user_id) t1 on c.user_id = t1.user_id
</if>
<where>
<if test="cashOut.userName!=null and cashOut.userName!=''">
and u.user_name like concat("%",#{cashOut.userName},"%")