|
|
|
@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreUserService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
@ -25,6 +26,7 @@ import com.ibeetl.jlw.web.query.StudentAccountEquityInvestmentSystemQuery;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -40,6 +42,11 @@ import java.math.RoundingMode;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.collection.IterUtil.getFirst;
|
|
|
|
@ -89,18 +96,14 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountMockTradingSystemService studentAccountMockTradingSystemService;
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<StudentAccountAssetAllocation> queryByConditionQuery(PageQuery query) {
|
|
|
|
|
PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
private final static String USER = "sa";
|
|
|
|
|
|
|
|
|
|
public void deleteByList(List list) {
|
|
|
|
|
String ids = "";
|
|
|
|
@ -293,11 +296,171 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
|
|
|
|
private final static String PASSWORD = "sztzjy@2017";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 应用授权后开通资金账户权限
|
|
|
|
|
*
|
|
|
|
|
* @param orgId
|
|
|
|
|
*/
|
|
|
|
|
public void updateApplicationAuthority(Long orgId) {
|
|
|
|
|
|
|
|
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager()
|
|
|
|
|
.lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class)
|
|
|
|
|
.andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select();
|
|
|
|
|
|
|
|
|
|
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
|
|
|
|
|
allocationQuery.setOrgId(orgId);
|
|
|
|
|
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
|
|
|
|
|
|
|
|
|
|
//获取所以的资金账号
|
|
|
|
|
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
|
|
|
|
|
int state = 1;
|
|
|
|
|
//获取添加院校权限,对账号进行限制
|
|
|
|
|
for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(), item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) {
|
|
|
|
|
//后期添加应用开发权限,新增的时候已经有应用添加了
|
|
|
|
|
state = 2;
|
|
|
|
|
} else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) {
|
|
|
|
|
//新增学生账号,应用还没有添加,后面才添加,授权权限的时候获取应用ID设置
|
|
|
|
|
ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery();
|
|
|
|
|
if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司");
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司");
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("投资银行");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FINANCIAL_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能理财");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())) {
|
|
|
|
|
List<ResourcesApplication> resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(resourcesApplicationList)) {
|
|
|
|
|
if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) {
|
|
|
|
|
accountAssetAllocation.setApplicationId(item.getTypeId());
|
|
|
|
|
state = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
accountAssetAllocation.setState(state);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(state, 2)) {
|
|
|
|
|
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) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -2L) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())) {
|
|
|
|
|
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 激活该校的所有学生用户的股票/期货账户
|
|
|
|
|
*
|
|
|
|
|
* @param orgId
|
|
|
|
|
*/
|
|
|
|
|
public void allOpenAccount(Long orgId) {
|
|
|
|
|
|
|
|
|
|
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
|
|
|
|
|
allocationQuery.setOrgId(orgId);
|
|
|
|
|
allocationQuery.setState(1);
|
|
|
|
|
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
|
|
|
|
|
|
|
|
|
|
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
|
|
|
|
|
accountAssetAllocation.setState(2);
|
|
|
|
|
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());
|
|
|
|
|
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Autowired
|
|
|
|
|
private CoreUserService coreUserService;
|
|
|
|
|
|
|
|
|
|
// 打开数据库连接
|
|
|
|
|
public static Connection openConn() throws SQLException {
|
|
|
|
|
try {
|
|
|
|
|
Connection connection = DriverManager.getConnection(URL, USER, PASSWORD);
|
|
|
|
|
if (connection != null) {
|
|
|
|
|
System.out.println("成功建立数据库连接");
|
|
|
|
|
return connection;
|
|
|
|
|
} else {
|
|
|
|
|
throw new SQLException("无法建立数据库连接");
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new SQLException("无法建立数据库连接: " + e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭数据库连接
|
|
|
|
|
public static void closeConn(Connection connection) {
|
|
|
|
|
if (connection != null) {
|
|
|
|
|
try {
|
|
|
|
|
connection.close();
|
|
|
|
|
System.out.println("数据库连接已关闭");
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
System.err.println("无法关闭数据库连接: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<StudentAccountAssetAllocation> queryByConditionQuery(PageQuery query) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户在创建的时候,紧跟着就要创建资金账户
|
|
|
|
|
*/
|
|
|
|
|
public void createFundAccountWithUserCreated(Long studentId, Long orgId) {
|
|
|
|
|
public void createFundAccountWithUserCreated(Long studentId, Long oldUserId, Long orgId) throws SQLException {
|
|
|
|
|
//开设7个账户,现金账户100万,银行账户0元,其他应用的账户开设,但是未被激活,没有初始资金
|
|
|
|
|
AccountTypeEnum[] values = AccountTypeEnum.values();
|
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesDao.getByOrgId(orgId);
|
|
|
|
@ -429,8 +592,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
allocation.setUpdateVersion(-1L);
|
|
|
|
|
allocation.setIsInstitution(j);
|
|
|
|
|
studentAccountAssetAllocationDao.insert(allocation);
|
|
|
|
|
if (allocation != null&&allocation.getApplicationId()!=null) {
|
|
|
|
|
|
|
|
|
|
if (allocation != null && allocation.getApplicationId() != null) {
|
|
|
|
|
|
|
|
|
|
if (allocation.getApplicationId() == 4 && j == 1) {
|
|
|
|
|
StudentAccountP2pSystem p2pSystem = new StudentAccountP2pSystem();
|
|
|
|
@ -446,6 +608,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
p2pSystem.setIsInstitution(1L);
|
|
|
|
|
p2pSystem.setUserId(allocation.getUserId());
|
|
|
|
|
studentAccountP2pSystemService.add(p2pSystem);
|
|
|
|
|
createBaseAccount(p2pSystem.getApplicationId(), oldUserId, 2000000D);
|
|
|
|
|
} else if (allocation.getApplicationId() == 5 && j == 1) {
|
|
|
|
|
|
|
|
|
|
StudentAccountCrowdfundingSystem crowdfundingSystem = new StudentAccountCrowdfundingSystem();
|
|
|
|
@ -461,6 +624,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
crowdfundingSystem.setIsInstitution(1L);
|
|
|
|
|
crowdfundingSystem.setUserId(allocation.getUserId());
|
|
|
|
|
studentAccountCrowdfundingSystemService.add(crowdfundingSystem);
|
|
|
|
|
createBaseAccount(crowdfundingSystem.getApplicationId(), oldUserId, 2000000D);
|
|
|
|
|
} else if (allocation.getApplicationId() == 16 && j == 1 && !lock) {
|
|
|
|
|
lock = true;
|
|
|
|
|
StudentAccountMockTradingSystem mockTradingSystem = new StudentAccountMockTradingSystem();
|
|
|
|
@ -476,7 +640,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
mockTradingSystem.setIsInstitution(1L);
|
|
|
|
|
mockTradingSystem.setUserId(allocation.getUserId());
|
|
|
|
|
studentAccountMockTradingSystemService.add(mockTradingSystem);
|
|
|
|
|
|
|
|
|
|
createBaseAccount(mockTradingSystem.getApplicationId(), oldUserId, 2000000D);
|
|
|
|
|
StudentAccountMockTradingSystem mockTradingSystem1 = new StudentAccountMockTradingSystem();
|
|
|
|
|
mockTradingSystem1.setStudentId(studentId);
|
|
|
|
|
mockTradingSystem1.setApplicationId(-16L);
|
|
|
|
@ -490,7 +654,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
mockTradingSystem1.setIsInstitution(1L);
|
|
|
|
|
mockTradingSystem1.setUserId(allocation.getUserId());
|
|
|
|
|
studentAccountMockTradingSystemService.add(mockTradingSystem1);
|
|
|
|
|
|
|
|
|
|
createBaseAccount(mockTradingSystem1.getApplicationId(), oldUserId, 2000000D);
|
|
|
|
|
} else if (allocation.getApplicationId() == 18 && j == 1) {
|
|
|
|
|
StudentAccountEquityInvestmentSystem investmentSystem = new StudentAccountEquityInvestmentSystem();
|
|
|
|
|
investmentSystem.setStudentId(studentId);
|
|
|
|
@ -504,6 +668,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
investmentSystem.setIsInstitution(1L);
|
|
|
|
|
investmentSystem.setUserId(allocation.getUserId());
|
|
|
|
|
studentAccountEquityInvestmentSystemService.add(investmentSystem);
|
|
|
|
|
createBaseAccount(investmentSystem.getApplicationId(), oldUserId, 2000000D);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -511,129 +676,64 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 应用授权后开通资金账户权限
|
|
|
|
|
*
|
|
|
|
|
* @param orgId
|
|
|
|
|
*/
|
|
|
|
|
public void updateApplicationAuthority(Long orgId) {
|
|
|
|
|
|
|
|
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager()
|
|
|
|
|
.lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class)
|
|
|
|
|
.andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select();
|
|
|
|
|
|
|
|
|
|
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
|
|
|
|
|
allocationQuery.setOrgId(orgId);
|
|
|
|
|
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
|
|
|
|
|
|
|
|
|
|
//获取所以的资金账号
|
|
|
|
|
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
|
|
|
|
|
int state = 1;
|
|
|
|
|
//获取添加院校权限,对账号进行限制
|
|
|
|
|
for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(), item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) {
|
|
|
|
|
//后期添加应用开发权限,新增的时候已经有应用添加了
|
|
|
|
|
state = 2;
|
|
|
|
|
} else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) {
|
|
|
|
|
//新增学生账号,应用还没有添加,后面才添加,授权权限的时候获取应用ID设置
|
|
|
|
|
ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery();
|
|
|
|
|
if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司");
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司");
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("投资银行");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) {
|
|
|
|
|
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司");
|
|
|
|
|
|
|
|
|
|
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FINANCIAL_ACCOUNT.getText())) {
|
|
|
|
|
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能理财");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())) {
|
|
|
|
|
List<ResourcesApplication> resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(resourcesApplicationList)) {
|
|
|
|
|
if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) {
|
|
|
|
|
accountAssetAllocation.setApplicationId(item.getTypeId());
|
|
|
|
|
state = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
accountAssetAllocation.setState(state);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(state, 2)) {
|
|
|
|
|
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) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -2L) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) &&
|
|
|
|
|
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())) {
|
|
|
|
|
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
|
|
|
|
|
}
|
|
|
|
|
//在2.0创建基础资金账户
|
|
|
|
|
public void createBaseAccount(Long applicationId, Long oldUserId, Double initialCapital) throws SQLException {
|
|
|
|
|
String sql = "";
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
|
|
String formattedDate = dateFormat.format(currentDate);
|
|
|
|
|
if (applicationId == 4L) {
|
|
|
|
|
sql = "INSERT INTO [dbo].[ExaP2PAssetAllocation]( [ApplicationId], [InitialCapital], [InitialInvestmentCapital], " +
|
|
|
|
|
"[The_Total_AssetsOf], [AvailableFunds], [InvestmentFunds], " +
|
|
|
|
|
"[Borrowed_Funds], [Freeze_Funds], [Cumulative_of_return], [TotalAssets_Rate_Return], " +
|
|
|
|
|
"[Return_on_equity], [TotalDailyInvestment], [TotalWeeklyInvestment], " +
|
|
|
|
|
"[TotalMonthlyInvestment], [UserId], [IsDeleted], [DeleterUserId], " +
|
|
|
|
|
"[DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], " +
|
|
|
|
|
"[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, " +
|
|
|
|
|
"0, 0, 0, 0, " + oldUserId + ", " +
|
|
|
|
|
"'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
|
|
|
|
|
} else if (applicationId == 5L) {
|
|
|
|
|
sql = "INSERT INTO [dbo].[ExaTheRaiseAssetAllocation]([ApplicationId], [InitialCapital], [InitialInvestmentCapital], " +
|
|
|
|
|
"[The_Total_AssetsOf], [AvailableFunds], [InvestmentFunds], " +
|
|
|
|
|
"[TheTotalAmountOfTheRaise], [TheTotalAmountOfFrozen], [Cumulative_of_return], [ReturnOnInvestmentOwnCapital], " +
|
|
|
|
|
"[ReturnOnCrowdfundingInvestment], [UserId], [IsDeleted], [DeleterUserId], [DeletionTime], " +
|
|
|
|
|
"[LastModificationTime], [LastModifierUserId], [CreationTime], " +
|
|
|
|
|
"[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, 0, " +
|
|
|
|
|
"" + oldUserId + ", '0', " +
|
|
|
|
|
"NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
|
|
|
|
|
} else if (applicationId == 16L || applicationId == -16L) {
|
|
|
|
|
Integer secType;
|
|
|
|
|
secType = applicationId == 16L ? 1 : 4;
|
|
|
|
|
sql = "INSERT INTO [dbo].[ExaMNJYAssetAllocation]( [ApplicationId], [InitialCapital], " +
|
|
|
|
|
"[InitialInvestmentCapital], [TotalAssets], [AvailableFunds], [Market_value], [Accumulative_total_profit_and_loss], " +
|
|
|
|
|
"[Cumulative_rate_of_return], [Annualized_rate_of_return], [Kumar_ratio], [Sharpe_ratio], " +
|
|
|
|
|
"[The_biggest_back_test], [Asset_Investment_Rate], [Return_on_equity], [UserId], " +
|
|
|
|
|
"[SecType], [IsDeleted], [DeleterUserId], [DeletionTime], [LastModificationTime], " +
|
|
|
|
|
"[LastModifierUserId], [CreationTime], [CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, 0, " +
|
|
|
|
|
"0, 0, 0, " + oldUserId + ", " + secType + ", '0', NULL, NULL, '" + formattedDate + "', NULL, '" + formattedDate + "', " + oldUserId + ")";
|
|
|
|
|
} else if (applicationId == 18L) {
|
|
|
|
|
sql = "INSERT INTO [dbo].[ExaPEVCAssetAllocation]([ApplicationId], [InitialInvestmentCapital], " +
|
|
|
|
|
"[InitialCapital], [TotalAssets], [InvestmentFunds], [LPAmount], [LPInvestmentAmount], " +
|
|
|
|
|
"[GPInvestmentAmount], [LhAmount], [FreeMoney], [Bank_loan], [BankInvestmentFunds], " +
|
|
|
|
|
"[FreeInvestment_funds], [Return_On_investment], [Return_on_net_asset_investment], " +
|
|
|
|
|
"[Return_on_total_assets], [UserId], [IsDeleted], [DeleterUserId], [DeletionTime], " +
|
|
|
|
|
"[LastModificationTime], [LastModifierUserId], [CreationTime], [CreatorUserId]) " +
|
|
|
|
|
"VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", "
|
|
|
|
|
+ initialCapital + ", 0, 0, 0, 0, 0, " + initialCapital + ", 0, 0, 0, 0, 0, 0, " + oldUserId + ", " +
|
|
|
|
|
"'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
|
|
|
|
|
sendPostRequest("http://120.79.161.177:8029/Account/InsertPevcFunding", "UserId=" + oldUserId);
|
|
|
|
|
}
|
|
|
|
|
runJdbc(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 激活该校的所有学生用户的股票/期货账户
|
|
|
|
|
*
|
|
|
|
|
* @param orgId
|
|
|
|
|
*/
|
|
|
|
|
public void allOpenAccount(Long orgId) {
|
|
|
|
|
|
|
|
|
|
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
|
|
|
|
|
allocationQuery.setOrgId(orgId);
|
|
|
|
|
allocationQuery.setState(1);
|
|
|
|
|
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
|
|
|
|
|
|
|
|
|
|
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
|
|
|
|
|
accountAssetAllocation.setState(2);
|
|
|
|
|
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());
|
|
|
|
|
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
|
|
|
|
|
}
|
|
|
|
|
//运行jdbc
|
|
|
|
|
public void runJdbc(String sql) throws SQLException {
|
|
|
|
|
Connection conn = openConn();
|
|
|
|
|
PreparedStatement ps = conn.prepareStatement(sql);
|
|
|
|
|
ps.executeUpdate();
|
|
|
|
|
closeConn(conn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转账
|
|
|
|
|
*
|
|
|
|
@ -737,22 +837,30 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
updateQuery.setStudentId(studentId);
|
|
|
|
|
List<StudentAccountAssetAllocation> updateAccount = studentAccountAssetAllocationDao.getValuesByQuery(updateQuery);
|
|
|
|
|
StudentAccountAssetAllocation allocation = updateAccount.get(0);
|
|
|
|
|
studentAccountEquityInvestmentSystemService.updateByTransfer(allocation.getAvailableFunds(),allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(),
|
|
|
|
|
studentAccountEquityInvestmentSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(),
|
|
|
|
|
allocation.getInitialInvestmentCapital(), allocation.getInitialInvestmentCapital(), studentId);
|
|
|
|
|
String sql = "update ExaPEVCAssetAllocation set FreeMoney =" + allocation.getAvailableFunds()
|
|
|
|
|
+ " where UserId = " + coreUser.getOldId() + "";
|
|
|
|
|
try{
|
|
|
|
|
runJdbc(sql);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (outAccountAssetAllocation.getApplicationId() == 4 || toAccountAssetAllocation.getApplicationId() == 4) {
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, 4);
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (outAccountAssetAllocation.getApplicationId() == 5 || toAccountAssetAllocation.getApplicationId() == 5) {
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, 5);
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (outAccountAssetAllocation.getApplicationId() == 16 || toAccountAssetAllocation.getApplicationId() == 16) {
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, 16);
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 16);
|
|
|
|
|
}
|
|
|
|
|
if (outAccountAssetAllocation.getApplicationId() == -16 || toAccountAssetAllocation.getApplicationId() == -16) {
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, -16);
|
|
|
|
|
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), -16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
@ -760,7 +868,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个方法来执行更新子系统资产表操作
|
|
|
|
|
public void updateStudentAccountByApplicationId(long studentId, int applicationId) {
|
|
|
|
|
public void updateStudentAccountByApplicationId(long studentId, Long oldUserId, int applicationId) {
|
|
|
|
|
StudentAccountAssetAllocationQuery updateQuery = new StudentAccountAssetAllocationQuery();
|
|
|
|
|
updateQuery.setApplicationId((long) applicationId);
|
|
|
|
|
updateQuery.setStudentId(studentId);
|
|
|
|
@ -770,15 +878,43 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
switch (applicationId) {
|
|
|
|
|
case 4:
|
|
|
|
|
studentAccountP2pSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId);
|
|
|
|
|
String sql = "update ExaP2PAssetAllocation set AvailableFunds =" + allocation.getAvailableFunds() + " ," +
|
|
|
|
|
"InitialCapital = " + allocation.getInitialCapital() + " , InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId = " + oldUserId + "";
|
|
|
|
|
try {
|
|
|
|
|
runJdbc(sql);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
studentAccountCrowdfundingSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId);
|
|
|
|
|
String sql1 = "update ExaTheRaiseAssetAllocation set AvailableFunds = " + allocation.getAvailableFunds() + ",InitialCapital = " + allocation.getInitialCapital() + "," +
|
|
|
|
|
"InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId =" + oldUserId + " ";
|
|
|
|
|
try {
|
|
|
|
|
runJdbc(sql1);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
studentAccountMockTradingSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId, Long.valueOf(16));
|
|
|
|
|
String sql2 = "update ExaMNJYAssetAllocation set AvailableFunds =" + allocation.getAvailableFunds() + " ,InitialCapital= " + allocation.getInitialCapital() + ", " +
|
|
|
|
|
"InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId =" + oldUserId + " and ApplicationId = 16";
|
|
|
|
|
try {
|
|
|
|
|
runJdbc(sql2);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case -16:
|
|
|
|
|
studentAccountMockTradingSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId, Long.valueOf(-16));
|
|
|
|
|
String sql3 = "update ExaMNJYAssetAllocation set AvailableFunds =" + allocation.getAvailableFunds() + " ,InitialCapital= " + allocation.getInitialCapital() + ", " +
|
|
|
|
|
"InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId =" + oldUserId + " and ApplicationId = -16";
|
|
|
|
|
try {
|
|
|
|
|
runJdbc(sql3);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|