店铺流水业务模块参数解耦

This commit is contained in:
Chopper 2021-12-08 11:39:09 +08:00
parent c301c55905
commit 357b214192
7 changed files with 97 additions and 87 deletions

View File

@ -0,0 +1,32 @@
package cn.lili.modules.order.order.entity.dto;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.store.entity.dos.Bill;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
/**
* 店铺流水查询DTO
*
* @author Chopper
* @version v1.0
* 2021-12-08 10:53
*/
@Data
@Builder
public class StoreFlowQueryDTO {
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "过滤只看分销订单")
private Boolean justDistribution;
@ApiModelProperty("结算单")
private Bill bill;
@ApiModelProperty(value = "分页")
private PageVO pageVO;
}

View File

@ -3,16 +3,12 @@ package cn.lili.modules.order.order.service;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
import cn.lili.modules.order.order.entity.dos.StoreFlow;
import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO;
import cn.lili.modules.store.entity.vos.StoreFlowPayDownloadVO;
import cn.lili.modules.store.entity.vos.StoreFlowRefundDownloadVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
/**
@ -40,31 +36,26 @@ public interface StoreFlowService extends IService<StoreFlow> {
/**
* 获取商家流水
*
* @param storeId 商家ID
* @param type 收入退款
* @param distribution 是否查看分销相关数据
* @param pageVO 分页
* @param startTime 开始时间
* @param endTime 结束时间
* @return
* @param storeFlowQueryDTO 查询参数
* @return 返回分页
*/
IPage<StoreFlow> getStoreFlow(String storeId, String type, boolean distribution, PageVO pageVO, Date startTime, Date endTime);
IPage<StoreFlow> getStoreFlow(StoreFlowQueryDTO storeFlowQueryDTO);
/**
* 获取结算单入账流水
* 获取结算单地入账流水
*
* @param queryWrapper 查询条件
* @param storeFlowQueryDTO 查询条件
* @return 入账流水
*/
List<StoreFlowPayDownloadVO> getStoreFlowPayDownloadVO(Wrapper<StoreFlow> queryWrapper);
List<StoreFlowPayDownloadVO> getStoreFlowPayDownloadVO(StoreFlowQueryDTO storeFlowQueryDTO);
/**
* 获取结算单的退款流水
*
* @param queryWrapper 查询条件
* @param storeFlowQueryDTO 查询条件
* @return 退款流水
*/
List<StoreFlowRefundDownloadVO> getStoreFlowRefundDownloadVO(Wrapper<StoreFlow> queryWrapper);
List<StoreFlowRefundDownloadVO> getStoreFlowRefundDownloadVO(StoreFlowQueryDTO storeFlowQueryDTO);
/**

View File

@ -1,11 +1,15 @@
package cn.lili.modules.order.order.serviceimpl;
import cn.lili.common.utils.*;
import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.SnowFlake;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dos.OrderItem;
import cn.lili.modules.order.order.entity.dos.StoreFlow;
import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO;
import cn.lili.modules.order.order.entity.enums.FlowTypeEnum;
import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum;
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
@ -20,7 +24,6 @@ import cn.lili.modules.store.entity.vos.StoreFlowPayDownloadVO;
import cn.lili.modules.store.entity.vos.StoreFlowRefundDownloadVO;
import cn.lili.modules.store.service.BillService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -31,7 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
@ -148,7 +150,7 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
//获取付款信息
StoreFlow payStoreFlow = this.getOne(new LambdaUpdateWrapper<StoreFlow>().eq(StoreFlow::getOrderItemSn, afterSale.getOrderItemSn())
.eq(StoreFlow::getFlowType,FlowTypeEnum.PAY));
.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY));
storeFlow.setNum(afterSale.getNum());
storeFlow.setCategoryId(payStoreFlow.getCategoryId());
//佣金
@ -167,37 +169,60 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
}
@Override
public IPage<StoreFlow> getStoreFlow(String storeId, String type, boolean distribution, PageVO pageVO, Date startTime, Date endTime) {
public IPage<StoreFlow> getStoreFlow(StoreFlowQueryDTO storeFlowQueryDTO) {
LambdaQueryWrapper<StoreFlow> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StoreFlow::getStoreId, storeId);
lambdaQueryWrapper.isNotNull(distribution, StoreFlow::getDistributionRebate);
lambdaQueryWrapper.between(StoreFlow::getCreateTime, startTime, endTime);
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(type), StoreFlow::getFlowType, type);
return this.page(PageUtil.initPage(pageVO), lambdaQueryWrapper);
return this.page(PageUtil.initPage(storeFlowQueryDTO.getPageVO()), generatorQueryWrapper(storeFlowQueryDTO));
}
@Override
public List<StoreFlowPayDownloadVO> getStoreFlowPayDownloadVO(StoreFlowQueryDTO storeFlowQueryDTO) {
return baseMapper.getStoreFlowPayDownloadVO(generatorQueryWrapper(storeFlowQueryDTO));
}
@Override
public List<StoreFlowPayDownloadVO> getStoreFlowPayDownloadVO(Wrapper<StoreFlow> queryWrapper) {
return baseMapper.getStoreFlowPayDownloadVO(queryWrapper);
}
@Override
public List<StoreFlowRefundDownloadVO> getStoreFlowRefundDownloadVO(Wrapper<StoreFlow> queryWrapper) {
return baseMapper.getStoreFlowRefundDownloadVO(queryWrapper);
public List<StoreFlowRefundDownloadVO> getStoreFlowRefundDownloadVO(StoreFlowQueryDTO storeFlowQueryDTO) {
return baseMapper.getStoreFlowRefundDownloadVO(generatorQueryWrapper(storeFlowQueryDTO));
}
@Override
public IPage<StoreFlow> getStoreFlow(String id, String type, PageVO pageVO) {
Bill bill = billService.getById(id);
return this.getStoreFlow(bill.getStoreId(), type, false, pageVO, bill.getStartTime(), bill.getCreateTime());
return this.getStoreFlow(StoreFlowQueryDTO.builder().type(type).pageVO(pageVO).bill(bill).build());
}
@Override
public IPage<StoreFlow> getDistributionFlow(String id, PageVO pageVO) {
Bill bill = billService.getById(id);
return this.getStoreFlow(bill.getStoreId(), null, true, pageVO, bill.getStartTime(), bill.getCreateTime());
return this.getStoreFlow(StoreFlowQueryDTO.builder().pageVO(pageVO).bill(bill).build());
}
/**
* 生成查询wrapper
*
* @param storeFlowQueryDTO
* @return
*/
private LambdaQueryWrapper generatorQueryWrapper(StoreFlowQueryDTO storeFlowQueryDTO) {
LambdaQueryWrapper<StoreFlow> lambdaQueryWrapper = Wrappers.lambdaQuery();
//分销订单过滤是否判定
lambdaQueryWrapper.isNotNull(storeFlowQueryDTO.getJustDistribution() != null && storeFlowQueryDTO.getJustDistribution(),
StoreFlow::getDistributionRebate);
//流水类型判定
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(storeFlowQueryDTO.getType()),
StoreFlow::getFlowType, storeFlowQueryDTO.getType());
//结算单非空则校对结算单参数
if (storeFlowQueryDTO.getBill() != null) {
Bill bill = storeFlowQueryDTO.getBill();
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(bill.getStoreId()), StoreFlow::getStoreId, bill.getStoreId());
lambdaQueryWrapper.between(bill.getStartTime() != null && bill.getEndTime() != null,
StoreFlow::getCreateTime, bill.getStartTime(), bill.getEndTime());
}
return lambdaQueryWrapper;
}
}

