| | |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | UserInviteLevelEnum level = null;
|
| | | // VIP预览信息
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.mineInfo);
|
| | | if (!StringUtil.isNullOrEmpty(redisContent)) {
|
| | | MineInfoVO vo = new Gson().fromJson(redisContent, MineInfoVO.class);
|
| | |
| | | data.put("vipAction", vipAction);
|
| | |
|
| | | }
|
| | | |
| | | data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | |
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | @RequestMapping(value = "countTeamNum")
|
| | | public void countTeamNum(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | try {
|
| | | |
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | /**
|
| | | * 邀请排行榜
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param dateType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRanking")
|
| | | public void getRanking(String callback, AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
|
| | | if (uid == null || dateType == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数缺失"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(timeStamp);
|
| | | |
| | | if (dateType == 1) {
|
| | | // 今日
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | } else if (dateType == 2) {
|
| | | // 昨日
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | minDate = DateUtil.reduceDay(1, maxDate);
|
| | | } else {
|
| | | // 本月
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | }
|
| | | |
| | | |
| | | List<OrderRankingVO> list = teamDailyRecordService.getRankingByFirstNum(uid, minDate, maxDate);
|
| | | if (list.size() > 0) {
|
| | | for (OrderRankingVO vo: list) {
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(vo.getUid());
|
| | | vo.setNickName(user.getNickName());
|
| | | vo.setPortrait(user.getPortrait());
|
| | | }
|
| | | }
|
| | | |
| | | JSONObject json = new JSONObject();
|
| | | json.put("list", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | |
| | | import com.yeshi.fanli.vo.money.MoneyPredictVO;
|
| | | import com.yeshi.fanli.vo.money.MoneyStatisticVO;
|
| | | import com.yeshi.fanli.vo.money.TeamPredictVO;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | private OrderMoneyDailyCount createVO(List<OrderMoneyDailyCount> list) {
|
| | | OrderMoneyDailyCount totalityRecord = new OrderMoneyDailyCount(0,0,0);
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | for (OrderMoneyDailyCount record: list) {
|
| | | totalityRecord.setDirectOrderNum(totalityRecord.getDirectOrderNum() + record.getDirectOrderNum());
|
| | |
| | | totalityRecord.setBeyondOrderNum(totalityRecord.getBeyondOrderNum() + record.getBeyondOrderNum());
|
| | | }
|
| | | }
|
| | | |
| | | return totalityRecord;
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 订单排行榜
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param dateType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRanking")
|
| | | public void getRanking(String callback, AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
|
| | | if (uid == null || dateType == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数缺失"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | |
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(timeStamp);
|
| | | |
| | | if (dateType == 1) {
|
| | | // 今日
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | } else if (dateType == 2) {
|
| | | // 昨日
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | minDate = DateUtil.reduceDay(1, maxDate);
|
| | | } else {
|
| | | // 本月
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | }
|
| | | |
| | | List<OrderRankingVO> list = orderMoneyDailyCountService.getRankingByOrderNum(uid, minDate, maxDate);
|
| | | if (list.size() > 0) {
|
| | | for (OrderRankingVO vo: list) {
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(vo.getUid());
|
| | | vo.setNickName(user.getNickName());
|
| | | vo.setPortrait(user.getPortrait());
|
| | | }
|
| | | }
|
| | | |
| | | JSONObject json = new JSONObject();
|
| | | json.put("list", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.data.domain.Sort;
|
| | | import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
| | | import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
| | | import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
| | | import org.springframework.data.mongodb.core.aggregation.LookupOperation;
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.data.mongodb.core.query.Update;
|
| | | import org.springframework.stereotype.Repository;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.mongodb.BasicDBList;
|
| | | import com.mongodb.BasicDBObject;
|
| | |
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.order.OrderMoneyDailyCount;
|
| | | import com.yeshi.fanli.entity.order.OrderMoneyDailyCount.SourceTypeEnum;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | @Repository
|
| | | public class OrderMoneyDailyCountDao extends MongodbBaseDao<OrderMoneyDailyCount> {
|
| | |
| | | }
|
| | | return results;
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 根据订单排行榜进行uid分组订单数量排序
|
| | | * @param uid
|
| | | * @param minDate
|
| | | * @param maxDate
|
| | | * @return
|
| | | */
|
| | | public List<OrderRankingVO> getRankingByOrderNum(Long uid, Date minDate, Date maxDate) {
|
| | | LookupOperation lookupToLots = LookupOperation.newLookup().
|
| | | from("order_money_daily_count").//关联表名,多方
|
| | | localField("workerUid").// 主表关联字段
|
| | | foreignField("uid").// 次表字段关联字段
|
| | | as("orders"); // 次表的别名
|
| | |
|
| | | // 查询条件
|
| | | List<Criteria> list = new ArrayList<Criteria>();
|
| | | list.add(Criteria.where("bossUid").is(uid));
|
| | | if (minDate != null) {
|
| | | minDate = DateUtil.reduceDay(minDate, 1);
|
| | | list.add(Criteria.where("orders.countDay").gt(minDate));
|
| | | }
|
| | | if (maxDate != null) {
|
| | | maxDate = DateUtil.reduceDay(maxDate, 1);
|
| | | list.add(Criteria.where("orders.countDay").lte(maxDate));
|
| | | }
|
| | | // 转换数组
|
| | | Criteria[] cas = new Criteria[list.size()];
|
| | | for (int i = 0; i < list.size(); i++)
|
| | | cas[i] = list.get(i);
|
| | | // 查询参数
|
| | | Criteria criteria = new Criteria().andOperator(cas);
|
| | | |
| | | |
| | | List<AggregationOperation> aggs = new ArrayList<>(); |
| | | // 左连接
|
| | | aggs.add(lookupToLots); |
| | | // 拆分子数组
|
| | | aggs.add(Aggregation.unwind("orders"));
|
| | | // 条件匹配
|
| | | aggs.add(Aggregation.match(criteria)); |
| | | // 需要返回的字段
|
| | | aggs.add(Aggregation.project().and("workerUid").as("workerUid").and("level").as("level")
|
| | | .and("orders.orderNum").as("number"));
|
| | | // 分组求和并返回
|
| | | aggs.add(Aggregation.group("workerUid").first("workerUid").as("workerUid").first("level").as("level")
|
| | | .sum("number").as("number")); |
| | | // 排序
|
| | | aggs.add(Aggregation.sort(new Sort(Sort.Direction.DESC, "number"))); |
| | | aggs.add(Aggregation.limit(10)); |
| | | |
| | | // 组织条件
|
| | | Aggregation agg = Aggregation.newAggregation(aggs); |
| | | // 执行查询
|
| | | AggregationResults<BasicDBObject> results = mongoTemplate.aggregate(agg, "threeSaleDetail", BasicDBObject.class);
|
| | | |
| | | // 返回结果处理
|
| | | List<BasicDBObject> livevideo = results.getMappedResults();
|
| | | |
| | | List<OrderRankingVO> resultList = new ArrayList<>();
|
| | | for (BasicDBObject obj : livevideo) {
|
| | | Object object = obj.get("workerUid");
|
| | | if (object == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | OrderRankingVO vo = new OrderRankingVO();
|
| | | vo.setUid(new BigDecimal(obj.get("workerUid").toString()).longValue());
|
| | | vo.setGrade(new BigDecimal(obj.get("level").toString()).intValue());
|
| | | vo.setNumber(new BigDecimal(obj.get("number").toString()).intValue());
|
| | | resultList.add(vo); |
| | | }
|
| | | return resultList;
|
| | | }
|
| | | }
|
| | |
| | | import java.util.Locale;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.data.domain.Sort;
|
| | | import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
| | | import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
| | | import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
| | | import org.springframework.data.mongodb.core.aggregation.LookupOperation;
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.data.mongodb.core.query.Update;
|
| | | import org.springframework.stereotype.Repository;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.mongodb.BasicDBList;
|
| | | import com.mongodb.BasicDBObject;
|
| | |
| | | import com.mongodb.GroupCommand;
|
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | @Repository
|
| | | public class TeamDailyRecordDao extends MongodbBaseDao<TeamDailyRecord> {
|
| | |
| | | }
|
| | | return results;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 根据订单排行榜进行uid分组订单数量排序
|
| | | * @param uid
|
| | | * @param minDate
|
| | | * @param maxDate
|
| | | * @return
|
| | | */
|
| | | public List<OrderRankingVO> getRankingByFirstNum(Long uid, Date minDate, Date maxDate) {
|
| | | LookupOperation lookupToLots = LookupOperation.newLookup().
|
| | | from("teamDailyRecord").//关联表名,多方
|
| | | localField("workerUid").// 主表关联字段
|
| | | foreignField("uid").// 次表字段关联字段
|
| | | as("result"); // 次表的别名
|
| | |
|
| | | // 查询条件
|
| | | List<Criteria> list = new ArrayList<Criteria>();
|
| | | list.add(Criteria.where("bossUid").is(uid));
|
| | | if (minDate != null) {
|
| | | minDate = DateUtil.reduceDay(minDate, 1);
|
| | | list.add(Criteria.where("orders.countDay").gt(minDate));
|
| | | }
|
| | | if (maxDate != null) {
|
| | | maxDate = DateUtil.reduceDay(maxDate, 1);
|
| | | list.add(Criteria.where("orders.countDay").lte(maxDate));
|
| | | }
|
| | | |
| | | // 转换数组
|
| | | Criteria[] cas = new Criteria[list.size()];
|
| | | for (int i = 0; i < list.size(); i++)
|
| | | cas[i] = list.get(i);
|
| | | // 查询参数
|
| | | Criteria criteria = new Criteria().andOperator(cas);
|
| | | |
| | | |
| | | List<AggregationOperation> aggs = new ArrayList<>(); |
| | | // 左连接
|
| | | aggs.add(lookupToLots); |
| | | // 拆分子数组
|
| | | aggs.add(Aggregation.unwind("result"));
|
| | | // 条件匹配
|
| | | aggs.add(Aggregation.match(criteria)); |
| | | // 需要返回的字段
|
| | | aggs.add(Aggregation.project().and("workerUid").as("workerUid").and("level").as("level")
|
| | | .and("result.firstNum").as("number"));
|
| | | // 分组求和并返回
|
| | | aggs.add(Aggregation.group("workerUid").first("workerUid").as("workerUid").first("level").as("level")
|
| | | .sum("number").as("number")); |
| | | // 排序
|
| | | aggs.add(Aggregation.sort(new Sort(Sort.Direction.DESC, "number"))); |
| | | aggs.add(Aggregation.limit(10)); |
| | | |
| | | // 组织条件
|
| | | Aggregation agg = Aggregation.newAggregation(aggs); |
| | | // 执行查询
|
| | | AggregationResults<BasicDBObject> results = mongoTemplate.aggregate(agg, "threeSaleDetail", BasicDBObject.class);
|
| | | |
| | | // 返回结果处理
|
| | | List<BasicDBObject> livevideo = results.getMappedResults();
|
| | | |
| | | List<OrderRankingVO> resultList = new ArrayList<>();
|
| | | for (BasicDBObject obj : livevideo) {
|
| | | Object object = obj.get("workerUid");
|
| | | if (object == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | OrderRankingVO vo = new OrderRankingVO();
|
| | | vo.setUid(new BigDecimal(obj.get("workerUid").toString()).longValue());
|
| | | vo.setGrade(new BigDecimal(obj.get("level").toString()).intValue());
|
| | | vo.setNumber(new BigDecimal(obj.get("number").toString()).intValue());
|
| | | resultList.add(vo); |
| | | }
|
| | | return resultList;
|
| | | }
|
| | | }
|
| | |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TimeUtil; |
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService; |
| | | import com.yeshi.fanli.vo.order.OrderRankingVO; |
| | | |
| | | @Service |
| | | public class OrderMoneyDailyCountServiceImpl implements OrderMoneyDailyCountService { |
| | |
| | | return orderMoneyDailyCountDao.sumTeamOrderNumGroupByUid(uid, minDay, maxDay); |
| | | } |
| | | |
| | | @Override |
| | | public List<OrderRankingVO> getRankingByOrderNum(Long uid, Date minDay, Date maxDay) { |
| | | return orderMoneyDailyCountDao.getRankingByOrderNum(uid, minDay, maxDay); |
| | | } |
| | | } |
| | |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | @Service
|
| | | public class TeamDailyRecordServiceImpl implements TeamDailyRecordService {
|
| | |
| | | return teamDailyRecordDao.sumTeamNumGroupByUid(uid, minDay, maxDay);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<OrderRankingVO> getRankingByFirstNum(Long uid, Date minDay, Date maxDay) {
|
| | | return teamDailyRecordDao.getRankingByFirstNum(uid, minDay, maxDay);
|
| | | }
|
| | | }
|
| | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.entity.order.OrderMoneyDailyCount; |
| | | import com.yeshi.fanli.vo.order.OrderRankingVO; |
| | | |
| | | public interface OrderMoneyDailyCountService { |
| | | |
| | |
| | | |
| | | public List<OrderMoneyDailyCount> sumTeamOrderNumGroupByUid(Long uid, Date minDay, Date maxDay); |
| | | |
| | | /** |
| | | * 我的订单排行榜 |
| | | * @param uid |
| | | * @param minDay |
| | | * @param maxDay |
| | | * @return |
| | | */ |
| | | public List<OrderRankingVO> getRankingByOrderNum(Long uid, Date minDay, Date maxDay); |
| | | |
| | | |
| | | } |
| | |
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
|
| | | import com.yeshi.fanli.exception.user.TeamDailyRecordException;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | public interface TeamDailyRecordService {
|
| | |
|
| | |
| | |
|
| | |
|
| | | public List<TeamDailyRecord> sumTeamNumGroupByUid(Long uid, Date minDay, Date maxDay);
|
| | |
|
| | | /**
|
| | | * 邀请排行榜
|
| | | * @param uid
|
| | | * @param minDay
|
| | | * @param maxDay
|
| | | * @return
|
| | | */
|
| | | public List<OrderRankingVO> getRankingByFirstNum(Long uid, Date minDay, Date maxDay);
|
| | | }
|