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;
public enum ShareOrdersKeyEnum {
ORDER_LIST("unions:share:orderList:","type:{}:status:{}:page:{}:limit:{}",3600,"订单列表"),
ORDER_INFO("unions:share:orderInfo:","orderCode:{}",3600,"订单详情"),
ORDER_INFO("unions:share:orderInfo:","key:{}:orderCode:{}",3600,"订单详情"),
USER_SETTLEMENT("unions:share:userSettlement:","type:{}",3600,"用户提现未提现总计"),
SETTLEMENT_LIST("unions:share:settlementList:","page:{}:limit:{}",3600,"提现列表"),
UNION_TYPE("unions:share:unionType:","",3600,"用户登录时获取对应的渠道号");
UNION_TYPE("unions:share:unionType:","key:{}",3600,"用户登录时获取对应的渠道号"),
RECENTLY_ORDER_LIMIT_TEN("unions:share:recentlyOrderLimitTen:","key:{}",3600,"用户前台获取个人推广近期订单(10个)");
private String preKey;
private String periodHashKey;
... ...
package com.yoho.unions.dal.model;
import java.util.List;
/**
* Created by qing.zhao on 2018/5/16.
*/
public class UnionShareSettlementListBO {
private List<UnionShareSettlement> list;
public List<UnionShareSettlement> getList() {
return list;
}
public void setList(List<UnionShareSettlement> list) {
this.list = list;
}
}
... ...
... ... @@ -11,6 +11,10 @@ public class UnionShareUser {
private String note;
private String url;
private String shareId;
public Integer getId() {
return id;
}
... ... @@ -50,4 +54,20 @@ public class UnionShareUser {
public void setNote(String note) {
this.note = note;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getShareId() {
return shareId;
}
public void setShareId(String shareId) {
this.shareId = shareId;
}
}
\ No newline at end of file
... ...
... ... @@ -113,10 +113,13 @@ public class UnionShareRest {
*/
@RequestMapping("/queryOderDetail")
@ResponseBody
public UnionResponse queryOderDetail(String orderCode){
log.info("UnionShareRest :: queryOderDetail orderCode is{}", orderCode);
public UnionResponse queryOderDetail(UnionShareOrderReqBO unionShareOrderReqBO){
log.info("UnionShareRest :: queryOderDetail unionShareOrderReqBO is{}", unionShareOrderReqBO);
if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid() || null == unionShareOrderReqBO.getOrderCode()){
return new UnionResponse(400, "querySettlementRecord uid or orderCode is null");
}
try {
ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(orderCode);
ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(unionShareOrderReqBO.getUid(), unionShareOrderReqBO.getOrderCode());
return new UnionResponse(200, "queryOderDetail success",shareOrderBo);
}catch (Exception e){
log.error("UnionShareRest :: queryOderDetail error", e);
... ... @@ -138,8 +141,7 @@ public class UnionShareRest {
return new UnionResponse(400, "querySettlementRecord params is null");
}
try {
List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO.getUid(),
unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO);
return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement);
}catch (Exception e){
log.error("UnionShareRest :: querySettlementRecord error", e);
... ...
... ... @@ -59,14 +59,14 @@ public interface IUnionShareService {
* @param orderCode
* @return
*/
ShareOrderBo queryOrderDetail(String orderCode);
ShareOrderBo queryOrderDetail(Integer uid, String orderCode);
/**
* 提现记录列表
* @param uid
* @param unionShareOrderReqBO
* @return
*/
List<UnionShareSettlement> querySettlementRecord(int uid, Integer start, Integer size);
List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO);
/**
* 订单列表
... ...
... ... @@ -74,6 +74,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private String SETTLEMENT_TOPIC = "front.union.shareSettleAdd";
private String NEW_USER_REBATES_RATIO_KEY = "union.newUserRebatesRatio";
private String OLD_USER_REBATES_RATIO_KEY = "union.oldUserRebatesRatio";
private String UNION_SHAREID = "union.shareId";
private String UNION_URL = "union.url";
/**
* 获取用户可提现金额、已提现金额、是否可以提现
... ... @@ -229,7 +231,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
//获取数据库
UnionShareUser unionShareUser = unionShareUserMapper.selectByUid(uid);
//设置返回文案
unionShareUser.setNote("邀请新客购买返点" + configReader.getDouble(NEW_USER_REBATES_RATIO_KEY, 0.1) + ",老客" + configReader.getDouble(OLD_USER_REBATES_RATIO_KEY, 0.03));
unionShareUser.setNote("邀请新客购买返点"+configReader.getDouble(NEW_USER_REBATES_RATIO_KEY, 0.1)+",老客"+configReader.getDouble(OLD_USER_REBATES_RATIO_KEY, 0.03));
unionShareUser.setShareId(configReader.getString(UNION_SHAREID, ""));
unionShareUser.setUrl(configReader.getString(UNION_URL, ""));
//设置缓存
addToRedis(ShareOrdersKeyEnum.UNION_TYPE, uid, unionShareUser, key);
return unionShareUser;
... ... @@ -242,12 +246,30 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
*/
@Override
public UnionShareOrders queryRecentlyOrderLimitTen(int uid) {
//先从缓存获取
String key = "recentlyOrderLimitTen";
UnionShareOrders cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrders.class, key);
if (cacheResult != null) {
logger.info("UnionShareServiceImpl :: queryRecentlyOrderLimitTen get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
return cacheResult;
}
//获取数据库
UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid);
//设置缓存
addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrders,key);
return unionShareOrders;
}
@Override
public ShareOrderBo queryOrderDetail(String orderCode) {
public ShareOrderBo queryOrderDetail(Integer uid, String orderCode) {
//先从缓存获取
String key = "orderDetail";
ShareOrderBo cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_INFO, uid, ShareOrderBo.class, key, orderCode);
if (cacheResult != null) {
logger.info("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
return cacheResult;
}
//数据库获取数据
UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByCode(orderCode);
if (null == unionShareOrders){
return null;
... ... @@ -258,12 +280,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class);
shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString());
shareOrderBo.setProductList(shareOrdersProductBoList);
//设置缓存
addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,unionShareOrders,key, orderCode);
return shareOrderBo;
}
@Override
public List<UnionShareSettlement> querySettlementRecord(int uid, Integer start, Integer size) {
List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(uid, start, size);
public List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) {
//先从缓存获取
String key = "orderDetail";
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);
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()));
return unionShareSettlement;
}
... ...
union.newUserRebatesRatio=0.1
union.oldUserRebatesRatio=0.03
union.shareId = 1
union.url = /2017/10/17/17/01118b6fa2ca8ba27423aaf6883833e8b9.jpg
\ No newline at end of file
... ...