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
504364c6
Commit
504364c6
authored
Apr 29, 2020
by
郑勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat-1002828 兑换券兑换配置功能
parent
e765df56
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
525 additions
and
27 deletions
+525
-27
BookConstant.java
...main/java/com/pcloud/book/book/constant/BookConstant.java
+2
-0
GiftCouponService.java
...com/pcloud/book/giftcoupon/service/GiftCouponService.java
+25
-0
GiftCouponVo.java
...main/java/com/pcloud/book/giftcoupon/vo/GiftCouponVo.java
+62
-0
GiftCouponPackageBiz.java
.../com/pcloud/book/giftcoupon/biz/GiftCouponPackageBiz.java
+5
-1
GiftCouponPackageBizImpl.java
...ud/book/giftcoupon/biz/impl/GiftCouponPackageBizImpl.java
+86
-4
GiftParamCheck.java
...java/com/pcloud/book/giftcoupon/check/GiftParamCheck.java
+34
-8
GiftCouponPackageDao.java
.../com/pcloud/book/giftcoupon/dao/GiftCouponPackageDao.java
+9
-0
GiftReceiveDao.java
...n/java/com/pcloud/book/giftcoupon/dao/GiftReceiveDao.java
+6
-2
GiftCouponPackageDaoImpl.java
...ud/book/giftcoupon/dao/impl/GiftCouponPackageDaoImpl.java
+29
-0
GiftReceiveDaoImpl.java
...m/pcloud/book/giftcoupon/dao/impl/GiftReceiveDaoImpl.java
+15
-0
GiftPackageDTO.java
...n/java/com/pcloud/book/giftcoupon/dto/GiftPackageDTO.java
+9
-0
MyGiftPackageDTO.java
...java/com/pcloud/book/giftcoupon/dto/MyGiftPackageDTO.java
+18
-0
GiftCouponPackage.java
.../com/pcloud/book/giftcoupon/entity/GiftCouponPackage.java
+17
-0
CouponTypeEnum.java
...java/com/pcloud/book/giftcoupon/enums/CouponTypeEnum.java
+23
-0
CouponUseTypeEnum.java
...a/com/pcloud/book/giftcoupon/enums/CouponUseTypeEnum.java
+23
-0
GiftCouponPackageFacade.java
...cloud/book/giftcoupon/facade/GiftCouponPackageFacade.java
+18
-3
GiftCouponServiceImpl.java
...d/book/giftcoupon/service/impl/GiftCouponServiceImpl.java
+35
-0
GiftCouplePackageDao.xml
...main/resources/mapper/giftConpon/GiftCouplePackageDao.xml
+71
-7
GiftReceiveDao.xml
...k/src/main/resources/mapper/giftConpon/GiftReceiveDao.xml
+38
-2
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/book/constant/BookConstant.java
View file @
504364c6
...
@@ -330,4 +330,6 @@ public class BookConstant {
...
@@ -330,4 +330,6 @@ public class BookConstant {
public
static
final
String
TIME_CONTROL_UPDATE_SEND
=
"TIME_CONTROL_UPDATE_SEND"
;
public
static
final
String
TIME_CONTROL_UPDATE_SEND
=
"TIME_CONTROL_UPDATE_SEND"
;
public
static
final
String
TIME_CONTROL_SEND
=
"TIME_CONTROL_SEND_"
;
public
static
final
String
TIME_CONTROL_SEND
=
"TIME_CONTROL_SEND_"
;
public
static
final
String
DEFAULT_COVER_PIC
=
"https://oss.5rs.me/oss/uploadfe/jpg/b10f42694d17429fe9ebd8dfd85704e0.jpg"
;
}
}
pcloud-facade-book/src/main/java/com/pcloud/book/giftcoupon/service/GiftCouponService.java
0 → 100644
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
service
;
import
com.pcloud.book.giftcoupon.vo.GiftCouponVo
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@FeignClient
(
value
=
"pcloud-service-book"
,
qualifier
=
"giftCouponServiceCloud"
,
path
=
"book/v1.0/giftCouponService"
)
@Api
(
description
=
"小程序劵包"
)
public
interface
GiftCouponService
{
@ApiOperation
(
value
=
"拿券的基本信息"
,
httpMethod
=
"POST"
)
@RequestMapping
(
value
=
"/getCouponBaseInfo"
,
method
=
RequestMethod
.
GET
)
ResponseEntity
<
ResponseDto
<
GiftCouponVo
>>
getCouponBaseInfo
(
@RequestParam
(
"couponId"
)
Long
couponId
)
throws
BizException
;
}
pcloud-facade-book/src/main/java/com/pcloud/book/giftcoupon/vo/GiftCouponVo.java
0 → 100644
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
vo
;
import
com.pcloud.common.entity.BaseEntity
;
import
lombok.Data
;
/**
* 专享礼券包表(GiftCouponPackage)实体类
*
* @author makejava
* @since 2020-04-19 14:59:19
*/
@Data
public
class
GiftCouponVo
extends
BaseEntity
{
/**
* 封面图
*/
private
String
coverPic
;
/**
* 名称
*/
private
String
title
;
/**
* 有效期开始时间
*/
private
String
validDateBegin
;
/**
* 有效期结束时间
*/
private
String
validDateEnd
;
/**
* 面额
*/
private
Integer
denomination
;
private
Integer
stock
;
/**
* 每人领取上限
*/
private
Integer
receiveLimit
;
/**
* 券类型(1-书币券,2-课程券)
*/
private
Integer
couponType
;
/**
* 使用说明
*/
private
String
instructions
;
/**
* 课程券使用方式(1-链接兑取,2-复制码)
*/
private
Integer
useType
;
/**
* 兑换地址
*/
private
String
exchangeAddress
;
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/biz/GiftCouponPackageBiz.java
View file @
504364c6
...
@@ -6,6 +6,8 @@ import com.pcloud.book.giftcoupon.entity.GiftCouponPackage;
...
@@ -6,6 +6,8 @@ import com.pcloud.book.giftcoupon.entity.GiftCouponPackage;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageBeanNew
;
import
java.util.List
;
public
interface
GiftCouponPackageBiz
{
public
interface
GiftCouponPackageBiz
{
void
createGiftPackage
(
GiftCouponPackage
giftCouponPackage
);
void
createGiftPackage
(
GiftCouponPackage
giftCouponPackage
);
...
@@ -17,9 +19,11 @@ public interface GiftCouponPackageBiz {
...
@@ -17,9 +19,11 @@ public interface GiftCouponPackageBiz {
void
createGiftReceive
(
GiftReceive
giftReceive
);
void
createGiftReceive
(
GiftReceive
giftReceive
);
PageBeanNew
<
GiftPackageDTO
>
list4GiftPackage
(
String
title
,
Integer
state
,
Integer
currentPage
,
Integer
numPerPage
);
PageBeanNew
<
GiftPackageDTO
>
list4GiftPackage
(
String
title
,
Integer
state
,
Integer
couponType
,
Integer
currentPage
,
Integer
numPerPage
);
PageBeanNew
<
MyGiftPackageDTO
>
list4MyGiftPackage
(
Integer
state
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
PageBeanNew
<
MyGiftPackageDTO
>
list4MyGiftPackage
(
Integer
state
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
void
useGiftCoupon
(
Long
wechatUserId
,
Long
giftPackageId
);
void
useGiftCoupon
(
Long
wechatUserId
,
Long
giftPackageId
);
void
createGiftReceiveBatch
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/biz/impl/GiftCouponPackageBizImpl.java
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
biz
.
impl
;
package
com
.
pcloud
.
book
.
giftcoupon
.
biz
.
impl
;
import
com.google.common.collect.Lists
;
import
com.pcloud.book.base.exception.BookBizException
;
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.biz.GiftCouponPackageBiz
;
import
com.pcloud.book.giftcoupon.check.GiftParamCheck
;
import
com.pcloud.book.giftcoupon.check.GiftParamCheck
;
import
com.pcloud.book.giftcoupon.dao.GiftCouponPackageDao
;
import
com.pcloud.book.giftcoupon.dao.GiftCouponPackageDao
;
...
@@ -14,6 +17,7 @@ import com.pcloud.common.core.aspect.ParamLog;
...
@@ -14,6 +17,7 @@ import com.pcloud.common.core.aspect.ParamLog;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -24,6 +28,7 @@ import java.util.ArrayList;
...
@@ -24,6 +28,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
(
"giftCouponPackageBiz"
)
@Component
(
"giftCouponPackageBiz"
)
...
@@ -41,6 +46,9 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
...
@@ -41,6 +46,9 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
@Override
@Override
public
void
createGiftPackage
(
GiftCouponPackage
giftCouponPackage
)
{
public
void
createGiftPackage
(
GiftCouponPackage
giftCouponPackage
)
{
giftParamCheck
.
checkGiftAddParam
(
giftCouponPackage
);
giftParamCheck
.
checkGiftAddParam
(
giftCouponPackage
);
if
(
StringUtil
.
isBlank
(
giftCouponPackage
.
getCoverPic
())){
giftCouponPackage
.
setCoverPic
(
BookConstant
.
DEFAULT_COVER_PIC
);
}
giftCouponPackageDao
.
insert
(
giftCouponPackage
);
giftCouponPackageDao
.
insert
(
giftCouponPackage
);
}
}
...
@@ -49,6 +57,9 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
...
@@ -49,6 +57,9 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
@Override
@Override
public
void
updateGiftPackage
(
GiftCouponPackage
giftCouponPackage
)
{
public
void
updateGiftPackage
(
GiftCouponPackage
giftCouponPackage
)
{
giftParamCheck
.
checkGiftAddParam
(
giftCouponPackage
);
giftParamCheck
.
checkGiftAddParam
(
giftCouponPackage
);
if
(
StringUtil
.
isBlank
(
giftCouponPackage
.
getCoverPic
())){
giftCouponPackage
.
setCoverPic
(
BookConstant
.
DEFAULT_COVER_PIC
);
}
giftCouponPackageDao
.
update
(
giftCouponPackage
);
giftCouponPackageDao
.
update
(
giftCouponPackage
);
}
}
...
@@ -64,10 +75,11 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
...
@@ -64,10 +75,11 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
}
}
@Override
@Override
public
PageBeanNew
<
GiftPackageDTO
>
list4GiftPackage
(
String
title
,
Integer
state
,
Integer
currentPage
,
Integer
numPerPage
)
{
public
PageBeanNew
<
GiftPackageDTO
>
list4GiftPackage
(
String
title
,
Integer
state
,
Integer
c
ouponType
,
Integer
c
urrentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"title"
,
title
);
paramMap
.
put
(
"title"
,
title
);
paramMap
.
put
(
"state"
,
state
);
paramMap
.
put
(
"state"
,
state
);
paramMap
.
put
(
"couponType"
,
couponType
);
PageBeanNew
<
GiftPackageDTO
>
pageBeanNew
=
giftCouponPackageDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
paramMap
,
"list4GiftPackage"
);
PageBeanNew
<
GiftPackageDTO
>
pageBeanNew
=
giftCouponPackageDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
paramMap
,
"list4GiftPackage"
);
if
(
pageBeanNew
==
null
||
ListUtils
.
isEmpty
(
pageBeanNew
.
getRecordList
()))
{
if
(
pageBeanNew
==
null
||
ListUtils
.
isEmpty
(
pageBeanNew
.
getRecordList
()))
{
return
new
PageBeanNew
<>(
currentPage
,
numPerPage
,
new
ArrayList
<>());
return
new
PageBeanNew
<>(
currentPage
,
numPerPage
,
new
ArrayList
<>());
...
@@ -92,7 +104,7 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
...
@@ -92,7 +104,7 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增专享礼包"
)
@ParamLog
(
value
=
"新增专享礼包"
,
isAfterReturn
=
false
)
@Override
@Override
public
void
createGiftReceive
(
GiftReceive
giftReceive
)
{
public
void
createGiftReceive
(
GiftReceive
giftReceive
)
{
giftParamCheck
.
checkGiftReceiveAddParam
(
giftReceive
);
giftParamCheck
.
checkGiftReceiveAddParam
(
giftReceive
);
...
@@ -101,13 +113,18 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
...
@@ -101,13 +113,18 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包不存在"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包不存在"
);
}
}
GiftReceive
receive
=
giftReceiveDao
.
getGiftReceive
(
giftReceive
.
getWechatUserId
(),
giftReceive
.
getGiftPackageId
());
GiftReceive
receive
=
giftReceiveDao
.
getGiftReceive
(
giftReceive
.
getWechatUserId
(),
giftReceive
.
getGiftPackageId
());
//库存减一
if
(
giftCouponPackage
.
getStock
()<
1
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存不够"
);
}
giftCouponPackageDao
.
reduceStock
(
giftReceive
.
getGiftPackageId
());
if
(
null
==
receive
){
if
(
null
==
receive
){
giftReceive
.
setReceiveNum
(
1
);
giftReceive
.
setReceiveNum
(
1
);
giftReceive
.
setUsedNum
(
0
);
giftReceive
.
setUsedNum
(
0
);
giftReceiveDao
.
insert
(
giftReceive
);
giftReceiveDao
.
insert
(
giftReceive
);
}
else
{
}
else
{
if
(
receive
.
getReceiveNum
()>=
giftCouponPackage
.
getReceiveLimit
()){
if
(
receive
.
getReceiveNum
()
+
1
>=
giftCouponPackage
.
getReceiveLimit
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
领取数量已超过奖券包最大领取数量
"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
该类型的兑换券您已经领取过,请前往“我的券库”使用吧
"
);
}
}
receive
.
setReceiveNum
(
receive
.
getReceiveNum
()+
1
);
receive
.
setReceiveNum
(
receive
.
getReceiveNum
()+
1
);
giftReceiveDao
.
update
(
receive
);
giftReceiveDao
.
update
(
receive
);
...
@@ -140,4 +157,69 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
...
@@ -140,4 +157,69 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
//todo 可能有其他操作,如果点击不跳转页面,需要控制重复点击
//todo 可能有其他操作,如果点击不跳转页面,需要控制重复点击
giftReceiveDao
.
useGiftCoupon
(
wechatUserId
,
giftPackageId
);
giftReceiveDao
.
useGiftCoupon
(
wechatUserId
,
giftPackageId
);
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
value
=
"礼券包一键领取"
,
isAfterReturn
=
false
)
public
void
createGiftReceiveBatch
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
)
{
if
(
ListUtils
.
isEmpty
(
giftPackageIds
))
{
return
;
}
List
<
Long
>
packageIdsBy
=
giftCouponPackageDao
.
getPackageIdsBy
(
giftPackageIds
);
if
(
ListUtils
.
isEmpty
(
packageIdsBy
)
||
packageIdsBy
.
size
()
!=
giftPackageIds
.
size
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有奖券包不存在,不能一键领取"
);
}
Integer
noStockCount
=
giftCouponPackageDao
.
getNoStockCount
(
giftPackageIds
);
if
(
noStockCount
>
0
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有奖券包无库存,不能一键领取"
);
}
//批量减库存
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
);
}
}
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/check/GiftParamCheck.java
View file @
504364c6
...
@@ -3,6 +3,7 @@ package com.pcloud.book.giftcoupon.check;
...
@@ -3,6 +3,7 @@ package com.pcloud.book.giftcoupon.check;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.book.giftcoupon.enums.CouponTypeEnum
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
...
@@ -16,33 +17,55 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -16,33 +17,55 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Slf4j
public
class
GiftParamCheck
{
public
class
GiftParamCheck
{
private
final
Integer
COUPON_MAX_TITLE_LENGTH
=
20
;
private
final
Integer
COUPON_MAX_DENOMINATION
=
999
;
private
final
Integer
COUPON_MAX_ADDRESS_LENGTH
=
800
;
private
final
Integer
COUPON_MAX_STOCK
=
99999
;
private
final
Integer
COUPON_MAX_RECEIVE
=
5
;
public
void
checkGiftAddParam
(
GiftCouponPackage
giftCouponPackage
)
{
public
void
checkGiftAddParam
(
GiftCouponPackage
giftCouponPackage
)
{
if
(
null
==
giftCouponPackage
)
{
if
(
null
==
giftCouponPackage
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数为空"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数为空"
);
}
}
if
(
null
==
giftCouponPackage
.
getCouponType
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"请选择礼券类型"
);
}
if
(
StringUtil
.
isEmpty
(
giftCouponPackage
.
getTitle
()))
{
if
(
StringUtil
.
isEmpty
(
giftCouponPackage
.
getTitle
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"名称为空"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"名称为空"
);
}
}
if
(
giftCouponPackage
.
getTitle
().
length
()>
20
)
{
if
(
giftCouponPackage
.
getTitle
().
length
()>
COUPON_MAX_TITLE_LENGTH
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"标题名称最多
20
个字"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"标题名称最多
"
+
COUPON_MAX_TITLE_LENGTH
+
"
个字"
);
}
}
if
(
CouponTypeEnum
.
BOOK_COIN_COUPON
.
value
.
equals
(
giftCouponPackage
.
getCouponType
()))
{
if
(
null
==
giftCouponPackage
.
getDenomination
())
{
if
(
null
==
giftCouponPackage
.
getDenomination
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"面额为空"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"面额为空"
);
}
}
if
(
giftCouponPackage
.
getDenomination
()>
999
)
{
if
(
giftCouponPackage
.
getDenomination
()
>
COUPON_MAX_DENOMINATION
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"面额最多999"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"面额最多"
+
COUPON_MAX_DENOMINATION
);
}
}
if
(
CouponTypeEnum
.
COURSE_COUPON
.
value
.
equals
(
giftCouponPackage
.
getCouponType
())){
if
(
null
==
giftCouponPackage
.
getUseType
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"使用方式为空"
);
}
if
(
StringUtil
.
isBlank
(
giftCouponPackage
.
getExchangeAddress
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"兑换地址为空"
);
}
if
(
giftCouponPackage
.
getExchangeAddress
().
length
()>
COUPON_MAX_ADDRESS_LENGTH
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"兑换地址太长,最多"
+
COUPON_MAX_ADDRESS_LENGTH
+
"个字"
);
}
}
}
if
(
null
==
giftCouponPackage
.
getStock
())
{
if
(
null
==
giftCouponPackage
.
getStock
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存为空"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存为空"
);
}
}
if
(
giftCouponPackage
.
getStock
()>
99999
)
{
if
(
giftCouponPackage
.
getStock
()>
COUPON_MAX_STOCK
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存最多
99999"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存最多
"
+
COUPON_MAX_STOCK
);
}
}
if
(
null
==
giftCouponPackage
.
getReceiveLimit
())
{
if
(
null
==
giftCouponPackage
.
getReceiveLimit
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限为空"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限为空"
);
}
}
if
(
giftCouponPackage
.
getReceiveLimit
()>
5
)
{
if
(
giftCouponPackage
.
getReceiveLimit
()>
COUPON_MAX_RECEIVE
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限最多
5
张"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限最多
"
+
COUPON_MAX_RECEIVE
+
"
张"
);
}
}
if
(
null
==
giftCouponPackage
.
getValidDateBegin
()
||
null
==
giftCouponPackage
.
getValidDateEnd
())
{
if
(
null
==
giftCouponPackage
.
getValidDateBegin
()
||
null
==
giftCouponPackage
.
getValidDateEnd
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期为空"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期为空"
);
...
@@ -53,6 +76,9 @@ public class GiftParamCheck {
...
@@ -53,6 +76,9 @@ public class GiftParamCheck {
if
(
DateUtils
.
getDateByStr
(
giftCouponPackage
.
getValidDateEnd
()).
before
(
new
Date
()))
{
if
(
DateUtils
.
getDateByStr
(
giftCouponPackage
.
getValidDateEnd
()).
before
(
new
Date
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期结束时间不能小于当前时间"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期结束时间不能小于当前时间"
);
}
}
if
(
StringUtil
.
isBlank
(
giftCouponPackage
.
getInstructions
())){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"使用说明不能为空"
);
}
}
}
public
void
checkGiftReceiveAddParam
(
GiftReceive
giftReceive
)
{
public
void
checkGiftReceiveAddParam
(
GiftReceive
giftReceive
)
{
...
...
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/GiftCouponPackageDao.java
View file @
504364c6
...
@@ -17,4 +17,12 @@ public interface GiftCouponPackageDao extends BaseDao<GiftCouponPackage> {
...
@@ -17,4 +17,12 @@ public interface GiftCouponPackageDao extends BaseDao<GiftCouponPackage> {
Map
<
Long
,
GiftCouponPackage
>
getMapByIds
(
List
<
Long
>
list
);
Map
<
Long
,
GiftCouponPackage
>
getMapByIds
(
List
<
Long
>
list
);
List
<
Long
>
getPackageIdsBy
(
List
<
Long
>
packageIds
);
Integer
getNoStockCount
(
List
<
Long
>
packageIds
);
void
reduceStock
(
Long
id
);
void
reduceStockBatch
(
List
<
Long
>
packageIds
);
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/GiftReceiveDao.java
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
dao
;
package
com
.
pcloud
.
book
.
giftcoupon
.
dao
;
import
com.pcloud.book.giftcoupon.dto.GiftReceiveDTO
;
import
com.pcloud.book.giftcoupon.dto.GiftReceiveDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.core.dao.BaseDao
;
import
com.pcloud.common.core.dao.BaseDao
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 专享礼券包领取表(GiftReceive)表数据库访问层
* 专享礼券包领取表(GiftReceive)表数据库访问层
...
@@ -28,9 +30,10 @@ public interface GiftReceiveDao extends BaseDao<GiftReceive> {
...
@@ -28,9 +30,10 @@ public interface GiftReceiveDao extends BaseDao<GiftReceive> {
List
<
GiftReceiveDTO
>
getGiftReceiveNumList
(
List
<
Long
>
giftPackageIds
);
List
<
GiftReceiveDTO
>
getGiftReceiveNumList
(
List
<
Long
>
giftPackageIds
);
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
);
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
);
Map
<
Long
,
GiftReceive
>
getMapByIds
(
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/GiftCouponPackageDaoImpl.java
View file @
504364c6
...
@@ -6,6 +6,7 @@ import com.pcloud.common.core.dao.BaseDaoImpl;
...
@@ -6,6 +6,7 @@ import com.pcloud.common.core.dao.BaseDaoImpl;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -17,4 +18,32 @@ public class GiftCouponPackageDaoImpl extends BaseDaoImpl<GiftCouponPackage> imp
...
@@ -17,4 +18,32 @@ public class GiftCouponPackageDaoImpl extends BaseDaoImpl<GiftCouponPackage> imp
public
Map
<
Long
,
GiftCouponPackage
>
getMapByIds
(
List
<
Long
>
list
)
{
public
Map
<
Long
,
GiftCouponPackage
>
getMapByIds
(
List
<
Long
>
list
)
{
return
super
.
getSqlSession
().
selectMap
(
super
.
getStatement
(
"getMapByIds"
),
list
,
"id"
);
return
super
.
getSqlSession
().
selectMap
(
super
.
getStatement
(
"getMapByIds"
),
list
,
"id"
);
}
}
@Override
public
List
<
Long
>
getPackageIdsBy
(
List
<
Long
>
packageIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"packageIds"
,
packageIds
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getPackageIdsBy"
),
map
);
}
@Override
public
Integer
getNoStockCount
(
List
<
Long
>
packageIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"packageIds"
,
packageIds
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getNoStockCount"
),
map
);
}
@Override
public
void
reduceStock
(
Long
id
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
id
);
super
.
getSqlSession
().
update
(
getStatement
(
"reduceStock"
),
map
);
}
@Override
public
void
reduceStockBatch
(
List
<
Long
>
packageIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"packageIds"
,
packageIds
);
super
.
getSqlSession
().
update
(
getStatement
(
"reduceStockBatch"
),
map
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/impl/GiftReceiveDaoImpl.java
View file @
504364c6
...
@@ -43,4 +43,19 @@ public class GiftReceiveDaoImpl extends BaseDaoImpl<GiftReceive> implements Gift
...
@@ -43,4 +43,19 @@ public class GiftReceiveDaoImpl extends BaseDaoImpl<GiftReceive> implements Gift
public
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
)
{
public
List
<
Long
>
getUserReceiveGiftId
(
Long
wechatUserId
)
{
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getUserReceiveGiftId"
),
wechatUserId
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getUserReceiveGiftId"
),
wechatUserId
);
}
}
@Override
public
Map
<
Long
,
GiftReceive
>
getMapByIds
(
List
<
Long
>
giftPackageIds
,
Long
wechatUserId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"giftPackageIds"
,
giftPackageIds
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectMap
(
super
.
getStatement
(
"getMapByIds"
),
map
,
"gift_package_id"
);
}
@Override
public
void
updateReceiveNum
(
List
<
Long
>
receives
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"receives"
,
receives
);
super
.
getSessionTemplate
().
update
(
getStatement
(
"updateReceiveNum"
),
map
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dto/GiftPackageDTO.java
View file @
504364c6
...
@@ -56,4 +56,13 @@ public class GiftPackageDTO {
...
@@ -56,4 +56,13 @@ public class GiftPackageDTO {
* 领取数量
* 领取数量
*/
*/
private
Integer
receiveNum
;
private
Integer
receiveNum
;
/**
* 券类型(2-书币券,1-课程券)
*/
private
Integer
couponType
;
/**
* 使用说明
*/
private
String
instructions
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dto/MyGiftPackageDTO.java
View file @
504364c6
...
@@ -46,4 +46,22 @@ public class MyGiftPackageDTO {
...
@@ -46,4 +46,22 @@ public class MyGiftPackageDTO {
* 未使用数量
* 未使用数量
*/
*/
private
Integer
notUsedNum
;
private
Integer
notUsedNum
;
/**
* 券类型(2-书币券,1-课程券)
*/
private
Integer
couponType
;
/**
* 使用说明
*/
private
String
instructions
;
/**
* 课程券使用方式(1-链接兑取,2-复制码)
*/
private
Integer
useType
;
/**
* 兑换地址
*/
private
String
exchangeAddress
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/entity/GiftCouponPackage.java
View file @
504364c6
...
@@ -42,6 +42,22 @@ public class GiftCouponPackage extends BaseEntity {
...
@@ -42,6 +42,22 @@ public class GiftCouponPackage extends BaseEntity {
*/
*/
private
Integer
receiveLimit
;
private
Integer
receiveLimit
;
/**
* 券类型(2-书币券,1-课程券)
*/
private
Integer
couponType
;
/**
* 使用说明
*/
private
String
instructions
;
/**
* 课程券使用方式(1-链接兑取,2-复制码)
*/
private
Integer
useType
;
/**
* 兑换地址
*/
private
String
exchangeAddress
;
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/enums/CouponTypeEnum.java
0 → 100644
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
enums
;
/**
* 礼券分类
*/
public
enum
CouponTypeEnum
{
/**
* 课程券
*/
COURSE_COUPON
(
1
),
/**
* 书币券
*/
BOOK_COIN_COUPON
(
2
);
public
final
Integer
value
;
CouponTypeEnum
(
Integer
value
)
{
this
.
value
=
value
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/enums/CouponUseTypeEnum.java
0 → 100644
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
enums
;
/**
* 礼券使用方式
*/
public
enum
CouponUseTypeEnum
{
/**
* 链接兑取
*/
LINK
(
1
),
/**
* 复制码
*/
COPY_CODE
(
2
);
public
final
Integer
value
;
CouponUseTypeEnum
(
Integer
value
)
{
this
.
value
=
value
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/facade/GiftCouponPackageFacade.java
View file @
504364c6
...
@@ -13,6 +13,7 @@ import com.pcloud.book.cultivate.entity.CultivateBookUser;
...
@@ -13,6 +13,7 @@ import com.pcloud.book.cultivate.entity.CultivateBookUser;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.giftcoupon.biz.GiftCouponPackageBiz
;
import
com.pcloud.book.giftcoupon.biz.GiftCouponPackageBiz
;
import
com.pcloud.book.giftcoupon.dto.GiftPackageDTO
;
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.dto.MyGiftPackageDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
...
@@ -32,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -32,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.POST
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -87,10 +90,11 @@ public class GiftCouponPackageFacade {
...
@@ -87,10 +90,11 @@ public class GiftCouponPackageFacade {
public
ResponseDto
<
PageBeanNew
<
GiftPackageDTO
>>
list4GiftPackage
(
public
ResponseDto
<
PageBeanNew
<
GiftPackageDTO
>>
list4GiftPackage
(
@RequestParam
(
value
=
"title"
,
required
=
false
)
@ApiParam
(
"礼包券名称"
)
String
title
,
@RequestParam
(
value
=
"title"
,
required
=
false
)
@ApiParam
(
"礼包券名称"
)
String
title
,
@RequestParam
(
value
=
"state"
,
required
=
false
)
@ApiParam
(
"状态"
)
Integer
state
,
@RequestParam
(
value
=
"state"
,
required
=
false
)
@ApiParam
(
"状态"
)
Integer
state
,
@RequestParam
(
value
=
"couponType"
,
required
=
false
)
@ApiParam
(
"券类型"
)
Integer
couponType
,
@RequestParam
(
value
=
"currentPage"
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
"currentPage"
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
"numPerPage"
,
required
=
false
)
Integer
numPerPage
@RequestParam
(
value
=
"numPerPage"
,
required
=
false
)
Integer
numPerPage
)
throws
BizException
,
PermissionException
{
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
giftCouponPackageBiz
.
list4GiftPackage
(
title
,
state
,
currentPage
,
numPerPage
));
return
new
ResponseDto
<>(
giftCouponPackageBiz
.
list4GiftPackage
(
title
,
state
,
c
ouponType
,
c
urrentPage
,
numPerPage
));
}
}
@ApiOperation
(
"新增礼券包领取"
)
@ApiOperation
(
"新增礼券包领取"
)
...
@@ -105,6 +109,17 @@ public class GiftCouponPackageFacade {
...
@@ -105,6 +109,17 @@ public class GiftCouponPackageFacade {
return
new
ResponseDto
<>();
return
new
ResponseDto
<>();
}
}
@ApiOperation
(
"礼券包一键领取"
)
@PostMapping
(
"/createGiftReceiveBatch"
)
public
ResponseDto
<?>
createGiftReceiveBatch
(
@CookieValue
(
value
=
"userInfo"
)
String
userInfo
,
@RequestBody
List
<
Long
>
giftPackageIds
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
giftCouponPackageBiz
.
createGiftReceiveBatch
(
giftPackageIds
,
wechatUserId
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"我的礼券包列表"
)
@ApiOperation
(
"我的礼券包列表"
)
@GetMapping
(
"/list4MyGiftPackage"
)
@GetMapping
(
"/list4MyGiftPackage"
)
public
ResponseDto
<
PageBeanNew
<
MyGiftPackageDTO
>>
list4MyGiftPackage
(
public
ResponseDto
<
PageBeanNew
<
MyGiftPackageDTO
>>
list4MyGiftPackage
(
...
@@ -121,10 +136,10 @@ public class GiftCouponPackageFacade {
...
@@ -121,10 +136,10 @@ public class GiftCouponPackageFacade {
@PostMapping
(
"/useGiftCoupon"
)
@PostMapping
(
"/useGiftCoupon"
)
public
ResponseDto
<?>
useGiftCoupon
(
public
ResponseDto
<?>
useGiftCoupon
(
@CookieValue
(
value
=
"userInfo"
)
String
userInfo
,
@CookieValue
(
value
=
"userInfo"
)
String
userInfo
,
@Request
Param
(
value
=
"giftPackageId"
,
required
=
false
)
@ApiParam
(
"礼券id"
)
Long
giftPackageId
@Request
Body
GiftReceiveDTO
giftReceiveDTO
)
throws
BizException
,
PermissionException
{
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
giftCouponPackageBiz
.
useGiftCoupon
(
wechatUserId
,
gift
PackageId
);
giftCouponPackageBiz
.
useGiftCoupon
(
wechatUserId
,
gift
ReceiveDTO
.
getGiftPackageId
()
);
return
new
ResponseDto
<>();
return
new
ResponseDto
<>();
}
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/service/impl/GiftCouponServiceImpl.java
0 → 100644
View file @
504364c6
package
com
.
pcloud
.
book
.
giftcoupon
.
service
.
impl
;
import
com.pcloud.book.giftcoupon.biz.GiftCouponPackageBiz
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.service.GiftCouponService
;
import
com.pcloud.book.giftcoupon.vo.GiftCouponVo
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.utils.ResponseHandleUtil
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
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
(
"giftCouponService"
)
@RequestMapping
(
"giftCouponService"
)
public
class
GiftCouponServiceImpl
implements
GiftCouponService
{
@Autowired
private
GiftCouponPackageBiz
giftCouponPackageBiz
;
@Override
@RequestMapping
(
value
=
"/getCouponBaseInfo"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
ResponseDto
<
GiftCouponVo
>>
getCouponBaseInfo
(
@RequestParam
(
"couponId"
)
Long
couponId
)
throws
BizException
{
GiftCouponPackage
giftPackage
=
giftCouponPackageBiz
.
getGiftPackage
(
couponId
);
GiftCouponVo
giftCouponVo
=
new
GiftCouponVo
();
BeanUtils
.
copyProperties
(
giftPackage
,
giftCouponVo
);
return
ResponseHandleUtil
.
toResponse
(
giftCouponVo
);
}
}
pcloud-service-book/src/main/resources/mapper/giftConpon/GiftCouplePackageDao.xml
View file @
504364c6
...
@@ -12,16 +12,23 @@
...
@@ -12,16 +12,23 @@
<result
property=
"receiveLimit"
column=
"receive_limit"
jdbcType=
"INTEGER"
/>
<result
property=
"receiveLimit"
column=
"receive_limit"
jdbcType=
"INTEGER"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"couponType"
column=
"coupon_type"
jdbcType=
"INTEGER"
/>
<result
property=
"instructions"
column=
"instructions"
jdbcType=
"VARCHAR"
/>
<result
property=
"useType"
column=
"use_type"
jdbcType=
"INTEGER"
/>
<result
property=
"exchangeAddress"
column=
"exchange_address"
jdbcType=
"VARCHAR"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
coupon_type,instructions,use_type,exchange_address
</sql>
</sql>
<!--查询单个-->
<!--查询单个-->
<select
id=
"getById"
resultMap=
"GiftCouplePackageMap"
>
<select
id=
"getById"
resultMap=
"GiftCouplePackageMap"
>
select
select
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
coupon_type,instructions,use_type,exchange_address
from book.gift_coupon_package
from book.gift_coupon_package
where id = #{id}
where id = #{id}
and is_delete=0
and is_delete=0
...
@@ -30,7 +37,8 @@
...
@@ -30,7 +37,8 @@
<!--查询指定行数据-->
<!--查询指定行数据-->
<select
id=
"queryAllByLimit"
resultMap=
"GiftCouplePackageMap"
>
<select
id=
"queryAllByLimit"
resultMap=
"GiftCouplePackageMap"
>
select
select
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
coupon_type,instructions,use_type,exchange_address
from book.gift_coupon_package
from book.gift_coupon_package
limit #{offset}, #{limit}
limit #{offset}, #{limit}
</select>
</select>
...
@@ -38,7 +46,8 @@
...
@@ -38,7 +46,8 @@
<!--通过实体作为筛选条件查询-->
<!--通过实体作为筛选条件查询-->
<select
id=
"queryAll"
resultMap=
"GiftCouplePackageMap"
>
<select
id=
"queryAll"
resultMap=
"GiftCouplePackageMap"
>
select
select
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
coupon_type,instructions,use_type,exchange_address
from book.gift_coupon_package
from book.gift_coupon_package
<where>
<where>
<if
test=
"id != null"
>
<if
test=
"id != null"
>
...
@@ -79,8 +88,10 @@
...
@@ -79,8 +88,10 @@
<!--新增所有列-->
<!--新增所有列-->
<insert
id=
"insert"
parameterType=
"com.pcloud.book.giftcoupon.entity.GiftCouponPackage"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.giftcoupon.entity.GiftCouponPackage"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into book.gift_coupon_package(cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete)
insert into book.gift_coupon_package(cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
values (#{coverPic}, #{title}, #{validDateBegin}, #{validDateEnd}, #{denomination}, #{stock}, #{receiveLimit}, now(), now(), 0)
coupon_type,instructions,use_type,exchange_address)
values (#{coverPic}, #{title}, #{validDateBegin}, #{validDateEnd}, #{denomination}, #{stock}, #{receiveLimit}, now(), now(), 0,
#{couponType},#{instructions},#{useType},#{exchangeAddress})
</insert>
</insert>
<!--通过主键修改数据-->
<!--通过主键修改数据-->
...
@@ -111,6 +122,18 @@
...
@@ -111,6 +122,18 @@
<if
test=
"createTime != null"
>
<if
test=
"createTime != null"
>
create_time = #{createTime},
create_time = #{createTime},
</if>
</if>
<if
test=
"couponType != null"
>
coupon_type = #{couponType},
</if>
<if
test=
"instructions != null"
>
instructions = #{instructions},
</if>
<if
test=
"useType != null"
>
use_type = #{useType},
</if>
<if
test=
"exchangeAddress != null"
>
exchange_address = #{exchangeAddress},
</if>
update_time = now()
update_time = now()
</set>
</set>
where id = #{id}
where id = #{id}
...
@@ -131,10 +154,13 @@
...
@@ -131,10 +154,13 @@
a.stock,
a.stock,
a.valid_date_begin validDateBegin,
a.valid_date_begin validDateBegin,
a.valid_date_end validDateEnd,
a.valid_date_end validDateEnd,
if(NOW()
<![CDATA[ < ]]>
a.valid_date_begin,1,if(NOW() between a.valid_date_begin and a.valid_date_end,2,3)) state
if(NOW()
<![CDATA[ < ]]>
a.valid_date_begin,1,if(NOW() between a.valid_date_begin and a.valid_date_end,2,3)) state,
a.coupon_type couponType,
a.instructions instructions
from
from
gift_coupon_package a
gift_coupon_package a
where a.is_delete=0
where a.is_delete=0
and a.stock>0
<if
test=
"title !=null and title !=''"
>
<if
test=
"title !=null and title !=''"
>
and a.title like concat('%',#{title},'%')
and a.title like concat('%',#{title},'%')
</if>
</if>
...
@@ -150,6 +176,9 @@
...
@@ -150,6 +176,9 @@
<if
test=
"state !=null and state==4"
>
<if
test=
"state !=null and state==4"
>
and now()
<![CDATA[ <= ]]>
a.valid_date_end
and now()
<![CDATA[ <= ]]>
a.valid_date_end
</if>
</if>
<if
test=
"couponType !=null"
>
and a.coupon_type=#{couponType}
</if>
GROUP BY a.id
GROUP BY a.id
order by a.update_time desc
order by a.update_time desc
...
@@ -165,6 +194,40 @@
...
@@ -165,6 +194,40 @@
</foreach>
</foreach>
</select>
</select>
<select
id=
"reduceStock"
parameterType=
"map"
>
update gift_coupon_package set stock=stock-1
where id=#{id}
</select>
<select
id=
"reduceStockBatch"
parameterType=
"map"
>
update gift_coupon_package set stock=stock-1
where id in
<foreach
collection=
"packageIds"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
${item}
</foreach>
</select>
<select
id=
"getPackageIdsBy"
parameterType=
"map"
resultType=
"Long"
>
select distinct id
from gift_coupon_package
where is_delete=0
and id in
<foreach
collection=
"packageIds"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
${item}
</foreach>
</select>
<select
id=
"getNoStockCount"
parameterType=
"map"
resultType=
"Integer"
>
select ifnull(count(1),0)
from gift_coupon_package
where is_delete=0
and id in
<foreach
collection=
"packageIds"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
${item}
</foreach>
and stock
<![CDATA[ <= ]]>
0
</select>
</mapper>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/giftConpon/GiftReceiveDao.xml
View file @
504364c6
...
@@ -12,6 +12,10 @@
...
@@ -12,6 +12,10 @@
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, wechat_user_id, gift_package_id, receive_num, used_num, create_time, update_time
</sql>
<!--查询单个-->
<!--查询单个-->
<select
id=
"queryById"
resultMap=
"GiftReceiveMap"
>
<select
id=
"queryById"
resultMap=
"GiftReceiveMap"
>
select
select
...
@@ -64,6 +68,14 @@
...
@@ -64,6 +68,14 @@
values (#{wechatUserId}, #{giftPackageId}, #{receiveNum}, #{usedNum}, now(), now())
values (#{wechatUserId}, #{giftPackageId}, #{receiveNum}, #{usedNum}, now(), now())
</insert>
</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, receive_num, used_num, create_time, update_time)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.wechatUserId}, #{item.giftPackageId}, #{item.receiveNum}, #{item.usedNum}, now(), now())
</foreach>
</insert>
<!--通过主键修改数据-->
<!--通过主键修改数据-->
<update
id=
"update"
>
<update
id=
"update"
>
update book.gift_receive
update book.gift_receive
...
@@ -95,7 +107,7 @@
...
@@ -95,7 +107,7 @@
<select
id=
"getGiftReceive"
parameterType=
"map"
resultMap=
"GiftReceiveMap"
>
<select
id=
"getGiftReceive"
parameterType=
"map"
resultMap=
"GiftReceiveMap"
>
select
select
id, wechat_user_id, gift_package_id, receive_num
id, wechat_user_id, gift_package_id, receive_num, used_num, create_time, update_time
from book.gift_receive
from book.gift_receive
where wechat_user_id=#{wechatUserId}
where wechat_user_id=#{wechatUserId}
and gift_package_id=#{giftPackageId}
and gift_package_id=#{giftPackageId}
...
@@ -117,7 +129,11 @@
...
@@ -117,7 +129,11 @@
a.valid_date_begin validDateBegin,
a.valid_date_begin validDateBegin,
a.valid_date_end validDateEnd,
a.valid_date_end validDateEnd,
a.id id,
a.id id,
(b.receive_num-ifnull(b.used_num,0)) noUsedNum
(b.receive_num-ifnull(b.used_num,0)) noUsedNum,
a.coupon_type couponType,
a.instructions instructions,
a.use_type useType,
a.exchange_address exchangeAddress
from
from
gift_receive b LEFT JOIN gift_coupon_package a
gift_receive b LEFT JOIN gift_coupon_package a
on a.id=b.gift_package_id
on a.id=b.gift_package_id
...
@@ -149,4 +165,23 @@
...
@@ -149,4 +165,23 @@
where wechat_user_id=#{wechatUserId}
where wechat_user_id=#{wechatUserId}
</select>
</select>
<select
id=
"getMapByIds"
parameterType=
"map"
resultMap=
"GiftReceiveMap"
>
select
<include
refid=
"Base_Column_List"
/>
from gift_receive
where wechat_user_id=#{wechatUserId}
and gift_package_id in
<foreach
collection=
"giftPackageIds"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
${item}
</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}
</foreach>
</select>
</mapper>
</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