feat:android交易统计
This commit is contained in:
1 parent
c7200ab438
commit
0388b83807
8 files changed
+48
-105
No files matched your search
+8
-49
@@ -1,62 +1,21 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSumAndCountVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardChartLatitudeVo {
|
||||
|
||||
@Schema(description = "早餐、中餐、晚餐")
|
||||
private String hourType;
|
||||
private List<HardOrderSumAndCountVo> dayTotal;
|
||||
|
||||
/**
|
||||
* 每天的交易量
|
||||
*/
|
||||
private Long dayCount = 0L;
|
||||
private List<HardOrderSumAndCountVo> weekTotal;
|
||||
|
||||
/**
|
||||
* 每天的交易金额
|
||||
*/
|
||||
private Long dayPrice = 0L;
|
||||
private List<HardOrderSumAndCountVo> monthTotal;
|
||||
|
||||
/**
|
||||
* 每周的交易量
|
||||
*/
|
||||
private Long weekCount = 0L;
|
||||
private List<HardOrderSumAndCountVo> yearTotal;
|
||||
|
||||
/**
|
||||
* 每周的交易
|
||||
*/
|
||||
private Long weekPrice = 0L;
|
||||
|
||||
/**
|
||||
* 每月的交易金额
|
||||
*/
|
||||
private Long monthCount = 0L;
|
||||
|
||||
/**
|
||||
* 每月的交易金额
|
||||
*/
|
||||
private Long monthPrice = 0L;
|
||||
|
||||
/**
|
||||
* 每年的交易金额
|
||||
*/
|
||||
private Long yearCount = 0L;
|
||||
|
||||
/**
|
||||
* 每年的交易金额
|
||||
*/
|
||||
private Long yearPrice = 0L;
|
||||
|
||||
/**
|
||||
* 全部交易量
|
||||
*/
|
||||
private Long totalCount = 0L;
|
||||
|
||||
/**
|
||||
* 全部交易金额
|
||||
*/
|
||||
private Long totalPrice = 0L;
|
||||
private List<HardOrderSumAndCountVo> allTotal;
|
||||
|
||||
}
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class HardApiController {
|
||||
|
||||
@GetMapping("/chart-latitude")
|
||||
@Operation(summary = "统计每天、每周、每月、每年的交易人数和次数")
|
||||
public R<List<HardChartLatitudeVo>> chartLatitude(@RequestParam Long merchantId) {
|
||||
public R<HardChartLatitudeVo> chartLatitude(@RequestParam Long merchantId) {
|
||||
return R.ok(hardOrderTotalService.chartLatitude(merchantId));
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -12,6 +12,8 @@ import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -78,6 +80,7 @@ public class HardOrderController {
|
||||
private final HardOrderMapper hardOrderMapper;
|
||||
|
||||
private final RemoteMchService mchService;
|
||||
private final RemoteUserService userService;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
@Inner
|
||||
@@ -135,19 +138,20 @@ public class HardOrderController {
|
||||
public R appMchPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
|
||||
dto.setIsFindCarList(false);
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
// 查询用户部门
|
||||
UserInfo userInfo = userService.getByUserId(user.getId()).getData();
|
||||
// 判断是否为合作超市管理员工
|
||||
if (!hardManagerService.isSuperMarketAdmin(user)) return R.ok(new Page());
|
||||
// 查询用户属于的商户
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(user.getDeptId()).getData();
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId()).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("该用户下不存在商户");
|
||||
// 查询商户和下面的子商户
|
||||
List<Long> mchDtoIds = new java.util.ArrayList<>(List.of(mch.getId()));
|
||||
List<MchManageVo> mchList = mchService.getByParentId(mch.getId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
|
||||
mchDtoIds.addAll(mchIds);
|
||||
dto.setMchIds(mchDtoIds);
|
||||
}
|
||||
// 查询子商户
|
||||
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
|
||||
mchDtoIds.addAll(mchIds);
|
||||
dto.setMchIds(mchDtoIds);
|
||||
return R.ok(hardwareOrderService.appMchPageJoin(page, dto, user));
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -9,6 +9,8 @@ import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
@@ -55,6 +57,7 @@ public class HardOrderTotalController {
|
||||
private final HardManagerService hardManagerService;
|
||||
|
||||
private final RemoteMchService mchService;
|
||||
private final RemoteUserService userService;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@@ -65,20 +68,21 @@ public class HardOrderTotalController {
|
||||
@GetMapping("/app/mch-water-day")
|
||||
public R appMchTotal(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
// 查询用户部门
|
||||
UserInfo userInfo = userService.getByUserId(user.getId()).getData();
|
||||
dto.setIsFindCarList(false);
|
||||
// 判断是否为合作超市管理员工
|
||||
if (!hardManagerService.isSuperMarketAdmin(user)) return R.ok(new Page());
|
||||
// 查询用户属于的商户
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(user.getDeptId()).getData();
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId()).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("该用户下不存在商户");
|
||||
List<Long> mchDtoIds = new ArrayList<>(List.of(mch.getId()));
|
||||
// 查询商户和下面的子商户
|
||||
List<MchManageVo> mchList = mchService.getByParentId(mch.getId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
|
||||
mchDtoIds.addAll(mchIds);
|
||||
dto.setMchIds(mchDtoIds);
|
||||
}
|
||||
// 查询子商户
|
||||
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
|
||||
mchDtoIds.addAll(mchIds);
|
||||
dto.setMchIds(mchDtoIds);
|
||||
return R.ok(hardOrderTotalService.listCsByDay(page, dto, user));
|
||||
}
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
+1
@@ -65,6 +65,7 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
.eqIfExists(HardOrderEntity::getPayType, dto.getPayType())
|
||||
.eqIfExists(HardOrderEntity::getOrderStatus, dto.getOrderStatus())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), HardOrderEntity::getUserId, dto.getUserIds())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getMchIds()), HardOrderEntity::getMerchantId, dto.getMchIds())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getMchTypeCodes()), HardOrderEntity::getMerchantType, dto.getMchTypeCodes())
|
||||
.orderByDesc(HardOrderEntity::getCreateTime)
|
||||
.orderByDesc(HardOrderEntity::getUserId);
|
||||
|
||||
+1
-1
@@ -44,5 +44,5 @@ public interface HardOrderTotalService {
|
||||
/**
|
||||
* 统计每天、每周、每月、每年的交易人数和次数
|
||||
*/
|
||||
List<HardChartLatitudeVo> chartLatitude(Long merchantId);
|
||||
HardChartLatitudeVo chartLatitude(Long merchantId);
|
||||
}
|
||||
+16
-41
@@ -488,13 +488,8 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
* 统计每天、每周、每月、每年的交易人数和次数
|
||||
*/
|
||||
@Override
|
||||
public List<HardChartLatitudeVo> chartLatitude(Long merchantId) {
|
||||
List<HardChartLatitudeVo> resultList = new LinkedList<>();
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
HardChartLatitudeVo hardChartLatitudeVo = new HardChartLatitudeVo();
|
||||
hardChartLatitudeVo.setHourType(String.valueOf(i));
|
||||
resultList.add(hardChartLatitudeVo);
|
||||
}
|
||||
public HardChartLatitudeVo chartLatitude(Long merchantId) {
|
||||
HardChartLatitudeVo result = new HardChartLatitudeVo();
|
||||
HardOrderSumAndCountDto dto = new HardOrderSumAndCountDto();
|
||||
dto.setMchIds(List.of(merchantId));
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
|
||||
@@ -526,8 +521,8 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
return hardOrderMapper.sumAndCountTotalByHourType(weekTotalDto);
|
||||
});
|
||||
// 每年
|
||||
LocalDate startOfYear = now.toLocalDate().minusYears(1).withDayOfYear(1);
|
||||
LocalDate endOfYear = now.toLocalDate().minusYears(1).withDayOfYear(now.toLocalDate().minusYears(1).lengthOfYear());
|
||||
LocalDate startOfYear = now.toLocalDate().withDayOfYear(1);
|
||||
LocalDate endOfYear = now.toLocalDate().withDayOfYear(now.toLocalDate().lengthOfYear());
|
||||
LocalDateTime startOfYearTime = startOfYear.atStartOfDay();
|
||||
LocalDateTime endOfYearTime = endOfYear.atTime(LocalTime.MAX);
|
||||
CompletableFuture<List<HardOrderSumAndCountVo>> yearTotalListFuture = CompletableFuture.supplyAsync(() -> {
|
||||
@@ -547,37 +542,17 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
List<HardOrderSumAndCountVo> monthTotalList = monthTotalListFuture.join();
|
||||
List<HardOrderSumAndCountVo> yearTotalList = yearTotalListFuture.join();
|
||||
List<HardOrderSumAndCountVo> totalList = totalListFuture.join();
|
||||
for (HardChartLatitudeVo v : resultList) {
|
||||
// 每天
|
||||
dayTotalList.stream().filter(i -> ObjectUtil.equals(i.getHourType(), v.getHourType())).findFirst().ifPresent(i -> {
|
||||
if (ObjectUtil.isNotEmpty(i.getCount())) v.setDayCount(i.getCount());
|
||||
if (ObjectUtil.isNotEmpty(i.getSum())) v.setDayPrice(i.getSum());
|
||||
});
|
||||
// 每周
|
||||
weekTotalList.stream().filter(i -> ObjectUtil.equals(i.getHourType(), v.getHourType())).findFirst().ifPresent(i -> {
|
||||
if (ObjectUtil.isNotEmpty(i.getCount())) v.setWeekCount(i.getCount());
|
||||
if (ObjectUtil.isNotEmpty(i.getSum())) v.setWeekPrice(i.getSum());
|
||||
});
|
||||
// 每月
|
||||
monthTotalList.stream().filter(i -> ObjectUtil.equals(i.getHourType(), v.getHourType())).findFirst().ifPresent(i -> {
|
||||
if (ObjectUtil.isNotEmpty(i.getCount())) v.setMonthCount(i.getCount());
|
||||
if (ObjectUtil.isNotEmpty(i.getSum())) v.setMonthPrice(i.getSum());
|
||||
});
|
||||
// 每年
|
||||
yearTotalList.stream().filter(i -> ObjectUtil.equals(i.getHourType(), v.getHourType())).findFirst().ifPresent(i -> {
|
||||
if (ObjectUtil.isNotEmpty(i.getCount())) v.setYearCount(i.getCount());
|
||||
if (ObjectUtil.isNotEmpty(i.getSum())) v.setYearPrice(i.getSum());
|
||||
});
|
||||
// 全部
|
||||
totalList.stream().filter(i -> ObjectUtil.equals(i.getHourType(), v.getHourType())).findFirst().ifPresent(i -> {
|
||||
if (ObjectUtil.isNotEmpty(i.getCount())) v.setTotalCount(i.getCount());
|
||||
if (ObjectUtil.isNotEmpty(i.getSum())) v.setTotalPrice(i.getSum());
|
||||
});
|
||||
}
|
||||
// 加入全部统计
|
||||
HardChartLatitudeVo total = BeanUtils.toBean(resultList.get(0), HardChartLatitudeVo.class);
|
||||
total.setHourType("-1");
|
||||
resultList.add(total);
|
||||
return resultList;
|
||||
|
||||
// 每天
|
||||
result.setDayTotal(dayTotalList);
|
||||
// 每周
|
||||
result.setWeekTotal(weekTotalList);
|
||||
// 每月
|
||||
result.setMonthTotal(monthTotalList);
|
||||
// 每年
|
||||
result.setYearTotal(yearTotalList);
|
||||
// 全部
|
||||
result.setAllTotal(totalList);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -244,7 +244,7 @@
|
||||
|
||||
<select id="listCsByDay" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
|
||||
select a.merchant_id,
|
||||
DATE_FORMAT(a.create_time, '%Y-%d-%m') as day,
|
||||
DATE_FORMAT(a.create_time, '%Y-%m-%d') as day,
|
||||
sum(a.pay_price) as totalPayPrice,
|
||||
count(0) as totalPayCount
|
||||
from hard_order a
|
||||
|
||||
Reference in new issue
Block a user