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
a86a2ad1
Commit
a86a2ad1
authored
Dec 17, 2025
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
应收管理、应付管理4
parent
2624262e
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
153 additions
and
41 deletions
+153
-41
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiCommissionController.java
+4
-3
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
+2
-2
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
+0
-2
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/dto/GenerateFortuneRequest.java
+9
-7
yd-csf-service/src/main/java/com/yd/csf/service/enums/FortuneStatusEnum.java
+7
-5
yd-csf-service/src/main/java/com/yd/csf/service/model/ExpectedFortune.java
+2
-2
yd-csf-service/src/main/java/com/yd/csf/service/model/Fortune.java
+10
-3
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+25
-9
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
+38
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+48
-7
yd-csf-service/src/main/resources/mappers/FortuneMapper.xml
+2
-1
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiCommissionController.java
View file @
a86a2ad1
...
...
@@ -36,6 +36,7 @@ import javax.annotation.Resource;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
...
...
@@ -189,9 +190,9 @@ public class ApiCommissionController {
@Operation
(
summary
=
"生成实际出账(发佣)记录,并设置检核日期"
)
public
Result
<
Boolean
>
generateFortune
(
@RequestBody
GenerateFortuneRequest
generateFortuneRequest
,
HttpServletRequest
request
)
{
L
ist
<
String
>
commissionBizIdList
=
generateFortuneRequest
.
getCommissionBizIdList
();
if
(
CollectionUtils
.
isEmpty
(
commissionBizIdList
)
||
CollectionUtils
.
isEmpty
(
generateFortuneRequest
.
getExpectedFortuneIdList
())
)
{
return
Result
.
fail
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
ResultCode
.
PARAMS_ERROR
.
getMessage
()
);
L
ocalDate
payoutYearMonth
=
generateFortuneRequest
.
getPayoutYearMonth
();
if
(
payoutYearMonth
==
null
)
{
return
Result
.
fail
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"预计出账年月不能为空"
);
}
return
Result
.
success
(
commissionService
.
generateFortune
(
generateFortuneRequest
));
}
...
...
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
View file @
a86a2ad1
...
...
@@ -397,13 +397,13 @@ public class ApiFortuneController {
}
/**
* 更新保单发佣
* 更新保单发佣
(检核操作)
*
* @param fortuneUpdateRequest
* @return
*/
@PostMapping
(
"/update"
)
@Operation
(
summary
=
"更新保单发佣信息"
)
@Operation
(
summary
=
"更新保单发佣信息
(检核操作)
"
)
public
Result
<
Boolean
>
updateFortune
(
@RequestBody
FortuneUpdateRequest
fortuneUpdateRequest
)
{
if
(
fortuneUpdateRequest
==
null
||
fortuneUpdateRequest
.
getFortuneBizId
()
==
null
)
{
return
Result
.
fail
(
ErrorCode
.
PARAMS_ERROR
.
getCode
(),
ErrorCode
.
PARAMS_ERROR
.
getMessage
());
...
...
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
View file @
a86a2ad1
...
...
@@ -394,8 +394,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
// 计算实际预计发佣金额 = 标准发佣金额 × decimalRatio
BigDecimal
actualAmount
=
standardAmount
.
multiply
(
decimalRatio
);
fortune
.
setAmount
(
actualAmount
);
// 本次出账金额 = 实际预计发佣金额
fortune
.
setCurrentPaymentAmount
(
actualAmount
);
}
catch
(
NumberFormatException
e
)
{
// 如果比例不是有效的数字,使用标准金额
...
...
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneUpdateRequest.java
View file @
a86a2ad1
...
...
@@ -16,6 +16,12 @@ public class FortuneUpdateRequest implements Serializable {
private
String
fortuneBizId
;
/**
* 出账状态
*/
@Schema
(
description
=
"出账状态 4=保留 5=已失效 6=可出帐,检核完成"
)
private
String
status
;
/**
* 保单号
*/
@Schema
(
description
=
"保单号"
)
...
...
yd-csf-service/src/main/java/com/yd/csf/service/dto/GenerateFortuneRequest.java
View file @
a86a2ad1
package
com
.
yd
.
csf
.
service
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
...
...
@@ -9,12 +10,13 @@ import java.util.List;
@Data
public
class
GenerateFortuneRequest
{
@Schema
(
description
=
"佣金业务id列表"
)
private
List
<
String
>
commissionBizIdList
;
// @Schema(description = "佣金业务id列表")
// private List<String> commissionBizIdList;
//
// @Schema(description = "expected fortune id 列表")
// private List<Long> expectedFortuneIdList;
@Schema
(
description
=
"expected fortune id 列表"
)
private
List
<
Long
>
expectedFortuneIdList
;
@Schema
(
description
=
"检核日期"
)
private
String
reconciliationYearMonth
;
@Schema
(
description
=
"预计出账年月"
)
@JsonFormat
(
pattern
=
"yyyy-MM"
)
private
LocalDate
payoutYearMonth
;
}
yd-csf-service/src/main/java/com/yd/csf/service/enums/FortuneStatusEnum.java
View file @
a86a2ad1
package
com
.
yd
.
csf
.
service
.
enums
;
/**
* 出账状态枚举
* 出账状态枚举
0=待出账 1=可出帐,待检核 2=完成出账 3=部分出账 4=保留 5=已失效 6=可出帐,检核完成 7=未找到当前预计发佣对应的来佣
*/
public
enum
FortuneStatusEnum
{
//出账状态枚举
WAIT
(
"待出账"
,
"0"
),
CAN_SEND
(
"可出账, 待检核"
,
"1"
),
CHECKED
(
"可出账, 已检核"
,
"4"
),
SENT
(
"已出账"
,
"2"
),
MATCH_FAIL
(
"未找到当前预计发佣对应的来佣"
,
"3"
),
SENT
(
"完成出账"
,
"2"
),
PARTIAL_SENT
(
"部分出账"
,
"3"
),
RESERVED
(
"保留"
,
"4"
),
INVALID
(
"已失效"
,
"5"
),
CHECKED
(
"可出账, 已检核"
,
"6"
),
MATCH_FAIL
(
"未找到当前预计发佣对应的来佣"
,
"7"
),
;
//字典项标签(名称)
private
String
itemLabel
;
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/ExpectedFortune.java
View file @
a86a2ad1
...
...
@@ -145,8 +145,8 @@ public class ExpectedFortune implements Serializable {
/**
* 本次出账金额
*/
@TableField
(
"current_payment_amount"
)
private
BigDecimal
currentPaymentAmount
;
//
@TableField("current_payment_amount")
//
private BigDecimal currentPaymentAmount;
/**
* 预计发佣日期
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/Fortune.java
View file @
a86a2ad1
...
...
@@ -6,13 +6,15 @@ import java.io.Serializable;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.util.Date
;
import
lombok.Data
;
/**
* 保单发佣表
*
* @TableName fortune
*/
@TableName
(
value
=
"fortune"
)
@TableName
(
value
=
"fortune"
)
@Data
public
class
Fortune
implements
Serializable
{
/**
...
...
@@ -32,6 +34,11 @@ public class Fortune implements Serializable {
private
String
reconciliationYearMonth
;
/**
* 是否部分出账拆分出来的出账记录 0=No, 1=Yes
*/
private
Integer
isPart
;
/**
* 保单发佣批次ID
*/
private
String
batchBizId
;
...
...
@@ -41,7 +48,7 @@ public class Fortune implements Serializable {
*/
private
String
fortuneBizId
;
/**
/**
* 来佣保单业务id
*/
private
String
commissionBizId
;
...
...
@@ -121,7 +128,7 @@ public class Fortune implements Serializable {
*/
private
LocalDate
payoutDate
;
/**
/**
* 出账数据业务ID
*/
private
String
fortuneAccountBizId
;
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
a86a2ad1
...
...
@@ -329,23 +329,38 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
generateFortune
(
GenerateFortuneRequest
generateFortuneRequest
)
{
if
(
StringUtils
.
isEmpty
(
generateFortuneRequest
.
getReconciliationYearMonth
()))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"请选择发佣检核日期"
);
LocalDate
payoutYearMonth
=
generateFortuneRequest
.
getPayoutYearMonth
();
if
(
ObjectUtils
.
isEmpty
(
payoutYearMonth
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"请选择预计出账年月"
);
}
// 1. 查询对应的预计发佣记录
List
<
Long
>
expectedFortuneIdList
=
generateFortuneRequest
.
getExpectedFortuneIdList
();
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
listByIds
(
expectedFortuneIdList
);
// 1. 查询在预计出账年月的预计发佣记录,预计出账日期在预计出账年月的1号到最后一天
QueryWrapper
<
ExpectedFortune
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
between
(
"payout_date"
,
payoutYearMonth
.
withDayOfMonth
(
1
),
payoutYearMonth
.
withDayOfMonth
(
payoutYearMonth
.
lengthOfMonth
()));
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
list
(
queryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
expectedFortuneList
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到保单对应的预计发佣记录,请先创建预计发佣记录"
);
}
// 2. 根据本次发佣日期,查询本期待发佣记录
List
<
Fortune
>
fortuneList
=
fortuneService
.
list
(
new
QueryWrapper
<
Fortune
>().
in
(
"reconciliation_year_month"
,
generateFortuneRequest
.
getReconciliationYearMonth
()));
QueryWrapper
<
Fortune
>
queryWrapperFortune
=
new
QueryWrapper
<>();
queryWrapperFortune
.
eq
(
"reconciliation_year_month"
,
payoutYearMonth
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM"
)));
List
<
Fortune
>
fortuneList
=
fortuneService
.
list
(
queryWrapperFortune
);
// 2.1 校验是否有已出账的记录
for
(
Fortune
fortune
:
fortuneList
)
{
if
(
FortuneStatusEnum
.
SENT
.
getItemValue
().
equals
(
fortune
.
getStatus
()))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"已出账的记录不能重新出账"
);
}
}
// 2.2 过滤掉 is_part = 1 的 fortune 记录
List
<
Fortune
>
filteredFortuneList
=
fortuneList
.
stream
()
.
filter
(
fortune
->
Integer
.
valueOf
(
0
).
equals
(
fortune
.
getIsPart
()))
.
collect
(
Collectors
.
toList
());
// 3.根据本次发佣日期,删除旧的发佣记录,以便重新计算
fortuneService
.
removeByIds
(
fortuneList
);
fortuneService
.
removeByIds
(
f
ilteredF
ortuneList
);
// 4.根据保单号查询对应来佣记录
Set
<
String
>
policyNoSet
=
expectedFortuneList
.
stream
()
...
...
@@ -355,7 +370,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
List
<
Commission
>
commissionList
=
this
.
list
(
new
QueryWrapper
<
Commission
>().
in
(
"policy_no"
,
policyNoSet
));
// 5. 构建实际的初始发佣记录
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
expectedFortuneList
,
commissionList
,
generateFortuneRequest
.
getReconciliationYearMonth
(
));
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
expectedFortuneList
,
commissionList
,
payoutYearMonth
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM"
)
));
// List<Fortune> newFortuneList = new ArrayList<>();
// for (ExpectedFortune expectedFortune : filteredExpectedFortuneList) {
// Fortune fortune = new Fortune();
...
...
@@ -414,9 +429,10 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
BeanUtils
.
copyProperties
(
expectedFortune
,
fortune
);
fortune
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
fortune
.
setAmount
(
expectedFortune
.
get
CurrentPayment
Amount
());
fortune
.
setAmount
(
expectedFortune
.
getAmount
());
fortune
.
setExpectedFortuneBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
fortune
.
setStatus
(
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
());
fortune
.
setIsPart
(
0
);
// 检核日期
fortune
.
setReconciliationYearMonth
(
reconciliationYearMonth
);
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
View file @
a86a2ad1
package
com
.
yd
.
csf
.
service
.
service
.
impl
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -14,6 +15,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
;
...
...
@@ -21,6 +23,7 @@ import com.yd.csf.service.service.FortuneAccountEditRecordService;
import
com.yd.csf.service.service.FortuneAccountService
;
import
com.yd.csf.service.dao.FortuneAccountMapper
;
import
com.yd.csf.service.service.FortuneService
;
import
com.yd.csf.service.service.IExpectedFortuneService
;
import
com.yd.csf.service.vo.FortuneAccountVO
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -30,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -47,6 +51,9 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
@Resource
private
FortuneAccountEditRecordService
fortuneAccountEditRecordService
;
@Resource
private
IExpectedFortuneService
expectedFortuneService
;
private
final
Gson
GSON
=
new
Gson
();
@Override
...
...
@@ -272,6 +279,37 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
fortuneService
.
updateBatchById
(
updateFortuneList
);
}
// 更新预计出账记录
List
<
String
>
expectedFortuneBizIdList
=
updateFortuneList
.
stream
().
map
(
Fortune:
:
getExpectedFortuneBizId
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
expectedFortuneBizIdList
))
{
List
<
ExpectedFortune
>
expectedFortuneList
=
expectedFortuneService
.
list
(
new
QueryWrapper
<
ExpectedFortune
>().
in
(
"expected_fortune_biz_id"
,
expectedFortuneBizIdList
));
// 预计出账映射
Map
<
String
,
ExpectedFortune
>
expectedFortuneMap
=
expectedFortuneList
.
stream
()
.
collect
(
Collectors
.
toMap
(
ExpectedFortune:
:
getExpectedFortuneBizId
,
Function
.
identity
()));
// 遍历本次出账记录,更新预计出账记录
for
(
Fortune
item
:
updateFortuneList
)
{
ExpectedFortune
expectedFortune
=
expectedFortuneMap
.
get
(
item
.
getExpectedFortuneBizId
());
if
(
Objects
.
nonNull
(
expectedFortune
))
{
BigDecimal
amount
=
item
.
getAmount
();
// 本次出账金额
BigDecimal
paidAmount
=
expectedFortune
.
getPaidAmount
();
// 已出账金额
if
(
expectedFortune
.
getAmount
().
compareTo
(
paidAmount
.
add
(
amount
))
==
0
)
{
// 已出账金额等于预计出账金额,更新状态为完成出账
expectedFortune
.
setPaidAmount
(
paidAmount
.
add
(
amount
));
expectedFortune
.
setUnpaidAmount
(
BigDecimal
.
ZERO
);
expectedFortune
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
}
else
{
// 已出账金额小于预计出账金额,更新已出账金额
expectedFortune
.
setPaidAmount
(
paidAmount
.
add
(
amount
));
expectedFortune
.
setUnpaidAmount
(
expectedFortune
.
getAmount
().
subtract
(
paidAmount
.
add
(
amount
)));
expectedFortune
.
setUpdaterId
(
loginUserId
.
toString
());
expectedFortune
.
setUpdateTime
(
LocalDateTime
.
now
());
}
}
}
// 更新预计出账记录
expectedFortuneService
.
updateBatchById
(
expectedFortuneList
);
}
return
true
;
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
a86a2ad1
...
...
@@ -17,11 +17,13 @@ import com.yd.common.utils.RandomStringGenerator;
import
com.yd.csf.service.dto.*
;
import
com.yd.csf.service.enums.FortuneStatusEnum
;
import
com.yd.csf.service.model.Commission
;
import
com.yd.csf.service.model.ExpectedFortune
;
import
com.yd.csf.service.model.Fortune
;
import
com.yd.csf.service.service.CommissionService
;
import
com.yd.csf.service.service.FortuneAccountService
;
import
com.yd.csf.service.service.FortuneService
;
import
com.yd.csf.service.dao.FortuneMapper
;
import
com.yd.csf.service.service.IExpectedFortuneService
;
import
com.yd.csf.service.vo.CommissionVO
;
import
com.yd.csf.service.vo.FortuneVO
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -37,6 +39,8 @@ import java.io.IOException;
import
java.io.UnsupportedEncodingException
;
import
java.math.BigDecimal
;
import
java.net.URLEncoder
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -55,6 +59,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
@Resource
private
CommissionService
commissionService
;
@Resource
private
IExpectedFortuneService
expectedFortuneService
;
@Override
public
Wrapper
<
Fortune
>
getQueryWrapper
(
FortuneQueryRequest
fortuneQueryRequest
)
{
QueryWrapper
<
Fortune
>
queryWrapper
=
new
QueryWrapper
<>();
...
...
@@ -93,24 +100,64 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateFortune
(
FortuneUpdateRequest
fortuneUpdateRequest
)
{
if
(
fortuneUpdateRequest
.
getStatus
()
==
null
)
{
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账状态不能为空"
);
}
if
(!
StringUtils
.
equalsAny
(
fortuneUpdateRequest
.
getStatus
(),
FortuneStatusEnum
.
RESERVED
.
getItemValue
(),
FortuneStatusEnum
.
INVALID
.
getItemValue
(),
FortuneStatusEnum
.
CHECKED
.
getItemValue
(),
FortuneStatusEnum
.
CHECKED
.
getItemValue
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账状态只能为保留、已失效、可出帐,检核完成"
);
}
String
fortuneBizId
=
fortuneUpdateRequest
.
getFortuneBizId
();
// 查询出账数据
Fortune
fortune
=
this
.
getOne
(
new
QueryWrapper
<
Fortune
>().
eq
(
"fortune_biz_id"
,
fortuneBizId
));
if
(
fortune
==
null
)
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"发佣数据不存在"
);
}
BeanUtils
.
copyProperties
(
fortuneUpdateRequest
,
fortune
,
"id"
,
"fortuneBizId"
);
// 查询预计出账数据
ExpectedFortune
expectedFortune
=
expectedFortuneService
.
getOne
(
new
QueryWrapper
<
ExpectedFortune
>().
eq
(
"expected_fortune_biz_id"
,
fortune
.
getExpectedFortuneBizId
()));
if
(
expectedFortune
==
null
)
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"预计出账数据不存在"
);
}
// 如果是部分出账,新增一条待出账的实际出账记录(fortune)
if
(
fortuneUpdateRequest
.
getAmount
().
compareTo
(
expectedFortune
.
getAmount
())
<
0
)
{
Fortune
newFortune
=
new
Fortune
();
BeanUtils
.
copyProperties
(
fortune
,
newFortune
);
newFortune
.
setAmount
(
expectedFortune
.
getAmount
().
subtract
(
fortuneUpdateRequest
.
getAmount
()));
newFortune
.
setStatus
(
FortuneStatusEnum
.
WAIT
.
getItemValue
());
newFortune
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
newFortune
.
setExpectedFortuneBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
newFortune
.
setIsPart
(
1
);
// 出账年月为次月
newFortune
.
setReconciliationYearMonth
(
calculateReconciliationYearMonth
(
fortune
));
this
.
save
(
newFortune
);
}
BeanUtils
.
copyProperties
(
fortuneUpdateRequest
,
fortune
,
"id"
,
"fortuneBizId"
,
"expectedFortuneBizId"
,
"commissionBizId"
);
// 获取当前登录用户
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
String
loginUserId
=
currentLoginUser
.
getId
().
toString
();
// 更新预计出账状态
expectedFortune
.
setStatus
(
fortuneUpdateRequest
.
getStatus
());
expectedFortuneService
.
updateById
(
expectedFortune
);
// 更新实际出账数据
fortune
.
setUpdaterId
(
loginUserId
);
fortune
.
setUpdateTime
(
new
Date
());
return
this
.
updateById
(
fortune
);
}
private
String
calculateReconciliationYearMonth
(
Fortune
fortune
)
{
// 出账年月为次月
LocalDate
reconciliationDate
=
LocalDate
.
parse
(
fortune
.
getReconciliationYearMonth
()
+
"-01"
).
plusMonths
(
1
);
return
reconciliationDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM"
));
}
@Override
public
void
downloadFortune
(
FortuneDownloadRequest
fortuneDownloadRequest
,
HttpServletResponse
response
)
throws
IOException
{
List
<
String
>
fortuneBizIdList
=
fortuneDownloadRequest
.
getFortuneBizIdList
();
...
...
@@ -278,12 +325,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
updateFortune
.
setStatus
(
fortuneStatusUpdateRequest
.
getStatus
());
updateList
.
add
(
updateFortune
);
}
// 更新预计发佣的状态
if
(
StringUtils
.
equals
(
fortuneStatusUpdateRequest
.
getStatus
(),
FortuneStatusEnum
.
CHECKED
.
getItemValue
()))
{
for
(
Fortune
fortune
:
fortuneList
)
{
// fortune.setExpectedFortuneStatus(FortuneStatusEnum.CHECKED.getItemValue());
}
}
return
this
.
updateBatchById
(
updateList
);
}
...
...
yd-csf-service/src/main/resources/mappers/FortuneMapper.xml
View file @
a86a2ad1
...
...
@@ -9,6 +9,7 @@
<result
property=
"fortuneBizId"
column=
"fortune_biz_id"
/>
<result
property=
"expectedFortuneBizId"
column=
"expected_fortune_biz_id"
/>
<result
property=
"reconciliationYearMonth"
column=
"reconciliation_year_month"
/>
<result
property=
"isPart"
column=
"is_part"
/>
<result
property=
"batchBizId"
column=
"batch_biz_id"
/>
<result
property=
"commissionBizId"
column=
"commission_biz_id"
/>
<result
property=
"policyNo"
column=
"policy_no"
/>
...
...
@@ -41,7 +42,7 @@
<sql
id=
"Base_Column_List"
>
id,fortune_biz_id,expected_fortune_biz_id,reconciliation_year_month,batch_biz_id,commission_biz_id,policy_no,fortune_period,fortune_total_period,broker_biz_id,
team_biz_id,grade_commission_rate,share_rate,fortune_name,fortune_type,
team_biz_id,grade_commission_rate,share_rate,fortune_name,fortune_type,
is_part,
amount,currency,status,payout_date,is_tax,
tax_amount,net_amount,salary_biz_id,base_rule_biz_id,settlement_biz_id,
calculation_formula,remark,is_deleted,creator_id,updater_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