Showing
1 changed file
with
50 additions
and
4 deletions
@@ -2,6 +2,7 @@ package com.yoho.activity.controller; | @@ -2,6 +2,7 @@ package com.yoho.activity.controller; | ||
2 | 2 | ||
3 | import javax.annotation.Resource; | 3 | import javax.annotation.Resource; |
4 | 4 | ||
5 | +import org.apache.commons.lang.StringUtils; | ||
5 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
6 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
7 | import org.springframework.stereotype.Controller; | 8 | import org.springframework.stereotype.Controller; |
@@ -61,7 +62,14 @@ public class OrderShareController { | @@ -61,7 +62,14 @@ public class OrderShareController { | ||
61 | @ResponseBody | 62 | @ResponseBody |
62 | public ApiResponse getInfoOfOrderShare(UserShareHistoryVO request) { | 63 | public ApiResponse getInfoOfOrderShare(UserShareHistoryVO request) { |
63 | logger.info("getActivityInfo param request={}", request); | 64 | logger.info("getActivityInfo param request={}", request); |
64 | - OrderShareBO data = orderShareActivityService.getShareInfo(request.getOrdercode(), request.getUid()); | 65 | + OrderShareBO data=null; |
66 | + if(request.getOrdercode()==null||request.getOrdercode().trim().equals("")||request.getUid()==0){ | ||
67 | + data=new OrderShareBO(); | ||
68 | + data.setFlag(7); | ||
69 | + data.setReturnMsg("参数输入有误"); | ||
70 | + return new ApiResponse.ApiResponseBuilder().code(200).data(data).message("参数输入有误").build(); | ||
71 | + } | ||
72 | + data = orderShareActivityService.getShareInfo(request.getOrdercode(), request.getUid()); | ||
65 | return new ApiResponse(data); | 73 | return new ApiResponse(data); |
66 | } | 74 | } |
67 | 75 | ||
@@ -77,7 +85,18 @@ public class OrderShareController { | @@ -77,7 +85,18 @@ public class OrderShareController { | ||
77 | @ResponseBody | 85 | @ResponseBody |
78 | public ApiResponse drawOrderShareCoupon(String mobile, String ordercode) { | 86 | public ApiResponse drawOrderShareCoupon(String mobile, String ordercode) { |
79 | logger.info("drawOrderShareCoupon enter, mobile: {}, orderCode: {}", mobile, ordercode); | 87 | logger.info("drawOrderShareCoupon enter, mobile: {}, orderCode: {}", mobile, ordercode); |
80 | - DrawOrderShareCouponRespBO respBO = orderShareActivityService.drawOrderShareCoupon(mobile, ordercode); | 88 | + DrawOrderShareCouponRespBO respBO=null; |
89 | + if(mobile==null||!validMobile(mobile)){ | ||
90 | + respBO=new DrawOrderShareCouponRespBO(mobile,0); | ||
91 | + respBO.setReturnCode(1); | ||
92 | + return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("手机号格式不正确").build(); | ||
93 | + } | ||
94 | + if(ordercode==null||ordercode.trim().equals("")){ | ||
95 | + respBO=new DrawOrderShareCouponRespBO(mobile,0); | ||
96 | + respBO.setReturnCode(9); | ||
97 | + return new ApiResponse.ApiResponseBuilder().code(200).data(null).message("订单号不可为空").build(); | ||
98 | + } | ||
99 | + respBO = orderShareActivityService.drawOrderShareCoupon(mobile, ordercode); | ||
81 | return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("ok").build(); | 100 | return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("ok").build(); |
82 | } | 101 | } |
83 | 102 | ||
@@ -94,8 +113,35 @@ public class OrderShareController { | @@ -94,8 +113,35 @@ public class OrderShareController { | ||
94 | @ResponseBody | 113 | @ResponseBody |
95 | public ApiResponse registerAndSendCoupon(String mobile, String ordercode, String identifycode) { | 114 | public ApiResponse registerAndSendCoupon(String mobile, String ordercode, String identifycode) { |
96 | logger.info("registerAndSendCoupon enter, mobile: {}, orderCode: {}, identifyCode : {}", mobile, ordercode, identifycode); | 115 | logger.info("registerAndSendCoupon enter, mobile: {}, orderCode: {}, identifyCode : {}", mobile, ordercode, identifycode); |
97 | - | ||
98 | - DrawOrderShareCouponRespBO respBO = orderShareActivityService.registerAndSendCoupon(mobile, ordercode, identifycode); | 116 | + DrawOrderShareCouponRespBO respBO=null; |
117 | + if(mobile==null||!validMobile(mobile)){ | ||
118 | + respBO=new DrawOrderShareCouponRespBO(mobile,0); | ||
119 | + respBO.setReturnCode(1); | ||
120 | + return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("手机号格式不正确").build(); | ||
121 | + } | ||
122 | + if(ordercode==null||ordercode.trim().equals("")){ | ||
123 | + respBO=new DrawOrderShareCouponRespBO(mobile,0); | ||
124 | + respBO.setReturnCode(9); | ||
125 | + return new ApiResponse.ApiResponseBuilder().code(200).data(null).message("订单号不可为空").build(); | ||
126 | + } | ||
127 | + | ||
128 | + if(identifycode==null||identifycode.trim().equals("")){ | ||
129 | + respBO=new DrawOrderShareCouponRespBO(mobile,0); | ||
130 | + respBO.setReturnCode(10); | ||
131 | + return new ApiResponse.ApiResponseBuilder().code(200).data(null).message("验证码不可为空").build(); | ||
132 | + } | ||
133 | + | ||
134 | + respBO = orderShareActivityService.registerAndSendCoupon(mobile, ordercode, identifycode); | ||
99 | return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("ok").build(); | 135 | return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("ok").build(); |
100 | } | 136 | } |
137 | + | ||
138 | + private boolean validMobile(String mobile) { | ||
139 | + if (mobile == null) | ||
140 | + return false; | ||
141 | + | ||
142 | + if (mobile.length() != 11) | ||
143 | + return false; | ||
144 | + | ||
145 | + return StringUtils.isNumeric(mobile); | ||
146 | + } | ||
101 | } | 147 | } |
-
Please register or login to post a comment