feat:商户交易记录(按月)表格
This commit is contained in:
1 parent
780279b936
commit
df99986af6
6 files changed
+233
-9
No files matched your search
+17
@@ -0,0 +1,17 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardSelectOrderMerchIdsDto {
|
||||
|
||||
private List<Long> merchIds;
|
||||
|
||||
private List<String> merchTypes;
|
||||
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
}
|
||||
+20
@@ -23,6 +23,7 @@ import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardDoorFlowVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.*;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.excel.HardMchOrderExcelVo;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
@@ -142,6 +143,25 @@ public class HardOrderTotalController {
|
||||
return R.ok(hardOrderTotalService.listCs(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/page-list-cs-by-month")
|
||||
@Operation(summary = "商户交易记录(按商户、月)查询")
|
||||
public R<Page<HardOrderCsVo>> pageListCsByMonth(@ParameterObject Page page, @RequestBody HardOrderDto dto) {
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
// 查询商户和下面的子商户
|
||||
List<Long> mchDtoIds = new ArrayList<>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getMerchantId())) {
|
||||
List<MchManageVo> mchList = mchService.getByParentId(dto.getMerchantId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
|
||||
mchDtoIds.add(dto.getMerchantId());
|
||||
mchDtoIds.addAll(mchIds);
|
||||
dto.setMerchantId(null);
|
||||
dto.setMchIds(mchDtoIds);
|
||||
}
|
||||
}
|
||||
return R.ok(hardOrderTotalService.pageListCsByMonth(page, dto));
|
||||
}
|
||||
|
||||
@PostMapping("/page-list-payType")
|
||||
@Operation(summary = "支付方式交易记录")
|
||||
public R<List<HardOrderPayTypeVo>> pageListPayType(@RequestBody HardOrderDto dto) {
|
||||
|
||||
+7
@@ -10,6 +10,7 @@ import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardSelectOrderMerchIdsDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelProductDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
@@ -108,6 +109,8 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
return selectListByScope(commonWrapper(dto), DataScope.of());
|
||||
}
|
||||
|
||||
List<Long> selectOrderMerchIds(@Param("dto") HardSelectOrderMerchIdsDto dto);
|
||||
|
||||
Page<HardOrderVo> scopePageList(Page page, @Param("dto") HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
List<HardOrderVo> scopeList(@Param("dto") HardOrderDto dto, DataScope dataScope);
|
||||
@@ -122,8 +125,12 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
|
||||
List<HardOrderCsVo> listRefundCs(@Param("dto") HardOrderDto refundDto, DataScope refundDataScope);
|
||||
|
||||
List<HardOrderCsVo> listRefundCsByMonth(@Param("dto") HardOrderDto refundDto, DataScope refundDataScope);
|
||||
|
||||
List<HardOrderCsVo> listCsByDay(@Param("dto") HardOrderDto totalDto);
|
||||
|
||||
Page<HardOrderCsVo> pageCsByMonth(Page page, @Param("dto") HardOrderDto totalDto, DataScope totalDataScope);
|
||||
|
||||
HardOrderCsVo listCsTotal(@Param("dto") HardOrderDto totalDto);
|
||||
|
||||
List<HardOrderPayTypeVo> listOrerPayType(@Param("dto") HardOrderDto dto);
|
||||
|
||||
+5
-1
@@ -21,6 +21,11 @@ public interface HardOrderTotalService {
|
||||
*/
|
||||
List<HardOrderCsVo> listCs(HardOrderDto dto);
|
||||
|
||||
/**
|
||||
* 商户交易记录(按商户、月)查询
|
||||
*/
|
||||
Page<HardOrderCsVo> pageListCsByMonth(Page page, HardOrderDto dto);
|
||||
|
||||
/**
|
||||
* 根据天查询每个商户的流水
|
||||
*/
|
||||
@@ -50,5 +55,4 @@ public interface HardOrderTotalService {
|
||||
* 统计每天、每周、每月、每年的交易人数和次数
|
||||
*/
|
||||
HardChartLatitudeVo chartLatitude(Long merchantId);
|
||||
|
||||
}
|
||||
+106
-8
@@ -15,14 +15,10 @@ import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardRefundStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardSaleStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.CurrentUserHardTypeInfoDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardChartLatitudeVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.*;
|
||||
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.*;
|
||||
@@ -48,8 +44,6 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -169,7 +163,6 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
refundDto.setRefundStatusCodes(List.of(HardSaleStatusEnum.COMPLETE.getStatus()));
|
||||
DataScope refundDataScope = DataScope.of();
|
||||
refundDataScope.setScopeDeptName("merchant_dept_id");
|
||||
|
||||
List<HardOrderCsVo> refundList = hardOrderMapper.listRefundCs(refundDto, refundDataScope);
|
||||
// 有退款没有流水的情况
|
||||
if (ObjectUtil.isAllNotEmpty(totalList, refundList)) {
|
||||
@@ -233,6 +226,111 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
return totalList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户交易记录(按商户、月)查询
|
||||
*/
|
||||
@Override
|
||||
public Page<HardOrderCsVo> pageListCsByMonth(Page page, HardOrderDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
if (ObjectUtil.isEmpty(dto.getMchTypeCodes())) {
|
||||
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
|
||||
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
|
||||
} else {
|
||||
dto.setMchTypeCodes(dto.getMchTypeCodes());
|
||||
}
|
||||
// // 查询总流水
|
||||
// if (ObjectUtil.isEmpty(dto.getMchIds())) {
|
||||
// HardSelectOrderMerchIdsDto merchQuery = new HardSelectOrderMerchIdsDto();
|
||||
// if (ObjectUtil.isNotEmpty(dto.getMerchantId())) {
|
||||
// merchQuery.setMerchIds(List.of(dto.getMerchantId()));
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(dto.getMchTypeCodes())) {
|
||||
// merchQuery.setMerchTypes(dto.getMchTypeCodes());
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
// merchQuery.setCreateTimeList(dto.getCreateTimeList());
|
||||
// }
|
||||
// List<Long> mechIds = hardOrderMapper.selectOrderMerchIds(merchQuery);
|
||||
// dto.setMchIds(mechIds);
|
||||
// }
|
||||
// 查询总流水
|
||||
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
|
||||
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
|
||||
DataScope totalDataScope = DataScope.of();
|
||||
totalDataScope.setScopeDeptName("merchant_dept_id");
|
||||
Page<HardOrderCsVo> totalPage = hardOrderMapper.pageCsByMonth(page, totalDto, totalDataScope);
|
||||
List<HardOrderCsVo> totalList = totalPage.getRecords();
|
||||
// 扣款总流水
|
||||
HardOrderDto refundDto = BeanUtil.toBean(dto, HardOrderDto.class);
|
||||
refundDto.setPayTimeList(null);
|
||||
refundDto.setRefundTimeList(dto.getPayTimeList());
|
||||
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
|
||||
refundDto.setRefundStatusCodes(List.of(HardSaleStatusEnum.COMPLETE.getStatus()));
|
||||
DataScope refundDataScope = DataScope.of();
|
||||
refundDataScope.setScopeDeptName("merchant_dept_id");
|
||||
List<HardOrderCsVo> refundList = hardOrderMapper.listRefundCsByMonth(refundDto, refundDataScope);
|
||||
// 有退款没有流水的情况
|
||||
if (ObjectUtil.isAllNotEmpty(totalList, refundList)) {
|
||||
for (HardOrderCsVo refund : refundList) {
|
||||
HardOrderCsVo target = totalList.stream().filter(v -> ObjectUtil.equals(refund.getMerchantId(), v.getMerchantId()) && ObjectUtil.equals(refund.getDay(), v.getDay())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isEmpty(target)) {
|
||||
HardOrderCsVo entity = BeanUtils.toBean(refund, HardOrderCsVo.class);
|
||||
entity.setTotalPayPrice(BigDecimal.ZERO);
|
||||
entity.setTotalPayCount(BigDecimal.ZERO);
|
||||
totalList.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (HardOrderCsVo v : totalList) {
|
||||
// 退款
|
||||
if (ObjectUtil.isNotEmpty(refundList)) {
|
||||
refundList.stream().filter(i -> ObjectUtil.equals(i.getMerchantId(), v.getMerchantId()) && ObjectUtil.equals(i.getDay(), v.getDay())).findFirst().ifPresent(i -> {
|
||||
v.setTotalRefundPrice(i.getTotalPayPrice());
|
||||
v.setTotalRefundCount(i.getTotalPayCount());
|
||||
});
|
||||
}
|
||||
// 消费净金额
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) {
|
||||
BigDecimal refundPrice = BigDecimal.ZERO;
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalRefundPrice())) {
|
||||
refundPrice = v.getTotalRefundPrice();
|
||||
}
|
||||
v.setTotalProfitPrice(v.getTotalPayPrice().subtract(refundPrice));
|
||||
}
|
||||
// 消费净次数
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) {
|
||||
BigDecimal refundCount = BigDecimal.ZERO;
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalRefundCount())) {
|
||||
refundCount = v.getTotalRefundCount();
|
||||
}
|
||||
v.setTotalProfitCount(v.getTotalPayCount().subtract(refundCount));
|
||||
}
|
||||
}
|
||||
// 聚合一下数据
|
||||
if (ObjectUtil.isNotEmpty(totalList)) {
|
||||
// 商户
|
||||
List<Long> mchIds = totalList.stream().map(HardOrderCsVo::getMerchantId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(mchIds)) {
|
||||
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId));
|
||||
}
|
||||
}
|
||||
// 商户部门
|
||||
List<Long> mchDeptIds = totalList.stream().map(HardOrderCsVo::getMerchantDeptId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(mchDeptIds)) {
|
||||
Map<Long, SysDept> deptMap = remoteDeptService.getDeptByDeptIds(mchDeptIds).getData();
|
||||
if (ObjectUtil.isNotEmpty(deptMap)) {
|
||||
for (HardOrderCsVo v : totalList) {
|
||||
if (ObjectUtil.isEmpty(v.getMerchantDeptId())) continue;
|
||||
v.setMerchantDeptName(deptMap.get(v.getMerchantDeptId()).getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HardOrderCsVo> listCsByDay(Page page, HardOrderDto dto, PjcloudUser user) {
|
||||
// 查询总流水
|
||||
|
||||
+78
@@ -223,6 +223,39 @@
|
||||
order by a.create_time desc, a.user_id desc
|
||||
</sql>
|
||||
|
||||
<select id="selectOrderMerchIds" resultType="java.lang.Long">
|
||||
select distinct (total.merchantId)
|
||||
from (select a.merchant_id as merchantId, a.merchant_type as merchantType, a.create_time as createTime
|
||||
from hard_order a
|
||||
where a.del_flag = '0'
|
||||
and a.merchant_id is not null
|
||||
and a.merchant_type is not null
|
||||
union all
|
||||
select o.merchant_id as merchantId, o.merchant_type as merchantType, a.create_time
|
||||
from hard_after_sale a
|
||||
left join hard_order o on o.id = a.order_id
|
||||
where a.del_flag = '0'
|
||||
and o.merchant_id is not null
|
||||
and o.merchant_type is not null) total
|
||||
<where>
|
||||
<if test="dto.merchIds != null and dto.merchIds.size() != 0">
|
||||
and total.merchantId in
|
||||
<foreach collection="dto.merchIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.merchTypes != null and dto.merchTypes.size() != 0">
|
||||
and total.merchantType in
|
||||
<foreach collection="dto.merchTypes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
|
||||
and a.createTime between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderVo">
|
||||
<include refid="pageList"/>
|
||||
</select>
|
||||
@@ -367,6 +400,37 @@
|
||||
ELSE 5 END
|
||||
</select>
|
||||
|
||||
<select id="listRefundCsByMonth" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
|
||||
select
|
||||
DATE_FORMAT(r.audit_time, '%Y-%m') as day,
|
||||
a.merchant_id,
|
||||
sum(ifnull(r.refund_price, 0)) as totalPayPrice,
|
||||
count(0) as totalPayCount
|
||||
from hard_after_sale r
|
||||
inner join hard_order a on a.id = r.order_id and r.del_flag = '0'
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
and a.merchant_id is not null
|
||||
<if test="dto.refundTimeList != null and dto.refundTimeList.length == 2">
|
||||
and r.audit_time between #{dto.refundTimeList[0]} and #{dto.refundTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.refundStatusCodes != null and dto.refundStatusCodes.size() != 0">
|
||||
and r.status in
|
||||
<foreach collection="dto.refundStatusCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by a.merchant_id,DATE_FORMAT(r.audit_time, '%Y-%m')
|
||||
order by DATE_FORMAT(r.audit_time, '%Y-%m'),
|
||||
CASE a.merchant_type
|
||||
WHEN 1 THEN 1
|
||||
WHEN 3 THEN 2
|
||||
WHEN 0 THEN 3
|
||||
WHEN 2 THEN 4
|
||||
ELSE 5 END
|
||||
</select>
|
||||
|
||||
<select id="listCsByDay" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
|
||||
select a.merchant_id,
|
||||
DATE_FORMAT(a.create_time, '%Y-%m-%d') as day,
|
||||
@@ -380,6 +444,20 @@
|
||||
order by DATE_FORMAT(a.create_time, '%Y-%m-%d') desc, a.merchant_id desc
|
||||
</select>
|
||||
|
||||
<select id="pageCsByMonth" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
|
||||
select a.merchant_id,
|
||||
DATE_FORMAT(a.pay_time, '%Y-%m') as day,
|
||||
sum(a.pay_price) as totalPayPrice,
|
||||
count(0) as totalPayCount
|
||||
from hard_order a
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
and a.merchant_id is not null
|
||||
</where>
|
||||
group by a.merchant_id, DATE_FORMAT(a.pay_time, '%Y-%m')
|
||||
order by a.merchant_id desc, DATE_FORMAT(a.pay_time, '%Y-%m') desc
|
||||
</select>
|
||||
|
||||
<select id="listCsTotal" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
|
||||
select a.merchant_id,
|
||||
sum(a.pay_price) as totalPayPrice,
|
||||
|
||||
Reference in new issue
Block a user