From e117fe17d11b5877df85e4269922495875ba1c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=8F=90=E8=AF=B4=E8=AF=B4?= <1913210361@qq.com> Date: Mon, 3 Jun 2019 13:04:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Stream=20=E7=94=A8=E7=9A=8466=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- java/NBStream | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 java/NBStream diff --git a/java/NBStream b/java/NBStream new file mode 100644 index 0000000..3df1de7 --- /dev/null +++ b/java/NBStream @@ -0,0 +1,87 @@ +//Stream 用的66的 +final EventAction eventAction = redisObj( + EventActionKey + distributionEventId, + () -> Optional + .of(distributionEventId) + .map(eventId -> { + final EventActionExample example = new EventActionExample(); + example.createCriteria() + .andEventIdEqualTo(eventId) + .andTriggerTypeEqualTo(EnumEventTriggerType.DISTRIBUTION_PURCHASE.getCode().byteValue()); + return example; + }) + .map(eventActionMapper::selectByExample) + .filter(StringUtil::isNotEmpty) + .map(e -> e.get(0)).orElseThrow(() -> ExceptionUtil.createParamException("事件触发信息不存在")) + , EventAction.class); + final AwardConfig awardConfig = redisObj(EventConfigKey + eventAction.getId(), + () -> Optional.ofNullable(eventAction.getId()) + .map(actionId -> { + final AwardConfigExample example = new AwardConfigExample(); + example.createCriteria() + .andActionIdEqualTo(actionId); + return example; + }) + .map(awardConfigMapper::selectByExample) + .filter(StringUtil::isNotEmpty) + .map(e -> e.get(0)).orElseThrow(() -> ExceptionUtil.createParamException("xxx")), + AwardConfig.class + ); + Optional.of(req) + .map(e -> e.clueUid) + .map(id -> { + final ClueExample example = new ClueExample(); + example.createCriteria() + .andClueUidEqualTo(id) + .andDeletedEqualTo(false) + .andReceivedEqualTo(false) + .andCreateTimeGreaterThan(now - cluetime); + example.setOrderByClause("create_time asc"); + return example; + }) // 获取该被邀请人所有未过期且未被领取的线索的线索 + .map(clueMapper::selectByExample) + .filter(StringUtil::isNotEmpty) + .ifPresent(clues -> { + final ClueResp clueResp = Optional.of(req) + .filter(c -> { + c.count = clues.size(); + return true; + }) + .map(this::awardValue) + .orElseThrow(() -> ExceptionUtil.createParamException("参数错误")); + final Integer specialId = req.getIsHead() + ? clues.get(0).getId() + : clues.get(clues.size() - 1).getId(); + clues.stream() + .peek(clue -> { + final AwardConfig awardConfigclone = Optional.of(awardConfig) + .map(JSONUtil::obj2Json) + .map(json -> JSONUtil.json2Obj(json, AwardConfig.class)) + .orElseGet(AwardConfig::new); + awardConfigclone.setMoney( + Optional.of(clue.getId()) + .filter(specialId::equals) + .map(e -> clueResp.specialReward.longValue()) + .orElse(clueResp.otherAverageReward.longValue()) + ); + eventActionService.assembleAward( + awardConfigclone, + clue.getAdviserUid(), + clue.getAdviserUid(), + clue.getClueUid(), + eventAction, + new PasMessageParam(), + clue.getId(), + AwardRelationType.Clud.code() + ); + }) + .forEach(clue -> { + clue.setOrderNo(req.orderNo); + clue.setCommodityName(req.commodityName); + clue.setOrderAmount(req.orderAmount); + clue.setReceived(true); + clue.setModifyTime(now); + clueMapper.updateByPrimaryKeySelective(clue); + }); + } + ); \ No newline at end of file -- Gitee From e401b860b07d99606ad4b5c6a9fa8c5124d87916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=8F=90=E8=AF=B4=E8=AF=B4?= <1913210361@qq.com> Date: Mon, 3 Jun 2019 13:04:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6java/NB?= =?UTF-8?q?Stream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- java/NBStream | 87 --------------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 java/NBStream diff --git a/java/NBStream b/java/NBStream deleted file mode 100644 index 3df1de7..0000000 --- a/java/NBStream +++ /dev/null @@ -1,87 +0,0 @@ -//Stream 用的66的 -final EventAction eventAction = redisObj( - EventActionKey + distributionEventId, - () -> Optional - .of(distributionEventId) - .map(eventId -> { - final EventActionExample example = new EventActionExample(); - example.createCriteria() - .andEventIdEqualTo(eventId) - .andTriggerTypeEqualTo(EnumEventTriggerType.DISTRIBUTION_PURCHASE.getCode().byteValue()); - return example; - }) - .map(eventActionMapper::selectByExample) - .filter(StringUtil::isNotEmpty) - .map(e -> e.get(0)).orElseThrow(() -> ExceptionUtil.createParamException("事件触发信息不存在")) - , EventAction.class); - final AwardConfig awardConfig = redisObj(EventConfigKey + eventAction.getId(), - () -> Optional.ofNullable(eventAction.getId()) - .map(actionId -> { - final AwardConfigExample example = new AwardConfigExample(); - example.createCriteria() - .andActionIdEqualTo(actionId); - return example; - }) - .map(awardConfigMapper::selectByExample) - .filter(StringUtil::isNotEmpty) - .map(e -> e.get(0)).orElseThrow(() -> ExceptionUtil.createParamException("xxx")), - AwardConfig.class - ); - Optional.of(req) - .map(e -> e.clueUid) - .map(id -> { - final ClueExample example = new ClueExample(); - example.createCriteria() - .andClueUidEqualTo(id) - .andDeletedEqualTo(false) - .andReceivedEqualTo(false) - .andCreateTimeGreaterThan(now - cluetime); - example.setOrderByClause("create_time asc"); - return example; - }) // 获取该被邀请人所有未过期且未被领取的线索的线索 - .map(clueMapper::selectByExample) - .filter(StringUtil::isNotEmpty) - .ifPresent(clues -> { - final ClueResp clueResp = Optional.of(req) - .filter(c -> { - c.count = clues.size(); - return true; - }) - .map(this::awardValue) - .orElseThrow(() -> ExceptionUtil.createParamException("参数错误")); - final Integer specialId = req.getIsHead() - ? clues.get(0).getId() - : clues.get(clues.size() - 1).getId(); - clues.stream() - .peek(clue -> { - final AwardConfig awardConfigclone = Optional.of(awardConfig) - .map(JSONUtil::obj2Json) - .map(json -> JSONUtil.json2Obj(json, AwardConfig.class)) - .orElseGet(AwardConfig::new); - awardConfigclone.setMoney( - Optional.of(clue.getId()) - .filter(specialId::equals) - .map(e -> clueResp.specialReward.longValue()) - .orElse(clueResp.otherAverageReward.longValue()) - ); - eventActionService.assembleAward( - awardConfigclone, - clue.getAdviserUid(), - clue.getAdviserUid(), - clue.getClueUid(), - eventAction, - new PasMessageParam(), - clue.getId(), - AwardRelationType.Clud.code() - ); - }) - .forEach(clue -> { - clue.setOrderNo(req.orderNo); - clue.setCommodityName(req.commodityName); - clue.setOrderAmount(req.orderAmount); - clue.setReceived(true); - clue.setModifyTime(now); - clueMapper.updateByPrimaryKeySelective(clue); - }); - } - ); \ No newline at end of file -- Gitee From de4a7298c67ec2f791a389c0ce548afa729c2c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=8F=90=E8=AF=B4=E8=AF=B4?= <1913210361@qq.com> Date: Mon, 3 Jun 2019 13:05:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Stream=20=E7=94=A8=E7=9A=8466=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- java/NBStream.java | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 java/NBStream.java diff --git a/java/NBStream.java b/java/NBStream.java new file mode 100644 index 0000000..3df1de7 --- /dev/null +++ b/java/NBStream.java @@ -0,0 +1,87 @@ +//Stream 用的66的 +final EventAction eventAction = redisObj( + EventActionKey + distributionEventId, + () -> Optional + .of(distributionEventId) + .map(eventId -> { + final EventActionExample example = new EventActionExample(); + example.createCriteria() + .andEventIdEqualTo(eventId) + .andTriggerTypeEqualTo(EnumEventTriggerType.DISTRIBUTION_PURCHASE.getCode().byteValue()); + return example; + }) + .map(eventActionMapper::selectByExample) + .filter(StringUtil::isNotEmpty) + .map(e -> e.get(0)).orElseThrow(() -> ExceptionUtil.createParamException("事件触发信息不存在")) + , EventAction.class); + final AwardConfig awardConfig = redisObj(EventConfigKey + eventAction.getId(), + () -> Optional.ofNullable(eventAction.getId()) + .map(actionId -> { + final AwardConfigExample example = new AwardConfigExample(); + example.createCriteria() + .andActionIdEqualTo(actionId); + return example; + }) + .map(awardConfigMapper::selectByExample) + .filter(StringUtil::isNotEmpty) + .map(e -> e.get(0)).orElseThrow(() -> ExceptionUtil.createParamException("xxx")), + AwardConfig.class + ); + Optional.of(req) + .map(e -> e.clueUid) + .map(id -> { + final ClueExample example = new ClueExample(); + example.createCriteria() + .andClueUidEqualTo(id) + .andDeletedEqualTo(false) + .andReceivedEqualTo(false) + .andCreateTimeGreaterThan(now - cluetime); + example.setOrderByClause("create_time asc"); + return example; + }) // 获取该被邀请人所有未过期且未被领取的线索的线索 + .map(clueMapper::selectByExample) + .filter(StringUtil::isNotEmpty) + .ifPresent(clues -> { + final ClueResp clueResp = Optional.of(req) + .filter(c -> { + c.count = clues.size(); + return true; + }) + .map(this::awardValue) + .orElseThrow(() -> ExceptionUtil.createParamException("参数错误")); + final Integer specialId = req.getIsHead() + ? clues.get(0).getId() + : clues.get(clues.size() - 1).getId(); + clues.stream() + .peek(clue -> { + final AwardConfig awardConfigclone = Optional.of(awardConfig) + .map(JSONUtil::obj2Json) + .map(json -> JSONUtil.json2Obj(json, AwardConfig.class)) + .orElseGet(AwardConfig::new); + awardConfigclone.setMoney( + Optional.of(clue.getId()) + .filter(specialId::equals) + .map(e -> clueResp.specialReward.longValue()) + .orElse(clueResp.otherAverageReward.longValue()) + ); + eventActionService.assembleAward( + awardConfigclone, + clue.getAdviserUid(), + clue.getAdviserUid(), + clue.getClueUid(), + eventAction, + new PasMessageParam(), + clue.getId(), + AwardRelationType.Clud.code() + ); + }) + .forEach(clue -> { + clue.setOrderNo(req.orderNo); + clue.setCommodityName(req.commodityName); + clue.setOrderAmount(req.orderAmount); + clue.setReceived(true); + clue.setModifyTime(now); + clueMapper.updateByPrimaryKeySelective(clue); + }); + } + ); \ No newline at end of file -- Gitee