generated from root/miduo_server
自在修仙0.1,返利
parent
66e48a1f92
commit
4b935f2106
|
@ -102,16 +102,17 @@ public class ItemSendController {
|
|||
LOGGER.info("免费返利,直接返回");
|
||||
return true;
|
||||
}
|
||||
|
||||
String roleid = params.get("roleid");
|
||||
String nonce = params.get("nonce");
|
||||
String orderId = params.get("sendid");
|
||||
CPayOrder cPayOrder = cuserDao.getCpayOrderByOrderId(orderId);
|
||||
|
||||
CPayOrder cPayOrder = RedisUtil.getInstence().getMapValue(RedisUserKey.REBATES_ORDER, roleid, orderId, CPayOrder.class);
|
||||
if (cPayOrder != null) {
|
||||
LOGGER.error("订单已存在,订单ID:{}", orderId);
|
||||
return false;
|
||||
}
|
||||
|
||||
String roleid = params.get("roleid");
|
||||
String nonce = params.get("nonce");
|
||||
|
||||
CPayOrder payOrder = new CPayOrder();
|
||||
payOrder.setOrderId(orderId);
|
||||
payOrder.setUserId(roleid);
|
||||
|
@ -123,7 +124,7 @@ public class ItemSendController {
|
|||
payOrder.setCc_id("0");
|
||||
payOrder.setPlatform("0");
|
||||
|
||||
RedisUtil.getInstence().putMapEntry(RedisUserKey.REBATES_ORDER, roleid, orderId, payOrder, 0);
|
||||
RedisUtil.getInstence().putMapValue(RedisUserKey.REBATES_ORDER, roleid, orderId, payOrder);
|
||||
// cuserDao.addCpayOrder(payOrder);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.jmfy.util;
|
|||
import com.google.gson.Gson;
|
||||
import com.jmfy.redisProperties.RedisProperties;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.server.ServerProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
|
@ -290,6 +289,8 @@ public class RedisUtil {
|
|||
delObject(type, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除Map中某hashKey值
|
||||
*
|
||||
|
@ -325,16 +326,13 @@ public class RedisUtil {
|
|||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getMap(String key, Class<T> clazz,int expireTime) {
|
||||
public <T> Map<String, T> getMap(String type, String key, Class<T> clazz) {
|
||||
try {
|
||||
Map<String, T> reslut = new HashMap<>();
|
||||
Map<Object, Object> map = redisObjectTemplate.opsForHash().entries(key);
|
||||
Map<Object, Object> map = redisObjectTemplate.opsForHash().entries(type+ ":" +key);
|
||||
for (Map.Entry<Object, Object> entry : map.entrySet()) {
|
||||
reslut.put((String) entry.getKey(), gson.fromJson((String) entry.getValue(), clazz));
|
||||
}
|
||||
if(expireTime > 0){
|
||||
redisObjectTemplate.expire(key, expireTime, TimeUnit.SECONDS);
|
||||
}
|
||||
return reslut;
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
LOGGER.error("------------------Redis 连接失败------------------");
|
||||
|
@ -349,15 +347,12 @@ public class RedisUtil {
|
|||
* @param mapKey
|
||||
* @return
|
||||
*/
|
||||
public <T> T getMapValue(String type, String key, String mapKey, Class<T> clazz, int expireTime) {
|
||||
public <T> T getMapValue(String type, String key, String mapKey, Class<T> clazz) {
|
||||
try {
|
||||
String valueStr = (String) redisObjectTemplate.opsForHash().get(type+key, mapKey);
|
||||
String valueStr = (String) redisObjectTemplate.opsForHash().get(type+ ":" +key, mapKey);
|
||||
if (valueStr == null) {
|
||||
return null;
|
||||
}
|
||||
// if(expireTime > 0){
|
||||
// redisObjectTemplate.expire(getKey(type, key), expireTime, TimeUnit.SECONDS);
|
||||
// }
|
||||
return gson.fromJson(valueStr, clazz);
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -372,21 +367,28 @@ public class RedisUtil {
|
|||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public <T> void putMap(String type, String key, Map<String, T> value, int expireTime) {
|
||||
public <T> void putMap(String type, String key, Map<String, T> value) {
|
||||
try {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (Map.Entry<String, T> entry : value.entrySet()) {
|
||||
String valueStr = gson.toJson(entry.getValue());
|
||||
map.put(entry.getKey(), valueStr);
|
||||
}
|
||||
redisObjectTemplate.opsForHash().putAll(type+key, map);
|
||||
// if (expireTime > 0) {
|
||||
// redisObjectTemplate.expire(getKey(type, key), expireTime, TimeUnit.SECONDS);
|
||||
// }
|
||||
redisObjectTemplate.opsForHash().putAll(type+ ":" +key, map);
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("------------------Redis 连接失败------------------");
|
||||
delObject(type, key);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void putMapValue(String type, String key, String mapKey, T value) {
|
||||
try {
|
||||
String valueStr = gson.toJson(value);
|
||||
redisObjectTemplate.opsForHash().put(type + ":" + key, mapKey, valueStr);
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
LOGGER.error("------------------Redis 连接失败------------------");
|
||||
delObject(type, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue