From eda623f37c3260f4b4657e34a8a39798c72432b1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期日, 28 六月 2020 15:49:14 +0800
Subject: [PATCH] 搜索接口增加小黄条返回
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java | 325 ++++++++++++++++++++++++++---------------------------
1 files changed, 159 insertions(+), 166 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
index 5f194e4..24e850e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
@@ -11,41 +11,40 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.Producer;
import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPInfoMapper;
-import com.yeshi.fanli.dto.msg.MsgAccountVipDTO;
-import com.yeshi.fanli.dto.msg.MsgOtherVIPDTO;
-import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
-import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail.MsgTypeAccountTypeEnum;
-import com.yeshi.fanli.entity.bus.user.HongBaoV2;
+import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
+import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
-import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
-import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelUpgradedNotify;
import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
-import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
-import com.yeshi.fanli.exception.msg.MsgAccountDetailException;
+import com.yeshi.fanli.entity.common.Config;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
+import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException;
+import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
-import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
-import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
-import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
-import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
-import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
-import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService;
import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
-import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
+import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
+import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.util.email.MailSenderUtil;
+import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
+import com.yeshi.fanli.util.rocketmq.MQTopicName;
@Service
public class UserVIPInfoServiceImpl implements UserVIPInfoService {
@@ -57,9 +56,6 @@
private UserInfoService userInfoService;
@Resource
- private UserInfoExtraService userInfoExtraService;
-
- @Resource
private UserVipConfigService userVipConfigService;
@Lazy
@@ -67,35 +63,28 @@
private HongBaoV2CountService hongBaoV2CountService;
@Resource
- private IntegralDetailService integralDetailService;
-
- @Resource
- private BanLiShopOrderService banLiShopOrderService;
-
- @Resource
- private UserOtherMsgNotificationService userOtherMsgNotificationService;
-
- @Resource
private ThreeSaleSerivce threeSaleSerivce;
-
- @Resource
- private UserInviteSeparateService userInviteSeparateService;
-
- @Resource
- private ConfigService configService;
-
- @Lazy
- @Resource
- private UserSystemCouponService userSystemCouponService;
@Resource
private UserVIPPreInfoService userVIPPreInfoService;
@Resource
- private MsgAccountDetailService msgAccountDetailService;
-
+ private UserAccountMsgNotificationService userAccountMsgNotificationService;
+
@Resource
private UserInviteValidNumService userInviteValidNumService;
+
+ @Resource
+ private UserLevelUpgradedNotifyService userLevelUpgradedNotifyService;
+
+ @Resource
+ private UserInviteMsgNotificationService userInviteMsgNotificationService;
+
+ @Resource(name = "producer")
+ private Producer producer;
+
+ @Resource
+ private ConfigService configService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -112,7 +101,6 @@
info.setCreateTime(new Date());
userVIPInfoMapper.insert(info);
}
-
@Override
public boolean isVIP(Long uid) {
@@ -155,7 +143,6 @@
return map;
}
-
@Override
public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state) {
return userVIPInfoMapper.listQuery((page - 1) * count, count, key, state);
@@ -166,82 +153,27 @@
return userVIPInfoMapper.countQuery(key, state);
}
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void inviteSeparate(Long workerId, Long bossId) {
- if (workerId == null || bossId == null)
- return;
-
- // 鏌ヨ璁板綍
- UserInviteSeparate userInviteSeparate = userInviteSeparateService.selectByWorkerIdAndBossId(workerId, bossId);
- if (userInviteSeparate == null)
- return;
-
- // 鏄惁瀛樺湪閭�璇峰叧绯�
- ThreeSale threeSale = threeSaleSerivce.getMyBoss(workerId);
- if (threeSale == null)
- return;
- Long bossIdExist = threeSale.getBoss().getId();
- if (bossIdExist == null || bossId.longValue() != bossIdExist.longValue())
- return;
-
- // 涓婄骇浼氬憳鎯呭喌
- boolean separate = false;
- UserVIPInfo userVIPInfo = userVIPInfoMapper.selectByPrimaryKey(bossId);
- if (userVIPInfo != null && userVIPInfo.getState() != null
- && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) {
- if (userInviteSeparate.getEndTime().getTime() < userVIPInfo.getSuccessTime().getTime()) {
- separate = true; // 缁撴潫鏃堕棿宸茬粡瓒呰繃
- }
- } else {
- separate = true; // 涓婄骇闈炰細鍛�
- }
-
- if (!separate) {
- // 鏈劚绂�
- userInviteSeparateService.updateStateByWorkerIdAndBossId(workerId, bossId,
- UserInviteSeparate.STATE_INVALID);
- } else {
- // 鑴辩鍏崇郴
- userInviteSeparateService.updateStateByWorkerIdAndBossId(workerId, bossId,
- UserInviteSeparate.STATE_SUCCESS);
-
- // 鑴辩閭�璇峰叧绯�
- threeSaleSerivce.inviteSeparate(workerId, bossId);
-
- int limitDays = Integer.parseInt(userVipConfigService.getValueByKey("invite_separate_limit_days"));
- // 娑堟伅
- UserInfo userInfo = userInfoService.selectByPKey(workerId);
- MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
- msgboss.setContent1(userInfo.getNickName() + workerId + "浜�"
- + TimeUtil.formatDateDot(userInviteSeparate.getCreateTime()) + "鎴愬姛鍗囩骇鎴愪负瓒呯骇浼氬憳 ");
- msgboss.setContent2("寰堥仐鎲撅紝浣犳湭鑳藉湪" + limitDays + "澶╁崌绾т负瓒呯骇浼氬憳 ");
- msgboss.setContent3("宸蹭笌鍏惰劚绂婚個璇峰叧绯�");
- userOtherMsgNotificationService.teamSplitCallBoss(bossId, "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgboss);
- }
- }
-
@Transactional(rollbackFor = Exception.class)
@Override
public void applyVIP(Long uid) throws UserVIPInfoException {
UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid);
if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) {
- throw new UserVIPInfoException(1, "璇ョ敤鎴疯繕涓嶆槸楂樼骇浼氬憳");
+ throw new UserVIPInfoException(1, "璇峰厛鍗囩骇涓洪珮绾т細鍛�");
}
- if (!verifyVip(uid))
- throw new UserVIPInfoException(1, "绯荤粺楠岃瘉锛氫笉婊¤冻鍗囩骇鏉′欢");
+ int verifyResult = verifyVip(uid);
+ if (verifyResult <= 0)
+ throw new UserVIPInfoException(1, "涓嶆弧瓒冲崌绾ф潯浠�");
UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
if (userInfo == null) {
userInfo = new UserVIPInfo();
userInfo.setId(uid);
- // 娣诲姞璁板綍
addUserVIPInfo(userInfo);
}
if (userInfo.getState() != UserVIPInfo.STATE_INVALID)
- throw new UserVIPInfoException(2, "宸茬粡鐢宠杩�");
+ throw new UserVIPInfoException(2, "绯荤粺宸叉敹鍒颁綘鐨勮秴绾т細鍛樺崌绾х敵璇凤紝灏嗕細灏藉揩瀹屾垚瀹℃牳");
UserVIPInfo info = new UserVIPInfo();
info.setId(userInfo.getId());
@@ -249,19 +181,21 @@
info.setState(UserVIPInfo.STATE_VERIFING);
info.setUpdateTime(new Date());
userVIPInfoMapper.updateByPrimaryKeySelective(info);
-
- MsgAccountDetail detail = new MsgAccountDetail();
- detail.setTitle("灏婃暚鐨勯珮绾т細鍛橈紝绯荤粺宸叉敹鍒颁綘鐨勮秴绾т細鍛樺崌绾х敵璇凤紝姝e湪鍙楃悊涓�");
- detail.setBeiZhu("濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇");
- detail.setRead(false);
- detail.setCreateTime(new Date());
- detail.setUser(new UserInfo(uid));
- detail.setContent("鎴戜滑灏嗕細鍦�48灏忔椂鍐呭畬鎴愬鏍�");
- detail.setType(MsgTypeAccountTypeEnum.vipApply);
+ // 鍙戦�侀偖浠堕�氱煡
try {
- msgAccountDetailService.addMsgAccountDetail(detail);
- } catch (MsgAccountDetailException e) {
- e.printStackTrace();
+ Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey());
+ String[] sts = config.getValue().split(",");
+ String account = sts[0];
+ String pwd = sts[1];
+
+ String msg = String.format("鐢ㄦ埛ID:%s 鐢宠瓒呯骇浼氬憳", uid + "");
+ String email = userVipConfigService.getValueByKey("apply_vip_email");
+ String[] emails = email.split(",");
+ for (String e : emails) {
+ MailSenderUtil.sendEmail(e, account, pwd, msg, msg);
+ }
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e);
}
}
@@ -281,41 +215,58 @@
throw new UserVIPInfoException(1, "璇ョ敤鎴疯繕涓嶆槸楂樼骇浼氬憳");
}
- if (!verifyVip(uid))
+ int verifyVipResult = verifyVip(uid);
+
+ if (verifyVipResult <= 0)
throw new UserVIPInfoException(1, "绯荤粺楠岃瘉锛氫笉婊¤冻鍗囩骇鏉′欢");
- // 棰濆淇℃伅
- UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
- if (userInfoExtra == null)
- throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
-
+ Date upgradeTime = new Date();
// 閫氳繃瓒呯骇浼氬憳
UserVIPInfo info = new UserVIPInfo();
info.setId(userVIPInfo.getId());
- info.setSuccessTime(new Date());
+ info.setSuccessTime(upgradeTime);
info.setState(UserVIPInfo.STATE_SUCCESS);
- info.setUpdateTime(new Date());
+ info.setUpdateTime(upgradeTime);
userVIPInfoMapper.updateByPrimaryKeySelective(info);
+ UserVIPPreInfo preInfo = new UserVIPPreInfo();
+ preInfo.setCreateTime(new Date());
+ preInfo.setProcess(UserLevelEnum.superVIP.getLevel());
+ preInfo.setSourceType(verifyVipResult);
+ preInfo.setUid(uid);
+
try {
- // 璧犻�佸厤鍗曞埜
- String giveCoupon = userVipConfigService.getValueByKey("vip_pre_10_gift_givefree_coupon");
- if (!StringUtil.isNullOrEmpty(giveCoupon)) {
- int num = Integer.parseInt(giveCoupon);
- for (int i = 0; i < num; i++) {
- userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
- UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
- }
+ userVIPPreInfoService.addUserVIPPreInfo(preInfo);
+ } catch (UserVIPPreInfoException e1) {
+ throw new UserVIPInfoException(100, "鍗囩骇澶辫触");
+ }
+
+ // 鍗囩骇寮规鎻愮ず
+ UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
+ notify.setUid(uid);
+ notify.setFromLevel(UserLevelEnum.highVIP);
+ notify.setToLevel(UserLevelEnum.superVIP);
+ notify.setValid(true);
+ notify.setCreateTime(new Date());
+ userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
+
+ try {
+ // 鍗囩骇娑堟伅
+ UserVIPPreInfo pre1 = userVIPPreInfoService.getVipByProcess(uid, UserVIPPreInfo.PROCESS_2);
+ userAccountMsgNotificationService.vipUpgradeSuccess(uid,
+ TimeUtil.getDayDifferenceCount(pre1.getCreateTime(), new Date()));
+
+ // 鐩存帴绮変笣鍗囩骇鎻愰啋
+ ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
+ if (threeSale != null) {
+ Long bossId = threeSale.getBoss().getId();
+ UserInfo userInfo = userInfoService.selectByPKey(uid);
+ userInviteMsgNotificationService.fansUpgrade(bossId, "瓒呯骇浼氬憳", userInfo.getNickName(), getPassItem(uid),
+ upgradeTime);
}
} catch (Exception e) {
- throw new UserVIPInfoException(1, "鍒歌禒閫佸け璐�");
+ e.printStackTrace();
}
-
- // 娑堟伅
- MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
- msgDto.setStatus("宸插皢浣犵殑璐︽埛鐢遍珮绾т細鍛樺崌绾т负瓒呯骇浼氬憳");
- msgDto.setEquity("浠庢敹鍒版湰娑堟伅璧凤紝浣犲皢鑾峰緱鍏ㄩ儴瓒呯骇浼氬憳鏉冪泭");
- msgAccountDetailService.addMsgVIP(uid, "鎭枩浣狅紒缁忎汉宸ュ鏍镐綘婊¤冻鍗囩骇瓒呯骇浼氬憳鏉′欢", "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgDto);
}
/**
@@ -323,14 +274,9 @@
* @param uid
* @return
*/
- private boolean verifyVip(Long uid) {
- // 鑷喘璁㈠崟
- long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
- HongBaoV2.TYPE_ZIGOU);
- // 鍒嗕韩璁㈠崟
- long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
- HongBaoV2.TYPE_SHARE_GOODS);
-
+ private String getPassItem(Long uid) {
+ // 鑷喘 + 鍒嗕韩璁㈠崟
+ long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY);
// 鏈夋晥绮変笣
int doneFirst = 0;
int doneSecond = 0;
@@ -340,34 +286,79 @@
doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
}
- long limitZiGou = 0;
- String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count");
+ long limitOrder = 0;
+ String zigou = userVipConfigService.getValueByKey("vip_pre_10_order_count");
if (!StringUtil.isNullOrEmpty(zigou)) {
- limitZiGou = Long.parseLong(zigou);
+ limitOrder = Long.parseLong(zigou);
}
-
- long limitShare = 0;
- String share = userVipConfigService.getValueByKey("vip_pre_10_share_order_count");
- if (!StringUtil.isNullOrEmpty(share)) {
- limitShare = Long.parseLong(share);
- }
-
+
long limitFirst = 0;
String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count");
if (!StringUtil.isNullOrEmpty(first)) {
limitFirst = Long.parseLong(first);
}
-
+
long limitSecond = 0;
String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count");
if (!StringUtil.isNullOrEmpty(second)) {
limitSecond = Long.parseLong(second);
}
-
- if (doneZiGou >= limitZiGou || doneShare >= limitShare || (doneFirst >= limitFirst && doneSecond >= limitSecond)) {
- return true;
+
+ String item = "";
+ if (doneOrder >= limitOrder) {
+ item = "杩斿埄+鍒嗕韩璁㈠崟";
+ } else if (doneFirst >= limitFirst && doneSecond >= limitSecond) {
+ item = "鐩存帴+闂存帴绮変笣";
}
- return false;
+ return item;
+ }
+
+ /**
+ * 楠岃瘉鏄惁绗﹀悎VIP
+ * @Title: verifyVip
+ * @Description:
+ * @param uid
+ * @return 0-涓嶇鍚� 1-璁㈠崟 2-鍥㈤槦
+ * int 杩斿洖绫诲瀷
+ * @throws
+ */
+ private int verifyVip(Long uid) {
+ // 鑷喘 + 鍒嗕韩璁㈠崟
+ long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY);
+ // 鏈夋晥绮変笣
+ int doneFirst = 0;
+ int doneSecond = 0;
+ UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
+ if (userInviteValidNum != null) {
+ doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
+ doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
+ }
+ long limitOrder = 0;
+ String zigou = userVipConfigService.getValueByKey("vip_pre_10_order_count");
+ if (!StringUtil.isNullOrEmpty(zigou)) {
+ limitOrder = Long.parseLong(zigou);
+ }
+
+ long limitFirst = 0;
+ String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count");
+ if (!StringUtil.isNullOrEmpty(first)) {
+ limitFirst = Long.parseLong(first);
+ }
+
+ long limitSecond = 0;
+ String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count");
+ if (!StringUtil.isNullOrEmpty(second)) {
+ limitSecond = Long.parseLong(second);
+ }
+
+ if (doneOrder >= limitOrder) {
+ return UserVIPPreInfo.SOURCE_TYPE_ORDER;
+ }
+
+ if ((doneFirst >= limitFirst && doneSecond >= limitSecond))
+
+ return UserVIPPreInfo.SOURCE_TYPE_TEAM;
+ return 0;
}
@Transactional(rollbackFor = Exception.class)
@@ -385,13 +376,15 @@
info.setId(userInfo.getId());
info.setState(UserVIPInfo.STATE_INVALID);
info.setUpdateTime(new Date());
+ info.setBeiZhu(reason);
userVIPInfoMapper.updateByPrimaryKeySelective(info);
-
// 娑堟伅
- MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
- msgDto.setStatus("浣犵殑璐﹀彿浠嶆槸楂樼骇浼氬憳");
- msgDto.setReason(reason);
- msgAccountDetailService.addMsgVIP(uid, "寰堟姳姝夛紒缁忎汉宸ュ鏍镐綘鏈弧瓒虫垨涓嶇鍚堝崌绾ц秴绾т細鍛樼殑鏉′欢", "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgDto);
+ userAccountMsgNotificationService.vipUpgradeFail(uid, reason);
+ }
+
+ @Override
+ public void deleteByPrimaryKey(Long id) {
+ userVIPInfoMapper.deleteByPrimaryKey(id);
}
}
--
Gitblit v1.8.0