|
|
@@ -1,21 +1,29 @@ |
|
|
|
package com.qtzl.alterSales.manager.handler; |
|
|
|
|
|
|
|
import cn.com.taiji.common.manager.net.http.ServiceHandleException; |
|
|
|
import cn.com.taiji.common.model.dao.Pagination; |
|
|
|
import cn.com.taiji.common.pub.BeanTools; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.qtzl.alterSales.dao.entity.primary.AflAgencyMchRel; |
|
|
|
import com.qtzl.alterSales.dao.entity.second.AflPaccountRefundCount; |
|
|
|
import com.qtzl.alterSales.dao.repo.jpa.primary.AflAgencyMchRelRepo; |
|
|
|
import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountRefundCountRepo; |
|
|
|
import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageRequest; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewRequest; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewResponse; |
|
|
|
import com.qtzl.alterSales.manager.service.AfterSalesCmd; |
|
|
|
import com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo; |
|
|
|
import com.txffp.api.core.manager.comm.annotation.ApiHandler; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.PageRequest; |
|
|
|
import org.springframework.data.domain.Sort; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.persistence.criteria.Predicate; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询部中心原始流水统计分页 |
|
|
@@ -27,6 +35,9 @@ public class AflPaccountRefundCountFindPageHandler extends AbstractAfterSalesMan |
|
|
|
@Resource |
|
|
|
AflPaccountRefundCountRepo aflPaccountRefundCountRepo; |
|
|
|
|
|
|
|
@Resource |
|
|
|
AflAgencyMchRelRepo aflAgencyMchRelRepo; |
|
|
|
|
|
|
|
public AflPaccountRefundCountFindPageHandler() { |
|
|
|
super(AfterSalesCmd.FINDPAGEPACCOUNTREFUNDCOUNT, AflPaccountRefundCountFindPageViewRequest.class); |
|
|
|
} |
|
|
@@ -34,8 +45,8 @@ public class AflPaccountRefundCountFindPageHandler extends AbstractAfterSalesMan |
|
|
|
@Override |
|
|
|
public String handleInternal(String filename, AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException { |
|
|
|
try { |
|
|
|
Pagination page =select(request); |
|
|
|
return toResponse(page).toJson(); |
|
|
|
Page<AflPaccountRefundCount> page = select(request); |
|
|
|
return toResponse(page,request).toJson(); |
|
|
|
} catch (Exception e) { |
|
|
|
if (e instanceof ServiceHandleException) { |
|
|
|
throw e; |
|
|
@@ -44,22 +55,68 @@ public class AflPaccountRefundCountFindPageHandler extends AbstractAfterSalesMan |
|
|
|
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("查询部中心原始流水统计失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
private AflPaccountRefundCountFindPageViewResponse toResponse(Pagination pagination) { |
|
|
|
// private AflPaccountRefundCountFindPageViewResponse toResponse(Pagination pagination) { |
|
|
|
// final AflPaccountRefundCountFindPageViewResponse response = new AflPaccountRefundCountFindPageViewResponse(); |
|
|
|
// BeanTools.copyProperties(pagination, response); |
|
|
|
// if (isEmpty(pagination.getResult())) { |
|
|
|
// return response; |
|
|
|
// } |
|
|
|
// response.setData(pagination.getResult(AflPaccountRefundCountVo.class)); |
|
|
|
// return response; |
|
|
|
// } |
|
|
|
|
|
|
|
// private Pagination select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException { |
|
|
|
// if (request.getPageSize() > 100) { |
|
|
|
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize()); |
|
|
|
// } |
|
|
|
// AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest(); |
|
|
|
// BeanUtil.copyProperties(request, queryRequest); |
|
|
|
// return aflPaccountRefundCountRepo.page(queryRequest); |
|
|
|
// } |
|
|
|
|
|
|
|
private AflPaccountRefundCountFindPageViewResponse toResponse(Page<AflPaccountRefundCount> page, AflPaccountRefundCountFindPageViewRequest request) { |
|
|
|
final AflPaccountRefundCountFindPageViewResponse response = new AflPaccountRefundCountFindPageViewResponse(); |
|
|
|
BeanTools.copyProperties(pagination, response); |
|
|
|
if (isEmpty(pagination.getResult())) { |
|
|
|
response.setCurrentPage(request.getPageNo()); |
|
|
|
response.setPageSize(request.getPageSize()); |
|
|
|
response.setPageCount(page.getTotalPages()); |
|
|
|
response.setTotalCount(page.getTotalElements()); |
|
|
|
if (isEmpty(page.getContent())) { |
|
|
|
response.setData(Lists.newArrayList()); |
|
|
|
return response; |
|
|
|
} |
|
|
|
response.setData(pagination.getResult(AflPaccountRefundCountVo.class)); |
|
|
|
List<AflPaccountRefundCountVo> formVoList = page.getContent().stream().map(this::toVo).collect(Collectors.toList()); |
|
|
|
response.setData(formVoList); |
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
private Pagination select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException { |
|
|
|
private Page<AflPaccountRefundCount> select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException { |
|
|
|
if (request.getPageSize() > 100) { |
|
|
|
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize()); |
|
|
|
} |
|
|
|
AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest(); |
|
|
|
BeanUtil.copyProperties(request, queryRequest); |
|
|
|
return aflPaccountRefundCountRepo.page(queryRequest); |
|
|
|
return aflPaccountRefundCountRepo.findAll(((root, query, cb) -> { |
|
|
|
List<Predicate> list = Lists.newArrayList(); |
|
|
|
if (!StringUtils.isEmpty(request.getAgentId())) { |
|
|
|
list.add(cb.equal(root.<Integer>get("agentId"), request.getAgentId())); |
|
|
|
} |
|
|
|
if (request.getAccountDateEnd()!=null) { |
|
|
|
list.add(cb.le(root.<Integer>get("accountDate"), request.getAccountDateEnd())); |
|
|
|
} |
|
|
|
if (request.getAccountDateStart()!=null) { |
|
|
|
list.add(cb.ge(root.<Integer>get("accountDate"), request.getAccountDateStart())); |
|
|
|
} |
|
|
|
Predicate[] p = new Predicate[list.size()]; |
|
|
|
return cb.and(list.toArray(p)); |
|
|
|
}), PageRequest.of(request.getPageNo() - 1, request.getPageSize(), |
|
|
|
Sort.by(Sort.Direction.DESC, "accountDate"))); |
|
|
|
} |
|
|
|
|
|
|
|
private AflPaccountRefundCountVo toVo(AflPaccountRefundCount aflPaccountRefundCount) { |
|
|
|
AflPaccountRefundCountVo aflPaccountRefundCountVo = new AflPaccountRefundCountVo(); |
|
|
|
BeanUtils.copyProperties(aflPaccountRefundCount,aflPaccountRefundCountVo); |
|
|
|
AflAgencyMchRel aflAgencyMchRel = aflAgencyMchRelRepo.findByAgencyId(aflPaccountRefundCountVo.getAgentId()); |
|
|
|
if (aflAgencyMchRel!=null){ |
|
|
|
aflPaccountRefundCountVo.setAgentName(aflAgencyMchRel.getAgencyName()); |
|
|
|
} |
|
|
|
return aflPaccountRefundCountVo; |
|
|
|
} |
|
|
|
} |