Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
9af953e0
Commit
9af953e0
authored
Jul 16, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加新人有礼
parent
18e00fd8
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
434 additions
and
4 deletions
+434
-4
ActivityRule.java
.../java/com/xxfc/platform/activity/entity/ActivityRule.java
+94
-0
ActivityUserJoin.java
...a/com/xxfc/platform/activity/entity/ActivityUserJoin.java
+66
-0
ActivityFeign.java
.../java/com/xxfc/platform/activity/feign/ActivityFeign.java
+4
-0
ActivityRuleBiz.java
.../java/com/xxfc/platform/activity/biz/ActivityRuleBiz.java
+34
-0
ActivityUserJoinBiz.java
...a/com/xxfc/platform/activity/biz/ActivityUserJoinBiz.java
+90
-0
UserCouponBiz.java
...in/java/com/xxfc/platform/activity/biz/UserCouponBiz.java
+34
-4
ActivityRuleMapper.java
...com/xxfc/platform/activity/mapper/ActivityRuleMapper.java
+15
-0
ActivityUserJoinMapper.java
...xxfc/platform/activity/mapper/ActivityUserJoinMapper.java
+15
-0
ActivityUserJoinController.java
...fc/platform/activity/rest/ActivityUserJoinController.java
+26
-0
CouponController.java
...ava/com/xxfc/platform/activity/rest/CouponController.java
+2
-0
UserCouponController.java
...com/xxfc/platform/activity/rest/UserCouponController.java
+18
-0
ActivityRuleMapper.xml
...y-server/src/main/resources/mapper/ActivityRuleMapper.xml
+20
-0
ActivityUserJoinMapper.xml
...rver/src/main/resources/mapper/ActivityUserJoinMapper.xml
+16
-0
No files found.
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/ActivityRule.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
entity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 通用活动规则表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-16 14:04:22
*/
@Data
@Table
(
name
=
"activity_rule"
)
public
class
ActivityRule
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键id
*/
@Id
@GeneratedValue
(
generator
=
"JDBC"
)
@ApiModelProperty
(
"主键id"
)
private
Integer
id
;
/**
* 活动名称
*/
@Column
(
name
=
"name"
)
@ApiModelProperty
(
value
=
"活动名称"
)
private
String
name
;
/**
* 活动描述
*/
@Column
(
name
=
"descr"
)
@ApiModelProperty
(
value
=
"活动描述"
)
private
String
descr
;
/**
* 活动人数限制
*/
@Column
(
name
=
"number"
)
@ApiModelProperty
(
value
=
"活动人数限制"
)
private
Integer
number
;
/**
* 参加活动人数
*/
@Column
(
name
=
"join_number"
)
@ApiModelProperty
(
value
=
"参加活动人数"
)
private
Integer
joinNumber
;
/**
* 活动是否开启:0-未开启;1-已开启;2-已关闭
*/
@Column
(
name
=
"status"
)
@ApiModelProperty
(
value
=
"活动是否开启:0-未开启;1-已开启;2-已关闭"
)
private
Integer
status
;
/**
* 活动奖励规则,json数组格式 [{"type":1, "detail":{...}},...] //// type分类 1--现金;
*/
@Column
(
name
=
"value"
)
@ApiModelProperty
(
value
=
"活动奖励规则,json数组格式 [{type:1, detail:{...}},...] //// type分类 1--现金;"
)
private
String
value
;
/**
* 创建时间
*/
@Column
(
name
=
"crt_time"
)
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
private
Long
crtTime
;
/**
* 更新时间
*/
@Column
(
name
=
"upd_time"
)
@ApiModelProperty
(
value
=
"更新时间"
,
hidden
=
true
)
private
Long
updTime
;
/**
* 是否删除:0-正常;1-删除
*/
@Column
(
name
=
"is_del"
)
@ApiModelProperty
(
value
=
"是否删除:0-正常;1-删除"
)
private
Integer
isDel
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/ActivityUserJoin.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
entity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 用户活动参与表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-16 14:04:22
*/
@Data
@Table
(
name
=
"activity_user_join"
)
public
class
ActivityUserJoin
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键id
*/
@Id
@GeneratedValue
(
generator
=
"JDBC"
)
@ApiModelProperty
(
"主键id"
)
private
Integer
id
;
/**
* 用户id
*/
@Column
(
name
=
"user_id"
)
@ApiModelProperty
(
value
=
"用户id"
)
private
Integer
userId
;
/**
* 活动规则id
*/
@Column
(
name
=
"activity_id"
)
@ApiModelProperty
(
value
=
"活动规则id"
)
private
Integer
activityId
;
/**
* 状态:0-已参与;1-已领取
*/
@Column
(
name
=
"status"
)
@ApiModelProperty
(
value
=
"状态:0-已参与;1-已领取"
)
private
Integer
status
;
/**
* 参与时间
*/
@Column
(
name
=
"crt_time"
)
@ApiModelProperty
(
value
=
"参与时间"
,
hidden
=
true
)
private
Long
crtTime
;
/**
* 领取时间
*/
@Column
(
name
=
"upd_time"
)
@ApiModelProperty
(
value
=
"领取时间"
,
hidden
=
true
)
private
Long
updTime
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/feign/ActivityFeign.java
View file @
9af953e0
...
...
@@ -36,4 +36,8 @@ public interface ActivityFeign {
@RequestMapping
(
value
=
"/user/cancelUse"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
cancelUse
(
@RequestParam
(
value
=
"TickerNo"
,
defaultValue
=
""
)
String
TickerNo
);
@ApiOperation
(
"新人有礼参加活动"
)
@RequestMapping
(
value
=
"/user"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
user
(
@RequestParam
(
value
=
"userId"
,
defaultValue
=
"0"
)
Integer
userId
);
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/ActivityRuleBiz.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
org.springframework.stereotype.Service
;
import
com.xxfc.platform.activity.entity.ActivityRule
;
import
com.xxfc.platform.activity.mapper.ActivityRuleMapper
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.List
;
/**
* 通用活动规则表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-16 14:04:22
*/
@Service
public
class
ActivityRuleBiz
extends
BaseBiz
<
ActivityRuleMapper
,
ActivityRule
>
{
//获取最新的生效的活动
public
ActivityRule
getActity
(){
Example
example
=
new
Example
(
ActivityRule
.
class
);
example
.
createCriteria
().
andEqualTo
(
"status"
,
1
).
andEqualTo
(
"isDel"
,
0
);
example
.
orderBy
(
"id desc"
);
List
<
ActivityRule
>
list
=
mapper
.
selectByExample
(
example
);
if
(
list
.
size
()>
0
){
return
list
.
get
(
0
);
}
return
null
;
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/ActivityUserJoinBiz.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xxfc.platform.activity.entity.ActivityRule
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.xxfc.platform.activity.entity.ActivityUserJoin
;
import
com.xxfc.platform.activity.mapper.ActivityUserJoinMapper
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
/**
* 用户活动参与表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-16 14:04:22
*/
@Service
@Slf4j
public
class
ActivityUserJoinBiz
extends
BaseBiz
<
ActivityUserJoinMapper
,
ActivityUserJoin
>
{
@Autowired
ActivityRuleBiz
ruleBiz
;
@Autowired
UserCouponBiz
userCouponBiz
;
//注册参与活动
public
void
joinActivity
(
Integer
userId
){
ActivityRule
rule
=
ruleBiz
.
getActity
();
if
(
rule
==
null
){
log
.
error
(
"----没有开启的活动----"
);
return
;
}
Integer
joinNumber
=
rule
.
getJoinNumber
()==
null
?
0
:
rule
.
getJoinNumber
();
Integer
number
=
rule
.
getNumber
()==
null
?
0
:
rule
.
getNumber
();
if
(
joinNumber
>=
number
){
log
.
error
(
"----活动已超过参与人数----number==="
+
number
);
return
;
}
Integer
activityId
=
rule
.
getId
();
ActivityUserJoin
userJoin
=
new
ActivityUserJoin
();
userJoin
.
setActivityId
(
activityId
);
userJoin
.
setUserId
(
userId
);
Long
num
=
selectCount
(
userJoin
);
if
(
num
!=
null
||
num
>
0
){
log
.
error
(
"----用户已经参与活动----userId===="
+
userId
);
return
;
}
insertSelective
(
userJoin
);
}
//领取优惠卷
public
void
receiveCoupn
(
Integer
userId
)
{
ActivityRule
rule
=
ruleBiz
.
getActity
();
if
(
rule
==
null
)
{
log
.
error
(
"----没有开启的活动----"
);
return
;
}
Integer
activityId
=
rule
.
getId
();
ActivityUserJoin
userJoin
=
new
ActivityUserJoin
();
userJoin
.
setActivityId
(
activityId
);
userJoin
.
setUserId
(
userId
);
Long
num
=
selectCount
(
userJoin
);
if
(
num
==
null
||
num
==
0
)
{
log
.
error
(
"----用户没有此参与活动----userId===="
+
userId
);
return
;
}
String
value
=
rule
.
getValue
();
JSONObject
json
=
JSONObject
.
parseObject
(
value
);
if
(
json
!=
null
){
Integer
type
=
json
.
getInteger
(
"type"
);
if
(
type
==
1
){
JSONArray
array
=
json
.
getJSONArray
(
"value"
);
if
(
array
.
size
()>
0
){
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++){
Integer
id
=
array
.
getJSONObject
(
i
).
getInteger
(
"id"
);
userCouponBiz
.
userLedCoupon
(
userId
,
id
);
}
}
}
}
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/UserCouponBiz.java
View file @
9af953e0
...
...
@@ -48,14 +48,33 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return
null
;
}
Integer
couponId
=
coupon
.
getId
();
Example
example
=
new
Example
(
UserCoupon
.
class
);
example
.
createCriteria
().
andEqualTo
(
"userId"
,
userId
).
andEqualTo
(
"couponId"
,
couponId
);
List
<
UserCoupon
>
list
=
selectByExample
(
example
);
if
(
list
.
size
()>
0
){
boolean
falg
=
checkUserLed
(
userId
,
couponId
);
if
(
falg
){
log
.
error
(
userId
+
"----已领优惠卷"
);
return
null
;
}
return
led
(
coupon
,
userId
);
}
//用户领劵
public
String
userLedCoupon
(
Integer
userId
,
Integer
couponId
){
Coupon
coupon
=
couponBiz
.
selectById
(
couponId
);
if
(
coupon
==
null
||
coupon
.
getIsDel
()!=
0
||
coupon
.
getStatus
()!=
1
){
log
.
error
(
userId
+
"----无可领取优惠卷"
);
return
null
;
}
boolean
falg
=
checkUserLed
(
userId
,
couponId
);
if
(
falg
){
log
.
error
(
userId
+
"----已领优惠卷"
);
return
null
;
}
return
led
(
coupon
,
userId
);
}
//领取动作
public
String
led
(
Coupon
coupon
,
Integer
userId
){
int
type
=
coupon
.
getValidType
();
Integer
couponId
=
coupon
.
getId
();
Long
expireTime
=
System
.
currentTimeMillis
();
Long
startTime
=
0L
;
if
(
type
==
1
){
...
...
@@ -74,7 +93,18 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
userCoupon
.
setExpireTime
(
expireTime
);
insertSelective
(
userCoupon
);
return
ticker_no
;
}
//检查用户是否领卷
public
boolean
checkUserLed
(
Integer
userId
,
Integer
id
){
Example
example
=
new
Example
(
UserCoupon
.
class
);
example
.
createCriteria
().
andEqualTo
(
"userId"
,
userId
).
andEqualTo
(
"couponId"
,
id
);
List
<
UserCoupon
>
list
=
selectByExample
(
example
);
if
(
list
.
size
()>
0
){
log
.
error
(
userId
+
"----已领优惠卷"
);
return
true
;
}
return
false
;
}
//获取我的优惠卷
...
...
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/ActivityRuleMapper.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.ActivityRule
;
import
tk.mybatis.mapper.common.Mapper
;
/**
* 通用活动规则表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-16 14:04:22
*/
public
interface
ActivityRuleMapper
extends
Mapper
<
ActivityRule
>
{
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/ActivityUserJoinMapper.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.ActivityUserJoin
;
import
tk.mybatis.mapper.common.Mapper
;
/**
* 用户活动参与表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-16 14:04:22
*/
public
interface
ActivityUserJoinMapper
extends
Mapper
<
ActivityUserJoin
>
{
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/ActivityUserJoinController.java
0 → 100644
View file @
9af953e0
package
com
.
xxfc
.
platform
.
activity
.
rest
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.xxfc.platform.activity.biz.ActivityUserJoinBiz
;
import
com.xxfc.platform.activity.entity.ActivityUserJoin
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"join"
)
public
class
ActivityUserJoinController
extends
BaseController
<
ActivityUserJoinBiz
,
ActivityUserJoin
>
{
@ApiOperation
(
"新人有礼参加活动"
)
@RequestMapping
(
value
=
"/user"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
user
(
@RequestParam
(
value
=
"userId"
,
defaultValue
=
"0"
)
Integer
userId
){
baseBiz
.
joinActivity
(
userId
);
return
ObjectRestResponse
.
succ
();
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/CouponController.java
View file @
9af953e0
...
...
@@ -10,4 +10,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"coupon"
)
public
class
CouponController
extends
BaseController
<
CouponBiz
,
Coupon
>
{
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/UserCouponController.java
View file @
9af953e0
...
...
@@ -3,9 +3,11 @@ package com.xxfc.platform.activity.rest;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.activity.biz.ActivityUserJoinBiz
;
import
com.xxfc.platform.activity.biz.UserCouponBiz
;
import
com.xxfc.platform.activity.vo.UserCouponVo
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
...
...
@@ -13,6 +15,10 @@ import org.springframework.web.bind.annotation.*;
public
class
UserCouponController
extends
ActivityBaseController
<
UserCouponBiz
>
{
@Autowired
ActivityUserJoinBiz
joinBiz
;
@ApiOperation
(
"用户自动领取新人卷"
)
@RequestMapping
(
value
=
"/auth/led"
,
method
=
RequestMethod
.
POST
)
public
String
led
(
@RequestParam
(
value
=
"userId"
,
defaultValue
=
"0"
)
Integer
userId
)
{
...
...
@@ -56,6 +62,18 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
return
ObjectRestResponse
.
succ
();
}
@ApiOperation
(
"领取优惠卷"
)
@RequestMapping
(
value
=
"/coupon/led"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
led
()
{
AppUserDTO
userInfo
=
getUserInfo
();
Integer
userId
=
userInfo
.
getId
();
if
(
userId
==
null
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
joinBiz
.
receiveCoupn
(
userId
);
return
ObjectRestResponse
.
succ
();
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/ActivityRuleMapper.xml
0 → 100644
View file @
9af953e0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxfc.platform.activity.mapper.ActivityRuleMapper"
>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.xxfc.platform.activity.entity.ActivityRule"
id=
"activityRuleMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"descr"
column=
"descr"
/>
<result
property=
"number"
column=
"number"
/>
<result
property=
"joinNumber"
column=
"join_number"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"value"
column=
"value"
/>
<result
property=
"crtTime"
column=
"crt_time"
/>
<result
property=
"updTime"
column=
"upd_time"
/>
<result
property=
"isDel"
column=
"is_del"
/>
</resultMap>
</mapper>
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/ActivityUserJoinMapper.xml
0 → 100644
View file @
9af953e0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxfc.platform.activity.mapper.ActivityUserJoinMapper"
>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.xxfc.platform.activity.entity.ActivityUserJoin"
id=
"activityUserJoinMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"userId"
column=
"user_id"
/>
<result
property=
"activityId"
column=
"activity_id"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"crtTime"
column=
"crt_time"
/>
<result
property=
"updTime"
column=
"upd_time"
/>
</resultMap>
</mapper>
\ 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