|
@@ -0,0 +1,72 @@
|
|
|
+package com.fjhx.account.service.transaction.impl;
|
|
|
+
|
|
|
+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.entity.transaction.dto.TransactionDto;
|
|
|
+import com.fjhx.account.entity.transaction.dto.TransactionSelectDto;
|
|
|
+import com.fjhx.account.entity.transaction.po.Transaction;
|
|
|
+import com.fjhx.account.entity.transaction.vo.TransactionVo;
|
|
|
+import com.fjhx.account.mapper.transaction.TransactionMapper;
|
|
|
+import com.fjhx.account.service.account.AccountManagementService;
|
|
|
+import com.fjhx.account.service.transaction.TransactionDepartmentService;
|
|
|
+import com.fjhx.account.service.transaction.TransactionService;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 往来管理 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2023-06-26
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TransactionServiceImpl extends ServiceImpl<TransactionMapper, Transaction> implements TransactionService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AccountManagementService accountManagementService;
|
|
|
+ @Autowired
|
|
|
+ private TransactionDepartmentService transactionDepartmentService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<TransactionVo> getPage(TransactionSelectDto dto) {
|
|
|
+ IWrapper<Transaction> wrapper = getWrapper();
|
|
|
+ //条件筛选
|
|
|
+ wrapper.eq(Transaction::getIsFlowingWater, dto.getIsFlowingWater());
|
|
|
+ wrapper.eq(Transaction::getDepartmentId, dto.getDepartmentId());
|
|
|
+ wrapper.eq(Transaction::getType, dto.getType());
|
|
|
+ //关键字搜索
|
|
|
+ List<Long> accountIds = accountManagementService.listObject(AccountManagement::getId,
|
|
|
+ q -> q.like(AccountManagement::getName, dto.getKeyword()));
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField(Transaction::getAmount),
|
|
|
+ new SqlField(Transaction::getRemark)
|
|
|
+ ).or().in(Transaction::getAccountId, accountIds);
|
|
|
+ //排序
|
|
|
+ wrapper.orderByDesc("t", Transaction::getId);
|
|
|
+ Page<TransactionVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ //赋值往来单位名称
|
|
|
+ List<TransactionVo> records = page.getRecords();
|
|
|
+ transactionDepartmentService.attributeAssign(records, TransactionVo::getDepartmentId, (item, transactionDepartment) -> {
|
|
|
+ item.setDepartmentName(transactionDepartment.getName());
|
|
|
+ });
|
|
|
+ //赋值往来账户名称
|
|
|
+ accountManagementService.attributeAssign(records, TransactionVo::getAccountId, (item, account) -> {
|
|
|
+ item.setAccountName(account.getName());
|
|
|
+ });
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(TransactionDto transactionDto) {
|
|
|
+ this.save(transactionDto);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|