Authored by zhaoqing

联盟红人

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