View File

@ -1,10 +1,6 @@
package cn.lili.modules.payment.service;
import cn.lili.modules.order.order.entity.vo.PaymentLog;
import cn.lili.modules.payment.kit.dto.PaymentSuccessParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* 支付日志 业务层
@ -29,13 +25,4 @@ public interface PaymentService {
*/
void adminPaySuccess(PaymentSuccessParams paymentSuccessParams);
/**
* 获取支付日志
*
* @param initPage
* @param initWrapper
* @return
*/
IPage<PaymentLog> page(Page<PaymentLog> initPage, QueryWrapper<PaymentLog> initWrapper);
}

View File

@ -1,21 +1,14 @@
package cn.lili.modules.payment.serviceimpl;
import cn.lili.modules.order.order.entity.vo.PaymentLog;
import cn.lili.modules.order.order.mapper.OrderMapper;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.payment.kit.CashierSupport;
import cn.lili.modules.payment.kit.dto.PaymentSuccessParams;
import cn.lili.modules.payment.kit.params.CashierExecute;
import cn.lili.modules.payment.service.PaymentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
@ -33,8 +26,6 @@ public class PaymentServiceImpl implements PaymentService {
private List<CashierExecute> cashierExecutes;
@Autowired
private CashierSupport cashierSupport;
@Resource
private OrderService orderService;
@Override
public void success(PaymentSuccessParams paymentSuccessParams) {
@ -61,9 +52,4 @@ public class PaymentServiceImpl implements PaymentService {
cashierExecute.paymentSuccess(paymentSuccessParams);
}
}
@Override
public IPage<PaymentLog> page(Page<PaymentLog> initPage, QueryWrapper<PaymentLog> initWrapper) {
return orderService.queryPaymentLogs(initPage, initWrapper);
}
}

