管理员中心recharge agency 汇总和列表接口修改
This commit is contained in:
parent
324b8dc2d5
commit
8bdbeabb5b
@ -7,6 +7,8 @@ import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
|||||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -59,7 +61,7 @@ public interface UserMonthlyRechargeClientApi {
|
|||||||
* 获取金币代理本月和上个月的充值汇总.
|
* 获取金币代理本月和上个月的充值汇总.
|
||||||
*/
|
*/
|
||||||
@GetMapping("/monthly-summary")
|
@GetMapping("/monthly-summary")
|
||||||
ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary();
|
ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary(@RequestParam("userIds") Set<Long> userIds);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,10 @@ package com.red.circle.order.infra.database.rds.dao.count;
|
|||||||
import com.red.circle.framework.mybatis.dao.BaseDAO;
|
import com.red.circle.framework.mybatis.dao.BaseDAO;
|
||||||
import com.red.circle.order.infra.database.rds.entity.count.UserMonthlyRecharge;
|
import com.red.circle.order.infra.database.rds.entity.count.UserMonthlyRecharge;
|
||||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -16,5 +18,5 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface UserMonthlyRechargeDAO extends BaseDAO<UserMonthlyRecharge> {
|
public interface UserMonthlyRechargeDAO extends BaseDAO<UserMonthlyRecharge> {
|
||||||
|
|
||||||
List<MonthlyRechargeSummaryVO> getMonthlyTotalRecharge();
|
List<MonthlyRechargeSummaryVO> getMonthlyTotalRecharge(@Param("userIds") Set<Long> userIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,5 +72,5 @@ public interface UserMonthlyRechargeService extends BaseService<UserMonthlyRecha
|
|||||||
/**
|
/**
|
||||||
* 当月和上个月 金币代理充值汇总
|
* 当月和上个月 金币代理充值汇总
|
||||||
*/
|
*/
|
||||||
List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary();
|
List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary(Set<Long> userIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,8 +184,8 @@ public class UserMonthlyRechargeServiceImpl extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary() {
|
public List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary(Set<Long> userIds) {
|
||||||
return userMonthlyRechargeDAO.getMonthlyTotalRecharge();
|
return userMonthlyRechargeDAO.getMonthlyTotalRecharge(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int nowThisMonth() {
|
private int nowThisMonth() {
|
||||||
|
|||||||
@ -14,6 +14,10 @@
|
|||||||
FROM user_monthly_recharge_v2 umr
|
FROM user_monthly_recharge_v2 umr
|
||||||
INNER JOIN likei_wallet.user_freight_balance ufb ON umr.user_id = ufb.user_id
|
INNER JOIN likei_wallet.user_freight_balance ufb ON umr.user_id = ufb.user_id
|
||||||
WHERE ufb.is_close = 0 -- 只查询未关闭的货运账户
|
WHERE ufb.is_close = 0 -- 只查询未关闭的货运账户
|
||||||
|
AND ufb.user_id IN
|
||||||
|
<foreach collection="userIds" open="(" separator="," close=")" item="userId">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
AND umr.recharge_date IN (
|
AND umr.recharge_date IN (
|
||||||
DATE_FORMAT(CURDATE(), '%Y%m'), -- 当月
|
DATE_FORMAT(CURDATE(), '%Y%m'), -- 当月
|
||||||
DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y%m') -- 上月
|
DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y%m') -- 上月
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
|||||||
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
|
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@ -68,8 +70,8 @@ public class UserMonthlyRechargeClientEndpoint implements UserMonthlyRechargeCli
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary() {
|
public ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary(Set<Long> userIds) {
|
||||||
return ResultResponse.success(userMonthlyRechargeClientService.getMonthlyRechargeSummary());
|
return ResultResponse.success(userMonthlyRechargeClientService.getMonthlyRechargeSummary(userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
|||||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 累计用户每月充值.
|
* 累计用户每月充值.
|
||||||
@ -43,7 +44,7 @@ public interface UserMonthlyRechargeClientService {
|
|||||||
/**
|
/**
|
||||||
* 批量获取用户上月充值.
|
* 批量获取用户上月充值.
|
||||||
*/
|
*/
|
||||||
List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary();
|
List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary(Set<Long> userIds);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
|||||||
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
|
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -62,8 +64,8 @@ public class UserMonthlyRechargeClientServiceImpl implements UserMonthlyRecharge
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary() {
|
public List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary(Set<Long> userIds) {
|
||||||
return userMonthlyRechargeService.getMonthlyRechargeSummary();
|
return userMonthlyRechargeService.getMonthlyRechargeSummary(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,41 +1,28 @@
|
|||||||
package com.red.circle.other.app.service.user.user;
|
package com.red.circle.other.app.service.user.user;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||||
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
import com.red.circle.framework.dto.PageQuery;
|
|
||||||
import com.red.circle.framework.dto.PageResult;
|
import com.red.circle.framework.dto.PageResult;
|
||||||
import com.red.circle.framework.dto.ResultResponse;
|
|
||||||
import com.red.circle.order.inner.endpoint.UserMonthlyRechargeClient;
|
import com.red.circle.order.inner.endpoint.UserMonthlyRechargeClient;
|
||||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||||
import com.red.circle.other.app.dto.h5.RechargeVO;
|
|
||||||
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
||||||
import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentBaseInfo;
|
import com.red.circle.other.infra.database.rds.dao.team.BusinessDevelopmentTeamDAO;
|
||||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||||
import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService;
|
|
||||||
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
|
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
|
||||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
|
||||||
import com.red.circle.tool.core.date.LocalDateUtils;
|
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
|
||||||
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
|
|
||||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd;
|
|
||||||
import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.util.HashSet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -43,10 +30,9 @@ import java.util.stream.Collectors;
|
|||||||
public class RechargeUserServiceImpl implements RechargeUserService {
|
public class RechargeUserServiceImpl implements RechargeUserService {
|
||||||
|
|
||||||
private final UserMonthlyRechargeClient userMonthlyRechargeClient;
|
private final UserMonthlyRechargeClient userMonthlyRechargeClient;
|
||||||
private final FreightGoldClient freightGoldClient;
|
|
||||||
private final UserProfileClient userProfileClient;
|
private final UserProfileClient userProfileClient;
|
||||||
private final AdministratorService administratorService;
|
private final AdministratorService administratorService;
|
||||||
private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService;
|
private final BusinessDevelopmentTeamDAO businessDevelopmentTeamDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd) {
|
public PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd) {
|
||||||
@ -55,54 +41,50 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
|||||||
ResponseAssert.failure(CommonErrorCode.OPERATING_FAILURE);
|
ResponseAssert.failure(CommonErrorCode.OPERATING_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> collect = getBdGoldUserIdList(cmd);
|
Page<Object> objectPage = new Page<>();
|
||||||
if (collect == null) return null;
|
objectPage.setCurrent(page.getPageQuery().getCursor());
|
||||||
|
objectPage.setSize(page.getPageQuery().getLimit());
|
||||||
|
Page<Long> pagedRechargeAgency = businessDevelopmentTeamDAO.pageRechargeAgency(cmd.getReqUserId(), objectPage);
|
||||||
|
if (pagedRechargeAgency == null || pagedRechargeAgency.getRecords().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Map<Long, BigDecimal> userMonthlyAmountMap = getThisMonthRechargeAmount(collect);
|
List<Long> collect = pagedRechargeAgency.getRecords().stream().toList();
|
||||||
Map<Long, BigDecimal> userLastMonthAmountMap = getLastMonthRechargeAmount(collect);
|
Map<Long, BigDecimal> userMonthlyAmountMap = getThisMonthRechargeAmount(collect);
|
||||||
|
Map<Long, BigDecimal> userLastMonthAmountMap = getLastMonthRechargeAmount(collect);
|
||||||
|
|
||||||
List<RechargePageVO> list = collect.stream().map(userId -> {
|
List<RechargePageVO> list = pagedRechargeAgency.getRecords().stream().map(userId -> {
|
||||||
UserProfileDTO body = userProfileClient.getByUserId(userId).getBody();
|
UserProfileDTO body = userProfileClient.getByUserId(userId).getBody();
|
||||||
return new RechargePageVO()
|
return new RechargePageVO()
|
||||||
.setUserId(userId)
|
.setUserId(userId)
|
||||||
.setAccount(body.getAccount())
|
.setAccount(body.getAccount())
|
||||||
.setUserNickname(body.getUserNickname())
|
.setUserNickname(body.getUserNickname())
|
||||||
.setUserAvatar(body.getUserAvatar())
|
.setUserAvatar(body.getUserAvatar())
|
||||||
.setThisMonth(userMonthlyAmountMap.get(userId))
|
.setThisMonth(userMonthlyAmountMap.get(userId))
|
||||||
.setLastMonth(userLastMonthAmountMap.get(userId));
|
.setLastMonth(userLastMonthAmountMap.get(userId));
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
PageResult<RechargePageVO> result = PageResult.newPageResult(list.size());
|
PageResult<RechargePageVO> result = PageResult.newPageResult(list.size());
|
||||||
result.setCurrent(1L);
|
result.setCurrent(pagedRechargeAgency.getCurrent());
|
||||||
result.setTotal(list.size());
|
result.setTotal(pagedRechargeAgency.getTotal());
|
||||||
result.setRecords(list);
|
result.setSize(pagedRechargeAgency.getSize());
|
||||||
return result;
|
result.setRecords(list);
|
||||||
}
|
return result;
|
||||||
|
|
||||||
private List<Long> getBdGoldUserIdList(AppExtCommand cmd) {
|
|
||||||
List<BusinessDevelopmentBaseInfo> bdList = businessDevelopmentBaseInfoService.query()
|
|
||||||
.eq(BusinessDevelopmentBaseInfo::getSysOrigin, cmd.getReqSysOrigin().getOrigin())
|
|
||||||
.eq(BusinessDevelopmentBaseInfo::getBdLeadUserId, cmd.getReqUserId())
|
|
||||||
.orderByDesc(BusinessDevelopmentBaseInfo::getCreateTime)
|
|
||||||
.list();
|
|
||||||
if (bdList.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Long> collect = bdList.stream().map(e -> {
|
|
||||||
UserFreightBalanceDTO result = freightGoldClient.getByUserId(e.getUserId()).getBody();
|
|
||||||
return result != null ? result.getUserId() : null;
|
|
||||||
}).filter(Objects::nonNull).toList();
|
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(collect)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return collect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MonthlyRechargeSummaryVO> getRechargeSummary(AppExtCommand cmd) {
|
public List<MonthlyRechargeSummaryVO> getRechargeSummary(AppExtCommand cmd) {
|
||||||
return userMonthlyRechargeClient.getMonthlyRechargeSummary().getBody();
|
|
||||||
|
Page<Object> objectPage = new Page<>();
|
||||||
|
objectPage.setCurrent(1L);
|
||||||
|
objectPage.setSize(3000L);
|
||||||
|
Page<Long> pagedRechargeAgency = businessDevelopmentTeamDAO.pageRechargeAgency(cmd.getReqUserId(), objectPage);
|
||||||
|
if (pagedRechargeAgency == null || pagedRechargeAgency.getRecords().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> collect = new HashSet<>(pagedRechargeAgency.getRecords());
|
||||||
|
return userMonthlyRechargeClient.getMonthlyRechargeSummary(collect).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Long, BigDecimal> getThisMonthRechargeAmount(List<Long> collect) {
|
private Map<Long, BigDecimal> getThisMonthRechargeAmount(List<Long> collect) {
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package com.red.circle.other.infra.database.rds.dao.team;
|
package com.red.circle.other.infra.database.rds.dao.team;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.red.circle.framework.mybatis.dao.BaseDAO;
|
import com.red.circle.framework.mybatis.dao.BaseDAO;
|
||||||
import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentTeam;
|
import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentTeam;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,4 +26,9 @@ public interface BusinessDevelopmentTeamDAO extends BaseDAO<BusinessDevelopmentT
|
|||||||
*/
|
*/
|
||||||
BigDecimal countAgentTotalTarget(@Param("userId") Long userId,
|
BigDecimal countAgentTotalTarget(@Param("userId") Long userId,
|
||||||
@Param("dateNumber") Integer dateNumber);
|
@Param("dateNumber") Integer dateNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bd下的金币代理(排除自己的)
|
||||||
|
*/
|
||||||
|
Page<Long> pageRechargeAgency(@Param("userId") Long userId, @Param("page")Page page);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,4 +12,10 @@
|
|||||||
AND rbdt.user_id = #{userId}
|
AND rbdt.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="pageRechargeAgency" resultType="java.lang.Long">
|
||||||
|
SELECT ufb.user_id
|
||||||
|
FROM room_business_development_team bdt
|
||||||
|
INNER JOIN likei_wallet.user_freight_balance ufb ON bdt.agent_id = ufb.user_id
|
||||||
|
WHERE bdt.user_id = #{userId} AND ufb.user_id != #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user