From 393e3a365b5ebbed6e9eef07fbd18881cde73711 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 28 三月 2020 16:51:04 +0800 Subject: [PATCH] Merge branch 'div' into div-1 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java | 477 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 449 insertions(+), 28 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 1f45dd5..b7f9e41 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,44 +11,97 @@ import javax.annotation.Resource; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.yeshi.utils.DateUtil; 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.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.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo; +import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; +import com.yeshi.fanli.entity.integral.IntegralDetail; import com.yeshi.fanli.entity.shop.BanLiShopOrder; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; +import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; +import com.yeshi.fanli.exception.msg.MsgAccountDetailException; import com.yeshi.fanli.exception.user.vip.UserVIPInfoException; +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.msg.MsgAccountDetailService; 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; @Service public class UserVIPInfoServiceImpl implements UserVIPInfoService { @Resource private UserVIPInfoMapper userVIPInfoMapper; - + + @Resource + private UserInfoService userInfoService; + @Resource private UserInfoExtraService userInfoExtraService; - + @Resource private UserVipConfigService userVipConfigService; - + + @Lazy @Resource 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; @Override + @Transactional(rollbackFor = Exception.class) public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException { if (info.getId() == null) { throw new UserVIPInfoException(1, "淇℃伅涓嶅畬鏁�"); @@ -63,26 +116,114 @@ userVIPInfoMapper.insert(info); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public void passVIPApply(Long uid) throws UserVIPInfoException { - UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); - if (userInfo == null) { + UserVIPInfo userVIPInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); + if (userVIPInfo == null) { throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } - if (userInfo.getState() != UserVIPInfo.STATE_VERIFING) { + if (userVIPInfo.getState() != UserVIPInfo.STATE_VERIFING) { throw new UserVIPInfoException(2, "鐢宠鏈浜庡鏍哥姸鎬�"); } + if (!verifyConform(uid)) + throw new UserVIPInfoException(1, "绯荤粺楠岃瘉锛氫笉婊¤冻鍗囩骇鏉′欢"); + UserVIPInfo info = new UserVIPInfo(); - info.setId(userInfo.getId()); + info.setId(userVIPInfo.getId()); info.setSuccessTime(new Date()); info.setState(UserVIPInfo.STATE_SUCCESS); info.setUpdateTime(new Date()); userVIPInfoMapper.updateByPrimaryKeySelective(info); + + // 涓嬬骇鐨勮秴绾т細鍛� 涓嶈劚绂� + userInviteSeparateService.updateInvalidByBossId(uid); + + // 棰濆淇℃伅 + UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid); + if (userInfoExtra == null) + throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); + + // 娣诲姞閲戝竵 + IntegralDetail detail = new IntegralDetail(); + detail.setTitle("鍗囩骇VIP绂忓埄"); + detail.setUid(uid); + detail.setMoney(Constant.VIP_COLDCOIN_NUM); + detail.setCreateTime(new Date()); + detail.setUniqueKey("VIP-" + uid); + integralDetailService.insertSelective(detail); + userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM); + + try { + // 濂栧姳鍒� + BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey())); + for (int i = 0; i < Constant.VIP_COUPON_REWARD_NUM; i++) { + userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), + UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false); + } + + // 璧犻�佸厤鍗曞埜 + for (int i = 0; i < Constant.VIP_COUPON_GIVEFREE_NUM; i++) { + userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(), + UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false); + } + } catch (Exception e) { + throw new UserVIPInfoException(1, "鍒歌禒閫佸け璐�"); + } + + // 娑堟伅 + MsgOtherVIPDTO msgOther = new MsgOtherVIPDTO(); + msgOther.setContent1("鎭枩浣狅紝宸叉垚涓鸿秴绾т細鍛�"); + msgOther.setContent2("婊¤冻鍗囩骇鏉′欢"); + msgOther.setContent3(TimeUtil.formatDateDot(new Date())); + userOtherMsgNotificationService.passVIPApplyMsg(uid, "杩斿埄濂栧姳鍒稿拰銆佽禒閫佸厤鍗曞埜鍜岄噾甯佽鍒版垜鐨�-绂忓埄涓績涓煡鐪�", msgOther); + + // 閫氱煡涓婄骇 + callBoss(uid); } + /** + * 閫氱煡涓婄骇鑴辩鍏崇郴 + * + * @param uid + */ @Transactional + private void callBoss(Long uid) { + // 鏄惁瀛樺湪涓婄骇 + ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); + if (threeSale == null) + return; + // 涓婄骇鏄惁涓轰細鍛� + Long bossId = threeSale.getBoss().getId(); + UserVIPInfo bossVIP = userVIPInfoMapper.selectByPrimaryKeyForUpdate(bossId); + if (bossVIP != null && bossVIP.getState() != null && bossVIP.getState() == UserVIPInfo.STATE_SUCCESS) + return; + + // 涔嬪墠鎻掑叆璁板綍澶辨晥 + userInviteSeparateService.updateStateByWorkerIdAndBossId(uid, bossId, UserInviteSeparate.STATE_INVALID); + + // 闄愬埗鏃堕棿 + int limitDays = Integer.parseInt(userVipConfigService.getValueByKey("invite_separate_limit_days")); + UserInviteSeparate inviteSeparate = new UserInviteSeparate(); + inviteSeparate.setBossId(bossId); + inviteSeparate.setWorkerId(uid); + inviteSeparate.setState(UserInviteSeparate.STATE_INIT); + inviteSeparate.setEndTime(DateUtil.plusDayDate(limitDays, new Date())); + inviteSeparate.setCreateTime(new Date()); + inviteSeparate.setUpdateTime(new Date()); + userInviteSeparateService.insertSelective(inviteSeparate); + + UserInfo userInfo = userInfoService.selectByPKey(uid); + // 娑堟伅 + MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO(); + msgboss.setContent1(userInfo.getNickName() + " " + uid); + msgboss.setContent2("浜�" + TimeUtil.formatDateDot(new Date()) + "鎴愬姛鍗囩骇鎴愪负瓒呯骇浼氬憳"); + msgboss.setContent3("浠婃棩璧�" + limitDays + "澶╁唴锛屼綘鏈兘鎴愪负瓒呯骇浼氬憳灏嗕細涓庡叾鑴辩閭�璇峰叧绯� "); + userOtherMsgNotificationService.teamVIPCallBoss(bossId, "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgboss); + } + + @Transactional(rollbackFor = Exception.class) @Override public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException { UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); @@ -98,19 +239,26 @@ info.setState(UserVIPInfo.STATE_INVALID); info.setUpdateTime(new Date()); userVIPInfoMapper.updateByPrimaryKeySelective(info); + + // 娑堟伅 + MsgOtherVIPDTO msgOther = new MsgOtherVIPDTO(); + msgOther.setContent1("寰堟姳姝夛紝鏈�氳繃瓒呯骇浼氬憳鐢宠"); + msgOther.setContent2("鏈弧瓒宠秴绾т細鍛樺崌绾ф潯浠舵垨鐤戜技鍑虹幇杩濊 "); + userOtherMsgNotificationService.rejectVIPApply(uid, "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgOther); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public void applyVIP(Long uid) throws UserVIPInfoException { UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); if (userInfo == null) { - throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); + userInfo = new UserVIPInfo(); + userInfo.setId(uid); + addUserVIPInfo(userInfo); } - if (userInfo.getState() != UserVIPInfo.STATE_INVALID) { + if (userInfo.getState() != UserVIPInfo.STATE_INVALID) throw new UserVIPInfoException(2, "宸茬粡鐢宠杩�"); - } UserVIPInfo info = new UserVIPInfo(); info.setId(userInfo.getId()); @@ -122,8 +270,14 @@ @Override public boolean isVIP(Long uid) { + return isVIP(uid, System.currentTimeMillis()); + } + + @Override + public boolean isVIP(Long uid, Long time) { UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKey(uid); - if (userInfo != null && userInfo.getState() == UserVIPInfo.STATE_SUCCESS) + if (userInfo != null && userInfo.getState() == UserVIPInfo.STATE_SUCCESS + && userInfo.getSuccessTime().getTime() < time) return true; else return false; @@ -155,16 +309,39 @@ return map; } - @Override public boolean verifyConform(Long uid) { if (uid == null || uid <= 0) return false; - + UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid); - if (extra == null) + if (extra == null) return false; - + + // 1銆佺洿鎺ョ矇涓濓紙浠� 2020 骞� 1 鏈� 1 鏃ヨ捣鐩存帴绮変笣浜х敓鏈夋晥璁㈠崟锛� + BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay")); + // long teamNum = + // hongBaoV2CountService.countValidOrderTeamUserByUid(uid, + // TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney); + long teamNum = 0L; + long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME); + List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin); + if (listThreeSale != null && listThreeSale.size() > 0) { + for (ThreeSale three : listThreeSale) { + UserInfo worker = three.getWorker(); + if (worker == null || worker.getId() == null) { + continue; + } + // 1銆侀個璇峰叧绯绘垚鍔熷悗锛�2銆佸崟锛堝垎浜� + 鑷喘锛夊疄浠樻澶т簬1鍏� + long countValid = hongBaoV2CountService.countValidOrderByUidAndTime(worker.getId(), + three.getSucceedTime(), payMoney); + if (countValid > 0) { + teamNum++; + } + } + } + + // 鍖哄垎鑰佺敤鎴峰拰鏂扮敤鎴� String limtDate = userVipConfigService.getValueByKey("vip_execute_time"); Date executeDate = null; try { @@ -175,10 +352,7 @@ } if (executeDate == null) return false; - - // 1銆佺洿鎺ョ矇涓濓紙浠� 2020 骞� 1 鏈� 1 鏃ヨ捣鐩存帴绮変笣浜х敓鏈夋晥璁㈠崟锛� - BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay")); - long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, executeDate.getTime(), payMoney); + if (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime()) { long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")); if (teamNum < limitNum) @@ -188,19 +362,19 @@ if (teamNum < limitNum) return false; } - + // 2銆佺疮璁¤嚜璐繑鍒┾墺100 鍏冿紙浠庢敞鍐屾澘鏍楀揩鐪佽捣锛夛紱 BigDecimal fanMoney = new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")); BigDecimal purchase = hongBaoV2CountService.getRewardMoneyBySelf(uid); if (purchase.compareTo(fanMoney) < 0) return false; - + // 3銆佺疮璁¢噾甯佲墺10000 鏋氾紙浠庢敞鍐屾澘鏍楀揩鐪佽捣锛夛紱 BigDecimal goldCoin = integralDetailService.getCumulativeMoney(uid); BigDecimal limitGoldCoin = new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin")); if (goldCoin.compareTo(limitGoldCoin) < 0) return false; - + // 4銆佷娇鐢ㄧ孩鍖呪墺1 娆� List<Integer> list = new ArrayList<Integer>(); list.add(BanLiShopOrder.STATE_SUCCESS); @@ -208,8 +382,255 @@ long limitHongBao = Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")); if (useHongBao < limitHongBao) return false; - + // 绗﹀悎鏉′欢 return true; } + + @Override + public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state) { + return userVIPInfoMapper.listQuery((page - 1) * count, count, key, state); + } + + @Override + public long countQuery(String key, Integer state) { + 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 applyVIPNew(Long uid) throws UserVIPInfoException { + UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid); + if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) { + throw new UserVIPInfoException(1, "璇ョ敤鎴疯繕涓嶆槸楂樼骇浼氬憳"); + } + + if (!verifyVipNew(uid)) + 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, "宸茬粡鐢宠杩�"); + + UserVIPInfo info = new UserVIPInfo(); + info.setId(userInfo.getId()); + info.setApplyTime(new Date()); + 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(); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void passVIPApplyNew(Long uid) throws UserVIPInfoException { + UserVIPInfo userVIPInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); + if (userVIPInfo == null) { + throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); + } + if (userVIPInfo.getState() != UserVIPInfo.STATE_VERIFING) { + throw new UserVIPInfoException(2, "鐢宠鏈浜庡鏍哥姸鎬�"); + } + + UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid); + if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) { + throw new UserVIPInfoException(1, "璇ョ敤鎴疯繕涓嶆槸楂樼骇浼氬憳"); + } + + if (!verifyVipNew(uid)) + throw new UserVIPInfoException(1, "绯荤粺楠岃瘉锛氫笉婊¤冻鍗囩骇鏉′欢"); + + // 棰濆淇℃伅 + UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid); + if (userInfoExtra == null) + throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); + + // 閫氳繃瓒呯骇浼氬憳 + UserVIPInfo info = new UserVIPInfo(); + info.setId(userVIPInfo.getId()); + info.setSuccessTime(new Date()); + info.setState(UserVIPInfo.STATE_SUCCESS); + info.setUpdateTime(new Date()); + userVIPInfoMapper.updateByPrimaryKeySelective(info); + + // 娣诲姞閲戝竵 + userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM); + // 娣诲姞閲戝竵鏄庣粏 + IntegralDetail detail = new IntegralDetail(); + detail.setTitle("鍗囩骇VIP绂忓埄"); + detail.setUid(uid); + detail.setMoney(Constant.VIP_COLDCOIN_NUM); + detail.setCreateTime(new Date()); + detail.setUniqueKey("VIP-" + uid); + integralDetailService.insertSelective(detail); + + try { + // 濂栧姳鍒� + BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey())); + for (int i = 0; i < Constant.VIP_COUPON_REWARD_NUM; i++) { + userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), + UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false); + } + + // 璧犻�佸厤鍗曞埜 + for (int i = 0; i < Constant.VIP_COUPON_GIVEFREE_NUM; i++) { + userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(), + UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false); + } + } catch (Exception e) { + throw new UserVIPInfoException(1, "鍒歌禒閫佸け璐�"); + } + + // 娑堟伅 + MsgAccountVipDTO msgDto = new MsgAccountVipDTO(); + msgDto.setStatus("宸插皢浣犵殑璐︽埛鐢遍珮绾т細鍛樺崌绾т负瓒呯骇浼氬憳"); + msgDto.setEquity("浠庢敹鍒版湰娑堟伅璧凤紝浣犲皢鑾峰緱鍏ㄩ儴瓒呯骇浼氬憳鏉冪泭"); + msgAccountDetailService.addMsgVIP(uid, "鎭枩浣狅紒缁忎汉宸ュ鏍镐綘婊¤冻鍗囩骇瓒呯骇浼氬憳鏉′欢", "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgDto); + } + + /** + * 楠岃瘉鏄惁绗﹀悎VIP + * @param uid + * @return + */ + private boolean verifyVipNew(Long uid) { + // 閭�璇疯鍗� + long countZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, + HongBaoV2.TYPE_ZIGOU); + // 閭�璇疯鍗� + long countShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, + HongBaoV2.TYPE_SHARE_GOODS); + // 闃熷憳 + long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1); + long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1); + + long limitZiGou = 0; + String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count"); + if (!StringUtil.isNullOrEmpty(zigou)) { + limitZiGou = 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 (countZiGou >= limitZiGou || countShare >= limitShare || (firstTeam >= limitFirst && secondTeam >= limitSecond)) { + return true; + } + return false; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void rejectVIPApplyNew(Long uid, String reason) throws UserVIPInfoException { + UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid); + if (userInfo == null) { + throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); + } + if (userInfo.getState() != UserVIPInfo.STATE_VERIFING) { + throw new UserVIPInfoException(2, "鐢宠鏈浜庡鏍哥姸鎬�"); + } + + UserVIPInfo info = new UserVIPInfo(); + info.setId(userInfo.getId()); + info.setState(UserVIPInfo.STATE_INVALID); + info.setUpdateTime(new Date()); + userVIPInfoMapper.updateByPrimaryKeySelective(info); + + // 娑堟伅 + MsgAccountVipDTO msgDto = new MsgAccountVipDTO(); + msgDto.setStatus("浣犵殑璐﹀彿浠嶆槸楂樼骇浼氬憳"); + msgDto.setReason(reason); + msgAccountDetailService.addMsgVIP(uid, "寰堟姳姝夛紒缁忎汉宸ュ鏍镐綘鏈弧瓒虫垨涓嶇鍚堝崌绾ц秴绾т細鍛樼殑鏉′欢", "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgDto); + } + } -- Gitblit v1.8.0