|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.oss.OSS;
|
|
import com.aliyun.oss.OSS;
|
|
import com.aliyun.oss.OSSClientBuilder;
|
|
import com.aliyun.oss.OSSClientBuilder;
|
|
|
|
+import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.ClubMapper;
|
|
import com.caimei365.user.mapper.ClubMapper;
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
@@ -20,12 +21,14 @@ import com.caimei365.user.model.po.UserBeansHistoryPo;
|
|
import com.caimei365.user.model.po.UserPo;
|
|
import com.caimei365.user.model.po.UserPo;
|
|
import com.caimei365.user.model.vo.*;
|
|
import com.caimei365.user.model.vo.*;
|
|
import com.caimei365.user.service.ClubService;
|
|
import com.caimei365.user.service.ClubService;
|
|
|
|
+import com.caimei365.user.utils.ImageUtils;
|
|
import com.caimei365.user.utils.OssUtil;
|
|
import com.caimei365.user.utils.OssUtil;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -44,7 +47,8 @@ import static com.alibaba.fastjson.JSON.parseObject;
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class ClubServiceImpl implements ClubService {
|
|
public class ClubServiceImpl implements ClubService {
|
|
-
|
|
|
|
|
|
+ @Value("${caimei.wwwDomain}")
|
|
|
|
+ private String wwwDomain;
|
|
@Resource
|
|
@Resource
|
|
private ClubMapper clubMapper;
|
|
private ClubMapper clubMapper;
|
|
@Resource
|
|
@Resource
|
|
@@ -53,6 +57,8 @@ public class ClubServiceImpl implements ClubService {
|
|
private RegisterMapper registerMapper;
|
|
private RegisterMapper registerMapper;
|
|
@Resource
|
|
@Resource
|
|
private SuperVipMapper vipMapper;
|
|
private SuperVipMapper vipMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据用户Id查询机构资料
|
|
* 根据用户Id查询机构资料
|
|
@@ -480,7 +486,7 @@ public class ClubServiceImpl implements ClubService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ResponseJson<Map<String, Object>> getPersonalData(Integer userId) {
|
|
public ResponseJson<Map<String, Object>> getPersonalData(Integer userId) {
|
|
- Map<String, Object> result = new HashMap<>(11);
|
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>(8);
|
|
// 1.用户信息
|
|
// 1.用户信息
|
|
UserVo user = baseMapper.getUserByUserId(userId);
|
|
UserVo user = baseMapper.getUserByUserId(userId);
|
|
if (user == null) {
|
|
if (user == null) {
|
|
@@ -511,9 +517,73 @@ public class ClubServiceImpl implements ClubService {
|
|
} else {
|
|
} else {
|
|
result.put("degree", "80%");
|
|
result.put("degree", "80%");
|
|
}
|
|
}
|
|
|
|
+ // 5.未读消息数量
|
|
|
|
+ Integer unReadMessageCount = clubMapper.getUnReadMessageCount(userId);
|
|
|
|
+ result.put("unReadMessageCount", unReadMessageCount);
|
|
|
|
+ // 6.优惠券可用数量
|
|
|
|
+ Integer couponNum = clubMapper.getUserCouponCount(userId);
|
|
|
|
+ result.put("couponNum", couponNum);
|
|
|
|
+ // 7.今日推荐
|
|
|
|
+ int floorId = 6;
|
|
|
|
+ int index = 1;
|
|
|
|
+ String homeAdvertiseKey = "home_advertise_" + floorId;
|
|
|
|
+ if (!redisService.exists(homeAdvertiseKey)) {
|
|
|
|
+ AdvertiseVo homePageAdvertise = new AdvertiseVo();
|
|
|
|
+ homePageAdvertise.setAdvertiseTypeId(1001);
|
|
|
|
+ homePageAdvertise.setTypeId(floorId);
|
|
|
|
+ homePageAdvertise.setValidFlag("1");
|
|
|
|
+ List<AdvertiseVo> list = clubMapper.getUserAdvertiseList(homePageAdvertise);
|
|
|
|
+ for (AdvertiseVo advertise : list) {
|
|
|
|
+ advertise.setImage(ImageUtils.getImageURL("homePageImages", advertise.getImage(), 0, wwwDomain));
|
|
|
|
+ }
|
|
|
|
+ redisService.setList(homeAdvertiseKey, list);
|
|
|
|
+ }
|
|
|
|
+ int pageSize = 4;
|
|
|
|
+ int totalRecord = (int) redisService.listSize(homeAdvertiseKey);
|
|
|
|
+ int total = totalRecord % pageSize == 0 ? totalRecord / pageSize : totalRecord / pageSize + 1;
|
|
|
|
+ if (index > total) {
|
|
|
|
+ index = index % total;
|
|
|
|
+ }
|
|
|
|
+ int begin = (index - 1) * pageSize;
|
|
|
|
+ int end = index * pageSize - 1;
|
|
|
|
+ //避免unchecked cast warning
|
|
|
|
+ List<AdvertiseVo> list = new ArrayList<>();
|
|
|
|
+ Object advertiseObj = redisService.getList(homeAdvertiseKey, begin, end);
|
|
|
|
+ if (advertiseObj instanceof ArrayList<?>) {
|
|
|
|
+ for (Object o : (List<?>) advertiseObj) {
|
|
|
|
+ list.add((AdvertiseVo) o);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.put("homePageAdvertiseList", list);
|
|
|
|
+ // 8.最新动态
|
|
|
|
+ String informationKey = "home_info_" + floorId;
|
|
|
|
+ redisService.remove(informationKey);
|
|
|
|
+ if (!redisService.exists(informationKey)) {
|
|
|
|
+ InformationVo info = new InformationVo();
|
|
|
|
+ info.setInfoTypeId(1);
|
|
|
|
+ info.setValidFlag("1");
|
|
|
|
+ List<InformationVo> infoList = clubMapper.getInformationList(info);
|
|
|
|
+ infoList.forEach(information -> information.setLink("/info/detail-" + information.getInformationId() + "-1.html"));
|
|
|
|
+ redisService.setList(informationKey, infoList);
|
|
|
|
+ }
|
|
|
|
+ int infoIndex = 1;
|
|
|
|
+ int infoPageSize = 5;
|
|
|
|
+ int totalInfoRecord = (int) redisService.listSize(informationKey);
|
|
|
|
+ int totalInfo = totalInfoRecord % infoPageSize == 0 ? totalInfoRecord / infoPageSize : totalInfoRecord / infoPageSize + 1;
|
|
|
|
+ if (infoIndex > totalInfo) {
|
|
|
|
+ infoIndex = infoIndex % totalInfo;
|
|
|
|
+ }
|
|
|
|
+ int infoBegin = (infoIndex - 1) * infoPageSize;
|
|
|
|
+ int infoEnd = infoIndex * infoPageSize - 1;
|
|
|
|
+ List<InformationVo> infoList = new ArrayList<>();
|
|
|
|
+ Object infoObj = redisService.getList(informationKey, infoBegin, infoEnd);
|
|
|
|
+ if (infoObj instanceof ArrayList<?>) {
|
|
|
|
+ for (Object o : (List<?>) infoObj) {
|
|
|
|
+ infoList.add((InformationVo) o);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.put("homePageInfoList", infoList);
|
|
|
|
|
|
- //todo
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
|
|
+ return ResponseJson.success(result);
|
|
}
|
|
}
|
|
}
|
|
}
|