|
@@ -1668,34 +1668,58 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 头部统计客户金额
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String, Object> getHeadCustomerStatistics() {
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("sumAmount",BigDecimal.ZERO);
|
|
|
- map.put("sumArrivalAmount",BigDecimal.ZERO);
|
|
|
- map.put("sumQuantity",BigDecimal.ZERO);
|
|
|
- map.put("list",new ArrayList<>());
|
|
|
+ public Map<String, Object> getHeadCustomerStatistics(ContractSelectDto dto) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("sumAmount", BigDecimal.ZERO);
|
|
|
+ map.put("sumArrivalAmount", BigDecimal.ZERO);
|
|
|
+ map.put("sumQuantity", BigDecimal.ZERO);
|
|
|
+ map.put("list", new ArrayList<>());
|
|
|
+
|
|
|
List<Long> authIdList = customerService.getAuthIdList();
|
|
|
- List<ContractVo> list;
|
|
|
- if(CollectionUtils.isNotEmpty(authIdList)){
|
|
|
- list = baseMapper.getCustomerMoney(authIdList);
|
|
|
- }else{
|
|
|
- list = baseMapper.getCustomerMoney(null);
|
|
|
+ if (authIdList.size() == 0) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ IWrapper<Contract> wrapper = getWrapper();
|
|
|
+ wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
|
|
|
+ wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
|
|
|
+ wrapper.ne("t1", Contract::getIsShow, 1);
|
|
|
+ wrapper.between("t1", Contract::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
|
|
|
+ if (StringUtils.isNotEmpty(dto.getStatus())) {
|
|
|
+ wrapper.eq("t1", Contract::getStatus, dto.getStatus());
|
|
|
}
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- BigDecimal sumAmount = list.stream().map(ContractVo::getSumAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
- BigDecimal sumQuantity = list.stream().map(ContractVo::getSumQuantity).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
- BigDecimal sumClaimMoney = list.stream().map(ContractVo::getSumClaimMoney).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
+ if (StringUtils.isNotEmpty(dto.getSellCorporationId())) {
|
|
|
+ wrapper.eq("t1", Contract::getSellCorporationId, dto.getSellCorporationId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getRefundStatusNew())) {
|
|
|
+ wrapper.in("t1.refundStatusNew", Arrays.asList(dto.getRefundStatusNew().split(",")));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
|
|
|
+ }
|
|
|
+ //根据客户id关联
|
|
|
+ wrapper.eq(ContractVo::getBuyCorporationId, dto.getCustomerId());
|
|
|
+ //过滤合同类型
|
|
|
+ wrapper.eq("t1.contract_type", dto.getContractType());
|
|
|
+ wrapper.groupBy("t1.sell_corporation_id");
|
|
|
+ List<ContractVo> list;
|
|
|
+ list = baseMapper.getCustomerMoney(wrapper);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ BigDecimal sumAmount = list.stream().map(ContractVo::getSumAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal sumQuantity = list.stream().map(ContractVo::getSumQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal sumClaimMoney = list.stream().map(ContractVo::getSumClaimMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//赋值原卖方公司名称 多公司
|
|
|
corporationService.attributeAssign(list, ContractVo::getSellCorporationId, (item, corporation) -> {
|
|
|
item.setSellCorporationName(corporation.getName());
|
|
|
});
|
|
|
- map.put("sumAmount",sumAmount);
|
|
|
- map.put("sumArrivalAmount",sumClaimMoney);
|
|
|
- map.put("sumQuantity",sumQuantity);
|
|
|
- map.put("list",list);
|
|
|
+ map.put("sumAmount", sumAmount);
|
|
|
+ map.put("sumArrivalAmount", sumClaimMoney);
|
|
|
+ map.put("sumQuantity", sumQuantity);
|
|
|
+ map.put("list", list);
|
|
|
}
|
|
|
return map;
|
|
|
}
|