feat(金币代理): 新增金币代理当月上月统计
This commit is contained in:
parent
15d93eacec
commit
04502b5685
@ -3,6 +3,7 @@ package com.red.circle.order.inner.endpoint.api;
|
||||
import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeDatesQryCmd;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeQryCmd;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -54,4 +55,11 @@ public interface UserMonthlyRechargeClientApi {
|
||||
@GetMapping("/listLastMonthByIds")
|
||||
ResultResponse<List<UserMonthlyRechargeDTO>> listLastMonthByIds(@RequestParam("userIds") List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 获取金币代理本月和上个月的充值汇总.
|
||||
*/
|
||||
@GetMapping("/monthly-summary")
|
||||
ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.red.circle.order.inner.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 月度充值汇总VO
|
||||
*
|
||||
* @author
|
||||
* @date
|
||||
*/
|
||||
@Data
|
||||
public class MonthlyRechargeSummaryVO {
|
||||
|
||||
/**
|
||||
* 充值月份显示
|
||||
*/
|
||||
private String rechargeMonth;
|
||||
|
||||
/**
|
||||
* 充值日期
|
||||
*/
|
||||
private Integer rechargeDate;
|
||||
|
||||
/**
|
||||
* 充值用户数量
|
||||
*/
|
||||
private Long userCount;
|
||||
|
||||
/**
|
||||
* 总充值金额
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
}
|
||||
@ -2,6 +2,9 @@ package com.red.circle.order.infra.database.rds.dao.count;
|
||||
|
||||
import com.red.circle.framework.mybatis.dao.BaseDAO;
|
||||
import com.red.circle.order.infra.database.rds.entity.count.UserMonthlyRecharge;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -13,4 +16,5 @@ import com.red.circle.order.infra.database.rds.entity.count.UserMonthlyRecharge;
|
||||
*/
|
||||
public interface UserMonthlyRechargeDAO extends BaseDAO<UserMonthlyRecharge> {
|
||||
|
||||
List<MonthlyRechargeSummaryVO> getMonthlyTotalRecharge();
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.red.circle.order.infra.database.rds.service.count;
|
||||
|
||||
import com.red.circle.framework.mybatis.service.BaseService;
|
||||
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.enums.MonthlyRechargeType;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@ -68,4 +69,8 @@ public interface UserMonthlyRechargeService extends BaseService<UserMonthlyRecha
|
||||
*/
|
||||
List<UserMonthlyRecharge> listLastMonthByIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 当月和上个月 金币代理充值汇总
|
||||
*/
|
||||
List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import com.red.circle.order.infra.database.rds.dao.count.UserMonthlyRechargeDAO;
|
||||
import com.red.circle.order.infra.database.rds.entity.count.UserMonthlyRecharge;
|
||||
import com.red.circle.order.infra.database.rds.service.count.UserMonthlyRechargeService;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.date.LocalDateUtils;
|
||||
@ -36,6 +37,8 @@ public class UserMonthlyRechargeServiceImpl extends
|
||||
BaseServiceImpl<UserMonthlyRechargeDAO, UserMonthlyRecharge> implements
|
||||
UserMonthlyRechargeService {
|
||||
|
||||
private final UserMonthlyRechargeDAO userMonthlyRechargeDAO;
|
||||
|
||||
@Override
|
||||
public void incrThisMonthAmount(Long userId, BigDecimal amount, MonthlyRechargeType type) {
|
||||
UserMonthlyRecharge userMonthlyRecharge = query()
|
||||
@ -180,6 +183,11 @@ public class UserMonthlyRechargeServiceImpl extends
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary() {
|
||||
return userMonthlyRechargeDAO.getMonthlyTotalRecharge();
|
||||
}
|
||||
|
||||
private int nowThisMonth() {
|
||||
return LocalDateUtils.nowThisMonthToInteger();
|
||||
}
|
||||
|
||||
@ -4,4 +4,22 @@
|
||||
<mapper
|
||||
namespace="com.red.circle.order.infra.database.rds.dao.count.UserMonthlyRechargeDAO">
|
||||
|
||||
<select id="getMonthlyTotalRecharge" resultType="com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO">
|
||||
SELECT
|
||||
DATE_FORMAT(STR_TO_DATE(CONCAT(umr.recharge_date, '01'), '%Y%m%d'), '%Y年%m月') AS recharge_month,
|
||||
umr.recharge_date,
|
||||
COUNT(DISTINCT umr.user_id) AS user_count,
|
||||
SUM(umr.amount) AS total_amount,
|
||||
AVG(umr.amount) AS avg_amount
|
||||
FROM user_monthly_recharge_v2 umr
|
||||
INNER JOIN likei_wallet.user_freight_balance ufb ON umr.user_id = ufb.user_id
|
||||
WHERE ufb.is_close = 0 -- 只查询未关闭的货运账户
|
||||
AND umr.recharge_date IN (
|
||||
DATE_FORMAT(CURDATE(), '%Y%m'), -- 当月
|
||||
DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y%m') -- 上月
|
||||
)
|
||||
GROUP BY umr.recharge_date
|
||||
ORDER BY umr.recharge_date DESC;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -4,6 +4,7 @@ import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.order.inner.endpoint.api.UserMonthlyRechargeClientApi;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeDatesQryCmd;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeQryCmd;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
|
||||
import java.util.List;
|
||||
@ -66,4 +67,9 @@ public class UserMonthlyRechargeClientEndpoint implements UserMonthlyRechargeCli
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary() {
|
||||
return ResultResponse.success(userMonthlyRechargeClientService.getMonthlyRechargeSummary());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.red.circle.order.inner.service;
|
||||
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeDatesQryCmd;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeQryCmd;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -39,4 +40,10 @@ public interface UserMonthlyRechargeClientService {
|
||||
*/
|
||||
List<UserMonthlyRechargeDTO> listLastMonthByIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 批量获取用户上月充值.
|
||||
*/
|
||||
List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.red.circle.order.infra.database.rds.service.count.UserMonthlyRecharge
|
||||
import com.red.circle.order.inner.convertor.UserMonthlyRechargeInnerConvertor;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeDatesQryCmd;
|
||||
import com.red.circle.order.inner.model.cmd.MonthlyRechargeQryCmd;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
|
||||
import java.util.List;
|
||||
@ -60,4 +61,9 @@ public class UserMonthlyRechargeClientServiceImpl implements UserMonthlyRecharge
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonthlyRechargeSummaryVO> getMonthlyRechargeSummary() {
|
||||
return userMonthlyRechargeService.getMonthlyRechargeSummary();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.red.circle.framework.web.controller.BaseController;
|
||||
import com.red.circle.order.inner.endpoint.UserFreightRechargeRecordClient;
|
||||
import com.red.circle.order.inner.endpoint.UserMonthlyRechargeClient;
|
||||
import com.red.circle.order.inner.endpoint.api.UserMonthlyRechargeClientApi;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.other.app.dto.h5.MemberActiveDTO;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
import com.red.circle.other.app.dto.h5.UserIdentityVO;
|
||||
@ -18,6 +19,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping(value = "/app/h5/", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ -62,4 +65,12 @@ public class MemberActiveController extends BaseController {
|
||||
return rechargeUserService.getRechargePage(page, cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 货运代理充值月度汇总(当月,上月)
|
||||
*/
|
||||
@GetMapping("/recharge-summary")
|
||||
public List<MonthlyRechargeSummaryVO> rechargeSummary(AppExtCommand cmd) {
|
||||
return rechargeUserService.getRechargeSummary(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.red.circle.framework.dto.PageQuery;
|
||||
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.model.dto.MonthlyRechargeSummaryVO;
|
||||
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.RechargeVO;
|
||||
@ -48,8 +49,6 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
}
|
||||
|
||||
UserFreightBalancePageQryCmd qryCmd = new UserFreightBalancePageQryCmd();
|
||||
qryCmd.setClose(false);
|
||||
qryCmd.setDisplay(false);
|
||||
qryCmd.setSysOrigin(cmd.getReqSysOrigin().getOrigin());
|
||||
qryCmd.setPageQuery(page.getPageQuery());
|
||||
PageResult<UserFreightBalanceDTO> pageResult = freightGoldClient.pageFreight(qryCmd).getBody();
|
||||
@ -76,6 +75,11 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonthlyRechargeSummaryVO> getRechargeSummary(AppExtCommand cmd) {
|
||||
return userMonthlyRechargeClient.getMonthlyRechargeSummary().getBody();
|
||||
}
|
||||
|
||||
private Map<Long, BigDecimal> getThisMonthRechargeAmount(List<Long> collect) {
|
||||
List<UserMonthlyRechargeDTO> recharges = userMonthlyRechargeClient.listThisMonthByIds(collect).getBody();
|
||||
return getLongBigDecimalMap(recharges);
|
||||
|
||||
@ -3,8 +3,11 @@ package com.red.circle.other.app.service.recharge;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RechargeUserService {
|
||||
|
||||
/**
|
||||
@ -12,4 +15,5 @@ public interface RechargeUserService {
|
||||
*/
|
||||
PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd);
|
||||
|
||||
List<MonthlyRechargeSummaryVO> getRechargeSummary(AppExtCommand cmd);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user