From d6ac376bbb16b750501ed47df999536980870b96 Mon Sep 17 00:00:00 2001 From: 喻健 <喻健@Admin> Date: 星期三, 21 十一月 2018 18:22:02 +0800 Subject: [PATCH] 前端:队员列表1.4.1 --- fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 169 insertions(+), 0 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java index 9e5e27d..2c71903 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java @@ -1,10 +1,17 @@ package com.yeshi.fanli.service.impl.hongbao; import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.Map; import javax.annotation.Resource; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import org.hibernate.HibernateException; import org.hibernate.Query; @@ -19,12 +26,14 @@ import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dao.user.ThreeSaleDao; import com.yeshi.fanli.entity.bus.user.ThreeSale; +import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.service.inter.config.InviteGetMoneyService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.StringUtil; @Service public class ThreeSaleSerivceImpl implements ThreeSaleSerivce { @@ -342,7 +351,167 @@ public long countSuperiorQuery(Integer state, Long uid) { return threeSaleMapper.countSuperiorQuery(state, uid); } + + @Override + public List<ThreeSale> listFirstTeam(long start, int count, Long uid) { + return threeSaleMapper.listFirstTeam(start, count, uid); + } + + @Override + public long countFirstTeam(Long uid, Integer state) { + return threeSaleMapper.countFirstTeam(uid, state); + } + + @Override + public List<ThreeSale> listSecondTeam(long start, int count, Long uid) { + return threeSaleMapper.listSecondTeam(start, count, uid); + } + + @Override + public long countSecondTeam(Long uid, Integer state) { + return threeSaleMapper.countSecondTeam(uid, state); + } + @Override + public ThreeSale getMyBoss(Long uid) { + return threeSaleMapper.getMyBoss(uid); + } + + + @Override + public JSONObject getMyFirstTeam(long start, int count, Long uid) { + + List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid); + if (list == null) { + list = new ArrayList<ThreeSale>(); + } + + long countTotal = threeSaleMapper.countFirstTeam(uid, null); + + return organizeTeam(countTotal, list); + } + + @Override + public JSONObject getMySecondTeam(long start, int count, Long uid) { + List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid); + if (list == null) { + list = new ArrayList<ThreeSale>(); + } + + long countTotal = threeSaleMapper.countSecondTeam(uid, null); + + return organizeTeam(countTotal, list); + } + + + + public JSONObject organizeTeam(long count, List<ThreeSale> list) { + + JSONObject result = new JSONObject(); + + JSONArray resultArray = new JSONArray(); + + for (ThreeSale threeSale: list) { + + JSONObject object = new JSONObject(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + Long createTime = threeSale.getCreateTime(); + Date inviteTime = new Date(createTime); + object.put("inviteTime", sdf.format(inviteTime) + "鍔犲叆"); + + String nickName = null; + Long lastLoginTime = null; + String portrait = null; + Long workerId = null; + + UserInfo worker = threeSale.getWorker(); + if (worker != null) { + workerId = worker.getId(); + portrait = worker.getPortrait(); + lastLoginTime = worker.getLastLoginTime(); + nickName = worker.getNickName(); + } + + object.put("workerId", workerId); + object.put("portrait", portrait); + + int type = 0; + String fontColor1 = "#888888"; + String fontColor2 = "#F14242"; + + JSONArray array = new JSONArray(); + if (threeSale.getState()) { + type = 1; + if (lastLoginTime == null) { + lastLoginTime = threeSale.getCreateTime(); + } + + JSONArray array1 = new JSONArray(); + array1.add(fontColor1); + array1.add("鏈�杩戠櫥闄�" + sdf.format(lastLoginTime)); + + array.add(array1); + + } else if ( threeSale.getExpire()!= null && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) { + type = 2; + JSONArray array1 = new JSONArray(); + array1.add(fontColor1); + array1.add("宸茬粡鑴辩閭�璇峰叧绯�"); + + array.add(array1); + } else { + type = 0; + + Calendar c = Calendar.getInstance(); + c.setTime(inviteTime); + c.add(Calendar.DAY_OF_MONTH, 60);// 閭�璇蜂笉瓒呰繃60澶� + Date todayTime = new Date(); + + long days = (c.getTimeInMillis() -todayTime.getTime()) / (1000*3600*24); + if (days < 0) { + days = 0; + } + + JSONArray array1 = new JSONArray(); + array1.add(fontColor1); + array1.add("灏嗕簬"); + + JSONArray array2 = new JSONArray(); + array2.add(fontColor2); + array2.add(days+"澶� "); + + JSONArray array3 = new JSONArray(); + array3.add(fontColor1); + array3.add("鍚庤劚绂婚個璇峰叧绯�"); + + array.add(array1); + array.add(array2); + array.add(array3); + } + + object.put("type", type); + object.put("recentMsg", array); + + ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo(); + if (threeSaleExtraInfo != null) { + if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) { + nickName = threeSaleExtraInfo.getNickname(); + } + } + + object.put("nickName", nickName); + + resultArray.add(object); + } + + result.put("count", count); + result.put("result_list", resultArray); + + return result; + + } } -- Gitblit v1.8.0