|
|
|
@ -10,6 +10,8 @@ import cn.hutool.jwt.JWTUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreUserService;
|
|
|
|
@ -37,10 +39,13 @@ import javax.validation.constraints.NotBlank;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
@ -73,8 +78,6 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
private ResourcesApplicationCourseService resourcesApplicationCourseService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private CourseInfoService courseInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UniversitiesCollegesDao universitiesCollegesDao;
|
|
|
|
|
|
|
|
|
@ -95,7 +98,8 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
private StudentAccountEquityInvestmentSystemService studentAccountEquityInvestmentSystemService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountMockTradingSystemService studentAccountMockTradingSystemService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountForeignExchangeInvestmentSystemService studentAccountForeignExchangeInvestmentSystemService;
|
|
|
|
|
private final static String URL = "jdbc:sqlserver://120.79.161.177:1433;databaseName=Test.Zhiyun_v2.0;trustServerCertificate=true;encrypt=true";
|
|
|
|
|
|
|
|
|
|
public PageQuery<StudentAccountAssetAllocation> queryByCondition(PageQuery query) {
|
|
|
|
@ -103,6 +107,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final static String USER = "sa";
|
|
|
|
|
|
|
|
|
|
public void deleteByList(List list) {
|
|
|
|
@ -296,6 +301,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final static String PASSWORD = "sztzjy@2017";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -384,15 +390,15 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(state, 2)) {
|
|
|
|
|
|
|
|
|
|
if(accountAssetAllocation!=null){
|
|
|
|
|
accountAssetAllocation.setInitialCapital(accountAssetAllocation.getInitialCapital()==null?new BigDecimal(0):accountAssetAllocation.getInitialCapital());
|
|
|
|
|
accountAssetAllocation.setAvailableFunds(accountAssetAllocation.getAvailableFunds()==null?new BigDecimal(0):accountAssetAllocation.getAvailableFunds());
|
|
|
|
|
accountAssetAllocation.setInitialInvestmentCapital(accountAssetAllocation.getInitialInvestmentCapital()==null?new BigDecimal(0):accountAssetAllocation.getInitialInvestmentCapital());
|
|
|
|
|
accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital());
|
|
|
|
|
accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds());
|
|
|
|
|
accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital());
|
|
|
|
|
accountAssetAllocation.setUpdateTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
if (accountAssetAllocation != null) {
|
|
|
|
|
accountAssetAllocation.setInitialCapital(accountAssetAllocation.getInitialCapital() == null ? new BigDecimal(0) : accountAssetAllocation.getInitialCapital());
|
|
|
|
|
accountAssetAllocation.setAvailableFunds(accountAssetAllocation.getAvailableFunds() == null ? new BigDecimal(0) : accountAssetAllocation.getAvailableFunds());
|
|
|
|
|
accountAssetAllocation.setInitialInvestmentCapital(accountAssetAllocation.getInitialInvestmentCapital() == null ? new BigDecimal(0) : accountAssetAllocation.getInitialInvestmentCapital());
|
|
|
|
|
accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital());
|
|
|
|
|
accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds());
|
|
|
|
|
accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital());
|
|
|
|
|
accountAssetAllocation.setUpdateTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -1L) &&
|
|
|
|
@ -426,6 +432,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CoreUserService coreUserService;
|
|
|
|
|
|
|
|
|
@ -533,14 +540,13 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText())) {
|
|
|
|
|
allocation.setState(2);
|
|
|
|
|
allocation.setApplicationId(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText()) ? -2L : -1L);
|
|
|
|
|
|
|
|
|
|
allocation.setInitialCapital(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText()) ?
|
|
|
|
|
new BigDecimal(2000000) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setAvailableFunds(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText()) ?
|
|
|
|
|
new BigDecimal(2000000) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setInitialInvestmentCapital(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText()) ?
|
|
|
|
|
new BigDecimal(2000000) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setApplicationId(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText()) ? -1L : -2L);
|
|
|
|
|
allocation.setInitialCapital(
|
|
|
|
|
new BigDecimal(2000000));
|
|
|
|
|
allocation.setAvailableFunds(
|
|
|
|
|
new BigDecimal(2000000));
|
|
|
|
|
allocation.setInitialInvestmentCapital(
|
|
|
|
|
new BigDecimal(2000000));
|
|
|
|
|
} else {
|
|
|
|
|
if (ObjectUtil.isNotNull(query.getApplicationSecondLevelRelation())) {
|
|
|
|
|
List<ResourcesApplication> applications = resourcesApplicationDao.getValuesByQuery(query);
|
|
|
|
@ -579,14 +585,14 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
} else if (values[i].getText().equals(AccountTypeEnum.INSURANCE_ACCOUNT.getText())) {
|
|
|
|
|
money = 2000000D;
|
|
|
|
|
}
|
|
|
|
|
allocation.setInitialCapital(CollectionUtil.isNotEmpty(experimentalSystems) ?
|
|
|
|
|
new BigDecimal(money) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setAvailableFunds(CollectionUtil.isNotEmpty(experimentalSystems) ?
|
|
|
|
|
new BigDecimal(money) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setInitialInvestmentCapital(CollectionUtil.isNotEmpty(experimentalSystems) ?
|
|
|
|
|
new BigDecimal(money) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setTotalAssetsOfSubAccounts(CollectionUtil.isNotEmpty(experimentalSystems) ?
|
|
|
|
|
new BigDecimal(money) : BigDecimal.ZERO);
|
|
|
|
|
allocation.setInitialCapital(
|
|
|
|
|
new BigDecimal(money));
|
|
|
|
|
allocation.setAvailableFunds(
|
|
|
|
|
new BigDecimal(money));
|
|
|
|
|
allocation.setInitialInvestmentCapital(
|
|
|
|
|
new BigDecimal(money));
|
|
|
|
|
allocation.setTotalAssetsOfSubAccounts(
|
|
|
|
|
new BigDecimal(money));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -676,6 +682,44 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
investmentSystem.setUserId(allocation.getUserId());
|
|
|
|
|
studentAccountEquityInvestmentSystemService.add(investmentSystem);
|
|
|
|
|
createBaseAccount(investmentSystem.getApplicationId(), oldUserId, 2000000D);
|
|
|
|
|
} else if (allocation.getApplicationId() == 113 && j == 1) {
|
|
|
|
|
Map<String, Object> students = getMapByStudentIdForForeign(studentId);
|
|
|
|
|
String className = students.get("classname").toString();
|
|
|
|
|
String name = students.get("studentname").toString();
|
|
|
|
|
Long classId = Long.valueOf(students.get("classid").toString());
|
|
|
|
|
String majorName = students.get("majorname").toString();
|
|
|
|
|
String studentNumber = students.get("studentno").toString();
|
|
|
|
|
Double initialCapital = 2000000D;
|
|
|
|
|
|
|
|
|
|
// 构建参数字符串
|
|
|
|
|
String postData = "name=" + name +
|
|
|
|
|
"&className=" + className +
|
|
|
|
|
"&classId=" + classId +
|
|
|
|
|
"&majorName=" + majorName +
|
|
|
|
|
"&studentNumber=" + studentNumber +
|
|
|
|
|
"&initialCapital=" + initialCapital;
|
|
|
|
|
String result = sendPostRequest("http://120.79.54.255:8801/account/checkOrCreateForexSimulationUser", postData);
|
|
|
|
|
// 使用 Gson 将 JSON 字符串解析为一个 Map 对象
|
|
|
|
|
Type type = new TypeToken<Map<String, Object>>() {
|
|
|
|
|
}.getType();
|
|
|
|
|
Map<String, Object> jsonMap = new Gson().fromJson(result, type);
|
|
|
|
|
|
|
|
|
|
StudentAccountForeignExchangeInvestmentSystem system = new StudentAccountForeignExchangeInvestmentSystem();
|
|
|
|
|
system.setStudentId(studentId);
|
|
|
|
|
system.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
|
|
|
system.setState(2L);
|
|
|
|
|
system.setApplicationId(113L);
|
|
|
|
|
system.setAccountName("外汇模拟交易账户");
|
|
|
|
|
system.setInitialCapital(new BigDecimal(initialCapital));
|
|
|
|
|
system.setTotalAssets(jsonMap.get("totalAssets") == null ? BigDecimal.ZERO : new BigDecimal(jsonMap.get("totalAssets").toString()));
|
|
|
|
|
system.setNetAssetIncome(jsonMap.get("netAssetIncome") == null ? BigDecimal.ZERO : new BigDecimal(jsonMap.get("netAssetIncome").toString()));
|
|
|
|
|
system.setAvailableBalance(new BigDecimal(2000000));
|
|
|
|
|
system.setCumulativeIncome(jsonMap.get("cumulativeProfitLoss") == null ? BigDecimal.ZERO : new BigDecimal(jsonMap.get("cumulativeProfitLoss").toString()));
|
|
|
|
|
system.setTotalAssetIncome(jsonMap.get("yield") == null ? BigDecimal.ZERO : new BigDecimal(jsonMap.get("yield").toString()));
|
|
|
|
|
system.setIsDel(1L);
|
|
|
|
|
system.setCreateTime(new Date());
|
|
|
|
|
system.setIsInstitution(1L);
|
|
|
|
|
studentAccountForeignExchangeInvestmentSystemService.add(system);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -699,10 +743,10 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
"[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, " +
|
|
|
|
|
"0, 0, 0, 0, " + oldUserId + ", " +
|
|
|
|
|
"'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
|
|
|
|
|
String sql1 = "INSERT INTO [dbo].[P2PAccount]([UserId], [Balance], [IsDeleted], [DeleterUserId], " +
|
|
|
|
|
"[DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], " +
|
|
|
|
|
"[CreatorUserId], [TotalInvestmentIncome]) VALUES ("+oldUserId+", "+initialCapital+", '0', NULL, NULL, " +
|
|
|
|
|
"'"+formattedDate+"', NULL, '"+formattedDate+"', "+oldUserId+", 0)";
|
|
|
|
|
String sql1 = "INSERT INTO [dbo].[P2PAccount]([UserId], [Balance], [IsDeleted], [DeleterUserId], " +
|
|
|
|
|
"[DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], " +
|
|
|
|
|
"[CreatorUserId], [TotalInvestmentIncome]) VALUES (" + oldUserId + ", " + initialCapital + ", '0', NULL, NULL, " +
|
|
|
|
|
"'" + formattedDate + "', NULL, '" + formattedDate + "', " + oldUserId + ", 0)";
|
|
|
|
|
runJdbc(sql1);
|
|
|
|
|
} else if (applicationId == 5L) {
|
|
|
|
|
sql = "INSERT INTO [dbo].[ExaTheRaiseAssetAllocation]([ApplicationId], [InitialCapital], [InitialInvestmentCapital], " +
|
|
|
|
@ -715,8 +759,8 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
"NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
|
|
|
|
|
String sql1 = "INSERT INTO [dbo].[CFAccount]([UserId], [TotalInvestmentIncome], [Balance], " +
|
|
|
|
|
"[IsDeleted], [DeleterUserId], [DeletionTime], [LastModificationTime], [LastModifierUserId], " +
|
|
|
|
|
"[CreationTime], [CreatorUserId]) VALUES ( "+oldUserId+", .00, "+initialCapital+", '0', NULL, NULL, '"+formattedDate+"', " +
|
|
|
|
|
"NULL, '"+formattedDate+"', NULL)";
|
|
|
|
|
"[CreationTime], [CreatorUserId]) VALUES ( " + oldUserId + ", .00, " + initialCapital + ", '0', NULL, NULL, '" + formattedDate + "', " +
|
|
|
|
|
"NULL, '" + formattedDate + "', NULL)";
|
|
|
|
|
runJdbc(sql1);
|
|
|
|
|
} else if (applicationId == 16L || applicationId == -16L) {
|
|
|
|
|
Integer secType;
|
|
|
|
@ -858,9 +902,9 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
allocation.getInitialInvestmentCapital(), allocation.getInitialInvestmentCapital(), studentId);
|
|
|
|
|
String sql = "update ExaPEVCAssetAllocation set FreeMoney =" + allocation.getAvailableFunds()
|
|
|
|
|
+ " where UserId = " + coreUser.getOldId() + "";
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
runJdbc(sql);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1088,5 +1132,14 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
return courseInfoService.getByIds(courseInfoIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询对应用户缺的数据
|
|
|
|
|
public List<StudentAccountAssetAllocation> getByStudentAndApplicationIsNotIn(Long studentId) {
|
|
|
|
|
return studentAccountAssetAllocationDao.getByStudentAndApplicationIsNotIn(studentId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getMapByStudentIdForForeign(Long studentId) {
|
|
|
|
|
return studentAccountAssetAllocationDao.getMapByStudentIdForForeign(studentId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|