|
@@ -26,14 +26,17 @@ import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.entity.corporation.po.Corporation;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.util.excel.util.ExcelUtil;
|
|
|
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.ruoyi.common.core.domain.BaseSelectDto;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.system.service.ISysDeptService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -71,6 +74,8 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
|
|
|
@Autowired
|
|
|
private AccountService accountService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -142,10 +147,19 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
QueryWrapper<Object> wrapper = getPageWrapper(dto);
|
|
|
Page<AccountRunningWaterVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<AccountRunningWaterVo> records = page.getRecords();
|
|
|
- //赋值归属公司名称
|
|
|
- corporationService.attributeAssign(records, AccountRunningWaterVo::getCorporationId, (item, corporation) -> {
|
|
|
- item.setCorporationName(corporation.getName());
|
|
|
- });
|
|
|
+// //赋值归属公司名称
|
|
|
+// corporationService.attributeAssign(records, AccountRunningWaterVo::getCorporationId, (item, corporation) -> {
|
|
|
+// item.setCorporationName(corporation.getName());
|
|
|
+// });
|
|
|
+
|
|
|
+ // 查询部门信息
|
|
|
+ List<SysDept> sysDeptList = deptService.list();
|
|
|
+ Map<Long, String> sysDeptMap = sysDeptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
+
|
|
|
+ for (AccountRunningWaterVo record : records) {
|
|
|
+ record.setCorporationName(sysDeptMap.get(record.getCompanyId()));
|
|
|
+ }
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -232,34 +246,37 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
dto.setRate(divide);
|
|
|
}
|
|
|
|
|
|
- // 修改账户余额表的余额
|
|
|
- AccountRemainder accountRemainder = accountRemainderService.getOne(q -> q
|
|
|
- .eq(AccountRemainder::getAccountManagementId, dto.getAccountManagementId())
|
|
|
- .eq(AccountRemainder::getCurrency, dto.getCurrency())
|
|
|
- );
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
- throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
- }
|
|
|
- BigDecimal amount = dto.getAmount();
|
|
|
- String status = dto.getStatus();
|
|
|
- BigDecimal remainder = accountRemainder.getRemainder();
|
|
|
-
|
|
|
- accountRemainder.setStatus(status);
|
|
|
- accountRemainder.setChangeRemainder(amount);
|
|
|
-
|
|
|
- if (status.equals("10")) {
|
|
|
- accountRemainder.setRemainder(remainder.add(amount));
|
|
|
- } else if (status.equals("20")) {
|
|
|
- if (remainder.compareTo(amount) < 0) {
|
|
|
- throw new ServiceException("账户余额不足");
|
|
|
- }
|
|
|
- accountRemainder.setRemainder(remainder.subtract(amount));
|
|
|
- }
|
|
|
- accountRemainderService.updateById(accountRemainder);
|
|
|
+// // 修改账户余额表的余额
|
|
|
+// AccountRemainder accountRemainder = accountRemainderService.getOne(q -> q
|
|
|
+// .eq(AccountRemainder::getAccountManagementId, dto.getAccountManagementId())
|
|
|
+// .eq(AccountRemainder::getCurrency, dto.getCurrency())
|
|
|
+// );
|
|
|
+//
|
|
|
+// if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
+// throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
+// }
|
|
|
+// BigDecimal amount = dto.getAmount();
|
|
|
+// String status = dto.getStatus();
|
|
|
+// BigDecimal remainder = accountRemainder.getRemainder();
|
|
|
+//
|
|
|
+// accountRemainder.setStatus(status);
|
|
|
+// accountRemainder.setChangeRemainder(amount);
|
|
|
+//
|
|
|
+// if (status.equals("10")) {
|
|
|
+// accountRemainder.setRemainder(remainder.add(amount));
|
|
|
+// } else if (status.equals("20")) {
|
|
|
+// if (remainder.compareTo(amount) < 0) {
|
|
|
+// throw new ServiceException("账户余额不足");
|
|
|
+// }
|
|
|
+// accountRemainder.setRemainder(remainder.subtract(amount));
|
|
|
+// }
|
|
|
+// accountRemainderService.updateById(accountRemainder);
|
|
|
|
|
|
this.save(dto);
|
|
|
|
|
|
+ //保存凭证附件
|
|
|
+ ObsFileUtil.saveFile(dto.getFileList(), dto.getBusinessId());
|
|
|
+
|
|
|
// 发送消息推送
|
|
|
sendSocket(dto);
|
|
|
}
|
|
@@ -322,7 +339,7 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
- public void delete(Long id) {
|
|
|
+ public synchronized void delete(Long id) {
|
|
|
AccountRunningWater accountRunningWater = getById(id);
|
|
|
Assert.notEmpty(accountRunningWater, "获取不到该流水信息");
|
|
|
|
|
@@ -333,6 +350,10 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
//操作余额
|
|
|
changeRemainder(accountRunningWater);
|
|
|
|
|
|
+ if (ObjectUtil.equals(accountRunningWater.getIsClaim(), 1)) {
|
|
|
+ throw new ServiceException("该回款已被确认,禁止删除!");
|
|
|
+ }
|
|
|
+
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
@@ -487,44 +508,44 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
* 余额操作
|
|
|
*/
|
|
|
private void changeRemainder(AccountRunningWater accountRunningWater) {
|
|
|
- // 修改账户余额表的余额
|
|
|
- AccountRemainder accountRemainder = accountRemainderService.getOne(q -> q
|
|
|
- .eq(AccountRemainder::getAccountManagementId, accountRunningWater.getAccountManagementId())
|
|
|
- .eq(AccountRemainder::getCurrency, accountRunningWater.getCurrency())
|
|
|
- );
|
|
|
- if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
- throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
- }
|
|
|
- BigDecimal amount = accountRunningWater.getAmount();
|
|
|
- String status = accountRunningWater.getStatus();
|
|
|
- BigDecimal remainder = accountRemainder.getRemainder();
|
|
|
-
|
|
|
- accountRemainder.setStatus(status);
|
|
|
- accountRemainder.setChangeRemainder(amount);
|
|
|
-
|
|
|
- boolean update = false;
|
|
|
- if ("10".equals(accountRunningWater.getStatus())) {
|
|
|
- //收入操作
|
|
|
- update = accountRemainderService.update(q -> q
|
|
|
- .setSql("remainder = remainder + " + accountRunningWater.getAmount())
|
|
|
- .setSql("change_remainder = " + accountRunningWater.getAmount())
|
|
|
- .eq(AccountRemainder::getId, accountRemainder.getId())
|
|
|
- );
|
|
|
- } else {
|
|
|
- //支出操作
|
|
|
- BigDecimal subtract = remainder.subtract(amount);
|
|
|
- if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- throw new ServiceException("账户余额不足");
|
|
|
- }
|
|
|
-
|
|
|
- update = accountRemainderService.update(q -> q
|
|
|
- .setSql("remainder = remainder - " + accountRunningWater.getAmount())
|
|
|
- .setSql("change_remainder = " + accountRunningWater.getAmount())
|
|
|
- .eq(AccountRemainder::getId, accountRemainder.getId())
|
|
|
- .apply("remainder - {0} >= 0", accountRunningWater.getAmount())
|
|
|
- );
|
|
|
- }
|
|
|
- Assert.eqTrue(update, "余额操作失败,请重试!!!");
|
|
|
+// // 修改账户余额表的余额
|
|
|
+// AccountRemainder accountRemainder = accountRemainderService.getOne(q -> q
|
|
|
+// .eq(AccountRemainder::getAccountManagementId, accountRunningWater.getAccountManagementId())
|
|
|
+// .eq(AccountRemainder::getCurrency, accountRunningWater.getCurrency())
|
|
|
+// );
|
|
|
+// if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
+// throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
+// }
|
|
|
+// BigDecimal amount = accountRunningWater.getAmount();
|
|
|
+// String status = accountRunningWater.getStatus();
|
|
|
+// BigDecimal remainder = accountRemainder.getRemainder();
|
|
|
+//
|
|
|
+// accountRemainder.setStatus(status);
|
|
|
+// accountRemainder.setChangeRemainder(amount);
|
|
|
+//
|
|
|
+// boolean update = false;
|
|
|
+// if ("10".equals(accountRunningWater.getStatus())) {
|
|
|
+// //收入操作
|
|
|
+// update = accountRemainderService.update(q -> q
|
|
|
+// .setSql("remainder = remainder + " + accountRunningWater.getAmount())
|
|
|
+// .setSql("change_remainder = " + accountRunningWater.getAmount())
|
|
|
+// .eq(AccountRemainder::getId, accountRemainder.getId())
|
|
|
+// );
|
|
|
+// } else {
|
|
|
+// //支出操作
|
|
|
+// BigDecimal subtract = remainder.subtract(amount);
|
|
|
+// if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+// throw new ServiceException("账户余额不足");
|
|
|
+// }
|
|
|
+//
|
|
|
+// update = accountRemainderService.update(q -> q
|
|
|
+// .setSql("remainder = remainder - " + accountRunningWater.getAmount())
|
|
|
+// .setSql("change_remainder = " + accountRunningWater.getAmount())
|
|
|
+// .eq(AccountRemainder::getId, accountRemainder.getId())
|
|
|
+// .apply("remainder - {0} >= 0", accountRunningWater.getAmount())
|
|
|
+// );
|
|
|
+// }
|
|
|
+// Assert.eqTrue(update, "余额操作失败,请重试!!!");
|
|
|
}
|
|
|
|
|
|
@Override
|