记得上下班打卡 | 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
55634f02
Commit
55634f02
authored
Mar 07, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
取消 店铺券可重复使用
店铺券 使用逻辑复制一份到 order
parent
fdaf9102
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
173 additions
and
14 deletions
+173
-14
GoblinCouponImpl.java
...quidnet/service/goblin/service/impl/GoblinCouponImpl.java
+1
-1
GoblinOrderServiceImpl.java
...et/service/order/service/impl/GoblinOrderServiceImpl.java
+9
-10
GoblinMongoUtils.java
...a/com/liquidnet/service/order/utils/GoblinMongoUtils.java
+14
-0
GoblinOrderUtils.java
...a/com/liquidnet/service/order/utils/GoblinOrderUtils.java
+108
-0
GoblinRedisUtils.java
...a/com/liquidnet/service/order/utils/GoblinRedisUtils.java
+34
-0
ObjectUtil.java
...in/java/com/liquidnet/service/order/utils/ObjectUtil.java
+7
-3
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinCouponImpl.java
View file @
55634f02
...
...
@@ -221,7 +221,7 @@ public class GoblinCouponImpl implements GoblinCouponService {
for
(
GoblinUserCouponVo
vo
:
voList
)
{
if
(
vo
.
getUcouponId
().
equals
(
ucouponId
))
{
//判断券状态 和 触发金额
if
((
vo
.
getState
().
equals
(
1
)
||
vo
.
getState
().
equals
(
5
)
)
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
<=
0
)
{
if
((
vo
.
getState
().
equals
(
1
))
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
<=
0
)
{
if
(
vo
.
getUseScope
().
equals
(
"0"
))
{
if
(
vo
.
getType
().
equals
(
"1"
))
{
//代金券
returnVo
.
setValue
(
vo
.
getValFace
());
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/service/impl/GoblinOrderServiceImpl.java
View file @
55634f02
...
...
@@ -20,12 +20,11 @@ import com.liquidnet.service.goblin.entity.GoblinOrderAttr;
import
com.liquidnet.service.goblin.entity.GoblinOrderSku
;
import
com.liquidnet.service.goblin.entity.GoblinStoreOrder
;
import
com.liquidnet.service.goblin.param.*
;
import
com.liquidnet.service.
candy
.param.BackCouponParam
;
import
com.liquidnet.service.
goblin
.param.BackCouponParam
;
import
com.liquidnet.service.goblin.service.IGoblinOrderService
;
import
com.liquidnet.service.order.utils.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -55,8 +54,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
QueueUtils
queueUtils
;
@Autowired
GoblinOrderUtils
orderUtils
;
@Autowired
FeignGoblinBaseClient
feignGoblinBaseClient
;
//
@Autowired
//
FeignGoblinBaseClient feignGoblinBaseClient;
@Value
(
"${liquidnet.service.order.url-pay.pay}"
)
private
String
payUrl
;
...
...
@@ -206,7 +205,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
params
.
add
(
backCouponParam
);
}
if
(
params
.
size
()
>
0
)
{
feignGoblinBaseClient
.
back
Coupon
(
params
);
orderUtils
.
backStore
Coupon
(
params
);
}
if
(
e
.
getMessage
()
==
null
)
{
...
...
@@ -354,12 +353,12 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
}
}
long
time1
=
System
.
currentTimeMillis
();
ResponseDto
<
GoblinUseResultVo
>
storeCouponVo
=
feignGoblinBaseClient
.
us
eCoupon
(
storeVoucherCode
,
"购买商品["
+
orderCode
+
"]"
,
storeTotalPrice
,
spuIds
,
uid
);
GoblinUseResultVo
storeCouponVo
=
orderUtils
.
useStor
eCoupon
(
storeVoucherCode
,
"购买商品["
+
orderCode
+
"]"
,
storeTotalPrice
,
spuIds
,
uid
);
log
.
info
(
"goblin接口调用:"
+
(
System
.
currentTimeMillis
()
-
time1
)
+
"秒"
);
String
typeVoucher
;
if
(
!(
storeCouponVo
==
null
||
storeCouponVo
.
getData
()
==
null
)
)
{
storeVoucherPrice
=
storeCouponVo
.
get
Data
().
get
Value
();
typeVoucher
=
storeCouponVo
.
get
Data
().
get
CouType
();
if
(
storeCouponVo
!=
null
)
{
storeVoucherPrice
=
storeCouponVo
.
getValue
();
typeVoucher
=
storeCouponVo
.
getCouType
();
if
(
typeVoucher
.
equals
(
"-1"
))
{
throw
new
Exception
(
"店铺券不可用"
);
}
else
{
...
...
@@ -951,7 +950,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
backCouponParam
.
setuCouponIds
(
orderVo
.
getStoreCouponId
());
backCouponParam
.
setUid
(
orderVo
.
getUserId
());
params
.
add
(
backCouponParam
);
feignGoblinBaseClient
.
back
Coupon
(
params
);
orderUtils
.
backStore
Coupon
(
params
);
}
}
backOrderVo
.
setStatus
(
GoblinStatusConst
.
Status
.
ORDER_BACK_STATUS_2
.
getValue
());
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/GoblinMongoUtils.java
View file @
55634f02
...
...
@@ -125,4 +125,18 @@ public class GoblinMongoUtils {
return
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"backCode"
).
is
(
backCode
)),
GoblinBackOrderVo
.
class
,
GoblinBackOrderVo
.
class
.
getSimpleName
());
}
public
Boolean
changeCouponVos
(
String
ucouponId
,
GoblinUserCouponVo
vo
)
{
return
mongoTemplate
.
getCollection
(
GoblinUserCouponVo
.
class
.
getSimpleName
())
.
updateOne
(
Query
.
query
(
Criteria
.
where
(
"ucouponId"
).
is
(
ucouponId
)).
getQueryObject
(),
ObjectUtil
.
cloneBasicDBObject
().
append
(
"$set"
,
mongoConverter
.
convertToMongoType
(
vo
))
).
getModifiedCount
()
>
0
;
}
public
GoblinStoreCouponBasicVo
getMgtStoreCouponBasicVo
(
String
storeCouponId
)
{
return
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"storeCouponId"
).
is
(
storeCouponId
).
and
(
"delFlg"
).
is
(
"0"
)),
GoblinStoreCouponBasicVo
.
class
,
GoblinStoreCouponBasicVo
.
class
.
getSimpleName
()
);
}
}
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/GoblinOrderUtils.java
View file @
55634f02
...
...
@@ -8,9 +8,13 @@ import com.liquidnet.commons.lang.util.HttpUtil;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.adam.dto.vo.AdamRscPolymer01Vo
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.candy.param.BackCouponParam
;
import
com.liquidnet.service.candy.vo.CandyCouponVo
;
import
com.liquidnet.service.candy.vo.CandyUseResultVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUseResultVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -18,8 +22,11 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.MultiValueMap
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
@Component
@Slf4j
...
...
@@ -32,7 +39,11 @@ public class GoblinOrderUtils {
@Value
(
"${liquidnet.service.stone.url}"
)
private
String
stoneUrl
;
@Autowired
QueueUtils
queueUtils
;
@Autowired
GoblinRedisUtils
redisUtils
;
@Autowired
GoblinMongoUtils
goblinMongoUtils
;
public
AdamRscPolymer01Vo
adamAddressEnterMember
(
String
uid
,
String
enterIds
,
String
addressId
)
{
try
{
...
...
@@ -192,4 +203,101 @@ public class GoblinOrderUtils {
e
.
printStackTrace
();
}
}
public
GoblinUseResultVo
useStoreCoupon
(
String
ucouponId
,
String
content
,
BigDecimal
totalPrice
,
String
spuId
,
String
uid
)
{
List
<
GoblinUserCouponVo
>
voList
=
redisUtils
.
getUserCouponVos
(
uid
);
GoblinUseResultVo
returnVo
=
GoblinUseResultVo
.
getNew
();
returnVo
.
setValue
(
BigDecimal
.
ZERO
);
returnVo
.
setCouType
(
"-1"
);
for
(
GoblinUserCouponVo
vo
:
voList
)
{
if
(
vo
.
getUcouponId
().
equals
(
ucouponId
))
{
//判断券状态 和 触发金额
if
((
vo
.
getState
().
equals
(
1
))
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
<=
0
)
{
if
(
vo
.
getUseScope
().
equals
(
"0"
))
{
if
(
vo
.
getType
().
equals
(
"1"
))
{
//代金券
returnVo
.
setValue
(
vo
.
getValFace
());
returnVo
.
setCouType
(
vo
.
getType
());
}
else
if
(
vo
.
getType
().
equals
(
"2"
))
{
//折扣
BigDecimal
tempPrice
=
totalPrice
.
multiply
(
vo
.
getDiscount
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
if
(
tempPrice
.
compareTo
(
vo
.
getDeduction
())
>
0
)
{
tempPrice
=
vo
.
getDeduction
();
}
returnVo
.
setValue
(
tempPrice
);
returnVo
.
setCouType
(
vo
.
getType
());
}
else
if
(
vo
.
getType
().
equals
(
"3"
)
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
<=
0
)
{
//满减
returnVo
.
setValue
(
vo
.
getValMinus
());
returnVo
.
setCouType
(
vo
.
getType
());
}
vo
.
setState
(
5
);
vo
.
setUsedFor
(
content
);
goblinMongoUtils
.
changeCouponVos
(
vo
.
getUcouponId
(),
vo
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_COUPON
.
getKey
(),
SqlMapping
.
get
(
"goblin_user_coupon.updateState"
,
vo
.
getState
(),
vo
.
getUsedFor
(),
LocalDateTime
.
now
(),
vo
.
getUcouponId
()));
break
;
}
else
{
List
<
String
>
spuIds
=
redisUtils
.
getStoreCouponSpuIds
(
vo
.
getStoreCouponId
());
if
(
spuId
==
null
)
{
continue
;
}
//判断是否在可用商品内
List
<
String
>
spuList
=
Arrays
.
asList
(
spuId
.
split
(
","
));
for
(
String
item
:
spuIds
)
{
if
(
spuList
.
contains
(
item
))
{
if
(
vo
.
getType
().
equals
(
"1"
))
{
//代金券
returnVo
.
setValue
(
vo
.
getValFace
());
returnVo
.
setCouType
(
vo
.
getType
());
}
else
if
(
vo
.
getType
().
equals
(
"2"
))
{
//折扣
BigDecimal
tempPrice
=
totalPrice
.
multiply
(
vo
.
getDiscount
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
if
(
tempPrice
.
compareTo
(
vo
.
getDeduction
())
>
0
)
{
tempPrice
=
vo
.
getDeduction
();
}
returnVo
.
setValue
(
tempPrice
);
returnVo
.
setCouType
(
vo
.
getType
());
}
else
if
(
vo
.
getType
().
equals
(
"3"
)
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
<=
0
)
{
//满减
returnVo
.
setValue
(
vo
.
getValMinus
());
returnVo
.
setCouType
(
vo
.
getType
());
}
vo
.
setState
(
5
);
vo
.
setUsedFor
(
content
);
goblinMongoUtils
.
changeCouponVos
(
vo
.
getUcouponId
(),
vo
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_COUPON
.
getKey
(),
SqlMapping
.
get
(
"goblin_user_coupon.updateState"
,
vo
.
getState
(),
vo
.
getUsedFor
(),
LocalDateTime
.
now
(),
vo
.
getUcouponId
()));
}
break
;
}
}
}
break
;
}
}
if
(!
returnVo
.
getCouType
().
equals
(
"-1"
))
{
redisUtils
.
setUserCouponVos
(
uid
,
voList
);
}
return
returnVo
;
}
public
Boolean
backStoreCoupon
(
List
<
com
.
liquidnet
.
service
.
goblin
.
param
.
BackCouponParam
>
params
)
{
try
{
for
(
com
.
liquidnet
.
service
.
goblin
.
param
.
BackCouponParam
item
:
params
)
{
List
<
GoblinUserCouponVo
>
voList
=
redisUtils
.
getUserCouponVos
(
item
.
getUid
());
for
(
GoblinUserCouponVo
vo
:
voList
)
{
if
(
vo
.
getUcouponId
().
equals
(
item
.
getuCouponIds
()))
{
if
(
LocalDateTime
.
now
().
isBefore
(
vo
.
getDuedAt
()))
{
vo
.
setState
(
1
);
vo
.
setUsedFor
(
""
);
redisUtils
.
setUserCouponVos
(
item
.
getUid
(),
voList
);
goblinMongoUtils
.
changeCouponVos
(
vo
.
getUcouponId
(),
vo
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_COUPON
.
getKey
(),
SqlMapping
.
get
(
"goblin_user_coupon.updateState"
,
vo
.
getState
(),
vo
.
getUsedFor
(),
LocalDateTime
.
now
(),
vo
.
getUcouponId
()));
}
break
;
}
}
}
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/GoblinRedisUtils.java
View file @
55634f02
...
...
@@ -366,4 +366,38 @@ public class GoblinRedisUtils {
return
(
List
<
GoblinMailVo
>)
obj
;
}
}
public
List
<
GoblinUserCouponVo
>
getUserCouponVos
(
String
uid
)
{
String
rk
=
GoblinRedisConst
.
USER_COUPON
.
concat
(
uid
);
String
valStr
=
(
String
)
redisUtil
.
get
(
rk
);
List
<
GoblinUserCouponVo
>
vos
;
if
(
StringUtils
.
isEmpty
(
valStr
))
{
return
ObjectUtil
.
getGoblinUserCouponVo
();
}
else
{
vos
=
JsonUtils
.
fromJson
(
valStr
,
new
TypeReference
<
List
<
GoblinUserCouponVo
>>()
{
});
}
return
vos
;
}
public
List
<
String
>
getStoreCouponSpuIds
(
String
storeCouponId
)
{
String
rk
=
GoblinRedisConst
.
STORE_COUPON_RULE
.
concat
(
storeCouponId
);
String
valStr
=
(
String
)
redisUtil
.
get
(
rk
);
List
<
String
>
strs
;
if
(
StringUtils
.
isEmpty
(
valStr
))
{
GoblinStoreCouponBasicVo
storeCouponBasicVo
=
goblinMongoUtils
.
getMgtStoreCouponBasicVo
(
storeCouponId
);
strs
=
null
==
storeCouponBasicVo
?
null
:
storeCouponBasicVo
.
getSpuIdList
();
if
(!
CollectionUtils
.
isEmpty
(
strs
))
{
redisUtil
.
set
(
rk
,
JsonUtils
.
toJson
(
strs
));
}
}
else
{
strs
=
JsonUtils
.
fromJson
(
valStr
,
new
TypeReference
<
List
<
String
>>()
{
});
}
return
strs
;
}
public
boolean
setUserCouponVos
(
String
uid
,
List
<
GoblinUserCouponVo
>
vos
)
{
return
redisUtil
.
set
(
GoblinRedisConst
.
USER_COUPON
.
concat
(
uid
),
JsonUtils
.
toJson
(
vos
));
}
}
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/ObjectUtil.java
View file @
55634f02
...
...
@@ -4,8 +4,9 @@ import com.liquidnet.service.adam.dto.vo.AdamEntersVo;
import
com.liquidnet.service.goblin.dto.vo.GoblinMailVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.entity.GoblinOrderSku
;
import
com.liquidnet.service.
candy
.param.BackCouponParam
;
import
com.liquidnet.service.
goblin
.param.BackCouponParam
;
import
com.liquidnet.service.goblin.param.GoblinOrderSqlParam
;
import
com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo
;
import
com.liquidnet.service.kylin.entity.KylinOrderCoupons
;
...
...
@@ -49,8 +50,7 @@ public class ObjectUtil {
private
static
final
ArrayList
<
GoblinStoreOrderVo
>
goblinStoreOrderVoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinOrderSkuVo
>
goblinOrderSkuVoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
WriteModel
<
Document
>>
writeModelDocumentArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinUserCouponVo
>
goblinUserCouponVo
=
new
ArrayList
<>();
public
static
Object
[]
objectsArray
;
public
static
final
Integer
[]
integerArray2
=
new
Integer
[
2
];
...
...
@@ -63,6 +63,10 @@ public class ObjectUtil {
return
(
ArrayList
<
GoblinOrderSkuVo
>)
goblinOrderSkuVoArrayList
.
clone
();
}
public
static
ArrayList
<
GoblinUserCouponVo
>
getGoblinUserCouponVo
()
{
return
(
ArrayList
<
GoblinUserCouponVo
>)
goblinUserCouponVo
.
clone
();
}
public
static
ArrayList
<
GoblinMailVo
>
goblinMailVo
()
{
return
(
ArrayList
<
GoblinMailVo
>)
goblinMailVo
.
clone
();
}
...
...
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