Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
873e14da
Commit
873e14da
authored
May 06, 2020
by
裴大威
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat-zy-1002853' into 'master'
1002853 小睿优化-券库优化增加已使用状态 See merge request rays/pcloud-book!701
parents
3d1f3ade
a7ea5ed2
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
202 additions
and
154 deletions
+202
-154
GiftCouponPackageBiz.java
.../com/pcloud/book/giftcoupon/biz/GiftCouponPackageBiz.java
+3
-2
GiftCouponPackageBizImpl.java
...ud/book/giftcoupon/biz/impl/GiftCouponPackageBizImpl.java
+33
-74
GiftParamCheck.java
...java/com/pcloud/book/giftcoupon/check/GiftParamCheck.java
+7
-0
GiftReceiveDao.java
...n/java/com/pcloud/book/giftcoupon/dao/GiftReceiveDao.java
+5
-6
GiftReceiveDaoImpl.java
...m/pcloud/book/giftcoupon/dao/impl/GiftReceiveDaoImpl.java
+19
-8
BatchReceiveDTO.java
.../java/com/pcloud/book/giftcoupon/dto/BatchReceiveDTO.java
+18
-0
GiftReceiveDTO.java
...n/java/com/pcloud/book/giftcoupon/dto/GiftReceiveDTO.java
+6
-0
MyGiftPackageDTO.java
...java/com/pcloud/book/giftcoupon/dto/MyGiftPackageDTO.java
+22
-0
GiftReceive.java
...n/java/com/pcloud/book/giftcoupon/entity/GiftReceive.java
+26
-8
GiftCouponPackageFacade.java
...cloud/book/giftcoupon/facade/GiftCouponPackageFacade.java
+4
-3
RightsSettingBizImpl.java
...oud/book/rightsSetting/biz/impl/RightsSettingBizImpl.java
+5
-16
GiftCouplePackageDao.xml
...main/resources/mapper/giftConpon/GiftCouplePackageDao.xml
+1
-0
GiftReceiveDao.xml
...k/src/main/resources/mapper/giftConpon/GiftReceiveDao.xml
+53
-37
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/biz/GiftCouponPackageBiz.java
View file @
873e14da
package
com
.
pcloud
.
book
.
giftcoupon
.
biz
;
import
com.pcloud.book.giftcoupon.dto.BatchReceiveDTO
;
import
com.pcloud.book.giftcoupon.dto.GiftPackageDTO
;
import
com.pcloud.book.giftcoupon.dto.MyGiftPackageDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
...
...
@@ -23,7 +24,7 @@ public interface GiftCouponPackageBiz {
PageBeanNew
<
MyGiftPackageDTO
>
list4MyGiftPackage
(
Integer
state
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
void
useGiftCoupon
(
Long
wechatUserId
,
Long
giftPackag
eId
);
void
useGiftCoupon
(
Long
wechatUserId
,
Long
receiv
eId
);
void
createGiftReceiveBatch
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
);
void
createGiftReceiveBatch
(
BatchReceiveDTO
batchReceiveDTO
,
Long
wechatUserId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/biz/impl/GiftCouponPackageBizImpl.java
View file @
873e14da
package
com
.
pcloud
.
book
.
giftcoupon
.
biz
.
impl
;
import
com.google.common.collect.Lists
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.book.constant.BookConstant
;
import
com.pcloud.book.giftcoupon.biz.GiftCouponPackageBiz
;
import
com.pcloud.book.giftcoupon.check.GiftParamCheck
;
import
com.pcloud.book.giftcoupon.dao.GiftCouponPackageDao
;
import
com.pcloud.book.giftcoupon.dao.GiftReceiveDao
;
import
com.pcloud.book.giftcoupon.dto.BatchReceiveDTO
;
import
com.pcloud.book.giftcoupon.dto.GiftPackageDTO
;
import
com.pcloud.book.giftcoupon.dto.GiftReceiveDTO
;
import
com.pcloud.book.giftcoupon.dto.MyGiftPackageDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.book.giftcoupon.enums.CouponTypeEnum
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.apache.commons.collections.MapUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -29,7 +26,6 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Component
(
"giftCouponPackageBiz"
)
...
...
@@ -113,28 +109,22 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
if
(
null
==
giftCouponPackage
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包不存在"
);
}
GiftReceive
receive
=
giftReceiveDao
.
getGiftReceive
(
giftReceive
.
getWechatUserId
(),
giftReceive
.
getGiftPackageId
());
Integer
giftReceiveCount
=
giftReceiveDao
.
getGiftReceiveCount
(
giftReceive
.
getWechatUserId
(),
giftReceive
.
getGiftPackageId
());
//库存减一
if
(
giftCouponPackage
.
getStock
()<
1
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存不够"
);
}
giftCouponPackageDao
.
reduceStock
(
giftReceive
.
getGiftPackageId
());
if
(
null
==
receive
){
giftReceive
.
setReceiveNum
(
1
);
giftReceive
.
setUsedNum
(
0
);
giftReceiveDao
.
insert
(
giftReceive
);
if
(
giftReceiveCount
>=
giftCouponPackage
.
getReceiveLimit
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"该类型的兑换券您已经领取过,请前往“我的券库”使用吧"
);
}
else
{
if
(
receive
.
getReceiveNum
()+
1
>=
giftCouponPackage
.
getReceiveLimit
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"该类型的兑换券您已经领取过,请前往“我的券库”使用吧"
);
}
receive
.
setReceiveNum
(
receive
.
getReceiveNum
()+
1
);
giftReceiveDao
.
update
(
receive
);
giftReceiveDao
.
insert
(
giftReceive
);
}
}
@Override
public
PageBeanNew
<
MyGiftPackageDTO
>
list4MyGiftPackage
(
Integer
state
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
)
{
//state=1 已领取 state=2 已
过期
//state=1 已领取 state=2 已
失效
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"wechatUserId"
,
wechatUserId
);
paramMap
.
put
(
"state"
,
state
);
...
...
@@ -147,31 +137,28 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
useGiftCoupon
(
Long
wechatUserId
,
Long
giftPackageId
)
{
GiftCouponPackage
giftCouponPackage
=
giftCouponPackageDao
.
getById
(
giftPackageId
);
if
(
null
==
giftCouponPackage
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包不存在"
);
}
GiftReceive
giftReceive
=
giftReceiveDao
.
getGiftReceive
(
wechatUserId
,
giftPackageId
);
public
void
useGiftCoupon
(
Long
wechatUserId
,
Long
receiveId
)
{
GiftReceive
giftReceive
=
giftReceiveDao
.
getById
(
receiveId
);
if
(
null
==
giftReceive
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"你还未领取该奖券包"
);
}
if
(!
CouponTypeEnum
.
COURSE_COUPON
.
value
.
equals
(
giftCouponPackage
.
getCouponType
()))
{
if
(
giftReceive
.
getReceiveNum
()
-
giftReceive
.
getUsedNum
()
<=
0
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包已经使用完了"
);
}
GiftCouponPackage
giftCouponPackage
=
giftCouponPackageDao
.
getById
(
giftReceive
.
getGiftPackageId
());
if
(
null
==
giftCouponPackage
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包不存在"
);
}
//todo 可能有其他操作,如果点击不跳转页面,需要控制重复点击
giftReceiveDao
.
useGiftCoupon
(
wechatUserId
,
giftPackag
eId
);
giftReceiveDao
.
useGiftCoupon
(
receiv
eId
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
value
=
"礼券包一键领取"
,
isAfterReturn
=
false
)
public
void
createGiftReceiveBatch
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
)
{
if
(
ListUtils
.
isEmpty
(
giftPackageIds
))
{
public
void
createGiftReceiveBatch
(
BatchReceiveDTO
batchReceiveDTO
,
Long
wechatUserId
)
{
if
(
null
==
batchReceiveDTO
||
null
==
batchReceiveDTO
.
getRightsSettingId
()
||
ListUtils
.
isEmpty
(
batchReceiveDTO
.
getGiftPackageIds
()
))
{
return
;
}
Long
rightsSettingId
=
batchReceiveDTO
.
getRightsSettingId
();
List
<
Long
>
giftPackageIds
=
batchReceiveDTO
.
getGiftPackageIds
();
List
<
Long
>
packageIdsBy
=
giftCouponPackageDao
.
getPackageIdsBy
(
giftPackageIds
);
if
(
ListUtils
.
isEmpty
(
packageIdsBy
)
||
packageIdsBy
.
size
()
!=
giftPackageIds
.
size
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有奖券包不存在,不能一键领取"
);
...
...
@@ -180,53 +167,25 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
if
(
noStockCount
>
0
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有奖券包无库存,不能一键领取"
);
}
//判断是否有超过上限的
List
<
GiftCouponPackage
>
overLimitCoupon
=
giftReceiveDao
.
getOverLimitCoupon
(
giftPackageIds
,
wechatUserId
);
if
(!
ListUtils
.
isEmpty
(
overLimitCoupon
)){
String
titles
=
overLimitCoupon
.
stream
().
map
(
a
->
a
.
getTitle
()).
collect
(
Collectors
.
joining
(
","
));
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
titles
+
"兑换券您已经领取过,请前往”我的券库”使用吧"
);
}
//批量减库存
giftCouponPackageDao
.
reduceStockBatch
(
giftPackageIds
);
Map
<
Long
,
GiftReceive
>
receiveMap
=
giftReceiveDao
.
getMapByIds
(
giftPackageIds
,
wechatUserId
);
if
(
MapUtils
.
isEmpty
(
receiveMap
))
{
//如果之前都没有领取过
List
<
GiftReceive
>
list
=
new
ArrayList
<>();
GiftReceive
receive
=
null
;
for
(
Long
giftPackageId
:
giftPackageIds
)
{
receive
=
new
GiftReceive
();
receive
.
setReceiveNum
(
1
);
receive
.
setUsedNum
(
0
);
receive
.
setGiftPackageId
(
giftPackageId
);
receive
.
setWechatUserId
(
wechatUserId
);
list
.
add
(
receive
);
}
giftReceiveDao
.
insert
(
list
);
}
else
{
//去掉已经领取的直接插入
List
<
Long
>
hasReceiveIds
=
new
ArrayList
<>(
receiveMap
.
keySet
());
giftPackageIds
.
removeAll
(
hasReceiveIds
);
List
<
GiftReceive
>
list
=
new
ArrayList
<>();
GiftReceive
receive
=
null
;
for
(
Long
giftPackageId
:
giftPackageIds
)
{
receive
=
new
GiftReceive
();
receive
.
setReceiveNum
(
1
);
receive
.
setUsedNum
(
0
);
receive
.
setGiftPackageId
(
giftPackageId
);
receive
.
setWechatUserId
(
wechatUserId
);
list
.
add
(
receive
);
}
giftReceiveDao
.
insert
(
list
);
//已经领取过得要做修改
Map
<
Long
,
GiftCouponPackage
>
couponMap
=
giftCouponPackageDao
.
getMapByIds
(
hasReceiveIds
);
List
<
Long
>
receives
=
Lists
.
newArrayList
();
for
(
Long
giftPackageId
:
hasReceiveIds
)
{
GiftCouponPackage
giftCouponPackage
=
couponMap
.
get
(
giftPackageId
);
GiftReceive
giftReceive
=
receiveMap
.
get
(
giftPackageId
);
if
(
giftReceive
.
getReceiveNum
()
+
1
>=
giftCouponPackage
.
getReceiveLimit
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"该类型的兑换券您已经领取过,请前往“我的券库”使用吧"
);
}
giftReceive
.
setReceiveNum
(
giftReceive
.
getReceiveNum
()
+
1
);
receives
.
add
(
giftReceive
.
getId
());
}
if
(!
ListUtils
.
isEmpty
(
receives
)){
giftReceiveDao
.
updateReceiveNum
(
receives
);
}
}
//批量插入
List
<
GiftReceive
>
list
=
new
ArrayList
<>();
GiftReceive
receive
=
null
;
for
(
Long
giftPackageId
:
giftPackageIds
)
{
receive
=
new
GiftReceive
();
receive
.
setRightsSettingId
(
rightsSettingId
);
receive
.
setGiftPackageId
(
giftPackageId
);
receive
.
setWechatUserId
(
wechatUserId
);
list
.
add
(
receive
);
}
giftReceiveDao
.
insert
(
list
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/check/GiftParamCheck.java
View file @
873e14da
...
...
@@ -22,6 +22,7 @@ public class GiftParamCheck {
private
final
Integer
COUPON_MAX_ADDRESS_LENGTH
=
800
;
private
final
Integer
COUPON_MAX_STOCK
=
99999
;
private
final
Integer
COUPON_MAX_RECEIVE
=
5
;
private
final
Integer
COUPON_MIN_RECEIVE
=
1
;
public
void
checkGiftAddParam
(
GiftCouponPackage
giftCouponPackage
)
{
if
(
null
==
giftCouponPackage
)
{
...
...
@@ -67,6 +68,9 @@ public class GiftParamCheck {
if
(
giftCouponPackage
.
getReceiveLimit
()>
COUPON_MAX_RECEIVE
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限最多"
+
COUPON_MAX_RECEIVE
+
"张"
);
}
if
(
giftCouponPackage
.
getReceiveLimit
()<
COUPON_MIN_RECEIVE
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限最低"
+
COUPON_MIN_RECEIVE
+
"张"
);
}
if
(
null
==
giftCouponPackage
.
getValidDateBegin
()
||
null
==
giftCouponPackage
.
getValidDateEnd
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期为空"
);
}
...
...
@@ -91,5 +95,8 @@ public class GiftParamCheck {
if
(
null
==
giftReceive
.
getGiftPackageId
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"奖券包id为空"
);
}
if
(
null
==
giftReceive
.
getRightsSettingId
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"权益id为空"
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/GiftReceiveDao.java
View file @
873e14da
...
...
@@ -5,8 +5,6 @@ import com.pcloud.book.giftcoupon.entity.GiftCouponPackage;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.core.dao.BaseDao
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -25,15 +23,17 @@ public interface GiftReceiveDao extends BaseDao<GiftReceive> {
*/
GiftReceive
getGiftReceive
(
Long
wechatUserId
,
Long
giftPackageId
);
Integer
getGiftReceiveCount
(
Long
wechatUserId
,
Long
giftPackageId
);
void
useGiftCoupon
(
Long
wechatUserId
,
Long
giftPackag
eId
);
void
useGiftCoupon
(
Long
receiv
eId
);
List
<
GiftReceiveDTO
>
getGiftReceiveNumList
(
List
<
Long
>
giftPackageIds
);
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
);
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
,
Long
rightsSettingId
);
Map
<
Long
,
GiftReceive
>
getMapByIds
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
);
List
<
GiftCouponPackage
>
getOverLimitCoupon
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
);
void
updateReceiveNum
(
List
<
Long
>
receives
);
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/impl/GiftReceiveDaoImpl.java
View file @
873e14da
...
...
@@ -2,6 +2,7 @@ package com.pcloud.book.giftcoupon.dao.impl;
import
com.pcloud.book.giftcoupon.dao.GiftReceiveDao
;
import
com.pcloud.book.giftcoupon.dto.GiftReceiveDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
...
...
@@ -22,13 +23,18 @@ public class GiftReceiveDaoImpl extends BaseDaoImpl<GiftReceive> implements Gift
return
super
.
getSessionTemplate
().
selectOne
(
getStatement
(
"getGiftReceive"
),
map
);
}
@Override
public
void
useGiftCoupon
(
Long
wechatUserId
,
Long
giftPackageId
)
{
public
Integer
getGiftReceiveCount
(
Long
wechatUserId
,
Long
giftPackageId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"giftPackageId"
,
giftPackageId
);
return
super
.
getSessionTemplate
().
selectOne
(
getStatement
(
"getGiftReceiveCount"
),
map
);
}
@Override
public
void
useGiftCoupon
(
Long
receiveId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"receiveId"
,
receiveId
);
super
.
getSessionTemplate
().
update
(
getStatement
(
"useGiftCoupon"
),
map
);
}
...
...
@@ -40,8 +46,11 @@ public class GiftReceiveDaoImpl extends BaseDaoImpl<GiftReceive> implements Gift
}
@Override
public
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
)
{
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getUserReceiveGiftId"
),
wechatUserId
);
public
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
,
Long
rightsSettingId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"rightsSettingId"
,
rightsSettingId
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getUserReceiveGiftId"
),
map
);
}
@Override
...
...
@@ -53,9 +62,11 @@ public class GiftReceiveDaoImpl extends BaseDaoImpl<GiftReceive> implements Gift
}
@Override
public
void
updateReceiveNum
(
List
<
Long
>
receives
)
{
public
List
<
GiftCouponPackage
>
getOverLimitCoupon
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"receives"
,
receives
);
super
.
getSessionTemplate
().
update
(
getStatement
(
"updateReceiveNum"
),
map
);
map
.
put
(
"giftPackageIds"
,
giftPackageIds
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectList
(
super
.
getStatement
(
"getOverLimitCoupon"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dto/BatchReceiveDTO.java
0 → 100644
View file @
873e14da
package
com
.
pcloud
.
book
.
giftcoupon
.
dto
;
import
java.util.List
;
import
lombok.Data
;
@Data
public
class
BatchReceiveDTO
{
/**
* 券id集合
*/
List
<
Long
>
giftPackageIds
;
/**
* 权益Id
*/
Long
rightsSettingId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dto/GiftReceiveDTO.java
View file @
873e14da
...
...
@@ -19,5 +19,10 @@ public class GiftReceiveDTO {
*/
private
Integer
receiveNum
;
/**
* 领取id
*/
private
Long
receiveId
;
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dto/MyGiftPackageDTO.java
View file @
873e14da
...
...
@@ -64,4 +64,26 @@ public class MyGiftPackageDTO {
* 兑换地址
*/
private
String
exchangeAddress
;
/**
* 使用时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm"
,
timezone
=
"GMT+8"
)
private
Date
useTime
;
/**
* 领取id
*/
private
Long
receiveId
;
/**
* 失效状态 (1-已使用,2-已过期)
*/
private
Integer
failureState
;
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/entity/GiftReceive.java
View file @
873e14da
package
com
.
pcloud
.
book
.
giftcoupon
.
entity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.pcloud.common.entity.BaseEntity
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlElement
;
import
lombok.Data
;
/**
...
...
@@ -15,14 +21,25 @@ public class GiftReceive extends BaseEntity {
private
Long
wechatUserId
;
private
Long
giftPackageId
;
/**
* 领取数量
*/
private
Integer
receiveNum
;
/**
* 使用数量
*/
private
Integer
usedNum
;
//权益id
private
Long
rightsSettingId
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
useTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm"
,
timezone
=
"GMT+8"
)
public
Date
getUseTime
()
{
return
useTime
;
}
public
void
setUseTime
(
Date
useTime
)
{
this
.
useTime
=
useTime
;
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/facade/GiftCouponPackageFacade.java
View file @
873e14da
...
...
@@ -12,6 +12,7 @@ import com.pcloud.book.cultivate.dto.SkillUseDTO;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.giftcoupon.biz.GiftCouponPackageBiz
;
import
com.pcloud.book.giftcoupon.dto.BatchReceiveDTO
;
import
com.pcloud.book.giftcoupon.dto.GiftPackageDTO
;
import
com.pcloud.book.giftcoupon.dto.GiftReceiveDTO
;
import
com.pcloud.book.giftcoupon.dto.MyGiftPackageDTO
;
...
...
@@ -113,10 +114,10 @@ public class GiftCouponPackageFacade {
@PostMapping
(
"/createGiftReceiveBatch"
)
public
ResponseDto
<?>
createGiftReceiveBatch
(
@CookieValue
(
value
=
"userInfo"
)
String
userInfo
,
@RequestBody
List
<
Long
>
giftPackageIds
@RequestBody
BatchReceiveDTO
batchReceiveDTO
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
giftCouponPackageBiz
.
createGiftReceiveBatch
(
giftPackageIds
,
wechatUserId
);
giftCouponPackageBiz
.
createGiftReceiveBatch
(
batchReceiveDTO
,
wechatUserId
);
return
new
ResponseDto
<>();
}
...
...
@@ -139,7 +140,7 @@ public class GiftCouponPackageFacade {
@RequestBody
GiftReceiveDTO
giftReceiveDTO
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
giftCouponPackageBiz
.
useGiftCoupon
(
wechatUserId
,
giftReceiveDTO
.
get
GiftPackag
eId
());
giftCouponPackageBiz
.
useGiftCoupon
(
wechatUserId
,
giftReceiveDTO
.
get
Receiv
eId
());
return
new
ResponseDto
<>();
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/rightsSetting/biz/impl/RightsSettingBizImpl.java
View file @
873e14da
...
...
@@ -2,7 +2,6 @@ package com.pcloud.book.rightsSetting.biz.impl;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.appcenter.assist.dto.AssistTempletDTO
;
...
...
@@ -33,8 +32,8 @@ import com.pcloud.book.group.tools.SendWeixinRequestTools;
import
com.pcloud.book.rightsSetting.biz.RightsSettingBiz
;
import
com.pcloud.book.rightsSetting.check.RightsSettingCheck
;
import
com.pcloud.book.rightsSetting.constants.RightsSettingConstant
;
import
com.pcloud.book.rightsSetting.dao.RightsItemGroupDao
;
import
com.pcloud.book.rightsSetting.dao.RightsCustomRelationDao
;
import
com.pcloud.book.rightsSetting.dao.RightsItemGroupDao
;
import
com.pcloud.book.rightsSetting.dao.RightsNowItemDao
;
import
com.pcloud.book.rightsSetting.dao.RightsReadPlanDao
;
import
com.pcloud.book.rightsSetting.dao.RightsSettingDAO
;
...
...
@@ -42,8 +41,8 @@ import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao;
import
com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO
;
import
com.pcloud.book.rightsSetting.dto.RightsSettingDto
;
import
com.pcloud.book.rightsSetting.entity.BaseTempletClassify
;
import
com.pcloud.book.rightsSetting.entity.RightsItemGroup
;
import
com.pcloud.book.rightsSetting.entity.RightsCustomRelation
;
import
com.pcloud.book.rightsSetting.entity.RightsItemGroup
;
import
com.pcloud.book.rightsSetting.entity.RightsNowItem
;
import
com.pcloud.book.rightsSetting.entity.RightsReadPlan
;
import
com.pcloud.book.rightsSetting.entity.RightsSetting
;
...
...
@@ -60,8 +59,6 @@ import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import
com.pcloud.book.util.common.CommonUtils
;
import
com.pcloud.book.util.common.YesOrNoEnums
;
import
com.pcloud.channelcenter.wechat.dto.AccountSettingDto
;
import
com.pcloud.channelcenter.wechat.dto.BookServeParamVO
;
import
com.pcloud.channelcenter.wechat.vo.BookServeVO
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
...
...
@@ -71,17 +68,10 @@ import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtilParent
;
import
com.pcloud.resourcecenter.product.dto.ProductDto
;
import
org.apache.commons.collections.CollectionUtils
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.sql.SQLException
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.function.Function
;
import
lombok.NonNull
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.elasticsearch.common.recycler.Recycler
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -94,12 +84,11 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.Random
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
RightsSettingBizImpl
implements
RightsSettingBiz
{
...
...
@@ -1306,7 +1295,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if
(
rightsSetting
==
null
||
wechatUserId
==
null
||
ListUtils
.
isEmpty
(
rightsSetting
.
getGiftCouponPackageTitle
().
getRightsSettingItemList
()))
{
return
;
}
List
<
Long
>
list
=
giftReceiveDao
.
getUserReceiveGiftId
(
wechatUserId
);
List
<
Long
>
list
=
giftReceiveDao
.
getUserReceiveGiftId
(
wechatUserId
,
rightsSetting
.
getId
()
);
if
(
ListUtils
.
isEmpty
(
list
))
{
list
=
new
ArrayList
<>();
}
...
...
pcloud-service-book/src/main/resources/mapper/giftConpon/GiftCouplePackageDao.xml
View file @
873e14da
...
...
@@ -179,6 +179,7 @@
<if
test=
"couponType !=null"
>
and a.coupon_type=#{couponType}
</if>
and a.receive_limit>0
GROUP BY a.id
order by a.update_time desc
...
...
pcloud-service-book/src/main/resources/mapper/giftConpon/GiftReceiveDao.xml
View file @
873e14da
...
...
@@ -6,20 +6,20 @@
<result
property=
"id"
column=
"id"
jdbcType=
"INTEGER"
/>
<result
property=
"wechatUserId"
column=
"wechat_user_id"
jdbcType=
"INTEGER"
/>
<result
property=
"giftPackageId"
column=
"gift_package_id"
jdbcType=
"INTEGER"
/>
<result
property=
"r
eceiveNum"
column=
"receive_num
"
jdbcType=
"INTEGER"
/>
<result
property=
"use
dNum"
column=
"used_num"
jdbcType=
"INTEGER
"
/>
<result
property=
"r
ightsSettingId"
column=
"rights_setting_id
"
jdbcType=
"INTEGER"
/>
<result
property=
"use
Time"
column=
"use_time"
jdbcType=
"TIMESTAMP
"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time
id, wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time
</sql>
<!--查询单个-->
<select
id=
"
query
ById"
resultMap=
"GiftReceiveMap"
>
<select
id=
"
get
ById"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time
id, wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time
from book.gift_receive
where id = #{id}
</select>
...
...
@@ -27,7 +27,7 @@
<!--查询指定行数据-->
<select
id=
"queryAllByLimit"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time
id, wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time
from book.gift_receive
limit #{offset}, #{limit}
</select>
...
...
@@ -35,7 +35,7 @@
<!--通过实体作为筛选条件查询-->
<select
id=
"queryAll"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time
id, wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time
from book.gift_receive
<where>
<if
test=
"id != null"
>
...
...
@@ -47,11 +47,11 @@
<if
test=
"giftPackageId != null"
>
and gift_package_id = #{giftPackageId}
</if>
<if
test=
"r
eceiveNum
!= null"
>
and r
eceive_num = #{receiveNum
}
<if
test=
"r
ightsSettingId
!= null"
>
and r
ights_setting_id = #{rightsSettingId
}
</if>
<if
test=
"use
dNum
!= null"
>
and use
d_num = #{usedNum
}
<if
test=
"use
Time
!= null"
>
and use
_time = #{useTime
}
</if>
<if
test=
"createTime != null"
>
and create_time = #{createTime}
...
...
@@ -64,15 +64,15 @@
<!--新增所有列-->
<insert
id=
"insert"
parameterType=
"com.pcloud.book.giftcoupon.entity.GiftReceive"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into book.gift_receive(wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time)
values (#{wechatUserId}, #{giftPackageId}, #{r
eceiveNum}, #{usedNum
}, now(), now())
insert into book.gift_receive(wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time)
values (#{wechatUserId}, #{giftPackageId}, #{r
ightsSettingId}, #{useTime
}, now(), now())
</insert>
<insert
id=
"batchInsert"
parameterType=
"com.pcloud.book.giftcoupon.entity.GiftReceive"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into book.gift_receive(wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time)
insert into book.gift_receive(wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.wechatUserId}, #{item.giftPackageId}, #{item.r
eceiveNum}, #{item.usedNum
}, now(), now())
(#{item.wechatUserId}, #{item.giftPackageId}, #{item.r
ightsSettingId}, #{item.useTime
}, now(), now())
</foreach>
</insert>
...
...
@@ -86,11 +86,11 @@
<if
test=
"giftPackageId != null"
>
gift_package_id = #{giftPackageId},
</if>
<if
test=
"
receiveNum
!= null"
>
receive_num = #{receiveNum
},
<if
test=
"
useTime
!= null"
>
use_time = #{useTime
},
</if>
<if
test=
"
usedNum
!= null"
>
used_num = #{usedNum
},
<if
test=
"
rightsSettingId
!= null"
>
rights_setting_id = #{rightsSettingId
},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
...
...
@@ -107,50 +107,58 @@
<select
id=
"getGiftReceive"
parameterType=
"map"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, r
eceive_num, used_num
, create_time, update_time
id, wechat_user_id, gift_package_id, r
ights_setting_id, use_time
, create_time, update_time
from book.gift_receive
where wechat_user_id=#{wechatUserId}
and gift_package_id=#{giftPackageId}
limit 1
</select>
<select
id=
"useGiftCoupon"
parameterType=
"map"
>
update gift_receive
set used_num=used_num+1
<select
id=
"getGiftReceiveCount"
parameterType=
"map"
resultType=
"Integer"
>
select
ifnull(count(1),0)
from gift_receive
where wechat_user_id=#{wechatUserId}
and gift_package_id=#{giftPackageId}
</select>
<select
id=
"useGiftCoupon"
parameterType=
"map"
>
update gift_receive
set use_time=now(),update_time=now()
where id=#{receiveId}
</select>
<select
id=
"list4MyGiftPackage"
parameterType=
"map"
resultType=
"com.pcloud.book.giftcoupon.dto.MyGiftPackageDTO"
>
select
b.id receiveId,
b.use_time useTime,
a.title title,
a.cover_pic coverPic,
a.denomination denomination,
a.valid_date_begin validDateBegin,
a.valid_date_end validDateEnd,
a.id id,
(b.receive_num-ifnull(b.used_num,0)) noUsedNum,
a.coupon_type couponType,
a.instructions instructions,
a.use_type useType,
a.exchange_address exchangeAddress
a.exchange_address exchangeAddress,
if(b.use_time>0,1,2) failureState
from
gift_receive b LEFT JOIN gift_coupon_package a
on a.id=b.gift_package_id
where b.wechat_user_id=#{wechatUserId}
and ( (coupon_type=1) or (coupon_type!=1 and b.used_num
<![CDATA[ < ]]>
b.receive_num) )
<if
test=
"state!=null and state==1"
>
and now()
<![CDATA[ <= ]]>
a.valid_date_end
and now()
<![CDATA[ <= ]]>
a.valid_date_end
and use_time is null
</if>
<if
test=
"state!=null and state==2"
>
and
now() > a.valid_date_end
and
(now() > a.valid_date_end or use_time>0)
</if>
order by b.
upd
ate_time desc
order by b.
cre
ate_time desc
</select>
<select
id=
"getGiftReceiveNumList"
parameterType=
"map"
resultType=
"com.pcloud.book.giftcoupon.dto.GiftReceiveDTO"
>
select gift_package_id giftPackageId,
ifnull(
sum(receive_num
),0) receiveNum
ifnull(
count(1
),0) receiveNum
from gift_receive
where gift_package_id in
<foreach
collection=
"giftPackageIds"
open=
"("
close=
")"
item=
"item"
separator=
","
>
...
...
@@ -159,10 +167,11 @@
group by gift_package_id
</select>
<select
id=
"getUserReceiveGiftId"
parameterType=
"
long
"
resultType=
"long"
>
<select
id=
"getUserReceiveGiftId"
parameterType=
"
map
"
resultType=
"long"
>
select distinct gift_package_id
from gift_receive
where wechat_user_id=#{wechatUserId}
and rights_setting_id=#{rightsSettingId}
</select>
<select
id=
"getMapByIds"
parameterType=
"map"
resultMap=
"GiftReceiveMap"
>
...
...
@@ -175,13 +184,19 @@
</foreach>
</select>
<select
id=
"updateReceiveNum"
parameterType=
"map"
>
update gift_receive
set receive_num=receive_num+1
where id in
<foreach
collection=
"receives"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{item}
<select
id=
"getOverLimitCoupon"
parameterType=
"map"
resultType=
"com.pcloud.book.giftcoupon.entity.GiftCouponPackage"
>
select b.receive_limit receiveLimit ,a.gift_package_id id,b.title title
from gift_receive a
left join gift_coupon_package b
on a.gift_package_id=b.id
where
a.wechat_user_id=#{wechatUserId}
and a.gift_package_id in
<foreach
collection=
"giftPackageIds"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
${item}
</foreach>
GROUP BY a.gift_package_id HAVING count(a.id)>=b.receive_limit
</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