Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
ufo-platform
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
mali
6 years ago
Commit
8bde2feda8129ccb7cf0df70dcda3a4ad7dbc4c1
1 parent
19034ea4
用户优惠券
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
237 additions
and
0 deletions
coupon/src/main/java/com/yoho/ufo/coupon/controller/CouponController.java
coupon/src/main/java/com/yoho/ufo/coupon/service/ICouponService.java
coupon/src/main/java/com/yoho/ufo/coupon/service/impl/CouponServiceImpl.java
dal/src/main/java/com/yoho/ufo/dal/CouponMapper.java
dal/src/main/java/com/yoho/ufo/model/coupon/resp/UidCouponQueryResp.java
dal/src/main/resources/META-INF/mybatis/CouponMapper.xml
web/src/main/webapp/html/coupon/userCoupon.html
coupon/src/main/java/com/yoho/ufo/coupon/controller/CouponController.java
View file @
8bde2fe
package
com
.
yoho
.
ufo
.
coupon
.
controller
;
import
com.google.common.collect.Lists
;
import
com.yoho.ufo.coupon.service.ICouponService
;
import
com.yoho.ufo.exception.PlatformException
;
import
com.yoho.ufo.service.impl.BatchService
;
...
...
@@ -118,4 +119,19 @@ public class CouponController {
}
}
/**
* 发放记录查询
* @param req
* @return
*/
@RequestMapping
(
value
=
"/queryUserCouponList"
)
public
com
.
yohobuy
.
ufo
.
model
.
common
.
ApiResponse
queryUserCouponList
(
UserCouponQueryReq
req
)
{
LOGGER
.
info
(
"enter queryCoupons,param is {}"
,
req
);
if
(
req
.
getUid
()
==
null
){
return
new
com
.
yohobuy
.
ufo
.
model
.
common
.
ApiResponse
<>(
Lists
.
newArrayList
());
}
return
new
com
.
yohobuy
.
ufo
.
model
.
common
.
ApiResponse
<>(
couponService
.
queryUserCouponList
(
req
));
}
}
...
...
coupon/src/main/java/com/yoho/ufo/coupon/service/ICouponService.java
View file @
8bde2fe
package
com
.
yoho
.
ufo
.
coupon
.
service
;
import
com.yoho.ufo.model.coupon.resp.UidCouponQueryResp
;
import
com.yoho.ufo.model.coupon.resp.UserCouponQueryResp
;
import
com.yoho.ufo.service.model.ApiResponse
;
import
com.yohobuy.ufo.coupon.req.CouponQueryReq
;
import
com.yohobuy.ufo.coupon.req.CouponSaveUpdateReq
;
import
com.yohobuy.ufo.coupon.req.CouponSendReq
;
import
com.yohobuy.ufo.coupon.req.UserCouponQueryReq
;
import
com.yohobuy.ufo.model.common.PageResponseBO
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.Set
;
...
...
@@ -24,4 +27,6 @@ public interface ICouponService {
ApiResponse
sendCoupon
(
CouponSendReq
req
);
ApiResponse
sendCouponByImport
(
MultipartFile
file
,
String
couponToken
)
throws
Exception
;
PageResponseBO
<
UidCouponQueryResp
>
queryUserCouponList
(
UserCouponQueryReq
req
);
}
...
...
coupon/src/main/java/com/yoho/ufo/coupon/service/impl/CouponServiceImpl.java
View file @
8bde2fe
...
...
@@ -17,6 +17,7 @@ import com.yoho.ufo.model.coupon.Coupon;
import
com.yoho.ufo.model.coupon.CouponProductLimit
;
import
com.yoho.ufo.model.coupon.UserCoupon
;
import
com.yoho.ufo.model.coupon.resp.CouponQueryResp
;
import
com.yoho.ufo.model.coupon.resp.UidCouponQueryResp
;
import
com.yoho.ufo.model.coupon.resp.UserCouponQueryResp
;
import
com.yoho.ufo.service.IBusinessExportService
;
import
com.yoho.ufo.service.impl.BatchService
;
...
...
@@ -26,6 +27,7 @@ import com.yohobuy.ufo.coupon.req.CouponQueryReq;
import
com.yohobuy.ufo.coupon.req.CouponSaveUpdateReq
;
import
com.yohobuy.ufo.coupon.req.CouponSendReq
;
import
com.yohobuy.ufo.coupon.req.UserCouponQueryReq
;
import
com.yohobuy.ufo.model.common.PageResponseBO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.math.NumberUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -280,6 +282,52 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{
return
sendCouponByMQ
(
couponToken
,
uidList
);
}
public
PageResponseBO
<
UidCouponQueryResp
>
queryUserCouponList
(
UserCouponQueryReq
req
)
{
LOGGER
.
info
(
"enter queryUserCouponList, req is {}"
,
req
);
int
total
=
userCouponMapper
.
selectTotalByCondition
(
req
);
if
(
0
==
total
){
new
PageResponseBO
<>(
total
,
Lists
.
newArrayList
(),
req
.
getRows
(),
req
.
getPage
());;
}
List
<
UserCoupon
>
userCoupons
=
userCouponMapper
.
selectByCondition
(
req
);
List
<
UidCouponQueryResp
>
result
=
complateCouponInfo
(
userCoupons
);
return
new
PageResponseBO
<>(
total
,
result
,
req
.
getRows
(),
req
.
getPage
());
}
private
List
<
UidCouponQueryResp
>
complateCouponInfo
(
List
<
UserCoupon
>
userCoupons
)
{
if
(
CollectionUtils
.
isEmpty
(
userCoupons
))
{
return
Lists
.
newArrayList
();
}
List
<
Integer
>
couponLists
=
userCoupons
.
stream
().
map
(
UserCoupon:
:
getCouponId
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
couponLists
))
{
return
Lists
.
newArrayList
();
}
List
<
Coupon
>
coupons
=
couponMapper
.
selectByIds
(
couponLists
);
Map
<
Integer
,
Coupon
>
couponMap
=
coupons
.
stream
().
collect
(
Collectors
.
toMap
(
Coupon:
:
getId
,
item
->
item
,
(
a
,
b
)
->
a
));
List
<
UidCouponQueryResp
>
result
=
new
ArrayList
<>();
for
(
UserCoupon
userCoupon
:
userCoupons
){
Coupon
coupon
=
couponMap
.
get
(
userCoupon
.
getCouponId
());
result
.
add
(
UidCouponQueryResp
.
builder
().
couponAmount
(
null
!=
coupon
?
coupon
.
getCouponAmount
()
:
null
)
.
couponName
(
null
!=
coupon
?
coupon
.
getCouponName
()
:
null
)
.
couponId
(
userCoupon
.
getCouponId
())
.
couponCode
(
userCoupon
.
getCouponCode
())
.
createTime
(
com
.
yoho
.
ufo
.
util
.
DateUtil
.
int2DateStr
(
userCoupon
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
))
.
status
(
UserCoupon
.
UserCouponStatusEnum
.
getKey
(
userCoupon
.
getStatus
()))
.
statusValue
(
userCoupon
.
getStatus
())
.
uid
(
userCoupon
.
getUid
())
.
useTime
(
null
==
userCoupon
.
getUseTime
()
||
0
==
userCoupon
.
getUseTime
()
?
null
:
com
.
yoho
.
ufo
.
util
.
DateUtil
.
int2DateStr
(
userCoupon
.
getUseTime
(),
"yyyy-MM-dd HH:mm:ss"
))
.
build
());
}
return
result
;
}
private
ApiResponse
sendCouponByMQ
(
String
couponToken
,
List
<
Integer
>
uidList
){
UserHelper
operator
=
new
UserHelper
();
LOGGER
.
info
(
"sendCoupon with couponToken is {}, uidList is {}, operateUserId is {}, operateUserName is {}"
,
couponToken
,
uidList
,
operator
.
getUserId
(),
operator
.
getUserName
());
...
...
dal/src/main/java/com/yoho/ufo/dal/CouponMapper.java
View file @
8bde2fe
...
...
@@ -24,4 +24,6 @@ public interface CouponMapper {
void
insertByCouponSaveUpdateReq
(
@Param
(
"param"
)
CouponSaveUpdateReq
param
);
void
updateByCouponSaveUpdateReq
(
@Param
(
"param"
)
CouponSaveUpdateReq
param
);
List
<
Coupon
>
selectByIds
(
@Param
(
"ids"
)
List
<
Integer
>
id
);
}
...
...
dal/src/main/java/com/yoho/ufo/model/coupon/resp/UidCouponQueryResp.java
0 → 100644
View file @
8bde2fe
package
com
.
yoho
.
ufo
.
model
.
coupon
.
resp
;
import
com.yoho.ufo.annotation.BatchExportField
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.experimental.Builder
;
/**
* Created by li.ma on 2019/5/21.
*/
@Data
@ToString
@Builder
public
class
UidCouponQueryResp
{
private
Integer
couponId
;
private
String
couponName
;
private
Float
couponAmount
;
private
String
couponCode
;
private
Integer
uid
;
private
String
createTime
;
private
String
status
;
private
Integer
statusValue
;
private
String
useTime
;
}
...
...
dal/src/main/resources/META-INF/mybatis/CouponMapper.xml
View file @
8bde2fe
...
...
@@ -226,4 +226,11 @@
select
<include
refid=
"Base_Column_List"
/>
from coupon
where coupon_token =#{token} and status = 1 limit 1;
</select>
<select
id=
"selectByIds"
resultType=
"com.yoho.ufo.model.coupon.Coupon"
>
select
<include
refid=
"Base_Column_List"
/>
from coupon where id in
<foreach
collection=
"ids"
close=
")"
open=
"("
separator=
","
item=
"item"
>
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
...
...
web/src/main/webapp/html/coupon/userCoupon.html
0 → 100644
View file @
8bde2fe
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
/>
<title>
Yoho!Buy运营平台
</title>
<script
src=
"/ufoPlatform/js/include.js"
></script>
<script
src=
"/ufoPlatform/js/ajaxfileupload.js"
></script>
</head>
<body
class=
"easyui-layout"
fit=
"true"
>
<div
region=
"north"
style=
"height: 230px"
>
<script>
document
.
write
(
addHead
(
'用户优惠券'
,
''
));
</script>
<style>
.div_search
input
{
margin-top
:
20px
;
}
.div_search
.textbox
{
margin-top
:
20px
;
}
.div_search
.easyui-linkbutton
{
margin-top
:
20px
;
}
</style>
<div
style=
"margin-left: 30px;"
class=
"div_search"
>
<input
id=
"uid"
type=
"text"
>
<a
id=
"searchLinkButton"
class=
"easyui-linkbutton btn-info"
data-options=
"iconCls:'icon-search'"
>
筛选
</a>
</div>
</div>
<div
region=
"center"
>
<div
style=
"margin-left: 30px;margin-top: 20px;height: 660px"
>
<table
id=
"couponTable"
></table>
</div>
</div>
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
"#uid"
).
textbox
({
prompt
:
"UID"
});
$
(
"#couponTable"
).
myDatagrid
({
fit
:
true
,
fitColumns
:
true
,
nowrap
:
false
,
url
:
contextPath
+
"/coupon/queryUserCouponList"
,
method
:
'POST'
,
loadFilter
:
function
(
data
)
{
var
temp
=
defaultLoadFilter
(
data
);
temp
.
rows
=
temp
.
list
;
return
temp
;
//couponAmount
},
columns
:
[[{
title
:
"券ID"
,
field
:
"couponId"
,
width
:
40
,
align
:
"center"
},{
title
:
"券名称"
,
field
:
"couponName"
,
width
:
40
,
align
:
"center"
},{
title
:
"券金额"
,
field
:
"couponAmount"
,
width
:
40
,
align
:
"center"
},{
title
:
"UID"
,
field
:
"uid"
,
width
:
40
,
align
:
"center"
},
{
title
:
"单券号"
,
field
:
"couponCode"
,
width
:
100
,
align
:
"center"
},
{
title
:
"发放时间"
,
field
:
"createTime"
,
width
:
80
,
align
:
"center"
},
{
title
:
"使用时间"
,
field
:
"useTime"
,
width
:
80
,
align
:
"center"
},
{
title
:
"状态"
,
field
:
"statusValue"
,
width
:
50
,
align
:
"center"
,
formatter
:
function
(
value
,
rowData
)
{
return
value
==
1
?
'已使用'
:
'未使用'
;
}
}]],
cache
:
false
,
pagination
:
true
,
pageSize
:
10
,
pageList
:
[
10
],
idField
:
"id"
,
singleSelect
:
false
,
checkOnSelect
:
false
,
onLoadSuccess
:
function
()
{}
});
// 搜索
$
(
"#searchLinkButton"
).
linkbutton
({
onClick
:
function
()
{
var
param
=
getParams
();
$
(
"#couponTable"
).
myDatagrid
(
"load"
,
param
);
}
});
/**
* 提取出搜索参数
*/
function
getParams
()
{
var
uid
=
$
(
'#uid'
).
textbox
(
'getText'
);
var
param
=
{};
if
(
undefined
!==
uid
&&
null
!==
uid
&&
""
!==
uid
)
{
param
.
uid
=
uid
;
}
return
param
;
}
});
</script>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment