记得上下班打卡 | 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
8ae8fabf
Commit
8ae8fabf
authored
Feb 18, 2022
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
~API:商城活动:优惠券领取;
parent
feda7ab5
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
215 additions
and
18 deletions
+215
-18
GoblinRedisConst.java
...m/liquidnet/service/goblin/constant/GoblinRedisConst.java
+9
-0
GoblinUserCouponBasicVo.java
...uidnet/service/goblin/dto/vo/GoblinUserCouponBasicVo.java
+55
-0
GoblinUserCouponVo.java
...m/liquidnet/service/goblin/dto/vo/GoblinUserCouponVo.java
+66
-0
GoblinCouponService.java
...liquidnet/service/goblin/service/GoblinCouponService.java
+4
-5
GoblinUserCoupon.java
...com/liquidnet/service/goblin/entity/GoblinUserCoupon.java
+2
-2
db_ln_goblin_initialdata.sql
...net-service-goblin-impl/docu/db_ln_goblin_initialdata.sql
+2
-2
GoblinCouponController.java
...net/service/goblin/controller/GoblinCouponController.java
+30
-2
GoblinCouponImpl.java
...quidnet/service/goblin/service/impl/GoblinCouponImpl.java
+10
-4
GoblinMongoUtils.java
...a/com/liquidnet/service/goblin/util/GoblinMongoUtils.java
+8
-0
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+21
-1
errors.properties
...-service-goblin-impl/src/main/resources/errors.properties
+8
-2
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/constant/GoblinRedisConst.java
View file @
8ae8fabf
...
...
@@ -145,4 +145,13 @@ public class GoblinRedisConst {
public
static
final
String
STORE_MARKETS
=
PREFIX
.
concat
(
"store_markets:"
);
/* ----------------------------------------------------------------- */
/**
* 商城用户券
* {golblin:user_coupon:${uid}, JsonUtils.toJson(List<com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo>)}
*/
public
static
final
String
USER_COUPON
=
PREFIX
.
concat
(
"user_coupon:"
);
/* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinUserCouponBasicVo.java
0 → 100644
View file @
8ae8fabf
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
/**
* 商城:用户优惠券基础信息
*/
@Data
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
GoblinUserCouponBasicVo
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
784844681919535650L
;
// com.liquidnet.service.goblin.entity.GoblinUserCoupon
private
String
ucouponId
;
private
String
storeCouponId
;
private
String
uid
;
////
private
Integer
state
;
private
LocalDateTime
bindAt
;
private
LocalDateTime
duedAt
;
private
LocalDateTime
usedAt
;
private
String
usedFor
;
private
String
operator
;
private
LocalDateTime
createdAt
;
private
LocalDateTime
updatedAt
;
// com.liquidnet.service.goblin.entity.GoblinStoreCoupon
private
String
storeId
;
////
private
String
title
;
private
String
label
;
private
String
notice
;
private
String
type
;
private
BigDecimal
triggers
;
private
BigDecimal
valFace
;
private
BigDecimal
discount
;
private
BigDecimal
valOver
;
private
BigDecimal
valMinus
;
private
BigDecimal
deduction
;
private
String
useScope
;
private
static
final
GoblinUserCouponBasicVo
obj
=
new
GoblinUserCouponBasicVo
();
public
static
GoblinUserCouponBasicVo
getNew
()
{
try
{
return
(
GoblinUserCouponBasicVo
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GoblinUserCouponBasicVo
();
}
}
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinUserCouponVo.java
0 → 100644
View file @
8ae8fabf
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
/**
* 商城:用户优惠券展示信息(缓存)
*/
@Data
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
GoblinUserCouponVo
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
-
5700053935603334517L
;
@ApiModelProperty
(
position
=
10
,
value
=
"用户券ID[64]"
)
private
String
ucouponId
;
@ApiModelProperty
(
position
=
11
,
value
=
"卡券ID"
)
private
String
storeCouponId
;
@ApiModelProperty
(
position
=
12
,
value
=
"用户券状态[1-可用|2-无效|3-已过期|5-已使用]"
)
private
Integer
state
;
@ApiModelProperty
(
position
=
13
,
value
=
"激活时间"
)
private
LocalDateTime
bindAt
;
@ApiModelProperty
(
position
=
14
,
value
=
"到期时间"
)
private
LocalDateTime
duedAt
;
@ApiModelProperty
(
position
=
15
,
value
=
"使用时间"
)
private
LocalDateTime
usedAt
;
@ApiModelProperty
(
position
=
16
,
value
=
"用于记录购买的内容"
)
private
String
usedFor
;
@ApiModelProperty
(
position
=
21
,
value
=
"卡券名称"
)
private
String
title
;
@ApiModelProperty
(
position
=
22
,
value
=
"标注"
)
private
String
label
;
@ApiModelProperty
(
position
=
23
,
value
=
"卡券描述"
)
private
String
notice
;
@ApiModelProperty
(
position
=
24
,
value
=
"券类型[1-代金券|2-折扣券|3-满减券]"
)
private
String
type
;
@ApiModelProperty
(
position
=
25
,
value
=
"触发金额"
)
private
BigDecimal
triggers
;
@ApiModelProperty
(
position
=
26
,
value
=
"面值"
)
private
BigDecimal
valFace
;
@ApiModelProperty
(
position
=
27
,
value
=
"折扣[8折即0.8]"
)
private
BigDecimal
discount
;
@ApiModelProperty
(
position
=
28
,
value
=
"满减~满"
)
private
BigDecimal
valOver
;
@ApiModelProperty
(
position
=
29
,
value
=
"满减~减"
)
private
BigDecimal
valMinus
;
@ApiModelProperty
(
position
=
30
,
value
=
"抵扣上限金额(最多扣除金额)"
)
private
BigDecimal
deduction
;
@ApiModelProperty
(
position
=
31
,
value
=
"使用范围[0-全部商品|1-部分商品]"
)
private
String
useScope
;
private
static
final
GoblinUserCouponVo
obj
=
new
GoblinUserCouponVo
();
public
static
GoblinUserCouponVo
getNew
()
{
try
{
return
(
GoblinUserCouponVo
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GoblinUserCouponVo
();
}
}
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/service/GoblinCouponService.java
View file @
8ae8fabf
package
com
.
liquidnet
.
service
.
goblin
.
service
;
import
com.liquidnet.service.goblin.dto.vo.*
;
import
com.liquidnet.service.goblin.entity.GoblinFrontHotWord
;
import
org.springframework.stereotype.Service
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.List
;
public
interface
GoblinCouponService
{
//根据spuId获取 该spu可参与的券活动
...
...
@@ -15,7 +14,7 @@ public interface GoblinCouponService {
ArrayList
<
GoblinStoreCouponVo
>
getSpuByType
(
String
spuId
,
String
storeId
,
String
type
);
//领取券
Boolean
receiveCoupon
(
String
storeCouponId
,
Integer
number
);
Boolean
receiveCoupon
(
String
uid
,
List
<
GoblinUserCouponVo
>
userCouponVoList
,
GoblinStoreCouponVo
storeCouponVo
,
Integer
number
);
//我的券列表 [类型 1可用 2过期/已使用]
...
...
liquidnet-bus-do/liquidnet-service-goblin-do/src/main/java/com/liquidnet/service/goblin/entity/GoblinUserCoupon.java
View file @
8ae8fabf
...
...
@@ -39,7 +39,7 @@ public class GoblinUserCoupon implements Serializable {
/**
* 用户券状态[1-可用|2-无效|3-已过期|5-已使用]
*/
private
String
state
;
private
Integer
state
;
/**
* 激活时间
...
...
@@ -59,7 +59,7 @@ public class GoblinUserCoupon implements Serializable {
/**
* 用于记录购买的内容
*/
private
String
used
By
;
private
String
used
For
;
private
String
operator
;
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/docu/db_ln_goblin_initialdata.sql
View file @
8ae8fabf
...
...
@@ -1023,11 +1023,11 @@ create table goblin_user_coupon
ucoupon_id
varchar
(
64
)
not
null
,
store_coupon_id
varchar
(
64
)
not
null
comment
'~goblin_store_coupon.store_coupon_id'
,
uid
varchar
(
64
)
not
null
comment
'~adam_user.uid'
,
state
char
null
comment
'用户券状态[1-可用|2-无效|3-已过期|5-已使用]'
,
state
tinyint
null
comment
'用户券状态[1-可用|2-无效|3-已过期|5-已使用]'
,
bind_at
datetime
(
3
)
null
comment
'激活时间'
,
dued_at
datetime
(
3
)
null
comment
'到期时间'
,
used_at
datetime
(
3
)
null
comment
'使用时间'
,
used_
by
varchar
(
255
)
null
comment
'用于记录购买的内容'
,
used_
for
varchar
(
255
)
null
comment
'用于记录购买的内容'
,
operator
varchar
(
64
)
null
,
created_at
datetime
(
3
)
not
null
,
updated_at
datetime
(
3
)
null
,
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinCouponController.java
View file @
8ae8fabf
package
com
.
liquidnet
.
service
.
goblin
.
controller
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.service.GoblinCouponService
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
io.swagger.annotations.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -13,13 +18,15 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.validation.Valid
;
import
java.util.ArrayList
;
import
java.util.List
;
@Slf4j
@Api
(
tags
=
"正在下单相关-商铺"
)
@RestController
@RequestMapping
(
"/store/coupon"
)
public
class
GoblinCouponController
{
@Autowired
GoblinRedisUtils
goblinRedisUtils
;
@Autowired
GoblinCouponService
goblinCouponService
;
...
...
@@ -58,6 +65,27 @@ public class GoblinCouponController {
})
public
ResponseDto
<
Boolean
>
checkOrderResult
(
@RequestParam
(
"storeCouponId"
)
@Valid
String
storeCouponId
,
@RequestParam
(
"number"
)
@Valid
Integer
number
)
{
return
ResponseDto
.
success
(
goblinCouponService
.
receiveCoupon
(
storeCouponId
,
number
));
String
currentUid
=
CurrentUtil
.
getCurrentUid
();
GoblinStoreCouponVo
storeCouponVo
=
goblinRedisUtils
.
getStoreCouponVo
(
storeCouponId
);
if
(
null
==
storeCouponVo
)
{
log
.
warn
(
"商城:用户领取优惠券:优惠券不存在:[uid={},storeCouponId={}]"
,
currentUid
,
storeCouponId
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140050"
));
}
if
(!
storeCouponVo
.
getState
().
equals
(
"1"
))
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140051"
));
}
List
<
GoblinUserCouponVo
>
userCouponVos
=
goblinRedisUtils
.
getUserCouponVos
(
currentUid
);
if
(!
CollectionUtils
.
isEmpty
(
userCouponVos
))
{
int
beforeSize
=
userCouponVos
.
size
();
userCouponVos
.
removeIf
(
vo
->
vo
.
getStoreCouponId
().
equals
(
storeCouponId
));
if
((
beforeSize
-
userCouponVos
.
size
())
>=
storeCouponVo
.
getReceiveLimit
())
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140052"
));
}
}
if
(
goblinRedisUtils
.
getStoreCouponStock
(
storeCouponId
)
>
0
)
{
Boolean
resultFlg
=
goblinCouponService
.
receiveCoupon
(
currentUid
,
userCouponVos
,
storeCouponVo
,
number
);
return
resultFlg
?
ResponseDto
.
success
()
:
ResponseDto
.
failure
();
}
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140053"
));
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinCouponImpl.java
View file @
8ae8fabf
...
...
@@ -3,9 +3,11 @@ package com.liquidnet.service.goblin.service.impl;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.service.goblin.constant.GoblinStatusConst
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.service.GoblinCouponService
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
com.liquidnet.service.goblin.util.ObjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -13,11 +15,12 @@ import java.time.LocalDateTime;
import
java.util.ArrayList
;
import
java.util.List
;
@Slf4j
@Service
public
class
GoblinCouponImpl
implements
GoblinCouponService
{
@Autowired
GoblinRedisUtils
r
edisUtils
;
GoblinRedisUtils
goblinR
edisUtils
;
@Override
public
ArrayList
<
String
>
getSpuType
(
String
spuId
,
String
storeId
)
{
...
...
@@ -26,7 +29,7 @@ public class GoblinCouponImpl implements GoblinCouponService {
if
(
pre
!=
null
)
{
spuId
=
spuId
.
split
(
pre
)[
0
];
}
List
<
GoblinStoreCouponVo
>
listVo
=
r
edisUtils
.
getGoodsMarketsForCoupon
(
spuId
,
storeId
);
List
<
GoblinStoreCouponVo
>
listVo
=
goblinR
edisUtils
.
getGoodsMarketsForCoupon
(
spuId
,
storeId
);
for
(
GoblinStoreCouponVo
vo
:
listVo
)
{
if
(!
returnList
.
contains
(
vo
.
getType
())
&&
LocalDateTime
.
now
().
isAfter
(
vo
.
getStartTime
())
&&
LocalDateTime
.
now
().
isBefore
(
vo
.
getEndTime
()))
{
returnList
.
add
(
vo
.
getType
());
...
...
@@ -42,7 +45,7 @@ public class GoblinCouponImpl implements GoblinCouponService {
if
(
pre
!=
null
)
{
spuId
=
spuId
.
split
(
pre
)[
0
];
}
List
<
GoblinStoreCouponVo
>
listVo
=
r
edisUtils
.
getGoodsMarketsForCoupon
(
spuId
,
storeId
);
List
<
GoblinStoreCouponVo
>
listVo
=
goblinR
edisUtils
.
getGoodsMarketsForCoupon
(
spuId
,
storeId
);
for
(
GoblinStoreCouponVo
vo
:
listVo
)
{
if
(
vo
.
getType
().
equals
(
type
)
&&
LocalDateTime
.
now
().
isAfter
(
vo
.
getStartTime
())
&&
LocalDateTime
.
now
().
isBefore
(
vo
.
getEndTime
()))
{
vo
.
setStock
(
null
);
...
...
@@ -53,7 +56,10 @@ public class GoblinCouponImpl implements GoblinCouponService {
}
@Override
public
Boolean
receiveCoupon
(
String
storeCouponId
,
Integer
number
)
{
public
Boolean
receiveCoupon
(
String
uid
,
List
<
GoblinUserCouponVo
>
userCouponVoList
,
GoblinStoreCouponVo
storeCouponVo
,
Integer
number
)
{
return
null
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinMongoUtils.java
View file @
8ae8fabf
...
...
@@ -1044,5 +1044,13 @@ public class GoblinMongoUtils {
}
;
/* ---------------------------------------- 商城:用户优惠券 ---------------------------------------- */
public
List
<
GoblinUserCouponVo
>
getUserCouponVos
(
String
uid
)
{
return
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"uid"
).
is
(
uid
)),
GoblinUserCouponVo
.
class
,
GoblinUserCouponBasicVo
.
class
.
getSimpleName
());
}
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
8ae8fabf
...
...
@@ -17,7 +17,6 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Array
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -1088,6 +1087,27 @@ public class GoblinRedisUtils {
return
storeCouponVos
;
}
/* ---------------------------------------- 商城:用户优惠券 ---------------------------------------- */
public
boolean
setUserCouponVos
(
String
uid
,
List
<
GoblinUserCouponVo
>
vos
)
{
return
redisUtil
.
set
(
GoblinRedisConst
.
USER_COUPON
.
concat
(
uid
),
JsonUtils
.
toJson
(
vos
));
}
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
))
{
if
(!
CollectionUtils
.
isEmpty
(
vos
=
goblinMongoUtils
.
getUserCouponVos
(
uid
)))
{
redisUtil
.
set
(
rk
,
JsonUtils
.
toJson
(
vos
));
}
}
else
{
vos
=
JsonUtils
.
fromJson
(
valStr
,
new
TypeReference
<
List
<
GoblinUserCouponVo
>>()
{
});
}
return
vos
;
}
/* ---------------------------------------- ---------------------------------------- */
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/resources/errors.properties
View file @
8ae8fabf
...
...
@@ -10,6 +10,14 @@
140050
=
优惠券不存在
140051
=
非活动时间不允许领取
140052
=
该活动优惠券为限量领取
140053
=
该活动优惠券被抢关了
...
...
@@ -33,6 +41,4 @@
148001
=
库存不足
149035
=
20018
=
下单失败
\ No newline at end of file
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