|
@@ -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
|
|