Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
yohoufo-fore
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
chenchao
6 years ago
Commit
6144fad27f3ccf31426fae7eac1c7c2d6cdb1a53
2 parents
5979a229
3222e788
Merge branch 'hotfix20181210sellercancelbug' into dev6.8.3_order
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
8 deletions
order/src/main/java/com/yohoufo/order/service/impl/SellerOrderCancelService.java
order/src/main/java/com/yohoufo/order/service/impl/SellerOrderCancelService.java
View file @
6144fad
...
...
@@ -35,6 +35,7 @@ import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import
com.yohoufo.order.utils.LoggerUtils
;
import
com.yohoufo.order.utils.PaymentHelper
;
import
lombok.experimental.Builder
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -44,6 +45,7 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
* Created by chenchao on 2018/9/17.
...
...
@@ -106,26 +108,53 @@ public class SellerOrderCancelService {
cancel
(
uid
,
orderCode
,
actor
);
}
private
final
static
List
<
Integer
>
relatedBuyerStatusList
=
Arrays
.
asList
(
OrderStatus
.
WAITING_PAY
.
getCode
(),
OrderStatus
.
HAS_PAYED
.
getCode
(),
OrderStatus
.
SELLER_SEND_OUT
.
getCode
(),
OrderStatus
.
PLATFORM_CHECKING
.
getCode
(),
OrderStatus
.
WAITING_RECEIVE
.
getCode
(),
OrderStatus
.
DONE
.
getCode
());
private
BuyerOrder
getBuyerOrderBySkup
(
Integer
skup
,
int
uid
,
Long
orderCode
,
OrderCodeType
actor
){
List
<
BuyerOrderGoods
>
pbogList
=
buyerOrderGoodsMapper
.
selectBySkups
(
Arrays
.
asList
(
skup
));
BuyerOrder
buyerOrder
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
pbogList
)){
List
<
Long
>
orderCodeList
=
pbogList
.
parallelStream
().
map
(
BuyerOrderGoods:
:
getOrderCode
).
collect
(
Collectors
.
toList
());
List
<
BuyerOrder
>
pboList
=
buyerOrderMapper
.
selectByOrderCodes
(
orderCodeList
,
relatedBuyerStatusList
);
if
(
CollectionUtils
.
isNotEmpty
(
pboList
)){
if
(
pboList
.
size
()
>
1
){
logger
.
warn
(
"in seller cancel ,related buyer order size {} buyer orderCodeList {} uid {} orderCode {} actor {}"
,
pboList
.
size
(),
orderCodeList
,
uid
,
orderCode
,
actor
);
throw
new
UfoServiceException
(
501
,
"订单不能取消"
);
}
buyerOrder
=
pboList
.
get
(
0
);
}
}
return
buyerOrder
;
}
public
int
cancel
(
int
uid
,
long
orderCode
,
OrderCodeType
actor
){
int
result
=
0
;
SellerOrder
sellerOrder
=
null
;
BuyerOrder
buyerOrder
=
null
;
Integer
skup
=
null
;
//seller order code
if
(
OrderCodeType
.
SELLER_TYPE
.
equals
(
actor
)){
sellerOrder
=
sellerOrderMapper
.
selectByOrderCodeUid
(
orderCode
,
uid
);
if
(
Objects
.
isNull
(
sellerOrder
)){
return
result
;
}
skup
=
sellerOrder
.
getSkup
();
buyerOrder
=
getBuyerOrderBySkup
(
skup
,
uid
,
orderCode
,
actor
);
}
BuyerOrder
buyerOrder
=
null
;
//buyer order code
if
(
OrderCodeType
.
BUYER_TYPE
.
equals
(
actor
)){
buyerOrder
=
buyerOrderMapper
.
selectByOrderCode
(
orderCode
);
BuyerOrderGoods
buyerOrderGoods
=
buyerOrderGoodsMapper
.
selectByOrderCode
(
buyerOrder
.
getUid
(),
orderCode
);
sellerOrder
=
sellerOrderMapper
.
selectBySkup
(
buyerOrderGoods
.
getSkup
());
if
(
Objects
.
isNull
(
sellerOrder
)){
return
result
;
}
skup
=
sellerOrder
.
getSkup
();
}
if
(
Objects
.
isNull
(
sellerOrder
)){
return
result
;
}
final
int
skup
=
sellerOrder
.
getSkup
();
Integer
status
=
Optional
.
ofNullable
(
sellerOrder
).
map
(
SellerOrder:
:
getStatus
).
orElse
(
null
);
logger
.
info
(
"in seller cancel, uid {}, orderCode {}, SellerOrder status {}"
,
uid
,
orderCode
,
status
);
if
(
Objects
.
isNull
(
status
)){
...
...
@@ -321,7 +350,7 @@ public class SellerOrderCancelService {
*/
Integer
buyerOrderStatus
=
buyerOrder
.
getStatus
();
if
(
Objects
.
isNull
(
buyerOrderStatus
)
||
!
ActionStatusHold
.
sellerCanCancelBuyerOrder
(
buyerOrderStatus
)){
throw
new
UfoServiceException
(
501
,
"不能取消"
);
throw
new
UfoServiceException
(
501
,
"
买家支付中,
不能取消"
);
}
final
int
sellerUid
=
sellerOrder
.
getUid
(),
buyerUid
=
buyerOrder
.
getUid
();
...
...
Please
register
or
login
to post a comment