Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
-Bin
Lottery-702-happy
提交
68ac25f4
L
Lottery-702-happy
项目概览
-Bin
/
Lottery-702-happy
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
Lottery-702-happy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
68ac25f4
编写于
2月 18, 2022
作者:
H
HappyChan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完成award领域开发
上级
c2801294
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
627 addition
and
15 deletion
+627
-15
lottery-common/src/main/java/cn/happy/lottery/common/Constants.java
...mmon/src/main/java/cn/happy/lottery/common/Constants.java
+86
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/model/req/GoodsReq.java
...ava/cn/happy/lottery/domain/award/model/req/GoodsReq.java
+99
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/model/res/DistributionRes.java
...happy/lottery/domain/award/model/res/DistributionRes.java
+77
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/model/vo/ShippingAddress.java
.../happy/lottery/domain/award/model/vo/ShippingAddress.java
+11
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/repository/IAwardRepository.java
...ppy/lottery/domain/award/repository/IAwardRepository.java
+9
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/repository/impl/AwardRepository.java
...lottery/domain/award/repository/impl/AwardRepository.java
+15
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/factory/DistributionGoodsFactory.java
...omain/award/service/factory/DistributionGoodsFactory.java
+19
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/factory/GoodsConfig.java
...ppy/lottery/domain/award/service/factory/GoodsConfig.java
+49
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/DistributionBase.java
.../lottery/domain/award/service/goods/DistributionBase.java
+26
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/IDistributionGoods.java
...ottery/domain/award/service/goods/IDistributionGoods.java
+21
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/CouponGoods.java
.../lottery/domain/award/service/goods/impl/CouponGoods.java
+30
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/DescGoods.java
...py/lottery/domain/award/service/goods/impl/DescGoods.java
+28
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/PhysicalGoods.java
...ottery/domain/award/service/goods/impl/PhysicalGoods.java
+32
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/RedeemCodeGoods.java
...tery/domain/award/service/goods/impl/RedeemCodeGoods.java
+32
-0
lottery-domain/src/main/java/cn/happy/lottery/domain/strategy/model/vo/DrawAwardInfo.java
...happy/lottery/domain/strategy/model/vo/DrawAwardInfo.java
+41
-9
lottery-domain/src/main/java/cn/happy/lottery/domain/strategy/service/draw/AbstractDrawBase.java
...ottery/domain/strategy/service/draw/AbstractDrawBase.java
+1
-1
lottery-infrastructure/src/main/java/cn/happy/lottery/infrastructure/po/StrategyDetail.java
...va/cn/happy/lottery/infrastructure/po/StrategyDetail.java
+14
-0
lottery-interfaces/src/test/java/cn/happy/lottery/test/SpringRunnerTest.java
...src/test/java/cn/happy/lottery/test/SpringRunnerTest.java
+37
-5
未找到文件。
lottery-common/src/main/java/cn/happy/lottery/common/Constants.java
浏览文件 @
68ac25f4
...
...
@@ -100,4 +100,90 @@ public class Constants {
}
}
public
enum
AwardState
{
/**
* 等待发奖
*/
WAIT
(
0
,
"等待发奖"
),
/**
* 发奖成功
*/
SUCCESS
(
1
,
"发奖成功"
),
/**
* 发奖失败
*/
FAILURE
(
2
,
"发奖失败"
);
private
Integer
code
;
private
String
info
;
AwardState
(
Integer
code
,
String
info
)
{
this
.
code
=
code
;
this
.
info
=
info
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getInfo
()
{
return
info
;
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
}
public
enum
AwardType
{
/**
* 文字描述
*/
DESC
(
1
,
"文字描述"
),
/**
* 兑换码
*/
RedeemCodeGoods
(
2
,
"兑换码"
),
/**
* 优惠券
*/
CouponGoods
(
3
,
"优惠券"
),
/**
* 实物奖品
*/
PhysicalGoods
(
4
,
"实物奖品"
);
private
Integer
code
;
private
String
info
;
AwardType
(
Integer
code
,
String
info
)
{
this
.
code
=
code
;
this
.
info
=
info
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getInfo
()
{
return
info
;
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/model/req/GoodsReq.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.model.req
;
import
cn.happy.lottery.domain.award.model.vo.ShippingAddress
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
public
class
GoodsReq
{
/** 用户ID */
private
String
uId
;
/** 抽奖单号 ID */
private
String
orderId
;
/** 奖品ID */
private
String
awardId
;
/**
* 奖品名称
*/
private
String
awardName
;
/**
* 奖品内容「描述、奖品码、sku」
*/
private
String
awardContent
;
/** 四级送货地址(只有实物类商品需要地址) */
private
ShippingAddress
shippingAddress
;
public
GoodsReq
(
String
uId
,
String
orderId
,
String
awardId
,
String
awardName
,
String
awardContent
)
{
this
.
uId
=
uId
;
this
.
orderId
=
orderId
;
this
.
awardId
=
awardId
;
this
.
awardName
=
awardName
;
this
.
awardContent
=
awardContent
;
}
public
GoodsReq
(
String
uId
,
String
orderId
,
String
awardId
,
String
awardName
,
String
awardContent
,
ShippingAddress
shippingAddress
)
{
this
.
uId
=
uId
;
this
.
orderId
=
orderId
;
this
.
awardId
=
awardId
;
this
.
awardName
=
awardName
;
this
.
awardContent
=
awardContent
;
this
.
shippingAddress
=
shippingAddress
;
}
public
String
getuId
()
{
return
uId
;
}
public
void
setuId
(
String
uId
)
{
this
.
uId
=
uId
;
}
public
String
getOrderId
()
{
return
orderId
;
}
public
void
setOrderId
(
String
orderId
)
{
this
.
orderId
=
orderId
;
}
public
String
getAwardId
()
{
return
awardId
;
}
public
void
setAwardId
(
String
awardId
)
{
this
.
awardId
=
awardId
;
}
public
String
getAwardName
()
{
return
awardName
;
}
public
void
setAwardName
(
String
awardName
)
{
this
.
awardName
=
awardName
;
}
public
String
getAwardContent
()
{
return
awardContent
;
}
public
void
setAwardContent
(
String
awardContent
)
{
this
.
awardContent
=
awardContent
;
}
public
ShippingAddress
getShippingAddress
()
{
return
shippingAddress
;
}
public
void
setShippingAddress
(
ShippingAddress
shippingAddress
)
{
this
.
shippingAddress
=
shippingAddress
;
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/model/res/DistributionRes.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.model.res
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
public
class
DistributionRes
{
/**
* 用户ID
*/
private
String
uId
;
/**
* 编码
*/
private
Integer
code
;
/**
* 描述
*/
private
String
info
;
/**
* 结算单ID,如:发券后有券码、发货后有单号等,用于存根查询
*/
private
String
statementId
;
public
DistributionRes
()
{
}
public
DistributionRes
(
String
uId
,
Integer
code
,
String
info
)
{
this
.
uId
=
uId
;
this
.
code
=
code
;
this
.
info
=
info
;
}
public
DistributionRes
(
String
uId
,
Integer
code
,
String
info
,
String
statementId
)
{
this
.
uId
=
uId
;
this
.
code
=
code
;
this
.
info
=
info
;
this
.
statementId
=
statementId
;
}
public
String
getuId
()
{
return
uId
;
}
public
void
setuId
(
String
uId
)
{
this
.
uId
=
uId
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getInfo
()
{
return
info
;
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
public
String
getStatementId
()
{
return
statementId
;
}
public
void
setStatementId
(
String
statementId
)
{
this
.
statementId
=
statementId
;
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/model/vo/ShippingAddress.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.model.vo
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
public
class
ShippingAddress
{
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/repository/IAwardRepository.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.repository
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
public
interface
IAwardRepository
{
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/repository/impl/AwardRepository.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.repository.impl
;
import
cn.happy.lottery.domain.award.repository.IAwardRepository
;
import
org.springframework.stereotype.Component
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
@Component
public
class
AwardRepository
implements
IAwardRepository
{
// TODO 对分库分表中的用户中奖记录操作
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/factory/DistributionGoodsFactory.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.factory
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
@Service
public
class
DistributionGoodsFactory
extends
GoodsConfig
{
public
IDistributionGoods
getDistributionGoodsService
(
Integer
awardType
)
{
return
goodsMap
.
get
(
awardType
);
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/factory/GoodsConfig.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.factory
;
import
cn.happy.lottery.common.Constants
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
cn.happy.lottery.domain.award.service.goods.impl.CouponGoods
;
import
cn.happy.lottery.domain.award.service.goods.impl.DescGoods
;
import
cn.happy.lottery.domain.award.service.goods.impl.PhysicalGoods
;
import
cn.happy.lottery.domain.award.service.goods.impl.RedeemCodeGoods
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
public
class
GoodsConfig
{
/**
* 奖品发放策略组
*/
protected
static
Map
<
Integer
,
IDistributionGoods
>
goodsMap
=
new
ConcurrentHashMap
<>();
@Resource
private
DescGoods
descGoods
;
@Resource
private
CouponGoods
couponGoods
;
@Resource
private
RedeemCodeGoods
redeemCodeGoods
;
@Resource
private
PhysicalGoods
physicalGoods
;
@PostConstruct
public
void
init
()
{
goodsMap
.
put
(
Constants
.
AwardType
.
DESC
.
getCode
(),
descGoods
);
goodsMap
.
put
(
Constants
.
AwardType
.
RedeemCodeGoods
.
getCode
(),
redeemCodeGoods
);
goodsMap
.
put
(
Constants
.
AwardType
.
CouponGoods
.
getCode
(),
couponGoods
);
goodsMap
.
put
(
Constants
.
AwardType
.
PhysicalGoods
.
getCode
(),
physicalGoods
);
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/DistributionBase.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.goods
;
import
cn.happy.lottery.domain.award.repository.IAwardRepository
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.Resource
;
/**
* @author Happy
* @description:
* @date 2022/2/17
*/
public
class
DistributionBase
{
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
DistributionBase
.
class
);
@Resource
IAwardRepository
awardRepository
;
protected
void
updateUserAwardState
(
String
uId
,
String
orderId
,
String
awardId
,
Integer
awardState
,
String
awardStateInfo
)
{
// TODO 后期添加更新分库分表中,用户个人的抽奖记录表中奖品发奖状态
logger
.
info
(
"TODO 后期添加更新分库分表中,用户个人的抽奖记录表中奖品发奖状态 uId:{}"
,
uId
);
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/IDistributionGoods.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.goods
;
import
cn.happy.lottery.domain.award.model.req.GoodsReq
;
import
cn.happy.lottery.domain.award.model.res.DistributionRes
;
/**
* @author Happy
* @description: 奖品配送接口
* @date 2022/2/17
*/
public
interface
IDistributionGoods
{
/**
* 奖品配送接口,奖品类型(1:文字描述、2:兑换码、3:优惠券、4:实物奖品)
*
* @param req 物品信息
* @return 配送结果
*/
DistributionRes
doDistribution
(
GoodsReq
req
);
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/CouponGoods.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.goods.impl
;
import
cn.happy.lottery.domain.award.model.req.GoodsReq
;
import
cn.happy.lottery.domain.award.model.res.DistributionRes
;
import
cn.happy.lottery.domain.award.service.goods.DistributionBase
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
cn.happy.lottery.common.Constants
;
import
org.springframework.stereotype.Component
;
/**
* @author Happy
* @description: 优惠券
* @date 2022/2/17
*/
@Component
public
class
CouponGoods
extends
DistributionBase
implements
IDistributionGoods
{
@Override
public
DistributionRes
doDistribution
(
GoodsReq
req
)
{
// 模拟调用优惠券发放接口
logger
.
info
(
"模拟优惠券调用发放接口 uId,{} awardContent:{}"
,
req
.
getuId
(),
req
.
getAwardContent
());
// 更新用户领奖结果
super
.
updateUserAwardState
(
req
.
getuId
(),
req
.
getOrderId
(),
req
.
getAwardId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
return
new
DistributionRes
(
req
.
getuId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/DescGoods.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.goods.impl
;
import
cn.happy.lottery.common.Constants
;
import
cn.happy.lottery.domain.award.model.req.GoodsReq
;
import
cn.happy.lottery.domain.award.model.res.DistributionRes
;
import
cn.happy.lottery.domain.award.service.goods.DistributionBase
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
org.springframework.stereotype.Component
;
/**
* @description: 描述类商品,以文字形式展示给用户
* @author: 小傅哥,微信:fustack
* @date: 2021/9/4
* @github: https://github.com/fuzhengwei
* @Copyright: 公众号:bugstack虫洞栈 | 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获!
*/
@Component
public
class
DescGoods
extends
DistributionBase
implements
IDistributionGoods
{
@Override
public
DistributionRes
doDistribution
(
GoodsReq
req
)
{
super
.
updateUserAwardState
(
req
.
getuId
(),
req
.
getOrderId
(),
req
.
getAwardId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
return
new
DistributionRes
(
req
.
getuId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/PhysicalGoods.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.goods.impl
;
import
cn.happy.lottery.common.Constants
;
import
cn.happy.lottery.domain.award.model.req.GoodsReq
;
import
cn.happy.lottery.domain.award.model.res.DistributionRes
;
import
cn.happy.lottery.domain.award.service.goods.DistributionBase
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
org.springframework.stereotype.Component
;
/**
* @description: 实物发货类商品
* @author: 小傅哥,微信:fustack
* @date: 2021/9/4
* @github: https://github.com/fuzhengwei
* @Copyright: 公众号:bugstack虫洞栈 | 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获!
*/
@Component
public
class
PhysicalGoods
extends
DistributionBase
implements
IDistributionGoods
{
@Override
public
DistributionRes
doDistribution
(
GoodsReq
req
)
{
// 模拟调用实物发奖
logger
.
info
(
"模拟调用实物发奖 uId:{} awardContent:{}"
,
req
.
getuId
(),
req
.
getAwardContent
());
// 更新用户领奖结果
super
.
updateUserAwardState
(
req
.
getuId
(),
req
.
getOrderId
(),
req
.
getAwardId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
return
new
DistributionRes
(
req
.
getuId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/award/service/goods/impl/RedeemCodeGoods.java
0 → 100644
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.award.service.goods.impl
;
import
cn.happy.lottery.common.Constants
;
import
cn.happy.lottery.domain.award.model.req.GoodsReq
;
import
cn.happy.lottery.domain.award.model.res.DistributionRes
;
import
cn.happy.lottery.domain.award.service.goods.DistributionBase
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
org.springframework.stereotype.Component
;
/**
* @description: 兑换码类商品
* @author: 小傅哥,微信:fustack
* @date: 2021/9/4
* @github: https://github.com/fuzhengwei
* @Copyright: 公众号:bugstack虫洞栈 | 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获!
*/
@Component
public
class
RedeemCodeGoods
extends
DistributionBase
implements
IDistributionGoods
{
@Override
public
DistributionRes
doDistribution
(
GoodsReq
req
)
{
// 模拟调用兑换码
logger
.
info
(
"模拟调用兑换码 uId:{} awardContent:{}"
,
req
.
getuId
(),
req
.
getAwardContent
());
// 更新用户领奖结果
super
.
updateUserAwardState
(
req
.
getuId
(),
req
.
getOrderId
(),
req
.
getAwardId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
return
new
DistributionRes
(
req
.
getuId
(),
Constants
.
AwardState
.
SUCCESS
.
getCode
(),
Constants
.
AwardState
.
SUCCESS
.
getInfo
());
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/strategy/model/vo/DrawAwardInfo.java
浏览文件 @
68ac25f4
package
cn.happy.lottery.domain.strategy.model.vo
;
/**
* @author Happy
* @description: 中奖奖品信息
* @date 2022/2/17
* @author:小傅哥,微信:fustack
* @date: 2021/8/28
* @Copyright: 公众号:bugstack虫洞栈 | 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获!
*/
public
class
DrawAwardInfo
{
/**
* 奖品ID
*/
private
String
rewardId
;
private
String
awardId
;
/**
* 奖品类型(1:文字描述、2:兑换码、3:优惠券、4:实物奖品)
*/
private
Integer
awardType
;
/**
* 奖品名称
*/
private
String
awardName
;
public
DrawAwardInfo
(
String
rewardId
,
String
awardName
)
{
this
.
rewardId
=
rewardId
;
/**
* 奖品内容「描述、奖品码、sku」
*/
private
String
awardContent
;
public
DrawAwardInfo
()
{
}
public
DrawAwardInfo
(
String
awardId
,
Integer
awardType
,
String
awardName
,
String
awardContent
)
{
this
.
awardId
=
awardId
;
this
.
awardType
=
awardType
;
this
.
awardName
=
awardName
;
this
.
awardContent
=
awardContent
;
}
public
String
get
Re
wardId
()
{
return
re
wardId
;
public
String
get
A
wardId
()
{
return
a
wardId
;
}
public
void
setRewardId
(
String
rewardId
)
{
this
.
rewardId
=
rewardId
;
public
void
setAwardId
(
String
awardId
)
{
this
.
awardId
=
awardId
;
}
public
Integer
getAwardType
()
{
return
awardType
;
}
public
void
setAwardType
(
Integer
awardType
)
{
this
.
awardType
=
awardType
;
}
public
String
getAwardName
()
{
...
...
@@ -37,4 +61,12 @@ public class DrawAwardInfo {
public
void
setAwardName
(
String
awardName
)
{
this
.
awardName
=
awardName
;
}
public
String
getAwardContent
()
{
return
awardContent
;
}
public
void
setAwardContent
(
String
awardContent
)
{
this
.
awardContent
=
awardContent
;
}
}
lottery-domain/src/main/java/cn/happy/lottery/domain/strategy/service/draw/AbstractDrawBase.java
浏览文件 @
68ac25f4
...
...
@@ -84,7 +84,7 @@ public abstract class AbstractDrawBase extends DrawStrategySupport implements ID
// 中奖
Award
award
=
super
.
queryAwardInfoByAwardId
(
awardId
);
DrawAwardInfo
drawAwardInfo
=
new
DrawAwardInfo
(
award
.
getAwardId
(),
award
.
getAward
Name
());
DrawAwardInfo
drawAwardInfo
=
new
DrawAwardInfo
(
award
.
getAwardId
(),
award
.
getAward
Type
(),
award
.
getAwardName
(),
award
.
getAwardContent
());
logger
.
info
(
"执行策略抽奖完成【已中奖】,用户:{} 策略ID:{} 奖品ID:{} 奖品名称:{}"
,
uid
,
strategyId
,
award
.
getAwardId
(),
award
.
getAwardName
());
return
new
DrawResult
(
uid
,
strategyId
,
Constants
.
DrawState
.
SUCCESS
.
getCode
(),
drawAwardInfo
);
}
...
...
lottery-infrastructure/src/main/java/cn/happy/lottery/infrastructure/po/StrategyDetail.java
浏览文件 @
68ac25f4
...
...
@@ -24,6 +24,12 @@ public class StrategyDetail {
*/
private
String
awardId
;
/**
* 奖品名称
*/
private
String
awardName
;
/**
* 奖品数量
*/
...
...
@@ -73,6 +79,14 @@ public class StrategyDetail {
this
.
awardId
=
awardId
;
}
public
String
getAwardName
()
{
return
awardName
;
}
public
void
setAwardName
(
String
awardName
)
{
this
.
awardName
=
awardName
;
}
public
String
getAwardCount
()
{
return
awardCount
;
}
...
...
lottery-interfaces/src/test/java/cn/happy/lottery/test/SpringRunnerTest.java
浏览文件 @
68ac25f4
package
cn.happy.lottery.test
;
import
cn.happy.lottery.common.Constants
;
import
cn.happy.lottery.domain.award.model.req.GoodsReq
;
import
cn.happy.lottery.domain.award.model.res.DistributionRes
;
import
cn.happy.lottery.domain.award.service.goods.IDistributionGoods
;
import
cn.happy.lottery.domain.strategy.model.req.DrawReq
;
import
cn.happy.lottery.domain.strategy.model.res.DrawResult
;
import
cn.happy.lottery.domain.strategy.model.vo.DrawAwardInfo
;
import
cn.happy.lottery.domain.strategy.service.draw.IDrawExec
;
import
cn.happy.lottery.infrastructure.dao.IActivityDao
;
import
cn.happy.lottery.infrastructure.dao.IAwardDao
;
...
...
@@ -21,6 +27,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
cn.happy.lottery.domain.award.service.factory.DistributionGoodsFactory
;
/**
* @author Happy
...
...
@@ -34,19 +41,22 @@ public class SpringRunnerTest {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SpringRunnerTest
.
class
);
@Resource
IActivityDao
activityDao
;
private
IActivityDao
activityDao
;
@Resource
IAwardDao
awardDao
;
private
IAwardDao
awardDao
;
@Resource
IStrategyDao
strategyDao
;
private
IStrategyDao
strategyDao
;
@Resource
IStrategyDetailDao
strategyDetailDao
;
private
IStrategyDetailDao
strategyDetailDao
;
@Resource
IDrawExec
drawExec
;
private
IDrawExec
drawExec
;
@Resource
private
DistributionGoodsFactory
distributionGoodsFactory
;
@Test
public
void
test_drawExec
()
{
...
...
@@ -56,6 +66,28 @@ public class SpringRunnerTest {
drawExec
.
doDrawExec
(
new
DrawReq
(
"八杯水"
,
10001L
));
}
@Test
public
void
test_award
()
{
// 执行抽奖
DrawResult
drawResult
=
drawExec
.
doDrawExec
(
new
DrawReq
(
"happy"
,
10001L
));
// 判断抽奖结果
if
(
Constants
.
DrawState
.
FAIL
.
getCode
().
equals
(
drawResult
.
getDrawState
()))
{
logger
.
info
(
"未中奖 DrawAwardInfo is null"
);
return
;
}
// 封装发奖参数,orderId:2109313442431 为模拟ID,需要在用户参与领奖活动时生成
DrawAwardInfo
drawAwardInfo
=
drawResult
.
getDrawAwardInfo
();
GoodsReq
goodsReq
=
new
GoodsReq
(
drawResult
.
getuId
(),
"2109313442431"
,
drawAwardInfo
.
getAwardId
(),
drawAwardInfo
.
getAwardName
(),
drawAwardInfo
.
getAwardContent
());
// 根据 awardType 从抽奖工厂中获取对应的发奖服务
IDistributionGoods
distributionGoodsService
=
distributionGoodsFactory
.
getDistributionGoodsService
(
drawAwardInfo
.
getAwardType
());
DistributionRes
distributionRes
=
distributionGoodsService
.
doDistribution
(
goodsReq
);
logger
.
info
(
"测试结果:{}"
,
JSON
.
toJSONString
(
distributionRes
));
}
@Test
public
void
test_insert
()
{
Activity
activity
=
new
Activity
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录