Showing
1 changed file
with
28 additions
and
17 deletions
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | -import com.github.rholder.retry.Retryer; | ||
4 | -import com.github.rholder.retry.RetryerBuilder; | ||
5 | -import com.github.rholder.retry.StopStrategies; | ||
6 | -import com.google.common.base.Predicates; | ||
7 | import com.yoho.core.rest.client.ServiceCaller; | 3 | import com.yoho.core.rest.client.ServiceCaller; |
8 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
9 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
10 | import com.yoho.message.sdk.utils.DateUtils; | 6 | import com.yoho.message.sdk.utils.DateUtils; |
11 | import com.yohobuy.ufo.model.order.resp.InviteInfoResp; | 7 | import com.yohobuy.ufo.model.order.resp.InviteInfoResp; |
12 | import com.yohoufo.common.utils.DateUtil; | 8 | import com.yohoufo.common.utils.DateUtil; |
13 | -import com.yohoufo.dal.order.*; | ||
14 | -import com.yohoufo.dal.order.model.*; | 9 | +import com.yohoufo.dal.order.InviteActivityMapper; |
10 | +import com.yohoufo.dal.order.InviteRecordMapper; | ||
11 | +import com.yohoufo.dal.order.InviteSettlementItemMapper; | ||
12 | +import com.yohoufo.dal.order.InviterMapper; | ||
13 | +import com.yohoufo.dal.order.model.InviteActivity; | ||
14 | +import com.yohoufo.dal.order.model.InviteRecord; | ||
15 | +import com.yohoufo.dal.order.model.InviteSettlementItem; | ||
16 | +import com.yohoufo.dal.order.model.Inviter; | ||
15 | import com.yohoufo.order.common.InviteRecordStatusEnum; | 17 | import com.yohoufo.order.common.InviteRecordStatusEnum; |
16 | import com.yohoufo.order.common.InviterStatus; | 18 | import com.yohoufo.order.common.InviterStatus; |
17 | import com.yohoufo.order.common.InviterType; | 19 | import com.yohoufo.order.common.InviterType; |
@@ -19,6 +21,7 @@ import com.yohoufo.order.service.IInviteService; | @@ -19,6 +21,7 @@ import com.yohoufo.order.service.IInviteService; | ||
19 | import com.yohoufo.order.service.IStoredSellerService; | 21 | import com.yohoufo.order.service.IStoredSellerService; |
20 | import com.yohoufo.order.service.proxy.UserProxyService; | 22 | import com.yohoufo.order.service.proxy.UserProxyService; |
21 | import com.yohoufo.order.service.support.InviteCodeGenerator; | 23 | import com.yohoufo.order.service.support.InviteCodeGenerator; |
24 | +import org.apache.commons.lang3.tuple.Pair; | ||
22 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
23 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
24 | import org.springframework.beans.factory.annotation.Autowired; | 27 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -187,15 +190,23 @@ public class InviteServiceImpl implements IInviteService { | @@ -187,15 +190,23 @@ public class InviteServiceImpl implements IInviteService { | ||
187 | } | 190 | } |
188 | 191 | ||
189 | // 获取展示用的邀请码 | 192 | // 获取展示用的邀请码 |
190 | - String showInviteCode = getShowInviteCode(uid); | 193 | + Pair<String,List<Inviter>> showInviteCodeAndInviter = getShowInviteCode(uid); |
191 | 194 | ||
192 | - if (StringUtils.isEmpty(showInviteCode)){ | 195 | + if (StringUtils.isEmpty(showInviteCodeAndInviter.getLeft())){ |
193 | LOGGER.warn("has no showInviteCode. uid is {}", uid); | 196 | LOGGER.warn("has no showInviteCode. uid is {}", uid); |
194 | throw new ServiceException(ServiceError.HAS_NO_ENTER); | 197 | throw new ServiceException(ServiceError.HAS_NO_ENTER); |
195 | } | 198 | } |
196 | 199 | ||
197 | // 有邀请码的场合,获取邀请的好友 | 200 | // 有邀请码的场合,获取邀请的好友 |
198 | - List<InviteRecord> inviteRecords = inviteRecordMapper.selectByInviterUid(uid); | 201 | + // 入驻商户角色的邀请记录 |
202 | + Integer storedInviterId = showInviteCodeAndInviter.getRight().stream() | ||
203 | + .filter(e->e.getType().intValue() == InviterType.STORED_SELLER.getType()) | ||
204 | + .map(Inviter::getId) | ||
205 | + .findFirst() | ||
206 | + .orElse(null); | ||
207 | + List<InviteRecord> inviteRecords = inviteRecordMapper.selectByInviterUid(uid).stream() | ||
208 | + .filter(e->e.getInviterId().equals(storedInviterId)) | ||
209 | + .collect(Collectors.toList()); | ||
199 | if (!CollectionUtils.isEmpty(inviteRecords)){ | 210 | if (!CollectionUtils.isEmpty(inviteRecords)){ |
200 | 211 | ||
201 | List<Integer> inviteeUidList = inviteRecords.stream().map(InviteRecord::getInviteeUid).collect(Collectors.toList()); | 212 | List<Integer> inviteeUidList = inviteRecords.stream().map(InviteRecord::getInviteeUid).collect(Collectors.toList()); |
@@ -213,7 +224,7 @@ public class InviteServiceImpl implements IInviteService { | @@ -213,7 +224,7 @@ public class InviteServiceImpl implements IInviteService { | ||
213 | 224 | ||
214 | return InviteInfoResp.builder() | 225 | return InviteInfoResp.builder() |
215 | .uid(uid) | 226 | .uid(uid) |
216 | - .showInviteCode(showInviteCode) | 227 | + .showInviteCode(showInviteCodeAndInviter.getLeft()) |
217 | .inviteeUidNum(inviteeUidList.size()) | 228 | .inviteeUidNum(inviteeUidList.size()) |
218 | .finishedOrderNum(orderNumMap.values().stream().collect(Collectors.summingInt(Integer::intValue))) | 229 | .finishedOrderNum(orderNumMap.values().stream().collect(Collectors.summingInt(Integer::intValue))) |
219 | .inviteRecordList(getInviteRecordList(inviteRecords, orderNumMap, nickNameMap)) | 230 | .inviteRecordList(getInviteRecordList(inviteRecords, orderNumMap, nickNameMap)) |
@@ -221,21 +232,21 @@ public class InviteServiceImpl implements IInviteService { | @@ -221,21 +232,21 @@ public class InviteServiceImpl implements IInviteService { | ||
221 | 232 | ||
222 | } | 233 | } |
223 | 234 | ||
224 | - return InviteInfoResp.builder().uid(uid).showInviteCode(showInviteCode).build(); | 235 | + return InviteInfoResp.builder().uid(uid).showInviteCode(showInviteCodeAndInviter.getLeft()).build(); |
225 | 236 | ||
226 | } | 237 | } |
227 | 238 | ||
228 | private List<InviteInfoResp.InviteRecord> getInviteRecordList(List<InviteRecord> inviteRecords, | 239 | private List<InviteInfoResp.InviteRecord> getInviteRecordList(List<InviteRecord> inviteRecords, |
229 | Map<Integer, Integer> orderNumMap, | 240 | Map<Integer, Integer> orderNumMap, |
230 | Map<Integer, String> nickNameMap) { | 241 | Map<Integer, String> nickNameMap) { |
231 | - return inviteRecords.stream().map(x ->{ | ||
232 | - return InviteInfoResp.InviteRecord.builder() | 242 | + return inviteRecords.stream() |
243 | + .map(x -> InviteInfoResp.InviteRecord.builder() | ||
233 | .inviteeUid(x.getInviteeUid()) | 244 | .inviteeUid(x.getInviteeUid()) |
234 | .nickName(Objects.isNull(nickNameMap.get(x.getInviteeUid())) ? "" : nickNameMap.get(x.getInviteeUid())) | 245 | .nickName(Objects.isNull(nickNameMap.get(x.getInviteeUid())) ? "" : nickNameMap.get(x.getInviteeUid())) |
235 | .enterTime(DateUtil.formatYYMMddHHmmssPoint(x.getCreateTime())) | 246 | .enterTime(DateUtil.formatYYMMddHHmmssPoint(x.getCreateTime())) |
236 | .orderNum(Objects.isNull(orderNumMap.get(x.getInviteeUid())) ? 0 : orderNumMap.get(x.getInviteeUid())) | 247 | .orderNum(Objects.isNull(orderNumMap.get(x.getInviteeUid())) ? 0 : orderNumMap.get(x.getInviteeUid())) |
237 | - .build(); | ||
238 | - }).collect(Collectors.toList()); | 248 | + .build()) |
249 | + .collect(Collectors.toList()); | ||
239 | } | 250 | } |
240 | 251 | ||
241 | /** | 252 | /** |
@@ -243,7 +254,7 @@ public class InviteServiceImpl implements IInviteService { | @@ -243,7 +254,7 @@ public class InviteServiceImpl implements IInviteService { | ||
243 | * @param uid | 254 | * @param uid |
244 | * @return | 255 | * @return |
245 | */ | 256 | */ |
246 | - private String getShowInviteCode(int uid) { | 257 | + private Pair<String,List<Inviter>> getShowInviteCode(int uid) { |
247 | 258 | ||
248 | // 查看是否已经有邀请码 | 259 | // 查看是否已经有邀请码 |
249 | List<Inviter> inviters = inviterMapper.selectInviteCodeByUid(uid); | 260 | List<Inviter> inviters = inviterMapper.selectInviteCodeByUid(uid); |
@@ -292,7 +303,7 @@ public class InviteServiceImpl implements IInviteService { | @@ -292,7 +303,7 @@ public class InviteServiceImpl implements IInviteService { | ||
292 | } | 303 | } |
293 | } | 304 | } |
294 | 305 | ||
295 | - return lastShowInvite; | 306 | + return Pair.of(lastShowInvite,inviters); |
296 | } | 307 | } |
297 | 308 | ||
298 | 309 |
-
Please register or login to post a comment