Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-csf
Commits
856a8ff9
Commit
856a8ff9
authored
Jan 09, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/test' into test
parents
ad444037
e33e4b9f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
163 additions
and
62 deletions
+163
-62
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
+53
-16
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneUpdateRequest.java
+6
-0
yd-csf-service/src/main/java/com/yd/csf/service/model/ExpectedFortune.java
+12
-0
yd-csf-service/src/main/java/com/yd/csf/service/model/Fortune.java
+15
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionExpectedServiceImpl.java
+1
-1
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+11
-31
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+39
-4
yd-csf-service/src/main/resources/mappers/CommissionMapper.xml
+16
-3
yd-csf-service/src/main/resources/mappers/ExpectedFortuneMapper.xml
+1
-1
yd-csf-service/src/main/resources/mappers/FortuneMapper.xml
+9
-6
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
View file @
856a8ff9
...
@@ -40,6 +40,8 @@ import com.yd.csf.service.service.PolicyService;
...
@@ -40,6 +40,8 @@ import com.yd.csf.service.service.PolicyService;
import
com.yd.csf.service.vo.ExpectedFortuneExportDTO
;
import
com.yd.csf.service.vo.ExpectedFortuneExportDTO
;
import
com.yd.csf.service.vo.ExpectedFortuneStatisticsVO
;
import
com.yd.csf.service.vo.ExpectedFortuneStatisticsVO
;
import
com.yd.user.feign.client.clientuser.ApiClientUserFeignClient
;
import
com.yd.user.feign.client.clientuser.ApiClientUserFeignClient
;
import
com.yd.user.feign.client.sysdict.ApiSysDictFeignClient
;
import
com.yd.user.feign.response.sysdict.GetDictItemListByDictTypeResponse
;
import
jodd.util.StringUtil
;
import
jodd.util.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
...
@@ -65,43 +67,36 @@ import java.util.stream.Collectors;
...
@@ -65,43 +67,36 @@ import java.util.stream.Collectors;
@Slf4j
@Slf4j
@Service
@Service
public
class
ApiExpectedFortuneServiceImpl
implements
ApiExpectedFortuneService
{
public
class
ApiExpectedFortuneServiceImpl
implements
ApiExpectedFortuneService
{
@Autowired
@Autowired
private
PolicyService
policyService
;
private
PolicyService
policyService
;
@Autowired
@Autowired
private
ApiClientUserFeignClient
apiClientUserFeignClient
;
private
ApiClientUserFeignClient
apiClientUserFeignClient
;
@Autowired
@Autowired
private
ICommissionRuleBindingService
iCommissionRuleBindingService
;
private
ICommissionRuleBindingService
iCommissionRuleBindingService
;
@Autowired
@Autowired
private
ApiBasicLawCalculateService
apiBasicLawCalculateService
;
private
ApiBasicLawCalculateService
apiBasicLawCalculateService
;
@Autowired
@Autowired
private
IExpectedFortuneService
iExpectedFortuneService
;
private
IExpectedFortuneService
iExpectedFortuneService
;
@Autowired
@Autowired
private
ApplicationContext
applicationContext
;
private
ApplicationContext
applicationContext
;
private
ApiExpectedFortuneService
getSelf
()
{
private
ApiExpectedFortuneService
getSelf
()
{
return
applicationContext
.
getBean
(
ApiExpectedFortuneService
.
class
);
return
applicationContext
.
getBean
(
ApiExpectedFortuneService
.
class
);
}
}
@Autowired
@Autowired
private
TransactionTemplate
transactionTemplate
;
private
TransactionTemplate
transactionTemplate
;
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
@Autowired
@Autowired
private
ApiExpectedFortuneLogService
apiExpectedFortuneLogService
;
private
ApiExpectedFortuneLogService
apiExpectedFortuneLogService
;
@Autowired
@Autowired
private
PolicyBrokerService
policyBrokerService
;
private
PolicyBrokerService
policyBrokerService
;
@Autowired
private
ApiSysDictFeignClient
apiSysDictFeignClient
;
/**
/**
* 生成预计发佣
* 生成预计发佣
*
* @param request
* @param request
* @return
* @return
*/
*/
...
@@ -112,16 +107,16 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -112,16 +107,16 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
if
(
StringUtil
.
isNotBlank
(
value
))
{
if
(
StringUtil
.
isNotBlank
(
value
))
{
//有值正在执行,提示
//有值正在执行,提示
return
Result
.
fail
(
"生成预计发佣正在执行中,无需再次执行"
);
return
Result
.
fail
(
"生成预计发佣正在执行中,无需再次执行"
);
}
else
{
}
else
{
//无值设置值,表示正在执行
//无值设置值,表示正在执行
redisUtil
.
setCacheObject
(
RedisConstants
.
EXPECTED_FORTUNE
+
request
.
getPolicyNo
(),
request
.
getPolicyNo
());
redisUtil
.
setCacheObject
(
RedisConstants
.
EXPECTED_FORTUNE
+
request
.
getPolicyNo
(),
request
.
getPolicyNo
());
}
}
List
<
ExpectedFortune
>
list
=
iExpectedFortuneService
.
queryList
(
request
.
getPolicyNo
());
List
<
ExpectedFortune
>
list
=
iExpectedFortuneService
.
queryList
(
request
.
getPolicyNo
());
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
throw
new
BusinessException
(
"当前保单已经生成过预计发佣数据,无需再次生成"
);
throw
new
BusinessException
(
"当前保单已经生成过预计发佣数据,无需再次生成"
);
}
}
//根据保单号查询保单和转介人列表信息
//根据保单号查询保单和转介人列表信息
List
<
QueryPolicyAndBrokerDto
>
queryPolicyAndBrokerDtoList
=
policyService
.
queryPolicyBrokerList
(
request
.
getPolicyNo
());
List
<
QueryPolicyAndBrokerDto
>
queryPolicyAndBrokerDtoList
=
policyService
.
queryPolicyBrokerList
(
request
.
getPolicyNo
());
if
(
CollectionUtils
.
isEmpty
(
queryPolicyAndBrokerDtoList
))
{
if
(
CollectionUtils
.
isEmpty
(
queryPolicyAndBrokerDtoList
))
{
throw
new
BusinessException
(
"保单和转介人信息不存在"
);
throw
new
BusinessException
(
"保单和转介人信息不存在"
);
}
}
...
@@ -141,13 +136,14 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -141,13 +136,14 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表
//遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表
// 通过代理对象调用
// 通过代理对象调用
getSelf
().
execute
(
queryPolicyAndBrokerDtoList
,
commissionRuleBindingList
,
request
.
getPolicyNo
());
getSelf
().
execute
(
queryPolicyAndBrokerDtoList
,
commissionRuleBindingList
,
request
.
getPolicyNo
());
return
Result
.
success
(
null
,
"生成预计发佣正在处理....,稍后查看预计发佣列表"
);
return
Result
.
success
(
null
,
"生成预计发佣正在处理....,稍后查看预计发佣列表"
);
}
}
/**
/**
* 异步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表
* 异步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表
*
* @param queryPolicyAndBrokerDtoList
* @param queryPolicyAndBrokerDtoList
* @param commissionRuleBindingList
* @param commissionRuleBindingList
* @return
* @return
...
@@ -232,6 +228,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -232,6 +228,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/**
/**
* 执行 - 奖励(非销售佣金基本法)
* 执行 - 奖励(非销售佣金基本法)
*
* @param dto
* @param dto
* @return
* @return
*/
*/
...
@@ -297,6 +294,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -297,6 +294,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/**
/**
* 执行 - 销售佣金(销售佣金基本法)
* 执行 - 销售佣金(销售佣金基本法)
*
* @param dto
* @param dto
* @return
* @return
*/
*/
...
@@ -357,6 +355,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -357,6 +355,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/**
/**
* 生成保单预计发佣表记录
* 生成保单预计发佣表记录
*
* @return
* @return
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -366,7 +365,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -366,7 +365,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//获得积分业务员绑定的基本法列表对应计算值结果集合
//获得积分业务员绑定的基本法列表对应计算值结果集合
for
(
AlgorithmResDto
algorithmResDto
:
fortuneDto
.
getAlgorithmResDtoList
())
{
for
(
AlgorithmResDto
algorithmResDto
:
fortuneDto
.
getAlgorithmResDtoList
())
{
if
(
Objects
.
isNull
(
algorithmResDto
.
getCalculatedValue
())
if
(
Objects
.
isNull
(
algorithmResDto
.
getCalculatedValue
())
||
algorithmResDto
.
getCalculatedValue
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
){
||
algorithmResDto
.
getCalculatedValue
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
//判空判0
//判空判0
continue
;
continue
;
}
}
...
@@ -460,6 +459,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -460,6 +459,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
if
(
CollectionUtils
.
isEmpty
(
fortuneAddRequestList
))
{
if
(
CollectionUtils
.
isEmpty
(
fortuneAddRequestList
))
{
return
true
;
return
true
;
}
}
validateAdd
(
fortuneAddRequestList
);
// 查询最新一条有 payableNo 记录
// 查询最新一条有 payableNo 记录
ExpectedFortune
latest
=
iExpectedFortuneService
.
getOne
(
ExpectedFortune
latest
=
iExpectedFortuneService
.
getOne
(
new
QueryWrapper
<
ExpectedFortune
>().
isNotNull
(
"payable_no"
).
orderByDesc
(
"id"
).
last
(
"LIMIT 1"
),
new
QueryWrapper
<
ExpectedFortune
>().
isNotNull
(
"payable_no"
).
orderByDesc
(
"id"
).
last
(
"LIMIT 1"
),
...
@@ -475,6 +476,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -475,6 +476,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
expectedFortune
.
setExpectedFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_EXPECTED_FORTUNE
.
getCode
()));
expectedFortune
.
setExpectedFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_EXPECTED_FORTUNE
.
getCode
()));
// 应付款编号
// 应付款编号
expectedFortune
.
setPayableNo
(
this
.
createPayableNo
(
expectedFortune
.
getFortuneBizType
(),
latest
));
expectedFortune
.
setPayableNo
(
this
.
createPayableNo
(
expectedFortune
.
getFortuneBizType
(),
latest
));
// 默认结算汇率
expectedFortune
.
setDefaultExchangeRate
(
queryDefaultExchangeRate
(
expectedFortune
.
getCurrency
()));
// 计算港币金额
expectedFortune
.
setHkdAmount
(
expectedFortune
.
getAmount
().
multiply
(
expectedFortune
.
getDefaultExchangeRate
()));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
expectedFortune
.
setPaidAmount
(
BigDecimal
.
ZERO
);
expectedFortune
.
setPaidAmount
(
BigDecimal
.
ZERO
);
expectedFortune
.
setUnpaidAmount
(
expectedFortune
.
getAmount
());
expectedFortune
.
setUnpaidAmount
(
expectedFortune
.
getAmount
());
...
@@ -486,6 +491,29 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -486,6 +491,29 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
return
true
;
return
true
;
}
}
private
BigDecimal
queryDefaultExchangeRate
(
String
currency
)
{
if
(
"HKD"
.
equalsIgnoreCase
(
currency
))
{
return
BigDecimal
.
valueOf
(
1
);
}
Result
<
List
<
GetDictItemListByDictTypeResponse
>>
result
=
apiSysDictFeignClient
.
getDictItemListByDictType
(
"csf_exchange_rate_hkd"
);
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
result
.
getData
()))
{
for
(
GetDictItemListByDictTypeResponse
dictItem
:
result
.
getData
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
dictItem
.
getItemLabel
(),
currency
))
{
return
new
BigDecimal
(
dictItem
.
getItemValue
());
}
}
}
return
BigDecimal
.
ONE
;
}
private
void
validateAdd
(
List
<
ExpectedFortuneAddRequest
>
fortuneAddRequestList
)
{
for
(
ExpectedFortuneAddRequest
expectedFortuneDto
:
fortuneAddRequestList
)
{
if
(
Objects
.
isNull
(
expectedFortuneDto
.
getAmount
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"预计出账金额不能为空"
);
}
}
}
@Override
@Override
public
void
exportExpectedFortune
(
ApiExpectedFortunePageRequest
request
,
HttpServletResponse
response
)
{
public
void
exportExpectedFortune
(
ApiExpectedFortunePageRequest
request
,
HttpServletResponse
response
)
{
// 查询数据
// 查询数据
...
@@ -528,6 +556,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -528,6 +556,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/**
/**
* 分页查询 - 预计发佣
* 分页查询 - 预计发佣
*
* @param request
* @param request
* @return
* @return
*/
*/
...
@@ -590,6 +619,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -590,6 +619,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/**
/**
* 查询保单是否生成过预计发佣
* 查询保单是否生成过预计发佣
*
* @param policyNo
* @param policyNo
* @return
* @return
*/
*/
...
@@ -604,6 +634,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -604,6 +634,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/**
/**
* 根据保单号批量删除预计发佣数据
* 根据保单号批量删除预计发佣数据
*
* @param policyNo
* @param policyNo
* @return
* @return
*/
*/
...
@@ -656,6 +687,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
...
@@ -656,6 +687,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
ExpectedFortune
updateExpectedFortune
=
new
ExpectedFortune
();
ExpectedFortune
updateExpectedFortune
=
new
ExpectedFortune
();
BeanUtils
.
copyProperties
(
request
,
updateExpectedFortune
);
BeanUtils
.
copyProperties
(
request
,
updateExpectedFortune
);
updateExpectedFortune
.
setId
(
expectedFortune
.
getId
());
updateExpectedFortune
.
setId
(
expectedFortune
.
getId
());
// 默认结算汇率
if
(
updateExpectedFortune
.
getDefaultExchangeRate
()
==
null
)
{
updateExpectedFortune
.
setDefaultExchangeRate
(
queryDefaultExchangeRate
(
updateExpectedFortune
.
getCurrency
()));
}
// 计算港币金额
updateExpectedFortune
.
setHkdAmount
(
updateExpectedFortune
.
getAmount
().
multiply
(
updateExpectedFortune
.
getDefaultExchangeRate
()));
// 获取当前登录用户
// 获取当前登录用户
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
...
...
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneUpdateRequest.java
View file @
856a8ff9
...
@@ -94,6 +94,12 @@ public class FortuneUpdateRequest implements Serializable {
...
@@ -94,6 +94,12 @@ public class FortuneUpdateRequest implements Serializable {
private
String
currency
;
private
String
currency
;
/**
/**
* 出账结算汇率
*/
@Schema
(
description
=
"出账结算汇率"
)
private
BigDecimal
exchangeRate
;
/**
* 出账日期
* 出账日期
*/
*/
@Schema
(
description
=
"出账日期"
)
@Schema
(
description
=
"出账日期"
)
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/ExpectedFortune.java
View file @
856a8ff9
...
@@ -179,6 +179,18 @@ public class ExpectedFortune implements Serializable {
...
@@ -179,6 +179,18 @@ public class ExpectedFortune implements Serializable {
private
LocalDate
actualPayoutDate
;
private
LocalDate
actualPayoutDate
;
/**
/**
* 默认结算汇率
*/
@TableField
(
"default_exchange_rate"
)
private
BigDecimal
defaultExchangeRate
;
/**
* 港币预计出账金额
*/
@TableField
(
"hkd_amount"
)
private
BigDecimal
hkdAmount
;
/**
* 已出账金额
* 已出账金额
*/
*/
@TableField
(
"paid_amount"
)
@TableField
(
"paid_amount"
)
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/Fortune.java
View file @
856a8ff9
...
@@ -129,11 +129,26 @@ public class Fortune implements Serializable {
...
@@ -129,11 +129,26 @@ public class Fortune implements Serializable {
private
String
currency
;
private
String
currency
;
/**
/**
* 结算汇率
*/
private
BigDecimal
exchangeRate
;
/**
* 港币金额
*/
private
BigDecimal
hkdAmount
;
/**
* 本次出账金额
* 本次出账金额
*/
*/
private
BigDecimal
currentPaymentAmount
;
private
BigDecimal
currentPaymentAmount
;
/**
/**
* 本次出账港币金额
*/
private
BigDecimal
currentPaymentHkdAmount
;
/**
* 本期出账比例
* 本期出账比例
*/
*/
private
BigDecimal
currentPaymentRatio
;
private
BigDecimal
currentPaymentRatio
;
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionExpectedServiceImpl.java
View file @
856a8ff9
...
@@ -364,7 +364,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
...
@@ -364,7 +364,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
}
}
}
}
}
}
return
BigDecimal
.
ZERO
;
return
BigDecimal
.
ONE
;
}
}
@Override
@Override
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
856a8ff9
...
@@ -45,6 +45,7 @@ import java.math.BigDecimal;
...
@@ -45,6 +45,7 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.function.Supplier
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -165,8 +166,9 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
...
@@ -165,8 +166,9 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
// 填充应收账款编号、已入账比例、待入账比例
// 填充应收账款编号、已入账比例、待入账比例
commissionVO
.
setReceivableNo
(
commissionExpected
.
getReceivableNo
());
commissionVO
.
setReceivableNo
(
commissionExpected
.
getReceivableNo
());
if
(
commissionExpected
.
getCommissionRatio
()
!=
null
)
{
if
(
commissionExpected
.
getCommissionRatio
()
!=
null
)
{
commissionVO
.
setPaidRatio
(
commissionExpected
.
getPaidRatio
());
BigDecimal
paidRatio
=
commissionExpected
.
getPaidRatio
()
!=
null
?
commissionExpected
.
getPaidRatio
()
:
BigDecimal
.
ZERO
;
commissionVO
.
setPendingRatio
(
commissionExpected
.
getCommissionRatio
().
subtract
(
commissionExpected
.
getPaidRatio
()));
commissionVO
.
setPaidRatio
(
paidRatio
);
commissionVO
.
setPendingRatio
(
commissionExpected
.
getCommissionRatio
().
subtract
(
paidRatio
));
}
}
commissionVO
.
setCommissionExpectedStatus
(
commissionExpected
.
getStatus
());
commissionVO
.
setCommissionExpectedStatus
(
commissionExpected
.
getStatus
());
}
}
...
@@ -720,39 +722,17 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
...
@@ -720,39 +722,17 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
String
currency
=
commissionExpected
.
getCurrency
();
String
currency
=
commissionExpected
.
getCurrency
();
// 如果当前入账币种等于保单币种,直接计算来佣比例
// 如果当前入账币种等于保单币种,直接计算来佣比例
if
(
StringUtils
.
equals
(
currentCurrency
,
currency
))
{
if
(
StringUtils
.
equals
IgnoreCase
(
currentCurrency
,
currency
))
{
return
amount
.
divide
(
new
BigDecimal
(
premium
),
4
,
RoundingMode
.
HALF_UP
)
return
amount
.
divide
(
new
BigDecimal
(
premium
),
4
,
RoundingMode
.
HALF_UP
)
.
multiply
(
new
BigDecimal
(
100
));
.
multiply
(
new
BigDecimal
(
100
));
}
else
{
// 将入账金额从入账币种转换为保单币种
BigDecimal
amountInPolicyCurrency
=
amount
.
divide
(
exchangeRate
,
4
,
RoundingMode
.
HALF_UP
);
// 计算佣金比例
return
amountInPolicyCurrency
.
divide
(
new
BigDecimal
(
premium
),
4
,
RoundingMode
.
HALF_UP
)
.
multiply
(
new
BigDecimal
(
"100"
));
}
}
// 如果币种不同,首先把当前入账金额转换为对应币种金额
if
(!
StringUtils
.
equals
(
currentCurrency
,
"HKD"
))
{
Result
<
List
<
GetDictItemListByDictTypeResponse
>>
result
=
apiSysDictFeignClient
.
getDictItemListByDictType
(
"csf_exchange_rate_hkd"
);
log
.
info
(
"--------------当前入账金额: {} {}"
,
amount
,
currentCurrency
);
log
.
info
(
"--------------当前入账币种: {}"
,
currentCurrency
);
BigDecimal
defaultExchangeRate
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
result
.
getData
()))
{
for
(
GetDictItemListByDictTypeResponse
dictItem
:
result
.
getData
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
dictItem
.
getItemLabel
(),
currentCurrency
))
{
defaultExchangeRate
=
new
BigDecimal
(
dictItem
.
getItemValue
());
}
}
}
if
(
ObjectUtils
.
isEmpty
(
defaultExchangeRate
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到当前入账币种对应的结算汇率"
);
}
amount
=
amount
.
divide
(
defaultExchangeRate
,
4
,
RoundingMode
.
HALF_UP
);
log
.
info
(
"--------------当前入账港币: {}"
,
amount
);
}
// 当前来佣比例=当前入账金额/结算汇率/保费 * 100
BigDecimal
currentCommissionRatio
=
amount
.
divide
(
new
BigDecimal
(
premium
),
4
,
RoundingMode
.
HALF_UP
)
.
divide
(
exchangeRate
,
4
,
RoundingMode
.
HALF_UP
)
.
multiply
(
new
BigDecimal
(
100
));
log
.
info
(
"--------------当前结算汇率: {}"
,
exchangeRate
);
log
.
info
(
"--------------当前来佣比例: {}"
,
currentCommissionRatio
);
return
currentCommissionRatio
;
}
}
@Override
@Override
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
856a8ff9
...
@@ -76,6 +76,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -76,6 +76,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
}
}
String
reconciliationYearMonth
=
fortuneQueryRequest
.
getReconciliationYearMonth
();
String
reconciliationYearMonth
=
fortuneQueryRequest
.
getReconciliationYearMonth
();
List
<
String
>
statusList
=
fortuneQueryRequest
.
getStatusList
();
List
<
String
>
statusList
=
fortuneQueryRequest
.
getStatusList
();
if
(
CollectionUtils
.
isEmpty
(
statusList
))
{
statusList
=
Collections
.
singletonList
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
());
}
String
policyNo
=
fortuneQueryRequest
.
getPolicyNo
();
String
policyNo
=
fortuneQueryRequest
.
getPolicyNo
();
List
<
String
>
insuranceCompanyBizIdList
=
fortuneQueryRequest
.
getInsuranceCompanyBizIdList
();
List
<
String
>
insuranceCompanyBizIdList
=
fortuneQueryRequest
.
getInsuranceCompanyBizIdList
();
List
<
String
>
productLaunchBizIdList
=
fortuneQueryRequest
.
getProductLaunchBizIdList
();
List
<
String
>
productLaunchBizIdList
=
fortuneQueryRequest
.
getProductLaunchBizIdList
();
...
@@ -208,6 +211,15 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -208,6 +211,15 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账币种不能为空"
);
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账币种不能为空"
);
}
}
}
}
// 更新结算汇率
BigDecimal
exchangeRate
=
ObjectUtils
.
isNotEmpty
((
fortuneUpdateRequest
.
getExchangeRate
()))
?
fortuneUpdateRequest
.
getExchangeRate
()
:
queryDefaultExchangeRate
(
fortuneUpdateRequest
.
getCurrency
());
fortune
.
setExchangeRate
(
exchangeRate
);
if
(
ObjectUtils
.
isEmpty
(
fortune
.
getHkdAmount
()))
{
fortune
.
setHkdAmount
(
fortune
.
getAmount
().
multiply
(
exchangeRate
));
}
// 获取当前登录用户
// 获取当前登录用户
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
...
@@ -235,6 +247,24 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -235,6 +247,24 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return
true
;
return
true
;
}
}
private
BigDecimal
queryDefaultExchangeRate
(
String
currency
)
{
if
(
StringUtils
.
isBlank
(
currency
))
{
return
BigDecimal
.
ONE
;
}
if
(
"HKD"
.
equalsIgnoreCase
(
currency
))
{
return
BigDecimal
.
valueOf
(
1
);
}
Result
<
List
<
GetDictItemListByDictTypeResponse
>>
result
=
apiSysDictFeignClient
.
getDictItemListByDictType
(
"csf_exchange_rate_hkd"
);
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
result
.
getData
()))
{
for
(
GetDictItemListByDictTypeResponse
dictItem
:
result
.
getData
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
dictItem
.
getItemLabel
(),
currency
))
{
return
new
BigDecimal
(
dictItem
.
getItemValue
());
}
}
}
return
BigDecimal
.
ONE
;
}
/**
/**
* 拆分发放(按本次发放金额拆)
* 拆分发放(按本次发放金额拆)
*/
*/
...
@@ -250,8 +280,11 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -250,8 +280,11 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
if
(
currentPaymentAmount
.
compareTo
(
main
.
getCurrentPaymentAmount
())
>
0
)
if
(
currentPaymentAmount
.
compareTo
(
main
.
getCurrentPaymentAmount
())
>
0
)
throw
new
BusinessException
(
"本次发放金额不能大于可出账金额"
);
throw
new
BusinessException
(
"本次发放金额不能大于可出账金额"
);
// 本次发放港币金额
BigDecimal
currentHkdAmount
=
currentPaymentAmount
.
multiply
(
main
.
getExchangeRate
());
// 1. 更新主行 = 本次发放金额
// 1. 更新主行 = 本次发放金额
main
.
setCurrentPaymentAmount
(
currentPaymentAmount
);
main
.
setCurrentPaymentAmount
(
currentPaymentAmount
);
main
.
setCurrentPaymentHkdAmount
(
currentHkdAmount
);
main
.
setCurrentPaymentRatio
(
currentPaymentAmount
main
.
setCurrentPaymentRatio
(
currentPaymentAmount
.
divide
(
expectedFortune
.
getAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)));
.
divide
(
expectedFortune
.
getAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)));
main
.
setStatus
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
());
main
.
setStatus
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
());
...
@@ -270,6 +303,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -270,6 +303,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
BeanUtils
.
copyProperties
(
main
,
part
,
"id"
,
"fortuneBizId"
,
"currentPaymentAmount"
,
"status"
,
"isPart"
,
"payoutDate"
);
BeanUtils
.
copyProperties
(
main
,
part
,
"id"
,
"fortuneBizId"
,
"currentPaymentAmount"
,
"status"
,
"isPart"
,
"payoutDate"
);
part
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
part
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
part
.
setCurrentPaymentAmount
(
leftAmount
);
part
.
setCurrentPaymentAmount
(
leftAmount
);
part
.
setCurrentPaymentHkdAmount
(
leftAmount
.
multiply
(
main
.
getExchangeRate
()));
part
.
setCurrentPaymentRatio
(
leftAmount
part
.
setCurrentPaymentRatio
(
leftAmount
.
divide
(
expectedFortune
.
getAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)));
.
divide
(
expectedFortune
.
getAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)));
part
.
setStatus
(
FortuneStatusEnum
.
WAIT
.
getItemValue
());
part
.
setStatus
(
FortuneStatusEnum
.
WAIT
.
getItemValue
());
...
@@ -286,17 +320,18 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -286,17 +320,18 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
.
one
();
.
one
();
if
(
ef
==
null
)
return
;
if
(
ef
==
null
)
return
;
BigDecimal
newPaid
=
ef
.
getPaidAmount
()
==
null
?
BigDecimal
.
ZERO
:
ef
.
getPaidAmount
().
add
(
currentPaymentAmount
);
// 统一使用港币金额
BigDecimal
newUnpaid
=
ef
.
getAmount
().
subtract
(
newPaid
);
BigDecimal
newPaid
=
ef
.
getPaidAmount
()
==
null
?
BigDecimal
.
ZERO
:
ef
.
getPaidAmount
().
add
(
currentHkdAmount
);
BigDecimal
newUnpaid
=
ef
.
getHkdAmount
().
subtract
(
newPaid
);
String
newStatus
=
newUnpaid
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
"6"
:
"3"
;
String
newStatus
=
newUnpaid
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
"6"
:
"3"
;
expectedFortuneService
.
lambdaUpdate
()
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getPaidAmount
,
newPaid
)
.
set
(
ExpectedFortune:
:
getPaidAmount
,
newPaid
)
.
set
(
ExpectedFortune:
:
getUnpaidAmount
,
newUnpaid
)
.
set
(
ExpectedFortune:
:
getUnpaidAmount
,
newUnpaid
)
.
set
(
ExpectedFortune:
:
getPaidRatio
,
.
set
(
ExpectedFortune:
:
getPaidRatio
,
newPaid
.
divide
(
ef
.
getAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)))
newPaid
.
divide
(
ef
.
get
Hkd
Amount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)))
.
set
(
ExpectedFortune:
:
getUnpaidRatio
,
.
set
(
ExpectedFortune:
:
getUnpaidRatio
,
newUnpaid
.
divide
(
ef
.
getAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)))
newUnpaid
.
divide
(
ef
.
get
Hkd
Amount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)))
.
set
(
ExpectedFortune:
:
getStatus
,
newStatus
)
.
set
(
ExpectedFortune:
:
getStatus
,
newStatus
)
.
eq
(
ExpectedFortune:
:
getId
,
ef
.
getId
())
.
eq
(
ExpectedFortune:
:
getId
,
ef
.
getId
())
.
update
();
.
update
();
...
...
yd-csf-service/src/main/resources/mappers/CommissionMapper.xml
View file @
856a8ff9
...
@@ -88,9 +88,22 @@
...
@@ -88,9 +88,22 @@
<select
id=
"getCommissionStatistics"
resultType=
"com.yd.csf.service.vo.CommissionStatisticsVO"
>
<select
id=
"getCommissionStatistics"
resultType=
"com.yd.csf.service.vo.CommissionStatisticsVO"
>
SELECT
SELECT
COALESCE(SUM(c.hkd_amount), 0) as totalPaidAmount,
COALESCE(SUM(c.hkd_amount), 0) as totalPaidAmount,
COALESCE(MAX(e.expected_amount), 0) as expectePaidAmount,
COALESCE(
COALESCE(IFNULL(e.expected_amount, 0) - SUM(c.amount), 0) as pendingPaidAmount,
(SELECT SUM(e2.expected_amount)
COALESCE(IFNULL(e.expected_amount, 0) - SUM(c.amount), 0) as differenceAmount,
FROM commission_expected e2
WHERE e2.commission_expected_biz_id IN (
SELECT DISTINCT c2.commission_expected_biz_id
FROM commission c2
WHERE c2.is_deleted = 0
<if
test=
"commissionIdList != null and commissionIdList.size > 0"
>
AND c2.id IN
<foreach
collection=
"commissionIdList"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
)
), 0
) as expectePaidAmount,
COUNT(DISTINCT c.policy_no) as totalPolicyCount,
COUNT(DISTINCT c.policy_no) as totalPolicyCount,
COALESCE(CAST(c.premium AS DECIMAL(15,2)) * p.payment_term, 0) AS totalPremium,
COALESCE(CAST(c.premium AS DECIMAL(15,2)) * p.payment_term, 0) AS totalPremium,
COUNT(DISTINCT c.reconciliation_company) as reconciliationCompanyCount,
COUNT(DISTINCT c.reconciliation_company) as reconciliationCompanyCount,
...
...
yd-csf-service/src/main/resources/mappers/ExpectedFortuneMapper.xml
View file @
856a8ff9
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
<select
id=
"getStatistics"
resultType=
"com.yd.csf.service.vo.ExpectedFortuneStatisticsVO"
>
<select
id=
"getStatistics"
resultType=
"com.yd.csf.service.vo.ExpectedFortuneStatisticsVO"
>
select
select
ifnull(sum(ef.amount),0) as totalExpectedAmount,
ifnull(sum(ef.
hkd_
amount),0) as totalExpectedAmount,
ifnull(sum(ef.paid_amount),0) as totalPaidAmount,
ifnull(sum(ef.paid_amount),0) as totalPaidAmount,
ifnull(sum(ef.unpaid_amount),0) as totalUnpaidAmount,
ifnull(sum(ef.unpaid_amount),0) as totalUnpaidAmount,
ifnull(e.totalPremiumAmount,0) as totalPremiumAmount,
ifnull(e.totalPremiumAmount,0) as totalPremiumAmount,
...
...
yd-csf-service/src/main/resources/mappers/FortuneMapper.xml
View file @
856a8ff9
...
@@ -25,7 +25,10 @@
...
@@ -25,7 +25,10 @@
<result
property=
"fortuneType"
column=
"fortune_type"
/>
<result
property=
"fortuneType"
column=
"fortune_type"
/>
<result
property=
"amount"
column=
"amount"
/>
<result
property=
"amount"
column=
"amount"
/>
<result
property=
"currency"
column=
"currency"
/>
<result
property=
"currency"
column=
"currency"
/>
<result
property=
"exchangeRate"
column=
"exchange_rate"
/>
<result
property=
"hkdAmount"
column=
"hkd_amount"
/>
<result
property=
"currentPaymentAmount"
column=
"current_payment_amount"
/>
<result
property=
"currentPaymentAmount"
column=
"current_payment_amount"
/>
<result
property=
"currentPaymentHkdAmount"
column=
"current_payment_hkd_amount"
/>
<result
property=
"currentPaymentRatio"
column=
"current_payment_ratio"
/>
<result
property=
"currentPaymentRatio"
column=
"current_payment_ratio"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"payoutDate"
column=
"payout_date"
/>
<result
property=
"payoutDate"
column=
"payout_date"
/>
...
@@ -49,7 +52,7 @@
...
@@ -49,7 +52,7 @@
id,fortune_biz_id,expected_fortune_biz_id,reconciliation_year_month,fortune_biz_type,batch_biz_id,
id,fortune_biz_id,expected_fortune_biz_id,reconciliation_year_month,fortune_biz_type,batch_biz_id,
commission_biz_id,commission_expected_biz_id,policy_no,fortune_period,fortune_total_period,broker_biz_id,
commission_biz_id,commission_expected_biz_id,policy_no,fortune_period,fortune_total_period,broker_biz_id,
team_biz_id,grade_commission_rate,share_rate,fortune_name,fortune_type,is_part,
team_biz_id,grade_commission_rate,share_rate,fortune_name,fortune_type,is_part,
amount,currency,
current_payment
_amount,current_payment_ratio,status,payout_date,actual_payout_date,is_tax,
amount,currency,
exchange_rate,hkd_amount,current_payment_amount,current_payment_hkd
_amount,current_payment_ratio,status,payout_date,actual_payout_date,is_tax,
tax_amount,net_amount,salary_biz_id,base_rule_biz_id,settlement_biz_id,
tax_amount,net_amount,salary_biz_id,base_rule_biz_id,settlement_biz_id,
calculation_formula,remark,is_deleted,creator_id,updater_id,
calculation_formula,remark,is_deleted,creator_id,updater_id,
create_time,update_time
create_time,update_time
...
@@ -58,12 +61,12 @@
...
@@ -58,12 +61,12 @@
<select
id=
"getFortuneStatistics"
resultType=
"com.yd.csf.service.dto.FortuneStatisticsVO"
>
<select
id=
"getFortuneStatistics"
resultType=
"com.yd.csf.service.dto.FortuneStatisticsVO"
>
SELECT
SELECT
f.policy_no,
f.policy_no,
SUM(CASE WHEN f.is_part = '0' THEN f.amount ELSE 0 END) AS amount,
SUM(CASE WHEN f.is_part = '0' THEN f.
hkd_
amount ELSE 0 END) AS amount,
SUM(CASE WHEN f.status = '2' THEN f.current_payment_amount ELSE 0 END) AS sentAmount,
SUM(CASE WHEN f.status = '2' THEN f.current_payment_
hkd_
amount ELSE 0 END) AS sentAmount,
SUM(CASE WHEN f.status = '0' THEN f.current_payment_amount ELSE 0 END) AS pendingOutAmount,
SUM(CASE WHEN f.status = '0' THEN f.current_payment_
hkd_
amount ELSE 0 END) AS pendingOutAmount,
SUM(CASE WHEN f.status = '6' THEN f.current_payment_amount ELSE 0 END) AS availableOutAmount,
SUM(CASE WHEN f.status = '6' THEN f.current_payment_
hkd_
amount ELSE 0 END) AS availableOutAmount,
COUNT(DISTINCT f.policy_no) AS totalPolicyCount,
COUNT(DISTINCT f.policy_no) AS totalPolicyCount,
MAX(c.amount) AS totalInAmount,
MAX(c.
hkd_
amount) AS totalInAmount,
MAX(c.premium) AS totalPremium
MAX(c.premium) AS totalPremium
FROM fortune f
FROM fortune f
LEFT JOIN commission c ON f.commission_biz_id = c.commission_biz_id
LEFT JOIN commission c ON f.commission_biz_id = c.commission_biz_id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment