Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
point-project
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
point-project
Commits
34a806ff
Commit
34a806ff
authored
Oct 15, 2025
by
“Kongxiangkun”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加积分商城相关代码
parent
e0477a3a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
55 deletions
+105
-55
cloud-point-api/src/main/java/com/yizhi/point/application/feign/PointRedisFeignClients.java
+8
-1
cloud-point/src/main/java/com/yizhi/application/constant/PointTypeEnum.java
+5
-0
cloud-point/src/main/java/com/yizhi/application/controller/PointRedisController.java
+22
-21
cloud-point/src/main/java/com/yizhi/application/domain/PointTypeStrategy.java
+27
-0
cloud-point/src/main/java/com/yizhi/application/service/PointService.java
+2
-0
cloud-point/src/main/java/com/yizhi/application/service/impl/PointServiceImpl.java
+36
-29
cloud-point/src/main/java/com/yizhi/application/service/impl/PointUserServiceImpl.java
+5
-4
No files found.
cloud-point-api/src/main/java/com/yizhi/point/application/feign/PointRedisFeignClients.java
View file @
34a806ff
...
@@ -2,13 +2,20 @@ package com.yizhi.point.application.feign;
...
@@ -2,13 +2,20 @@ package com.yizhi.point.application.feign;
import
com.yizhi.point.application.vo.PointParamVO
;
import
com.yizhi.point.application.vo.PointParamVO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
@FeignClient
(
name
=
"point"
,
contextId
=
"PointRedisFeignClients"
)
@FeignClient
(
name
=
"point"
,
contextId
=
"PointRedisFeignClients"
)
public
interface
PointRedisFeignClients
{
public
interface
PointRedisFeignClients
{
@PostMapping
(
"/point/redis/add"
)
@PostMapping
(
"/point/redis/add"
)
String
addPointRedis
(
@RequestBody
PointParamVO
vo
);
String
addPointRedis
(
@RequestBody
PointParamVO
vo
);
@GetMapping
(
"/point/add"
)
public
void
pointAdd
(
@RequestParam
(
name
=
"type"
,
required
=
false
)
String
type
,
@RequestParam
(
name
=
"accountId"
,
required
=
false
)
Long
accountId
,
@RequestParam
(
name
=
"sourceId"
,
required
=
false
)
String
sourceId
);
}
}
cloud-point/src/main/java/com/yizhi/application/constant/PointTypeEnum.java
View file @
34a806ff
...
@@ -31,6 +31,11 @@ public enum PointTypeEnum {
...
@@ -31,6 +31,11 @@ public enum PointTypeEnum {
* 培训测试
* 培训测试
*/
*/
EXAM
(
"point_exam"
,
"培训测试"
,
0
),
EXAM
(
"point_exam"
,
"培训测试"
,
0
),
/**
* 积分兑换
*/
EXCHANGE
(
"point_exchange"
,
"积分兑换"
,
0
),
;
;
private
String
key
;
private
String
key
;
...
...
cloud-point/src/main/java/com/yizhi/application/controller/PointRedisController.java
View file @
34a806ff
...
@@ -5,12 +5,11 @@ import com.yizhi.application.domain.MqPointParam;
...
@@ -5,12 +5,11 @@ import com.yizhi.application.domain.MqPointParam;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.application.redis.RedisUtils
;
import
com.yizhi.application.redis.RedisUtils
;
import
com.yizhi.application.service.MqPointParamService
;
import
com.yizhi.application.service.MqPointParamService
;
import
com.yizhi.application.service.PointService
;
import
com.yizhi.point.application.vo.PointParamVO
;
import
com.yizhi.point.application.vo.PointParamVO
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
...
@@ -22,30 +21,32 @@ public class PointRedisController {
...
@@ -22,30 +21,32 @@ public class PointRedisController {
private
IdGenerator
idGenerator
;
private
IdGenerator
idGenerator
;
@Autowired
@Autowired
private
MqPointParamService
mqPointParamService
;
private
MqPointParamService
mqPointParamService
;
@Autowired
PointService
pointService
;
@PostMapping
(
"/point/redis/add"
)
@PostMapping
(
"/point/redis/add"
)
public
String
addPointRedis
(
@RequestBody
PointParamVO
vo
)
{
public
String
addPointRedis
(
@RequestBody
PointParamVO
vo
)
{
String
key
=
idGenerator
.
generate
().
toString
();
// String key = idGenerator.generate().toString();
vo
.
setId
(
key
);
// vo.setId(key);
boolean
boo
=
redisUtils
.
set
(
key
,
vo
,
10800L
);
// boolean boo = redisUtils.set(key, vo, 10800L);
if
(
boo
){
// if(boo){
MqPointParam
mqPointParam
=
new
MqPointParam
();
// MqPointParam mqPointParam = new MqPointParam();
BeanUtils
.
copyProperties
(
vo
,
mqPointParam
);
// BeanUtils.copyProperties(vo, mqPointParam);
mqPointParam
.
setState
(
1
);
// mqPointParam.setState(1);
mqPointParamService
.
insert
(
mqPointParam
);
// mqPointParamService.insert(mqPointParam);
return
key
;
// return key;
}
// }
return
null
;
// return null;
return
""
;
}
}
@PostMapping
(
"/point/add"
)
@GetMapping
(
"/point/add"
)
public
String
pointAdd
(
String
type
)
{
public
void
pointAdd
(
@RequestParam
(
name
=
"type"
,
required
=
false
)
String
type
,
@RequestParam
(
name
=
"accountId"
,
required
=
false
)
Long
accountId
,
@RequestParam
(
name
=
"sourceId"
,
required
=
false
)
String
sourceId
)
{
pointService
.
addPoint
(
accountId
,
type
,
sourceId
);
return
null
;
}
}
}
}
cloud-point/src/main/java/com/yizhi/application/domain/PointTypeStrategy.java
0 → 100644
View file @
34a806ff
package
com
.
yizhi
.
application
.
domain
;
import
com.baomidou.mybatisplus.activerecord.Model
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.yizhi.application.constant.PointTypeEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
PointTypeStrategy
{
private
static
final
long
serialVersionUID
=
1L
;
private
PointTypeEnum
pointTypeEnum
;
private
String
learnSource
;
}
cloud-point/src/main/java/com/yizhi/application/service/PointService.java
View file @
34a806ff
...
@@ -15,4 +15,6 @@ public interface PointService extends IService<Point> {
...
@@ -15,4 +15,6 @@ public interface PointService extends IService<Point> {
Point
pointList
(
Long
companyId
,
Long
siteId
);
Point
pointList
(
Long
companyId
,
Long
siteId
);
boolean
updateList
(
Point
point
);
boolean
updateList
(
Point
point
);
void
addPoint
(
Long
accountId
,
String
type
,
String
sourceId
);
}
}
cloud-point/src/main/java/com/yizhi/application/service/impl/PointServiceImpl.java
View file @
34a806ff
package
com
.
yizhi
.
application
.
service
.
impl
;
package
com
.
yizhi
.
application
.
service
.
impl
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.application.constant.PointTypeEnum
;
import
com.yizhi.application.constant.PointTypeEnum
;
import
com.yizhi.application.domain.Point
;
import
com.yizhi.application.domain.PointDetails
;
import
com.yizhi.application.domain.PointDetails
;
import
com.yizhi.application.domain.PointTypeStrategy
;
import
com.yizhi.application.domain.PointUser
;
import
com.yizhi.application.domain.PointUser
;
import
com.yizhi.application.mapper.Point
User
Mapper
;
import
com.yizhi.application.mapper.PointMapper
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.application.service.PointDetailsService
;
import
com.yizhi.application.service.PointDetailsService
;
import
com.yizhi.application.service.PointService
;
import
com.yizhi.application.service.PointUserService
;
import
com.yizhi.application.service.PointUserService
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.util.application.date.DateUtil
;
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
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
java.util.Date
;
import
com.yizhi.application.domain.Point
;
import
com.yizhi.application.mapper.PointMapper
;
import
com.yizhi.application.service.PointService
;
/**
/**
* <p>
* <p>
...
@@ -79,14 +76,14 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
...
@@ -79,14 +76,14 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
}
}
public
void
addPoint
(
Long
accountId
,
String
type
,
Lo
ng
sourceId
){
public
void
addPoint
(
Long
accountId
,
String
type
,
Stri
ng
sourceId
){
Long
companyId
=
ContextHolder
.
get
().
getCompanyId
();
Long
companyId
=
ContextHolder
.
get
().
getCompanyId
();
Long
orgId
=
ContextHolder
.
get
().
getOrgId
();
Long
orgId
=
ContextHolder
.
get
().
getOrgId
();
Long
siteId
=
ContextHolder
.
get
().
getSiteId
();
Long
siteId
=
ContextHolder
.
get
().
getSiteId
();
String
accountName
=
ContextHolder
.
get
().
getAccountName
();
String
accountName
=
ContextHolder
.
get
().
getAccountName
();
//执行积分奖励策略进行相应的业务校验
//执行积分奖励策略进行相应的业务校验
int
point
=
getPointByType
(
type
);
PointTypeStrategy
strategy
=
getPointByType
(
type
,
accountId
);
if
(
point
>
0
)
{
if
(
strategy
!=
null
)
{
PointUser
pu
=
new
PointUser
();
PointUser
pu
=
new
PointUser
();
pu
.
setUserId
(
accountId
);
pu
.
setUserId
(
accountId
);
EntityWrapper
<
PointUser
>
wrapper
=
new
EntityWrapper
<
PointUser
>(
pu
);
EntityWrapper
<
PointUser
>
wrapper
=
new
EntityWrapper
<
PointUser
>(
pu
);
...
@@ -96,13 +93,13 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
...
@@ -96,13 +93,13 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
pu
=
new
PointUser
();
pu
=
new
PointUser
();
pu
.
setId
(
id
);
pu
.
setId
(
id
);
pu
.
setUserId
(
accountId
);
pu
.
setUserId
(
accountId
);
pu
.
setTotalPoint
(
point
);
pu
.
setTotalPoint
(
strategy
.
getPointTypeEnum
().
getPoint
()
);
pu
.
setState
(
1
);
pu
.
setState
(
1
);
pu
.
setCreateById
(
accountId
);
pu
.
setCreateById
(
accountId
);
pu
.
setCreateByName
(
accountName
);
pu
.
setCreateByName
(
accountName
);
pu
.
setCreateTime
(
new
Date
());
pu
.
setCreateTime
(
new
Date
());
}
else
{
}
else
{
pu
.
setTotalPoint
(
pu
.
getTotalPoint
()
+
point
);
pu
.
setTotalPoint
(
pu
.
getTotalPoint
()
+
strategy
.
getPointTypeEnum
().
getPoint
()
);
pu
.
setUpdateById
(
accountId
);
pu
.
setUpdateById
(
accountId
);
pu
.
setUpdateByName
(
accountName
);
pu
.
setUpdateByName
(
accountName
);
pu
.
setUpdateTime
(
new
Date
());
pu
.
setUpdateTime
(
new
Date
());
...
@@ -116,14 +113,13 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
...
@@ -116,14 +113,13 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
pd
.
setId
(
idGenerator
.
generate
());
pd
.
setId
(
idGenerator
.
generate
());
pd
.
setTime
(
new
Date
());
pd
.
setTime
(
new
Date
());
pd
.
setChangeBefore
(
pointUser
.
getTotalPoint
());
pd
.
setChangeBefore
(
pointUser
.
getTotalPoint
());
pd
.
setPoint
(
point
);
pd
.
setPoint
(
strategy
.
getPointTypeEnum
().
getPoint
()
);
pd
.
setChangeAfter
(
pointUser
.
getTotalPoint
()
+
point
);
pd
.
setChangeAfter
(
pointUser
.
getTotalPoint
()
+
strategy
.
getPointTypeEnum
().
getPoint
()
);
pd
.
setMultiple
(
1
);
pd
.
setMultiple
(
1
);
pd
.
setAccountId
(
accountId
);
pd
.
setAccountId
(
accountId
);
pd
.
setLearnName
(
"积分兑换"
);
pd
.
setLearnName
(
strategy
.
getPointTypeEnum
().
getDesc
());
pd
.
setLearnSource
(
"积分兑换"
);
pd
.
setLearnSource
(
strategy
.
getLearnSource
());
pd
.
setLearnSourceId
(
sourceId
);
pd
.
setLearnType
(
strategy
.
getPointTypeEnum
().
getKey
());
pd
.
setLearnType
(
"积分兑换"
);
pd
.
setState
(
1
);
pd
.
setState
(
1
);
pd
.
setCreateById
(
accountId
);
pd
.
setCreateById
(
accountId
);
pd
.
setCreateByName
(
accountName
);
pd
.
setCreateByName
(
accountName
);
...
@@ -136,25 +132,36 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
...
@@ -136,25 +132,36 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
}
}
}
}
public
int
getPointByType
(
String
type
){
public
PointTypeStrategy
getPointByType
(
String
type
,
Long
accountId
){
PointTypeStrategy
strategy
=
null
;
if
(
type
.
equals
(
PointTypeEnum
.
LOGIN
.
getKey
())){
if
(
type
.
equals
(
PointTypeEnum
.
LOGIN
.
getKey
())){
return
PointTypeEnum
.
LOGIN
.
getPoint
();
//查询当天是否首次登录,奖励积分
String
date
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd"
);
PointDetails
pd
=
new
PointDetails
();
pd
.
setAccountId
(
accountId
);
pd
.
setLearnType
(
PointTypeEnum
.
LOGIN
.
getKey
());
pd
.
setLearnSource
(
date
);
EntityWrapper
<
PointDetails
>
wrapper
=
new
EntityWrapper
<
PointDetails
>(
pd
);
int
cnt
=
pointDetailsService
.
selectCount
(
wrapper
);
if
(
cnt
<=
0
)
{
return
new
PointTypeStrategy
(
PointTypeEnum
.
LOGIN
,
date
);
}
}
}
if
(
type
.
equals
(
PointTypeEnum
.
READ
.
getKey
())){
if
(
type
.
equals
(
PointTypeEnum
.
READ
.
getKey
())){
return
PointTypeEnum
.
READ
.
getPoint
()
;
return
null
;
}
}
if
(
type
.
equals
(
PointTypeEnum
.
PUBLICATION
.
getKey
())){
if
(
type
.
equals
(
PointTypeEnum
.
PUBLICATION
.
getKey
())){
return
PointTypeEnum
.
PUBLICATION
.
getPoint
()
;
return
null
;
}
}
if
(
type
.
equals
(
PointTypeEnum
.
COMMENT
.
getKey
())){
if
(
type
.
equals
(
PointTypeEnum
.
COMMENT
.
getKey
())){
return
PointTypeEnum
.
COMMENT
.
getPoint
()
;
return
null
;
}
}
if
(
type
.
equals
(
PointTypeEnum
.
ACITVITY
.
getKey
())){
if
(
type
.
equals
(
PointTypeEnum
.
ACITVITY
.
getKey
())){
return
PointTypeEnum
.
ACITVITY
.
getPoint
()
;
return
null
;
}
}
if
(
type
.
equals
(
PointTypeEnum
.
EXAM
.
getKey
())){
if
(
type
.
equals
(
PointTypeEnum
.
EXAM
.
getKey
())){
return
PointTypeEnum
.
EXAM
.
getPoint
()
;
return
null
;
}
}
return
0
;
return
null
;
}
}
}
}
cloud-point/src/main/java/com/yizhi/application/service/impl/PointUserServiceImpl.java
View file @
34a806ff
...
@@ -3,6 +3,7 @@ package com.yizhi.application.service.impl;
...
@@ -3,6 +3,7 @@ package com.yizhi.application.service.impl;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.application.constant.PointTypeEnum
;
import
com.yizhi.application.domain.PointDetails
;
import
com.yizhi.application.domain.PointDetails
;
import
com.yizhi.application.domain.PointUser
;
import
com.yizhi.application.domain.PointUser
;
import
com.yizhi.application.mapper.PointUserMapper
;
import
com.yizhi.application.mapper.PointUserMapper
;
...
@@ -278,15 +279,15 @@ public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser
...
@@ -278,15 +279,15 @@ public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser
PointDetails
pd
=
new
PointDetails
();
PointDetails
pd
=
new
PointDetails
();
pd
.
setId
(
idGenerator
.
generate
());
pd
.
setId
(
idGenerator
.
generate
());
pd
.
setTime
(
new
Date
());
pd
.
setTime
(
new
Date
());
pd
.
setChangeBefore
(
pointUser
ExchangeVO
.
get
Point
());
pd
.
setChangeBefore
(
pointUser
.
getTotal
Point
());
pd
.
setPoint
(
pointUserExchangeVO
.
getPoint
());
pd
.
setPoint
(
pointUserExchangeVO
.
getPoint
());
pd
.
setChangeAfter
(
pointUser
.
getTotalPoint
()
-
pointUserExchangeVO
.
getPoint
());
pd
.
setChangeAfter
(
pointUser
.
getTotalPoint
()
-
pointUserExchangeVO
.
getPoint
());
pd
.
setMultiple
(
1
);
pd
.
setMultiple
(
1
);
pd
.
setAccountId
(
accountId
);
pd
.
setAccountId
(
accountId
);
pd
.
setLearnName
(
"积分兑换"
);
pd
.
setLearnName
(
PointTypeEnum
.
EXCHANGE
.
getDesc
()
);
pd
.
setLearnSource
(
"积分兑换"
);
pd
.
setLearnSource
(
PointTypeEnum
.
EXCHANGE
.
getDesc
()
);
pd
.
setLearnSourceId
(
0L
);
pd
.
setLearnSourceId
(
0L
);
pd
.
setLearnType
(
"积分兑换"
);
pd
.
setLearnType
(
PointTypeEnum
.
EXCHANGE
.
getKey
()
);
pd
.
setState
(
1
);
pd
.
setState
(
1
);
pd
.
setCreateById
(
accountId
);
pd
.
setCreateById
(
accountId
);
pd
.
setCreateByName
(
accountName
);
pd
.
setCreateByName
(
accountName
);
...
...
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