From a4637ae9d71aa4a624b217ed3a1483f0e3a3a7ed Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 06 五月 2020 14:04:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java | 135 ++++++++++++--------------------------------
1 files changed, 37 insertions(+), 98 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
index 507d0ce..bbc9950 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -27,7 +27,6 @@
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.Producer;
-import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.user.UserInfoExtraMapper;
import com.yeshi.fanli.dao.mybatis.user.UserRankRecordMapper;
import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
@@ -358,48 +357,14 @@
throw new UserInfoExtraException(1, "宸茬粡婵�娲�, 鏃犻渶鍐嶆婵�娲�");
inviteCode = inviteCode.toUpperCase();
+
// 閭�璇风爜瀵瑰簲鐢ㄦ埛淇℃伅
- UserInfo inviter = userInfoService.getUserInfoByInviteCode(inviteCode);
- if (inviter == null || inviter.getState() != UserInfo.STATE_NORMAL)
+ UserInfo boss = userInfoService.getUserInfoByInviteCode(inviteCode);
+ if (boss == null || boss.getState() != UserInfo.STATE_NORMAL)
throw new UserInfoExtraException(1, "涓婄骇閭�璇风爜涓嶅瓨鍦�");
- // 缁戝畾鍏崇郴
- try {
- threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
- } catch (ThreeSaleException e) {
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- throw new UserInfoExtraException(1, "婵�娲诲け璐�");
- }
-
- // 鐢熸垚閭�璇风爜
- String mycode = createInviteCode(uid);
- if (StringUtil.isNullOrEmpty(mycode))
- throw new UserInfoExtraException(1, "婵�娲荤爜鐢熸垚澶辫触");
-
- UserInfoExtra userInfoExtra = new UserInfoExtra();
- userInfoExtra.setUserInfo(invitee);
- userInfoExtra.setInviteCode(mycode);
- userInfoExtra.setUpdateTime(new Date());
- if (extra != null) {
- userInfoExtra.setId(extra.getId());
- userInfoExtraMapper.updateByPrimaryKeySelective(userInfoExtra);
- } else {
- userInfoExtra.setCreateTime(new Date());
- userInfoExtraMapper.insertSelective(userInfoExtra);
- }
- userActivedRecordService.add(new UserActivedRecord(uid));
-
- if (!Constant.IS_TEST) { // 鍙戦�佹縺娲绘垚鍔熸秷鎭�
- Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
- new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
- producer.send(message);
- }
-
- return mycode;
+ // 鐢熸垚閭�璇峰叧绯�
+ return inviteCodeActive(uid, boss.getId());
}
@Override
@@ -489,42 +454,8 @@
throw new UserInfoExtraException(1, "娌℃湁瀵瑰簲鐨勯個璇峰叧绯�");
}
- // 缁戝畾鍏崇郴
- try {
- threeSaleSerivce.bindRelationshipByWX(invitee, inviterId);
- } catch (ThreeSaleException e) {
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- throw new UserInfoExtraException(1, "鍏崇郴缁戝畾鏃跺け璐�");
- }
-
- // 鐢熸垚閭�璇风爜
- String inviteCode = createInviteCode(uid);
- if (StringUtil.isNullOrEmpty(inviteCode))
- throw new UserInfoExtraException(1, "婵�娲荤爜鐢熸垚澶辫触");
-
- UserInfoExtra userInfoExtra = new UserInfoExtra();
- userInfoExtra.setUserInfo(invitee);
- userInfoExtra.setInviteCode(inviteCode);
- userInfoExtra.setUpdateTime(new Date());
- if (extra != null) {
- userInfoExtra.setId(extra.getId());
- userInfoExtraMapper.updateByPrimaryKeySelective(userInfoExtra);
- } else {
- userInfoExtra.setCreateTime(new Date());
- userInfoExtraMapper.insertSelective(userInfoExtra);
- }
- userActivedRecordService.add(new UserActivedRecord(uid));
-
-
- if (!Constant.IS_TEST) { // 鍙戦�佹縺娲绘垚鍔熸秷鎭�
- Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
- new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
- producer.send(message);
- }
+ // 閭�璇风爜婵�娲�
+ inviteCodeActive(uid, boss.getId());
}
@Override
@@ -538,15 +469,6 @@
UserInfo invitee = userInfoService.selectByPKey(uid);
if (invitee == null) {
throw new UserInfoExtraException(1, "鐢ㄦ埛涓嶅瓨鍦�");
- }
-
- // 鐢ㄦ埛棰濆淇℃伅
- UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
- if (extra != null) {
- String inviteCodeHas = extra.getInviteCode();
- if (inviteCodeHas != null && inviteCodeHas.trim().length() > 0) {
- throw new UserInfoExtraException(1, "宸茬粡婵�娲�, 鏃犻渶鍐嶆婵�娲�");
- }
}
String wxUnionId = weiXinUser.getUnionid();
@@ -616,10 +538,28 @@
if (boss == null || boss.getState() != UserInfo.STATE_NORMAL) {
throw new UserInfoExtraException(1, "娌℃湁瀵瑰簲鐨勯個璇峰叧绯�");
}
-
+
+ // 閭�璇风爜婵�娲�
+ inviteCodeActive(uid, boss.getId());
+ }
+
+
+ /**
+ * 閭�璇峰叧绯荤敓鎴愭縺娲荤爜
+ * @param uid
+ * @param bossId
+ * @return
+ * @throws UserInfoExtraException
+ */
+ private String inviteCodeActive(Long uid, Long bossId) throws UserInfoExtraException{
+ UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
+ if (extra != null && !StringUtil.isNullOrEmpty(extra.getInviteCode())) {
+ throw new UserInfoExtraException(1, "宸茬粡婵�娲�, 鏃犻渶鍐嶆婵�娲�");
+ }
+
// 缁戝畾鍏崇郴
try {
- threeSaleSerivce.bindRelationshipByWX(invitee, inviterId);
+ threeSaleSerivce.bindInviteRelationship(uid, bossId);
} catch (ThreeSaleException e) {
try {
LogHelper.errorDetailInfo(e);
@@ -631,12 +571,11 @@
// 鐢熸垚閭�璇风爜
String inviteCode = createInviteCode(uid);
- ;
if (StringUtil.isNullOrEmpty(inviteCode))
throw new UserInfoExtraException(1, "婵�娲荤爜鐢熸垚澶辫触");
UserInfoExtra userInfoExtra = new UserInfoExtra();
- userInfoExtra.setUserInfo(invitee);
+ userInfoExtra.setUserInfo(new UserInfo(uid));
userInfoExtra.setInviteCode(inviteCode);
userInfoExtra.setUpdateTime(new Date());
if (extra != null) {
@@ -649,12 +588,16 @@
userActivedRecordService.add(new UserActivedRecord(uid));
- if (!Constant.IS_TEST) { // 鍙戦�佹縺娲绘垚鍔熸秷鎭�
+// if (!Constant.IS_TEST) { // 鍙戦�佹縺娲绘垚鍔熸秷鎭�
Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
- new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
+ new InviteCodeActiveMQMsg(uid, new Date()));
producer.send(message);
- }
+// }
+
+ return inviteCode;
}
+
+
@Override
public void updateActiveTime(Long uid, Date date) {
@@ -854,10 +797,6 @@
return inviter;
}
- @Override
- public void updateAutoExtract(Integer days) {
- userInfoExtraMapper.updateAutoExtract(days);
- }
@Transactional(rollbackFor = Exception.class)
@Override
@@ -897,8 +836,8 @@
if (!Constant.IS_TEST) { // 鍙戦�侀個璇风爜鏇存敼鎴愬姛鐨勬秷鎭�
Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate,
- new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip,
- new Date())));
+ new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip,
+ new Date()));
producer.send(message);
}
--
Gitblit v1.8.0