|
@@ -3,14 +3,18 @@ package com.seamew.lottery.application.process.impl;
|
|
|
import com.seamew.lottery.application.process.IActivityProcess;
|
|
|
import com.seamew.lottery.application.process.req.DrawProcessReq;
|
|
|
import com.seamew.lottery.application.process.res.DrawProcessResult;
|
|
|
+import com.seamew.lottery.application.process.res.RuleQuantificationCrowdResult;
|
|
|
import com.seamew.lottery.common.Constants;
|
|
|
import com.seamew.lottery.domain.activity.model.req.PartakeReq;
|
|
|
import com.seamew.lottery.domain.activity.model.res.PartakeResult;
|
|
|
import com.seamew.lottery.domain.activity.model.vo.DrawOrderVO;
|
|
|
import com.seamew.lottery.domain.activity.service.partake.IActivityPartake;
|
|
|
+import com.seamew.lottery.domain.rule.model.req.DecisionMatterReq;
|
|
|
+import com.seamew.lottery.domain.rule.model.res.EngineResult;
|
|
|
+import com.seamew.lottery.domain.rule.service.engine.EngineFilter;
|
|
|
import com.seamew.lottery.domain.strategy.model.req.DrawReq;
|
|
|
import com.seamew.lottery.domain.strategy.model.res.DrawResult;
|
|
|
-import com.seamew.lottery.domain.strategy.model.vo.DrawAwardInfo;
|
|
|
+import com.seamew.lottery.domain.strategy.model.vo.DrawAwardVO;
|
|
|
import com.seamew.lottery.domain.strategy.service.draw.IDrawExec;
|
|
|
import com.seamew.lottery.domain.support.ids.IIdGenerator;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -33,6 +37,9 @@ public class ActivityProcessImpl implements IActivityProcess {
|
|
|
@Resource
|
|
|
private IDrawExec drawExec;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private EngineFilter engineFilter;
|
|
|
+
|
|
|
@Resource
|
|
|
private Map<Constants.Ids, IIdGenerator> idGeneratorMap;
|
|
|
|
|
@@ -47,22 +54,39 @@ public class ActivityProcessImpl implements IActivityProcess {
|
|
|
Long takeId = partakeResult.getTakeId();
|
|
|
|
|
|
// 2. 执行抽奖
|
|
|
- DrawResult drawResult = drawExec.doDrawExec(new DrawReq(req.getUId(), strategyId, String.valueOf(takeId)));
|
|
|
+ DrawResult drawResult = drawExec.doDrawExec(new DrawReq(req.getUId(), strategyId));
|
|
|
if (Constants.DrawState.FAIL.getCode().equals(drawResult.getDrawState())) {
|
|
|
return new DrawProcessResult(Constants.ResponseCode.LOSING_DRAW.getCode(), Constants.ResponseCode.LOSING_DRAW.getInfo());
|
|
|
}
|
|
|
- DrawAwardInfo drawAwardInfo = drawResult.getDrawAwardInfo();
|
|
|
+ DrawAwardVO drawAwardVO = drawResult.getDrawAwardInfo();
|
|
|
|
|
|
// 3. 结果落库
|
|
|
- activityPartake.recordDrawOrder(buildDrawOrderVO(req, strategyId, takeId, drawAwardInfo));
|
|
|
+ activityPartake.recordDrawOrder(buildDrawOrderVO(req, strategyId, takeId, drawAwardVO));
|
|
|
|
|
|
// 4. 发送MQ,触发发奖流程
|
|
|
|
|
|
// 5. 返回结果
|
|
|
- return new DrawProcessResult(Constants.ResponseCode.SUCCESS.getCode(), Constants.ResponseCode.SUCCESS.getInfo(), drawAwardInfo);
|
|
|
+ return new DrawProcessResult(Constants.ResponseCode.SUCCESS.getCode(), Constants.ResponseCode.SUCCESS.getInfo(), drawAwardVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RuleQuantificationCrowdResult doRuleQuantificationCrowd(DecisionMatterReq req) {
|
|
|
+ // 1. 量化决策
|
|
|
+ EngineResult engineResult = engineFilter.process(req);
|
|
|
+
|
|
|
+ if (!engineResult.isSuccess()) {
|
|
|
+ return new RuleQuantificationCrowdResult(Constants.ResponseCode.RULE_ERR.getCode(), Constants.ResponseCode.RULE_ERR.getInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 封装结果
|
|
|
+ RuleQuantificationCrowdResult ruleQuantificationCrowdResult = new RuleQuantificationCrowdResult(Constants.ResponseCode.SUCCESS.getCode(), Constants.ResponseCode.SUCCESS.getInfo());
|
|
|
+ ruleQuantificationCrowdResult.setActivityId(Long.valueOf(engineResult.getNodeValue()));
|
|
|
+
|
|
|
+ return ruleQuantificationCrowdResult;
|
|
|
}
|
|
|
|
|
|
- private DrawOrderVO buildDrawOrderVO(DrawProcessReq req, Long strategyId, Long takeId, DrawAwardInfo drawAwardInfo) {
|
|
|
+
|
|
|
+ private DrawOrderVO buildDrawOrderVO(DrawProcessReq req, Long strategyId, Long takeId, DrawAwardVO drawAwardVO) {
|
|
|
long orderId = idGeneratorMap.get(Constants.Ids.SnowFlake).nextId();
|
|
|
DrawOrderVO drawOrderVO = new DrawOrderVO();
|
|
|
drawOrderVO.setUId(req.getUId());
|
|
@@ -70,14 +94,14 @@ public class ActivityProcessImpl implements IActivityProcess {
|
|
|
drawOrderVO.setActivityId(req.getActivityId());
|
|
|
drawOrderVO.setOrderId(orderId);
|
|
|
drawOrderVO.setStrategyId(strategyId);
|
|
|
- drawOrderVO.setStrategyMode(drawAwardInfo.getStrategyMode());
|
|
|
- drawOrderVO.setGrantType(drawAwardInfo.getGrantType());
|
|
|
- drawOrderVO.setGrantDate(drawAwardInfo.getGrantDate());
|
|
|
+ drawOrderVO.setStrategyMode(drawAwardVO.getStrategyMode());
|
|
|
+ drawOrderVO.setGrantType(drawAwardVO.getGrantType());
|
|
|
+ drawOrderVO.setGrantDate(drawAwardVO.getGrantDate());
|
|
|
drawOrderVO.setGrantState(Constants.GrantState.INIT.getCode());
|
|
|
- drawOrderVO.setAwardId(drawAwardInfo.getAwardId());
|
|
|
- drawOrderVO.setAwardType(drawAwardInfo.getAwardType());
|
|
|
- drawOrderVO.setAwardName(drawAwardInfo.getAwardName());
|
|
|
- drawOrderVO.setAwardContent(drawAwardInfo.getAwardContent());
|
|
|
+ drawOrderVO.setAwardId(drawAwardVO.getAwardId());
|
|
|
+ drawOrderVO.setAwardType(drawAwardVO.getAwardType());
|
|
|
+ drawOrderVO.setAwardName(drawAwardVO.getAwardName());
|
|
|
+ drawOrderVO.setAwardContent(drawAwardVO.getAwardContent());
|
|
|
return drawOrderVO;
|
|
|
}
|
|
|
}
|