@RequestMapping(value = "/customer/{shopId}/{nick}") @ResponseBody public ControlerResult customer( @PathVariable("shopId") final String shopId, @PathVariable("nick") final String nick) { final Customer customer = factResolver.getCustomer(nick, shopId); final User user = factResolver.getTaobaoUserObject(nick, shopId); final Map<String, Object> map = new HashMap<String, Object>(); map.put("customer", customer); map.put("user", user); return ControlerResult.newSuccess(map); }
/** * 查看给点店铺开启的方案作用于给定订单后可以得到的结果 * * @param shopId * @param tid * @return */ @RequestMapping(value = "/{shopId}/{tid}") @ResponseBody public ControlerResult test( @PathVariable("shopId") final String shopId, @PathVariable("tid") final Long tid) { try { final RuleEngineSession session = sessionRepository.getSession(shopId); final Fact fact = factResolver.resolve(tid); if (fact != null) { session.execute(fact); final FactResult result = fact.getResult(); if (result.getHits() == 0) { return ControlerResult.newSuccess("没有匹配的规则!", fact); } else { final PlanGroup planGroup = planGroupService.planGroupOfShop(shopId); final List<Rule> matchedRules = new ArrayList<Rule>(); for (final RuleHitDetail detail : result.getHitDetails()) { final Rule rule = ruleService.getRule(detail.getRuleId()); matchedRules.add(rule); } final String remark = remarkContentBuilder.buildMemoContent(planGroup, matchedRules); return ControlerResult.newSuccess(remark, fact); } } else { return ControlerResult.newError("获取订单失败!"); } } catch (final RuleCenterBusinessException e) { e.printStackTrace(); return ControlerResult.newError(e.getMessage()); } catch (final Exception e) { e.printStackTrace(); return ControlerResult.newError(e.getMessage()); } }