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
1c76296d
Commit
1c76296d
authored
Apr 19, 2020
by
裴大威
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat-zy-1002779' into 'master'
1002779小睿紧急需求-专享礼券包 See merge request rays/pcloud-book!645
parents
c180a126
c8905c39
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
816 additions
and
0 deletions
+816
-0
GiftCouponPackageBiz.java
.../com/pcloud/book/giftcoupon/biz/GiftCouponPackageBiz.java
+20
-0
GiftCouponPackageBizImpl.java
...ud/book/giftcoupon/biz/impl/GiftCouponPackageBizImpl.java
+97
-0
GiftParamCheck.java
...java/com/pcloud/book/giftcoupon/check/GiftParamCheck.java
+72
-0
GiftCouponPackageDao.java
.../com/pcloud/book/giftcoupon/dao/GiftCouponPackageDao.java
+18
-0
GiftReceiveDao.java
...n/java/com/pcloud/book/giftcoupon/dao/GiftReceiveDao.java
+54
-0
GiftCouponPackageDaoImpl.java
...ud/book/giftcoupon/dao/impl/GiftCouponPackageDaoImpl.java
+13
-0
GiftReceiveDaoImpl.java
...m/pcloud/book/giftcoupon/dao/impl/GiftReceiveDaoImpl.java
+38
-0
GiftPackageDTO.java
...n/java/com/pcloud/book/giftcoupon/dto/GiftPackageDTO.java
+59
-0
GiftCouponPackage.java
.../com/pcloud/book/giftcoupon/entity/GiftCouponPackage.java
+48
-0
GiftReceive.java
...n/java/com/pcloud/book/giftcoupon/entity/GiftReceive.java
+29
-0
GiftCouponPackageFacade.java
...cloud/book/giftcoupon/facade/GiftCouponPackageFacade.java
+106
-0
GiftCouplePackageDao.xml
...main/resources/mapper/giftConpon/GiftCouplePackageDao.xml
+156
-0
GiftReceiveDao.xml
...k/src/main/resources/mapper/giftConpon/GiftReceiveDao.xml
+106
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/biz/GiftCouponPackageBiz.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
biz
;
import
com.pcloud.book.giftcoupon.dto.GiftPackageDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.page.PageBeanNew
;
public
interface
GiftCouponPackageBiz
{
void
createGiftPackage
(
GiftCouponPackage
giftCouponPackage
);
void
updateGiftPackage
(
GiftCouponPackage
giftCouponPackage
);
GiftCouponPackage
getGiftPackage
(
Long
id
);
void
deleteGiftPackage
(
Long
id
);
void
createGiftReceive
(
GiftReceive
giftReceive
);
PageBeanNew
<
GiftPackageDTO
>
list4GiftPackage
(
String
title
,
Integer
state
,
Integer
currentPage
,
Integer
numPerPage
);
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/biz/impl/GiftCouponPackageBizImpl.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
biz
.
impl
;
import
com.pcloud.book.base.exception.BookBizException
;
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.GiftPackageDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
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
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
@Component
(
"giftCouponPackageBiz"
)
public
class
GiftCouponPackageBizImpl
implements
GiftCouponPackageBiz
{
@Autowired
private
GiftCouponPackageDao
giftCouponPackageDao
;
@Autowired
private
GiftReceiveDao
giftReceiveDao
;
@Autowired
private
GiftParamCheck
giftParamCheck
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增专享礼包"
)
@Override
public
void
createGiftPackage
(
GiftCouponPackage
giftCouponPackage
)
{
giftParamCheck
.
checkGiftAddParam
(
giftCouponPackage
);
giftCouponPackageDao
.
insert
(
giftCouponPackage
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"修改专享礼包"
)
@Override
public
void
updateGiftPackage
(
GiftCouponPackage
giftCouponPackage
)
{
giftParamCheck
.
checkGiftAddParam
(
giftCouponPackage
);
giftCouponPackageDao
.
update
(
giftCouponPackage
);
}
@Override
public
GiftCouponPackage
getGiftPackage
(
Long
id
)
{
return
giftCouponPackageDao
.
getById
(
id
);
}
@Override
public
void
deleteGiftPackage
(
Long
id
)
{
//todo 删除应该有限制
giftCouponPackageDao
.
deleteById
(
id
);
}
@Override
public
PageBeanNew
<
GiftPackageDTO
>
list4GiftPackage
(
String
title
,
Integer
state
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"title"
,
title
);
paramMap
.
put
(
"state"
,
state
);
PageBeanNew
<
GiftPackageDTO
>
pageBeanNew
=
giftCouponPackageDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
paramMap
,
"list4GiftPackage"
);
if
(
pageBeanNew
==
null
||
ListUtils
.
isEmpty
(
pageBeanNew
.
getRecordList
()))
{
return
new
PageBeanNew
<>(
currentPage
,
numPerPage
,
new
ArrayList
<>());
}
return
pageBeanNew
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增专享礼包"
)
@Override
public
void
createGiftReceive
(
GiftReceive
giftReceive
)
{
giftParamCheck
.
checkGiftReceiveAddParam
(
giftReceive
);
GiftCouponPackage
giftCouponPackage
=
giftCouponPackageDao
.
getById
(
giftReceive
.
getGiftPackageId
());
if
(
null
==
giftCouponPackage
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"当前奖券包不存在"
);
}
GiftReceive
receive
=
giftReceiveDao
.
getGiftReceive
(
giftReceive
.
getWechatUserId
(),
giftReceive
.
getGiftPackageId
());
if
(
null
==
receive
){
giftReceive
.
setReceiveNum
(
1
);
giftReceive
.
setUsedNum
(
0
);
giftReceiveDao
.
insert
(
giftReceive
);
}
else
{
if
(
receive
.
getReceiveNum
()>=
giftCouponPackage
.
getReceiveLimit
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取数量已超过奖券包最大领取数量"
);
}
receive
.
setReceiveNum
(
receive
.
getReceiveNum
()+
1
);
giftReceiveDao
.
update
(
receive
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/check/GiftParamCheck.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
check
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
lombok.extern.slf4j.Slf4j
;
@Component
(
"giftParamCheck"
)
@Slf4j
public
class
GiftParamCheck
{
public
void
checkGiftAddParam
(
GiftCouponPackage
giftCouponPackage
)
{
if
(
null
==
giftCouponPackage
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数为空"
);
}
if
(
StringUtil
.
isEmpty
(
giftCouponPackage
.
getCoverPic
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"封面为空"
);
}
if
(
StringUtil
.
isEmpty
(
giftCouponPackage
.
getTitle
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"名称为空"
);
}
if
(
giftCouponPackage
.
getTitle
().
length
()>
20
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"标题名称最多20个字"
);
}
if
(
null
==
giftCouponPackage
.
getDenomination
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"面额为空"
);
}
if
(
giftCouponPackage
.
getDenomination
()>
999
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"面额最多999"
);
}
if
(
null
==
giftCouponPackage
.
getStock
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存为空"
);
}
if
(
giftCouponPackage
.
getStock
()>
99999
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"库存最多99999"
);
}
if
(
null
==
giftCouponPackage
.
getReceiveLimit
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限为空"
);
}
if
(
giftCouponPackage
.
getReceiveLimit
()>
5
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"领取上限最多5张"
);
}
if
(
null
==
giftCouponPackage
.
getValidDateBegin
()
||
null
==
giftCouponPackage
.
getValidDateEnd
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期为空"
);
}
if
(
DateUtils
.
getDateByStr
(
giftCouponPackage
.
getValidDateBegin
()).
after
(
DateUtils
.
getDateByStr
((
giftCouponPackage
.
getValidDateEnd
()))))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期开始时间不能大于结束时间"
);
}
if
(
DateUtils
.
getDateByStr
(
giftCouponPackage
.
getValidDateEnd
()).
before
(
new
Date
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"有效期结束时间不能小于当前时间"
);
}
}
public
void
checkGiftReceiveAddParam
(
GiftReceive
giftReceive
)
{
if
(
null
==
giftReceive
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数为空"
);
}
if
(
null
==
giftReceive
.
getWechatUserId
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户为空"
);
}
if
(
null
==
giftReceive
.
getGiftPackageId
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"奖券包id为空"
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/GiftCouponPackageDao.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
dao
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.common.core.dao.BaseDao
;
/**
* 专享礼券包表(GiftCouponPackage)表数据库访问层
*
* @author makejava
* @since 2020-04-19 14:59:21
*/
public
interface
GiftCouponPackageDao
extends
BaseDao
<
GiftCouponPackage
>
{
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/GiftReceiveDao.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
dao
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.core.dao.BaseDao
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 专享礼券包领取表(GiftReceive)表数据库访问层
*
* @author makejava
* @since 2020-04-19 14:59:34
*/
public
interface
GiftReceiveDao
extends
BaseDao
<
GiftReceive
>
{
/**
* 通过ID查询单条数据
*
* @return 实例对象
*/
GiftReceive
getGiftReceive
(
Long
wechatUserId
,
Long
giftPackageId
);
/**
* 查询指定行数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List
<
GiftReceive
>
queryAllByLimit
(
@Param
(
"offset"
)
int
offset
,
@Param
(
"limit"
)
int
limit
);
/**
* 通过实体作为筛选条件查询
*
* @param giftReceive 实例对象
* @return 对象列表
*/
List
<
GiftReceive
>
queryAll
(
GiftReceive
giftReceive
);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int
deleteById
(
Integer
id
);
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/impl/GiftCouponPackageDaoImpl.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
dao
.
impl
;
import
com.pcloud.book.giftcoupon.dao.GiftCouponPackageDao
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
@Component
(
"giftCouponPackageDao"
)
public
class
GiftCouponPackageDaoImpl
extends
BaseDaoImpl
<
GiftCouponPackage
>
implements
GiftCouponPackageDao
{
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dao/impl/GiftReceiveDaoImpl.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
dao
.
impl
;
import
com.pcloud.book.giftcoupon.dao.GiftReceiveDao
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
(
"giftReceiveDao"
)
public
class
GiftReceiveDaoImpl
extends
BaseDaoImpl
<
GiftReceive
>
implements
GiftReceiveDao
{
@Override
public
GiftReceive
getGiftReceive
(
Long
wechatUserId
,
Long
giftPackageId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"giftPackageId"
,
giftPackageId
);
return
super
.
getSessionTemplate
().
selectOne
(
getStatement
(
"getGiftReceive"
),
map
);
}
@Override
public
List
<
GiftReceive
>
queryAllByLimit
(
int
offset
,
int
limit
)
{
return
null
;
}
@Override
public
List
<
GiftReceive
>
queryAll
(
GiftReceive
giftReceive
)
{
return
null
;
}
@Override
public
int
deleteById
(
Integer
id
)
{
return
0
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/dto/GiftPackageDTO.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.util.Date
;
import
lombok.Data
;
@Data
public
class
GiftPackageDTO
{
/**
* 封面图
*/
private
Long
id
;
/**
* 封面图
*/
private
String
coverPic
;
/**
* 名称
*/
private
String
title
;
/**
* 有效期开始时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
validDateBegin
;
/**
* 有效期结束时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
validDateEnd
;
/**
* 面额
*/
private
Integer
denomination
;
private
Integer
stock
;
/**
* 每人领取上限
*/
private
Integer
receiveLimit
;
/**
* (1-未开始,2-进行中,3-已结束)
*/
private
Integer
state
;
/**
* 领取数量
*/
private
Integer
receiveNum
;
}
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/entity/GiftCouponPackage.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
java.util.Date
;
import
lombok.Data
;
/**
* 专享礼券包表(GiftCouponPackage)实体类
*
* @author makejava
* @since 2020-04-19 14:59:19
*/
@Data
public
class
GiftCouponPackage
extends
BaseEntity
{
/**
* 封面图
*/
private
String
coverPic
;
/**
* 名称
*/
private
String
title
;
/**
* 有效期开始时间
*/
private
String
validDateBegin
;
/**
* 有效期结束时间
*/
private
String
validDateEnd
;
/**
* 面额
*/
private
Integer
denomination
;
private
Integer
stock
;
/**
* 每人领取上限
*/
private
Integer
receiveLimit
;
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/entity/GiftReceive.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
lombok.Data
;
/**
* 专享礼券包领取表(GiftReceive)实体类
*
* @author makejava
* @since 2020-04-19 14:59:34
*/
@Data
public
class
GiftReceive
extends
BaseEntity
{
private
Long
wechatUserId
;
private
Long
giftPackageId
;
/**
* 领取数量
*/
private
Integer
receiveNum
;
/**
* 使用数量
*/
private
Integer
usedNum
;
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/giftcoupon/facade/GiftCouponPackageFacade.java
0 → 100644
View file @
1c76296d
package
com
.
pcloud
.
book
.
giftcoupon
.
facade
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.cultivate.biz.CultivateBiz
;
import
com.pcloud.book.cultivate.dto.CreateCultivateDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.GiveEnergyDTO
;
import
com.pcloud.book.cultivate.dto.HoldSeatDTO
;
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.GiftPackageDTO
;
import
com.pcloud.book.giftcoupon.entity.GiftCouponPackage
;
import
com.pcloud.book.giftcoupon.entity.GiftReceive
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.permission.PermissionException
;
import
com.pcloud.common.utils.NumberUtil
;
import
com.pcloud.common.utils.cookie.Cookie
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.ws.rs.POST
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
@Api
(
"专享礼券包"
)
@RestController
(
"giftCouponPackageFacade"
)
@RequestMapping
(
"giftCouponPackage"
)
public
class
GiftCouponPackageFacade
{
@Autowired
private
GiftCouponPackageBiz
giftCouponPackageBiz
;
@ApiOperation
(
"新增礼券包"
)
@PostMapping
(
"/createGiftPackage"
)
public
ResponseDto
<?>
createGiftPackage
(
@RequestBody
GiftCouponPackage
giftCouponPackage
)
throws
BizException
,
PermissionException
{
giftCouponPackageBiz
.
createGiftPackage
(
giftCouponPackage
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"修改礼券包"
)
@PostMapping
(
"/updateGiftPackage"
)
public
ResponseDto
<?>
updateGiftPackage
(
@RequestBody
GiftCouponPackage
giftCouponPackage
)
throws
BizException
,
PermissionException
{
giftCouponPackageBiz
.
updateGiftPackage
(
giftCouponPackage
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"获取礼券包"
)
@GetMapping
(
"/getGiftPackage"
)
public
ResponseDto
<?>
getGiftPackage
(
@RequestParam
(
"id"
)
@ApiParam
(
"礼券包id"
)
Long
id
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
giftCouponPackageBiz
.
getGiftPackage
(
id
));
}
@ApiOperation
(
"删除礼券包"
)
@GetMapping
(
"/deleteGiftPackage"
)
public
ResponseDto
<?>
deleteGiftPackage
(
@RequestParam
(
"id"
)
@ApiParam
(
"礼券包id"
)
Long
id
)
throws
BizException
,
PermissionException
{
giftCouponPackageBiz
.
deleteGiftPackage
(
id
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"礼券包列表"
)
@GetMapping
(
"/list4GiftPackage"
)
public
ResponseDto
<?>
list4GiftPackage
(
@RequestParam
(
value
=
"title"
,
required
=
false
)
@ApiParam
(
"礼包券名称"
)
String
title
,
@RequestParam
(
value
=
"state"
,
required
=
false
)
@ApiParam
(
"状态"
)
Integer
state
,
@RequestParam
(
value
=
"currentPage"
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
"numPerPage"
,
required
=
false
)
Integer
numPerPage
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
giftCouponPackageBiz
.
list4GiftPackage
(
title
,
state
,
currentPage
,
numPerPage
));
}
@ApiOperation
(
"新增礼券包领取"
)
@PostMapping
(
"/createGiftReceive"
)
public
ResponseDto
<?>
createGiftReceive
(
@CookieValue
(
value
=
"userInfo"
)
String
userInfo
,
@RequestBody
GiftReceive
GiftReceive
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
GiftReceive
.
setWechatUserId
(
wechatUserId
);
giftCouponPackageBiz
.
createGiftReceive
(
GiftReceive
);
return
new
ResponseDto
<>();
}
}
pcloud-service-book/src/main/resources/mapper/giftConpon/GiftCouplePackageDao.xml
0 → 100644
View file @
1c76296d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.pcloud.book.giftcoupon.dao.impl.GiftCouponPackageDaoImpl"
>
<resultMap
type=
"com.pcloud.book.giftcoupon.entity.GiftCouponPackage"
id=
"GiftCouplePackageMap"
>
<result
property=
"id"
column=
"id"
jdbcType=
"INTEGER"
/>
<result
property=
"coverPic"
column=
"cover_pic"
jdbcType=
"VARCHAR"
/>
<result
property=
"title"
column=
"title"
jdbcType=
"VARCHAR"
/>
<result
property=
"validDateBegin"
column=
"valid_date_begin"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"validDateEnd"
column=
"valid_date_end"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"denomination"
column=
"denomination"
jdbcType=
"INTEGER"
/>
<result
property=
"stock"
column=
"stock"
jdbcType=
"INTEGER"
/>
<result
property=
"receiveLimit"
column=
"receive_limit"
jdbcType=
"INTEGER"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<!--查询单个-->
<select
id=
"getById"
resultMap=
"GiftCouplePackageMap"
>
select
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
from book.gift_coupon_package
where id = #{id}
and is_delete=0
</select>
<!--查询指定行数据-->
<select
id=
"queryAllByLimit"
resultMap=
"GiftCouplePackageMap"
>
select
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
from book.gift_coupon_package
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select
id=
"queryAll"
resultMap=
"GiftCouplePackageMap"
>
select
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete
from book.gift_coupon_package
<where>
<if
test=
"id != null"
>
and id = #{id}
</if>
<if
test=
"coverPic != null and coverPic != ''"
>
and cover_pic = #{coverPic}
</if>
<if
test=
"title != null and title != ''"
>
and title = #{title}
</if>
<if
test=
"validDateBegin != null"
>
and valid_date_begin = #{validDateBegin}
</if>
<if
test=
"validDateEnd != null"
>
and valid_date_end = #{validDateEnd}
</if>
<if
test=
"denomination != null"
>
and denomination = #{denomination}
</if>
<if
test=
"stock != null"
>
and stock = #{stock}
</if>
<if
test=
"receiveLimit != null"
>
and receive_limit = #{receiveLimit}
</if>
<if
test=
"createTime != null"
>
and create_time = #{createTime}
</if>
<if
test=
"updateTime != null"
>
and update_time = #{updateTime}
</if>
<if
test=
"isDelete != null"
>
and is_delete = #{isDelete}
</if>
</where>
</select>
<!--新增所有列-->
<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)
values (#{coverPic}, #{title}, #{validDateBegin}, #{validDateEnd}, #{denomination}, #{stock}, #{receiveLimit}, now(), now(), 0)
</insert>
<!--通过主键修改数据-->
<update
id=
"update"
>
update book.gift_coupon_package
<set>
<if
test=
"coverPic != null and coverPic != ''"
>
cover_pic = #{coverPic},
</if>
<if
test=
"title != null and title != ''"
>
title = #{title},
</if>
<if
test=
"validDateBegin != null"
>
valid_date_begin = #{validDateBegin},
</if>
<if
test=
"validDateEnd != null"
>
valid_date_end = #{validDateEnd},
</if>
<if
test=
"denomination != null"
>
denomination = #{denomination},
</if>
<if
test=
"stock != null"
>
stock = #{stock},
</if>
<if
test=
"receiveLimit != null"
>
receive_limit = #{receiveLimit},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
update_time = now()
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete
id=
"deleteById"
>
update book.gift_coupon_package set is_delete=1 where id = #{id}
</delete>
<select
id=
"list4GiftPackage"
parameterType=
"map"
resultType=
"com.pcloud.book.giftcoupon.dto.GiftPackageDTO"
>
select
a.id id,
a.title title,
a.cover_pic coverPic,
a.denomination denomination,
a.receive_limit receiveLimit,
a.stock,
ifnull(sum(b.receive_num),0) receiveNum,
a.valid_date_begin validDateBegin,
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
from
gift_coupon_package a LEFT JOIN gift_receive b
on a.id=b.gift_package_id
where a.is_delete=0
<if
test=
"title !=null and title !=''"
>
and a.title like concat('%',#{title},'%')
</if>
<if
test=
"state !=null and state==1"
>
and now()
<![CDATA[ < ]]>
a.valid_date_begin
</if>
<if
test=
"state !=null and state==2"
>
and now() between a.valid_date_begin and a.valid_date_end
</if>
<if
test=
"state !=null and state==3"
>
and now() > a.valid_date_end
</if>
GROUP BY a.id
order by a.update_time desc
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/giftConpon/GiftReceiveDao.xml
0 → 100644
View file @
1c76296d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.pcloud.book.giftcoupon.dao.impl.GiftReceiveDaoImpl"
>
<resultMap
type=
"com.pcloud.book.giftcoupon.entity.GiftReceive"
id=
"GiftReceiveMap"
>
<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=
"receiveNum"
column=
"receive_num"
jdbcType=
"INTEGER"
/>
<result
property=
"usedNum"
column=
"used_num"
jdbcType=
"INTEGER"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<!--查询单个-->
<select
id=
"queryById"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, receive_num, used_num, create_time, update_time
from book.gift_receive
where id = #{id}
</select>
<!--查询指定行数据-->
<select
id=
"queryAllByLimit"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, receive_num, used_num, create_time, update_time
from book.gift_receive
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select
id=
"queryAll"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, receive_num, used_num, create_time, update_time
from book.gift_receive
<where>
<if
test=
"id != null"
>
and id = #{id}
</if>
<if
test=
"wechatUserId != null"
>
and wechat_user_id = #{wechatUserId}
</if>
<if
test=
"giftPackageId != null"
>
and gift_package_id = #{giftPackageId}
</if>
<if
test=
"receiveNum != null"
>
and receive_num = #{receiveNum}
</if>
<if
test=
"usedNum != null"
>
and used_num = #{usedNum}
</if>
<if
test=
"createTime != null"
>
and create_time = #{createTime}
</if>
<if
test=
"updateTime != null"
>
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增所有列-->
<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, receive_num, used_num, create_time, update_time)
values (#{wechatUserId}, #{giftPackageId}, #{receiveNum}, #{usedNum}, now(), now())
</insert>
<!--通过主键修改数据-->
<update
id=
"update"
>
update book.gift_receive
<set>
<if
test=
"wechatUserId != null"
>
wechat_user_id = #{wechatUserId},
</if>
<if
test=
"giftPackageId != null"
>
gift_package_id = #{giftPackageId},
</if>
<if
test=
"receiveNum != null"
>
receive_num = #{receiveNum},
</if>
<if
test=
"usedNum != null"
>
used_num = #{usedNum},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
update_time = #{updateTime},
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete
id=
"deleteById"
>
delete from book.gift_receive where id = #{id}
</delete>
<select
id=
"getGiftReceive"
parameterType=
"map"
resultMap=
"GiftReceiveMap"
>
select
id, wechat_user_id, gift_package_id, receive_num
from book.gift_receive
where wechat_user_id=#{wechatUserId}
and gift_package_id=#{giftPackageId}
limit 1
</select>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment