记得上下班打卡 | 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
f656e9e9
Commit
f656e9e9
authored
Feb 21, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
店铺券使用
parent
547a10be
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
311 additions
and
9 deletions
+311
-9
GoblinUseResultVo.java
...om/liquidnet/service/goblin/dto/vo/GoblinUseResultVo.java
+31
-0
BackCouponParam.java
...a/com/liquidnet/service/goblin/param/BackCouponParam.java
+45
-0
GoblinCouponService.java
...liquidnet/service/goblin/service/GoblinCouponService.java
+8
-0
GoblinCouponController.java
...net/service/goblin/controller/GoblinCouponController.java
+81
-9
GoblinCouponImpl.java
...quidnet/service/goblin/service/impl/GoblinCouponImpl.java
+135
-0
GoblinMongoUtils.java
...a/com/liquidnet/service/goblin/util/GoblinMongoUtils.java
+7
-0
ObjectUtil.java
...in/java/com/liquidnet/service/goblin/util/ObjectUtil.java
+4
-0
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinUseResultVo.java
0 → 100644
View file @
f656e9e9
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
@Data
@ApiModel
public
class
GoblinUseResultVo
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
4073256621782131607L
;
@ApiModelProperty
(
value
=
"优惠内容"
,
example
=
"1"
)
private
BigDecimal
value
;
@ApiModelProperty
(
value
=
"券类型[1-代金券|2-折扣券|3-满减券]"
,
example
=
"1"
)
private
String
couType
;
private
static
final
GoblinUseResultVo
obj
=
new
GoblinUseResultVo
();
public
static
GoblinUseResultVo
getNew
()
{
try
{
return
(
GoblinUseResultVo
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
e
.
printStackTrace
();
}
return
new
GoblinUseResultVo
();
}
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/param/BackCouponParam.java
0 → 100644
View file @
f656e9e9
package
com
.
liquidnet
.
service
.
goblin
.
param
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
@Api
public
class
BackCouponParam
implements
Serializable
,
Cloneable
{
@ApiModelProperty
(
dataType
=
"String"
,
name
=
"uCouponIds"
,
value
=
"券唯一表示id(逗号隔开的字符串)"
,
example
=
"1"
,
required
=
true
)
@NotNull
@NotBlank
private
String
uCouponIds
;
@ApiModelProperty
(
dataType
=
"String"
,
name
=
"uid"
,
value
=
"用户id"
,
example
=
"10"
,
required
=
true
)
@NotNull
@NotBlank
private
String
uid
;
private
static
final
BackCouponParam
obj
=
new
BackCouponParam
();
public
static
BackCouponParam
getNew
()
{
try
{
return
(
BackCouponParam
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
e
.
printStackTrace
();
}
return
new
BackCouponParam
();
}
public
String
getuCouponIds
()
{
return
uCouponIds
;
}
public
void
setuCouponIds
(
String
uCouponIds
)
{
this
.
uCouponIds
=
uCouponIds
;
}
public
String
getUid
()
{
return
uid
;
}
public
void
setUid
(
String
uid
)
{
this
.
uid
=
uid
;
}
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/service/GoblinCouponService.java
View file @
f656e9e9
package
com
.
liquidnet
.
service
.
goblin
.
service
;
package
com
.
liquidnet
.
service
.
goblin
.
service
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUseResultVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.param.BackCouponParam
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -17,12 +20,17 @@ public interface GoblinCouponService {
...
@@ -17,12 +20,17 @@ public interface GoblinCouponService {
Boolean
receiveCoupon
(
String
uid
,
List
<
GoblinUserCouponVo
>
userCouponVoList
,
GoblinStoreCouponVo
storeCouponVo
);
Boolean
receiveCoupon
(
String
uid
,
List
<
GoblinUserCouponVo
>
userCouponVoList
,
GoblinStoreCouponVo
storeCouponVo
);
//我的券列表 [类型 1可用 2过期/已使用]
//我的券列表 [类型 1可用 2过期/已使用]
List
<
GoblinUserCouponVo
>
getList
(
String
type
);
//是否可用券 [价格] [spuId逗号隔开] [uid]
//是否可用券 [价格] [spuId逗号隔开] [uid]
Boolean
canUse
(
BigDecimal
totalPrice
,
String
spuId
,
String
uid
);
//可用券列表 [价格] [spuId逗号隔开] [uid]
//可用券列表 [价格] [spuId逗号隔开] [uid]
List
<
GoblinUserCouponVo
>
useList
(
BigDecimal
totalPrice
,
String
spuId
,
String
uid
);
//使用券 [券id] [消费内容] [价格] [spuId逗号隔开]
//使用券 [券id] [消费内容] [价格] [spuId逗号隔开]
GoblinUseResultVo
useCoupon
(
String
ucouponId
,
String
content
,
BigDecimal
totalPrice
,
String
spuId
,
String
uid
);
//回退券 [list<Data>] [券id , 用户id]
//回退券 [list<Data>] [券id , 用户id]
Boolean
backCoupon
(
List
<
BackCouponParam
>
params
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinCouponController.java
View file @
f656e9e9
...
@@ -4,19 +4,19 @@ import com.liquidnet.commons.lang.util.CurrentUtil;
...
@@ -4,19 +4,19 @@ import com.liquidnet.commons.lang.util.CurrentUtil;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUseResultVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.param.BackCouponParam
;
import
com.liquidnet.service.goblin.service.GoblinCouponService
;
import
com.liquidnet.service.goblin.service.GoblinCouponService
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -50,20 +50,20 @@ public class GoblinCouponController {
...
@@ -50,20 +50,20 @@ public class GoblinCouponController {
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"storeId"
,
value
=
"店铺id"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"storeId"
,
value
=
"店铺id"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"type"
,
value
=
"券类型[1-代金券|2-折扣券|3-满减券]"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"type"
,
value
=
"券类型[1-代金券|2-折扣券|3-满减券]"
),
})
})
public
ResponseDto
<
ArrayList
<
GoblinStoreCouponVo
>>
checkOrderResult
(
@RequestParam
(
"spuId"
)
@Valid
String
spuId
,
public
ResponseDto
<
ArrayList
<
GoblinStoreCouponVo
>>
getSpuByType
(
@RequestParam
(
"spuId"
)
@Valid
String
spuId
,
@RequestParam
(
"storeId"
)
@Valid
String
storeId
,
@RequestParam
(
"storeId"
)
@Valid
String
storeId
,
@RequestParam
(
"type"
)
@Valid
String
type
)
{
@RequestParam
(
"type"
)
@Valid
String
type
)
{
return
ResponseDto
.
success
(
goblinCouponService
.
getSpuByType
(
spuId
,
storeId
,
type
));
return
ResponseDto
.
success
(
goblinCouponService
.
getSpuByType
(
spuId
,
storeId
,
type
));
}
}
@PostMapping
(
"
checkPayment
"
)
@PostMapping
(
"
receive
"
)
@ApiOperation
(
"订单状态"
)
@ApiOperation
(
"订单状态"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"storeCouponId"
,
value
=
"平台券id"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"storeCouponId"
,
value
=
"平台券id"
),
// @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "number", value = "数量"),
// @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "number", value = "数量"),
})
})
public
ResponseDto
<
Boolean
>
checkOrderResult
(
@RequestParam
(
"storeCouponId"
)
@Valid
String
storeCouponId
)
{
public
ResponseDto
<
Boolean
>
receive
(
@RequestParam
(
"storeCouponId"
)
@Valid
String
storeCouponId
)
{
// public ResponseDto<Boolean> checkOrderResult(@RequestParam("storeCouponId") @Valid String storeCouponId,
// public ResponseDto<Boolean> checkOrderResult(@RequestParam("storeCouponId") @Valid String storeCouponId,
// @RequestParam("number") @Valid Integer number) {
// @RequestParam("number") @Valid Integer number) {
String
currentUid
=
CurrentUtil
.
getCurrentUid
();
String
currentUid
=
CurrentUtil
.
getCurrentUid
();
...
@@ -89,4 +89,76 @@ public class GoblinCouponController {
...
@@ -89,4 +89,76 @@ public class GoblinCouponController {
}
}
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140053"
));
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140053"
));
}
}
@PostMapping
(
"my/list"
)
@ApiOperation
(
"我的券券列表[根据类型]"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"type"
,
value
=
"类型 1可用 2过期/已使用"
),
})
public
ResponseDto
<
List
<
GoblinUserCouponVo
>>
getList
(
@RequestParam
(
"type"
)
@Valid
String
type
)
{
return
ResponseDto
.
success
(
goblinCouponService
.
getList
(
type
));
}
@PostMapping
(
"can/use"
)
@ApiOperation
(
"是否可用券"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"Number"
,
name
=
"totalPrice"
,
value
=
"spuId"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"spuId"
,
value
=
"逗号隔开"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"uid"
,
value
=
"用户id"
),
})
public
ResponseDto
<
Boolean
>
canUse
(
@RequestParam
(
"totalPrice"
)
@Valid
BigDecimal
totalPrice
,
@RequestParam
(
"spuId"
)
@Valid
String
spuId
,
@RequestParam
(
value
=
"uid"
,
required
=
false
)
@Valid
String
uid
)
{
if
(
uid
==
null
)
{
uid
=
CurrentUtil
.
getCurrentUid
();
}
return
ResponseDto
.
success
(
goblinCouponService
.
canUse
(
totalPrice
,
spuId
,
uid
));
}
@PostMapping
(
"useList"
)
@ApiOperation
(
"可用券列表"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"Number"
,
name
=
"totalPrice"
,
value
=
"spuId"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"spuId"
,
value
=
"逗号隔开"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"uid"
,
value
=
"用户id"
)
})
public
ResponseDto
<
List
<
GoblinUserCouponVo
>>
useList
(
@RequestParam
(
"totalPrice"
)
@Valid
BigDecimal
totalPrice
,
@RequestParam
(
"spuId"
)
@Valid
String
spuId
,
@RequestParam
(
value
=
"uid"
,
required
=
false
)
@Valid
String
uid
)
{
if
(
uid
==
null
)
{
uid
=
CurrentUtil
.
getCurrentUid
();
}
return
ResponseDto
.
success
(
goblinCouponService
.
useList
(
totalPrice
,
spuId
,
uid
));
}
@PostMapping
(
"useCoupon"
)
@ApiOperation
(
"用券"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"ucouponId"
,
value
=
"券id"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"content"
,
value
=
"消费内容"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"Number"
,
name
=
"totalPrice"
,
value
=
"总价格"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"spuId"
,
value
=
"spuId逗号隔开"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"uid"
,
value
=
"uid"
),
})
public
ResponseDto
<
GoblinUseResultVo
>
checkOrderResult
(
@RequestParam
(
"ucouponId"
)
@Valid
String
ucouponId
,
@RequestParam
(
"content"
)
@Valid
String
content
,
@RequestParam
(
"totalPrice"
)
@Valid
BigDecimal
totalPrice
,
@RequestParam
(
"spuId"
)
@Valid
String
spuId
,
@RequestParam
(
"uid"
)
@Valid
String
uid
)
{
return
ResponseDto
.
success
(
goblinCouponService
.
useCoupon
(
ucouponId
,
content
,
totalPrice
,
spuId
,
uid
));
}
@PostMapping
(
"backCoupon"
)
@ApiOperation
(
"退券"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
public
ResponseDto
<
Boolean
>
checkOrderResult
(
@RequestBody
@Valid
List
<
BackCouponParam
>
backCouponParam
)
{
if
(
backCouponParam
.
size
()
>
100
)
{
return
ResponseDto
.
failure
(
"数据量不得大于100"
);
}
return
ResponseDto
.
success
(
goblinCouponService
.
backCoupon
(
backCouponParam
));
}
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinCouponImpl.java
View file @
f656e9e9
...
@@ -3,10 +3,13 @@ package com.liquidnet.service.goblin.service.impl;
...
@@ -3,10 +3,13 @@ package com.liquidnet.service.goblin.service.impl;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.service.goblin.constant.GoblinStatusConst
;
import
com.liquidnet.service.goblin.constant.GoblinStatusConst
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUseResultVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponBasicVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponBasicVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo
;
import
com.liquidnet.service.goblin.param.BackCouponParam
;
import
com.liquidnet.service.goblin.service.GoblinCouponService
;
import
com.liquidnet.service.goblin.service.GoblinCouponService
;
import
com.liquidnet.service.goblin.util.GoblinMongoUtils
;
import
com.liquidnet.service.goblin.util.GoblinMongoUtils
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
...
@@ -16,9 +19,11 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -16,9 +19,11 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
@Slf4j
@Slf4j
...
@@ -93,4 +98,134 @@ public class GoblinCouponImpl implements GoblinCouponService {
...
@@ -93,4 +98,134 @@ public class GoblinCouponImpl implements GoblinCouponService {
goblinRedisUtils
.
incrStoreCouponStock
(
storeCouponId
,
1
);
goblinRedisUtils
.
incrStoreCouponStock
(
storeCouponId
,
1
);
return
false
;
return
false
;
}
}
@Override
public
List
<
GoblinUserCouponVo
>
getList
(
String
type
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
GoblinUserCouponVo
>
voList
=
goblinRedisUtils
.
getUserCouponVos
(
uid
);
List
<
GoblinUserCouponVo
>
returnList
=
ObjectUtil
.
getGoblinUserCouponVo
();
for
(
GoblinUserCouponVo
vo
:
voList
)
{
if
(
"1"
.
equals
(
type
))
{
if
(
vo
.
getState
().
equals
(
1
))
{
returnList
.
add
(
vo
);
}
}
else
{
if
(
vo
.
getState
().
equals
(
3
)
||
vo
.
getState
().
equals
(
5
))
{
returnList
.
add
(
vo
);
}
}
}
return
returnList
;
}
@Override
public
Boolean
canUse
(
BigDecimal
totalPrice
,
String
spuId
,
String
uid
)
{
List
<
GoblinUserCouponVo
>
voList
=
goblinRedisUtils
.
getUserCouponVos
(
uid
);
Boolean
canUse
=
false
;
for
(
GoblinUserCouponVo
vo
:
voList
)
{
//判断券状态 和 触发金额
if
(
vo
.
getState
().
equals
(
1
)
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
>=
0
)
{
List
<
String
>
spuIds
=
goblinRedisUtils
.
getStoreCouponSpuIds
(
vo
.
getStoreCouponId
());
//判断是否在可用商品内
for
(
String
item
:
spuIds
)
{
List
<
String
>
spuList
=
Arrays
.
asList
(
spuId
.
split
(
","
));
if
(
spuList
.
contains
(
item
))
{
canUse
=
true
;
break
;
}
}
}
if
(
canUse
)
{
break
;
}
}
return
canUse
;
}
@Override
public
List
<
GoblinUserCouponVo
>
useList
(
BigDecimal
totalPrice
,
String
spuId
,
String
uid
)
{
List
<
GoblinUserCouponVo
>
voList
=
goblinRedisUtils
.
getUserCouponVos
(
uid
);
List
<
GoblinUserCouponVo
>
returnList
=
ObjectUtil
.
getGoblinUserCouponVo
();
for
(
GoblinUserCouponVo
vo
:
voList
)
{
//判断券状态 和 触发金额
if
(
vo
.
getState
().
equals
(
1
)
&&
vo
.
getTriggers
().
compareTo
(
totalPrice
)
>=
0
)
{
List
<
String
>
spuIds
=
goblinRedisUtils
.
getStoreCouponSpuIds
(
vo
.
getStoreCouponId
());
//判断是否在可用商品内
for
(
String
item
:
spuIds
)
{
List
<
String
>
spuList
=
Arrays
.
asList
(
spuId
.
split
(
","
));
if
(
spuList
.
contains
(
item
))
{
returnList
.
add
(
vo
);
break
;
}
}
}
}
return
returnList
;
}
@Override
public
GoblinUseResultVo
useCoupon
(
String
ucouponId
,
String
content
,
BigDecimal
totalPrice
,
String
spuId
,
String
uid
)
{
List
<
GoblinUserCouponVo
>
voList
=
goblinRedisUtils
.
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
)
{
List
<
String
>
spuIds
=
goblinRedisUtils
.
getStoreCouponSpuIds
(
vo
.
getStoreCouponId
());
//判断是否在可用商品内
for
(
String
item
:
spuIds
)
{
List
<
String
>
spuList
=
Arrays
.
asList
(
spuId
.
split
(
","
));
if
(
spuList
.
contains
(
item
))
{
if
(
vo
.
getType
().
equals
(
"1"
))
{
//代金券
returnVo
.
setValue
(
vo
.
getValFace
());
returnVo
.
setCouType
(
vo
.
getType
());
}
else
if
(
vo
.
getType
().
equals
(
"2"
))
{
//折扣
returnVo
.
setValue
(
totalPrice
.
multiply
(
vo
.
getDeduction
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
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
);
break
;
}
}
}
break
;
}
}
if
(!
returnVo
.
getCouType
().
equals
(
"-1"
))
{
goblinRedisUtils
.
setUserCouponVos
(
uid
,
voList
);
}
return
returnVo
;
}
@Override
public
Boolean
backCoupon
(
List
<
BackCouponParam
>
params
)
{
try
{
for
(
BackCouponParam
item
:
params
)
{
List
<
GoblinUserCouponVo
>
voList
=
goblinRedisUtils
.
getUserCouponVos
(
item
.
getUid
());
for
(
GoblinUserCouponVo
vo
:
voList
)
{
if
(
vo
.
getUcouponId
().
equals
(
item
.
getuCouponIds
()))
{
if
(
LocalDateTime
.
now
().
isBefore
(
vo
.
getDuedAt
()))
{
vo
.
setState
(
1
);
vo
.
setUsedFor
(
""
);
goblinRedisUtils
.
setUserCouponVos
(
item
.
getUid
(),
voList
);
goblinMongoUtils
.
changeCouponVos
(
vo
.
getUcouponId
(),
vo
);
}
break
;
}
}
}
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinMongoUtils.java
View file @
f656e9e9
...
@@ -1055,6 +1055,13 @@ public class GoblinMongoUtils {
...
@@ -1055,6 +1055,13 @@ public class GoblinMongoUtils {
return
mongoTemplate
.
insert
(
vo
,
GoblinUserCouponBasicVo
.
class
.
getSimpleName
());
return
mongoTemplate
.
insert
(
vo
,
GoblinUserCouponBasicVo
.
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
;
}
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/ObjectUtil.java
View file @
f656e9e9
...
@@ -72,6 +72,7 @@ public class ObjectUtil {
...
@@ -72,6 +72,7 @@ public class ObjectUtil {
private
static
final
ArrayList
<
GoblinStoreMarketDto
>
goblinStoreMarketDtoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinStoreMarketDto
>
goblinStoreMarketDtoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinStoreCouponVo
>
goblinStoreCouponVoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinStoreCouponVo
>
goblinStoreCouponVoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinStoreMgtCouponListVoExcel
>
goblinStoreMgtCouponListVoExcelArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinStoreMgtCouponListVoExcel
>
goblinStoreMgtCouponListVoExcelArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinUserCouponVo
>
goblinUserCouponVo
=
new
ArrayList
<>();
private
static
final
BasicDBObject
basicDBObject
=
new
BasicDBObject
();
private
static
final
BasicDBObject
basicDBObject
=
new
BasicDBObject
();
private
static
final
ArrayList
<
WriteModel
<
Document
>>
writeModelDocumentArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
WriteModel
<
Document
>>
writeModelDocumentArrayList
=
new
ArrayList
<>();
...
@@ -91,6 +92,9 @@ public class ObjectUtil {
...
@@ -91,6 +92,9 @@ public class ObjectUtil {
public
static
ArrayList
<
GoblinGoodsInfoListVo
>
getGoblinGoodsInfoListVo
()
{
public
static
ArrayList
<
GoblinGoodsInfoListVo
>
getGoblinGoodsInfoListVo
()
{
return
(
ArrayList
<
GoblinGoodsInfoListVo
>)
goblinGoodsInfoListVo
.
clone
();
return
(
ArrayList
<
GoblinGoodsInfoListVo
>)
goblinGoodsInfoListVo
.
clone
();
}
}
public
static
ArrayList
<
GoblinUserCouponVo
>
getGoblinUserCouponVo
()
{
return
(
ArrayList
<
GoblinUserCouponVo
>)
goblinUserCouponVo
.
clone
();
}
public
static
ArrayList
<
GoblinStoreMgtGoodsListVoExcel
>
getGoblinStoreMgtGoodsListVoExcelArrayList
()
{
public
static
ArrayList
<
GoblinStoreMgtGoodsListVoExcel
>
getGoblinStoreMgtGoodsListVoExcelArrayList
()
{
return
(
ArrayList
<
GoblinStoreMgtGoodsListVoExcel
>)
goblinStoreMgtGoodsListVoExcelArrayList
.
clone
();
return
(
ArrayList
<
GoblinStoreMgtGoodsListVoExcel
>)
goblinStoreMgtGoodsListVoExcelArrayList
.
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