Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
cce6b8f2
Y
youlai-mall
项目概览
有来技术
/
youlai-mall
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
youlai-mall
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cce6b8f2
编写于
7月 11, 2022
作者:
郝
郝先瑞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增优惠券面值类型字段和对应逻辑调整
上级
5fcaf870
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
18 deletion
+74
-18
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/common/enums/CouponFaceValueTypeEnum.java
...youlai/mall/sms/common/enums/CouponFaceValueTypeEnum.java
+27
-0
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/common/utils/CouponUtils.java
...in/java/com/youlai/mall/sms/common/utils/CouponUtils.java
+17
-9
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/converter/SmsCouponConverter.java
...ava/com/youlai/mall/sms/converter/SmsCouponConverter.java
+8
-1
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/entity/SmsCoupon.java
.../main/java/com/youlai/mall/sms/pojo/entity/SmsCoupon.java
+11
-5
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java
...c/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java
+11
-3
未找到文件。
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/common/enums/CouponFaceValueTypeEnum.java
0 → 100644
浏览文件 @
cce6b8f2
package
com.youlai.mall.sms.common.enums
;
import
com.baomidou.mybatisplus.annotation.EnumValue
;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
com.youlai.common.base.IBaseEnum
;
import
lombok.Getter
;
@Getter
public
enum
CouponFaceValueTypeEnum
implements
IBaseEnum
<
Integer
>
{
CASH
(
1
,
"现金"
),
DISCOUNT
(
2
,
"折扣"
),
;
@Getter
@EnumValue
// Mybatis-Plus 提供注解表示插入数据库时插入该值
private
Integer
value
;
@Getter
@JsonValue
// 表示对枚举序列化时返回此字段
private
String
label
;
CouponFaceValueTypeEnum
(
Integer
value
,
String
label
)
{
this
.
value
=
value
;
this
.
label
=
label
;
}
}
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/common/utils/CouponUtils.java
浏览文件 @
cce6b8f2
...
...
@@ -3,6 +3,7 @@ package com.youlai.mall.sms.common.utils;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.NumberUtil
;
import
com.youlai.common.base.IBaseEnum
;
import
com.youlai.mall.sms.common.enums.CouponFaceValueTypeEnum
;
import
com.youlai.mall.sms.common.enums.CouponTypeEnum
;
import
com.youlai.mall.sms.common.enums.ValidityPeriodTypeEnum
;
...
...
@@ -15,23 +16,27 @@ public class CouponUtils {
/**
* 计算优惠券面值
*
* @param
type
* @param
faceValueType 面值类型
* @param faceValue
* @param discount
* @return
*/
public
static
String
getFaceValue
(
Integer
t
ype
,
Long
faceValue
,
BigDecimal
discount
)
{
public
static
String
getFaceValue
(
Integer
faceValueT
ype
,
Long
faceValue
,
BigDecimal
discount
)
{
String
faceValueLabel
=
null
;
CouponTypeEnum
couponTypeEnum
=
IBaseEnum
.
getEnumByValue
(
type
,
CouponTypeEnum
.
class
);
switch
(
couponTypeEnum
)
{
case
ZK:
faceValueLabel
=
NumberUtil
.
mul
(
discount
,
10
)
+
"折"
;
if
(
faceValueType
==
null
)
{
return
null
;
}
CouponFaceValueTypeEnum
couponFaceValueTypeEnum
=
IBaseEnum
.
getEnumByValue
(
faceValueType
,
CouponFaceValueTypeEnum
.
class
);
switch
(
couponFaceValueTypeEnum
)
{
case
CASH:
faceValueLabel
=
NumberUtil
.
toStr
(
NumberUtil
.
div
(
faceValue
,
new
Float
(
100
),
2
))
+
"元"
;
break
;
case
MJ:
case
ZJ:
faceValueLabel
=
NumberUtil
.
div
(
faceValue
,
new
Float
(
10000
),
2
)
+
"元"
;
case
DISCOUNT:
faceValueLabel
=
NumberUtil
.
mul
(
discount
,
10
)
+
"折"
;
break
;
}
return
faceValueLabel
;
}
...
...
@@ -48,6 +53,9 @@ public class CouponUtils {
*/
public
static
String
getValidityPeriod
(
Integer
validityPeriodType
,
Integer
validityDays
,
Date
validityBeginTime
,
Date
validityEndTime
)
{
String
validityPeriodLabel
=
null
;
if
(
validityPeriodType
==
null
)
{
return
null
;
}
ValidityPeriodTypeEnum
validityPeriodTypeEnum
=
IBaseEnum
.
getEnumByValue
(
validityPeriodType
,
ValidityPeriodTypeEnum
.
class
);
switch
(
validityPeriodTypeEnum
)
{
case
DATE_RANGE:
...
...
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/converter/SmsCouponConverter.java
浏览文件 @
cce6b8f2
...
...
@@ -27,15 +27,22 @@ public interface SmsCouponConverter {
target
=
"validityPeriodLabel"
,
expression
=
"java(com.youlai.mall.sms.common.utils.CouponUtils.getValidityPeriod(entity.getValidityPeriodType(),entity.getValidityDays(),entity.getValidityBeginTime(),entity.getValidityBeginTime()))"
),
@Mapping
(
target
=
"minPointLabel"
,
expression
=
"java(cn.hutool.core.util.NumberUtil.
div(entity.getMinPoint(),new java.math.BigDecimal(10000)).setScale(2).toString(
))"
),
@Mapping
(
target
=
"minPointLabel"
,
expression
=
"java(cn.hutool.core.util.NumberUtil.
toStr(cn.hutool.core.util.NumberUtil.div(entity.getMinPoint(),new java.math.BigDecimal(100)).setScale(2)
))"
),
})
CouponPageVO
entity2PageVO
(
SmsCoupon
entity
);
List
<
CouponPageVO
>
entity2PageVO
(
List
<
SmsCoupon
>
entities
);
@Mappings
({
@Mapping
(
target
=
"discount"
,
expression
=
"java(cn.hutool.core.util.NumberUtil.div(form.getDiscount(),10L))"
),
})
SmsCoupon
form2Entity
(
CouponForm
form
);
@Mappings
({
@Mapping
(
target
=
"discount"
,
expression
=
"java(cn.hutool.core.util.NumberUtil.mul(entity.getDiscount(),10L))"
),
})
CouponForm
entity2Form
(
SmsCoupon
entity
);
}
\ No newline at end of file
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/entity/SmsCoupon.java
浏览文件 @
cce6b8f2
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.youlai.common.base.BaseEntity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
...
...
@@ -24,14 +25,14 @@ public class SmsCoupon extends BaseEntity {
private
Long
id
;
/**
* 优惠券
名称
* 优惠券
类型(1:满减券;2:直减券;3:折扣券)
*/
private
String
nam
e
;
private
Integer
typ
e
;
/**
* 优惠券
类型(1:满减券;2:直减券;3:折扣券)
* 优惠券
名称
*/
private
Integer
typ
e
;
private
String
nam
e
;
/**
* 优惠券码
...
...
@@ -39,10 +40,15 @@ public class SmsCoupon extends BaseEntity {
private
String
code
;
/**
* 使用平台(0
-全平台;1-移动端;2-PC
)
* 使用平台(0
:全平台;1:移动端;2:PC端
)
*/
private
Integer
platform
;
/**
* 优惠券面值类型((1:金额;2:折扣)
*/
private
Integer
faceValueType
;
/**
* 优惠券面值金额(单位:分)
*/
...
...
mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java
浏览文件 @
cce6b8f2
package
com.youlai.mall.sms.pojo.form
;
import
cn.hutool.core.util.NumberUtil
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -27,6 +28,9 @@ public class CouponForm {
@ApiModelProperty
(
"优惠券类型(1:满减券;2:直减券;3:折扣券)"
)
private
Integer
type
;
@ApiModelProperty
(
"优惠券面值类型((1:金额;2:折扣)"
)
private
Integer
faceValueType
;
@ApiModelProperty
(
"优惠券面值金额(单位:分)"
)
private
Long
faceValue
;
...
...
@@ -42,13 +46,13 @@ public class CouponForm {
@ApiModelProperty
(
"发行量(-1:无限制)"
)
private
Integer
circulation
;
@ApiModelProperty
(
"
最低消费金额
(0:无门槛)"
)
@ApiModelProperty
(
"
使用门槛
(0:无门槛)"
)
private
Long
minPoint
;
@ApiModelProperty
(
"每人限领张数(-1:不限制)"
)
private
Integer
perLimit
;
@ApiModelProperty
(
"有效期类型(1:
自领取之日起有效天数;2:有效起止时间
)"
)
@ApiModelProperty
(
"有效期类型(1:
日期范围;2:固定天数
)"
)
private
Integer
validityPeriodType
;
@ApiModelProperty
(
"自领取之日起有效天数"
)
...
...
@@ -60,7 +64,7 @@ public class CouponForm {
@ApiModelProperty
(
"有效期截止时间"
)
private
Date
validityEndTime
;
@ApiModelProperty
(
"使用类型(0
-全场通用;1-指定商品分类;2-
指定商品)"
)
@ApiModelProperty
(
"使用类型(0
:全场通用;1:指定商品分类;2:
指定商品)"
)
private
Integer
useType
;
@ApiModelProperty
(
"备注"
)
...
...
@@ -96,4 +100,8 @@ public class CouponForm {
private
String
spuName
;
}
public
static
void
main
(
String
[]
args
)
{
double
div
=
NumberUtil
.
div
(
1L
,
1L
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录