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
84f73675
Commit
84f73675
authored
Jun 22, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加优惠卷模块
parent
be341868
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
375 additions
and
13 deletions
+375
-13
ActivityFeign.java
.../java/com/xxfc/platform/activity/Feign/ActivityFeign.java
+12
-0
UserCoupon.java
...in/java/com/xxfc/platform/activity/entity/UserCoupon.java
+23
-2
UserCouponVo.java
...main/java/com/xxfc/platform/activity/vo/UserCouponVo.java
+148
-0
UserCouponBiz.java
...in/java/com/xxfc/platform/activity/biz/UserCouponBiz.java
+58
-0
UserCouponMapper.java
...a/com/xxfc/platform/activity/mapper/UserCouponMapper.java
+11
-1
ActivityBaseController.java
...m/xxfc/platform/activity/rest/ActivityBaseController.java
+34
-0
UserCouponController.java
...com/xxfc/platform/activity/rest/UserCouponController.java
+34
-7
UserCouponMapper.xml
...ity-server/src/main/resources/mapper/UserCouponMapper.xml
+55
-3
No files found.
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/Feign/ActivityFeign.java
View file @
84f73675
package
com
.
xxfc
.
platform
.
activity
.
Feign
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.activity.vo.UserCouponVo
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -20,4 +21,15 @@ public interface ActivityFeign {
@RequestMapping
(
value
=
"/user/auth/led"
,
method
=
RequestMethod
.
POST
)
public
String
led
(
@RequestParam
(
value
=
"userId"
)
Integer
userId
);
@ApiOperation
(
"单个优惠卷信息"
)
@RequestMapping
(
value
=
"/info/{no}"
,
method
=
RequestMethod
.
GET
)
public
UserCouponVo
info
(
@PathVariable
String
no
);
@ApiOperation
(
"优惠卷使用"
)
@RequestMapping
(
value
=
"/use"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
use
(
@RequestParam
(
value
=
"userId"
)
Integer
userId
,
@RequestParam
(
value
=
"TickerNo"
)
String
TickerNo
,
@RequestParam
(
value
=
"orderNo"
)
String
orderNo
);
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/UserCoupon.java
View file @
84f73675
...
...
@@ -72,19 +72,40 @@ public class UserCoupon implements Serializable {
@ApiModelProperty
(
value
=
"领卷时间"
,
hidden
=
true
)
private
Long
crtTime
;
/**
/**
* 更新时间
*/
@Column
(
name
=
"upd_time"
)
@ApiModelProperty
(
value
=
"更新时间"
,
hidden
=
true
)
private
Long
updTime
;
/**
* 开始时间
*/
@Column
(
name
=
"start_time"
)
@ApiModelProperty
(
value
=
"开始时间"
,
hidden
=
true
)
private
Long
startTime
;
/**
* 到期时间
*/
@Column
(
name
=
"expire_time"
)
@ApiModelProperty
(
value
=
"到期时间"
,
hidden
=
true
)
private
Long
expireTime
;
/**
/**
* 使用时间
*/
@Column
(
name
=
"use_time"
)
@ApiModelProperty
(
value
=
"使用时间"
)
private
Long
useTime
;
/**
* 是否删除;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/vo/UserCouponVo.java
0 → 100644
View file @
84f73675
package
com
.
xxfc
.
platform
.
activity
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* 我的优惠卷
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
@Data
public
class
UserCouponVo
{
/**
* 优惠卡券id
*/
@ApiModelProperty
(
value
=
"优惠卡券id"
)
private
Integer
couponId
;
/**
* 用户id
*/
@ApiModelProperty
(
value
=
"用户id"
)
private
Integer
userId
;
/**
* 券号
*/
@ApiModelProperty
(
value
=
"券号"
)
private
String
tickerNo
;
/**
* 0-未使用;1-已使用
*/
@ApiModelProperty
(
value
=
"0-未使用;1-已使用"
)
private
Integer
isUse
;
/**
* 使用订单号
*/
@ApiModelProperty
(
value
=
"使用订单号"
)
private
String
orderNo
;
/**
* 领卷时间
*/
@ApiModelProperty
(
value
=
"领卷时间"
,
hidden
=
true
)
private
Long
crtTime
;
/**
* 开始时间
*/
@ApiModelProperty
(
value
=
"开始时间"
,
hidden
=
true
)
private
Long
startTime
;
/**
* 到期时间
*/
@ApiModelProperty
(
value
=
"到期时间"
,
hidden
=
true
)
private
Long
expireTime
;
/**
* 使用时间
*/
@ApiModelProperty
(
value
=
"使用时间"
)
private
Long
useTime
;
/**
* 优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元
*/
@ApiModelProperty
(
value
=
"优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元"
)
private
String
title
;
/**
* 图片
*/
@ApiModelProperty
(
value
=
"图片"
)
private
String
icon
;
/**
* 可用于:10店铺优惠券 11新人店铺券 20商品优惠券 30类目优惠券 60平台优惠券 61新人平台券
*/
@ApiModelProperty
(
value
=
"可用于:10店铺优惠券 11新人店铺券 20商品优惠券 30类目优惠券 60平台优惠券 61新人平台券"
)
private
Integer
used
;
/**
* 0-全平台;1-租车;2-旅游;3-营地
*/
@ApiModelProperty
(
value
=
"0-全平台;1-租车;2-旅游;3-营地"
)
private
Integer
channel
;
/**
* 0-普通用户;1-会员用户
*/
@ApiModelProperty
(
value
=
"0-普通用户;1-会员用户"
)
private
Integer
userType
;
/**
* 1满减券 2叠加满减券 3无门槛券(需要限制大小)
*/
@ApiModelProperty
(
value
=
"1满减券 2叠加满减券 3无门槛券(需要限制大小)"
)
private
Integer
type
;
/**
* 1可用于特价商品 2不能 默认不能(商品优惠卷除外)
*/
@ApiModelProperty
(
value
=
"1可用于特价商品 2不能 默认不能(商品优惠卷除外)"
)
private
Integer
withSpecial
;
/**
* 店铺或商品流水号
*/
@ApiModelProperty
(
value
=
"店铺或商品流水号"
)
private
String
withSn
;
/**
* 满多少金额
*/
@ApiModelProperty
(
value
=
"满多少金额"
)
private
BigDecimal
withAmount
;
/**
* 用券抵扣金额
*/
@ApiModelProperty
(
value
=
"用券抵扣金额"
)
private
BigDecimal
usedAmount
;
/**
* 1生效 2失效 3已结束
*/
@ApiModelProperty
(
value
=
"1生效 2失效 3已结束"
)
private
Integer
status
;
/**
* 跳转链接
*/
@ApiModelProperty
(
value
=
"跳转链接"
)
private
String
url
;
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/UserCouponBiz.java
View file @
84f73675
...
...
@@ -7,8 +7,10 @@ import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import
com.xxfc.platform.activity.constant.CouponUsed
;
import
com.xxfc.platform.activity.entity.Coupon
;
import
com.xxfc.platform.activity.entity.UserCoupon
;
import
com.xxfc.platform.activity.vo.UserCouponVo
;
import
com.xxfc.platform.universal.weixin.util.Snowflake
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.xxfc.platform.activity.mapper.UserCouponMapper
;
...
...
@@ -32,6 +34,8 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
@Autowired
private
CouponBiz
couponBiz
;
private
static
final
Long
DAY
=
86400000L
;
//自动发送优惠卷
public
String
authledCoupon
(
Integer
userId
){
if
(
userId
==
null
||
userId
==
0
){
...
...
@@ -51,14 +55,68 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
log
.
error
(
userId
+
"----已领优惠卷"
);
return
null
;
}
int
type
=
coupon
.
getValidType
();
Long
expireTime
=
System
.
currentTimeMillis
();
Long
startTime
=
0L
;
if
(
type
==
1
){
startTime
=
coupon
.
getStartTime
();
expireTime
=
coupon
.
getValidEndTime
();
}
else
{
startTime
=
expireTime
;
expireTime
+=
DAY
*
coupon
.
getValidDays
();
}
String
ticker_no
=
Snowflake
.
build
()+
""
;
UserCoupon
userCoupon
=
new
UserCoupon
();
userCoupon
.
setUserId
(
userId
);
userCoupon
.
setCouponId
(
couponId
);
userCoupon
.
setTickerNo
(
ticker_no
);
userCoupon
.
setStartTime
(
startTime
);
userCoupon
.
setExpireTime
(
expireTime
);
insertSelective
(
userCoupon
);
return
ticker_no
;
}
//获取我的优惠卷
public
ObjectRestResponse
getCouponList
(
Integer
userId
,
int
type
){
if
(
userId
==
null
||
userId
==
0
){
log
.
error
(
"----参数不能为空"
);
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
NULL_CODE
,
"参数不能为空"
);
}
Long
time
=
System
.
currentTimeMillis
();
return
ObjectRestResponse
.
succ
(
mapper
.
getUserCouponsByType
(
userId
,
type
,
time
));
}
//获取单个优惠卷
public
UserCouponVo
getUserCoupon
(
String
tickerNo
){
if
(
StringUtils
.
isBlank
(
tickerNo
)){
log
.
error
(
"----参数不能为空"
);
return
null
;
}
return
mapper
.
getUserCoupon
(
tickerNo
);
}
//支付后更新优惠卷状态
public
void
useTickerNo
(
Integer
userId
,
String
TickerNo
,
String
orderNo
){
if
(
userId
==
null
||
userId
==
0
||
StringUtils
.
isBlank
(
TickerNo
)){
log
.
error
(
"----参数不能为空"
);
return
;
}
Example
example
=
new
Example
(
UserCoupon
.
class
);
example
.
createCriteria
().
andEqualTo
(
"TickerNo"
,
TickerNo
).
andEqualTo
(
"isDel"
,
0
);
List
<
UserCoupon
>
list
=
selectByExample
(
example
);
if
(
list
.
size
()==
0
){
log
.
error
(
userId
+
"----已领优惠卷"
);
return
;
}
UserCoupon
userCoupon
=
list
.
get
(
0
);
userCoupon
.
setIsUse
(
1
);
userCoupon
.
setOrderNo
(
orderNo
);
userCoupon
.
setUseTime
(
System
.
currentTimeMillis
());
updateSelectiveById
(
userCoupon
);
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/UserCouponMapper.java
View file @
84f73675
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.UserCoupon
;
import
com.xxfc.platform.activity.vo.UserCouponVo
;
import
org.apache.ibatis.annotations.Param
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
/**
* 我的优惠卷
*
...
...
@@ -11,5 +15,11 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2019-06-21 14:34:49
*/
public
interface
UserCouponMapper
extends
Mapper
<
UserCoupon
>
{
//我的优惠卷
public
List
<
UserCouponVo
>
getUserCouponsByType
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"type"
)
int
type
,
@Param
(
"time"
)
Long
time
);
//单个优惠卷
public
UserCouponVo
getUserCoupon
(
@Param
(
"tickerNo"
)
String
tickerNo
);
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/ActivityBaseController.java
0 → 100644
View file @
84f73675
package
com
.
xxfc
.
platform
.
activity
.
rest
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.auth.client.config.UserAuthConfig
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.rest.CommonBaseController
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
@Slf4j
public
class
ActivityBaseController
<
Biz
extends
BaseBiz
>
extends
CommonBaseController
{
@Autowired
protected
Biz
baseBiz
;
@Autowired
protected
UserFeign
userFeign
;
@Autowired
protected
UserAuthConfig
userAuthConfig
;
public
AppUserDTO
getUserInfo
(){
return
userFeign
.
userDetailByToken
(
userAuthConfig
.
getToken
(
request
)).
getData
();
}
public
Biz
getBaseBiz
()
{
return
baseBiz
;
}
public
UserDTO
userinfoByToken
(){
return
userFeign
.
userinfoByToken
(
userAuthConfig
.
getToken
(
request
)).
getData
();
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/UserCouponController.java
View file @
84f73675
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.
rest.BaseController
;
import
com.github.wxiaoqi.security.common.
util.process.ResultCode
;
import
com.xxfc.platform.activity.biz.UserCouponBiz
;
import
com.xxfc.platform.activity.
entity.UserCoupon
;
import
com.xxfc.platform.activity.
vo.UserCouponVo
;
import
io.swagger.annotations.ApiOperation
;
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
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"user"
)
public
class
UserCouponController
extends
BaseController
<
UserCouponBiz
,
UserCoupon
>
{
public
class
UserCouponController
extends
ActivityBaseController
<
UserCouponBiz
>
{
@ApiOperation
(
"用户自动领取新人卷"
)
...
...
@@ -21,4 +19,33 @@ public class UserCouponController extends BaseController<UserCouponBiz, UserCoup
return
baseBiz
.
authledCoupon
(
userId
);
}
@ApiOperation
(
"我的优惠卷"
)
@RequestMapping
(
value
=
"/list/{type}"
,
method
=
RequestMethod
.
GET
)
public
ObjectRestResponse
list
(
@PathVariable
Integer
type
)
{
AppUserDTO
userInfo
=
getUserInfo
();
Integer
userId
=
userInfo
.
getId
();
if
(
userId
==
null
){
return
ObjectRestResponse
.
createDefaultFail
();
}
return
baseBiz
.
getCouponList
(
userId
,
type
);
}
@ApiOperation
(
"单个优惠卷信息"
)
@RequestMapping
(
value
=
"/info/{no}"
,
method
=
RequestMethod
.
GET
)
public
UserCouponVo
info
(
@PathVariable
String
no
)
{
return
baseBiz
.
getUserCoupon
(
no
);
}
@ApiOperation
(
"优惠卷使用"
)
@RequestMapping
(
value
=
"/use"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
use
(
@RequestParam
(
value
=
"userId"
,
defaultValue
=
"0"
)
Integer
userId
,
@RequestParam
(
value
=
"TickerNo"
,
defaultValue
=
""
)
String
TickerNo
,
@RequestParam
(
value
=
"orderNo"
,
defaultValue
=
""
)
String
orderNo
)
{
baseBiz
.
useTickerNo
(
userId
,
TickerNo
,
orderNo
);
return
ObjectRestResponse
.
succ
();
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/UserCouponMapper.xml
View file @
84f73675
...
...
@@ -4,16 +4,68 @@
<mapper
namespace=
"com.xxfc.platform.activity.mapper.UserCouponMapper"
>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.xxfc.platform.activity.entity.UserCoupon"
id=
"userCouponMap"
>
<result
property=
"id"
column=
"id"
/>
<resultMap
type=
"com.xxfc.platform.activity.vo.UserCouponVo"
id=
"userCouponMap"
>
<result
property=
"couponId"
column=
"coupon_id"
/>
<result
property=
"userId"
column=
"user_id"
/>
<result
property=
"tickerNo"
column=
"ticker_no"
/>
<result
property=
"isUse"
column=
"is_use"
/>
<result
property=
"orderNo"
column=
"order_no"
/>
<result
property=
"crtTime"
column=
"crt_time"
/>
<result
property=
"updTime"
column=
"upd_time"
/>
<result
property=
"startTime"
column=
"start_time"
/>
<result
property=
"expireTime"
column=
"expire_time"
/>
<result
property=
"useTime"
column=
"use_time"
/>
<result
property=
"title"
column=
"title"
/>
<result
property=
"icon"
column=
"icon"
/>
<result
property=
"used"
column=
"used"
/>
<result
property=
"channel"
column=
"channel"
/>
<result
property=
"userType"
column=
"user_type"
/>
<result
property=
"type"
column=
"type"
/>
<result
property=
"withSpecial"
column=
"with_special"
/>
<result
property=
"withSn"
column=
"with_sn"
/>
<result
property=
"withAmount"
column=
"with_amount"
/>
<result
property=
"usedAmount"
column=
"used_amount"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"url"
column=
"url"
/>
</resultMap>
<select
id=
"getUserCouponsByType"
resultMap=
"userCouponMap"
>
SELECT
*
FROM
user_coupon u
LEFT JOIN coupon c ON u.coupon_id = c.id
WHERE
u.is_del = 0 and u.user_id=#{userId}
<if
test=
"type==0"
>
and u.is_use=0 and u.expire_time >=#{time}
</if>
<if
test=
"type==1"
>
and u.is_use=1
</if>
<if
test=
"type==2"
>
and u.is_use=0 and u.expire_time
<
#{time}
</if>
<choose>
<when
test=
"type==1"
>
ORDER BY u.use_time DESC
</when>
<otherwise>
ORDER BY c.used_amount DESC
</otherwise>
</choose>
</select>
<select
id=
"getUserCoupon"
resultMap=
"userCouponMap"
>
SELECT
*
FROM
user_coupon u
LEFT JOIN coupon c ON u.coupon_id = c.id
WHERE
u.is_del = 0 and u.ticker_no=#{tickerNo} limit 1
</select>
</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