记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
939c980d
Commit
939c980d
authored
Nov 17, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add try applyrefund
parent
6508d91a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
112 deletions
+117
-112
KylinOrderRefundsServiceImpl.java
...gzai/kylin/service/impl/KylinOrderRefundsServiceImpl.java
+117
-112
No files found.
liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/kylin/service/impl/KylinOrderRefundsServiceImpl.java
View file @
939c980d
...
...
@@ -93,82 +93,100 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
private
MongoConverter
mongoConverter
;
public
ResponseDto
refundApply
(
RefundApplyParam
refundApplyParam
,
String
authId
,
String
authName
)
{
String
orderTicketsId
=
refundApplyParam
.
getOrderTicketsId
();
List
<
String
>
ticketEntityIds
=
refundApplyParam
.
getTicketEntityIds
();
List
<
BigDecimal
>
entitiesPrice
=
refundApplyParam
.
getEntitiesPrice
();
BigDecimal
RefundPriceExpress
=
refundApplyParam
.
getRefundPriceExpress
();
if
(
null
==
RefundPriceExpress
)
{
RefundPriceExpress
=
new
BigDecimal
(
0
);
}
try
{
String
orderTicketsId
=
refundApplyParam
.
getOrderTicketsId
();
List
<
String
>
ticketEntityIds
=
refundApplyParam
.
getTicketEntityIds
();
List
<
BigDecimal
>
entitiesPrice
=
refundApplyParam
.
getEntitiesPrice
();
BigDecimal
RefundPriceExpress
=
refundApplyParam
.
getRefundPriceExpress
();
if
(
null
==
RefundPriceExpress
)
{
RefundPriceExpress
=
new
BigDecimal
(
0
);
}
KylinOrderTickets
orderInfo
=
kylinOrderTicketsMapper
.
selectOne
(
new
QueryWrapper
<
KylinOrderTickets
>().
eq
(
"order_tickets_id"
,
orderTicketsId
)
);
KylinOrderTicketStatus
orderStatus
=
kylinOrderTicketStatusMapper
.
selectOne
(
new
QueryWrapper
<
KylinOrderTicketStatus
>().
eq
(
"order_id"
,
orderTicketsId
)
);
int
thisOrderStatus
=
orderStatus
.
getStatus
();
int
thisPayStatus
=
orderStatus
.
getPayStatus
();
BigDecimal
priceExpress
=
orderInfo
.
getPriceExpress
();
// todo 转增是否能退
// 订单状态需已付款
if
(
thisOrderStatus
!=
KylinTableStatusConst
.
ORDER_STATUS1
&&
thisOrderStatus
!=
KylinTableStatusConst
.
ORDER_STATUS3
&&
thisOrderStatus
!=
KylinTableStatusConst
.
ORDER_STATUS6
)
{
return
ResponseDto
.
failure
(
"当前订单状态不支持退款申请"
);
}
if
(!(
orderStatus
.
getTransferStatus
()
==
0
||
orderStatus
.
getTransferStatus
()
==
5
))
{
return
ResponseDto
.
failure
(
"当前转增状态不可退款"
);
}
// 订单支付状态需为已支付
if
(
thisPayStatus
!=
KylinTableStatusConst
.
ORDER_PAY_STATUS1
)
{
return
ResponseDto
.
failure
(
"订单支付状态需为已支付"
);
}
// TODO: 2021/6/16 是否能单独退快递飞 批量退款是否退快递费 现在做的是自动退剩余快递费
// 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费)
BigDecimal
refundPriceExpressSum
=
kylinOrderRefundsMapper
.
RefundPriceExpressSum
(
// 已退快递费
orderTicketsId
,
KylinTableStatusConst
.
ORDER_REFUND_STATUS_CANCEL
);
if
(
null
==
refundPriceExpressSum
)
{
refundPriceExpressSum
=
new
BigDecimal
(
0
);
}
if
(
null
==
refundApplyParam
.
getOrderRefundBatchesId
()
||
refundApplyParam
.
getOrderRefundBatchesId
().
isEmpty
())
{
// 不是批量退款
if
(
RefundPriceExpress
.
compareTo
(
priceExpress
.
subtract
(
refundPriceExpressSum
))
>
0
)
{
return
ResponseDto
.
failure
(
"快递费不能大于实际减去已退的快递费"
);
KylinOrderTickets
orderInfo
=
kylinOrderTicketsMapper
.
selectOne
(
new
QueryWrapper
<
KylinOrderTickets
>().
eq
(
"order_tickets_id"
,
orderTicketsId
)
);
KylinOrderTicketStatus
orderStatus
=
kylinOrderTicketStatusMapper
.
selectOne
(
new
QueryWrapper
<
KylinOrderTicketStatus
>().
eq
(
"order_id"
,
orderTicketsId
)
);
int
thisOrderStatus
=
orderStatus
.
getStatus
();
int
thisPayStatus
=
orderStatus
.
getPayStatus
();
BigDecimal
priceExpress
=
orderInfo
.
getPriceExpress
();
// todo 转增是否能退
// 订单状态需已付款
if
(
thisOrderStatus
!=
KylinTableStatusConst
.
ORDER_STATUS1
&&
thisOrderStatus
!=
KylinTableStatusConst
.
ORDER_STATUS3
&&
thisOrderStatus
!=
KylinTableStatusConst
.
ORDER_STATUS6
)
{
return
ResponseDto
.
failure
(
"当前订单状态不支持退款申请"
);
}
if
(!(
orderStatus
.
getTransferStatus
()
==
0
||
orderStatus
.
getTransferStatus
()
==
5
))
{
return
ResponseDto
.
failure
(
"当前转增状态不可退款"
);
}
// 订单支付状态需为已支付
if
(
thisPayStatus
!=
KylinTableStatusConst
.
ORDER_PAY_STATUS1
)
{
return
ResponseDto
.
failure
(
"订单支付状态需为已支付"
);
}
// TODO: 2021/6/16 是否能单独退快递飞 批量退款是否退快递费 现在做的是自动退剩余快递费
// 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费)
BigDecimal
refundPriceExpressSum
=
kylinOrderRefundsMapper
.
RefundPriceExpressSum
(
// 已退快递费
orderTicketsId
,
KylinTableStatusConst
.
ORDER_REFUND_STATUS_CANCEL
);
if
(
null
==
refundPriceExpressSum
)
{
refundPriceExpressSum
=
new
BigDecimal
(
0
);
}
if
(
null
==
refundApplyParam
.
getOrderRefundBatchesId
()
||
refundApplyParam
.
getOrderRefundBatchesId
().
isEmpty
())
{
// 不是批量退款
if
(
RefundPriceExpress
.
compareTo
(
priceExpress
.
subtract
(
refundPriceExpressSum
))
>
0
)
{
return
ResponseDto
.
failure
(
"快递费不能大于实际减去已退的快递费"
);
}
}
else
{
RefundPriceExpress
=
priceExpress
.
subtract
(
refundPriceExpressSum
);
}
}
else
{
RefundPriceExpress
=
priceExpress
.
subtract
(
refundPriceExpressSum
);
}
// todo 出票未出票
// 选择退款的入场人是否正确
Integer
[]
entitiesStatus
=
new
Integer
[]{
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT1
,
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT2
,
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT4
};
int
choiceCount
=
kylinOrderTicketEntitiesMapper
.
selectCount
(
new
QueryWrapper
<
KylinOrderTicketEntities
>()
.
eq
(
"order_id"
,
orderTicketsId
)
.
in
(
"is_payment"
,
entitiesStatus
)
.
in
(
"order_ticket_entities_id"
,
ticketEntityIds
)
);
if
(
choiceCount
<
0
||
choiceCount
!=
ticketEntityIds
.
size
())
{
return
ResponseDto
.
failure
(
"入场人订单有误"
);
}
// 该订单正在退款或已有退款 因支持填入价格所有取消判断
// 各个入场人订单填写的退款金额是否正确
BigDecimal
priceActual
=
orderInfo
.
getPriceActual
();
int
allEntitiesCount
=
kylinOrderTicketEntitiesMapper
.
selectCount
(
// 总入场人数量 排出未付款的 用来计算单入场人的价格
new
QueryWrapper
<
KylinOrderTicketEntities
>()
.
eq
(
"order_id"
,
orderTicketsId
)
.
ne
(
"is_payment"
,
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT0
)
);
BigDecimal
onePrice
=
priceActual
.
subtract
(
priceExpress
).
divide
(
BigDecimal
.
valueOf
(
allEntitiesCount
));
//单价
List
<
BigDecimal
>
realRefundPriceList
=
new
ArrayList
<>();
if
(
null
==
refundApplyParam
.
getOrderRefundBatchesId
()
||
refundApplyParam
.
getOrderRefundBatchesId
().
isEmpty
())
{
// 不是批量退款
for
(
int
i
=
0
;
i
<=
ticketEntityIds
.
size
()
-
1
;
i
++)
{
BigDecimal
price
=
entitiesPrice
.
get
(
i
);
if
(
price
.
compareTo
(
BigDecimal
.
ZERO
)
<=
0
)
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20021"
));
}
else
{
BigDecimal
refundedPrice
=
kylinOrderTicketEntitiesMapper
.
getRefundEntitiesPrice
(
//已退
// todo 出票未出票
// 选择退款的入场人是否正确
Integer
[]
entitiesStatus
=
new
Integer
[]{
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT1
,
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT2
,
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT4
};
int
choiceCount
=
kylinOrderTicketEntitiesMapper
.
selectCount
(
new
QueryWrapper
<
KylinOrderTicketEntities
>()
.
eq
(
"order_id"
,
orderTicketsId
)
.
in
(
"is_payment"
,
entitiesStatus
)
.
in
(
"order_ticket_entities_id"
,
ticketEntityIds
)
);
if
(
choiceCount
<
0
||
choiceCount
!=
ticketEntityIds
.
size
())
{
return
ResponseDto
.
failure
(
"入场人订单有误"
);
}
// 该订单正在退款或已有退款 因支持填入价格所有取消判断
// 各个入场人订单填写的退款金额是否正确
BigDecimal
priceActual
=
orderInfo
.
getPriceActual
();
int
allEntitiesCount
=
kylinOrderTicketEntitiesMapper
.
selectCount
(
// 总入场人数量 排出未付款的 用来计算单入场人的价格
new
QueryWrapper
<
KylinOrderTicketEntities
>()
.
eq
(
"order_id"
,
orderTicketsId
)
.
ne
(
"is_payment"
,
KylinTableStatusConst
.
ENTITIES_IS_PAYMENT0
)
);
BigDecimal
onePrice
=
priceActual
.
subtract
(
priceExpress
).
divide
(
BigDecimal
.
valueOf
(
allEntitiesCount
));
//单价
List
<
BigDecimal
>
realRefundPriceList
=
new
ArrayList
<>();
if
(
null
==
refundApplyParam
.
getOrderRefundBatchesId
()
||
refundApplyParam
.
getOrderRefundBatchesId
().
isEmpty
())
{
// 不是批量退款
for
(
int
i
=
0
;
i
<=
ticketEntityIds
.
size
()
-
1
;
i
++)
{
BigDecimal
price
=
entitiesPrice
.
get
(
i
);
if
(
price
.
compareTo
(
BigDecimal
.
ZERO
)
<=
0
)
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20021"
));
}
else
{
BigDecimal
refundedPrice
=
kylinOrderTicketEntitiesMapper
.
getRefundEntitiesPrice
(
//已退
orderTicketsId
,
KylinTableStatusConst
.
ORDER_REFUND_STATUS_CANCEL
,
ticketEntityIds
.
get
(
i
)
);
if
(
null
==
refundedPrice
)
{
refundedPrice
=
new
BigDecimal
(
0
);
}
if
(
price
.
compareTo
(
onePrice
.
subtract
(
refundedPrice
))
>
0
)
{
return
ResponseDto
.
failure
(
"超过可退款金额"
);
}
}
}
realRefundPriceList
=
entitiesPrice
;
}
else
{
// 批量 计算入场人订单可退金额
List
<
String
>
ticketEntityIdsNew
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<=
ticketEntityIds
.
size
()
-
1
;
i
++)
{
BigDecimal
refundedPrice
=
kylinOrderTicketEntitiesMapper
.
getRefundEntitiesPrice
(
//已退 包含退款中
orderTicketsId
,
KylinTableStatusConst
.
ORDER_REFUND_STATUS_CANCEL
,
ticketEntityIds
.
get
(
i
)
...
...
@@ -176,50 +194,37 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
if
(
null
==
refundedPrice
)
{
refundedPrice
=
new
BigDecimal
(
0
);
}
if
(
price
.
compareTo
(
onePrice
.
subtract
(
refundedPrice
))
>
0
)
{
return
ResponseDto
.
failure
(
"超过可退款金额"
);
BigDecimal
price
=
onePrice
.
subtract
(
refundedPrice
);
// 计算可退金额
if
(
price
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
realRefundPriceList
.
add
(
price
);
ticketEntityIdsNew
.
add
(
ticketEntityIds
.
get
(
i
));
}
}
// 剔除掉已经退完的入场人订单 可能包含正在退的
ticketEntityIds
=
ticketEntityIdsNew
;
}
realRefundPriceList
=
entitiesPrice
;
}
else
{
// 批量 计算入场人订单可退金额
List
<
String
>
ticketEntityIdsNew
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<=
ticketEntityIds
.
size
()
-
1
;
i
++)
{
BigDecimal
refundedPrice
=
kylinOrderTicketEntitiesMapper
.
getRefundEntitiesPrice
(
//已退 包含退款中
orderTicketsId
,
KylinTableStatusConst
.
ORDER_REFUND_STATUS_CANCEL
,
ticketEntityIds
.
get
(
i
)
);
if
(
null
==
refundedPrice
)
{
refundedPrice
=
new
BigDecimal
(
0
);
}
BigDecimal
price
=
onePrice
.
subtract
(
refundedPrice
);
// 计算可退金额
if
(
price
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
realRefundPriceList
.
add
(
price
);
ticketEntityIdsNew
.
add
(
ticketEntityIds
.
get
(
i
));
}
}
// 剔除掉已经退完的入场人订单 可能包含正在退的
ticketEntityIds
=
ticketEntityIdsNew
;
}
boolean
res
=
kylinRefundsStatusServiceImpl
.
orderTicketRefunding
(
refundApplyParam
,
orderInfo
,
orderTicketsId
,
RefundPriceExpress
,
ticketEntityIds
,
realRefundPriceList
,
authId
,
authName
);
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"isHaveRefundDetails"
,
1
);
BasicDBObject
obj
=
new
BasicDBObject
(
"$set"
,
mongoConverter
.
convertToMongoType
(
map
));
mongoTemplate
.
getCollection
(
KylinOrderTicketVo
.
class
.
getSimpleName
()).
updateOne
(
Query
.
query
(
Criteria
.
where
(
"orderTicketsId"
).
is
(
orderTicketsId
)).
getQueryObject
(),
obj
);
boolean
res
=
kylinRefundsStatusServiceImpl
.
orderTicketRefunding
(
refundApplyParam
,
orderInfo
,
orderTicketsId
,
RefundPriceExpress
,
ticketEntityIds
,
realRefundPriceList
,
authId
,
authName
);
if
(
res
)
{
return
ResponseDto
.
success
();
}
else
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"isHaveRefundDetails"
,
1
);
BasicDBObject
obj
=
new
BasicDBObject
(
"$set"
,
mongoConverter
.
convertToMongoType
(
map
));
mongoTemplate
.
getCollection
(
KylinOrderTicketVo
.
class
.
getSimpleName
()).
updateOne
(
Query
.
query
(
Criteria
.
where
(
"orderTicketsId"
).
is
(
orderTicketsId
)).
getQueryObject
(),
obj
);
if
(
res
)
{
return
ResponseDto
.
success
();
}
else
{
return
ResponseDto
.
failure
(
"操作失败"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"orderApplyException e[{}]"
,
e
);
return
ResponseDto
.
failure
(
"操作失败"
);
}
}
...
...
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