Commit f8cc2ff0 by zhangxingmin

Merge remote-tracking branch 'origin/dev' into prod

parents 74b63aac 6d940b51
......@@ -953,11 +953,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
expectedFortune.setFortuneName(queryByDict(expectedFortuneDto.getFortuneType()));
// 应付款编号(序号递增)
expectedFortune.setPayableNo(this.createPayableNo(expectedFortune.getFortuneBizType(), ++currentSeq));
// 默认结算汇率
expectedFortune.setDefaultExchangeRate(
queryExchangeRateByFeign(expectedFortuneDto.getCurrency(), "HKD"));
// 计算港币金额
expectedFortune.setHkdAmount(expectedFortuneDto.getAmount().multiply(expectedFortune.getDefaultExchangeRate()));
// // 默认结算汇率
// expectedFortune.setDefaultExchangeRate(
// queryExchangeRateByFeign(expectedFortuneDto.getCurrency(), "HKD"));
// // 计算港币金额
// expectedFortune.setHkdAmount(expectedFortuneDto.getAmount().multiply(expectedFortune.getDefaultExchangeRate()));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
expectedFortune.setPaidAmount(BigDecimal.ZERO);
// 转介人比例默认100%
......@@ -1013,7 +1014,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
private void validateAdd(List<ExpectedFortuneAddRequest> fortuneAddRequestList) {
for (ExpectedFortuneAddRequest expectedFortuneDto : fortuneAddRequestList) {
if (Objects.isNull(expectedFortuneDto.getAmount())) {
if (Objects.isNull(expectedFortuneDto.getHkdAmount())) {
throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "预计出账金额不能为空");
}
if (Objects.isNull(expectedFortuneDto.getCurrency())) {
......
......@@ -76,10 +76,10 @@ public class ExpectedFortuneAddRequest {
private String fortuneType;
/**
* 出账金额
* 出账金额 单位:港币
*/
@Schema(description = "出账金额")
private BigDecimal amount;
@Schema(description = "出账金额 单位:港币")
private BigDecimal hkdAmount;
/**
* 出账币种
......
......@@ -169,12 +169,6 @@ public class ExpectedFortune implements Serializable {
private String statusDesc;
/**
* 本次出账金额
*/
// @TableField("current_payment_amount")
// private BigDecimal currentPaymentAmount;
/**
* 预计出账日期
*/
@TableField("payout_date")
......
......@@ -18,10 +18,7 @@ import com.yd.common.utils.RandomStringGenerator;
import com.yd.csf.service.dto.*;
import com.yd.csf.service.enums.FortuneAccountStatusEnum;
import com.yd.csf.service.enums.FortuneStatusEnum;
import com.yd.csf.service.model.ExpectedFortune;
import com.yd.csf.service.model.Fortune;
import com.yd.csf.service.model.FortuneAccount;
import com.yd.csf.service.model.FortuneAccountEditRecord;
import com.yd.csf.service.model.*;
import com.yd.csf.service.service.FortuneAccountEditRecordService;
import com.yd.csf.service.service.FortuneAccountService;
import com.yd.csf.service.dao.FortuneAccountMapper;
......@@ -222,7 +219,9 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
AuthUserDto currentLoginUser = SecurityUtil.getCurrentLoginUser();
Long loginUserId = currentLoginUser.getId();
FortuneAccount fortuneAccount = this.getByFortuneAccountBizId(fortuneAccountUpdateRequest.getFortuneAccountBizId());
String fortuneAccountBizId = fortuneAccountUpdateRequest.getFortuneAccountBizId();
FortuneAccount fortuneAccount = this.getByFortuneAccountBizId(fortuneAccountBizId);
if (fortuneAccount == null) {
throw new BusinessException(ResultCode.NULL_ERROR.getCode(), ResultCode.NULL_ERROR.getMessage());
}
......@@ -235,6 +234,18 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
this.updateById(fortuneAccount);
// // 更新关联 expected_fortune、fortune的出账日期
// if (fortuneAccountUpdateRequest.getFortuneAccountDate() != null) {
// List<Fortune> fortuneList = fortuneService.lambdaQuery().eq(Fortune::getFortuneAccountBizId, fortuneAccountBizId).list();
// if (CollectionUtils.isNotEmpty(fortuneList)) {
// Set<String> expectedBizIdSet = fortuneList.stream().map(Fortune::getExpectedFortuneBizId).collect(Collectors.toSet());
// // 查询 expected_fortune 列表
// List<ExpectedFortune> expectedList = expectedFortuneService.lambdaQuery()
// .in(ExpectedFortune::getExpectedFortuneBizId, expectedBizIdSet)
// .list();
//
// }
// }
return true;
}
......@@ -361,7 +372,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.set(ExpectedFortune::getUnpaidRatio,
unpaid.divide(totalAmount, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)))
.set(ExpectedFortune::getStatus, newStatus)
.set(ExpectedFortune::getActualPayoutDate, new Date())
// .set(ExpectedFortune::getActualPayoutDate, new Date())
.set(ExpectedFortune::getUpdaterId, loginUserId.toString())
.set(ExpectedFortune::getUpdateTime, LocalDateTime.now())
.eq(ExpectedFortune::getId, ef.getId())
......
......@@ -749,8 +749,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
fortune.setStatus(FortuneStatusEnum.MATCH_FAIL.getItemValue());
fortune.setRemark("未找到当前预计发佣对应的来佣");
}
// 更新预计出账的数据
processExpectedFortune(expectedFortune, fortune, expectedFortuneUpdateList);
}
// 生成发佣业务ID
......@@ -770,28 +769,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return true;
}
private void processExpectedFortune(ExpectedFortune expectedFortune, Fortune fortune, List<ExpectedFortune> expectedFortuneUpdateList) {
// 出账币种
String currency = fortune.getCurrency();
// 港币出账金额
BigDecimal hkdAmount = fortune.getHkdAmount();
ExpectedFortune updateObj = new ExpectedFortune();
updateObj.setId(expectedFortune.getId());
updateObj.setHkdAmount(expectedFortune.getHkdAmount().add(hkdAmount));
updateObj.setUnpaidAmount(hkdAmount.add(expectedFortune.getUnpaidAmount()));
updateObj.setUnpaidRatio(updateObj.getUnpaidAmount().divide(updateObj.getHkdAmount(), 4, RoundingMode.HALF_UP));
// 根据预计出账币种计算 expectedFortune.getAmount() 字段
BigDecimal originalAmount = fortune.getAmount(); // 原始币种金额
BigDecimal exchangeRate = queryExchangeRateByFeign(currency, expectedFortune.getCurrency());
BigDecimal amount = originalAmount.multiply(exchangeRate);// 本次新增出账金额
updateObj.setAmount(amount.add(expectedFortune.getAmount()));
expectedFortuneUpdateList.add(updateObj);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment