Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
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
hooloo
ms
soss
Commits
bc8ffd75
Commit
bc8ffd75
authored
Jul 22, 2022
by
caiyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加优惠券部分接口
parent
6cd2da43
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
365 additions
and
40 deletions
+365
-40
pom.xml
+4
-1
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponCategoryController.java
+36
-10
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponController.java
+24
-0
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponRuleController.java
+0
-19
soss-system/pom.xml
+26
-2
soss-system/src/main/java/com/soss/system/domain/CouponRule.java
+5
-0
soss-system/src/main/java/com/soss/system/domain/po/CouponPo.java
+120
-0
soss-system/src/main/java/com/soss/system/domain/vo/CouponVo.java
+13
-0
soss-system/src/main/java/com/soss/system/mapper/CouponCategoryMapper.java
+8
-0
soss-system/src/main/java/com/soss/system/service/ICouponCategoryService.java
+5
-1
soss-system/src/main/java/com/soss/system/service/impl/CouponCategoryServiceImpl.java
+34
-4
soss-system/src/main/java/com/soss/system/service/impl/CouponServiceImpl.java
+81
-0
soss-system/src/main/resources/mapper/system/CouponCategoryMapper.xml
+7
-2
soss-system/src/main/resources/mapper/system/CouponMapper.xml
+1
-1
soss-system/src/main/resources/mapper/system/CouponRuleMapper.xml
+1
-0
No files found.
pom.xml
View file @
bc8ffd75
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
<kaptcha.version>
2.3.2
</kaptcha.version>
<kaptcha.version>
2.3.2
</kaptcha.version>
<mybatis-spring-boot.version>
2.2.2
</mybatis-spring-boot.version>
<mybatis-spring-boot.version>
2.2.2
</mybatis-spring-boot.version>
<pagehelper.boot.version>
1.4.1
</pagehelper.boot.version>
<pagehelper.boot.version>
1.4.1
</pagehelper.boot.version>
<fastjson.version>
1.2.79
</fastjson.version>
<log4j2.version>
2.17.2
</log4j2.version>
<fastjson.version>
1.2.83
</fastjson.version>
<oshi.version>
6.1.2
</oshi.version>
<oshi.version>
6.1.2
</oshi.version>
<jna.version>
5.10.0
</jna.version>
<jna.version>
5.10.0
</jna.version>
<commons.io.version>
2.11.0
</commons.io.version>
<commons.io.version>
2.11.0
</commons.io.version>
...
@@ -31,6 +32,8 @@
...
@@ -31,6 +32,8 @@
<poi.version>
4.1.2
</poi.version>
<poi.version>
4.1.2
</poi.version>
<velocity.version>
2.3
</velocity.version>
<velocity.version>
2.3
</velocity.version>
<jwt.version>
0.9.1
</jwt.version>
<jwt.version>
0.9.1
</jwt.version>
<io.springfox.version>
3.0.0
</io.springfox.version>
<io.swagger.version>
1.5.23
</io.swagger.version>
</properties>
</properties>
<!-- 依赖声明 -->
<!-- 依赖声明 -->
...
...
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponCategoryController.java
View file @
bc8ffd75
...
@@ -4,6 +4,7 @@ package com.soss.web.controller.coupon;
...
@@ -4,6 +4,7 @@ package com.soss.web.controller.coupon;
import
com.soss.common.annotation.Log
;
import
com.soss.common.annotation.Log
;
import
com.soss.common.core.controller.BaseController
;
import
com.soss.common.core.controller.BaseController
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.core.page.TableDataInfo
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.system.domain.CouponCategory
;
import
com.soss.system.domain.CouponCategory
;
import
com.soss.system.service.ICouponCategoryService
;
import
com.soss.system.service.ICouponCategoryService
;
...
@@ -25,7 +26,7 @@ import java.util.List;
...
@@ -25,7 +26,7 @@ import java.util.List;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/coupon-category"
)
@RequestMapping
(
"/coupon-category"
)
@Api
(
"优惠券类别服务类"
)
@Api
(
tags
=
"优惠券类别服务类"
)
public
class
CouponCategoryController
extends
BaseController
{
public
class
CouponCategoryController
extends
BaseController
{
@Autowired
@Autowired
private
ICouponCategoryService
couponCategoryService
;
private
ICouponCategoryService
couponCategoryService
;
...
@@ -49,20 +50,45 @@ public class CouponCategoryController extends BaseController {
...
@@ -49,20 +50,45 @@ public class CouponCategoryController extends BaseController {
@Log
(
title
=
"查询优惠券类别列表"
,
businessType
=
BusinessType
.
INSERT
)
@Log
(
title
=
"查询优惠券类别列表"
,
businessType
=
BusinessType
.
INSERT
)
@GetMapping
@GetMapping
@ApiOperation
(
"查询优惠券类别列表"
)
@ApiOperation
(
"查询优惠券类别列表"
)
public
AjaxResult
listCouponCategory
(
@RequestBody
CouponCategory
couponCategory
)
{
public
TableDataInfo
listCouponCategory
(
@RequestBody
CouponCategory
couponCategory
)
{
startPage
();
List
<
CouponCategory
>
couponCategories
=
couponCategoryService
.
listCouponCategory
(
couponCategory
);
List
<
CouponCategory
>
couponCategories
=
couponCategoryService
.
listCouponCategory
(
couponCategory
);
return
AjaxResult
.
success
(
couponCategories
);
return
getDataTable
(
couponCategories
);
}
}
/**
/**
*
变更
优惠券类别状态
*
上架
优惠券类别状态
*/
*/
@PreAuthorize
(
"@ss.hasPermi('coupon:category:state-switch')"
)
@PreAuthorize
(
"@ss.hasPermi('coupon:category:online')"
)
@Log
(
title
=
"变更优惠券类别状态"
,
businessType
=
BusinessType
.
INSERT
)
@Log
(
title
=
"上架优惠券类别"
,
businessType
=
BusinessType
.
INSERT
)
@GetMapping
(
"/{id}/{state}"
)
@GetMapping
(
"/online/{id}"
)
@ApiOperation
(
value
=
"变更优惠券类别状态"
,
notes
=
"state: 状态 0 默认 1 生效 2 下线 3删除"
)
@ApiOperation
(
"上架优惠券类别状态"
)
public
AjaxResult
switchState
(
@PathVariable
Integer
id
,
@PathVariable
Integer
state
)
{
public
AjaxResult
switchState
(
@PathVariable
Integer
id
)
{
int
updateCnt
=
couponCategoryService
.
switchState
(
id
,
state
);
int
updateCnt
=
couponCategoryService
.
onlineCouponCategory
(
id
);
return
toAjax
(
updateCnt
);
}
/**
* 下架优惠券类别状态
*/
@PreAuthorize
(
"@ss.hasPermi('coupon:category:offline')"
)
@Log
(
title
=
"下架优惠券类别"
,
businessType
=
BusinessType
.
INSERT
)
@GetMapping
(
"/offline/{id}"
)
@ApiOperation
(
"下架优惠券类别状态"
)
public
AjaxResult
offlineCouponCategory
(
@PathVariable
Integer
id
)
{
int
updateCnt
=
couponCategoryService
.
offlineCouponCategory
(
id
);
return
toAjax
(
updateCnt
);
}
/**
* 删除优惠券类别状态
*/
@PreAuthorize
(
"@ss.hasPermi('coupon:category:delete')"
)
@Log
(
title
=
"删除优惠券类别"
,
businessType
=
BusinessType
.
INSERT
)
@DeleteMapping
(
"/{id}"
)
@ApiOperation
(
"删除优惠券类别状态"
)
public
AjaxResult
deleteCouponCategory
(
@PathVariable
Integer
id
)
{
int
updateCnt
=
couponCategoryService
.
deleteCouponCategory
(
id
);
return
toAjax
(
updateCnt
);
return
toAjax
(
updateCnt
);
}
}
}
}
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponController.java
View file @
bc8ffd75
package
com
.
soss
.
web
.
controller
.
coupon
;
package
com
.
soss
.
web
.
controller
.
coupon
;
import
com.soss.common.annotation.Log
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.system.domain.po.CouponPo
;
import
com.soss.system.service.ICouponService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -13,7 +24,20 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,7 +24,20 @@ import org.springframework.web.bind.annotation.RestController;
* @since 2022-07-21
* @since 2022-07-21
*/
*/
@RestController
@RestController
@Api
(
tags
=
"优惠券服务类"
)
@RequestMapping
(
"/coupon"
)
@RequestMapping
(
"/coupon"
)
public
class
CouponController
{
public
class
CouponController
{
@Autowired
private
ICouponService
couponService
;
/**
* 新增优惠券
*/
@PreAuthorize
(
"@ss.hasPermi('coupon:add')"
)
@Log
(
title
=
"新增优惠券"
,
businessType
=
BusinessType
.
INSERT
)
@PutMapping
@ApiOperation
(
"新增优惠券"
)
public
AjaxResult
save
(
@RequestBody
CouponPo
couponPo
)
{
return
AjaxResult
.
success
();
}
}
}
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponRuleController.java
deleted
100644 → 0
View file @
6cd2da43
package
com
.
soss
.
web
.
controller
.
coupon
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* <p>
* 优惠券规则 前端控制器
* </p>
*
* @author caiyt
* @since 2022-07-21
*/
@RestController
@RequestMapping
(
"/coupon-rule"
)
public
class
CouponRuleController
{
}
soss-system/pom.xml
View file @
bc8ffd75
...
@@ -92,8 +92,32 @@
...
@@ -92,8 +92,32 @@
<version>
4.1.0
</version>
<version>
4.1.0
</version>
</dependency>
</dependency>
<!-- swagger相关 -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-boot-starter
</artifactId>
<version>
${io.springfox.version}
</version>
<exclusions>
<exclusion>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
</exclusion>
<exclusion>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-models
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
${io.swagger.version}
</version>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-models
</artifactId>
<version>
${io.swagger.version}
</version>
</dependency>
</dependencies>
</dependencies>
...
...
soss-system/src/main/java/com/soss/system/domain/CouponRule.java
View file @
bc8ffd75
...
@@ -92,6 +92,11 @@ public class CouponRule extends BaseEntity {
...
@@ -92,6 +92,11 @@ public class CouponRule extends BaseEntity {
private
Integer
relativeTime
;
private
Integer
relativeTime
;
/**
/**
* 价格扣减(当券类型为抵扣时单位为'元',当券类型为折扣时,单位为'折')
*/
private
BigDecimal
priceDiscount
;
/**
* 价格门槛
* 价格门槛
*/
*/
private
BigDecimal
priceLimit
;
private
BigDecimal
priceLimit
;
...
...
soss-system/src/main/java/com/soss/system/domain/po/CouponPo.java
0 → 100644
View file @
bc8ffd75
package
com
.
soss
.
system
.
domain
.
po
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.soss.common.exception.ServiceException
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.List
;
@Data
@ApiModel
(
"优惠券请求类"
)
public
class
CouponPo
{
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"优惠劵名"
)
private
String
name
;
@ApiModelProperty
(
"优惠券编码"
)
private
String
serialNo
;
@ApiModelProperty
(
"优惠券类别ID"
)
private
Integer
categoryId
;
@ApiModelProperty
(
"优惠券类别名"
)
private
String
categoryName
;
@ApiModelProperty
(
"优惠券规则id"
)
private
Integer
ruleId
;
@ApiModelProperty
(
"优惠券类型 1 抵扣 2 折扣 3 免单"
)
private
Integer
type
;
@ApiModelProperty
(
"优惠劵规则描述"
)
private
String
desc
;
@ApiModelProperty
(
"可用商品类别列表"
)
private
List
<
Integer
>
categoryIds
;
@ApiModelProperty
(
"可用商品id列表"
)
private
List
<
Integer
>
goodsIds
;
@ApiModelProperty
(
"可用省份列表 可存code列表"
)
private
List
<
String
>
province
;
@ApiModelProperty
(
"可用城市列表"
)
private
List
<
String
>
city
;
@ApiModelProperty
(
"可用区域列表"
)
private
List
<
String
>
area
;
@ApiModelProperty
(
"可用店铺ID列表"
)
private
List
<
Integer
>
shopIds
;
@ApiModelProperty
(
"领取开始时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
startTime
;
@ApiModelProperty
(
"领取截止时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
endTime
;
@ApiModelProperty
(
"使用绝对开始时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
useStartTime
;
@ApiModelProperty
(
"使用绝对截止时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
useEndTime
;
@ApiModelProperty
(
"领取后相对有效天数"
)
private
Integer
relativeTime
;
@ApiModelProperty
(
"价格扣减(当券类型为抵扣时单位为'元',当券类型为折扣时,单位为'折')"
)
private
BigDecimal
priceDiscount
;
@ApiModelProperty
(
"价格门槛,为0表示无门槛"
)
private
BigDecimal
priceLimit
;
@ApiModelProperty
(
"订单限制 false 整单 true 单杯"
)
private
Boolean
orderLimit
;
@ApiModelProperty
(
"周几限制 1,2,3"
)
private
List
<
Integer
>
weekLimit
;
@ApiModelProperty
(
"用户可领取次数之次数限制0无限制,即每N天M次对应的次数"
)
private
Integer
userLimit
;
@ApiModelProperty
(
"用户可领取次数之天数限制0无限制,即每N天M次对应的天数"
)
private
Integer
daysLimit
;
@ApiModelProperty
(
"是否发送短信 false 不 true 发"
)
private
Boolean
sendMsg
;
@ApiModelProperty
(
"短信模板ID"
)
private
Integer
msgId
;
public
void
couponUseLimitCheck
()
{
int
limitDim
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
province
))
{
limitDim
+=
1
;
}
if
(!
CollectionUtils
.
isEmpty
(
city
))
{
limitDim
+=
1
;
}
if
(!
CollectionUtils
.
isEmpty
(
area
))
{
limitDim
+=
1
;
}
if
(!
CollectionUtils
.
isEmpty
(
shopIds
))
{
limitDim
+=
1
;
}
if
(
limitDim
>
1
)
{
throw
new
ServiceException
(
"适用范围之地区/门店不能跨级"
);
}
}
}
soss-system/src/main/java/com/soss/system/domain/vo/CouponVo.java
0 → 100644
View file @
bc8ffd75
package
com
.
soss
.
system
.
domain
.
vo
;
import
com.soss.system.domain.po.CouponPo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
@Data
public
class
CouponVo
extends
CouponPo
{
@ApiModelProperty
(
"优惠劵规则名称"
)
private
String
ruleName
;
}
soss-system/src/main/java/com/soss/system/mapper/CouponCategoryMapper.java
View file @
bc8ffd75
...
@@ -30,6 +30,14 @@ public interface CouponCategoryMapper {
...
@@ -30,6 +30,14 @@ public interface CouponCategoryMapper {
List
<
CouponCategory
>
listCouponCategory
(
CouponCategory
couponCategory
);
List
<
CouponCategory
>
listCouponCategory
(
CouponCategory
couponCategory
);
/**
/**
* 根据id查询优惠券类别
*
* @param id 优惠券类别ID
* @return 优惠券类别
*/
CouponCategory
selectCouponCategoryById
(
Integer
id
);
/**
* 更新优惠券类别
* 更新优惠券类别
*
*
* @param couponCategory 优惠券类别
* @param couponCategory 优惠券类别
...
...
soss-system/src/main/java/com/soss/system/service/ICouponCategoryService.java
View file @
bc8ffd75
...
@@ -18,5 +18,9 @@ public interface ICouponCategoryService {
...
@@ -18,5 +18,9 @@ public interface ICouponCategoryService {
List
<
CouponCategory
>
listCouponCategory
(
CouponCategory
couponCategory
);
List
<
CouponCategory
>
listCouponCategory
(
CouponCategory
couponCategory
);
int
switchState
(
Integer
id
,
Integer
state
);
int
onlineCouponCategory
(
Integer
id
);
int
offlineCouponCategory
(
Integer
id
);
int
deleteCouponCategory
(
Integer
id
);
}
}
soss-system/src/main/java/com/soss/system/service/impl/CouponCategoryServiceImpl.java
View file @
bc8ffd75
package
com
.
soss
.
system
.
service
.
impl
;
package
com
.
soss
.
system
.
service
.
impl
;
import
com.soss.common.enums.CouponCategoryType
;
import
com.soss.common.enums.CouponCategoryType
;
import
com.soss.common.enums.CouponState
;
import
com.soss.system.domain.CouponCategory
;
import
com.soss.system.domain.CouponCategory
;
import
com.soss.system.mapper.CouponCategoryMapper
;
import
com.soss.system.mapper.CouponCategoryMapper
;
import
com.soss.system.mapper.CouponMapper
;
import
com.soss.system.mapper.CouponMapper
;
...
@@ -69,17 +70,46 @@ public class CouponCategoryServiceImpl implements ICouponCategoryService {
...
@@ -69,17 +70,46 @@ public class CouponCategoryServiceImpl implements ICouponCategoryService {
}
}
/**
/**
*
更新优惠券类别状态
*
上架优惠券类别
*
*
* @param id
* @param id
* @param state
* @return
* @return
*/
*/
@Override
@Override
@Transactional
@Transactional
public
int
switchState
(
Integer
id
,
Integer
state
)
{
public
int
onlineCouponCategory
(
Integer
id
)
{
CouponCategory
online
=
new
CouponCategory
(
id
,
state
);
CouponCategory
online
=
new
CouponCategory
(
id
,
CouponState
.
ONLINE
.
getState
()
);
int
updateCnt
=
couponCategoryMapper
.
updateCouponCategory
(
online
);
int
updateCnt
=
couponCategoryMapper
.
updateCouponCategory
(
online
);
return
updateCnt
;
return
updateCnt
;
}
}
/**
* 下架优惠券类别
*
* @param id
* @return
*/
@Override
@Transactional
public
int
offlineCouponCategory
(
Integer
id
)
{
CouponCategory
online
=
new
CouponCategory
(
id
,
CouponState
.
OFFLINE
.
getState
());
int
updateCnt
=
couponCategoryMapper
.
updateCouponCategory
(
online
);
// offline logic todo
return
updateCnt
;
}
/**
* 删除优惠券类别
*
* @param id
* @return
*/
@Override
@Transactional
public
int
deleteCouponCategory
(
Integer
id
)
{
CouponCategory
online
=
new
CouponCategory
(
id
,
CouponState
.
DELETE
.
getState
());
int
updateCnt
=
couponCategoryMapper
.
updateCouponCategory
(
online
);
// delete logic todo
return
updateCnt
;
}
}
}
soss-system/src/main/java/com/soss/system/service/impl/CouponServiceImpl.java
View file @
bc8ffd75
package
com
.
soss
.
system
.
service
.
impl
;
package
com
.
soss
.
system
.
service
.
impl
;
import
com.soss.common.enums.CouponCategoryType
;
import
com.soss.common.utils.GenerateCode
;
import
com.soss.system.domain.Coupon
;
import
com.soss.system.domain.CouponCategory
;
import
com.soss.system.domain.CouponRule
;
import
com.soss.system.domain.po.CouponPo
;
import
com.soss.system.mapper.CouponCategoryMapper
;
import
com.soss.system.mapper.CouponMapper
;
import
com.soss.system.service.ICouponService
;
import
com.soss.system.service.ICouponService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.stream.Collectors
;
/**
/**
* <p>
* <p>
...
@@ -13,5 +29,70 @@ import org.springframework.stereotype.Service;
...
@@ -13,5 +29,70 @@ import org.springframework.stereotype.Service;
*/
*/
@Service
@Service
public
class
CouponServiceImpl
implements
ICouponService
{
public
class
CouponServiceImpl
implements
ICouponService
{
@Autowired
private
CouponCategoryMapper
couponCategoryMapper
;
@Autowired
private
CouponMapper
couponMapper
;
public
void
save
(
CouponPo
couponPo
)
{
Assert
.
notNull
(
couponPo
.
getName
(),
"优惠券名称还未填写"
);
Assert
.
notNull
(
couponPo
.
getCategoryId
(),
"优惠券类别还未选择"
);
CouponCategory
couponCategory
=
couponCategoryMapper
.
selectCouponCategoryById
(
couponPo
.
getCategoryId
());
Assert
.
notNull
(
couponCategory
,
"未查询到匹配的优惠券类别[id="
+
couponPo
.
getCategoryId
()
+
"]"
);
StringBuilder
ruleName
=
new
StringBuilder
(
16
);
if
(
CouponCategoryType
.
DEDUCTION
.
getType
().
equals
(
couponCategory
.
getType
()))
{
Assert
.
notNull
(
couponPo
.
getPriceDiscount
(),
"满减价还未设置"
);
Assert
.
notNull
(
couponPo
.
getPriceLimit
(),
"价格门槛还未设置"
);
Assert
.
notNull
(
couponPo
.
getDaysLimit
(),
"用户可领取次数还未设置"
);
if
(
couponPo
.
getPriceLimit
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
ruleName
.
append
(
"无门槛"
);
}
else
{
ruleName
.
append
(
"满"
).
append
(
couponPo
.
getPriceLimit
()).
append
(
"元"
);
}
ruleName
.
append
(
"立减"
).
append
(
couponPo
.
getPriceDiscount
()).
append
(
"元"
);
}
else
if
(
CouponCategoryType
.
DISCOUNT
.
getType
().
equals
(
couponCategory
.
getType
()))
{
Assert
.
notNull
(
couponPo
.
getPriceDiscount
(),
"打折数还未设置"
);
Assert
.
notNull
(
couponPo
.
getOrderLimit
(),
"订单限制还未设置"
);
ruleName
.
append
(
couponPo
.
getOrderLimit
()
?
"单杯"
:
"整单"
).
append
(
couponPo
.
getOrderLimit
()).
append
(
"折"
);
}
else
{
Assert
.
notNull
(
couponPo
.
getPriceLimit
(),
"价格门槛还未设置"
);
Assert
.
notNull
(
couponPo
.
getOrderLimit
(),
"订单限制还未设置"
);
if
(
couponPo
.
getPriceLimit
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
ruleName
.
append
(
"无门槛"
);
}
else
{
ruleName
.
append
(
"满"
).
append
(
couponPo
.
getPriceLimit
()).
append
(
"元"
);
}
ruleName
.
append
(
"免单"
);
}
Assert
.
notNull
(
couponPo
.
getUseStartTime
(),
"优惠券的绝对有效时间还未设置"
);
Assert
.
notNull
(
couponPo
.
getUseEndTime
(),
"优惠券的绝对有效时间还未设置"
);
Assert
.
isTrue
(!
CollectionUtils
.
isEmpty
(
couponPo
.
getCategoryIds
())
&&
!
CollectionUtils
.
isEmpty
(
couponPo
.
getGoodsIds
()),
"商品范围还未设置"
);
Assert
.
notNull
(
couponPo
.
getSendMsg
(),
"是否短信通知还未设置"
);
Assert
.
isTrue
(
couponPo
.
getSendMsg
()
&&
couponPo
.
getMsgId
()
!=
null
,
"短信模板还未选择"
);
Coupon
coupon
=
new
Coupon
();
coupon
.
setName
(
couponPo
.
getName
());
coupon
.
setSerialNo
(
GenerateCode
.
getCode
(
"CP"
,
"%06d"
));
coupon
.
setCategoryId
(
couponCategory
.
getId
());
coupon
.
setCategoryName
(
couponCategory
.
getName
());
// coupon.setRuleId(); todo
coupon
.
setType
(
couponCategory
.
getType
());
LocalDateTime
now
=
LocalDateTime
.
now
();
coupon
.
setCreatedAt
(
now
);
coupon
.
setUpdatedAt
(
now
);
CouponRule
couponRule
=
new
CouponRule
();
BeanUtils
.
copyProperties
(
couponPo
,
couponRule
);
couponRule
.
setName
(
ruleName
.
toString
());
couponRule
.
setDesc
(
""
);
// todo
couponRule
.
setCategoryIds
(
couponPo
.
getCategoryIds
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
)));
couponRule
.
setGoodsIds
(
couponPo
.
getGoodsIds
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
)));
couponRule
.
setProvince
(
String
.
join
(
","
,
couponPo
.
getProvince
()));
couponRule
.
setCity
(
String
.
join
(
","
,
couponPo
.
getCity
()));
couponRule
.
setArea
(
String
.
join
(
","
,
couponPo
.
getArea
()));
couponRule
.
setShopIds
(
couponPo
.
getShopIds
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
)));
couponRule
.
setCreatedAt
(
now
);
couponRule
.
setUpdatedAt
(
now
);
}
}
}
soss-system/src/main/resources/mapper/system/CouponCategoryMapper.xml
View file @
bc8ffd75
...
@@ -16,13 +16,18 @@
...
@@ -16,13 +16,18 @@
select id, name, state, `desc`, type, created_at, updated_at from coupon_category
select id, name, state, `desc`, type, created_at, updated_at from coupon_category
</sql>
</sql>
<select
id=
"listCouponCategory"
parameterType=
"CouponCategory"
resultMap=
"BaseResultMap"
>
<select
id=
"selectCouponCategoryById"
resultMap=
"BaseResultMap"
>
<include
refid=
"selectCouponCategory"
/>
where id = #{id} and state = ${@com.soss.common.enums.CouponState @ONLINE.getState}
</select>
<select
id=
"listCouponCategory"
parameterType=
"com.soss.system.domain.CouponCategory"
resultMap=
"BaseResultMap"
>
<include
refid=
"selectCouponCategory"
/>
<include
refid=
"selectCouponCategory"
/>
<where>
<where>
<if
test=
"type != null"
>
and type = #{type}
</if>
<if
test=
"type != null"
>
and type = #{type}
</if>
<if
test=
"state != null and state != ''"
>
and state = #{state}
</if>
<if
test=
"state != null and state != ''"
>
and state = #{state}
</if>
</where>
</where>
order by
turn
order by
updated_at desc, id desc
</select>
</select>
<insert
id=
"insertCouponCategory"
parameterType=
"com.soss.system.domain.CouponCategory"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
<insert
id=
"insertCouponCategory"
parameterType=
"com.soss.system.domain.CouponCategory"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
...
...
soss-system/src/main/resources/mapper/system/CouponMapper.xml
View file @
bc8ffd75
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
</resultMap>
</resultMap>
<select
id=
"getCouponCategoryTypeStat"
resultType=
"com.soss.system.domain.CouponCategory"
>
<select
id=
"getCouponCategoryTypeStat"
resultType=
"com.soss.system.domain.CouponCategory"
>
select category_id id, count(*) couponCnt from coupon
select category_id id, count(*) couponCnt from coupon
where category_id in
<foreach
collection=
"categoryIds"
item=
"categoryId"
open=
"("
close=
")"
separator=
","
>
#{categoryId}
</foreach>
<foreach
collection=
"categoryIds"
item=
"categoryId"
open=
"("
close=
")"
separator=
","
>
#{categoryId}
</foreach>
group by category_id
group by category_id
</select>
</select>
...
...
soss-system/src/main/resources/mapper/system/CouponRuleMapper.xml
View file @
bc8ffd75
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
<result
column=
"use_start_time"
property=
"useStartTime"
/>
<result
column=
"use_start_time"
property=
"useStartTime"
/>
<result
column=
"use_end_time"
property=
"useEndTime"
/>
<result
column=
"use_end_time"
property=
"useEndTime"
/>
<result
column=
"relative_time"
property=
"relativeTime"
/>
<result
column=
"relative_time"
property=
"relativeTime"
/>
<result
column=
"price_discount"
property=
"priceDiscount"
/>
<result
column=
"price_limit"
property=
"priceLimit"
/>
<result
column=
"price_limit"
property=
"priceLimit"
/>
<result
column=
"order_limit"
property=
"orderLimit"
/>
<result
column=
"order_limit"
property=
"orderLimit"
/>
<result
column=
"week_limit"
property=
"weekLimit"
/>
<result
column=
"week_limit"
property=
"weekLimit"
/>
...
...
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