记得上下班打卡 | 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
561c2c8a
Commit
561c2c8a
authored
Feb 18, 2022
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
~API:商品活动数据获取及店铺活动存储;
parent
145c9fd6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
250 additions
and
9 deletions
+250
-9
GoblinStoreMarketDto.java
...om/liquidnet/service/goblin/dto/GoblinStoreMarketDto.java
+10
-0
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+9
-9
PlatformGoblinStoreTaskController.java
...roller/goblin/task/PlatformGoblinStoreTaskController.java
+51
-0
PlatformGoblinStoreCouponService.java
...service/impl/goblin/PlatformGoblinStoreCouponService.java
+133
-0
GoblinRedisUtils.java
...om/liquidnet/service/platform/utils/GoblinRedisUtils.java
+47
-0
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/GoblinStoreMarketDto.java
View file @
561c2c8a
...
...
@@ -17,4 +17,14 @@ public class GoblinStoreMarketDto implements Serializable, Cloneable {
* 活动类型:1-优惠券
*/
private
Integer
type
;
private
static
final
GoblinStoreMarketDto
obj
=
new
GoblinStoreMarketDto
();
public
static
GoblinStoreMarketDto
getNew
()
{
try
{
return
(
GoblinStoreMarketDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GoblinStoreMarketDto
();
}
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
561c2c8a
...
...
@@ -966,24 +966,24 @@ public class GoblinRedisUtils {
return
dtos
;
}
public
boolean
addStoreMarketDto
(
String
s
pu
Id
,
GoblinStoreMarketDto
dto
)
{
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
s
pu
Id
);
public
boolean
addStoreMarketDto
(
String
s
tore
Id
,
GoblinStoreMarketDto
dto
)
{
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
s
tore
Id
);
dtos
.
add
(
dto
);
return
redisUtil
.
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
pu
Id
),
JsonUtils
.
toJson
(
dtos
));
return
redisUtil
.
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
tore
Id
),
JsonUtils
.
toJson
(
dtos
));
}
public
void
delStoreMarket
(
String
spu
Id
)
{
redisUtil
.
del
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
pu
Id
));
public
void
delStoreMarket
Dto
(
String
store
Id
)
{
redisUtil
.
del
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
tore
Id
));
}
public
void
delStoreMarket
(
String
spu
Id
,
GoblinStoreMarketDto
dto
)
{
String
rk
=
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
pu
Id
);
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
s
pu
Id
);
public
void
delStoreMarket
Dto
(
String
store
Id
,
GoblinStoreMarketDto
dto
)
{
String
rk
=
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
tore
Id
);
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
s
tore
Id
);
if
(!
CollectionUtils
.
isEmpty
(
dtos
))
{
int
beforeSize
=
dtos
.
size
();
dtos
.
removeIf
(
r
->
r
.
getId
().
equals
(
dto
.
getId
())
&&
r
.
getType
().
equals
(
dto
.
getType
()));
if
(
beforeSize
>
dtos
.
size
())
{
redisUtil
.
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
pu
Id
),
JsonUtils
.
toJson
(
dtos
));
redisUtil
.
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
s
tore
Id
),
JsonUtils
.
toJson
(
dtos
));
}
}
}
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/goblin/task/PlatformGoblinStoreTaskController.java
0 → 100644
View file @
561c2c8a
package
com
.
liquidnet
.
service
.
platform
.
controller
.
goblin
.
task
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.liquidnet.common.cache.redis.util.AbstractRedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisDataSourceUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.entity.GoblinGoods
;
import
com.liquidnet.service.goblin.entity.GoblinStoreCoupon
;
import
com.liquidnet.service.platform.service.impl.goblin.PlatformGoblinGoodsService
;
import
com.liquidnet.service.platform.service.impl.goblin.PlatformGoblinStoreCouponService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 商城商品任务处理
*
* @author zhanggb
* Created by IntelliJ IDEA at 2022/1/21
*/
@Slf4j
@RestController
@RequestMapping
(
"gstore/task"
)
public
class
PlatformGoblinStoreTaskController
{
@Autowired
private
PlatformGoblinStoreCouponService
platformGoblinStoreCouponService
;
@PutMapping
(
"market"
)
public
ResponseDto
<
String
>
marketActivityProcessing
()
{
int
startNum
=
0
,
stopNum
=
0
;
LocalDateTime
now
=
LocalDateTime
.
now
();
{
// 优惠券活动
startNum
+=
platformGoblinStoreCouponService
.
activityStartProcessing
(
now
);
stopNum
+=
platformGoblinStoreCouponService
.
activityStopProcessing
(
now
);
}
return
ResponseDto
.
success
(
String
.
format
(
"商铺活动处理成功[开启=%s,结束=%s]"
,
startNum
,
stopNum
));
}
}
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/service/impl/goblin/PlatformGoblinStoreCouponService.java
0 → 100644
View file @
561c2c8a
package
com
.
liquidnet
.
service
.
platform
.
service
.
impl
.
goblin
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.liquidnet.common.cache.redis.util.AbstractRedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisDataSourceUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.dto.GoblinStoreMarketDto
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponBasicVo
;
import
com.liquidnet.service.goblin.entity.GoblinStoreCoupon
;
import
com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper
;
import
com.liquidnet.service.goblin.mapper.GoblinStoreCouponMapper
;
import
com.liquidnet.service.platform.utils.GoblinRedisUtils
;
import
com.mongodb.client.result.UpdateResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
public
class
PlatformGoblinStoreCouponService
extends
ServiceImpl
<
GoblinStoreCouponMapper
,
GoblinStoreCoupon
>
{
@Autowired
private
GoblinStoreCouponMapper
goblinStoreCouponMapper
;
@Autowired
private
GoblinRedisUtils
goblinRedisUtils
;
@Autowired
private
MongoTemplate
mongoTemplate
;
public
int
activityStartProcessing
(
LocalDateTime
now
)
{
LambdaQueryWrapper
<
GoblinStoreCoupon
>
queryWrapper
=
Wrappers
.
lambdaQuery
(
GoblinStoreCoupon
.
class
);
queryWrapper
.
eq
(
GoblinStoreCoupon:
:
getDelFlg
,
"0"
);
queryWrapper
.
eq
(
GoblinStoreCoupon:
:
getState
,
"0"
);
queryWrapper
.
le
(
GoblinStoreCoupon:
:
getStartTime
,
now
);
List
<
GoblinStoreCoupon
>
storeCouponList
=
this
.
list
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
storeCouponList
))
{
List
<
String
>
storeCouponIdList
=
storeCouponList
.
stream
().
map
(
GoblinStoreCoupon:
:
getStoreCouponId
).
collect
(
Collectors
.
toList
());
LambdaUpdateWrapper
<
GoblinStoreCoupon
>
updateWrapper
=
Wrappers
.
lambdaUpdate
(
GoblinStoreCoupon
.
class
);
updateWrapper
.
eq
(
GoblinStoreCoupon:
:
getDelFlg
,
"0"
);
updateWrapper
.
eq
(
GoblinStoreCoupon:
:
getState
,
"0"
);
updateWrapper
.
in
(
GoblinStoreCoupon:
:
getStoreCouponId
,
storeCouponIdList
);
updateWrapper
.
set
(
GoblinStoreCoupon:
:
getState
,
"1"
);
updateWrapper
.
set
(
GoblinStoreCoupon:
:
getUpdatedAt
,
now
);
updateWrapper
.
set
(
GoblinStoreCoupon:
:
getUpdatedBy
,
"task"
);
if
(
this
.
update
(
updateWrapper
))
{
try
{
UpdateResult
updateResult
=
mongoTemplate
.
getCollection
(
GoblinStoreCouponBasicVo
.
class
.
getSimpleName
()).
updateMany
(
Query
.
query
(
Criteria
.
where
(
"delFlg"
).
is
(
"0"
).
and
(
"state"
).
is
(
"0"
).
and
(
"storeCouponId"
).
in
(
storeCouponIdList
)).
getQueryObject
(),
Update
.
update
(
"state"
,
"1"
).
set
(
"updatedAt"
,
now
).
set
(
"updatedBy"
,
"task"
).
getUpdateObject
()
);
if
(
updateResult
.
getModifiedCount
()
<=
0
)
{
log
.
warn
(
"###商铺活动:优惠券处理失败:[now={},storeCouponIdList={}]"
,
now
,
JsonUtils
.
toJson
(
storeCouponIdList
));
}
else
{
storeCouponList
.
forEach
(
storeCoupon
->
{
GoblinStoreMarketDto
storeMarketDto
=
GoblinStoreMarketDto
.
getNew
();
storeMarketDto
.
setId
(
storeCoupon
.
getStoreCouponId
());
storeMarketDto
.
setType
(
1
);
goblinRedisUtils
.
addStoreMarketDto
(
storeCoupon
.
getStoreId
(),
storeMarketDto
);
goblinRedisUtils
.
del
(
GoblinRedisConst
.
STORE_COUPON
.
concat
(
storeCoupon
.
getStoreCouponId
()));
});
return
storeCouponList
.
size
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"###商铺活动:优惠券处理异常[now={},storeCouponList={}]"
,
now
,
JsonUtils
.
toJson
(
storeCouponIdList
));
}
}
}
return
0
;
}
public
int
activityStopProcessing
(
LocalDateTime
now
)
{
LambdaQueryWrapper
<
GoblinStoreCoupon
>
queryWrapper
=
Wrappers
.
lambdaQuery
(
GoblinStoreCoupon
.
class
);
queryWrapper
.
eq
(
GoblinStoreCoupon:
:
getDelFlg
,
"0"
);
queryWrapper
.
eq
(
GoblinStoreCoupon:
:
getState
,
"1"
);
queryWrapper
.
le
(
GoblinStoreCoupon:
:
getEndTime
,
now
);
List
<
GoblinStoreCoupon
>
storeCouponList
=
this
.
list
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
storeCouponList
))
{
List
<
String
>
storeCouponIdList
=
storeCouponList
.
stream
().
map
(
GoblinStoreCoupon:
:
getStoreCouponId
).
collect
(
Collectors
.
toList
());
LambdaUpdateWrapper
<
GoblinStoreCoupon
>
updateWrapper
=
Wrappers
.
lambdaUpdate
(
GoblinStoreCoupon
.
class
);
updateWrapper
.
eq
(
GoblinStoreCoupon:
:
getDelFlg
,
"0"
);
updateWrapper
.
eq
(
GoblinStoreCoupon:
:
getState
,
"1"
);
updateWrapper
.
in
(
GoblinStoreCoupon:
:
getStoreCouponId
,
storeCouponIdList
);
updateWrapper
.
set
(
GoblinStoreCoupon:
:
getState
,
"2"
);
updateWrapper
.
set
(
GoblinStoreCoupon:
:
getUpdatedAt
,
now
);
updateWrapper
.
set
(
GoblinStoreCoupon:
:
getUpdatedBy
,
"task"
);
if
(
this
.
update
(
updateWrapper
))
{
try
{
UpdateResult
updateResult
=
mongoTemplate
.
getCollection
(
GoblinStoreCouponBasicVo
.
class
.
getSimpleName
()).
updateMany
(
Query
.
query
(
Criteria
.
where
(
"delFlg"
).
is
(
"0"
).
and
(
"state"
).
is
(
"1"
).
and
(
"storeCouponId"
).
in
(
storeCouponIdList
)).
getQueryObject
(),
Update
.
update
(
"state"
,
"2"
).
set
(
"updatedAt"
,
now
).
set
(
"updatedBy"
,
"task"
).
getUpdateObject
()
);
if
(
updateResult
.
getModifiedCount
()
<=
0
)
{
log
.
warn
(
"###商铺活动:优惠券处理失败:[now={},storeCouponIdList={}]"
,
now
,
JsonUtils
.
toJson
(
storeCouponIdList
));
}
else
{
storeCouponList
.
forEach
(
storeCoupon
->
{
GoblinStoreMarketDto
storeMarketDto
=
GoblinStoreMarketDto
.
getNew
();
storeMarketDto
.
setId
(
storeCoupon
.
getStoreCouponId
());
storeMarketDto
.
setType
(
1
);
goblinRedisUtils
.
delStoreMarketDto
(
storeCoupon
.
getStoreId
(),
storeMarketDto
);
goblinRedisUtils
.
del
(
GoblinRedisConst
.
STORE_COUPON
.
concat
(
storeCoupon
.
getStoreCouponId
()));
});
return
storeCouponList
.
size
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"###商铺活动:优惠券处理异常[now={},storeCouponList={}]"
,
now
,
JsonUtils
.
toJson
(
storeCouponIdList
));
}
}
}
return
0
;
}
}
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/utils/GoblinRedisUtils.java
View file @
561c2c8a
package
com
.
liquidnet
.
service
.
platform
.
utils
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.liquidnet.common.cache.redis.util.AbstractRedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisDataSourceUtil
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.dto.GoblinStoreMarketDto
;
import
com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
...
...
@@ -21,6 +26,10 @@ public class GoblinRedisUtils {
return
redisDataSourceUtil
.
getRedisGoblinUtil
();
}
public
void
del
(
String
...
keys
)
{
getRedis
().
del
(
keys
);
}
// 获取 订单相关vo
public
GoblinStoreOrderVo
getGoblinOrder
(
String
orderId
)
{
String
redisKey
=
GoblinRedisConst
.
REDIS_GOBLIN_ORDER
.
concat
(
orderId
);
...
...
@@ -111,4 +120,42 @@ public class GoblinRedisUtils {
String
redisKey
=
GoblinRedisConst
.
REDIS_GOBLIN_ORDER_SKU
.
concat
(
orderSkuId
);
getRedis
().
set
(
redisKey
,
vo
);
}
/* ---------------------------------------- 商铺活动 ---------------------------------------- */
public
List
<
GoblinStoreMarketDto
>
getStoreMarketDtos
(
String
storeId
)
{
String
rk
=
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
storeId
);
String
valStr
=
(
String
)
getRedis
().
get
(
rk
);
List
<
GoblinStoreMarketDto
>
dtos
=
null
;
if
(
StringUtils
.
isEmpty
(
valStr
))
{
// TODO: 2022/2/17 zhanggb mongodb 查取该商品所有参与的活动并整理集合
// dtos = ObjectUtil.getGoblinGoodsMarketDtoArrayList();
}
else
{
dtos
=
JsonUtils
.
fromJson
(
valStr
,
new
TypeReference
<
List
<
GoblinStoreMarketDto
>>()
{
});
}
return
dtos
;
}
public
boolean
addStoreMarketDto
(
String
storeId
,
GoblinStoreMarketDto
dto
)
{
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
storeId
);
dtos
.
add
(
dto
);
return
getRedis
().
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
storeId
),
JsonUtils
.
toJson
(
dtos
));
}
public
void
delStoreMarketDto
(
String
storeId
,
GoblinStoreMarketDto
dto
)
{
String
rk
=
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
storeId
);
List
<
GoblinStoreMarketDto
>
dtos
=
this
.
getStoreMarketDtos
(
storeId
);
if
(!
CollectionUtils
.
isEmpty
(
dtos
))
{
int
beforeSize
=
dtos
.
size
();
dtos
.
removeIf
(
r
->
r
.
getId
().
equals
(
dto
.
getId
())
&&
r
.
getType
().
equals
(
dto
.
getType
()));
if
(
beforeSize
>
dtos
.
size
())
{
getRedis
().
set
(
GoblinRedisConst
.
STORE_MARKETS
.
concat
(
storeId
),
JsonUtils
.
toJson
(
dtos
));
}
}
}
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
}
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