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
c79c9281
Commit
c79c9281
authored
Jul 24, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券
parent
7cf9d0ac
Changes
19
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
876 additions
and
117 deletions
+876
-117
UserFeign.java
...va/com/github/wxiaoqi/security/admin/feign/UserFeign.java
+6
-1
AppUserController.java
...github/wxiaoqi/security/admin/rest/AppUserController.java
+10
-1
CouponDTO.java
...c/main/java/com/xxfc/platform/activity/dto/CouponDTO.java
+106
-0
CouponFindDTO.java
...in/java/com/xxfc/platform/activity/dto/CouponFindDTO.java
+4
-0
UserCouponDTO.java
...in/java/com/xxfc/platform/activity/dto/UserCouponDTO.java
+39
-0
UserCouponFindDTO.java
...ava/com/xxfc/platform/activity/dto/UserCouponFindDTO.java
+26
-0
UserCouponSendDTO.java
...ava/com/xxfc/platform/activity/dto/UserCouponSendDTO.java
+19
-0
CouponPagVo.java
.../main/java/com/xxfc/platform/activity/vo/CouponPagVo.java
+43
-0
CouponTitleVo.java
...ain/java/com/xxfc/platform/activity/vo/CouponTitleVo.java
+15
-0
CouponVo.java
...src/main/java/com/xxfc/platform/activity/vo/CouponVo.java
+106
-0
UserCouponPageVo.java
.../java/com/xxfc/platform/activity/vo/UserCouponPageVo.java
+41
-0
CouponBiz.java
...c/main/java/com/xxfc/platform/activity/biz/CouponBiz.java
+91
-0
UserCouponBiz.java
...in/java/com/xxfc/platform/activity/biz/UserCouponBiz.java
+186
-98
CouponMapper.java
.../java/com/xxfc/platform/activity/mapper/CouponMapper.java
+5
-1
UserCouponMapper.java
...a/com/xxfc/platform/activity/mapper/UserCouponMapper.java
+6
-2
CouponAdminController.java
...c/platform/activity/rest/admin/CouponAdminController.java
+47
-6
UserCouponAdminController.java
...atform/activity/rest/admin/UserCouponAdminController.java
+85
-0
CouponMapper.xml
...ctivity-server/src/main/resources/mapper/CouponMapper.xml
+3
-0
UserCouponMapper.xml
...ity-server/src/main/resources/mapper/UserCouponMapper.xml
+38
-8
No files found.
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/feign/UserFeign.java
View file @
c79c9281
...
...
@@ -117,6 +117,11 @@ public interface UserFeign {
@GetMapping
(
"/api/app/imi/{imiId}"
)
public
ImiVo
findUserInfoByImiId
(
@PathVariable
(
value
=
"imiId"
)
Integer
imiId
);
ImiVo
findUserInfoByImiId
(
@PathVariable
(
value
=
"imiId"
)
Integer
imiId
);
@GetMapping
(
"/app/user/findusersByIds"
)
Map
<
Integer
,
AppUserLogin
>
findAppUsersByUserIds
(
@RequestParam
(
value
=
"userIds"
)
List
<
Integer
>
userIds
);
@GetMapping
(
"/app/user/finduserIdsByphones"
)
Map
<
String
,
Integer
>
findAppusersByUserNames
(
@RequestParam
(
value
=
"phones"
)
List
<
String
>
phones
);
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/AppUserController.java
View file @
c79c9281
...
...
@@ -18,6 +18,8 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.ws.rs.GET
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -170,6 +172,13 @@ public class AppUserController extends CommonBaseController {
return
appUserLoginBiz
.
getUserByUsername
(
username
);
}
@GetMapping
(
"/findusersByIds"
)
public
Map
<
Integer
,
AppUserLogin
>
findAppUsersByUserIds
(
@RequestParam
(
value
=
"userIds"
)
List
<
Integer
>
userIds
){
return
appUserLoginBiz
.
findUserIdAndUserLoginMapByMemberIds
(
userIds
);
}
@GetMapping
(
"/finduserIdsByphones"
)
Map
<
String
,
Integer
>
findAppusersByUserNames
(
@RequestParam
(
value
=
"phones"
)
List
<
String
>
phones
){
return
appUserLoginBiz
.
findPhoneAndUserIdMapByPhones
(
phones
);
}
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/dto/CouponDTO.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 15:00
*/
@Data
public
class
CouponDTO
{
@ApiModelProperty
(
"主键id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元"
)
private
String
title
;
@ApiModelProperty
(
value
=
"副标题"
)
private
String
subtitle
;
@ApiModelProperty
(
value
=
"图片"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"可用于:10店铺优惠券 11新人店铺券 20商品优惠券 30类目优惠券 60平台优惠券 61新人平台券"
)
private
Integer
used
;
@ApiModelProperty
(
value
=
"0-全平台;1-租车;2-旅游;3-营地"
)
private
Integer
channel
;
@ApiModelProperty
(
value
=
"0-普通用户;1-会员用户"
)
private
Integer
userType
;
@ApiModelProperty
(
value
=
"1满减券 2叠加满减券 3无门槛券(需要限制大小)"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"1可用于特价商品 2不能 默认不能(商品优惠卷除外)"
)
private
Integer
withSpecial
;
@ApiModelProperty
(
value
=
"店铺或商品流水号"
)
private
String
withSn
;
@ApiModelProperty
(
value
=
"满多少金额"
)
private
BigDecimal
withAmount
;
@ApiModelProperty
(
value
=
"用券抵扣金额"
)
private
BigDecimal
usedAmount
;
@ApiModelProperty
(
value
=
"配额:发券数量"
)
private
Integer
quota
;
@ApiModelProperty
(
value
=
"每人限领次数"
)
private
Integer
limitCollar
;
@ApiModelProperty
(
value
=
"已领取的优惠券数量"
)
private
Integer
takeCount
;
@ApiModelProperty
(
value
=
"已使用的优惠券数量"
)
private
Integer
usedCount
;
@ApiModelProperty
(
value
=
"发放开始时间"
)
private
Long
startTime
;
@ApiModelProperty
(
value
=
"发放结束时间"
)
private
Long
endTime
;
@ApiModelProperty
(
value
=
"时效:1绝对时效(领取后XXX-XXX时间段有效) 2相对时效(领取后N天有效)"
)
private
Integer
validType
;
@ApiModelProperty
(
value
=
"使用开始时间"
)
private
Long
validStartTime
;
@ApiModelProperty
(
value
=
"使用结束时间"
)
private
Long
validEndTime
;
@ApiModelProperty
(
value
=
"自领取之日起有效天数"
)
private
Integer
validDays
;
@ApiModelProperty
(
value
=
"跳转链接"
)
private
String
url
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/dto/CouponFindDTO.java
View file @
c79c9281
...
...
@@ -14,5 +14,9 @@ public class CouponFindDTO extends PageParam {
private
String
title
;
private
Integer
channel
;
private
Integer
type
;
private
Integer
status
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/dto/UserCouponDTO.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 17:06
*/
@Data
public
class
UserCouponDTO
{
private
Integer
id
;
@ApiModelProperty
(
value
=
"用户id"
)
private
Integer
userId
;
@ApiModelProperty
(
value
=
"标题"
)
private
String
title
;
@ApiModelProperty
(
value
=
"抵扣金额"
)
private
BigDecimal
usedAmount
;
@ApiModelProperty
(
value
=
"0-未使用;1-已使用"
)
private
Integer
isUse
;
@ApiModelProperty
(
value
=
"领卷时间"
,
hidden
=
true
)
private
Long
crtTime
;
@ApiModelProperty
(
value
=
"到期时间"
,
hidden
=
true
)
private
Long
expireTime
;
@ApiModelProperty
(
value
=
"使用时间"
)
private
Long
useTime
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/dto/UserCouponFindDTO.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
dto
;
import
com.github.wxiaoqi.security.common.vo.PageParam
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 16:26
*/
@Data
public
class
UserCouponFindDTO
extends
PageParam
{
private
String
phone
;
private
String
title
;
private
BigDecimal
usedAmount
;
private
Integer
status
;
private
Integer
userId
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/dto/UserCouponSendDTO.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
dto
;
import
lombok.Data
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 18:02
*/
@Data
public
class
UserCouponSendDTO
{
private
String
phone
;
private
Integer
couponId
;
private
Integer
couponNum
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/vo/CouponPagVo.java
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
...
...
@@ -11,4 +14,44 @@ import lombok.Data;
@Data
public
class
CouponPagVo
{
@ApiModelProperty
(
"主键id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元"
)
private
String
title
;
@ApiModelProperty
(
value
=
"图片"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"0-全平台;1-租车;2-旅游;3-营地"
)
private
Integer
channel
;
@ApiModelProperty
(
value
=
"1满减券 2叠加满减券 3无门槛券(需要限制大小)"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"用券抵扣金额"
)
private
BigDecimal
usedAmount
;
@ApiModelProperty
(
value
=
"配额:发券数量"
)
private
Integer
quota
;
@ApiModelProperty
(
value
=
"已领取的优惠券数量"
)
private
Integer
takeCount
;
@ApiModelProperty
(
value
=
"已使用的优惠券数量"
)
private
Integer
usedCount
;
@ApiModelProperty
(
value
=
"1生效 2失效 3已结束"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
private
Long
crtTime
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/vo/CouponTitleVo.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
vo
;
import
lombok.Data
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 18:11
*/
@Data
public
class
CouponTitleVo
{
private
Integer
id
;
private
String
title
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/vo/CouponVo.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 15:00
*/
@Data
public
class
CouponVo
{
@ApiModelProperty
(
"主键id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元"
)
private
String
title
;
@ApiModelProperty
(
value
=
"副标题"
)
private
String
subtitle
;
@ApiModelProperty
(
value
=
"图片"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"可用于:10店铺优惠券 11新人店铺券 20商品优惠券 30类目优惠券 60平台优惠券 61新人平台券"
)
private
Integer
used
;
@ApiModelProperty
(
value
=
"0-全平台;1-租车;2-旅游;3-营地"
)
private
Integer
channel
;
@ApiModelProperty
(
value
=
"0-普通用户;1-会员用户"
)
private
Integer
userType
;
@ApiModelProperty
(
value
=
"1满减券 2叠加满减券 3无门槛券(需要限制大小)"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"1可用于特价商品 2不能 默认不能(商品优惠卷除外)"
)
private
Integer
withSpecial
;
@ApiModelProperty
(
value
=
"店铺或商品流水号"
)
private
String
withSn
;
@ApiModelProperty
(
value
=
"满多少金额"
)
private
BigDecimal
withAmount
;
@ApiModelProperty
(
value
=
"用券抵扣金额"
)
private
BigDecimal
usedAmount
;
@ApiModelProperty
(
value
=
"配额:发券数量"
)
private
Integer
quota
;
@ApiModelProperty
(
value
=
"每人限领次数"
)
private
Integer
limitCollar
;
@ApiModelProperty
(
value
=
"已领取的优惠券数量"
)
private
Integer
takeCount
;
@ApiModelProperty
(
value
=
"已使用的优惠券数量"
)
private
Integer
usedCount
;
@ApiModelProperty
(
value
=
"发放开始时间"
)
private
Long
startTime
;
@ApiModelProperty
(
value
=
"发放结束时间"
)
private
Long
endTime
;
@ApiModelProperty
(
value
=
"时效:1绝对时效(领取后XXX-XXX时间段有效) 2相对时效(领取后N天有效)"
)
private
Integer
validType
;
@ApiModelProperty
(
value
=
"使用开始时间"
)
private
Long
validStartTime
;
@ApiModelProperty
(
value
=
"使用结束时间"
)
private
Long
validEndTime
;
@ApiModelProperty
(
value
=
"自领取之日起有效天数"
)
private
Integer
validDays
;
@ApiModelProperty
(
value
=
"跳转链接"
)
private
String
url
;
}
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/vo/UserCouponPageVo.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 16:29
*/
@Data
public
class
UserCouponPageVo
{
private
Integer
id
;
@ApiModelProperty
(
value
=
"手机号"
)
private
String
phone
;
@ApiModelProperty
(
value
=
"标题"
)
private
String
title
;
@ApiModelProperty
(
value
=
"抵扣金额"
)
private
BigDecimal
usedAmount
;
@ApiModelProperty
(
value
=
"0-未使用;1-已使用"
)
private
Integer
isUse
;
@ApiModelProperty
(
value
=
"领卷时间"
,
hidden
=
true
)
private
Long
crtTime
;
@ApiModelProperty
(
value
=
"到期时间"
,
hidden
=
true
)
private
Long
expireTime
;
@ApiModelProperty
(
value
=
"使用时间"
)
private
Long
useTime
;
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/CouponBiz.java
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.activity.constant.CouponUsed
;
import
com.xxfc.platform.activity.dto.CouponDTO
;
import
com.xxfc.platform.activity.dto.CouponFindDTO
;
import
com.xxfc.platform.activity.entity.Coupon
;
import
com.xxfc.platform.activity.vo.CouponPagVo
;
import
com.xxfc.platform.activity.vo.CouponTitleVo
;
import
com.xxfc.platform.activity.vo.CouponVo
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
com.xxfc.platform.activity.mapper.CouponMapper
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
tk.mybatis.mapper.entity.Example
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* 优惠券表
...
...
@@ -31,4 +44,82 @@ public class CouponBiz extends BaseBiz<CouponMapper, Coupon> {
}
return
null
;
}
public
PageDataVO
<
CouponPagVo
>
listCouponWithPage
(
CouponFindDTO
couponFindDTO
)
{
PageDataVO
<
CouponPagVo
>
couponPagVo
=
new
PageDataVO
<>();
Example
example
=
new
Example
(
Coupon
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
couponFindDTO
.
getTitle
())){
criteria
.
andLike
(
"title"
,
couponFindDTO
.
getTitle
());
}
if
(
Objects
.
nonNull
(
couponFindDTO
.
getChannel
())){
criteria
.
andEqualTo
(
"channel"
,
couponFindDTO
.
getChannel
());
}
if
(
Objects
.
nonNull
(
couponFindDTO
.
getType
())){
criteria
.
andEqualTo
(
"type"
,
couponFindDTO
.
getType
());
}
if
(
Objects
.
nonNull
(
couponFindDTO
.
getStatus
())){
criteria
.
andEqualTo
(
"status"
,
couponFindDTO
.
getStatus
());
}
criteria
.
andEqualTo
(
"isDel"
,
0
);
example
.
setOrderByClause
(
"crt_time DESC"
);
PageDataVO
<
Coupon
>
couponPage
=
PageDataVO
.
pageInfo
(
couponFindDTO
.
getPage
(),
couponFindDTO
.
getLimit
(),
()
->
mapper
.
selectByExample
(
example
));
List
<
Coupon
>
data
=
couponPage
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
data
)){
return
couponPagVo
;
}
List
<
CouponPagVo
>
couponPagVos
=
new
ArrayList
<>();
CouponPagVo
coupon
;
for
(
Coupon
coup
:
data
)
{
coupon
=
new
CouponPagVo
();
BeanUtils
.
copyProperties
(
coupon
,
coup
);
couponPagVos
.
add
(
coupon
);
}
couponPagVo
.
setPageNum
(
couponPage
.
getPageNum
());
couponPagVo
.
setPageSize
(
couponPage
.
getTotalPage
());
couponPagVo
.
setTotalPage
(
couponPage
.
getTotalPage
());
couponPagVo
.
setTotalCount
(
couponPage
.
getTotalCount
());
couponPagVo
.
setData
(
couponPagVos
);
return
couponPagVo
;
}
public
CouponVo
findCouponById
(
Integer
id
)
{
CouponVo
couponVo
=
new
CouponVo
();
Coupon
coupon
=
mapper
.
selectByPrimaryKey
(
id
);
BeanUtils
.
copyProperties
(
coupon
,
couponVo
);
return
couponVo
;
}
public
int
addCoupon
(
CouponDTO
couponDTO
,
UserDTO
userDTO
)
{
Coupon
coupon
=
new
Coupon
();
BeanUtils
.
copyProperties
(
couponDTO
,
coupon
);
if
(
Objects
.
nonNull
(
couponDTO
.
getId
())){
coupon
.
setUpdTime
(
Instant
.
now
().
toEpochMilli
());
coupon
.
setUpdUser
(
userDTO
.
getId
());
coupon
.
setUpdName
(
userDTO
.
getUsername
());
return
mapper
.
updateByPrimaryKeySelective
(
coupon
);
}
else
{
coupon
.
setCrtTime
(
Instant
.
now
().
toEpochMilli
());
coupon
.
setCrtUser
(
userDTO
.
getId
());
coupon
.
setCrtName
(
userDTO
.
getUsername
());
return
mapper
.
insertSelective
(
coupon
);
}
}
public
int
updateCouponDelStateById
(
Integer
id
,
UserDTO
userDTO
)
{
Coupon
coupon
=
new
Coupon
();
coupon
.
setId
(
id
);
coupon
.
setUpdName
(
userDTO
.
getUsername
());
coupon
.
setUpdUser
(
userDTO
.
getId
());
coupon
.
setUpdTime
(
Instant
.
now
().
toEpochMilli
());
coupon
.
setIsDel
(
1
);
return
mapper
.
updateByPrimaryKeySelective
(
coupon
);
}
public
List
<
CouponTitleVo
>
getCouponTitleList
()
{
return
mapper
.
selectTitles
();
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/UserCouponBiz.java
View file @
c79c9281
This diff is collapsed.
Click to expand it.
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/CouponMapper.java
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.Coupon
;
import
com.xxfc.platform.activity.vo.CouponTitleVo
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
/**
* 优惠券表
*
...
...
@@ -12,4 +15,5 @@ import tk.mybatis.mapper.common.Mapper;
*/
public
interface
CouponMapper
extends
Mapper
<
Coupon
>
{
List
<
CouponTitleVo
>
selectTitles
();
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/UserCouponMapper.java
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.dto.UserCouponDTO
;
import
com.xxfc.platform.activity.dto.UserCouponFindDTO
;
import
com.xxfc.platform.activity.entity.UserCoupon
;
import
com.xxfc.platform.activity.vo.UserCouponVo
;
import
org.apache.ibatis.annotations.Param
;
import
tk.mybatis.mapper.additional.insert.InsertListMapper
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
...
...
@@ -14,7 +17,7 @@ import java.util.List;
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
public
interface
UserCouponMapper
extends
Mapper
<
UserCoupon
>
{
public
interface
UserCouponMapper
extends
Mapper
<
UserCoupon
>
,
InsertListMapper
<
UserCoupon
>
{
//我的优惠卷
public
List
<
UserCouponVo
>
getUserCouponsByType
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"type"
)
int
type
,
@Param
(
"time"
)
Long
time
,
@Param
(
"channel"
)
Integer
channel
);
...
...
@@ -22,4 +25,5 @@ public interface UserCouponMapper extends Mapper<UserCoupon> {
//单个优惠卷
public
UserCouponVo
getUserCoupon
(
@Param
(
"tickerNo"
)
String
tickerNo
);
List
<
UserCouponDTO
>
findUserCoupons
(
UserCouponFindDTO
userCouponFindDTO
);
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/admin/CouponAdminController.java
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
rest
.
admin
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.activity.biz.CouponBiz
;
import
com.xxfc.platform.activity.dto.CouponDTO
;
import
com.xxfc.platform.activity.dto.CouponFindDTO
;
import
com.xxfc.platform.activity.vo.CouponPagVo
;
import
com.xxfc.platform.activity.vo.CouponTitleVo
;
import
com.xxfc.platform.activity.vo.CouponVo
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.
GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.
*
;
import
java.util.List
;
/**
* @author libin
...
...
@@ -21,10 +28,44 @@ public class CouponAdminController {
@Autowired
private
CouponBiz
couponBiz
;
@ApiOperation
(
"优惠券列表"
)
@GetMapping
(
"/page"
)
public
ObjectRestResponse
listCouponWithPage
(
CouponFindDTO
couponFindDTO
){
public
ObjectRestResponse
<
PageDataVO
<
CouponPagVo
>>
listCouponWithPage
(
CouponFindDTO
couponFindDTO
)
{
PageDataVO
<
CouponPagVo
>
couponPage
=
couponBiz
.
listCouponWithPage
(
couponFindDTO
);
return
ObjectRestResponse
.
succ
(
couponPage
);
}
@ApiOperation
(
"查询优惠券详情"
)
@GetMapping
(
"/{id}"
)
public
ObjectRestResponse
<
CouponVo
>
findCouponById
(
@PathVariable
(
value
=
"id"
)
Integer
id
){
CouponVo
couponVo
=
couponBiz
.
findCouponById
(
id
);
return
ObjectRestResponse
.
succ
(
couponVo
);
}
@ApiOperation
(
"获取优惠劵标题列表"
)
@GetMapping
(
"/titles"
)
public
ObjectRestResponse
<
List
<
CouponTitleVo
>>
getCouponTitleList
(){
List
<
CouponTitleVo
>
titles
=
couponBiz
.
getCouponTitleList
();
return
ObjectRestResponse
.
succ
(
titles
);
}
@ApiOperation
(
"优惠劵新增 或 编辑"
)
@PostMapping
public
ObjectRestResponse
<
Void
>
addCoupon
(
@RequestBody
CouponDTO
couponDTO
,
UserDTO
userDTO
){
couponBiz
.
addCoupon
(
couponDTO
,
userDTO
);
return
ObjectRestResponse
.
succ
();
}
@ApiOperation
(
"优惠劵逻辑删除"
)
@DeleteMapping
(
"/{id}"
)
public
ObjectRestResponse
<
Void
>
deleteCouponById
(
@PathVariable
(
value
=
"id"
)
Integer
id
,
UserDTO
userDTO
){
couponBiz
.
updateCouponDelStateById
(
id
,
userDTO
);
return
ObjectRestResponse
.
succ
();
}
@ApiOperation
(
"检查优惠劵是否已经在使用阶段"
)
@GetMapping
(
"check/{id}"
)
public
Boolean
checkCouponHasUsedById
(
@PathVariable
(
value
=
"id"
)
Integer
id
){
return
true
;
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/admin/UserCouponAdminController.java
0 → 100644
View file @
c79c9281
package
com
.
xxfc
.
platform
.
activity
.
rest
.
admin
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.excel.ExcelImport
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.activity.ActivityApplication
;
import
com.xxfc.platform.activity.biz.UserCouponBiz
;
import
com.xxfc.platform.activity.dto.UserCouponFindDTO
;
import
com.xxfc.platform.activity.dto.UserCouponSendDTO
;
import
com.xxfc.platform.activity.vo.UserCouponPageVo
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/23 16:22
*/
@RestController
@RequestMapping
(
"/admin/user_coupon"
)
public
class
UserCouponAdminController
{
@Autowired
private
UserCouponBiz
userCouponBiz
;
@ApiOperation
(
"领劵列表"
)
@GetMapping
(
"/page"
)
public
ObjectRestResponse
<
PageDataVO
<
UserCouponPageVo
>>
listUserCouponWithPage
(
UserCouponFindDTO
userCouponFindDTO
)
{
PageDataVO
<
UserCouponPageVo
>
userCouponPage
=
userCouponBiz
.
listUserCouponWithPage
(
userCouponFindDTO
);
return
ObjectRestResponse
.
succ
(
userCouponPage
);
}
@PostMapping
(
"/sendcoupon"
)
public
ObjectRestResponse
<
Void
>
sendCoupon
(
UserCouponSendDTO
userCouponSendDTO
){
userCouponBiz
.
sendCoupon
(
userCouponSendDTO
);
return
ObjectRestResponse
.
succ
();
}
@PostMapping
(
"/import"
)
public
ObjectRestResponse
<
Void
>
importCouponBatch
(
@RequestParam
(
"couponId"
)
Integer
couponId
,
@RequestPart
(
name
=
"file"
)
MultipartFile
couponExcel
){
List
<
String
[]>
userCounponData
=
ExcelImport
.
getExcelData
(
couponExcel
);
if
(
userCounponData
.
size
()
<
1
)
{
return
ObjectRestResponse
.
createFailedResult
(
1001
,
"导入不能没数据!!!"
);
}
for
(
String
[]
userCounponDateNum
:
userCounponData
)
{
if
(
userCounponDateNum
.
length
!=
4
){
return
ObjectRestResponse
.
createFailedResult
(
1002
,
"数据不完整!!!"
);
}
}
userCounponData
.
remove
(
0
);
userCouponBiz
.
importUserCoupon
(
couponId
,
userCounponData
);
return
ObjectRestResponse
.
succ
();
}
@ApiOperation
(
"用户劵excel模板下载"
)
@GetMapping
(
"/excel_model/dowload"
)
public
ResponseEntity
<
byte
[]>
dowloadUserMemberExcelModel
(
HttpServletResponse
response
){
// 重置response
response
.
reset
();
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename=usermember.xlsx"
);
InputStream
inputStream
=
ActivityApplication
.
class
.
getClassLoader
().
getResourceAsStream
(
"file/usercoupon.xlsx"
);
try
{
byte
[]
bytes
=
IOUtils
.
toByteArray
(
inputStream
);
return
ResponseEntity
.
ok
(
bytes
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
null
);
}
}
xx-activity/xx-activity-server/src/main/resources/mapper/CouponMapper.xml
View file @
c79c9281
...
...
@@ -37,4 +37,7 @@
<result
property=
"isDel"
column=
"is_del"
/>
</resultMap>
<select
id=
"selectTitles"
resultType=
"string"
>
select `id`,`title` from `coupon` where `is_del`=0
</select>
</mapper>
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/UserCouponMapper.xml
View file @
c79c9281
...
...
@@ -72,4 +72,34 @@
u.is_del = 0 and u.ticker_no=#{tickerNo} limit 1
</select>
<select
id=
"findUserCoupons"
resultType=
"com.xxfc.platform.activity.dto.UserCouponDTO"
parameterType=
"com.xxfc.platform.activity.dto.UserCouponFindDTO"
>
SELECT
uc.id,
uc.user_id AS `userId`,
uc.is_use AS `isUse`,
cp.title,
cp.used_amount AS `usedAmount`,
uc.crt_time AS `crtTime`,
uc.expire_time AS `expireTime`,
uc.use_time AS `useTime`
FROM
( SELECT `id`, coupon_id, `user_id`, `is_use`, `crt_time`, `expire_time`, `use_time` FROM user_coupon WHERE
`is_del` = 0
<if
test=
"userId != null"
>
`user_id`=#{userId}
</if>
<if
test=
"status != null"
>
`is_use`=#{status}
</if>
) AS `uc`
INNER JOIN ( SELECT `id`, `title`, `used_amount` FROM `coupon` WHERE 1=1
<if
test=
"title != null and title != ''"
>
AND `title`=#{title}
</if>
<if
test=
"usedAmount != null"
>
AND `used_amount`=#{usedAmount}
</if>
) AS `cp` ON uc.coupon_id = cp.id;
</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