@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; }
@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)); }
@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); }