|
@@ -2,10 +2,19 @@ package com.fjhx.jxst.service.sales.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.account.entity.account.po.AccountManagement;
|
|
|
+import com.fjhx.account.service.account.AccountManagementService;
|
|
|
+import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
+import com.fjhx.common.entity.corporation.po.Corporation;
|
|
|
+import com.fjhx.common.service.corporation.CorporationService;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
+import com.fjhx.customer.entity.customer.po.CustomerUser;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
+import com.fjhx.customer.service.customer.CustomerUserService;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.jxst.entity.sales.dto.SalesContractDto;
|
|
|
import com.fjhx.jxst.entity.sales.dto.SalesContractSelectDto;
|
|
@@ -26,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -46,6 +56,12 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
|
|
|
private CustomerService customerService;
|
|
|
@Autowired
|
|
|
private ProductInfoService productInfoService;
|
|
|
+ @Autowired
|
|
|
+ private CustomerUserService customerUserService;
|
|
|
+ @Autowired
|
|
|
+ private AccountManagementService accountManagementService;
|
|
|
+ @Autowired
|
|
|
+ private CorporationService corporationService;
|
|
|
|
|
|
@Override
|
|
|
public Page<SalesContractVo> getPage(SalesContractSelectDto dto) {
|
|
@@ -71,23 +87,60 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
|
|
|
|
|
|
@Override
|
|
|
public SalesContractVo detail(Long id) {
|
|
|
- SalesContract SalesContract = this.getById(id);
|
|
|
- SalesContractVo result = BeanUtil.toBean(SalesContract, SalesContractVo.class);
|
|
|
+ SalesContract salesContract = this.getById(id);
|
|
|
+ Assert.notEmpty(salesContract,"查询不到合同信息");
|
|
|
+ SalesContractVo result = BeanUtil.toBean(salesContract, SalesContractVo.class);
|
|
|
List<SalesContractDetails> salesContractDetailsList = salesContractDetailsService.list(q -> q.eq(SalesContractDetails::getSalesContractId, result.getId()));
|
|
|
List<SalesContractDetailsVo> salesContractDetailsVos = BeanUtil.copyToList(salesContractDetailsList, SalesContractDetailsVo.class);
|
|
|
//赋值产品信息
|
|
|
productInfoService.attributeAssign(salesContractDetailsVos, SalesContractDetailsVo::getProductId, (item, productInfo) -> {
|
|
|
item.setProductName(productInfo.getName());
|
|
|
+ item.setProductSpec(productInfo.getSpec());
|
|
|
+ item.setProductUnit(productInfo.getUnit());
|
|
|
});
|
|
|
result.setContractDetailsList(salesContractDetailsVos);
|
|
|
- //赋值客户名称
|
|
|
+ //赋值客户信息
|
|
|
customerService.attributeAssign(Arrays.asList(result), SalesContractVo::getCustomerId, (item, customer) -> {
|
|
|
item.setCustomerName(customer.getName());
|
|
|
+ item.setCustomerBank(customer.getBeneficiaryBank());
|
|
|
+ item.setCustomerSwiftCode(customer.getSwiftCode());
|
|
|
+ item.setCustomerAccountNumber(customer.getBeneficiaryAccountNumber());
|
|
|
});
|
|
|
+ //赋值客户更多联系人
|
|
|
+ List<CustomerUser> customerUserList = customerUserService.list(q -> q.eq(CustomerUser::getCustomerId, salesContract.getCustomerId()));
|
|
|
+ result.setCustomerUserList(customerUserList);
|
|
|
+ //赋值客户国省市名称
|
|
|
+ Map<Long, String> areaMapByIds = CustomizeAreaUtil.getAreaMapByIds(Arrays.asList(
|
|
|
+ result.getBuyCountryId(),
|
|
|
+ result.getBuyProvinceId(),
|
|
|
+ result.getBuyCityId(),
|
|
|
+
|
|
|
+ result.getSellCountryId(),
|
|
|
+ result.getSellProvinceId(),
|
|
|
+ result.getSellCityId())
|
|
|
+ );
|
|
|
+ result.setBuyCountryName(areaMapByIds.get(result.getBuyCountryId()));
|
|
|
+ result.setBuyProvinceName(areaMapByIds.get(result.getBuyProvinceId()));
|
|
|
+ result.setBuyCityName(areaMapByIds.get(result.getBuyCityId()));
|
|
|
+
|
|
|
+ //赋值卖方信息多公司
|
|
|
+ AccountManagement accountManagement = accountManagementService.getById(result.getShroffAccountId());
|
|
|
+ Corporation corporation = corporationService.getById(accountManagement.getCorporationId());
|
|
|
+ result.setSellCorporationName(corporation.getName());
|
|
|
+ result.setSellCorporationNumber(corporation.getCorporationNumber());
|
|
|
+ result.setSellTaxationCode(corporation.getTaxationCode());
|
|
|
+ result.setSellOpeningBank(accountManagement.getOpeningBank());
|
|
|
+ result.setSellSwiftCode(accountManagement.getSwiftCode());
|
|
|
+ result.setSellAccountOpening(accountManagement.getAccountOpening());
|
|
|
+ //赋值卖方国省市名称
|
|
|
+ result.setSellCountryName(areaMapByIds.get(result.getSellCountryId()));
|
|
|
+ result.setSellProvinceName(areaMapByIds.get(result.getSellProvinceId()));
|
|
|
+ result.setSellCityName(areaMapByIds.get(result.getSellCityId()));
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
public void add(SalesContractDto salesContractDto) {
|
|
|
List<SalesContractDetails> salesContractDetailsList = salesContractDto.getSalesContractDetailsList();
|