| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInfoExtraMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserRankRecordMapper;
|
| | |
| | | if (userInfoExtra != null && userInfoExtra.getId() != null) {
|
| | | // 判断当月是否已更新
|
| | | Date rankUpdateTime = userInfoExtra.getRankUpdateTime();
|
| | | if (rankUpdateTime != null && DateUtil.isSameMonth(rankUpdateTime, new Date())) {
|
| | | isupdateRank = false;
|
| | | if (rankUpdateTime != null) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
| | | if (sdf.format(rankUpdateTime).equals(sdf.format(new Date()))) {
|
| | | isupdateRank = false;
|
| | | }
|
| | | }
|
| | | } else {
|
| | | userInfoExtra = new UserInfoExtra();
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | // 等级更新时间
|
| | | userInfoExtra.setRankUpdateTime(new Date());
|
| | | |
| | | // 等级更新时间 当月1号
|
| | | Calendar calendar1=Calendar.getInstance();
|
| | | calendar1.set(Calendar.DAY_OF_MONTH, 1);
|
| | | userInfoExtra.setRankUpdateTime(calendar1.getTime());
|
| | | |
| | | // 保存信息并返回
|
| | | saveUserInfoExtra(userInfoExtra);
|
| | |
|
| | |
| | | public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException{
|
| | | if (uid == null || inviteCode == null) {
|
| | | throw new UserInfoExtraException(1, "用户id、邀请码不能为空");
|
| | | }
|
| | | |
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra != null) {
|
| | | String inviteCodeHas = extra.getInviteCode();
|
| | | if (inviteCodeHas != null && inviteCodeHas.trim().length() > 0) {
|
| | | throw new UserInfoExtraException(1, "已存在邀请码,请刷新页面");
|
| | | }
|
| | | }
|
| | |
|
| | | // 被邀请人信息
|
| | |
| | | return inviteCode;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByRankId(Long rankId) {
|
| | | return userInfoExtraMapper.countByRankId(rankId);
|
| | | }
|
| | | |
| | | |
| | | |
| | | }
|