体现记录接口修改
This commit is contained in:
parent
acb3e97e5a
commit
362e99c8c9
|
|
@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -44,4 +45,5 @@ public interface CashOutDao extends BaseMapper<CashOut> {
|
|||
|
||||
BigDecimal selectSumMoney(@Param("userId") Long userId, @Param("state") Integer state);
|
||||
|
||||
List<CashOut> selectSumByUserIdList(ArrayList<Long> userIdList, Integer state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.date.DateUtil;
|
|||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -107,8 +108,54 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||
|
||||
@Override
|
||||
public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut,@Param("isApp") boolean isApp) {
|
||||
LambdaQueryWrapper<CashOut> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (isApp) {
|
||||
queryWrapper.eq(CashOut::getUserId, cashOut.getUserId());
|
||||
}
|
||||
|
||||
if (!isApp && cashOut.getUserId() != null) {
|
||||
queryWrapper.eq(CashOut::getUserId, cashOut.getUserId());
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, limit);
|
||||
return PageUtils.page(new PageInfo<>(baseMapper.selectCashOutPage(cashOut, isApp)));
|
||||
List<CashOut> cashOutList = list(queryWrapper);
|
||||
|
||||
if (!isApp) {
|
||||
ArrayList<Long> userIdList = new ArrayList<>();
|
||||
for (CashOut out : cashOutList) {
|
||||
userIdList.add(out.getUserId());
|
||||
}
|
||||
|
||||
// 查询用户提现总数和总金额
|
||||
Map<Long, CashOut> cashoutSumMap = new HashMap<>();
|
||||
Map<Long, CashOut> cashoutVerifySumMap = new HashMap<>();
|
||||
Map<Long, String> userinfoMap = new HashMap<>();
|
||||
if (!userIdList.isEmpty()) {
|
||||
cashoutSumMap = cashOutDao.selectSumByUserIdList(userIdList, 1).stream().collect(Collectors.toMap(CashOut::getUserId, item -> item));
|
||||
cashoutVerifySumMap = cashOutDao.selectSumByUserIdList(userIdList, 3).stream().collect(Collectors.toMap(CashOut::getUserId, item -> item));
|
||||
userinfoMap = userDao.selectList(new LambdaQueryWrapper<UserEntity>().in(UserEntity::getUserId, userIdList).select(UserEntity::getUserId, UserEntity::getUserName))
|
||||
.stream().collect(Collectors.toMap(UserEntity::getUserId, UserEntity::getUserName));
|
||||
}
|
||||
|
||||
for (CashOut item : cashOutList) {
|
||||
CashOut info = cashoutSumMap.get(item.getUserId());
|
||||
CashOut info2 = cashoutVerifySumMap.get(item.getUserId());
|
||||
item.setUserName(userinfoMap.get(item.getUserId()));
|
||||
|
||||
if (info != null) {
|
||||
item.setCount(info.getCount());
|
||||
item.setTotal(info.getTotal());
|
||||
}
|
||||
|
||||
if (info2 != null) {
|
||||
item.setVerifyCount(info2.getCount());
|
||||
item.setVerifyTotal(info2.getTotal());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return PageUtils.page(new PageInfo<>(cashOutList));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -45,6 +45,22 @@
|
|||
select money from user_money where user_id=#{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectSumByUserIdList" resultType="com.sqx.modules.pay.entity.CashOut">
|
||||
SELECT
|
||||
user_id,
|
||||
ROUND( sum( money ), 2 ) AS total,
|
||||
count(*) AS count
|
||||
FROM
|
||||
cash_out
|
||||
WHERE
|
||||
state = #{state}
|
||||
and user_id in
|
||||
<foreach collection="userIdList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
user_id
|
||||
</select>
|
||||
<select id="selectCashOutPage" resultType="com.sqx.modules.pay.entity.CashOut">
|
||||
SELECT c.*,
|
||||
ifnull(u.user_name,"用户不存在") as userName,
|
||||
|
|
@ -172,4 +188,5 @@
|
|||
select format(sum(money),2) from cash_out where state = #{state} and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue