Authored by zhaoqing

联盟红人

@@ -10,7 +10,7 @@ public enum ShareOrdersKeyEnum { @@ -10,7 +10,7 @@ public enum ShareOrdersKeyEnum {
10 ORDER_LIST("unions:share:orderList:","type:{}:status:{}:page:{}:limit:{}",3600,"订单列表"), 10 ORDER_LIST("unions:share:orderList:","type:{}:status:{}:page:{}:limit:{}",3600,"订单列表"),
11 ORDER_INFO("unions:share:orderInfo:","key:{}:orderCode:{}",3600,"订单详情"), 11 ORDER_INFO("unions:share:orderInfo:","key:{}:orderCode:{}",3600,"订单详情"),
12 USER_SETTLEMENT("unions:share:userSettlement:","type:{}",3600,"用户提现未提现总计"), 12 USER_SETTLEMENT("unions:share:userSettlement:","type:{}",3600,"用户提现未提现总计"),
13 - SETTLEMENT_LIST("unions:share:settlementList:","page:{}:limit:{}",3600,"提现列表"), 13 + SETTLEMENT_LIST("unions:share:settlementList:","key:{}:page:{}:limit:{}",3600,"提现列表"),
14 UNION_TYPE("unions:share:unionType:","key:{}",3600,"用户登录时获取对应的渠道号"), 14 UNION_TYPE("unions:share:unionType:","key:{}",3600,"用户登录时获取对应的渠道号"),
15 RECENTLY_ORDER_LIMIT_TEN("unions:share:recentlyOrderLimitTen:","key:{}",3600,"用户前台获取个人推广近期订单(10个)"); 15 RECENTLY_ORDER_LIMIT_TEN("unions:share:recentlyOrderLimitTen:","key:{}",3600,"用户前台获取个人推广近期订单(10个)");
16 16
1 package com.yoho.unions.common.redis; 1 package com.yoho.unions.common.redis;
2 2
3 -import com.alibaba.fastjson.JSONArray;  
4 -import com.google.common.collect.Lists;  
5 -import com.google.common.collect.Maps;  
6 -  
7 import com.yoho.core.redis.cluster.annotation.Redis; 3 import com.yoho.core.redis.cluster.annotation.Redis;
8 import com.yoho.core.redis.cluster.operations.nosync.YHHashOperations; 4 import com.yoho.core.redis.cluster.operations.nosync.YHHashOperations;
9 import com.yoho.core.redis.cluster.operations.nosync.YHRedisTemplate; 5 import com.yoho.core.redis.cluster.operations.nosync.YHRedisTemplate;
@@ -11,18 +7,13 @@ import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder; @@ -11,18 +7,13 @@ import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
11 import com.yoho.unions.common.utils.SerializeUtils; 7 import com.yoho.unions.common.utils.SerializeUtils;
12 import com.yoho.unions.helper.CacheKeyHelper; 8 import com.yoho.unions.helper.CacheKeyHelper;
13 import org.apache.commons.collections.CollectionUtils; 9 import org.apache.commons.collections.CollectionUtils;
14 -import org.apache.commons.collections.MapUtils;  
15 import org.apache.commons.lang3.StringUtils; 10 import org.apache.commons.lang3.StringUtils;
16 import org.slf4j.Logger; 11 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 12 import org.slf4j.LoggerFactory;
18 -import org.springframework.beans.factory.annotation.Autowired;  
19 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
20 14
21 -import javax.annotation.Resource;  
22 import java.util.ArrayList; 15 import java.util.ArrayList;
23 -import java.util.Collection;  
24 import java.util.List; 16 import java.util.List;
25 -import java.util.Map;  
26 import java.util.concurrent.TimeUnit; 17 import java.util.concurrent.TimeUnit;
27 18
28 @Component 19 @Component
  1 +package com.yoho.unions.dal.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * Created by qing.zhao on 2018/5/17.
  7 + */
  8 +public class UnionShareOrdersListBO {
  9 + private List<UnionShareOrders> list;
  10 +
  11 + public List<UnionShareOrders> getList() {
  12 + return list;
  13 + }
  14 +
  15 + public void setList(List<UnionShareOrders> list) {
  16 + this.list = list;
  17 + }
  18 +}
@@ -291,7 +291,7 @@ @@ -291,7 +291,7 @@
291 <include refid="Base_Column_List" /> 291 <include refid="Base_Column_List" />
292 from union_share_orders 292 from union_share_orders
293 where promote_uid = #{uid,jdbcType=INTEGER} 293 where promote_uid = #{uid,jdbcType=INTEGER}
294 - <if test="tab1 != null and tab1 == 1 and tab2 == null"> 294 + <if test="tab1 != null and tab1 == 1 and tab2 == 0">
295 AND status != 100 295 AND status != 100
296 </if> 296 </if>
297 <if test="tab1 != null and tab1 == 1 and tab2 == 1"> 297 <if test="tab1 != null and tab1 == 1 and tab2 == 1">
@@ -303,7 +303,7 @@ @@ -303,7 +303,7 @@
303 <if test="tab1 != null and tab1 == 1 and tab2 == 3"> 303 <if test="tab1 != null and tab1 == 1 and tab2 == 3">
304 AND status IN (30,40) 304 AND status IN (30,40)
305 </if> 305 </if>
306 - <if test="tab1 != null and tab1 == 2 and tab2 == null"> 306 + <if test="tab1 != null and tab1 == 2 and tab2 == 0">
307 AND status IN (10,20,30,40) 307 AND status IN (10,20,30,40)
308 </if> 308 </if>
309 <if test="tab1 != null and tab1 == 2 and tab2 == 1"> 309 <if test="tab1 != null and tab1 == 2 and tab2 == 1">
@@ -282,26 +282,40 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -282,26 +282,40 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
282 @Override 282 @Override
283 public List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) { 283 public List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) {
284 //先从缓存获取 284 //先从缓存获取
285 - String key = "orderDetail"; 285 + String key = "settlementRecord";
286 UnionShareSettlementListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST, unionShareOrderReqBO.getUid(), 286 UnionShareSettlementListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST, unionShareOrderReqBO.getUid(),
287 UnionShareSettlementListBO.class, key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); 287 UnionShareSettlementListBO.class, key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
288 if (cacheResult != null) { 288 if (cacheResult != null) {
289 - logger.info("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult); 289 + logger.info("UnionShareServiceImpl :: querySettlementRecord get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
290 return cacheResult.getList(); 290 return cacheResult.getList();
291 } 291 }
  292 + //数据库获取
292 List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(), 293 List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
293 unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize()); 294 unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
294 //设置缓存 295 //设置缓存
295 UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO(); 296 UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO();
296 unionShareSettlementListBO.setList(unionShareSettlement); 297 unionShareSettlementListBO.setList(unionShareSettlement);
297 - addToRedis(ShareOrdersKeyEnum.ORDER_INFO,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); 298 + addToRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
298 return unionShareSettlement; 299 return unionShareSettlement;
299 } 300 }
300 301
301 @Override 302 @Override
302 public List<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) { 303 public List<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) {
  304 + //先从缓存获取
  305 + UnionShareOrdersListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),UnionShareOrdersListBO.class, unionShareOrderReqBO.getTab1().toString(),
  306 + unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
  307 + if (cacheResult != null) {
  308 + logger.info("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
  309 + return cacheResult.getList();
  310 + }
  311 + //数据库获取
303 //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中 312 //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中
304 List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO); 313 List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO);
  314 + //设置缓存
  315 + UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO();
  316 + unionShareOrdersListBO.setList(unionShareOrdersList);
  317 + addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),unionShareOrdersListBO,unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(),
  318 + String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
305 return unionShareOrdersList; 319 return unionShareOrdersList;
306 } 320 }
307 321
@@ -669,6 +683,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -669,6 +683,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
669 redisHashCache.delete(ShareOrdersKeyEnum.ORDER_LIST.getPreKey(),uid); 683 redisHashCache.delete(ShareOrdersKeyEnum.ORDER_LIST.getPreKey(),uid);
670 redisHashCache.delete(ShareOrdersKeyEnum.SETTLEMENT_LIST.getPreKey(),uid); 684 redisHashCache.delete(ShareOrdersKeyEnum.SETTLEMENT_LIST.getPreKey(),uid);
671 redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(),uid); 685 redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(),uid);
  686 + redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),uid);
  687 + redisHashCache.delete(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN.getPreKey(),uid);
672 } 688 }
673 689
674 @Override 690 @Override