Example #1
0
  @RequestMapping(value = "/invite", method = RequestMethod.POST)
  public MomiaHttpResponse inviteCoupon(
      @RequestParam String mobile, @RequestParam(value = "invite") String inviteCode) {
    if (MomiaUtil.isInvalidMobile(mobile)) return MomiaHttpResponse.FAILED("无效的手机号码");
    if (StringUtils.isBlank(inviteCode)) return MomiaHttpResponse.FAILED("无效的邀请码");
    if (userServiceApi.getByMobile(mobile).exists())
      return MomiaHttpResponse.FAILED("该手机号已经注册过,只有新用户才能领取");

    couponServiceApi.invite(mobile, inviteCode);
    return MomiaHttpResponse.SUCCESS;
  }
Example #2
0
  @RequestMapping(value = "/share", method = RequestMethod.GET)
  public MomiaHttpResponse shareCoupon(@RequestParam String utoken) {
    if (StringUtils.isBlank(utoken)) return MomiaHttpResponse.TOKEN_EXPIRED;

    User user = userServiceApi.get(utoken);
    JSONObject shareJson = new JSONObject();
    shareJson.put("img", Configuration.getString("Share.Img"));
    shareJson.put("desc", Configuration.getString("Share.Desc"));
    shareJson.put("url", Configuration.getString("Share.Url") + "?invite=" + user.getInviteCode());
    shareJson.put("cover", Configuration.getString("Share.Cover"));
    shareJson.put("title", Configuration.getString("Share.Title"));
    shareJson.put("abstracts", Configuration.getString("Share.Abstracts"));

    return MomiaHttpResponse.SUCCESS(shareJson);
  }
Example #3
0
  @RequestMapping(method = RequestMethod.GET)
  public MomiaHttpResponse index(
      HttpServletRequest request,
      @RequestParam(value = "city") int cityId,
      @RequestParam int start) {
    if (cityId < 0 || start < 0) return MomiaHttpResponse.BAD_REQUEST;

    JSONObject indexJson = new JSONObject();
    if (start == 0) {
      int platform = getPlatform(request);
      String version = getVersion(request);

      indexJson.put("banners", getBanners(cityId, platform, version));
      indexJson.put("icons", getIcons(cityId, platform, version));
      indexJson.put("events", getEvents(cityId, platform, version, 0));
    }
    indexJson.put("courses", getRecommendCourses(cityId, start));

    return MomiaHttpResponse.SUCCESS(indexJson);
  }
Example #4
0
 @RequestMapping(value = "/code", method = RequestMethod.GET)
 public MomiaHttpResponse couponCode(@RequestParam String code) {
   if (StringUtils.isBlank(code)) return MomiaHttpResponse.FAILED("无效的优惠码");
   return MomiaHttpResponse.SUCCESS(couponServiceApi.couponCode(code));
 }
Example #5
0
 @RequestMapping(method = RequestMethod.GET)
 public MomiaHttpResponse getCoupon(@RequestParam int id) {
   Coupon coupon = couponServiceApi.get(id);
   if (!coupon.exists()) return MomiaHttpResponse.FAILED("无效的红包");
   return MomiaHttpResponse.SUCCESS(coupon);
 }