Authored by csgyoho

Merge branch 'dev_180508_联盟红人推广' of http://git.yoho.cn/yoho30/yohobuy-union into dev_180508_联盟红人推广

@@ -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 }
@@ -113,10 +113,13 @@ public class UnionShareRest { @@ -113,10 +113,13 @@ public class UnionShareRest {
113 */ 113 */
114 @RequestMapping("/queryOderDetail") 114 @RequestMapping("/queryOderDetail")
115 @ResponseBody 115 @ResponseBody
116 - public UnionResponse queryOderDetail(String orderCode){  
117 - log.info("UnionShareRest :: queryOderDetail orderCode is{}", orderCode); 116 + public UnionResponse queryOderDetail(UnionShareOrderReqBO unionShareOrderReqBO){
  117 + log.info("UnionShareRest :: queryOderDetail unionShareOrderReqBO is{}", unionShareOrderReqBO);
  118 + if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid() || null == unionShareOrderReqBO.getOrderCode()){
  119 + return new UnionResponse(400, "querySettlementRecord uid or orderCode is null");
  120 + }
118 try { 121 try {
119 - ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(orderCode); 122 + ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(unionShareOrderReqBO.getUid(), unionShareOrderReqBO.getOrderCode());
120 return new UnionResponse(200, "queryOderDetail success",shareOrderBo); 123 return new UnionResponse(200, "queryOderDetail success",shareOrderBo);
121 }catch (Exception e){ 124 }catch (Exception e){
122 log.error("UnionShareRest :: queryOderDetail error", e); 125 log.error("UnionShareRest :: queryOderDetail error", e);
@@ -138,8 +141,7 @@ public class UnionShareRest { @@ -138,8 +141,7 @@ public class UnionShareRest {
138 return new UnionResponse(400, "querySettlementRecord params is null"); 141 return new UnionResponse(400, "querySettlementRecord params is null");
139 } 142 }
140 try { 143 try {
141 - List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO.getUid(),  
142 - unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize()); 144 + List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO);
143 return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement); 145 return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement);
144 }catch (Exception e){ 146 }catch (Exception e){
145 log.error("UnionShareRest :: querySettlementRecord error", e); 147 log.error("UnionShareRest :: querySettlementRecord error", e);
@@ -59,14 +59,14 @@ public interface IUnionShareService { @@ -59,14 +59,14 @@ public interface IUnionShareService {
59 * @param orderCode 59 * @param orderCode
60 * @return 60 * @return
61 */ 61 */
62 - ShareOrderBo queryOrderDetail(String orderCode); 62 + ShareOrderBo queryOrderDetail(Integer uid, String orderCode);
63 63
64 /** 64 /**
65 * 提现记录列表 65 * 提现记录列表
66 - * @param uid 66 + * @param unionShareOrderReqBO
67 * @return 67 * @return
68 */ 68 */
69 - List<UnionShareSettlement> querySettlementRecord(int uid, Integer start, Integer size); 69 + List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO);
70 70
71 /** 71 /**
72 * 订单列表 72 * 订单列表
@@ -74,6 +74,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -74,6 +74,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
74 private String SETTLEMENT_TOPIC = "front.union.shareSettleAdd"; 74 private String SETTLEMENT_TOPIC = "front.union.shareSettleAdd";
75 private String NEW_USER_REBATES_RATIO_KEY = "union.newUserRebatesRatio"; 75 private String NEW_USER_REBATES_RATIO_KEY = "union.newUserRebatesRatio";
76 private String OLD_USER_REBATES_RATIO_KEY = "union.oldUserRebatesRatio"; 76 private String OLD_USER_REBATES_RATIO_KEY = "union.oldUserRebatesRatio";
  77 + private String UNION_SHAREID = "union.shareId";
  78 + private String UNION_URL = "union.url";
77 79
78 /** 80 /**
79 * 获取用户可提现金额、已提现金额、是否可以提现 81 * 获取用户可提现金额、已提现金额、是否可以提现
@@ -229,7 +231,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -229,7 +231,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
229 //获取数据库 231 //获取数据库
230 UnionShareUser unionShareUser = unionShareUserMapper.selectByUid(uid); 232 UnionShareUser unionShareUser = unionShareUserMapper.selectByUid(uid);
231 //设置返回文案 233 //设置返回文案
232 - unionShareUser.setNote("邀请新客购买返点" + configReader.getDouble(NEW_USER_REBATES_RATIO_KEY, 0.1) + ",老客" + configReader.getDouble(OLD_USER_REBATES_RATIO_KEY, 0.03)); 234 + unionShareUser.setNote("邀请新客购买返点"+configReader.getDouble(NEW_USER_REBATES_RATIO_KEY, 0.1)+",老客"+configReader.getDouble(OLD_USER_REBATES_RATIO_KEY, 0.03));
  235 + unionShareUser.setShareId(configReader.getString(UNION_SHAREID, ""));
  236 + unionShareUser.setUrl(configReader.getString(UNION_URL, ""));
233 //设置缓存 237 //设置缓存
234 addToRedis(ShareOrdersKeyEnum.UNION_TYPE, uid, unionShareUser, key); 238 addToRedis(ShareOrdersKeyEnum.UNION_TYPE, uid, unionShareUser, key);
235 return unionShareUser; 239 return unionShareUser;
@@ -242,12 +246,30 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -242,12 +246,30 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
242 */ 246 */
243 @Override 247 @Override
244 public UnionShareOrders queryRecentlyOrderLimitTen(int uid) { 248 public UnionShareOrders queryRecentlyOrderLimitTen(int uid) {
  249 + //先从缓存获取
  250 + String key = "recentlyOrderLimitTen";
  251 + UnionShareOrders cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrders.class, key);
  252 + if (cacheResult != null) {
  253 + logger.info("UnionShareServiceImpl :: queryRecentlyOrderLimitTen get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
  254 + return cacheResult;
  255 + }
  256 + //获取数据库
245 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid); 257 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid);
  258 + //设置缓存
  259 + addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrders,key);
246 return unionShareOrders; 260 return unionShareOrders;
247 } 261 }
248 262
249 @Override 263 @Override
250 - public ShareOrderBo queryOrderDetail(String orderCode) { 264 + public ShareOrderBo queryOrderDetail(Integer uid, String orderCode) {
  265 + //先从缓存获取
  266 + String key = "orderDetail";
  267 + ShareOrderBo cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_INFO, uid, ShareOrderBo.class, key, orderCode);
  268 + if (cacheResult != null) {
  269 + logger.info("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
  270 + return cacheResult;
  271 + }
  272 + //数据库获取数据
251 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByCode(orderCode); 273 UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByCode(orderCode);
252 if (null == unionShareOrders){ 274 if (null == unionShareOrders){
253 return null; 275 return null;
@@ -258,12 +280,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -258,12 +280,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
258 shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class); 280 shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class);
259 shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString()); 281 shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString());
260 shareOrderBo.setProductList(shareOrdersProductBoList); 282 shareOrderBo.setProductList(shareOrdersProductBoList);
  283 + //设置缓存
  284 + addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,unionShareOrders,key, orderCode);
261 return shareOrderBo; 285 return shareOrderBo;
262 } 286 }
263 287
264 @Override 288 @Override
265 - public List<UnionShareSettlement> querySettlementRecord(int uid, Integer start, Integer size) {  
266 - List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(uid, start, size); 289 + public List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) {
  290 + //先从缓存获取
  291 + String key = "orderDetail";
  292 + UnionShareSettlementListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST, unionShareOrderReqBO.getUid(),
  293 + UnionShareSettlementListBO.class, key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
  294 + if (cacheResult != null) {
  295 + logger.info("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
  296 + return cacheResult.getList();
  297 + }
  298 + List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
  299 + unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
  300 + //设置缓存
  301 + UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO();
  302 + unionShareSettlementListBO.setList(unionShareSettlement);
  303 + addToRedis(ShareOrdersKeyEnum.ORDER_INFO,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
267 return unionShareSettlement; 304 return unionShareSettlement;
268 } 305 }
269 306
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