充值和数据转换
parent
38c3cffa54
commit
000b4466b3
|
@ -16,6 +16,9 @@ import com.mongodb.MongoClient;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||
import util.MathUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -299,7 +302,10 @@ public class MongoUtil {
|
|||
MongoTemplate mongoTemplate = mongoTemplateMap.get(serverId);
|
||||
if(mongoTemplate == null){
|
||||
String dbName = "jieling_"+serverId;
|
||||
mongoTemplate = new MongoTemplate(mongoClient, dbName);
|
||||
// new MongoTemplate(this.mongoDbFactory(), this.mappingMongoConverter1())
|
||||
MappingMongoConverter mappingMongoConverter = (MappingMongoConverter) ConfigurableApplicationContextManager.getBean("mappingMongoConverter1");
|
||||
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongoClient, dbName);
|
||||
mongoTemplate = new MongoTemplate(mongoDbFactory, mappingMongoConverter);
|
||||
mongoTemplateMap.put(serverId,mongoTemplate);
|
||||
List<GuildInfo> all = mongoTemplate.findAll(GuildInfo.class, GuildInfo._COLLECTION_NAME);
|
||||
for (GuildInfo guildInfo:all) {
|
||||
|
|
|
@ -366,11 +366,11 @@ public class RedisKey {
|
|||
}
|
||||
}
|
||||
|
||||
if (withoutServerId) {
|
||||
// if (rankCacChe.contains(type)||withoutServerId) {
|
||||
return AreaManager.areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
} else {
|
||||
return GameApplication.serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
}
|
||||
// } else {
|
||||
// return GameApplication.serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -112,8 +112,8 @@ public class BuyGoodsLogic {
|
|||
buyCount = 0;
|
||||
}
|
||||
double priceTemp =sRechargeCommodityConfig.getPrice();
|
||||
SExchangeRate sExchangeRate = STableManager.getConfig(SExchangeRate.class).get((int)priceTemp);
|
||||
double price = sExchangeRate.getPrice_2();
|
||||
int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
|
||||
double price = SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
|
||||
buyCount=buyCount+1;
|
||||
|
||||
//time check
|
||||
|
|
|
@ -3,63 +3,103 @@ package config;
|
|||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ExchangeRate")
|
||||
@Table(name = "ExchangeRate")
|
||||
public class SExchangeRate implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
private int id;
|
||||
|
||||
private int price_1;
|
||||
private int price_1;
|
||||
|
||||
private float price_2;
|
||||
private float price_2;
|
||||
|
||||
private float price_3;
|
||||
private float price_3;
|
||||
|
||||
private float price_4;
|
||||
private float price_4;
|
||||
|
||||
private float price_5;
|
||||
private float price_5;
|
||||
|
||||
private float price_6;
|
||||
private float price_6;
|
||||
|
||||
private float price_7;
|
||||
private float price_7;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public static HashMap<Integer, HashMap<Integer, Double>> doubleIntegerHashMap = new HashMap<>(); //币种 原货币 本货币
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
doubleIntegerHashMap = new HashMap<>();
|
||||
Map<Integer, SExchangeRate> config = STableManager.getConfig(SExchangeRate.class);
|
||||
|
||||
Field[] fields = SExchangeRate.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
String temp = "price_";
|
||||
if(!field.getName().contains(temp)){
|
||||
continue;
|
||||
}
|
||||
String substring = field.getName().substring(temp.length());
|
||||
|
||||
Integer integer = Integer.valueOf(substring);
|
||||
doubleIntegerHashMap.putIfAbsent(integer,new HashMap<>());
|
||||
|
||||
HashMap<Integer, Double> doubleIntegerHashMap = SExchangeRate.doubleIntegerHashMap.get(integer);
|
||||
|
||||
config.entrySet().forEach(integerSExchangeRateEntry -> {
|
||||
try {
|
||||
if(integer==1){
|
||||
doubleIntegerHashMap.put(integerSExchangeRateEntry.getValue().getPrice_1(), Double.valueOf((int)field.get(integerSExchangeRateEntry.getValue())));
|
||||
}else {
|
||||
doubleIntegerHashMap.put(integerSExchangeRateEntry.getValue().getPrice_1(),Double.valueOf((float) field.get(integerSExchangeRateEntry.getValue())));
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getPrice_1() {
|
||||
public int getPrice_1() {
|
||||
return price_1;
|
||||
}
|
||||
|
||||
public float getPrice_2() {
|
||||
public float getPrice_2() {
|
||||
return price_2;
|
||||
}
|
||||
|
||||
public float getPrice_3() {
|
||||
public float getPrice_3() {
|
||||
return price_3;
|
||||
}
|
||||
|
||||
public float getPrice_4() {
|
||||
public float getPrice_4() {
|
||||
return price_4;
|
||||
}
|
||||
|
||||
public float getPrice_5() {
|
||||
public float getPrice_5() {
|
||||
return price_5;
|
||||
}
|
||||
|
||||
public float getPrice_6() {
|
||||
public float getPrice_6() {
|
||||
return price_6;
|
||||
}
|
||||
|
||||
public float getPrice_7() {
|
||||
public float getPrice_7() {
|
||||
return price_7;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ public class SSpecialConfig implements BaseConfig {
|
|||
public static final String REPLACE_COST = "replace_cost";//置换玉消耗
|
||||
|
||||
public static final String XUANYUAN_OPEN_TIME = "xuanyuan_open_time";//轩辕开始时间(星期)
|
||||
public static final String EXCHANGE_FORCE_TYPE = "exchange_focus_type";//货币转换类型
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue