Authored by zhaoqing

联盟红人

@@ -8,10 +8,12 @@ import org.slf4j.helpers.MessageFormatter; @@ -8,10 +8,12 @@ import org.slf4j.helpers.MessageFormatter;
8 public enum ShareOrdersKeyEnum { 8 public enum ShareOrdersKeyEnum {
9 9
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:","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:","page:{}:limit:{}",3600,"提现列表"),
14 - UNION_TYPE("unions:share:unionType:","",3600,"用户登录时获取对应的渠道号"); 14 + UNION_TYPE("unions:share:unionType:","key:{}",3600,"用户登录时获取对应的渠道号"),
  15 + RECENTLY_ORDER_LIMIT_TEN("unions:share:recentlyOrderLimitTen:","key:{}",3600,"用户前台获取个人推广近期订单(10个)");
  16 +
15 17
16 private String preKey; 18 private String preKey;
17 private String periodHashKey; 19 private String periodHashKey;
  1 +package com.yoho.unions.dal.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * Created by qing.zhao on 2018/5/16.
  7 + */
  8 +public class UnionShareSettlementListBO {
  9 + private List<UnionShareSettlement> list;
  10 +
  11 + public List<UnionShareSettlement> getList() {
  12 + return list;
  13 + }
  14 +
  15 + public void setList(List<UnionShareSettlement> list) {
  16 + this.list = list;
  17 + }
  18 +}
@@ -11,6 +11,10 @@ public class UnionShareUser { @@ -11,6 +11,10 @@ public class UnionShareUser {
11 11
12 private String note; 12 private String note;
13 13
  14 + private String url;
  15 +
  16 + private String shareId;
  17 +
14 public Integer getId() { 18 public Integer getId() {
15 return id; 19 return id;
16 } 20 }
@@ -50,4 +54,20 @@ public class UnionShareUser { @@ -50,4 +54,20 @@ public class UnionShareUser {
50 public void setNote(String note) { 54 public void setNote(String note) {
51 this.note = note; 55 this.note = note;
52 } 56 }
  57 +
  58 + public String getUrl() {
  59 + return url;
  60 + }
  61 +
  62 + public void setUrl(String url) {
  63 + this.url = url;
  64 + }
  65 +
  66 + public String getShareId() {
  67 + return shareId;
  68 + }
  69 +
  70 + public void setShareId(String shareId) {
  71 + this.shareId = shareId;
  72 + }
53 } 73 }
@@ -94,10 +94,13 @@ public class UnionShareRest { @@ -94,10 +94,13 @@ public class UnionShareRest {
94 */ 94 */
95 @RequestMapping("/queryOderDetail") 95 @RequestMapping("/queryOderDetail")
96 @ResponseBody 96 @ResponseBody
97 - public UnionResponse queryOderDetail(String orderCode){  
98 - log.info("UnionShareRest :: queryOderDetail orderCode is{}", orderCode); 97 + public UnionResponse queryOderDetail(UnionShareOrderReqBO unionShareOrderReqBO){
  98 + log.info("UnionShareRest :: queryOderDetail unionShareOrderReqBO is{}", unionShareOrderReqBO);
  99 + if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid() || null == unionShareOrderReqBO.getOrderCode()){
  100 + return new UnionResponse(400, "querySettlementRecord uid or orderCode is null");
  101 + }
99 try { 102 try {
100 - ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(orderCode); 103 + ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(unionShareOrderReqBO.getUid(), unionShareOrderReqBO.getOrderCode());
101 return new UnionResponse(200, "queryOderDetail success",shareOrderBo); 104 return new UnionResponse(200, "queryOderDetail success",shareOrderBo);
102 }catch (Exception e){ 105 }catch (Exception e){
103 log.error("UnionShareRest :: queryOderDetail error", e); 106 log.error("UnionShareRest :: queryOderDetail error", e);
@@ -119,8 +122,7 @@ public class UnionShareRest { @@ -119,8 +122,7 @@ public class UnionShareRest {
119 return new UnionResponse(400, "querySettlementRecord params is null"); 122 return new UnionResponse(400, "querySettlementRecord params is null");
120 } 123 }
121 try { 124 try {
122 - List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO.getUid(),  
123 - unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize()); 125 + List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO);
124 return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement); 126 return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement);
125 }catch (Exception e){ 127 }catch (Exception e){
126 log.error("UnionShareRest :: querySettlementRecord error", e); 128 log.error("UnionShareRest :: querySettlementRecord error", e);
@@ -57,14 +57,14 @@ public interface IUnionShareService { @@ -57,14 +57,14 @@ public interface IUnionShareService {
57 * @param orderCode 57 * @param orderCode
58 * @return 58 * @return
59 */ 59 */
60 - ShareOrderBo queryOrderDetail(String orderCode); 60 + ShareOrderBo queryOrderDetail(Integer uid, String orderCode);
61 61
62 /** 62 /**
63 * 提现记录列表 63 * 提现记录列表
64 - * @param uid 64 + * @param unionShareOrderReqBO
65 * @return 65 * @return
66 */ 66 */
67 - List<UnionShareSettlement> querySettlementRecord(int uid, Integer start, Integer size); 67 + List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO);
68 68
69 /** 69 /**
70 * 订单列表 70 * 订单列表
@@ -15,10 +15,7 @@ import com.yoho.unions.dal.UnionShareOrdersMapper; @@ -15,10 +15,7 @@ import com.yoho.unions.dal.UnionShareOrdersMapper;
15 import com.yoho.unions.dal.UnionShareOrdersProductMapper; 15 import com.yoho.unions.dal.UnionShareOrdersProductMapper;
16 import com.yoho.unions.dal.UnionShareSettlementMapper; 16 import com.yoho.unions.dal.UnionShareSettlementMapper;
17 import com.yoho.unions.dal.UnionShareUserMapper; 17 import com.yoho.unions.dal.UnionShareUserMapper;
18 -import com.yoho.unions.dal.model.UnionShareOrders;  
19 -import com.yoho.unions.dal.model.UnionShareOrdersProduct;  
20 -import com.yoho.unions.dal.model.UnionShareSettlement;  
21 -import com.yoho.unions.dal.model.UnionShareUser; 18 +import com.yoho.unions.dal.model.*;
22 import com.yoho.unions.server.service.IUnionShareService; 19 import com.yoho.unions.server.service.IUnionShareService;
23 import org.apache.commons.collections.CollectionUtils; 20 import org.apache.commons.collections.CollectionUtils;
24 import org.slf4j.Logger; 21 import org.slf4j.Logger;
@@ -67,6 +64,8 @@ public class UnionShareServiceImpl implements IUnionShareService { @@ -67,6 +64,8 @@ public class UnionShareServiceImpl implements IUnionShareService {
67 private String SETTLEMENT_TOPIC = "front.union.shareSettleAdd"; 64 private String SETTLEMENT_TOPIC = "front.union.shareSettleAdd";
68 private String NEW_USER_REBATES_RATIO_KEY = "union.newUserRebatesRatio"; 65 private String NEW_USER_REBATES_RATIO_KEY = "union.newUserRebatesRatio";
69 private String OLD_USER_REBATES_RATIO_KEY = "union.oldUserRebatesRatio"; 66 private String OLD_USER_REBATES_RATIO_KEY = "union.oldUserRebatesRatio";
  67 + private String UNION_SHAREID = "union.shareId";
  68 + private String UNION_URL = "union.url";
70 69
71 /** 70 /**
72 * 获取用户可提现金额、已提现金额、是否可以提现 71 * 获取用户可提现金额、已提现金额、是否可以提现
@@ -111,6 +110,8 @@ public class UnionShareServiceImpl implements IUnionShareService { @@ -111,6 +110,8 @@ public class UnionShareServiceImpl implements IUnionShareService {
111 UnionShareUser unionShareUser = unionShareUserMapper.selectByUid(uid); 110 UnionShareUser unionShareUser = unionShareUserMapper.selectByUid(uid);
112 //设置返回文案 111 //设置返回文案
113 unionShareUser.setNote("邀请新客购买返点"+configReader.getDouble(NEW_USER_REBATES_RATIO_KEY, 0.1)+",老客"+configReader.getDouble(OLD_USER_REBATES_RATIO_KEY, 0.03)); 112 unionShareUser.setNote("邀请新客购买返点"+configReader.getDouble(NEW_USER_REBATES_RATIO_KEY, 0.1)+",老客"+configReader.getDouble(OLD_USER_REBATES_RATIO_KEY, 0.03));
  113 + unionShareUser.setShareId(configReader.getString(UNION_SHAREID, ""));
  114 + unionShareUser.setUrl(configReader.getString(UNION_URL, ""));
114 //设置缓存 115 //设置缓存
115 addToRedis(ShareOrdersKeyEnum.UNION_TYPE,uid,unionShareUser,key); 116 addToRedis(ShareOrdersKeyEnum.UNION_TYPE,uid,unionShareUser,key);
116 return unionShareUser; 117 return unionShareUser;
@@ -123,12 +124,30 @@ public class UnionShareServiceImpl implements IUnionShareService { @@ -123,12 +124,30 @@ public class UnionShareServiceImpl implements IUnionShareService {
123 */ 124 */
124 @Override 125 @Override
125 public UnionShareOrders queryRecentlyOrderLimitTen(int uid) { 126 public UnionShareOrders queryRecentlyOrderLimitTen(int uid) {
  127 + //先从缓存获取
  128 + String key = "recentlyOrderLimitTen";
  129 + UnionShareOrders cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrders.class, key);
  130 + if (cacheResult != null) {
  131 + logger.info("UnionShareServiceImpl :: queryRecentlyOrderLimitTen get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
  132 + return cacheResult;
  133 + }
  134 + //获取数据库
126 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid); 135 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid);
  136 + //设置缓存
  137 + addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrders,key);
127 return unionShareOrders; 138 return unionShareOrders;
128 } 139 }
129 140
130 @Override 141 @Override
131 - public ShareOrderBo queryOrderDetail(String orderCode) { 142 + public ShareOrderBo queryOrderDetail(Integer uid, String orderCode) {
  143 + //先从缓存获取
  144 + String key = "orderDetail";
  145 + ShareOrderBo cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_INFO, uid, ShareOrderBo.class, key, orderCode);
  146 + if (cacheResult != null) {
  147 + logger.info("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
  148 + return cacheResult;
  149 + }
  150 + //数据库获取数据
132 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByCode(orderCode); 151 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByCode(orderCode);
133 if (null == unionShareOrders){ 152 if (null == unionShareOrders){
134 return null; 153 return null;
@@ -139,12 +158,27 @@ public class UnionShareServiceImpl implements IUnionShareService { @@ -139,12 +158,27 @@ public class UnionShareServiceImpl implements IUnionShareService {
139 shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class); 158 shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class);
140 shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString()); 159 shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString());
141 shareOrderBo.setProductList(shareOrdersProductBoList); 160 shareOrderBo.setProductList(shareOrdersProductBoList);
  161 + //设置缓存
  162 + addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,unionShareOrders,key, orderCode);
142 return shareOrderBo; 163 return shareOrderBo;
143 } 164 }
144 165
145 @Override 166 @Override
146 - public List<UnionShareSettlement> querySettlementRecord(int uid, Integer start, Integer size) {  
147 - List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(uid, start, size); 167 + public List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) {
  168 + //先从缓存获取
  169 + String key = "orderDetail";
  170 + UnionShareSettlementListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST, unionShareOrderReqBO.getUid(),
  171 + UnionShareSettlementListBO.class, key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
  172 + if (cacheResult != null) {
  173 + logger.info("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
  174 + return cacheResult.getList();
  175 + }
  176 + List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
  177 + unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
  178 + //设置缓存
  179 + UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO();
  180 + unionShareSettlementListBO.setList(unionShareSettlement);
  181 + addToRedis(ShareOrdersKeyEnum.ORDER_INFO,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
148 return unionShareSettlement; 182 return unionShareSettlement;
149 } 183 }
150 184
1 union.newUserRebatesRatio=0.1 1 union.newUserRebatesRatio=0.1
2 -union.oldUserRebatesRatio=0.03  
  2 +union.oldUserRebatesRatio=0.03
  3 +union.shareId = 1
  4 +union.url = /2017/10/17/17/01118b6fa2ca8ba27423aaf6883833e8b9.jpg