Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-backend
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
AutogeneralShanghai
yd-backend
Commits
e81f1030
Commit
e81f1030
authored
Nov 19, 2020
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
来佣比对状态修改
parent
9267e52f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
41 deletions
+106
-41
yd-api/src/main/java/com/yd/api/commission/service/impl/LifeCommissionServiceImpl.java
+73
-29
yd-api/src/main/java/com/yd/api/commission/vo/lifecommission/CheckComeCommissionRequestVO.java
+12
-0
yd-api/src/main/java/com/yd/dal/mapper/lifecommission/LifeCommissionMapper.java
+2
-1
yd-api/src/main/resources/mapper/lifecommission/LifeCommissionMapper.xml
+19
-11
No files found.
yd-api/src/main/java/com/yd/api/commission/service/impl/LifeCommissionServiceImpl.java
View file @
e81f1030
...
...
@@ -17,6 +17,7 @@ import com.yd.dal.service.customer.AclCustomerFortuneDALService;
import
com.yd.dal.service.order.PoOrderDALService
;
import
com.yd.util.CommonUtil
;
import
com.yd.util.config.ZHBErrorConfig
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -66,8 +67,8 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
BigDecimal
totalCommission
=
BigDecimal
.
ZERO
;
for
(
ComeCommissionVO
item:
dataList
)
{
totalOrderPrice
.
add
(
new
BigDecimal
(
item
.
getOrderPrice
()));
totalCommission
.
add
(
new
BigDecimal
(
item
.
getCommissionAmount
()));
totalOrderPrice
=
totalOrderPrice
.
add
(
new
BigDecimal
(
item
.
getOrderPrice
()));
totalCommission
=
totalCommission
.
add
(
new
BigDecimal
(
item
.
getCommissionAmount
()));
}
resp
.
setTotalOrderPrice
(
totalOrderPrice
);
resp
.
setTotalSingular
(
totalSingular
);
...
...
@@ -80,10 +81,11 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
List
<
Long
>
orderIds
=
requestVO
.
getOrderIds
();
String
status
=
requestVO
.
getCheckStatus
();
String
loginId
=
requestVO
.
getLoginId
();
String
checkBatch
=
requestVO
.
getCheckBatch
();
try
{
// 寿险经纪人的财富需要初始化withdraw和pay
if
(
"2"
.
equals
(
status
))
{
//已比对
this
.
checkPass
(
orderIds
,
status
,
loginId
);
this
.
checkPass
(
orderIds
,
status
,
loginId
,
checkBatch
);
}
else
if
(
"3"
.
equals
(
status
))
{
//已退保
SurrenderFortuneRequestVO
surrenderFortuneRequest
=
new
SurrenderFortuneRequestVO
();
...
...
@@ -92,41 +94,79 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
agmsFortuneService
.
surrenderFortune
(
surrenderFortuneRequest
);
}
}
else
{
//待来佣
// 设置order记录为待来佣
this
.
checkRollBack
(
orderIds
,
loginId
);
}
resp
.
setCommonResult
(
new
CommonResult
(
true
,
ZHBErrorConfig
.
getErrorInfo
(
"800000"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
resp
.
setCommonResult
(
new
CommonResult
(
false
,
e
.
getMessage
()));
}
return
resp
;
}
private
void
checkRollBack
(
List
<
Long
>
orderIds
,
String
loginId
)
throws
Exception
{
// 查询对应订单记录
List
<
PoOrder
>
orders
=
poOrderDALService
.
findByIds
(
orderIds
);
orders
.
forEach
(
o
->
{
// 查询保单下的所有寿险经纪人的fortune记录
List
<
AclCustomerFortune
>
fortuneList
=
agmsFortuneDALService
.
queryLifeFortuneListByOrderIds
(
orderIds
);
// 校验数据,若订单下存在已发放的财富记录,则该笔订单来佣比对状态不能改为待来佣
this
.
validateRollBackOrders
(
orders
,
fortuneList
);
// 设置order记录为待来佣
for
(
PoOrder
o:
orders
)
{
o
.
setCommissionCheckId
(
null
);
o
.
setCommissionCheckStatus
(
"1"
);
o
.
setCommissionCheckAt
(
new
Date
());
o
.
setCommissionCheckBy
(
Long
.
getLong
(
loginId
));
poOrderDALService
.
update
(
o
);
});
// 查询保单下的所有寿险经纪人的fortune记录
List
<
AclCustomerFortune
>
fortuneList
=
agmsFortuneDALService
.
queryLifeFortuneListByOrderIds
(
orderIds
);
// 批量设置fortune为b不可发佣
}
// 批量设置fortune为不可发佣
fortuneList
.
forEach
(
f
->
{
f
.
setCommissionPayoutStatus
(
"1"
);
f
.
setCommissionPayoutAt
(
new
Date
());
f
.
setCommissionPayoutBy
(
Long
.
getLong
(
loginId
));
});
if
(
fortuneList
.
size
()
>
0
)
{
customerFortuneDalService
.
updateBatch
(
fortuneList
);
}
resp
.
setCommonResult
(
new
CommonResult
(
true
,
ZHBErrorConfig
.
getErrorInfo
(
"800000"
)));
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
resp
.
setCommonResult
(
new
CommonResult
(
false
,
e
.
getMessage
()));
private
void
validateRollBackOrders
(
List
<
PoOrder
>
orders
,
List
<
AclCustomerFortune
>
fortuneList
)
throws
Exception
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
Map
<
Long
,
String
>
orderIdPolicyNoMap
=
new
HashMap
<>();
for
(
PoOrder
o:
orders
)
{
orderIdPolicyNoMap
.
put
(
o
.
getId
(),
o
.
getPolicyNo
());
if
(
"1"
.
equals
(
o
.
getCommissionCheckStatus
())
||
"3"
.
equals
(
o
.
getCommissionCheckStatus
()))
{
stringBuilder
.
append
(
o
.
getPolicyNo
()+
" "
);
}
}
if
(
StringUtils
.
isNotEmpty
(
stringBuilder
.
toString
()))
{
stringBuilder
.
append
(
"待来佣和已退保的订单不能改为待来佣"
);
throw
new
Exception
(
stringBuilder
.
toString
());
}
for
(
AclCustomerFortune
f:
fortuneList
)
{
if
(
"4"
.
equals
(
f
.
getCommissionPayoutStatus
()))
{
stringBuilder
.
append
(
orderIdPolicyNoMap
.
get
(
f
.
getOrderId
())+
" "
);
}
}
if
(
StringUtils
.
isNotEmpty
(
stringBuilder
.
toString
()))
{
stringBuilder
.
append
(
"订单下存在已发放的财富记录,不能改为待来佣"
);
throw
new
Exception
(
stringBuilder
.
toString
());
}
return
resp
;
}
private
void
checkPass
(
List
<
Long
>
orderIds
,
String
status
,
String
loginId
)
{
private
void
checkPass
(
List
<
Long
>
orderIds
,
String
status
,
String
loginId
,
String
checkBatch
)
{
// 插入批次表信息
OrderCommissonCheck
orderCommissionCheck
=
this
.
batchInsertOrderCommissionCheck
(
orderIds
,
loginId
);
Long
checkBatchId
=
this
.
getOrderCommissionCheckBatch
(
checkBatch
,
loginId
);
// 设置order记录的CommissionCheckId
this
.
setOrderCommissionCheckId
(
orderIds
,
status
,
orderCommissionCheck
);
this
.
setOrderCommissionCheckId
(
orderIds
,
status
,
checkBatchId
,
loginId
);
// 查询保单下的所有寿险经纪人的fortune记录
List
<
AclCustomerFortune
>
fortuneList
=
agmsFortuneDALService
.
queryLifeFortuneListByOrderIds
(
orderIds
);
if
(
fortuneList
.
size
()
==
0
)
{
return
;
}
// 批量设置fortune为可发佣
fortuneList
.
forEach
(
f
->
{
f
.
setCommissionPayoutStatus
(
"2"
);
...
...
@@ -135,7 +175,7 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
});
customerFortuneDalService
.
updateBatch
(
fortuneList
);
// 初始化withdraw和pay
agmsFortuneService
.
canPaymentUpDate
(
"2"
,
Long
.
getLong
(
"-1"
),
Long
.
getLong
(
loginId
),
fortuneList
);
agmsFortuneService
.
canPaymentUpDate
(
"2"
,
Long
.
valueOf
(
"-1"
),
Long
.
valueOf
(
loginId
),
fortuneList
);
}
private
PageInfo
<
ComeCommissionVO
>
queryComeCommissionListPage
(
QueryComeCommissionListRequestVO
requestVO
)
{
...
...
@@ -152,30 +192,34 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
return
pageInfo
;
}
private
void
setOrderCommissionCheckId
(
List
<
Long
>
orderIds
,
String
status
,
OrderCommissonCheck
orderCommissionCheck
)
{
private
void
setOrderCommissionCheckId
(
List
<
Long
>
orderIds
,
String
status
,
Long
checkBatchId
,
String
loginId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"checkId"
,
orderCommissionCheck
.
getId
()
);
paramMap
.
put
(
"checkId"
,
checkBatchId
);
paramMap
.
put
(
"status"
,
status
);
paramMap
.
put
(
"checkAt"
,
orderCommissionCheck
.
getCreatedAt
());
paramMap
.
put
(
"checkBy"
,
orderCommissionCheck
.
getCreatedBy
());
// 获取当前时间
Date
curDate
=
new
Date
();
paramMap
.
put
(
"checkAt"
,
curDate
);
paramMap
.
put
(
"checkBy"
,
loginId
);
lifeCommissionMapper
.
setOrderCommissionCheckId
(
orderIds
,
paramMap
);
}
private
OrderCommissonCheck
batchInsertOrderCommissionCheck
(
List
<
Long
>
orderIds
,
String
loginId
)
{
private
Long
getOrderCommissionCheckBatch
(
String
OrderCommissionCheckBatch
,
String
loginId
)
{
OrderCommissonCheck
orderCommissonCheck
=
lifeCommissionMapper
.
findByCheckYearmonth
(
OrderCommissionCheckBatch
);
if
(
orderCommissonCheck
==
null
){
// 获取当前时间
Date
curDate
=
new
Date
();
// 获取代表批次的年月
String
yearmonth
=
CommonUtil
.
dateParseString
(
curDate
,
"yyyy-MM"
);
System
.
out
.
println
(
"看看年月"
);
System
.
out
.
println
(
yearmonth
);
OrderCommissonCheck
orderCommissonCheck
=
new
OrderCommissonCheck
();
orderCommissonCheck
=
new
OrderCommissonCheck
();
orderCommissonCheck
.
setCheckYearmonth
(
yearmonth
);
orderCommissonCheck
.
setCreatedAt
(
curDate
);
orderCommissonCheck
.
setCreatedBy
(
loginId
);
return
lifeCommissionMapper
.
insertOrderCommissionCheck
(
orderCommissonCheck
);
orderCommissonCheck
.
setUpdatedAt
(
curDate
);
orderCommissonCheck
.
setUpdatedBy
(
loginId
);
lifeCommissionMapper
.
insertOrderCommissionCheck
(
orderCommissonCheck
);
}
return
orderCommissonCheck
.
getId
();
}
}
yd-api/src/main/java/com/yd/api/commission/vo/lifecommission/CheckComeCommissionRequestVO.java
View file @
e81f1030
...
...
@@ -6,6 +6,10 @@ public class CheckComeCommissionRequestVO {
private
List
<
Long
>
orderIds
;
private
String
checkStatus
;
private
String
loginId
;
/**
* 来佣比对批次
*/
private
String
checkBatch
;
public
List
<
Long
>
getOrderIds
()
{
return
orderIds
;
...
...
@@ -30,4 +34,12 @@ public class CheckComeCommissionRequestVO {
public
void
setLoginId
(
String
loginId
)
{
this
.
loginId
=
loginId
;
}
public
String
getCheckBatch
()
{
return
checkBatch
;
}
public
void
setCheckBatch
(
String
checkBatch
)
{
this
.
checkBatch
=
checkBatch
;
}
}
yd-api/src/main/java/com/yd/dal/mapper/lifecommission/LifeCommissionMapper.java
View file @
e81f1030
...
...
@@ -13,6 +13,7 @@ public interface LifeCommissionMapper {
void
setOrderCommissionCheckId
(
@Param
(
"list"
)
List
<
Long
>
orderIds
,
@Param
(
"paramMap"
)
Map
<
String
,
Object
>
paramMap
);
OrderCommissonCheck
insertOrderCommissionCheck
(
OrderCommissonCheck
orderCommissonCheck
);
void
insertOrderCommissionCheck
(
OrderCommissonCheck
orderCommissonCheck
);
OrderCommissonCheck
findByCheckYearmonth
(
String
orderCommissionCheckBatch
);
}
yd-api/src/main/resources/mapper/lifecommission/LifeCommissionMapper.xml
View file @
e81f1030
...
...
@@ -17,22 +17,24 @@
o.order_date orderDate,
e.coverageTerm,
e.payTerm,
p.
categoryName,
IFNULL(p.categoryName,a.categoryName2)
categoryName,
a.planCategoryName
from (SELECT id, policy_no, order_price, commission_rate, commission_amount, commission_check_status, commission_check_id, product_id,
plan_id, insurer_id, order_date, commission_check_at
from ag_po_order t
where t.status
= 3
where t.status
in (3,4) and policy_no is not null
and t.plan_id not in (424,453,464)
) o
left join ag_po_order_commission_check c on o.commission_check_id = c.id
left join (select p.id, p.name, pc.name categoryName
from ag_product p left join ag_product_category pc on p.product_category_id = pc.id
) p on o.product_id = p.id
left join (select pl.id, pl.name, pc.name planCategoryName
left join (select pl.id, pl.name, pc.name planCategoryName
, proc.name categoryName2
from ag_product_plan pl
left join ag_plan_category_list pcl on pl.id = pcl.plan_id
left join ag_plan_category pc on pc.id = pcl.plan_category_id
left join ag_product pro on pro.id = pl.product_id
left join ag_product_category proc on proc.id = pro.product_category_id
) a on o.plan_id = a.id
left join ag_acl_insurer i on o.insurer_id = i.id
left join (select order_id,withdrawable_date from ag_acl_customer_fortune group by order_id,withdrawable_date) f on o.id = f.order_id
...
...
@@ -50,7 +52,7 @@
</when>
<otherwise>
<if
test=
"compareDate != null"
>
and
((o.commission_check_status is null or o.commission_check_status = 1) and date_format(f.withdrawable_date, '%Y-%m')
<
= #{compareDate})
and
date_format(f.withdrawable_date, '%Y-%m')
<
= #{compareDate}
</if>
<if
test=
"insurerId != null"
>
and o.insurer_id = #{insurerId}
...
...
@@ -63,26 +65,27 @@
</select>
<insert
id=
"insertOrderCommissionCheck"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into ag_po_order_commission_check (check_yearmonth,created_at,created_by)
<insert
id=
"insertOrderCommissionCheck"
parameterType=
"com.yd.dal.entity.commission.OrderCommissonCheck"
useGeneratedKeys=
"true"
keyColumn=
"id"
keyProperty=
"id"
>
insert into ag_po_order_commission_check (check_yearmonth,created_at,created_by,updated_at,updated_by)
VALUES
(#{checkYearmonth},#{createdAt},#{createdBy})
(#{checkYearmonth},#{createdAt},#{createdBy}
,#{updatedAt},#{updatedBy}
)
</insert>
<update
id=
"setOrderCommissionCheckId"
>
update ag_po_order
<set>
<if
test=
"
isSuccess
!= null"
>
<if
test=
"
paramMap.checkId
!= null"
>
commission_check_id = #{paramMap.checkId,jdbcType=BIGINT},
</if>
<if
test=
"
logoutTime
!= null"
>
<if
test=
"
paramMap.status
!= null"
>
commission_check_status = #{paramMap.status,jdbcType=VARCHAR},
</if>
<if
test=
"
created
At != null"
>
<if
test=
"
paramMap.check
At != null"
>
commission_check_at = #{paramMap.checkAt,jdbcType=TIMESTAMP},
</if>
<if
test=
"
created
By != null"
>
<if
test=
"
paramMap.check
By != null"
>
commission_check_by = #{paramMap.checkBy,jdbcType=VARCHAR},
</if>
</set>
...
...
@@ -92,6 +95,10 @@
</foreach>
</update>
<select
id=
"findByCheckYearmonth"
parameterType=
"String"
resultType=
"com.yd.dal.entity.commission.OrderCommissonCheck"
>
select * from ag_po_order_commission_check
where check_yearmonth = #{orderCommissionCheckBatch,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
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