@Select("SELECT COUNT(id) AS total_orders\n" + "FROM eb_store_order;")
int totalOrder();
@Select("SELECT SUM(pay_price) AS total_income\n" + "FROM eb_store_order;")
Integer totalIncome();
@Select("SELECT COUNT(id) AS total_reviews\n" + "FROM eb_store_product_reply\n" + "WHERE is_del = 0;")
Integer totalEvaluation();
@Select("SELECT COUNT(id) AS total_refunds\n" + "FROM eb_store_order\n" + "WHERE refund_status = 2;")
Integer totalRefund();
/**
* 宠物类型折线图数据
* @return
*/
List<PetTypeResponse> petType();
List<PrimaryServiceResponse> PrimaryService();
List<AdditionalServiceResponse> AdditionalService();
@Override
public OrderStatisticsAllResponse totalDate() {
OrderStatisticsAllResponse allResponse = new OrderStatisticsAllResponse();
OrderStatisticsResponse orderResponse = new OrderStatisticsResponse();
orderResponse.setTotalOrder(orderStatisticsDao.totalOrder());
orderResponse.setTotalIncome(orderStatisticsDao.totalIncome());
orderResponse.setTotalEvaluation(orderStatisticsDao.totalEvaluation());
orderResponse.setTotalRefund(orderStatisticsDao.totalRefund());
//这部分代码创建了一个只包含一个元素的列表,其中这个唯一的元素就是 orderResponse 对象。
allResponse.setTotalOrder(Collections.singletonList(orderResponse));
allResponse.setPetTypeLine(orderStatisticsDao.petType());
//主要业务
allResponse.setPrimaryTypeLine(orderStatisticsDao.PrimaryService());
//附加业务
allResponse.setAdditionalTypeLine(orderStatisticsDao.AdditionalService());
return allResponse;
}
@Override
public StatisticsMemberDefaultResponse StatisticsMemberDefault(String timeRangeType) {
StatisticsMemberDefaultResponse response = new StatisticsMemberDefaultResponse();
response.setKcxftjYear(membershipTotal());
response.setKslxtjYear(thisWeek());
response.setDbpjMajorId(getPresetTimeRangeActivity(timeRangeType));
response.setBkhkMajorId(countUsersPerCity());
response.setKsfbMajorId(calculateAgeGroupStatistics());
return response;
}
@Override
public MembershipStatisticsResponse membershipTotal() {
MembershipStatisticsResponse Response = new MembershipStatisticsResponse();
Response.setNewMembersThisWeek(statisticsMembershipDao.newMembersThisWeek());
Response.setGrowthRateLastWeek(statisticsMembershipDao.growthRateLastWeek());
Response.setAverageSpendingAmount(statisticsMembershipDao.averageSpendingAmount());
Response.setTotalRegisteredMembers(statisticsMembershipDao.totalRegisteredMembers());
Response.setAverageOrderCount(statisticsMembershipDao.averageOrderCount());
Response.setPaidMemberRate(statisticsMembershipDao.paidMemberRate());
Response.setAverageOrderAmount(statisticsMembershipDao.averageOrderAmount());
Response.setAverageAge(calculateAverageAge());
return Response;
}
@Override
public List<NewMembershipStatisticsResponse> today() {
return statisticsNewMembershipDao.today();
}
@Override
public List<NewMembershipStatisticsResponse> thisWeek() {
return statisticsNewMembershipDao.thisWeek();
}
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="StatisticsMemberDefaultResponse", description="会员默认返回数据对象")
public class StatisticsMemberDefaultResponse {
@ApiModelProperty(value = "会员总数等数据")
MembershipStatisticsResponse kcxftjYear;
@ApiModelProperty(value = "本周新增会员数量")
List<NewMembershipStatisticsResponse> kslxtjYear;
@ApiModelProperty(value = "获取预设时间范围内的活跃会员数today,thisWeek,thisMonth")
List<Map<String, Object>> dbpjMajorId;
@ApiModelProperty(value = "获取每个城市的人数")
List<Map<String, Object>> bkhkMajorId;
@ApiModelProperty(value = "获取每个年龄段的人数")
List<AgeGroupStatisticsResponse> ksfbMajorId;
}