View File

@ -11,11 +11,8 @@ import cn.lili.common.security.context.UserContext;
import cn.lili.common.security.enums.UserEnums;
import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.SnowFlake;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.order.order.entity.dos.StoreFlow;
import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO;
import cn.lili.modules.order.order.entity.enums.FlowTypeEnum;
import cn.lili.modules.order.order.mapper.StoreFlowMapper;
import cn.lili.modules.order.order.service.StoreFlowService;
import cn.lili.modules.store.entity.dos.Bill;
import cn.lili.modules.store.entity.dto.BillSearchParams;
@ -28,7 +25,6 @@ import cn.lili.modules.store.mapper.BillMapper;
import cn.lili.modules.store.service.BillService;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -39,7 +35,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
@ -228,12 +223,8 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
writer.addHeaderAlias("billPrice", "应结金额");
writer.setColumnWidth(11, 20);
//存放入账列表
LambdaQueryWrapper<StoreFlow> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StoreFlow::getStoreId, bill.getStoreId());
lambdaQueryWrapper.between(StoreFlow::getCreateTime, bill.getStartTime(), bill.getCreateTime());
lambdaQueryWrapper.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY.name());
List<StoreFlowPayDownloadVO> storeFlowList = storeFlowService.getStoreFlowPayDownloadVO(lambdaQueryWrapper);
List<StoreFlowPayDownloadVO> storeFlowList = storeFlowService.getStoreFlowPayDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.PAY.name()).bill(bill).build());
writer.write(storeFlowList, true);
writer.setSheet("退款订单");
@ -260,12 +251,10 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
writer.addHeaderAlias("billPrice", "结算金额");
writer.setColumnWidth(12, 20);
//存放入账列表
LambdaQueryWrapper<StoreFlow> storeFlowLambdaQueryWrapper = Wrappers.lambdaQuery();
storeFlowLambdaQueryWrapper.eq(StoreFlow::getStoreId, bill.getStoreId());
storeFlowLambdaQueryWrapper.between(StoreFlow::getCreateTime, bill.getStartTime(), bill.getCreateTime());
storeFlowLambdaQueryWrapper.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY.name());
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(storeFlowLambdaQueryWrapper);
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(
StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build()
);
writer.write(storeFlowRefundDownloadVOList, true);
ServletOutputStream out = null;

View File

@ -1,13 +1,13 @@
package cn.lili.controller.order;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.common.vo.SearchVO;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.vo.PaymentLog;
import cn.lili.modules.payment.service.PaymentService;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
public class PaymentLogManagerController {
@Autowired
private PaymentService paymentService;
private OrderService orderService;
@GetMapping
@ -39,6 +39,6 @@ public class PaymentLogManagerController {
public ResultMessage<IPage<PaymentLog>> getByPage(Order order,
SearchVO searchVo,
PageVO page) {
return ResultUtil.data(paymentService.page(PageUtil.initPage(page), PageUtil.initWrapper(order, searchVo)));
return ResultUtil.data(orderService.queryPaymentLogs(PageUtil.initPage(page), PageUtil.initWrapper(order, searchVo)));
}
}