|
@@ -5,17 +5,13 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
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.entity.account.po.AccountPayment;
|
|
|
-import com.fjhx.account.entity.account.po.AccountRemainder;
|
|
|
-import com.fjhx.account.entity.account.po.AccountRunningWater;
|
|
|
+import com.fjhx.account.entity.account.po.*;
|
|
|
import com.fjhx.account.entity.write.dto.WriteOffRecordsDto;
|
|
|
import com.fjhx.account.entity.write.dto.WriteOffRecordsSelectDto;
|
|
|
import com.fjhx.account.entity.write.po.WriteOffRecords;
|
|
|
import com.fjhx.account.entity.write.vo.WriteOffRecordsVo;
|
|
|
import com.fjhx.account.mapper.write.WriteOffRecordsMapper;
|
|
|
-import com.fjhx.account.service.account.AccountPaymentService;
|
|
|
-import com.fjhx.account.service.account.AccountRemainderService;
|
|
|
-import com.fjhx.account.service.account.AccountRunningWaterService;
|
|
|
+import com.fjhx.account.service.account.*;
|
|
|
import com.fjhx.account.service.write.WriteOffRecordsService;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
@@ -26,6 +22,7 @@ import com.ruoyi.system.utils.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -47,6 +44,10 @@ public class WriteOffRecordsServiceImpl extends ServiceImpl<WriteOffRecordsMappe
|
|
|
private AccountRemainderService accountRemainderService;
|
|
|
@Autowired
|
|
|
private AccountRunningWaterService accountRunningWaterService;
|
|
|
+ @Autowired
|
|
|
+ private AccountPaymentRecordsService accountPaymentRecordsService;
|
|
|
+ @Autowired
|
|
|
+ private AccountManagementService accountManagementService;
|
|
|
|
|
|
@Override
|
|
|
public Page<WriteOffRecordsVo> getPage(WriteOffRecordsSelectDto dto) {
|
|
@@ -73,28 +74,41 @@ public class WriteOffRecordsServiceImpl extends ServiceImpl<WriteOffRecordsMappe
|
|
|
Assert.notEmpty(accountPayment, "查询不到打款信息");
|
|
|
//修改打款状态为未打款
|
|
|
accountPayment.setStatus("20");
|
|
|
+ //清空已打款金额
|
|
|
+ accountPayment.setAmount(BigDecimal.ZERO);
|
|
|
accountPaymentService.updateById(accountPayment);
|
|
|
- //清理历史附件
|
|
|
- ObsFileUtil.removeFile(accountPayment.getId());
|
|
|
- //赋值之前的打款时间
|
|
|
+
|
|
|
+ //赋值最后一次打款时间
|
|
|
writeOffRecordsDto.setAccountPaymentDate(accountPayment.getExpensesTime());
|
|
|
this.save(writeOffRecordsDto);
|
|
|
- //根据币种回滚余额
|
|
|
- AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
|
|
|
- .eq(AccountRemainder::getAccountManagementId, accountPayment.getAccountManagementId())
|
|
|
- .eq(AccountRemainder::getCurrency, accountPayment.getCurrency()));
|
|
|
- // 如果不存在这条数据则返回币种不存在
|
|
|
- if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
- throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
- }
|
|
|
- accountRemainderService.update(q -> q
|
|
|
- .eq(AccountRemainder::getId, accountRemainder.getId())
|
|
|
- .setSql("remainder = remainder + " + accountPayment.getAmount())
|
|
|
+
|
|
|
+ List<AccountPaymentRecords> accountPaymentRecordsList = accountPaymentRecordsService.list(
|
|
|
+ q -> q.eq(AccountPaymentRecords::getAccountPaymentId, accountPayment.getId())
|
|
|
);
|
|
|
+ for (AccountPaymentRecords accountPaymentRecords : accountPaymentRecordsList) {
|
|
|
+ //清理历史附件
|
|
|
+ ObsFileUtil.removeFile(accountPaymentRecords.getId());
|
|
|
+ AccountManagement accountManagement = accountManagementService.getById(accountPaymentRecords.getAccountManagementId());
|
|
|
+ if (ObjectUtil.isEmpty(accountManagement)) {
|
|
|
+ throw new ServiceException("资金账户不存在:" + accountPaymentRecords.getAccountManagementId());
|
|
|
+ }
|
|
|
+ //根据币种回滚余额
|
|
|
+ AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
|
|
|
+ .eq(AccountRemainder::getAccountManagementId, accountPaymentRecords.getAccountManagementId())
|
|
|
+ .eq(AccountRemainder::getCurrency, accountPaymentRecords.getCurrency()));
|
|
|
+ // 如果不存在这条数据则返回币种不存在
|
|
|
+ if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
+ String format = String.format("账户%s不存在币种(%s),请前往资金账户添加", accountManagement.getName(), accountPaymentRecords.getCurrency());
|
|
|
+ throw new ServiceException(format);
|
|
|
+ }
|
|
|
+ accountRemainderService.update(q -> q
|
|
|
+ .eq(AccountRemainder::getId, accountRemainder.getId())
|
|
|
+ .setSql("remainder = remainder + " + accountPaymentRecords.getAmount())
|
|
|
+ );
|
|
|
+ }
|
|
|
//删除打款对应的流水
|
|
|
- AccountRunningWater accountRunningWater = accountRunningWaterService.getOne(q -> q.eq(AccountRunningWater::getBusinessId, accountPayment.getId()));
|
|
|
- Assert.notEmpty(accountRunningWater, "查询不到打款流水信息");
|
|
|
- accountRunningWaterService.removeById(accountRunningWater);
|
|
|
+ List<AccountRunningWater> accountRunningWaterList = accountRunningWaterService.list(q -> q.eq(AccountRunningWater::getBusinessId, accountPayment.getId()));
|
|
|
+ Assert.notEmpty(accountRunningWaterList, "查询不到打款流水信息");
|
|
|
}
|
|
|
|
|
|
}
|