|
@@ -10,11 +10,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.account.entity.account.dto.AccountPaymentDto;
|
|
|
import com.fjhx.account.entity.account.dto.AccountRequestFundsSelectDto;
|
|
|
import com.fjhx.account.entity.account.enums.PaymentStatusEnum;
|
|
|
-import com.fjhx.account.entity.account.po.*;
|
|
|
+import com.fjhx.account.entity.account.po.AccountManagement;
|
|
|
+import com.fjhx.account.entity.account.po.AccountPayment;
|
|
|
+import com.fjhx.account.entity.account.po.AccountPaymentRecords;
|
|
|
+import com.fjhx.account.entity.account.po.AccountRunningWater;
|
|
|
import com.fjhx.account.entity.account.vo.AccountPaymentRecordsVo;
|
|
|
import com.fjhx.account.entity.account.vo.AccountPaymentVo;
|
|
|
+import com.fjhx.account.entity.payment.po.PaymentType;
|
|
|
import com.fjhx.account.mapper.account.AccountPaymentMapper;
|
|
|
-import com.fjhx.account.service.account.*;
|
|
|
+import com.fjhx.account.service.account.AccountManagementService;
|
|
|
+import com.fjhx.account.service.account.AccountPaymentRecordsService;
|
|
|
+import com.fjhx.account.service.account.AccountPaymentService;
|
|
|
+import com.fjhx.account.service.account.AccountRunningWaterService;
|
|
|
+import com.fjhx.account.service.payment.PaymentTypeService;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
@@ -28,8 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -49,8 +56,6 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
@Autowired
|
|
|
private ISysDeptService sysDeptService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private AccountRemainderService accountRemainderService;
|
|
|
|
|
|
@Autowired
|
|
|
private AccountRunningWaterService accountRunningWaterService;
|
|
@@ -61,6 +66,9 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
@Autowired
|
|
|
private AccountPaymentRecordsService accountPaymentRecordsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PaymentTypeService paymentTypeService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<AccountPaymentVo> getPage(AccountRequestFundsSelectDto dto) {
|
|
|
|
|
@@ -98,7 +106,7 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
wrapper.like(ObjectUtil.isNotEmpty(dto.getOppositeAccountName()), "ap.name", dto.getOppositeAccountName());
|
|
|
|
|
|
|
|
|
- wrapper.in("ap.company_id", SecurityUtils.getCompanyIds());
|
|
|
+
|
|
|
wrapper.eq(ObjectUtil.isNotEmpty(dto.getCompanyId()), "ap.company_id", dto.getCompanyId());
|
|
|
|
|
|
|
|
@@ -108,11 +116,6 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
UserUtil.assignmentNickName(records, AccountPayment::getDataUser, AccountPaymentVo::setUserName);
|
|
|
|
|
@@ -120,9 +123,33 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
List<SysDept> sysDeptList = sysDeptService.list();
|
|
|
Map<Long, String> deptMap = sysDeptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
|
|
|
+
|
|
|
+ Map<Long, String> paymentTypeMap = paymentTypeService.mapKV(PaymentType::getId, PaymentType::getName, q -> q.orderByAsc(PaymentType::getId));
|
|
|
+
|
|
|
for (AccountPaymentVo record : records) {
|
|
|
- record.setCorporationName(deptMap.get(record.getCorporationId()));
|
|
|
+ List<String> nameList = new ArrayList<>();
|
|
|
+
|
|
|
+ String companyIds = record.getCompanyIds();
|
|
|
+ if (ObjectUtil.isNull(companyIds)) {
|
|
|
+ companyIds = "";
|
|
|
+ }
|
|
|
+ List<Long> collect = Arrays.stream(companyIds.split(","))
|
|
|
+ .filter(item -> ObjectUtil.isNotEmpty(item)).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ collect.add(record.getCompanyId());
|
|
|
+ collect = collect.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ for (Long aLong : collect) {
|
|
|
+ nameList.add(deptMap.getOrDefault(aLong, String.valueOf(aLong)));
|
|
|
+ }
|
|
|
+
|
|
|
+ record.setCorporationName(nameList.stream().collect(Collectors.joining(",")));
|
|
|
record.setDeptName(deptMap.get(record.getDepartmentId()));
|
|
|
+
|
|
|
+
|
|
|
+ String type = record.getType();
|
|
|
+ if (ObjectUtil.isNotEmpty(type) && type.matches("\\d+")) {
|
|
|
+ record.setTypeName(paymentTypeMap.get(Long.valueOf(type)));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return page;
|
|
@@ -179,19 +206,19 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
Long companyId = SecurityUtils.getCompanyId();
|
|
|
accountPaymentDto.setCompanyId(companyId);
|
|
|
|
|
|
- AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
|
|
|
- .eq(AccountRemainder::getAccountManagementId, accountPaymentDto.getAccountManagementId())
|
|
|
- .eq(AccountRemainder::getCurrency, accountPaymentDto.getCurrency()));
|
|
|
-
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
- throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (accountRemainder.getRemainder().compareTo(accountPaymentDto.getAmount()) < 0) {
|
|
|
- throw new ServiceException("账户余额不足");
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
AccountPayment oldAccountPayment = this.getById(accountPaymentDto.getId());
|
|
@@ -227,13 +254,13 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
accountPaymentRecords.setCompanyId(companyId);
|
|
|
accountPaymentRecordsService.save(accountPaymentRecords);
|
|
|
|
|
|
-
|
|
|
- accountRemainder.setChangeRemainder(accountPaymentDto.getAmount());
|
|
|
-
|
|
|
- accountRemainder.setRemainder(accountRemainder.getRemainder().subtract(accountPaymentDto.getAmount()));
|
|
|
-
|
|
|
- accountRemainder.setStatus("20");
|
|
|
- accountRemainderService.updateById(accountRemainder);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
ObsFileUtil.saveFile(accountPaymentDto.getFileList(), accountPaymentRecords.getId());
|