...
|
...
|
@@ -15,10 +15,7 @@ import com.yoho.unions.dal.UnionShareOrdersMapper; |
|
|
import com.yoho.unions.dal.UnionShareOrdersProductMapper;
|
|
|
import com.yoho.unions.dal.UnionShareSettlementMapper;
|
|
|
import com.yoho.unions.dal.UnionShareUserMapper;
|
|
|
import com.yoho.unions.dal.model.UnionShareOrders;
|
|
|
import com.yoho.unions.dal.model.UnionShareOrdersProduct;
|
|
|
import com.yoho.unions.dal.model.UnionShareSettlement;
|
|
|
import com.yoho.unions.dal.model.UnionShareUser;
|
|
|
import com.yoho.unions.dal.model.*;
|
|
|
import com.yoho.unions.server.service.IUnionShareService;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -67,6 +64,8 @@ public class UnionShareServiceImpl implements IUnionShareService { |
|
|
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";
|
|
|
|
|
|
/**
|
|
|
* 获取用户可提现金额、已提现金额、是否可以提现
|
...
|
...
|
@@ -111,6 +110,8 @@ public class UnionShareServiceImpl implements IUnionShareService { |
|
|
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.setShareId(configReader.getString(UNION_SHAREID, ""));
|
|
|
unionShareUser.setUrl(configReader.getString(UNION_URL, ""));
|
|
|
//设置缓存
|
|
|
addToRedis(ShareOrdersKeyEnum.UNION_TYPE,uid,unionShareUser,key);
|
|
|
return unionShareUser;
|
...
|
...
|
@@ -123,12 +124,30 @@ public class UnionShareServiceImpl implements IUnionShareService { |
|
|
*/
|
|
|
@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;
|
...
|
...
|
@@ -139,12 +158,27 @@ public class UnionShareServiceImpl implements IUnionShareService { |
|
|
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;
|
|
|
}
|
|
|
|
...
|
...
|
|