|
@@ -13,10 +13,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.account.controller.utils.DateUtils;
|
|
|
-import com.fjhx.account.entity.account.po.AccountRunningWater;
|
|
|
import com.fjhx.account.entity.account.vo.AccountRequestFundsDetailVo;
|
|
|
import com.fjhx.account.entity.account.vo.AccountRunningWaterVo;
|
|
|
-import com.fjhx.account.entity.tax.po.TaxRefundDetails;
|
|
|
import com.fjhx.account.service.account.AccountManagementService;
|
|
|
import com.fjhx.account.service.account.AccountRequestFundsDetailService;
|
|
|
import com.fjhx.account.service.tax.TaxRefundDetailsService;
|
|
@@ -42,8 +40,6 @@ import com.fjhx.flow.service.flow.FlowExampleService;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.purchase.entity.arrival.po.ArrivalDetail;
|
|
|
-import com.fjhx.purchase.entity.pay.po.Pay;
|
|
|
-import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
|
import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
|
import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
|
|
|
import com.fjhx.purchase.entity.purchase.vo.PurchaseDetailVo;
|
|
@@ -68,7 +64,6 @@ import com.fjhx.sale.entity.contract.vo.*;
|
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo;
|
|
|
import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
|
|
|
import com.fjhx.sale.entity.statement.dto.ProfitSettlementDto;
|
|
|
-import com.fjhx.sale.entity.statement.vo.ProfitSettlementVo;
|
|
|
import com.fjhx.sale.mapper.contract.ContractMapper;
|
|
|
import com.fjhx.sale.service.claim.ClaimContractService;
|
|
|
import com.fjhx.sale.service.contract.ContractProductService;
|
|
@@ -81,7 +76,6 @@ import com.fjhx.sale.service.statement.SaleStatementService;
|
|
|
import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
-import com.github.pagehelper.util.StringUtil;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
@@ -197,6 +191,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
@Autowired
|
|
|
private SaleStatementService saleStatementService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页
|
|
|
*
|
|
@@ -220,6 +215,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 利润结算表分页
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -230,34 +226,35 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
wrapper.orderByDesc("t1", Contract::getCreateTime);
|
|
|
wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
|
|
|
wrapper.between("t1", Contract::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getSettlementStatus())){
|
|
|
- wrapper.eq( "t1",Contract::getSettlementStatus, dto.getSettlementStatus());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getSettlementStatus())) {
|
|
|
+ wrapper.eq("t1", Contract::getSettlementStatus, dto.getSettlementStatus());
|
|
|
}
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getUserId())){
|
|
|
- wrapper.eq( "t1",Contract::getCreateUser, dto.getUserId());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getUserId())) {
|
|
|
+ wrapper.eq("t1", Contract::getCreateUser, dto.getUserId());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getIsArrival())){
|
|
|
- if(StringUtils.equals(dto.getIsArrival(),"1")){//已到账----//预付比例等于0||到账认领金额 >= 合同金额 * 预付比例%
|
|
|
+ if (StringUtils.isNotEmpty(dto.getIsArrival())) {
|
|
|
+ if (StringUtils.equals(dto.getIsArrival(), "1")) {//已到账----//预付比例等于0||到账认领金额 >= 合同金额 * 预付比例%
|
|
|
wrapper.and(c -> {
|
|
|
c.eq(Contract::getAdvanceRatio, "0").or();
|
|
|
c.eq("t1.refundStatusNew", 20);
|
|
|
});
|
|
|
|
|
|
- }else{
|
|
|
- wrapper.ne("t1",Contract::getAdvanceRatio,"0");
|
|
|
- wrapper.ne("t1.refundStatusNew",20);
|
|
|
+ } else {
|
|
|
+ wrapper.ne("t1", Contract::getAdvanceRatio, "0");
|
|
|
+ wrapper.ne("t1.refundStatusNew", 20);
|
|
|
}
|
|
|
}
|
|
|
- Page<ContractVo> page = baseMapper.getProfitSettlement(dto.getPage(),wrapper);
|
|
|
+ Page<ContractVo> page = baseMapper.getProfitSettlement(dto.getPage(), wrapper);
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 利润结算表分页
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -267,24 +264,24 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
wrapper.orderByDesc("t1", Contract::getCreateTime);
|
|
|
wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
|
|
|
wrapper.between("t1", Contract::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getSettlementStatus())){
|
|
|
- wrapper.eq( "t1",Contract::getSettlementStatus, dto.getSettlementStatus());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getSettlementStatus())) {
|
|
|
+ wrapper.eq("t1", Contract::getSettlementStatus, dto.getSettlementStatus());
|
|
|
}
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getUserId())){
|
|
|
- wrapper.eq( "t1",Contract::getCreateUser, dto.getUserId());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getUserId())) {
|
|
|
+ wrapper.eq("t1", Contract::getCreateUser, dto.getUserId());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getIsArrival())){
|
|
|
- if(StringUtils.equals(dto.getIsArrival(),"1")){//已到账----//预付比例等于0||到账认领金额 >= 合同金额 * 预付比例%
|
|
|
+ if (StringUtils.isNotEmpty(dto.getIsArrival())) {
|
|
|
+ if (StringUtils.equals(dto.getIsArrival(), "1")) {//已到账----//预付比例等于0||到账认领金额 >= 合同金额 * 预付比例%
|
|
|
wrapper.and(c -> {
|
|
|
c.eq(Contract::getAdvanceRatio, "0").or();
|
|
|
c.eq("t1.refundStatusNew", 20);
|
|
|
});
|
|
|
- }else{
|
|
|
- wrapper.ne("t1",Contract::getAdvanceRatio,"0");
|
|
|
- wrapper.ne("t1.refundStatusNew",20);
|
|
|
+ } else {
|
|
|
+ wrapper.ne("t1", Contract::getAdvanceRatio, "0");
|
|
|
+ wrapper.ne("t1.refundStatusNew", 20);
|
|
|
}
|
|
|
}
|
|
|
List<ContractVo> list = baseMapper.getProfitSettlementHead(wrapper);
|
|
@@ -307,7 +304,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
private Page<ContractVo> pageCommon(ContractSelectDto dto, IWrapper<Contract> wrapper) {
|
|
|
wrapper.orderByDesc("t1", Contract::getCreateTime);
|
|
|
wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
|
|
|
- wrapper.ne("t1",Contract::getIsShow,1);
|
|
|
+ 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());
|
|
@@ -580,6 +577,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 合同明细
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
@@ -616,12 +614,21 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 暂存合同
|
|
|
+ *
|
|
|
* @param contract
|
|
|
* @return
|
|
|
*/
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public long add(ContractDto contract) {
|
|
|
+ //禁止操作非暂存合同
|
|
|
+ if (ObjectUtil.isNotEmpty(contract.getId())) {
|
|
|
+ Contract byId = getById(contract.getId());
|
|
|
+ if (byId.getStatus() != FlowStatusEnum1.DRAFT.getKey()) {
|
|
|
+ throw new ServiceException("禁止操作非暂存合同");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isEmpty(contract.getCurrency())) {
|
|
|
throw new ServiceException("币种不能为空");
|
|
|
}
|
|
@@ -638,11 +645,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
contract = commStart(contract);
|
|
|
return contract.getId();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 开始公共代码抽取
|
|
|
*/
|
|
|
public ContractDto commStart(ContractDto contract) {
|
|
|
- if(ObjectUtil.isEmpty(contract.getBuyCorporationId())){
|
|
|
+ if (ObjectUtil.isEmpty(contract.getBuyCorporationId())) {
|
|
|
throw new ServiceException("客户不能为空");
|
|
|
}
|
|
|
// 赋值城市省份信息
|
|
@@ -684,6 +692,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
ObsFileUtil.saveFile(contract.getPackageFileList(), contract.getId(), 2);
|
|
|
return contract;
|
|
|
}
|
|
|
+
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void edit(ContractDto contractDto) {
|
|
@@ -1735,15 +1744,16 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 头部统计客户金额
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
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<>());
|
|
|
+ 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();
|
|
|
if (authIdList.size() == 0) {
|
|
@@ -1752,7 +1762,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
|
wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
|
|
|
wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
|
|
|
- wrapper.ne("t1",Contract::getIsShow,1);
|
|
|
+ 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());
|
|
@@ -1783,25 +1793,25 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
wrapper.groupBy("t1.sell_corporation_id");
|
|
|
List<ContractVo> 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);
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getDocumentaryPdf(Long newContractId, List<Long> contractIds) {
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
if (ObjectUtil.isEmpty(newContractId)) {
|
|
|
throw new ServiceException("销售合同id不能为空");
|
|
|
}
|
|
@@ -1810,21 +1820,21 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
throw new ServiceException("没有找到销售合同");
|
|
|
}
|
|
|
contract.setCreateTimeEn(sdf.format(contract.getCreateTime()));
|
|
|
- map.put("contract",contract);
|
|
|
+ map.put("contract", contract);
|
|
|
QueryWrapper<Contract> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.select("IFNULL(SUM( amount ),0) AS amount").in("id",contractIds);
|
|
|
+ queryWrapper.select("IFNULL(SUM( amount ),0) AS amount").in("id", contractIds);
|
|
|
contract.setAmount(contractService.getOne(queryWrapper).getAmount());
|
|
|
//查询合同产品
|
|
|
- List<ContractProduct> contractProductList = contractProductService.list(Wrappers.<ContractProduct>query().lambda().in(ContractProduct::getContractId,contractIds));
|
|
|
+ List<ContractProduct> contractProductList = contractProductService.list(Wrappers.<ContractProduct>query().lambda().in(ContractProduct::getContractId, contractIds));
|
|
|
productInfoService.attributeAssign(contractProductList, ContractProduct::getProductId, (item, product) -> {
|
|
|
item.setProductCnName(product.getName());
|
|
|
item.setProductCode(product.getCode());
|
|
|
item.setProductUnit(product.getUnit());
|
|
|
});
|
|
|
//查询合同其他收费项目
|
|
|
- List<ContractProject> contractProjectList = contractProjectService.list(Wrappers.<ContractProject>query().lambda().in(ContractProject::getContractId,contractIds));
|
|
|
- map.put("contractProductList",contractProductList);
|
|
|
- map.put("contractProjectList",contractProjectList);
|
|
|
+ List<ContractProject> contractProjectList = contractProjectService.list(Wrappers.<ContractProject>query().lambda().in(ContractProject::getContractId, contractIds));
|
|
|
+ map.put("contractProductList", contractProductList);
|
|
|
+ map.put("contractProjectList", contractProjectList);
|
|
|
return map;
|
|
|
}
|
|
|
}
|