Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
c8227482
提交
c8227482
authored
10月 31, 2022
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
清理优惠劵模板的逻辑
上级
0e6d9487
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
0 行增加
和
902 行删除
+0
-902
PreferentialTypeEnum.java
...ocoder/mall/promotion/api/enums/PreferentialTypeEnum.java
+0
-46
CouponTemplateDateTypeEnum.java
...api/enums/coupon/template/CouponTemplateDateTypeEnum.java
+0
-46
CouponTemplateStatusEnum.java
...n/api/enums/coupon/template/CouponTemplateStatusEnum.java
+0
-45
CouponTemplateTypeEnum.java
...ion/api/enums/coupon/template/CouponTemplateTypeEnum.java
+0
-38
CouponTemplateController.java
...promotionservice/controller/CouponTemplateController.java
+0
-56
PriceController.java
...der/mall/promotionservice/controller/PriceController.java
+0
-33
CouponCardConvert.java
...ll/promotionservice/convert/coupon/CouponCardConvert.java
+0
-26
CouponTemplateConvert.java
...romotionservice/convert/coupon/CouponTemplateConvert.java
+0
-37
CouponCodeDO.java
...tionservice/dal/mysql/dataobject/coupon/CouponCodeDO.java
+0
-43
CouponTemplateDO.java
...service/dal/mysql/dataobject/coupon/CouponTemplateDO.java
+0
-237
CouponTemplateMapper.java
...service/dal/mysql/mapper/coupon/CouponTemplateMapper.java
+0
-8
ProductRecommendMapper.java
...ce/dal/mysql/mapper/recommend/ProductRecommendMapper.java
+0
-5
CouponTemplateService.java
...romotionservice/service/coupon/CouponTemplateService.java
+0
-173
application-dev.yaml
...otion-service-app/src/main/resources/application-dev.yaml
+0
-21
application-local.yaml
...ion-service-app/src/main/resources/application-local.yaml
+0
-24
application.yaml
...promotion-service-app/src/main/resources/application.yaml
+0
-64
没有找到文件。
归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PreferentialTypeEnum.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotion
.
api
.
enums
;
import
cn.iocoder.common.framework.core.IntArrayValuable
;
import
java.util.Arrays
;
/**
* 优惠类型枚举
*/
public
enum
PreferentialTypeEnum
implements
IntArrayValuable
{
PRICE
(
1
,
"减价"
),
DISCOUNT
(
2
,
"打折"
),
;
public
static
final
int
[]
ARRAYS
=
Arrays
.
stream
(
values
()).
mapToInt
(
PreferentialTypeEnum:
:
getValue
).
toArray
();
/**
* 值
*/
private
final
Integer
value
;
/**
* 名字
*/
private
final
String
name
;
PreferentialTypeEnum
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
@Override
public
int
[]
array
()
{
return
ARRAYS
;
}
}
归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateDateTypeEnum.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotion
.
api
.
enums
.
coupon
.
template
;
import
cn.iocoder.common.framework.core.IntArrayValuable
;
import
java.util.Arrays
;
/**
* 优惠劵(码)模板的时间类型的枚举
*/
public
enum
CouponTemplateDateTypeEnum
implements
IntArrayValuable
{
FIXED_DATE
(
1
,
"固定日期"
),
FIXED_TERM
(
2
,
"领取日期"
),
;
public
static
final
int
[]
ARRAYS
=
Arrays
.
stream
(
values
()).
mapToInt
(
CouponTemplateDateTypeEnum:
:
getValue
).
toArray
();
/**
* 值
*/
private
final
Integer
value
;
/**
* 名字
*/
private
final
String
name
;
CouponTemplateDateTypeEnum
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
@Override
public
int
[]
array
()
{
return
ARRAYS
;
}
}
归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateStatusEnum.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotion
.
api
.
enums
.
coupon
.
template
;
import
cn.iocoder.common.framework.core.IntArrayValuable
;
import
java.util.Arrays
;
/**
* 优惠劵(码)模板的状态的枚举
*/
public
enum
CouponTemplateStatusEnum
implements
IntArrayValuable
{
ENABLE
(
1
,
"生效中"
),
DISABLE
(
2
,
"已失效"
),
// EXPIRE(3, "已过期"), TODO 芋艿,暂时不考虑过期的
;
public
static
final
int
[]
ARRAYS
=
Arrays
.
stream
(
values
()).
mapToInt
(
CouponTemplateStatusEnum:
:
getValue
).
toArray
();
/**
* 值
*/
private
final
Integer
value
;
/**
* 名字
*/
private
final
String
name
;
CouponTemplateStatusEnum
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
@Override
public
int
[]
array
()
{
return
ARRAYS
;
}
}
归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateTypeEnum.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotion
.
api
.
enums
.
coupon
.
template
;
import
java.util.Arrays
;
/**
* 优惠劵(码)模板的类型的枚举
*/
public
enum
CouponTemplateTypeEnum
{
CARD
(
1
,
"优惠劵"
),
CODE
(
2
,
"折扣卷"
),
;
public
static
final
int
[]
ARRAYS
=
Arrays
.
stream
(
values
()).
mapToInt
(
CouponTemplateTypeEnum:
:
getValue
).
toArray
();
/**
* 值
*/
private
final
Integer
value
;
/**
* 名字
*/
private
final
String
name
;
CouponTemplateTypeEnum
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
controller
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*
;
import
cn.iocoder.mall.promotionservice.manager.coupon.CouponTemplateManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
static
cn
.
iocoder
.
common
.
framework
.
vo
.
CommonResult
.
success
;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping
(
"/coupon/template"
)
public
class
CouponTemplateController
{
@Autowired
private
CouponTemplateManager
couponTemplateManager
;
// ========== 通用逻辑 =========
@GetMapping
(
"getCouponTemplate"
)
public
CommonResult
<
CouponTemplateRespDTO
>
getCouponTemplate
(
@RequestParam
(
"couponTemplateId"
)
Integer
couponTemplateId
)
{
return
success
(
couponTemplateManager
.
getCouponTemplate
(
couponTemplateId
));
}
@PostMapping
(
"pageCouponTemplate"
)
public
CommonResult
<
PageResult
<
CouponTemplateRespDTO
>>
pageCouponTemplate
(
@RequestBody
CouponTemplatePageReqDTO
pageDTO
)
{
return
success
(
couponTemplateManager
.
pageCouponTemplate
(
pageDTO
));
}
@PostMapping
(
"updateCouponTemplateStatus"
)
public
CommonResult
<
Boolean
>
updateCouponTemplateStatus
(
@RequestBody
CouponCardTemplateUpdateStatusReqDTO
updateStatusReqDTO
)
{
couponTemplateManager
.
updateCouponTemplateStatus
(
updateStatusReqDTO
);
return
success
(
true
);
}
// ========== 优惠劵模板 ==========
@PostMapping
(
"createCouponCardTemplate"
)
public
CommonResult
<
Integer
>
createCouponCardTemplate
(
@RequestBody
CouponCardTemplateCreateReqDTO
createDTO
)
{
return
success
(
couponTemplateManager
.
createCouponCardTemplate
(
createDTO
));
}
@PostMapping
(
"updateCouponCardTemplate"
)
public
CommonResult
<
Boolean
>
updateCouponCardTemplate
(
@RequestBody
CouponCardTemplateUpdateReqDTO
updateDTO
)
{
couponTemplateManager
.
updateCouponCardTemplate
(
updateDTO
);
return
success
(
true
);
}
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
controller
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO
;
import
cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO
;
import
cn.iocoder.mall.promotionservice.manager.price.PriceManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.RestController
;
import
static
cn
.
iocoder
.
common
.
framework
.
vo
.
CommonResult
.
success
;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping
(
"/promotion/price"
)
public
class
PriceController
{
@Autowired
private
PriceManager
priceManager
;
@PostMapping
(
"calcProductPrice"
)
public
CommonResult
<
PriceProductCalcRespDTO
>
calcProductPrice
(
@RequestBody
PriceProductCalcReqDTO
calcReqDTO
)
{
return
success
(
priceManager
.
calcProductPrice
(
calcReqDTO
));
}
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponCardConvert.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
convert
.
coupon
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableRespDTO
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardRespDTO
;
import
cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon.CouponCardDO
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.Named
;
import
org.mapstruct.factory.Mappers
;
@Mapper
public
interface
CouponCardConvert
{
CouponCardConvert
INSTANCE
=
Mappers
.
getMapper
(
CouponCardConvert
.
class
);
CouponCardRespDTO
convert
(
CouponCardDO
bean
);
@Mapping
(
source
=
"records"
,
target
=
"list"
)
PageResult
<
CouponCardRespDTO
>
convertPage
(
IPage
<
CouponCardDO
>
page
);
@Named
(
"convertCouponCardDOToCouponCardAvailableRespDTO"
)
// 避免生成的方法名的冲突
CouponCardAvailableRespDTO
convert01
(
CouponCardDO
bean
);
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponTemplateConvert.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
convert
.
coupon
;
import
cn.iocoder.common.framework.util.StringUtils
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateCreateReqDTO
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateReqDTO
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO
;
import
cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon.CouponTemplateDO
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.Named
;
import
org.mapstruct.factory.Mappers
;
import
java.util.List
;
@Mapper
public
interface
CouponTemplateConvert
{
CouponTemplateConvert
INSTANCE
=
Mappers
.
getMapper
(
CouponTemplateConvert
.
class
);
@Mapping
(
source
=
"rangeValues"
,
target
=
"rangeValues"
,
qualifiedByName
=
"translateStringToIntList"
)
CouponTemplateRespDTO
convert
(
CouponTemplateDO
bean
);
CouponTemplateDO
convert
(
CouponCardTemplateCreateReqDTO
bean
);
CouponTemplateDO
convert
(
CouponCardTemplateUpdateReqDTO
bean
);
@Mapping
(
source
=
"records"
,
target
=
"list"
)
PageResult
<
CouponTemplateRespDTO
>
convertPage
(
IPage
<
CouponTemplateDO
>
couponTemplatePage
);
@Named
(
"translateStringToIntList"
)
default
List
<
Integer
>
translateStringToIntList
(
String
str
)
{
return
StringUtils
.
splitToInt
(
str
,
","
);
}
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponCodeDO.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
dal
.
mysql
.
dataobject
.
coupon
;
import
cn.iocoder.mall.mybatis.core.dataobject.BaseDO
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* 优惠码
*/
@Data
@Accessors
(
chain
=
true
)
public
class
CouponCodeDO
extends
BaseDO
{
/**
* 编号
*/
private
Integer
id
;
/**
* 模板编号 {@link CouponTemplateDO} 的 id
*/
private
Integer
templateId
;
/**
* 优惠码
*/
private
Integer
code
;
/**
* 领取时间
*/
private
Date
takeTime
;
/**
* 领取用户编号
*/
private
Integer
userId
;
/**
* 领取的优惠劵编号
*/
private
Integer
couponId
;
// TODO 芋艿,后续要考虑状态的追踪
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponTemplateDO.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
dal
.
mysql
.
dataobject
.
coupon
;
import
cn.iocoder.mall.mybatis.core.dataobject.BaseDO
;
import
cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.RangeTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateDateTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateStatusEnum
;
import
cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateTypeEnum
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* 优惠劵(码)模板 DO
*
* 当用户领取时,会生成 {@link CouponCardDO} 优惠劵(码)。
*/
@TableName
(
"coupon_template"
)
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
public
class
CouponTemplateDO
extends
BaseDO
{
// ========== 基本信息 BEGIN ==========
/**
* 模板编号,自增唯一。
*/
private
Integer
id
;
/**
* 标题
*/
private
String
title
;
/**
* 使用说明
*/
private
String
description
;
/**
* 类型
*
* 枚举 {@link CouponTemplateTypeEnum}
*
* 1-优惠劵
* 2-优惠码
*/
private
Integer
type
;
/**
* 优惠码状态
*
* 枚举 {@link CouponTemplateStatusEnum}
*
* 当优惠劵(码)开启中,可以手动操作,设置禁用中。
*/
private
Integer
status
;
// /**
// * 是否可分享领取链接
// */
// private Boolean isShare;
// /**
// * 设置为失效时间
// */
// private Date invalidTime;
// /**
// * 删除时间
// */
// private Date deleteTime;
// ========== 基本信息 END ==========
// ========== 领取规则 BEGIN ==========
// /**
// * 是否限制领用者的等级
// *
// * 0-不限制
// * 大于0-领用者必须是这个等级编号
// *
// * 【优惠劵独有】
// */
// private Integer needUserLevel;
/**
* 每人限领个数
*
* null - 则表示不限制
*/
private
Integer
quota
;
/**
* 发行总量
*/
private
Integer
total
;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
// /**
// * 是否仅原价购买商品时可用
// *
// * true-是
// * false-否
// */
// private Boolean isForbidPreference;
/**
* 是否设置满多少金额可用,单位:分
*
* 0-不限制
* 大于0-多少金额可用
*/
private
Integer
priceAvailable
;
/**
* 可用范围的类型
*
* 枚举 {@link RangeTypeEnum}
*
* 10-全部(ALL):所有可用
* 20-部分(PART):部分商品可用,或指定商品可用
* 21-部分(PART):部分商品不可用,或指定商品可用
* 30-部分(PART):部分分类可用,或指定商品可用
* 31-部分(PART):部分分类不可用,或指定商品可用
*/
private
Integer
rangeType
;
/**
* 指定商品 / 分类列表,使用逗号分隔商品编号
*/
private
String
rangeValues
;
/**
* 生效日期类型
*
* 枚举 {@link CouponTemplateDateTypeEnum}
*
* 1-固定日期
* 2-领取日期:领到券 {@link #fixedStartTerm} 日开始 N 天内有效
*/
private
Integer
dateType
;
/**
* 固定日期-生效开始时间
*/
private
Date
validStartTime
;
/**
* 固定日期-生效结束时间
*/
private
Date
validEndTime
;
/**
* 领取日期-开始天数
*
* 例如,0-当天;1-次天
*/
private
Integer
fixedStartTerm
;
/**
* 领取日期-结束天数
*/
private
Integer
fixedEndTerm
;
// /**
// * 是否到期前4天发送提醒
// *
// * true-发送
// * false-不发送
// */
// private Boolean expireNotice;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
/**
* 优惠类型
*
* 枚举 {@link PreferentialTypeEnum}
*
* 1-代金卷
* 2-折扣卷
*/
private
Integer
preferentialType
;
/**
* 折扣百分比。
*
* 例如,80% 为 80。
* 当 100% 为 100 ,则代表免费。
*/
private
Integer
percentOff
;
// /**
// * 是否是随机优惠券
// *
// * true-随机
// * false-不随机
// *
// * 【优惠劵独有】
// */
// private Boolean isRandom;
/**
* 优惠金额,单位:分
*/
// * 当 {@link #isRandom} 为 true 时,代表随机优惠金额的下限
private
Integer
priceOff
;
// /**
// * 优惠金额上限
// *
// * 【优惠劵独有】
// */
// private Integer valueRandomTo;
/**
* 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。
*
* 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。
*/
private
Integer
discountPriceLimit
;
// ========== 使用效果 END ==========
// ========== 统计信息 BEGIN ==========
// /**
// * 领取优惠券的人数
// */
// private Integer statFetchUserNum;
/**
* 领取优惠券的次数
*/
private
Integer
statFetchNum
;
// /**
// * 使用优惠券的次数
// */
// private Integer statUseNum;
// ========== 统计信息 END ==========
// ========== 优惠码 BEGIN ==========
/**
* 码类型
*
* 1-一卡一码(UNIQUE)
* 2-通用码(GENERAL)
*
* 【优惠码独有】 @see CouponCodeDO
*/
private
Integer
codeType
;
/**
* 通用码
*/
private
String
commonCode
;
// ========== 优惠码 BEGIN ==========
}
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponTemplateMapper.java
浏览文件 @
c8227482
...
...
@@ -12,14 +12,6 @@ import org.springframework.stereotype.Repository;
@Repository
public
interface
CouponTemplateMapper
extends
BaseMapper
<
CouponTemplateDO
>
{
default
IPage
<
CouponTemplateDO
>
selectPage
(
CouponTemplatePageReqDTO
pageReqDTO
)
{
return
selectPage
(
new
Page
<>(
pageReqDTO
.
getPageNo
(),
pageReqDTO
.
getPageSize
()),
new
QueryWrapperX
<
CouponTemplateDO
>().
eqIfPresent
(
"type"
,
pageReqDTO
.
getType
())
.
likeIfPresent
(
"title"
,
pageReqDTO
.
getTitle
())
.
eqIfPresent
(
"status"
,
pageReqDTO
.
getStatus
())
.
eqIfPresent
(
"preferential_type"
,
pageReqDTO
.
getPreferentialType
()));
}
/**
* 更新优惠劵模板已领取的数量
*
...
...
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/recommend/ProductRecommendMapper.java
浏览文件 @
c8227482
...
...
@@ -20,11 +20,6 @@ public interface ProductRecommendMapper extends BaseMapper<ProductRecommendDO> {
.
eq
(
"type"
,
type
));
}
default
List
<
ProductRecommendDO
>
selectList
(
ProductRecommendListReqDTO
listReqDTO
)
{
return
selectList
(
new
QueryWrapperX
<
ProductRecommendDO
>().
eqIfPresent
(
"type"
,
listReqDTO
.
getType
())
.
eqIfPresent
(
"status"
,
listReqDTO
.
getStatus
()));
}
default
IPage
<
ProductRecommendDO
>
selectPage
(
ProductRecommendPageReqDTO
pageReqDTO
)
{
return
selectPage
(
new
Page
<>(
pageReqDTO
.
getPageNo
(),
pageReqDTO
.
getPageSize
()),
new
QueryWrapperX
<
ProductRecommendDO
>().
eqIfPresent
(
"type"
,
pageReqDTO
.
getType
()));
...
...
归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponTemplateService.java
deleted
100644 → 0
浏览文件 @
0e6d9487
package
cn
.
iocoder
.
mall
.
promotionservice
.
service
.
coupon
;
import
cn.iocoder.common.framework.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants
;
import
cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateDateTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateStatusEnum
;
import
cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateTypeEnum
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateCreateReqDTO
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateReqDTO
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplatePageReqDTO
;
import
cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO
;
import
cn.iocoder.mall.promotionservice.convert.coupon.CouponTemplateConvert
;
import
cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon.CouponTemplateDO
;
import
cn.iocoder.mall.promotionservice.dal.mysql.mapper.coupon.CouponTemplateMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
java.util.Date
;
import
static
cn
.
iocoder
.
common
.
framework
.
exception
.
enums
.
GlobalErrorCodeConstants
.
BAD_REQUEST
;
/**
* 优惠劵模板 Service
*/
@Service
@Validated
public
class
CouponTemplateService
{
@Autowired
private
CouponTemplateMapper
couponTemplateMapper
;
// ========== 通用逻辑 =========
/**
* 获得优惠劵(码)模板
*
* @param couponCardId 优惠劵模板编号
* @return 优惠劵(码)模板
*/
public
CouponTemplateRespDTO
getCouponTemplate
(
Integer
couponCardId
)
{
return
CouponTemplateConvert
.
INSTANCE
.
convert
(
couponTemplateMapper
.
selectById
(
couponCardId
));
}
/**
* 获得优惠劵(码)分页
*
* @param pageDTO 分页条件
* @return 优惠劵(码)分页
*/
public
PageResult
<
CouponTemplateRespDTO
>
pageCouponTemplate
(
CouponTemplatePageReqDTO
pageDTO
)
{
IPage
<
CouponTemplateDO
>
couponTemplatePage
=
couponTemplateMapper
.
selectPage
(
pageDTO
);
return
CouponTemplateConvert
.
INSTANCE
.
convertPage
(
couponTemplatePage
);
}
/**
* 更新优惠劵(码)模板的状态
*
* @param couponTemplateId 优惠劵模板编号
* @param status 状态
*/
public
void
updateCouponTemplateStatus
(
Integer
couponTemplateId
,
Integer
status
)
{
// 校验 CouponCardTemplate 存在
CouponTemplateDO
template
=
couponTemplateMapper
.
selectById
(
couponTemplateId
);
if
(
template
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeConstants
.
COUPON_TEMPLATE_NOT_EXISTS
.
getCode
());
}
// 更新到数据库
CouponTemplateDO
updateTemplateDO
=
new
CouponTemplateDO
().
setId
(
couponTemplateId
).
setStatus
(
status
);
couponTemplateMapper
.
updateById
(
updateTemplateDO
);
}
private
Boolean
checkCouponTemplateDateType
(
Integer
dateType
,
Date
validStartTime
,
Date
validEndTime
,
Integer
fixedStartTerm
,
Integer
fixedEndTerm
)
{
// TODO 芋艿:后续这种类型的校验,看看怎么优化到对象里
if
(
CouponTemplateDateTypeEnum
.
FIXED_DATE
.
getValue
().
equals
(
dateType
))
{
// 固定日期
if
(
validStartTime
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"生效开始时间不能为空"
);
}
if
(
validEndTime
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"生效结束时间不能为空"
);
}
if
(
validStartTime
.
after
(
validEndTime
))
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"生效开始时间不能大于生效结束时间"
);
}
}
else
if
(
CouponTemplateDateTypeEnum
.
FIXED_TERM
.
getValue
().
equals
(
dateType
))
{
// 领取日期
if
(
fixedStartTerm
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"领取日期开始时间不能为空"
);
}
if
(
fixedEndTerm
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"领取日期结束时间不能为空"
);
}
}
else
{
throw
new
IllegalArgumentException
(
"未知的生效日期类型:"
+
dateType
);
}
return
true
;
}
private
Boolean
checkCouponTemplatePreferentialType
(
Integer
preferentialType
,
Integer
percentOff
,
Integer
priceOff
,
Integer
priceAvailable
)
{
if
(
PreferentialTypeEnum
.
PRICE
.
getValue
().
equals
(
preferentialType
))
{
if
(
priceOff
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"优惠金额不能为空"
);
}
if
(
priceOff
>=
priceAvailable
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"优惠金额不能d大于等于使用金额门槛"
);
}
}
else
if
(
PreferentialTypeEnum
.
DISCOUNT
.
getValue
().
equals
(
preferentialType
))
{
if
(
percentOff
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
BAD_REQUEST
,
"折扣百分比不能为空"
);
}
}
else
{
throw
new
IllegalArgumentException
(
"未知的优惠类型:"
+
preferentialType
);
}
return
true
;
}
// ========== 优惠劵模板 ==========
/**
* 添加优惠劵模板
*
* @param createReqDTO 优惠劵模板添加信息
* @return 优惠劵模板编号
*/
public
Integer
createCouponCardTemplate
(
CouponCardTemplateCreateReqDTO
createReqDTO
)
{
// 校验生效日期相关
checkCouponTemplateDateType
(
createReqDTO
.
getDateType
(),
createReqDTO
.
getValidStartTime
(),
createReqDTO
.
getValidEndTime
(),
createReqDTO
.
getFixedStartTerm
(),
createReqDTO
.
getFixedEndTerm
());
// 校验优惠类型
checkCouponTemplatePreferentialType
(
createReqDTO
.
getPreferentialType
(),
createReqDTO
.
getPercentOff
(),
createReqDTO
.
getPriceOff
(),
createReqDTO
.
getPriceAvailable
());
// 保存优惠劵模板到数据库
CouponTemplateDO
template
=
CouponTemplateConvert
.
INSTANCE
.
convert
(
createReqDTO
)
.
setType
(
CouponTemplateTypeEnum
.
CARD
.
getValue
())
.
setStatus
(
CouponTemplateStatusEnum
.
ENABLE
.
getValue
())
.
setStatFetchNum
(
0
);
couponTemplateMapper
.
insert
(
template
);
// 返回成功
return
template
.
getId
();
}
/**
* 更新优惠劵模板
*
* @param updateReqDTO 优惠劵模板修改信息
*/
public
void
updateCouponCardTemplate
(
CouponCardTemplateUpdateReqDTO
updateReqDTO
)
{
// 校验 CouponCardTemplate 存在
CouponTemplateDO
template
=
couponTemplateMapper
.
selectById
(
updateReqDTO
.
getId
());
if
(
template
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeConstants
.
COUPON_TEMPLATE_NOT_EXISTS
.
getCode
());
}
// 校验 CouponCardTemplate 是 CARD
if
(!
CouponTemplateTypeEnum
.
CARD
.
getValue
().
equals
(
template
.
getType
()))
{
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeConstants
.
COUPON_TEMPLATE_NOT_CARD
.
getCode
());
}
// 校验发放数量不能减少
if
(
updateReqDTO
.
getTotal
()
<
template
.
getTotal
())
{
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeConstants
.
COUPON_TEMPLATE_TOTAL_CAN_NOT_REDUCE
.
getCode
());
}
// 更新优惠劵模板到数据库
CouponTemplateDO
updateTemplateDO
=
CouponTemplateConvert
.
INSTANCE
.
convert
(
updateReqDTO
);
couponTemplateMapper
.
updateById
(
updateTemplateDO
);
}
// ========== 优惠码模板 TODO 芋艿:以后开发 ==========
}
归档/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml
deleted
100644 → 0
浏览文件 @
0e6d9487
spring
:
# 数据源配置项
datasource
:
url
:
jdbc:mysql://localhost:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name
:
com.mysql.jdbc.Driver
username
:
root
password
:
zhuyang
# Spring Cloud 配置项
cloud
:
nacos
:
# Spring Cloud Nacos Discovery 配置项
discovery
:
server-addr
:
localhost:8848
# Nacos 服务器地址
namespace
:
dev
# Nacos 命名空间
# Dubbo 配置项
dubbo
:
# Dubbo 注册中心
registry
:
# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
address
:
nacos://localhost:8848?namespace=dev
# 指定 Dubbo 服务注册中心的地址
归档/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml
deleted
100644 → 0
浏览文件 @
0e6d9487
spring
:
# 数据源配置项
datasource
:
url
:
jdbc:mysql://localhost:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name
:
com.mysql.jdbc.Driver
username
:
root
password
:
zhuyang
# Spring Cloud 配置项
cloud
:
nacos
:
# Spring Cloud Nacos Discovery 配置项
discovery
:
server-addr
:
localhost:8848
# Nacos 服务器地址
namespace
:
dev
# Nacos 命名空间
# Dubbo 配置项
dubbo
:
# Dubbo 注册中心
registry
:
# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
address
:
nacos://localhost:8848?namespace=dev
# 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider
:
tag
:
${DUBBO_TAG}
# Dubbo 路由分组
归档/promotion-service-project/promotion-service-app/src/main/resources/application.yaml
deleted
100644 → 0
浏览文件 @
0e6d9487
spring
:
# Application 的配置项
application
:
name
:
promotion-service
# Profile 的配置项
profiles
:
active
:
local
# MyBatis Plus 配置项
mybatis-plus
:
configuration
:
map-underscore-to-camel-case
:
true
# 虽然默认为 true ,但是还是显示去指定下。
global-config
:
db-config
:
id-type
:
auto
logic-delete-value
:
1
# 逻辑已删除值(默认为 1)
logic-not-delete-value
:
0
# 逻辑未删除值(默认为 0)
mapper-locations
:
classpath*:mapper/*.xml
type-aliases-package
:
cn.iocoder.mall.promotionservice.dal.mysql.dataobject
# Dubbo 配置项
dubbo
:
# Spring Cloud Alibaba Dubbo 专属配置
cloud
:
subscribed-services
:
'
'
# 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol
:
name
:
dubbo
port
:
-1
# Dubbo 提供服务的扫描基础包
scan
:
base-packages
:
cn.iocoder.mall.promotionservice.rpc
# Dubbo 服务提供者的配置
provider
:
filter
:
-exception
validation
:
true
# 开启 Provider 参数校验
version
:
1.0.0
# 服务的版本号
# Dubbo 服务消费者的配置
consumer
:
ErrorCodeRpc
:
version
:
1.0.0
ProductSkuRpc
:
version
:
1.0.0
ProductSpuRpc
:
version
:
1.0.0
# RocketMQ 配置项
rocketmq
:
name-server
:
localhost:9876
producer
:
group
:
${spring.application.name}-producer-group
# Actuator 监控配置项
management
:
server.port
:
38085
# 独立端口,避免被暴露出去
endpoints.web.exposure.include
:
'
*'
# 暴露所有监控端点
server.port
:
${management.server.port}
# 设置使用 Actuator 的服务器端口,因为 RPC 服务不需要 Web 端口
# Mall 配置项
mall
:
# 错误码配置项对应 ErrorCodeProperties 配置类
error-code
:
group
:
${spring.application.name}
constants-class
:
cn.iocoder.mall.promotionservice.enums.PromotionErrorCodeConstants
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论