记得上下班打卡 | 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
fa4e0656
Commit
fa4e0656
authored
Feb 22, 2022
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
~API:商铺活动:优惠券+领取使用统计;
+优惠券库存为0不做库存判断逻辑;
parent
f076911a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
21 deletions
+73
-21
GoblinStoreMgtCouponListVo.java
...vice/goblin/dto/manage/vo/GoblinStoreMgtCouponListVo.java
+2
-2
GoblinCouponController.java
...net/service/goblin/controller/GoblinCouponController.java
+1
-1
GoblinCouponImpl.java
...quidnet/service/goblin/service/impl/GoblinCouponImpl.java
+11
-9
GoblinStoreMgtCouponServiceImpl.java
.../service/impl/manage/GoblinStoreMgtCouponServiceImpl.java
+36
-9
GoblinMongoUtils.java
...a/com/liquidnet/service/goblin/util/GoblinMongoUtils.java
+10
-0
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+4
-0
GoblinRedisUtils.java
...om/liquidnet/service/platform/utils/GoblinRedisUtils.java
+9
-0
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/manage/vo/GoblinStoreMgtCouponListVo.java
View file @
fa4e0656
...
...
@@ -40,7 +40,7 @@ public class GoblinStoreMgtCouponListVo implements Serializable, Cloneable {
@ApiModelProperty
(
position
=
20
,
value
=
"已领取库存"
)
private
Integer
receiveStock
;
private
int
receiveStock
;
@ApiModelProperty
(
position
=
21
,
value
=
"已使用库存"
)
private
Integer
usedStock
;
private
int
usedStock
;
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinCouponController.java
View file @
fa4e0656
...
...
@@ -83,7 +83,7 @@ public class GoblinCouponController {
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140052"
));
}
}
if
(
goblinRedisUtils
.
getStoreCouponStock
(
storeCouponId
)
>
0
)
{
if
(
storeCouponVo
.
getStock
().
equals
(
0
)
||
goblinRedisUtils
.
getStoreCouponStock
(
storeCouponId
)
>
0
)
{
Boolean
resultFlg
=
goblinCouponService
.
receiveCoupon
(
currentUid
,
userCouponVos
,
storeCouponVo
);
return
resultFlg
?
ResponseDto
.
success
()
:
ResponseDto
.
failure
();
}
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinCouponImpl.java
View file @
fa4e0656
...
...
@@ -72,16 +72,16 @@ public class GoblinCouponImpl implements GoblinCouponService {
@Override
public
Boolean
receiveCoupon
(
String
uid
,
List
<
GoblinUserCouponVo
>
userCouponVoList
,
GoblinStoreCouponVo
storeCouponVo
)
{
String
storeCouponId
=
storeCouponVo
.
getStoreCouponId
();
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
storeCouponVo
.
getStock
().
equals
(
0
)
||
goblinRedisUtils
.
decrStoreCouponStock
(
storeCouponId
,
1
)
>=
0
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
GoblinUserCouponBasicVo
receiveUserCouponBasicVo
=
GoblinUserCouponBasicVo
.
getNew
().
initByStoreCouponVo
(
storeCouponVo
);
receiveUserCouponBasicVo
.
setUid
(
uid
);
receiveUserCouponBasicVo
.
setBindAt
(
now
);
receiveUserCouponBasicVo
.
setOperator
(
uid
);
receiveUserCouponBasicVo
.
setCreatedAt
(
now
);
GoblinUserCouponBasicVo
receiveUserCouponBasicVo
=
GoblinUserCouponBasicVo
.
getNew
().
initByStoreCouponVo
(
storeCouponVo
);
receiveUserCouponBasicVo
.
setUid
(
uid
);
receiveUserCouponBasicVo
.
setBindAt
(
now
);
receiveUserCouponBasicVo
.
setOperator
(
uid
);
receiveUserCouponBasicVo
.
setCreatedAt
(
now
);
userCouponVoList
.
add
(
GoblinUserCouponVo
.
getNew
().
copy
(
receiveUserCouponBasicVo
));
userCouponVoList
.
add
(
GoblinUserCouponVo
.
getNew
().
copy
(
receiveUserCouponBasicVo
));
if
(
goblinRedisUtils
.
decrStoreCouponStock
(
storeCouponId
,
1
)
>=
0
)
{
goblinMongoUtils
.
insertUserCouponVo
(
receiveUserCouponBasicVo
);
goblinRedisUtils
.
setUserCouponVos
(
uid
,
userCouponVoList
);
...
...
@@ -95,7 +95,9 @@ public class GoblinCouponImpl implements GoblinCouponService {
SqlMapping
.
get
(
"goblin_user_coupon.insert"
,
initUserCouponObjs
));
return
true
;
}
goblinRedisUtils
.
incrStoreCouponStock
(
storeCouponId
,
1
);
if
(!
storeCouponVo
.
getStock
().
equals
(
0
))
{
goblinRedisUtils
.
incrStoreCouponStock
(
storeCouponId
,
1
);
}
return
false
;
}
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinStoreMgtCouponServiceImpl.java
View file @
fa4e0656
...
...
@@ -12,9 +12,7 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponFilterParam;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponInfoVo
;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponListVo
;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponSpuListVo
;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinSelfGoodsCategoryVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponBasicVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtExtraService
;
...
...
@@ -24,15 +22,13 @@ import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import
com.liquidnet.service.goblin.util.ObjectUtil
;
import
com.liquidnet.service.goblin.util.QueueUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
...
...
@@ -52,7 +48,31 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
PagedResult
<
GoblinStoreMgtCouponListVo
>
mgtCouponListVoPagedResult
=
goblinMongoUtils
.
getMgtStoreCouponListVos
(
filterParam
);
if
(
mgtCouponListVoPagedResult
.
getTotal
()
>
0
)
{
List
<
GoblinStoreMgtCouponListVo
>
volist
=
mgtCouponListVoPagedResult
.
getList
();
List
<
String
>
storeCouponIdList
=
volist
.
stream
().
map
(
GoblinStoreMgtCouponListVo:
:
getStoreCouponId
).
collect
(
Collectors
.
toList
());
List
<
Document
>
aggregateUserCouponResults
=
goblinMongoUtils
.
aggregateMgtUserCoupon
(
storeCouponIdList
);
if
(!
CollectionUtils
.
isEmpty
(
aggregateUserCouponResults
))
{
volist
.
forEach
(
vo
->
{
List
<
Document
>
aggregateUserCouponResult
=
aggregateUserCouponResults
.
stream
()
.
filter
(
r
->
r
.
getString
(
"storeCouponId"
).
equals
(
vo
.
getStoreCouponId
())).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
aggregateUserCouponResult
))
{
int
receiveStock
=
0
,
usedStock
=
0
;
for
(
Document
aggregateDoc
:
aggregateUserCouponResult
)
{
Integer
totalCount
=
aggregateDoc
.
getInteger
(
"totalCount"
);
switch
(
aggregateDoc
.
getInteger
(
"state"
))
{
// 用户券状态[1-可用|2-无效|3-已过期|5-已使用]
case
5
:
usedStock
+=
totalCount
;
default
:
receiveStock
+=
totalCount
;
}
}
vo
.
setReceiveStock
(
receiveStock
);
vo
.
setUsedStock
(
usedStock
);
}
});
}
else
{
}
}
return
mgtCouponListVoPagedResult
;
}
...
...
@@ -122,7 +142,10 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
storeCouponBasicVo
.
setCreatedBy
(
uid
);
goblinMongoUtils
.
setMgtStoreCouponBasicVo
(
storeCouponBasicVo
);
Integer
stock
=
storeCouponBasicVo
.
getStock
();
if
(!
stock
.
equals
(
0
))
{
goblinRedisUtils
.
setStoreCouponStock
(
storeCouponId
,
stock
);
}
LinkedList
<
String
>
toMqSqls
=
CollectionUtil
.
linkedListString
();
toMqSqls
.
add
(
SqlMapping
.
get
(
"goblin_store_coupon.insert"
));
...
...
@@ -130,7 +153,7 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
initStoreCouponObjs
.
add
(
new
Object
[]{
storeCouponId
,
storeCouponBasicVo
.
getStoreCouponNo
(),
storeCouponBasicVo
.
getStoreId
(),
storeCouponBasicVo
.
getTitle
(),
storeCouponBasicVo
.
getLabel
(),
storeCouponBasicVo
.
getNotice
(),
storeCouponBasicVo
.
getType
(),
sto
reCouponBasicVo
.
getStock
()
,
storeCouponBasicVo
.
getTriggers
(),
storeCouponBasicVo
.
getType
(),
sto
ck
,
storeCouponBasicVo
.
getTriggers
(),
storeCouponBasicVo
.
getValFace
(),
storeCouponBasicVo
.
getDiscount
(),
storeCouponBasicVo
.
getValOver
(),
storeCouponBasicVo
.
getValMinus
(),
storeCouponBasicVo
.
getDeduction
(),
storeCouponBasicVo
.
getReceiveLimit
(),
storeCouponBasicVo
.
getReceiveCurb
(),
storeCouponBasicVo
.
getUseScope
(),
storeCouponBasicVo
.
getState
(),
...
...
@@ -210,7 +233,8 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
@Override
public
boolean
couponEditStock
(
GoblinStoreCouponVo
storeCouponVo
,
String
uid
,
int
operStock
)
{
String
storeCouponId
=
storeCouponVo
.
getStoreCouponId
();
int
stock
=
storeCouponVo
.
getStock
(),
surplusStock
,
operStockVal
=
Math
.
abs
(
operStock
);
Integer
stock
=
storeCouponVo
.
getStock
();
int
surplusStock
,
operStockVal
=
Math
.
abs
(
operStock
);
if
(
operStock
<
0
)
{
surplusStock
=
goblinRedisUtils
.
decrStoreCouponStock
(
storeCouponId
,
operStockVal
);
if
(
surplusStock
<
0
)
{
...
...
@@ -227,6 +251,9 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
LocalDateTime
now
=
LocalDateTime
.
now
();
goblinMongoUtils
.
updateMgtStoreCouponStock
(
storeCouponId
,
stock
,
uid
,
now
);
if
(
stock
.
equals
(
0
))
{
goblinRedisUtils
.
delStoreCouponStock
(
storeCouponId
);
}
goblinRedisUtils
.
del
(
GoblinRedisConst
.
STORE_COUPON
.
concat
(
storeCouponId
));
// 删除REDIS缓存
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_STORE
.
getKey
(),
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinMongoUtils.java
View file @
fa4e0656
...
...
@@ -1096,6 +1096,16 @@ public class GoblinMongoUtils {
return
pagedResult
.
setList
(
mgtCouponListVos
).
setTotal
(
count
,
filterParam
.
getPageSize
());
}
public
List
<
Document
>
aggregateMgtUserCoupon
(
List
<
String
>
storeCouponIds
)
{
Aggregation
aggregation
=
Aggregation
.
newAggregation
(
Aggregation
.
project
(
"storeCouponId"
,
"state"
,
"receiveStock"
),
Aggregation
.
match
(
Criteria
.
where
(
"storeCouponId"
).
in
(
storeCouponIds
).
and
(
"state"
).
ne
(
2
)),
Aggregation
.
group
(
"storeCouponId"
,
"state"
).
count
().
as
(
"totalCount"
)
);
AggregationResults
<
Document
>
aggregationResults
=
mongoTemplate
.
aggregate
(
aggregation
,
GoblinUserCouponBasicVo
.
class
.
getSimpleName
(),
Document
.
class
);
return
aggregationResults
.
getMappedResults
();
}
//根据艺人标签和演出查询商品
public
List
<
GoblinGoodsInfoVo
>
getMusicTagPGoods
(
String
musicTag
,
String
performanceId
)
{
return
mongoTemplate
.
find
(
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
fa4e0656
...
...
@@ -986,6 +986,10 @@ public class GoblinRedisUtils {
return
redisUtil
.
set
(
GoblinRedisConst
.
STORE_COUPON_STOCK
.
concat
(
storeCouponId
),
stock
);
}
public
void
delStoreCouponStock
(
String
storeCouponId
)
{
redisUtil
.
del
(
GoblinRedisConst
.
STORE_COUPON_STOCK
.
concat
(
storeCouponId
));
}
public
int
getStoreCouponStock
(
String
storeCouponId
)
{
Object
valObj
=
redisUtil
.
get
(
GoblinRedisConst
.
STORE_COUPON_STOCK
.
concat
(
storeCouponId
));
return
null
==
valObj
?
0
:
(
int
)
valObj
;
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/utils/GoblinRedisUtils.java
View file @
fa4e0656
...
...
@@ -29,6 +29,9 @@ public class GoblinRedisUtils {
public
void
del
(
String
...
keys
)
{
getRedis
().
del
(
keys
);
}
public
boolean
set
(
String
key
,
Object
val
)
{
return
getRedis
().
set
(
key
,
val
);
}
// 获取 订单相关vo
public
GoblinStoreOrderVo
getGoblinOrder
(
String
orderId
)
{
...
...
@@ -139,8 +142,14 @@ public class GoblinRedisUtils {
public
boolean
addStoreMarketDto
(
String
storeId
,
GoblinStoreMarketDto
dto
)
{
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
storeId
);
dtos
.
removeIf
(
r
->
r
.
getType
().
equals
(
dto
.
getType
())
&&
r
.
getId
().
equals
(
dto
.
getId
()));
dtos
.
add
(
dto
);
return
getRedis
().
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
storeId
),
JsonUtils
.
toJson
(
dtos
));
// if (dtos.stream().noneMatch(r -> (r.getType().equals(dto.getType()) && r.getId().equals(dto.getId())))) {
// dtos.add(dto);
// return getRedis().set(GoblinRedisConst.STORE_MARKETS.concat(storeId), JsonUtils.toJson(dtos));
// }
// return false;
}
public
void
delStoreMarketDto
(
String
storeId
,
GoblinStoreMarketDto
dto
)
{
...
...
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