记得上下班打卡 | 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
95404e1d
Commit
95404e1d
authored
Mar 10, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改逻辑
parent
74b1ebe8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
49 deletions
+61
-49
GoblinOrderServiceImpl.java
...et/service/order/service/impl/GoblinOrderServiceImpl.java
+15
-22
GoblinOrderUtils.java
...a/com/liquidnet/service/order/utils/GoblinOrderUtils.java
+46
-27
No files found.
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/service/impl/GoblinOrderServiceImpl.java
View file @
95404e1d
...
...
@@ -88,7 +88,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
List
<
GoblinOrderStoreParam
>
goblinOrderStoreParamList
=
param
.
getGoblinOrderStoreParamList
();
//分订单
boolean
isMember
;
AddressVo
addressesVo
=
null
;
if
(
noZhengzaiOrder
(
uid
))
{
if
(
orderUtils
.
noZhengzaiOrder
(
uid
))
{
addressesVo
=
param
.
getAddressesVo
();
long
time3
=
System
.
currentTimeMillis
();
if
(
orderUtils
.
getMember
(
uid
)
!=
null
)
{
...
...
@@ -96,7 +96,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
}
else
{
isMember
=
false
;
}
log
.
error
(
"获取会员信息:"
+(
System
.
currentTimeMillis
()-
time3
)+
"ms"
);
log
.
error
(
"获取会员信息:"
+
(
System
.
currentTimeMillis
()
-
time3
)
+
"ms"
);
}
else
{
isMember
=
false
;
}
...
...
@@ -104,19 +104,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String
orderId
=
IDGenerator
.
nextSnowId
();
String
orderCode
=
IDGenerator
.
storeCode
(
orderId
);
for
(
GoblinOrderSkuParam
skuParam
:
storeParam
.
getGoblinOrderSkuParamArrayList
())
{
//商品维度循环
Long
time3
=
System
.
currentTimeMillis
();
String
skuId
=
skuParam
.
getSkuId
();
int
number
=
skuParam
.
getNumber
();
String
pre
=
GoblinStatusConst
.
MarketPreStatus
.
getPre
(
skuId
);
// GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuId);
log
.
error
(
"获取skuVo"
+
(
System
.
currentTimeMillis
()
-
time3
)
+
"ms"
);
int
surplusGeneral
=
redisUtils
.
decrSkuStock
(
pre
,
skuId
,
number
);
skuAndPreListAndNumber
.
add
(
skuId
+
","
+
pre
+
","
+
number
);
log
.
error
(
"判断逻辑 "
+
(
System
.
currentTimeMillis
()
-
time3
)
+
"ms"
);
//库存回滚
if
(
surplusGeneral
<
0
)
{
re
disUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
throw
new
Exception
(
"库存不足"
);
re
turn
orderUtils
.
orderException
(
skuAndPreListAndNumber
,
platformCodeList
,
storeCodeList
,
uid
,
"库存不足"
);
//
throw new Exception("库存不足");
}
}
//GoblinOrderSkuParam
//下单
...
...
@@ -133,7 +129,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
orderSqlParams
.
add
(
sqlParam
);
}
//GoblinOrderStoreParam
if
(
preParam
.
getOrderIdList
().
equals
(
""
))
{
throw
new
Exception
(
"参数异常"
);
return
orderUtils
.
orderException
(
skuAndPreListAndNumber
,
platformCodeList
,
storeCodeList
,
uid
,
"参数异常"
);
// throw new Exception("参数异常");
}
return
payOrder
(
preParam
,
orderSqlParams
,
uid
);
}
catch
(
Exception
e
)
{
...
...
@@ -146,7 +143,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String
pre
=
array
[
1
];
int
number
=
Integer
.
parseInt
(
array
[
2
]);
redisUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
if
(
noZhengzaiOrder
(
uid
))
{
if
(
orderUtils
.
noZhengzaiOrder
(
uid
))
{
redisUtils
.
decrSkuCountByUid
(
uid
,
skuId
,
number
);
}
}
...
...
@@ -217,13 +214,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
Long
time3
=
System
.
currentTimeMillis
();
GoblinGoodsSkuInfoVo
skuVo
=
redisUtils
.
getGoodsSkuInfoVo
(
skuParam
.
getSkuId
());
GoblinGoodsInfoVo
spuVo
=
redisUtils
.
getGoodsInfoVo
(
skuParam
.
getSpuId
());
if
(!
spuVo
.
getStoreId
().
equals
(
storeParam
.
getStoreId
())
||
!
skuVo
.
getStoreId
().
equals
(
storeParam
.
getStoreId
()))
{
throw
new
Exception
(
"非法参数"
);
}
if
(!(
skuVo
.
getStatus
().
equals
(
"3"
)
&&
skuVo
.
getShelvesStatus
().
equals
(
"3"
))
||
skuVo
.
getDelFlg
().
equals
(
"1"
))
{
throw
new
Exception
(
"不可购买"
);
}
// 判断库存
int
limitCount
=
skuVo
.
getBuyLimit
()
==
0
?
Integer
.
MAX_VALUE
:
skuVo
.
getBuyLimit
();
//判断限购
if
(
noZhengzaiOrder
(
uid
))
{
if
(
orderUtils
.
noZhengzaiOrder
(
uid
))
{
String
res1
=
orderUtils
.
judgeOrderLimit
(
uid
,
skuParam
.
getSkuId
(),
skuParam
.
getNumber
(),
limitCount
);
if
(!
res1
.
equals
(
""
))
{
throw
new
Exception
(
"已超出限购数量"
);
...
...
@@ -234,10 +234,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
throw
new
Exception
(
"无权购买"
);
}
}
log
.
error
(
"获取会员sku&spu:"
+(
System
.
currentTimeMillis
()-
time3
)+
"ms"
);
if
(!
spuVo
.
getStoreId
().
equals
(
storeParam
.
getStoreId
())
||
!
skuVo
.
getStoreId
().
equals
(
storeParam
.
getStoreId
()))
{
throw
new
Exception
(
"非法参数"
);
}
log
.
error
(
"获取会员sku&spu:"
+
(
System
.
currentTimeMillis
()
-
time3
)
+
"ms"
);
marketId
=
spuVo
.
getMarketId
();
marketType
=
pre
;
skuName
=
skuName
.
concat
(
skuVo
.
getName
()).
concat
(
","
);
...
...
@@ -349,7 +346,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
}
long
time3
=
System
.
currentTimeMillis
();
GoblinStoreInfoVo
storeInfoVo
=
redisUtils
.
getStoreInfoVo
(
storeId
);
log
.
error
(
"获取店铺信息:"
+(
System
.
currentTimeMillis
()-
time3
)+
"ms"
);
log
.
error
(
"获取店铺信息:"
+
(
System
.
currentTimeMillis
()
-
time3
)
+
"ms"
);
//生成订单
GoblinStoreOrder
storeOrder
=
GoblinStoreOrder
.
getNew
();
storeOrder
.
setMasterOrderCode
(
orderMasterCode
);
...
...
@@ -567,7 +564,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
log
.
error
(
"保存数据:"
+
(
System
.
currentTimeMillis
()
-
time2
)
+
"ms"
);
time2
=
System
.
currentTimeMillis
();
//redis 订单列表
if
(
noZhengzaiOrder
(
uid
))
{
if
(
orderUtils
.
noZhengzaiOrder
(
uid
))
{
if
(
orderVo
.
getMarketType
()
==
null
)
{
redisUtils
.
addOrderList
(
uid
,
orderVo
.
getOrderId
());
}
else
if
(
orderVo
.
getMarketType
().
equals
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_ZHENGZAI
.
getValue
()))
{
...
...
@@ -835,7 +832,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
// );
// }
//加分
if
(
noZhengzaiOrder
(
uid
))
{
if
(
orderUtils
.
noZhengzaiOrder
(
uid
))
{
orderUtils
.
doTask
(
uid
,
priceActual
);
}
}
...
...
@@ -1000,8 +997,4 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
}
return
"success"
;
}
private
boolean
noZhengzaiOrder
(
String
uid
)
{
return
!
uid
.
equals
(
"zhengzai"
);
}
}
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/GoblinOrderUtils.java
View file @
95404e1d
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.service.adam.dto.vo.AdamRscPolymer01Vo
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.constant.MQConst
;
...
...
@@ -51,29 +52,6 @@ public class GoblinOrderUtils {
@Autowired
GoblinMongoUtils
goblinMongoUtils
;
public
AdamRscPolymer01Vo
adamAddressEnterMember
(
String
uid
,
String
enterIds
,
String
addressId
)
{
try
{
MultiValueMap
<
String
,
String
>
header
=
CollectionUtil
.
linkedMultiValueMapStringString
();
header
.
add
(
"Accept"
,
"application/json;charset=UTF-8"
);
MultiValueMap
<
String
,
String
>
params
=
CollectionUtil
.
linkedMultiValueMapStringString
();
params
.
add
(
"addressId"
,
addressId
);
params
.
add
(
"entersIds"
,
enterIds
);
params
.
add
(
"uid"
,
uid
);
String
resultData
=
HttpUtil
.
post
(
adamUrl
+
"/adam/rsc/inquire/of_buy_ticket"
,
params
,
header
);
ResponseDto
<
AdamRscPolymer01Vo
>
vo
=
JsonUtils
.
fromJson
(
resultData
,
new
TypeReference
<
ResponseDto
<
AdamRscPolymer01Vo
>>()
{
});
if
(
null
!=
vo
.
getData
())
{
return
vo
.
getData
();
}
else
{
return
null
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"获取用户信息,e:{}"
,
e
);
e
.
printStackTrace
();
return
null
;
}
}
//判断 数量限购
public
String
judgeOrderLimit
(
String
uid
,
String
skuId
,
int
number
,
int
limitCount
)
{
int
buyCount
=
redisUtils
.
getSkuCountByUid
(
uid
,
skuId
);
...
...
@@ -401,9 +379,9 @@ public class GoblinOrderUtils {
backOrderLog
.
getMessage
(),
backOrderLog
.
getOperationName
(),
backOrderLog
.
getStatus
(),
now
)
);
if
(
success
)
{
if
(
success
)
{
return
true
;
}
else
{
}
else
{
log
.
error
(
"退款失败:"
+
message
);
return
false
;
}
...
...
@@ -428,8 +406,8 @@ public class GoblinOrderUtils {
params
.
add
(
"paymentType"
,
orderVo
.
getPaymentType
());
params
.
add
(
"price"
,
String
.
valueOf
(
price
));
BigDecimal
totalPrice
=
BigDecimal
.
ZERO
;
String
[]
orderIds
=
redisUtils
.
getMasterCode
(
orderVo
.
getOrderId
());
for
(
String
orderId
:
orderIds
)
{
String
[]
orderIds
=
redisUtils
.
getMasterCode
(
orderVo
.
getOrderId
());
for
(
String
orderId
:
orderIds
)
{
GoblinStoreOrderVo
vo
=
redisUtils
.
getGoblinOrder
(
orderId
);
totalPrice
=
totalPrice
.
add
(
vo
.
getPriceActual
());
}
...
...
@@ -441,4 +419,45 @@ public class GoblinOrderUtils {
log
.
debug
(
"REFUND DATA = "
+
returnString
);
return
returnString
;
}
//订单异常处理
public
ResponseDto
<
GoblinPayInnerResultVo
>
orderException
(
List
<
String
>
skuAndPreListAndNumber
,
List
<
String
>
platformCodeList
,
List
<
String
>
storeCodeList
,
String
uid
,
String
message
)
{
long
time3
=
System
.
currentTimeMillis
();
//回顾限购 回滚库存
for
(
String
item
:
skuAndPreListAndNumber
)
{
String
[]
array
=
item
.
split
(
","
);
String
skuId
=
array
[
0
];
String
pre
=
array
[
1
];
int
number
=
Integer
.
parseInt
(
array
[
2
]);
redisUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
if
(
noZhengzaiOrder
(
uid
))
{
redisUtils
.
decrSkuCountByUid
(
uid
,
skuId
,
number
);
}
}
//回退平台券
for
(
String
platformCode
:
platformCodeList
)
{
backCoupon
(
platformCode
,
uid
);
}
//回退店铺券
List
<
com
.
liquidnet
.
service
.
goblin
.
param
.
BackCouponParam
>
params
=
ObjectUtil
.
getBackCouponParam
();
for
(
String
storeCode
:
storeCodeList
)
{
com
.
liquidnet
.
service
.
goblin
.
param
.
BackCouponParam
backCouponParam
=
com
.
liquidnet
.
service
.
goblin
.
param
.
BackCouponParam
.
getNew
();
backCouponParam
.
setuCouponIds
(
storeCode
);
backCouponParam
.
setUid
(
uid
);
params
.
add
(
backCouponParam
);
}
if
(
params
.
size
()
>
0
)
{
backStoreCoupon
(
params
);
}
log
.
info
(
"回滚逻辑 "
+
(
System
.
currentTimeMillis
()
-
time3
)
+
"ms"
);
if
(
message
==
null
&&
!
message
.
equals
(
""
))
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20018"
));
//乱七八糟异常
}
else
{
return
ResponseDto
.
failure
(
message
);
//乱七八糟异常
}
}
public
boolean
noZhengzaiOrder
(
String
uid
)
{
return
!
uid
.
equals
(
"zhengzai"
);
}
}
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